{
  "schemaVersion": 1,
  "slug": "electrical-calculator",
  "category": "everyday",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "19f7e8253a5dfb911c28845d344a0eff7dad92ef6f3162374b3b78bd0e173a2a",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/electrical-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": "P = V × I × pf × φ",
    "vars": [
      [
        "V",
        "Voltage (V)"
      ],
      [
        "I",
        "Current (A)"
      ],
      [
        "pf",
        "Power factor (0–1)"
      ],
      [
        "φ",
        "Phase factor: single 1, three-phase √3 ≈ 1.732"
      ],
      [
        "P",
        "Real power (W)"
      ]
    ],
    "note": "P = V × I × pf × φ. The 125% value is a simplified continuous-load example only; breaker and conductor selection require load, conductor, equipment, and local-code details. Not installation advice."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const phaseFactor = phase === 'three' ? 1.732 : 1;\nconst close = (a,b) => Math.abs(a-b) <= Math.max(0.05, Math.max(Math.abs(a),Math.abs(b))*0.01);\nconst error = () => ({powerWatts:null,current:null,resistanceResult:null,apparentPower:null,breakerSize:null,note:null,__error:'inconsistentInputs'});\nif (watts > 0 && amps > 0 && !close(watts,volts*amps*powerFactor*phaseFactor)) return error();\nif (resistance > 0 && amps > 0 && !close(amps,volts/resistance)) return error();\nif (resistance > 0 && watts > 0 && !close(watts,(volts*volts/resistance)*powerFactor*phaseFactor)) return error();\nconst current = amps > 0 ? amps : watts > 0 ? watts/(volts*powerFactor*phaseFactor) : resistance > 0 ? volts/resistance : 0;\nconst powerWatts = watts > 0 ? watts : current > 0 ? volts*current*powerFactor*phaseFactor : 0;\nconst resistanceResult = resistance > 0 ? resistance : current > 0 ? volts/current : 0;\nconst apparentPower = powerFactor > 0 ? powerWatts/powerFactor : powerWatts;\nconst standard = [15, 20, 30, 40, 50, 60, 70, 80, 100, 125, 150, 200];\nconst needed = current*1.25;\nconst breakerSize = standard.find((s) => s >= needed) || Math.ceil(needed/50)*50;\nreturn { powerWatts, current, resistanceResult, apparentPower, breakerSize, note: phase === 'three' ? 'Three-phase loads use the square root of three factor — confirm the connection type before wiring' : 'Size the breaker at 125% of continuous load, and never exceed the cable rating' };",
    "inputs": [
      {
        "name": "volts",
        "type": "number",
        "default": 120,
        "min": 1,
        "max": 100000,
        "step": 1
      },
      {
        "name": "amps",
        "type": "number",
        "default": 10,
        "min": 0,
        "max": 10000,
        "step": 0.1
      },
      {
        "name": "watts",
        "type": "number",
        "default": 0,
        "min": 0,
        "max": 1000000,
        "step": 1
      },
      {
        "name": "resistance",
        "type": "number",
        "default": 0,
        "min": 0,
        "max": 1000000,
        "step": 0.1
      },
      {
        "name": "phase",
        "type": "select",
        "default": "single",
        "options": [
          {
            "value": "single"
          },
          {
            "value": "three"
          }
        ]
      },
      {
        "name": "powerFactor",
        "type": "number",
        "default": 1,
        "min": 0.1,
        "max": 1,
        "step": 0.01,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "powerWatts",
        "precision": 2,
        "unit": "W"
      },
      {
        "name": "current",
        "precision": 3,
        "unit": "A"
      },
      {
        "name": "resistanceResult",
        "precision": 3,
        "unit": "Ω"
      },
      {
        "name": "apparentPower",
        "precision": 1,
        "unit": "VA"
      },
      {
        "name": "breakerSize",
        "precision": 1,
        "unit": "A"
      },
      {
        "name": "note",
        "precision": 0,
        "unit": "",
        "type": "text"
      }
    ],
    "interpret": null
  }
}
