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.
Calculations
-
Depth at a point
The depth of water at a plan point.
depth = WS − ground
Flood extent on the ground surface river-extent.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js32-bit in part- CivilCraft
-
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.js32-bit in part- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
-
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.js64-bit- CivilCraft
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.