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

  • Plan turned along the alignment

    Where each plan point lands on a plan-and-profile sheet, turned so the stretch runs left to right.

    q = R(−θ)·(p − p_a); x_mm = x₀ + q_x·s; y_mm = c_y + (q_y − y_mid)·s

    Plan sheets and plan-and-profile sheets as PDF pp-sheets.js
    • CivilCraft
    64-bit
  • Profile grid and scales

    The station and elevation grid of the profile and the mapping from station and elevation to paper.

    X = x₀ + (sta − a)·s; Y = y₀ + (z − z₀)·s·exaggeration; z₀ = ⌊(z_mid − span ÷ 2) ÷ step⌋ × step

    Plan sheets and plan-and-profile sheets as PDF pp-sheets.js
    • CivilCraft
    64-bit
  • Vertical scale label

    The vertical scale printed in the title strip.

    meters: 1:round(1000 ÷ s_v); feet: 1 in = (25.4 ÷ s_v) ft to 1 decimal

    Plan sheets and plan-and-profile sheets as PDF pp-sheets.js
    • CivilCraft
    64-bit
  • Volumes done, remaining and percent complete

    For each survey: cut and fill done, what remains, over-cut, over-fill, stockpiles, digs and percent complete.

    cut done = Σ clamp(E − A, 0, E − D)·A_cell; fill done = Σ clamp(A − E, 0, D − E)·A_cell; percent = 100 × (cut done + fill done) ÷ planned

    Earthwork progress from repeat surveys progress.js
    • CivilCraft
    64-bit
  • Forecast finish date

    The date the work reaches 100 percent at the pace of the last surveys.

    slope = Σ (t − t̄)(p − p̄) ÷ Σ (t − t̄)²; t_end = t_last + (100 − p_last) ÷ slope

    Earthwork progress from repeat surveys progress.js
    • CivilCraft
    64-bit
  • Scheduled percent on a date

    The planned percent complete on a date, between the schedule's points.

    p = p₀ + (p₁ − p₀) × (t − t₀) ÷ (t₁ − t₀)

    Earthwork progress from repeat surveys progress.js
    • CivilCraft
    64-bit
  • Gravity and unit constants

    The constants behind cant and unit conversion.

    g = 9.81; km/h per mph = 1.609344; meters per foot = 1200 ÷ 3937

    Railway cant, cant ramps and track quantities rail.js
    • CivilCraft
    64-bit
  • Speed and length conversions

    Converts a speed to km/h, a project length to meters and millimeters to project units.

    km/h = mph × 1.609344; m = ft × 1200 ÷ 3937; project = mm ÷ 1000 (÷ meters per foot)

    Railway cant, cant ramps and track quantities rail.js
    • CivilCraft
    64-bit
  • Equilibrium cant

    The cant at which a train at the design speed puts equal load on both rails.

    E = G × v² ÷ (g × R), v = V ÷ 3.6

    Railway cant, cant ramps and track quantities rail.js
    • CivilCraft
    64-bit
  • Cant ramp shapes

    How the cant rises from 0 to full along a ramp for each transition kind.

    linear u; Bloss u²(3 − 2u); Helmert 2u² then 1 − 2(1 − u)²; cosine (1 − cos πu) ÷ 2; sine u − sin(2πu) ÷ 2π

    Railway cant, cant ramps and track quantities rail.js
    • CivilCraft
    64-bit
  • Steepest slope of each ramp shape

    The factor that turns the average cant gradient of a ramp into its steepest gradient.

    linear 1; Bloss 1.5; Helmert 2; cosine π ÷ 2; sine 2

    Railway cant, cant ramps and track quantities rail.js
    • CivilCraft
    64-bit
  • Rail heights from cant

    Each rail's height above the profile for an applied cant and a pivot rule.

    center: ∓E ÷ 2; inner rail fixed: 0 and E; low rail fixed: max(0, ±E)

    Railway cant, cant ramps and track quantities rail.js
    • CivilCraft
    64-bit
  • Cant ramp gradient and rate

    The steepest cant gradient of each ramp in mm per meter and the rate of change of cant in mm per second.

    gradient = |E| ÷ length (m) × peak factor; rate = gradient × v; ramp on a straight: length = |E| ÷ gradient limit

    Railway cant, cant ramps and track quantities rail.js
    • CivilCraft
    64-bit
  • Cant, deficiency and excess checks

    Compares the applied cant, the cant deficiency and the cant excess with the limits.

    deficiency = E_eq − E; excess = E − E_eq(slowest train); flagged when over the limit + 1e-9

    Railway cant, cant ramps and track quantities rail.js
    • CivilCraft
    64-bit
  • Cant segments along the alignment

    The cant layout as constant and ramp segments, with each rail's height at both ends of each.

    Railway cant, cant ramps and track quantities rail.js
    • CivilCraft
    64-bit
  • Cant at a station

    The applied cant and each rail's height at any station.

    u = (sta − ramp start) ÷ ramp length; E = cant × g(u) on the way in, cant × (1 − g(u)) on the way out

    Railway cant, cant ramps and track quantities rail.js
    • CivilCraft
    64-bit
  • Track cross section

    The rails, sleeper, ballast and sub-ballast outline square to the alignment, and the ballast and sub-ballast areas.

    slope = (h_R − h_L) ÷ base; toe distance d = (z_shoulder − z₀ + |o|·fall) ÷ (1 ÷ ballast slope − fall)

    Railway cant, cant ramps and track quantities rail.js
    • CivilCraft
    64-bit
  • Area of a section polygon

    The area of the ballast or sub-ballast outline in the cross section.

    A = Σ (o_i·z_j − o_j·z_i) ÷ 2

    Railway cant, cant ramps and track quantities rail.js
    • CivilCraft
    64-bit
  • Track quantities

    Track and rail lengths, sleeper count and volume, and gross and net ballast and sub-ballast volumes.

    volume = Σ (A_i + A_(i+1)) ÷ 2 × Δsta; sleepers = ⌊length ÷ spacing + 1e-9⌋ + 1; net ballast = gross − sleepers × L × W × (depth − crib)

    Railway cant, cant ramps and track quantities rail.js
    • CivilCraft
    64-bit
  • Gravity and the foot

    The constants the simulation uses.

    g = 9.80665 m/s²; 1 ft = 0.3048 m

    Rain on the ground: overland flow, ponding and outflow rain.js
    • CivilCraft
    Exact
  • Grid from the surface

    Samples the ground surface into square cells in meters.

    n_x = round(W ÷ c), n_y = round(H ÷ c); c = max(W ÷ n_x, H ÷ n_y); z (m) = elevation × meters per unit

    Rain on the ground: overland flow, ponding and outflow rain.js
    • CivilCraft
    64-bit
  • Low spots and what they hold

    Finds each depression, its area, the volume it holds before it spills, its greatest depth and its sill level.

    filled = max(ground, lowest way out); depth = filled − ground; volume = Σ depth × cell²

    Rain on the ground: overland flow, ponding and outflow rain.js
    • CivilCraft
    64-bit
  • 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.js
    • CivilCraft
    64-bit
  • 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.js
    • CivilCraft
    64-bit
  • 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.js
    • CivilCraft
    64-bit
  • 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.js
    • CivilCraft
    64-bit
  • 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.js
    • CivilCraft
    64-bit
  • 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.js
    • CivilCraft
    64-bit
  • 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.js
    • CivilCraft
    32-bit in part
  • 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.js
    • CivilCraft
    32-bit in part
  • 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.js
    • CivilCraft
    64-bit
  • 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.js
    • CivilCraft
    64-bit
  • 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.js
    • CivilCraft
    64-bit
  • 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.js
    • CivilCraft
    64-bit
  • 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.js
    • CivilCraft
    64-bit
  • 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.js
    • CivilCraft
    64-bit
  • Minimum search

    Refines the level of least specific energy.

    River water surface profiles by the standard step method river-solve.js
    • CivilCraft
    64-bit
  • 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.js
    • CivilCraft
    64-bit
  • Critical water surface

    The water level of least specific energy at a section.

    River water surface profiles by the standard step method river-solve.js
    • CivilCraft
    64-bit
  • 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.js
    • CivilCraft
    64-bit
  • 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.js
    • CivilCraft
    64-bit
  • 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.js
    • CivilCraft
    64-bit
  • 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.js
    • CivilCraft
    64-bit
  • 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.js
    • CivilCraft
    64-bit
  • 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.js
    • CivilCraft
    64-bit
  • 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.js
    • CivilCraft
    64-bit
  • 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.js
    • CivilCraft
    64-bit
  • 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.js
    • CivilCraft
    64-bit
  • 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.js
    • CivilCraft
    64-bit
  • 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.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.