{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.calculatorx.com/schemas/electrical.battery_runtime/1.2.1/input.json",
  "title": "Battery runtime — input",
  "type": "object",
  "oneOf": [
    {
      "title": "watts",
      "type": "object",
      "additionalProperties": false,
      "required": [
        "mode",
        "V",
        "P_W"
      ],
      "properties": {
        "mode": {
          "const": "watts",
          "description": "Load entered as delivered load-side power P_W"
        },
        "capacity_Ah": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "Battery capacity in amp-hours (mutually exclusive with capacity_mAh)"
        },
        "capacity_mAh": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "Battery capacity in mAh; Ah = mAh/1000 (mutually exclusive with capacity_Ah)"
        },
        "V": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "Nominal pack voltage (V)"
        },
        "P_W": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "Constant delivered load-side power (W)"
        },
        "dod": {
          "type": "number",
          "exclusiveMinimum": 0,
          "maximum": 1,
          "description": "Planning depth of discharge in (0, 1]; default 1 — not a chemistry model"
        },
        "eta": {
          "type": "number",
          "exclusiveMinimum": 0,
          "maximum": 1,
          "description": "Load-side delivery efficiency in (0, 1]; default 1 — planning knob"
        },
        "u_capacity_Ah": {
          "type": "number",
          "minimum": 0,
          "description": "Optional standard uncertainty of capacity_Ah (Ah)"
        },
        "u_V": {
          "type": "number",
          "minimum": 0,
          "description": "Optional standard uncertainty of V (V)"
        },
        "u_P_W": {
          "type": "number",
          "minimum": 0,
          "description": "Optional standard uncertainty of P_W (W)"
        },
        "u_dod": {
          "type": "number",
          "minimum": 0,
          "description": "Optional standard uncertainty of dod"
        },
        "u_eta": {
          "type": "number",
          "minimum": 0,
          "description": "Optional standard uncertainty of eta"
        },
        "uncertainty_k": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "Coverage factor for expanded U on t_h; default 2 when any u_* is set. Mutually exclusive with confidence. Requires at least one u_*."
        },
        "confidence": {
          "type": "number",
          "exclusiveMinimum": 0,
          "exclusiveMaximum": 1,
          "description": "Coverage probability instead of uncertainty_k. Mutually exclusive with uncertainty_k. Requires at least one u_*."
        }
      },
      "allOf": [
        {
          "oneOf": [
            {
              "required": [
                "capacity_Ah"
              ],
              "not": {
                "required": [
                  "capacity_mAh"
                ]
              }
            },
            {
              "required": [
                "capacity_mAh"
              ],
              "not": {
                "required": [
                  "capacity_Ah"
                ]
              }
            }
          ]
        },
        {
          "not": {
            "required": [
              "uncertainty_k",
              "confidence"
            ]
          }
        },
        {
          "if": {
            "anyOf": [
              {
                "required": [
                  "uncertainty_k"
                ]
              },
              {
                "required": [
                  "confidence"
                ]
              }
            ]
          },
          "then": {
            "anyOf": [
              {
                "required": [
                  "u_capacity_Ah"
                ]
              },
              {
                "required": [
                  "u_V"
                ]
              },
              {
                "required": [
                  "u_P_W"
                ]
              },
              {
                "required": [
                  "u_dod"
                ]
              },
              {
                "required": [
                  "u_eta"
                ]
              }
            ]
          }
        }
      ]
    },
    {
      "title": "amps",
      "type": "object",
      "additionalProperties": false,
      "required": [
        "mode",
        "V",
        "I_A"
      ],
      "properties": {
        "mode": {
          "const": "amps",
          "description": "Load entered as battery-side discharge current I_A"
        },
        "capacity_Ah": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "Battery capacity in amp-hours (mutually exclusive with capacity_mAh)"
        },
        "capacity_mAh": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "Battery capacity in mAh; Ah = mAh/1000 (mutually exclusive with capacity_Ah)"
        },
        "V": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "Nominal pack voltage (V); used for E_Wh reporting"
        },
        "I_A": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "Constant battery-side discharge current (A). Converter losses are already in this current — do not also apply η."
        },
        "dod": {
          "type": "number",
          "exclusiveMinimum": 0,
          "maximum": 1,
          "description": "Planning depth of discharge in (0, 1]; default 1 — not a chemistry model"
        },
        "eta": {
          "type": "number",
          "exclusiveMinimum": 0,
          "maximum": 1,
          "description": "Ignored in amps mode (battery-side current). Use watts mode for load-side delivery efficiency."
        },
        "u_capacity_Ah": {
          "type": "number",
          "minimum": 0,
          "description": "Optional standard uncertainty of capacity_Ah (Ah)"
        },
        "u_I_A": {
          "type": "number",
          "minimum": 0,
          "description": "Optional standard uncertainty of I_A (A)"
        },
        "u_dod": {
          "type": "number",
          "minimum": 0,
          "description": "Optional standard uncertainty of dod"
        },
        "u_eta": {
          "type": "number",
          "minimum": 0,
          "description": "Ignored in amps mode (η does not enter t_h)"
        },
        "u_V": {
          "type": "number",
          "minimum": 0,
          "description": "Ignored in amps mode (V does not enter t_h)"
        },
        "uncertainty_k": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "Coverage factor for expanded U on t_h; default 2 when any u_* is set. Mutually exclusive with confidence. Requires at least one contributing u_* (u_capacity_Ah, u_I_A, or u_dod)."
        },
        "confidence": {
          "type": "number",
          "exclusiveMinimum": 0,
          "exclusiveMaximum": 1,
          "description": "Coverage probability instead of uncertainty_k. Mutually exclusive with uncertainty_k. Requires at least one contributing u_*."
        }
      },
      "allOf": [
        {
          "oneOf": [
            {
              "required": [
                "capacity_Ah"
              ],
              "not": {
                "required": [
                  "capacity_mAh"
                ]
              }
            },
            {
              "required": [
                "capacity_mAh"
              ],
              "not": {
                "required": [
                  "capacity_Ah"
                ]
              }
            }
          ]
        },
        {
          "not": {
            "required": [
              "uncertainty_k",
              "confidence"
            ]
          }
        },
        {
          "if": {
            "anyOf": [
              {
                "required": [
                  "uncertainty_k"
                ]
              },
              {
                "required": [
                  "confidence"
                ]
              }
            ]
          },
          "then": {
            "anyOf": [
              {
                "required": [
                  "u_capacity_Ah"
                ]
              },
              {
                "required": [
                  "u_I_A"
                ]
              },
              {
                "required": [
                  "u_dod"
                ]
              }
            ]
          }
        }
      ]
    }
  ],
  "description": "Estimate constant-load battery runtime from capacity, voltage, load (W load-side or A battery-side), DoD, and load-side efficiency (watts mode); optional u_* compose expanded uncertainty on t_h via Uncertainty Engine. (calculation_version 1.2.1)"
}
