Resources Numerical accuracy

Calculations

Every calculation under our calculation policies: what it works out, its formula and the precision it runs at. Open one to see its code as it is in the released app.

  • 6,917 calculations in 1,248 source files
  • 143 exact
  • 6,286 in 64-bit
  • 335 with a 32-bit step
  • Last reviewed

Calculations

  • Depth at a point

    The depth of water at a plan point.

    depth = WS − ground

    Flood extent on the ground surface river-extent.js
    • CivilCraft
    64-bit
  • Waterline point on a triangle edge

    Where the depth is zero along an edge between a wet corner and a dry corner.

    u = d_a ÷ (d_a − d_b); point = a + u × (b − a)

    Flood extent on the ground surface river-extent.js
    • CivilCraft
    64-bit
  • Flooded area and greatest depth

    Adds up the wet part of each triangle and tracks the greatest depth at a corner.

    piece area = |Σ (x_i·y_j − x_j·y_i)| ÷ 2; area = Σ piece areas

    Flood extent on the ground surface river-extent.js
    • CivilCraft
    64-bit
  • Barrel flow area and top width

    The flow area, water surface width and full-barrel hydraulic radius of one culvert barrel at a given depth.

    circle: θ = 2·acos((r − y) ÷ r); A = r²(θ − sin θ) ÷ 2; T = 2√(y(D − y)); R = D ÷ 4. box: A = B·y; R = B·D ÷ (2(B + D))

    Culverts, bridges and junctions in a river model river-structures.js
    • CivilCraft
    64-bit
  • Critical depth in a barrel

    The depth at which the flow in one barrel is critical, capped at the rise.

    Q²·T(y) − g·A(y)³ = 0

    Culverts, bridges and junctions in a river model river-structures.js
    • CivilCraft
    64-bit
  • Headwater for one barrel's flow

    The inlet-control and outlet-control headwater depths for a flow in one barrel, and which one governs.

    HWw = (Q ÷ (Cw·B))^(2/3); HWo = Q² ÷ (Cd²·A²·2g) + D ÷ 2; φ = clamp((HWo ÷ D − 1) ÷ 0.5, 0, 1); HWin = (1 − φ)·HWw + φ·HWo; Kf = 2g·n²·L ÷ (k²·R^(4/3)); HWout = (1 + Ke + Kf)·V² ÷ 2g + ho − L·S₀

    Culverts, bridges and junctions in a river model river-structures.js
    • CivilCraft
    64-bit
  • Culvert headwater with road overtopping

    The headwater at which the flow through the barrels plus the flow over the road equals the total flow.

    n·Qbarrel(HW) + Cr·Lr·(HW − crest)^1.5 = Q

    Culverts, bridges and junctions in a river model river-structures.js
    • CivilCraft
    64-bit
  • Bridge opening section

    The downstream cross-section clipped to the abutments, with each pier as a strip that carries no flow.

    z(o) = z₀ + (o − o₀) ÷ (o₁ − o₀) × (z₁ − z₀)

    Culverts, bridges and junctions in a river model river-structures.js
    • CivilCraft
    64-bit
  • Water surface above a bridge

    The water surface in the opening and at the section above the bridge, in low flow, pressure flow or flow over the deck.

    WS + α·Q² ÷ (2g·A²) = E₀ + L·(Q ÷ ((K₁ + K₂) ÷ 2))² + c·|Δ velocity head|; pressure: Q = Cd·An·√(2g·head); deck: Q = Cw·L·(EGL − deck)^1.5

    Culverts, bridges and junctions in a river model river-structures.js
    • CivilCraft
    64-bit
  • Stepping a profile across a structure

    Takes the water surface below a structure, works out the level above it and uses that as the start of the next reach upstream.

    TW = max(0, WSd − invert down); WSu = invert up + HW

    Culverts, bridges and junctions in a river model river-structures.js
    • CivilCraft
    64-bit
  • Flows and water levels at a junction

    Adds the flows of the reaches that join and carries the water surface at the head of the downstream reach up to them.

    Q = Σ Q of the joining reaches; WS of each joining reach's downstream end = WS at the head of the reach below

    Culverts, bridges and junctions in a river model river-structures.js
    • CivilCraft
    64-bit
  • Area and conveyance table of a section

    Flow area and conveyance of one cross-section as functions of water level, read from a table.

    levels hᵢ = h₀ + (hi − h₀)·(i ÷ 200)²; between levels: linear interpolation; below h₀: A·f, K·f^1.6667 with f = depth ÷ (h₀ − bed)

    Unsteady flow routing down a river river-unsteady.js
    • CivilCraft
    64-bit
  • Banded linear solve

    Solves the Newton step for all sections at once.

    L·U·x = b with row pivoting inside the band

    Unsteady flow routing down a river river-unsteady.js
    • CivilCraft
    64-bit
  • Continuity and momentum residuals of one interval

    The two equations that must be zero between a pair of neighboring sections for one time step.

    continuity: Δ(Aᵢ + Aⱼ) ÷ (2Δt) + (θ·ΔQ_new + (1 − θ)·ΔQ_old) ÷ Δx; momentum: Δ(Qᵢ + Qⱼ) ÷ (2Δt) + Δ(Q|Q| ÷ A) ÷ Δx + g·Ā·Δh ÷ Δx + g·Ā·S̄f, Sf = Q|Q| ÷ K²

    Unsteady flow routing down a river river-unsteady.js
    • CivilCraft
    64-bit
  • Newton iteration for one time step

    Finds the water levels and flows at the end of a time step.

    J·Δu = −F; J by forward differences with steps 1e-6·Href and 1e-6·Qref; stop when max(|Δh| ÷ Href, |ΔQ| ÷ Qref) < 1e-8

    Unsteady flow routing down a river river-unsteady.js
    • CivilCraft
    64-bit
  • Time stepping, peaks and Froude check

    Advances the run step by step, records the peak level and flow at each section and flags supercritical flow.

    V_in += Δt·(θ·Q_new + (1 − θ)·Q_old); T ≈ (A(h + 0.001·Href) − A(h)) ÷ (0.001·Href); flag when |Q| ÷ A > √(g·A ÷ T)

    Unsteady flow routing down a river river-unsteady.js
    • CivilCraft
    64-bit
  • Volume balance error

    The share of water not accounted for between inflow, outflow and the change of storage in the reach.

    storage = Σ ½(Aᵢ + Aᵢ₊₁)·Δxᵢ; error = (V_in − V_out − (S₁ − S₀)) ÷ max(V_in, V_out, |S₁ − S₀|, 1e-12)

    Unsteady flow routing down a river river-unsteady.js
    • CivilCraft
    64-bit
  • Gravity and Manning constant per unit system

    The gravity and the Manning equation constant every river calculation uses.

    m: k = 1, g = 9.80665; ft: k = 1.486, g = 32.174

    River model: stations, cut sections and reach lengths river.js
    • CivilCraft
    64-bit
  • River station of a point

    The station of a point, measured along the centerline from its downstream end, and its offset to the side.

    rs = L − d

    River model: stations, cut sections and reach lengths river.js
    • CivilCraft
    64-bit
  • Cross-section from a cut line

    Turns a line drawn across the river into a cross-section: station, ground points by offset, and first bank positions.

    rs = round₆(L − d_crossing); o = round₆(offset); banks = lowest point ± bank distance, clipped to the section

    River model: stations, cut sections and reach lengths river.js
    • CivilCraft
    64-bit
  • Sections at a spacing along the centerline

    Cuts square cross-sections every set distance along the centerline and at both ends.

    dₖ = k × spacing while k × spacing < L − 1e-9; rs = round₆(L − dₖ)

    River model: stations, cut sections and reach lengths river.js
    • CivilCraft
    64-bit
  • Reach lengths between sections

    The channel and overbank distances from each section to the next one downstream.

    channel = rsᵢ − rsᵢ₋₁; overbank = √(Δx² + Δy²) between the middles of the overbank parts of the two cut lines

    River model: stations, cut sections and reach lengths river.js
    • CivilCraft
    64-bit
  • Flow at a station

    The flow that applies at a station, from the profile's flow and its flow changes.

    River model: stations, cut sections and reach lengths river.js
    • CivilCraft
    64-bit
  • First guess of the boundary slope

    The slope offered for a normal-depth boundary when one is first chosen, from the lowest points of the end sections.

    S = (z_min upstream − z_min downstream) ÷ (rs upstream − rs downstream), to 3 significant digits; 0.001 when S ≤ 1e-5

    River model: stations, cut sections and reach lengths river-ui.js
    • CivilCraft
    64-bit
  • Least-cost search

    Searches the grid for the cheapest allowed path and returns its points and total cost.

    grade = |z₂ − z₁| ÷ length ≤ limit; cost = length × unit cost × factor × (1 + w·(grade ÷ limit)²) + area × length × earth cost

    Best route across the terrain route.js
    • CivilCraft
    32-bit in part
  • Path points and their elevations

    Turns the chain of grid cells into the route's points, with the two ends at the picked points and collinear points removed.

    x = minX + (i + 0.5) × cell; collinear when |cross product| < 1e-9 × cell²

    Best route across the terrain route.js
    • CivilCraft
    32-bit in part
  • Route length, steepest grade and earthwork

    The length, steepest grade, cut and fill along a finished route.

    length = Σ √(Δx² + Δy²); grade = |Δz| ÷ l; s = |z_left − z_right| ÷ width; area = width²·s ÷ 4 ÷ max(0.05, 1 − sideSlope·s); volume += area × l ÷ n

    Best route across the terrain route.js
    • CivilCraft
    64-bit
  • Curve radius at each bend

    The turn angle and the radius implied at each bend of the route.

    turn = atan2 of the leg after − atan2 of the leg before, wrapped to (−π, π]; radius = (l₁ + l₂) ÷ (2|turn|)

    Best route across the terrain route.js
    • CivilCraft
    64-bit
  • Route profile

    Distance along the route against elevation, for the profile drawing and the point table.

    dᵢ = dᵢ₋₁ + √(Δx² + Δy²)

    Best route across the terrain route.js
    • CivilCraft
    64-bit
  • Sample stations

    The stations where sections are cut: every multiple of the step, both ends, the curve ends and any extra stations.

    sta = round₆(k × step) for whole k; neighbors closer than 1e-6 merged

    Cross sections and end-area volumes along an alignment sections.js
    • CivilCraft
    64-bit
  • Sample line at a station

    The two ends of the line square to the alignment at a station.

    right = (sin dir, −cos dir); a = c − right × left; b = c + right × right offset

    Cross sections and end-area volumes along an alignment sections.js
    • CivilCraft
    64-bit
  • Surface along a sample line

    The ground or design line along a sample line, with a point at every triangle edge it crosses.

    z at a + (b − a)·t for every edge-crossing parameter t; o = offA + (offB − offA)·t

    Cross sections and end-area volumes along an alignment sections.js
    • CivilCraft
    64-bit
  • Segment crossing parameter

    Where one segment crosses another, as a fraction along the first.

    den = r × s; t = ((q − p) × s) ÷ den; u = ((q − p) × r) ÷ den

    Cross sections and end-area volumes along an alignment sections.js
    • CivilCraft
    64-bit
  • Elevation of a section line at an offset

    The elevation of a section at any offset, between its points.

    z = z₀ + (z₁ − z₀)·(o − o₀) ÷ (o₁ − o₀)

    Cross sections and end-area volumes along an alignment sections.js
    • CivilCraft
    64-bit
  • Cut and fill area of a section

    The area of cut and of fill between the ground line and the design line of one section.

    per interval: area = (e₀ + e₁) ÷ 2 × w; where the lines cross: o× = o₀ + w·e₀ ÷ (e₀ − e₁), two triangles

    Cross sections and end-area volumes along an alignment sections.js
    • CivilCraft
    64-bit
  • Feature line crossings

    The offset and elevation where each corridor feature line crosses the sample line.

    o = −left + (left + right)·t; z = z_p + (z_q − z_p)·u

    Cross sections and end-area volumes along an alignment sections.js
    • CivilCraft
    64-bit
  • Spans inside the graded regions

    The parts of a sample line that lie inside the graded regions, which is where the design counts.

    Cross sections and end-area volumes along an alignment sections.js
    • CivilCraft
    64-bit
  • Volumes between sections

    Cut and fill volume between neighboring sections and the running totals.

    V = (A₁ + A₂) ÷ 2 × (sta₂ − sta₁); cumulative = Σ V

    Cross sections and end-area volumes along an alignment sections.js
    • CivilCraft
    64-bit
  • Section table as CSV

    Writes station, areas, volumes and running totals to a CSV file.

    areas to 2 decimals; volumes to 1 decimal; feet projects: volume ÷ 27 (cubic yards)

    Cross sections and end-area volumes along an alignment sections.js
    • CivilCraft
    64-bit
  • US gallon in cubic feet

    The factor that turns gallons into cubic feet in feet projects.

    1 gal = 0.133680556 ft³

    Sanitary sewer design flows and pipe sizes sewer.js
    • CivilCraft
    64-bit
  • Peaking factor

    The ratio of peak to average sanitary flow for a population.

    Harmon: 1 + 14 ÷ (4 + √P); Babbitt: 5 ÷ P^0.2; P in thousands; held between pfMin and pfMax

    Sanitary sewer design flows and pipe sizes sewer.js
    • CivilCraft
    64-bit
  • Average flow from people

    People times per-person daily flow, in project flow units.

    m: P × L/day ÷ 1000 ÷ 86400; ft: P × gal/day × 0.133680556 ÷ 86400

    Sanitary sewer design flows and pipe sizes sewer.js
    • CivilCraft
    64-bit
  • Infiltration flow

    Tributary area times the infiltration allowance, in project flow units.

    m: ha × L/s per ha ÷ 1000; ft: ac × gal/day per ac × 0.133680556 ÷ 86400

    Sanitary sewer design flows and pipe sizes sewer.js
    • CivilCraft
    64-bit
  • Design flow, slope and velocity per pipe

    For each pipe in flow order: the people and area above it, the peak flow, the slope, the full capacity, the normal depth and the velocity.

    S = (inv up − inv down) ÷ length; Q = q_dom × pf + q_inf; ratio = Q ÷ Q_full; V = Q ÷ A(yn)

    Sanitary sewer design flows and pipe sizes sewer.js
    • CivilCraft
    64-bit
  • Pipe size for the design flow

    The smallest listed pipe size whose allowed share of full capacity carries the design flow.

    first size with Q_full(size) × maxFull ≥ Q

    Sanitary sewer design flows and pipe sizes sewer.js
    • CivilCraft
    64-bit
  • Catchment runoff hydrograph

    The runoff from one catchment at each time step for a constant storm.

    q(t) = k·C·A·(depth(t) − depth(t − w)) ÷ w; depth(τ) = i·clamp(τ, 0, duration); k = 1 ÷ 360 (m), 1 (ft)

    Storm hydrographs routed through the pipe network storm-route.js
    • CivilCraft
    64-bit
  • Muskingum coefficients

    The three weights of the routing equation for a reach.

    d = K(1 − X) + Δt ÷ 2; c₀ = (−KX + Δt ÷ 2) ÷ d; c₁ = (KX + Δt ÷ 2) ÷ d; c₂ = (K(1 − X) − Δt ÷ 2) ÷ d

    Storm hydrographs routed through the pipe network storm-route.js
    • CivilCraft
    64-bit
  • Routing one reach

    The outflow hydrograph of a pipe from its inflow hydrograph.

    O₂ = max(0, c₀·I₂ + c₁·I₁ + c₂·O₁) on a step of max(Δt, 2KX); values between steps by linear interpolation

    Storm hydrographs routed through the pipe network storm-route.js
    • CivilCraft
    64-bit
  • Travel time and weighting of each pipe

    The routing constants K and X of each pipe from its length, slope and rational peak flow.

    c = 1.5 × max(V, 0.1); K = L ÷ c ÷ 60; X = clamp(½(1 − Q ÷ (T·S·c·L)), 0, ½)

    Storm hydrographs routed through the pipe network storm-route.js
    • CivilCraft
    64-bit
  • Summing flows and reading peaks

    Adds the hydrographs arriving at each structure and reads each pipe's peak in, peak out, attenuation and share of capacity.

    att = max(0, 1 − peak out ÷ peak in); ratio = peak out ÷ capacity; over when peak out > capacity × (1 + 1e-9)

    Storm hydrographs routed through the pipe network storm-route.js
    • CivilCraft
    64-bit

A calculation is added only after its source was read. Each statement can be checked in the code shown on its policy's page; the app repositories are public. When a release changes a calculation, its page says so until it has been read again.