{
  "schemaVersion": 1,
  "slug": "hot-tub-chemical-calculator",
  "category": "household",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "d403d87e040649cd88d171680180f4af0dc75088bd449d30c3134bb35e1a9736",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/hot-tub-chemical-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": "ΔS = S_target − S_current ; ΔpH = pH_target − pH_current ; ΔA = A_target − A_current",
    "vars": [
      [
        "S",
        "sanitizer reading (ppm)"
      ],
      [
        "pH",
        "measured pH"
      ],
      [
        "A",
        "total alkalinity reading (ppm)"
      ]
    ],
    "note": "These are reading differences only. No product dose is calculated because chemical formulations and strengths vary."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const sanitizerChange=targetSanitizer-currentSanitizer; const phChange=targetPh-currentPh; const alkalinityChange=targetAlkalinity-currentAlkalinity; const phDirection=phChange < -0.05 ? 'pH is above target' : phChange > 0.05 ? 'pH is below target' : 'pH is within 0.05 of target'; return { sanitizerChange, phChange, phDirection, alkalinityChange, note: 'Reading differences only—not chemical doses. Follow the exact product label and spa manual, retest the water, and never mix products. CDC advises against stabilized chlorine (including dichlor) in hot tubs.' };",
    "inputs": [
      {
        "name": "currentSanitizer",
        "type": "number",
        "default": 1,
        "min": 0,
        "max": 10,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "targetSanitizer",
        "type": "number",
        "default": 4,
        "min": 0,
        "max": 10,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "currentPh",
        "type": "number",
        "default": 7.2,
        "min": 6,
        "max": 9,
        "step": 0.1,
        "slider": true
      },
      {
        "name": "targetPh",
        "type": "number",
        "default": 7.4,
        "min": 6,
        "max": 9,
        "step": 0.1,
        "slider": true
      },
      {
        "name": "currentAlkalinity",
        "type": "number",
        "default": 60,
        "min": 0,
        "max": 300,
        "step": 10,
        "slider": true
      },
      {
        "name": "targetAlkalinity",
        "type": "number",
        "default": 100,
        "min": 0,
        "max": 300,
        "step": 10,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "sanitizerChange",
        "precision": 2,
        "unit": "ppm"
      },
      {
        "name": "phChange",
        "precision": 2,
        "unit": "pH"
      },
      {
        "name": "phDirection",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "alkalinityChange",
        "precision": 0,
        "unit": "ppm"
      },
      {
        "name": "note",
        "precision": 0,
        "unit": "",
        "type": "text"
      }
    ],
    "interpret": null
  }
}
