{
  "schemaVersion": 1,
  "slug": "composting-ratio-calculator",
  "category": "gardening",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "a2978601a5accfff03c523ecf8d4839ef3ccef4adc705d30e7a5300cc0667482",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/composting-ratio-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": "N=G÷(g+1); C=G×g÷(g+1); B=max(0,(t×N−C)÷(b÷(b+1)−t÷(b+1))); ratio=B÷G; pileVolume=w²×h",
    "vars": [
      [
        "G",
        "greens volume (gal)"
      ],
      [
        "g",
        "greens C:N"
      ],
      [
        "B",
        "browns volume (gal)"
      ],
      [
        "b",
        "browns C:N"
      ],
      [
        "t",
        "target C:N"
      ],
      [
        "N",
        "green nitrogen proxy"
      ],
      [
        "C",
        "green carbon proxy"
      ],
      [
        "w",
        "pile width (ft)"
      ],
      [
        "h",
        "pile height (ft)"
      ]
    ],
    "note": "rough volume-based starting point; C:N ratios are mass-based and material density and moisture vary, so this is not a measured recipe or timing estimate."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "if (greensVolume === 0) return { brownsNeeded: null, brownsPerGreen: null, pileVolume: pileSize * pileSize * pileHeight, __error: \"inputError\" }; if (targetCn >= brownsCn && greensCn < targetCn) return { brownsNeeded: null, brownsPerGreen: null, pileVolume: pileSize * pileSize * pileHeight, __error: \"ratioUnreachable\" }; const nitrogen = greensVolume / (greensCn + 1); const carbon = greensVolume * greensCn / (greensCn + 1); const brownCarbonFraction = brownsCn / (brownsCn + 1); const brownNitrogenFraction = 1 / (brownsCn + 1); const brownsNeeded = Math.max(0, (targetCn * nitrogen - carbon) / (brownCarbonFraction - targetCn * brownNitrogenFraction)); return { brownsNeeded, brownsPerGreen: brownsNeeded / greensVolume, pileVolume: pileSize * pileSize * pileHeight };",
    "inputs": [
      {
        "name": "greensVolume",
        "type": "number",
        "default": 5,
        "min": 0,
        "max": 1000,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "greensCn",
        "type": "number",
        "default": 15,
        "min": 5,
        "max": 40,
        "step": 1,
        "slider": true
      },
      {
        "name": "brownsCn",
        "type": "number",
        "default": 60,
        "min": 20,
        "max": 500,
        "step": 5,
        "slider": true
      },
      {
        "name": "targetCn",
        "type": "number",
        "default": 30,
        "min": 15,
        "max": 60,
        "step": 1,
        "slider": true
      },
      {
        "name": "pileSize",
        "type": "number",
        "default": 3,
        "min": 1,
        "max": 20,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "pileHeight",
        "type": "number",
        "default": 3,
        "min": 1,
        "max": 20,
        "step": 0.5,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "brownsNeeded",
        "precision": 2,
        "unit": "gal"
      },
      {
        "name": "pileVolume",
        "precision": 1,
        "unit": "cu ft"
      },
      {
        "name": "brownsPerGreen",
        "precision": 2,
        "unit": "gal/gal"
      }
    ],
    "interpret": null
  }
}
