{
  "schemaVersion": 1,
  "slug": "rainfall-calculator",
  "category": "weather",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "7c4fe2eef9e85992cf4203bac6e37df86820d6fb261e730b13de4359081f973e",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/rainfall-calculator.json",
    "src/engine.js"
  ],
  "runtimeSource": "/sources/engine.txt",
  "runtimeHash": "5c888d8898afbdee36267bb9977829e1e2ac568f6677c8ee87469c139864645c",
  "scope": "The compute function records implemented equations, constants, lookup tables and custom rules. Inputs record defaults and allowed values; outputs record precision and units. Defaults are examples, not recommendations. General background references are not evidence for this specific algorithm.",
  "publishedFormula": {
    "formula": "V = dₘ × Aₘ²; L = 1000V; G = L/3.785411784; H = Gp/100; B = H/55",
    "vars": [
      [
        "dₘ",
        "Rainfall depth in metres"
      ],
      [
        "Aₘ²",
        "Catchment area in square metres"
      ],
      [
        "V,L,G",
        "Total cubic metres, litres and US liquid gallons"
      ],
      [
        "p",
        "Entered collection percentage"
      ],
      [
        "H",
        "Estimated collected US gallons"
      ],
      [
        "B",
        "Equivalent 55-US-gallon capacity, including fractions"
      ]
    ],
    "note": "Convert inches with ×0.0254, millimetres with ×0.001 and centimetres with ×0.01 to metres. Convert square feet with ×0.09290304 and acres with ×4046.8564224 to square metres. Barrel capacity is a volume equivalent, not a count of full barrels."
  },
  "externalEvidence": {
    "reviewedAt": "2026-10-18",
    "sources": [
      {
        "name": "USGS — Rainfall depth and catchment volume",
        "url": "https://www.usgs.gov/special-topics/water-science-school/science/rain-and-precipitation"
      },
      {
        "name": "NIST SP 811 — SI conversion factors",
        "url": "https://www.nist.gov/pml/special-publication-811/nist-guide-si-appendix-b-conversion-factors/nist-guide-si-appendix-b8"
      }
    ],
    "referenceRole": "definition",
    "implementationHash": "7c4fe2eef9e85992cf4203bac6e37df86820d6fb261e730b13de4359081f973e",
    "basis": "Convert depth to metres and area to square metres, then multiply them for cubic metres. One millimetre over one square metre equals one litre. One US liquid gallon is 3.785411784 litres; one square foot is 0.09290304 square metres, and an acre here is 43560 international square feet. Collected volume is total volume times the entered percentage divided by 100. The default 1 inch over 1000 square feet gives about 623.4 US gallons, or 529.9 at 85% collection. Divide that collected amount by 55 for equivalent barrel capacity; 9.6 means nine full barrels plus part of another, not ten full barrels. Depth accepts 0–100 in the selected unit, area 0.1–10000000 in its selected unit, and collection 0–100%. Changing a unit reinterprets the number; it does not convert the entered value.",
    "limitations": "The collection percentage is a user assumption, not a site-specific runoff forecast. Storage limits, first-flush diversion, evaporation, infiltration and overflow are not modelled. Use this volume estimate as one input to planning; it does not size a drainage system."
  },
  "contract": {
    "compute": "const invalid={cubicFeet:null,gallons:null,liters:null,cubicMeters:null,harvestableGallons:null,barrelEquivalent:null,__error:'inputError'};\nif(!Number.isFinite(rainfall)||rainfall<0||rainfall>100||!Number.isFinite(area)||area<0.1||area>1e7||!Number.isFinite(runoffPct)||runoffPct<0||runoffPct>100||!['in','mm','cm'].includes(depthUnit)||!['sqft','sqm','acre'].includes(areaUnit))return invalid;\nconst depthM=rainfall*({in:0.0254,mm:0.001,cm:0.01}[depthUnit]);const areaM=area*({sqft:0.09290304,sqm:1,acre:4046.8564224}[areaUnit]);const cubicMeters=depthM*areaM,liters=cubicMeters*1000,gallons=liters/3.785411784,harvestableGallons=gallons*runoffPct/100;return {cubicFeet:cubicMeters/0.028316846592,gallons,liters,cubicMeters,harvestableGallons,barrelEquivalent:harvestableGallons/55};",
    "inputs": [
      {
        "name": "rainfall",
        "type": "number",
        "default": 1,
        "min": 0,
        "max": 100,
        "step": 0.01,
        "requiredValue": true,
        "strictRange": true,
        "unitField": "depthUnit",
        "unitLabels": {
          "in": "in",
          "mm": "mm",
          "cm": "cm"
        }
      },
      {
        "name": "area",
        "type": "number",
        "default": 1000,
        "min": 0.1,
        "max": 10000000,
        "step": 1,
        "requiredValue": true,
        "strictRange": true,
        "unitField": "areaUnit",
        "unitLabels": {
          "sqft": "ft²",
          "sqm": "m²",
          "acre": "acre"
        }
      },
      {
        "name": "depthUnit",
        "type": "select",
        "default": "in",
        "options": [
          {
            "value": "in"
          },
          {
            "value": "mm"
          },
          {
            "value": "cm"
          }
        ]
      },
      {
        "name": "areaUnit",
        "type": "select",
        "default": "sqft",
        "options": [
          {
            "value": "sqft"
          },
          {
            "value": "sqm"
          },
          {
            "value": "acre"
          }
        ]
      },
      {
        "name": "runoffPct",
        "type": "number",
        "default": 85,
        "min": 0,
        "max": 100,
        "step": 1,
        "slider": true,
        "requiredValue": true,
        "strictRange": true
      }
    ],
    "outputs": [
      {
        "name": "cubicFeet",
        "precision": 2,
        "unit": "cu ft",
        "notation": "auto"
      },
      {
        "name": "gallons",
        "precision": 1,
        "unit": "gal",
        "notation": "auto"
      },
      {
        "name": "liters",
        "precision": 1,
        "unit": "l",
        "notation": "auto"
      },
      {
        "name": "cubicMeters",
        "precision": 3,
        "unit": "m³",
        "notation": "auto"
      },
      {
        "name": "harvestableGallons",
        "precision": 1,
        "unit": "gal",
        "notation": "auto"
      },
      {
        "name": "barrelEquivalent",
        "precision": 1,
        "unit": "",
        "notation": "auto"
      }
    ],
    "interpret": null
  }
}
