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
-
Rain depth of a storm
The total depth of rain over the storm's duration.
depth (mm) = Σ i × Δt ÷ 60
Rain on the ground: overland flow, ponding and outflow rain.js64-bit- CivilCraft
-
Design storm by alternating blocks
Builds a storm from an intensity-duration curve with the heaviest block in the middle.
depth_k = idf(k·Δt) × k·Δt ÷ 60 − depth_(k−1); i_k = depth_k × 60 ÷ Δt
Rain on the ground: overland flow, ponding and outflow rain.js64-bit- CivilCraft
-
Time step
The length of each simulation step.
dt = min(dt_max, α × Δx ÷ √(g × max(h_max, 0.01)))
Rain on the ground: overland flow, ponding and outflow rain.js64-bit- CivilCraft
-
Flow across a cell face
The unit flow between two neighboring cells for one time step.
q = (q − g·h_f·dt·Δη ÷ Δx) ÷ (1 + g·dt·n²·|q| ÷ h_f^(7/3)); |q| ≤ h_f·√(g·h_f)
Rain on the ground: overland flow, ponding and outflow rain.js64-bit- CivilCraft
-
Flow leaving at an open edge
The unit flow out of the grid at an open edge or beside a hole in the ground.
q = h^(5/3) × √S ÷ n, S = max(edge slope, bed slope to the cell behind); q ≤ h·√(g·h)
Rain on the ground: overland flow, ponding and outflow rain.js64-bit- CivilCraft
-
Keeping depths from going negative
Scales the outflows of a cell so it cannot give away more water than it has.
when Σ out × dt ÷ Δx > available: out ← out × available ÷ (Σ out × dt ÷ Δx)
Rain on the ground: overland flow, ponding and outflow rain.js64-bit- CivilCraft
-
New depth, deepest water, fastest flow and first-wet time
Updates each cell's depth and records its greatest depth, greatest speed and the time it first got wet.
h ← h + rain − losses + (dt ÷ Δx) × (q_W − q_E + q_S − q_N); speed = |q| ÷ h
Rain on the ground: overland flow, ponding and outflow rain.js32-bit in part- CivilCraft
-
Where the records are kept
Sets up the arrays that hold the per-cell maximum depth, maximum speed and first-wet time.
Rain on the ground: overland flow, ponding and outflow rain.js32-bit in part- CivilCraft
-
Drains
Takes water out of a drain's cell up to its capacity each step.
take = min(capacity × dt, depth × cell area)
Rain on the ground: overland flow, ponding and outflow rain.js64-bit- CivilCraft
-
Volumes of rain, loss and outflow
Adds each step's rain, losses and outflow to the running totals.
out += Σ q × Δx × dt; rain += Σ depth of rain × cell area
Rain on the ground: overland flow, ponding and outflow rain.js64-bit- CivilCraft
-
Mass balance and the results
The stored volume, the mass balance error, the pond volumes at the end and the peak outflow.
error = (rain − loss − out − drained − stored) ÷ rain
Rain on the ground: overland flow, ponding and outflow rain.js64-bit- CivilCraft
-
Section prepared for the solver
Splits a cross section at the banks, roughness changes and ineffective areas, and adds a point at each split.
z(o) = z_p + (z_q − z_p) × (o − o_p) ÷ (o_q − o_p)
River water surface profiles by the standard step method river-solve.js64-bit- CivilCraft
-
Area, wetted perimeter, conveyance and velocity coefficient
The hydraulic properties of a section at a water level.
A = Σ (d_a + d_b) ÷ 2 × Δo; P = Σ hypot(Δo, Δz); K = (k ÷ n) × A × (A ÷ P)^(2/3); n_c = (Σ P_i·n_i^1.5 ÷ P)^(2/3); α = max(1, A²·Σ(K_i³ ÷ A_i²) ÷ K³)
River water surface profiles by the standard step method river-solve.js64-bit- CivilCraft
-
Root finding
Solves the energy balance for the water level between two bracketing levels.
stop when |bracket ÷ 2| ≤ 2ε|x| + tol ÷ 2, tol = 1e-6
River water surface profiles by the standard step method river-solve.js64-bit- CivilCraft
-
Minimum search
Refines the level of least specific energy.
River water surface profiles by the standard step method river-solve.js64-bit- CivilCraft
-
Specific energy
The energy level at a section for a water level and a flow.
E = WS + α·Q² ÷ (2g·A²)
River water surface profiles by the standard step method river-solve.js64-bit- CivilCraft
-
Critical water surface
The water level of least specific energy at a section.
River water surface profiles by the standard step method river-solve.js64-bit- CivilCraft
-
Normal depth boundary
The water level at which the section carries the flow at a given energy slope.
K(WS) = Q ÷ √S
River water surface profiles by the standard step method river-solve.js64-bit- CivilCraft
-
Velocity head and flow split
The velocity head, energy level and the flow in the left overbank, channel and right overbank.
h_v = α·Q² ÷ (2g·A²); Q_part = Q × K_part ÷ K
River water surface profiles by the standard step method river-solve.js64-bit- CivilCraft
-
Energy loss between two sections
The friction loss and the contraction or expansion loss over a reach.
L = (L_lob·Q_lob + L_ch·Q_ch + L_rob·Q_rob) ÷ Q; S_f = ((Q₁ + Q₂) ÷ (K₁ + K₂))²; h_e = L·S_f + C·|h_v2 − h_v1|
River water surface profiles by the standard step method river-solve.js64-bit- CivilCraft
-
Results at a section
Depth, velocities, Froude numbers, energy slope and specific force for the results table.
Fr = V ÷ √(g·A ÷ T); S_f = (Q ÷ K)²; specific force = Q² ÷ (g·A) + A·ȳ
River water surface profiles by the standard step method river-solve.js64-bit- CivilCraft
-
Subcritical run
Steps upstream from the downstream boundary, solving each section's water level.
River water surface profiles by the standard step method river-solve.js64-bit- CivilCraft
-
Supercritical run
Steps downstream from the upstream boundary, solving each section's water level below critical depth.
River water surface profiles by the standard step method river-solve.js64-bit- CivilCraft
-
Mixed regime
Keeps, at each section, the subcritical or supercritical answer with the larger specific force, and marks hydraulic jumps.
River water surface profiles by the standard step method river-solve.js64-bit- CivilCraft
-
Decimals in the results table
The number of decimals each result is shown with in the table, the text report and the CSV.
River water surface profiles by the standard step method river-report.js64-bit- CivilCraft
-
Table rows
Formats each section's results for the table and the CSV.
text = v.toFixed(d)
River water surface profiles by the standard step method river-report.js64-bit- CivilCraft
-
Water surface at a plan point
The water level at any point from the results at the sections either side.
rs = centerline length − distance along; WS = WS_a + (WS_b − WS_a) × (rs − rs_a) ÷ (rs_b − rs_a)
Flood extent on the ground surface river-extent.js64-bit- CivilCraft
-
Behind a levee
Whether a point is kept dry by a levee the water does not top.
offset and crest interpolated between the two sections; dry when beyond the levee and WS < crest
Flood extent on the ground surface river-extent.js64-bit- CivilCraft
-
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
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.