{
  "schemaVersion": 1,
  "slug": "tesla-charging-cost-calculator",
  "category": "automotive",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "b95da930b7b8d036ed3e8c485c90c26a55eba8f359b25982f95c299f7e0776b0",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/tesla-charging-cost-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": "E = B(t − s) ÷ 100; C = E ÷ η × r",
    "vars": [
      [
        "B",
        "Battery capacity (kWh)"
      ],
      [
        "t",
        "Target charge (%)"
      ],
      [
        "s",
        "Start charge (%)"
      ],
      [
        "η",
        "Illustrative efficiency: 0.90 home, 0.93 Supercharger"
      ],
      [
        "r",
        "Electricity rate (currency/kWh)"
      ],
      [
        "E",
        "Energy added (kWh)"
      ]
    ],
    "note": "Annual cost difference = (Supercharger cost − home cost) × charges/month × 12; positive means modeled home savings. The efficiency factors are illustrative, not universal measurements."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const energyAdded = batteryKwh*Math.max(0, (targetPercent-startPercent))/100; const homeCost = energyAdded/0.9*homeRate; const superchargerCost = energyAdded/0.93*superchargerRate; return { energyAdded, homeCost, superchargerCost, annualCostDifference: (superchargerCost-homeCost)*monthlyCharges*12, rangeAdded: energyAdded*efficiencyMilesPerKwh };",
    "inputs": [
      {
        "name": "batteryKwh",
        "type": "number",
        "default": 75,
        "min": 5,
        "max": 250,
        "step": 1,
        "slider": true
      },
      {
        "name": "startPercent",
        "type": "number",
        "default": 15,
        "min": 0,
        "max": 100,
        "step": 1,
        "slider": true
      },
      {
        "name": "targetPercent",
        "type": "number",
        "default": 90,
        "min": 0,
        "max": 100,
        "step": 1,
        "slider": true
      },
      {
        "name": "homeRate",
        "type": "number",
        "default": 0.16,
        "min": 0,
        "max": 5,
        "step": 0.001,
        "slider": true
      },
      {
        "name": "superchargerRate",
        "type": "number",
        "default": 0.42,
        "min": 0,
        "max": 5,
        "step": 0.001,
        "slider": true
      },
      {
        "name": "efficiencyMilesPerKwh",
        "type": "number",
        "default": 3.2,
        "min": 0.5,
        "max": 10,
        "step": 0.1,
        "slider": true
      },
      {
        "name": "monthlyCharges",
        "type": "number",
        "default": 8,
        "min": 0,
        "max": 100,
        "step": 1,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "homeCost",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "superchargerCost",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "energyAdded",
        "precision": 2,
        "unit": "kWh"
      },
      {
        "name": "annualCostDifference",
        "precision": 0,
        "unit": "USD"
      },
      {
        "name": "rangeAdded",
        "precision": 0,
        "unit": "mi"
      }
    ],
    "interpret": null
  }
}
