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

  • 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
  • Hydrograph as CSV

    Writes a structure's hydrograph as minutes and flow.

    minutes to 3 decimals; flow to 6 decimals

    Storm hydrographs routed through the pipe network storm-route.js
    • CivilCraft
    64-bit
  • Search box around a point

    The longitude and latitude box that holds a radius in meters around a point.

    Δlat = r ÷ 111320; Δlon = r ÷ (111320 × max(0.01, cos lat))

    Address to site: parcel area, distances and shares site-sources.js
    • CivilCraft
    64-bit
  • Ring area

    The signed area of one polygon ring.

    A = ½ Σ (xᵢ·yᵢ₊₁ − xᵢ₊₁·yᵢ)

    Address to site: parcel area, distances and shares site-sources.js
    • CivilCraft
    64-bit
  • Polygon area in square meters

    The area of a polygon with holes, scaled to square meters.

    A = (Σ |outer ring| − Σ |holes|) × kx × ky

    Address to site: parcel area, distances and shares site-sources.js
    • CivilCraft
    64-bit
  • Meters per degree at the site

    The factors that turn longitude and latitude differences into meters, and the search window.

    kx = 111320 × cos(lat); ky = 111320

    Address to site: parcel area, distances and shares site-sources.js
    • CivilCraft
    64-bit
  • Distance to each building

    The distance from the point to each building and the building's footprint area.

    d = √(((cx − x)·kx)² + ((cy − y)·ky)²), c = center of the building's bounding box

    Address to site: parcel area, distances and shares site-sources.js
    • CivilCraft
    64-bit
  • Shares of the parcel by sampling

    The share of the parcel that lies in each zoning district, soil unit and flood zone.

    share = points in the zone ÷ points in the parcel, on a 40 × 40 grid over the parcel's bounding box

    Address to site: parcel area, distances and shares site-sources.js
    • CivilCraft
    64-bit
  • Ground slope under a table

    The slope of the ground under one table, from a plane fitted through its sample points.

    least squares z = a + b·x + c·y on centered points; b = (Sxz·Syy − Syz·Sxy) ÷ d, c = (Syz·Sxx − Sxz·Sxy) ÷ d, d = Sxx·Syy − Sxy²

    Ground-mounted solar arrays on terrain solar.js
    • CivilCraft
    64-bit
  • Table size and the shadow rule

    The width, slant length, plan depth and height of one table, and how fast the winter shadow drops behind a row.

    D = Ls·cos β; H = Ls·sin β; shadow drop per meter = tan(α) ÷ max(0.2, cos Δ)

    Ground-mounted solar arrays on terrain solar.js
    • CivilCraft
    64-bit
  • One table on its piles

    Tests a table position: inside the region, off kept-out ground, not too steep, and how high its lower edge must stand.

    z₀ = max over samples of (z_ground − dq·tan β + clearance); pile = z₀ − z_ground at the lower edge; slope = atan(|gradient|)

    Ground-mounted solar arrays on terrain solar.js
    • CivilCraft
    64-bit
  • Row spacing on the ground

    Steps back from each placed table to the first position where its shadow no longer reaches the next table's lower edge.

    accept when q ≥ q_top + 0.02 and z₀ ≥ z_top − (q − q_top)·tanE − 1e-6; otherwise q += step

    Ground-mounted solar arrays on terrain solar.js
    • CivilCraft
    64-bit
  • Module count and installed power

    The number of modules and the installed power of the array.

    modules = tables × per row × stacked; kWp = round(modules × Wp ÷ 10) ÷ 100

    Ground-mounted solar arrays on terrain solar.js
    • CivilCraft
    64-bit
  • Terrain horizon

    The highest angle of the terrain seen from a point, in each 5 degrees of bearing.

    elevation angle = max over d of atan2(z(d) − (z₀ + observer height), d)

    Ground-mounted solar arrays on terrain solar.js
    • CivilCraft
    64-bit
  • Hours hidden by the horizon

    Marks the hours of the year when the sun is below the terrain horizon as fully shaded before the yield is computed.

    shaded when sun altitude < horizon elevation at round(azimuth ÷ 5) × 5 degrees

    Ground-mounted solar arrays on terrain solar.js
    • CivilCraft
    64-bit
  • Follower behind a leader (tractrix)

    Where a rear axle ends up when the point that pulls it moves along a straight piece.

    α₁ = 2·atan(tan(α₀ ÷ 2) × e^(−d ÷ L)); follower = B + L × (−w turned by α₁)

    Vehicle swept paths swept.js
    • CivilCraft
    64-bit
  • Steady-state turning radii

    The radius each rear axle and hitch runs on when the front axle follows a circle for ever.

    r = √(max(0, R² − L²)); hitch = √(r² + c²)

    Vehicle swept paths swept.js
    • CivilCraft
    64-bit
  • Stepping along the path

    Cuts the path into steps no longer than the step length, with a point and travel direction on every line and arc.

    step = max(0.001, shortest wheelbase ÷ 40); k = ceil(L ÷ step); s = s₀ + L·j ÷ k

    Vehicle swept paths swept.js
    • CivilCraft
    64-bit
  • One step forward or reversing

    Moves every unit of the vehicle for one step: the tractor behind its front axle, each trailer behind its hitch, or the chain pushed from the last axle when reversing.

    heading = atan2(leader − follower); hitch = axle − c·(cos θ, sin θ)

    Vehicle swept paths swept.js
    • CivilCraft
    64-bit
  • Steering angle and limit checks

    The steering angle at each step and the largest steering and articulation angles, checked against the vehicle's limits.

    δ = atan(wheelbase × Δheading ÷ ±Δlength); articulation = heading of the unit ahead − heading of the unit, wrapped to (−π, π]

    Vehicle swept paths swept.js
    • CivilCraft
    64-bit
  • Body corners at a step

    The four corners of a unit's body from its rear axle position and heading.

    corner = axle + a·(cos θ, sin θ) + b·(−sin θ, cos θ)

    Vehicle swept paths swept.js
    • CivilCraft
    64-bit
  • Swept area and outline

    The area the bodies sweep and its outline.

    cell h = narrowest width ÷ 40 (× 1.5 until the grid fits); area = filled cells × h²

    Vehicle swept paths swept.js
    • CivilCraft
    64-bit
  • Alignment as a path with bulges

    Turns an alignment's lines and arcs into the path the vehicle follows.

    bulge = ± tan(Δ ÷ 4)

    Vehicle swept paths swept.js
    • CivilCraft
    64-bit
  • Unit factors

    The factors that turn project units (ft, in, gpm, psi or m, mm, L/s, kPa) into the SI values the solver works in.

    ft = 0.3048 m; in = 0.0254 m; gpm = 6.30902e-5 m³/s; psi per ft = 0.433527; kPa per m = 9.80665

    Water mains network: heads, flows and pressures water.js
    • CivilCraft
    64-bit
  • Pump curve fit

    Turns one or three pump curve points into the head a pump adds at any flow.

    H = H₀ − r·Qⁿ; n = ln((H₀ − H₂) ÷ (H₀ − H₁)) ÷ ln(Q₂ ÷ Q₁); r = (H₀ − H₁) ÷ Q₁ⁿ

    Water mains network: heads, flows and pressures water.js
    • CivilCraft
    64-bit
  • Hazen-Williams head loss

    The friction head loss in a pipe for a given flow, length, diameter and C factor, in SI.

    h = 10.67 × L × |Q|^1.852 ÷ (C^1.852 × D^4.871) × sign(Q)

    Water mains network: heads, flows and pressures water.js
    • CivilCraft
    64-bit
  • Node equations for one pass

    Builds the linear system for the unknown heads from the link coefficients, demands and fixed heads, and solves it.

    Q = P·(Hₐ − H_b) + Y; P = 1 ÷ g; Y = Q − f ÷ g; Σ flows at each node = demand

    Water mains network: heads, flows and pressures water.js
    • CivilCraft
    64-bit
  • Flow update and convergence test

    Updates every link flow from the new heads and decides when the network is solved.

    stop when Σ|Q_new − Q_old| ÷ Σ|Q_new| < 1e−7 and no valve or pump changed status

    Water mains network: heads, flows and pressures water.js
    • CivilCraft
    64-bit
  • Linear solve for the heads

    Solves the symmetric positive definite system for the unknown node heads.

    A = L·Lᵀ, forward and back substitution; or conjugate gradient with z = r ÷ diag(A)

    Water mains network: heads, flows and pressures water.js
    • CivilCraft
    64-bit
  • Heads, pressures, velocities and head loss per 1000

    The numbers shown for each node and pipe, converted back to project units, and the limit checks on them.

    pressure = (H − z) × p factor; v = |Q| ÷ (π D² ÷ 4); loss per 1000 = |Hₐ − H_b| ÷ (L ÷ 1000)

    Water mains network: heads, flows and pressures water.js
    • CivilCraft
    64-bit
  • Available fire flow

    The largest draw at one node that keeps the lowest pressure in the network at or above the residual pressure.

    bisection on the draw: 40 halvings of [lo, hi], each one a full network solve

    Water mains network: heads, flows and pressures water.js
    • CivilCraft
    64-bit
  • Tank levels over time

    Steps the network through the day and moves each tank level by the flow into it.

    level₊ = level + inflow × Δt ÷ (π d² ÷ 4), clamped to [min level, max level]

    Water mains network: heads, flows and pressures water.js
    • CivilCraft
    64-bit
  • EPANET-format export

    Writes the network as EPANET-format text for other programs.

    written value = round(v × 10⁴) ÷ 10⁴

    Water mains network: heads, flows and pressures water.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.