{
  "schemaVersion": 1,
  "slug": "alcohol-dilution-calculator",
  "category": "cooking",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "7d7fa8888186914b77bba1f6a38feaaf585a8936a53566cdde06f55ca3116062",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/alcohol-dilution-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": "water = V × ABV₁ ÷ ABV₂ − V",
    "vars": [
      [
        "water",
        "water to add (ml)"
      ],
      [
        "V",
        "initial volume (ml)"
      ],
      [
        "ABV₁",
        "current strength (%)"
      ],
      [
        "ABV₂",
        "target strength (%)"
      ]
    ],
    "note": "Assumes additive volumes, although ethanol and water can contract when mixed. Target strength must be below current strength; verify the finished mixture with a suitable alcohol measurement."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "if(volumeMl<=0||targetAbv>=currentAbv)return {waterToAdd:null,finalVolume:null,finalLitres:null,dilutionRatio:null,__error:'inputError'}; const finalVolume=volumeMl*currentAbv/targetAbv; return {waterToAdd:finalVolume-volumeMl,finalVolume,finalLitres:finalVolume/1000,dilutionRatio:finalVolume/volumeMl};",
    "inputs": [
      {
        "name": "volumeMl",
        "type": "number",
        "default": 750,
        "min": 0,
        "max": 100000,
        "step": 10
      },
      {
        "name": "currentAbv",
        "type": "number",
        "default": 50,
        "min": 0.5,
        "max": 96,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "targetAbv",
        "type": "number",
        "default": 40,
        "min": 0.5,
        "max": 96,
        "step": 0.5,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "waterToAdd",
        "precision": 1,
        "unit": "ml"
      },
      {
        "name": "finalVolume",
        "precision": 1,
        "unit": "ml"
      },
      {
        "name": "finalLitres",
        "precision": 3,
        "unit": "L"
      },
      {
        "name": "dilutionRatio",
        "precision": 3,
        "unit": "x"
      }
    ],
    "interpret": null
  }
}
