{
  "schemaVersion": 1,
  "slug": "rain-barrel-size-calculator",
  "category": "gardening",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "baaf6d7299f09299abfb83e44eb3c546faad5db7d45d80810385cc4402073ce2",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/rain-barrel-size-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": "G = L×W×0.623×(1−q÷100)×r; B = G÷V",
    "vars": [
      [
        "L",
        "Roof length (ft)"
      ],
      [
        "W",
        "Roof width (ft)"
      ],
      [
        "q",
        "Loss factor (%)"
      ],
      [
        "r",
        "Rainfall (in)"
      ],
      [
        "G",
        "Gallons collected"
      ],
      [
        "V",
        "Barrel size (gal)"
      ],
      [
        "B",
        "Barrels filled"
      ]
    ],
    "note": "0.623 gal per ft² per inch of rain. B = barrels filled per storm; annual potential uses annual rainfall instead of r."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const roofArea = roofLength*roofWidth; const factor = (1-lossFactor/100); const perInch = roofArea*0.623*factor; const gallonsPerStormTotal = perInch*rainfall; const annualPotential = perInch*annualRainfall; return { roofArea, gallonsPerStorm: perInch, gallonsPerStormTotal, annualPotential, barrelsFilled: barrelSize > 0 ? gallonsPerStormTotal/barrelSize : 0, note: 'Most barrels overflow — plan an overflow route away from the house foundation' };",
    "inputs": [
      {
        "name": "roofLength",
        "type": "number",
        "default": 40,
        "min": 0,
        "max": 2000,
        "step": 1,
        "slider": true
      },
      {
        "name": "roofWidth",
        "type": "number",
        "default": 25,
        "min": 0,
        "max": 2000,
        "step": 1,
        "slider": true
      },
      {
        "name": "rainfall",
        "type": "number",
        "default": 1,
        "min": 0.1,
        "max": 12,
        "step": 0.1,
        "slider": true
      },
      {
        "name": "annualRainfall",
        "type": "number",
        "default": 35,
        "min": 1,
        "max": 200,
        "step": 1,
        "slider": true
      },
      {
        "name": "lossFactor",
        "type": "number",
        "default": 15,
        "min": 0,
        "max": 50,
        "step": 5,
        "slider": true
      },
      {
        "name": "barrelSize",
        "type": "number",
        "default": 55,
        "min": 5,
        "max": 5000,
        "step": 5,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "roofArea",
        "precision": 0,
        "unit": "sq ft"
      },
      {
        "name": "gallonsPerStorm",
        "precision": 1,
        "unit": "gal"
      },
      {
        "name": "gallonsPerStormTotal",
        "precision": 1,
        "unit": "gal"
      },
      {
        "name": "annualPotential",
        "precision": 0,
        "unit": "gal"
      },
      {
        "name": "barrelsFilled",
        "precision": 1,
        "unit": ""
      },
      {
        "name": "note",
        "precision": 0,
        "unit": "",
        "type": "text"
      }
    ],
    "interpret": null
  }
}
