{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.calculatorx.com/schemas/electrical.diode.equation.input.json",
  "title": "Diode equation — input",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "mode": {
      "type": "string",
      "enum": [
        "id",
        "vd"
      ],
      "default": "id",
      "description": "id: Vd→Id (default). vd: Id→Vd."
    },
    "Vd": {
      "type": "number",
      "description": "Diode voltage in volts. Required when mode=id (default)."
    },
    "Id": {
      "type": "number",
      "description": "Diode current in amperes. Required when mode=vd. Shockley inverse domain: Id > -Is (includes Id=0 and reverse branch)."
    },
    "Is": {
      "type": "number",
      "exclusiveMinimum": 0,
      "description": "Saturation current at the selected junction temperature T. Not derived as Is(T) from a reference-temperature value."
    },
    "n": {
      "type": "number",
      "exclusiveMinimum": 0,
      "default": 1,
      "description": "Ideality factor. Default 1."
    },
    "T_K": {
      "type": "number",
      "exclusiveMinimum": 0,
      "default": 300,
      "description": "Junction temperature in kelvin. Canonical REST/MCP input. Default 300."
    },
    "T_C": {
      "type": "number",
      "description": "Optional Celsius alias for junction temperature. UI/query accept T_C; canonical schema is T_K. If both are sent, T_K wins."
    }
  },
  "required": [
    "Is"
  ],
  "allOf": [
    {
      "if": {
        "properties": {
          "mode": {
            "const": "vd"
          }
        },
        "required": [
          "mode"
        ]
      },
      "then": {
        "required": [
          "Id"
        ]
      }
    },
    {
      "if": {
        "not": {
          "properties": {
            "mode": {
              "const": "vd"
            }
          },
          "required": [
            "mode"
          ]
        }
      },
      "then": {
        "required": [
          "Vd"
        ]
      }
    }
  ],
  "description": "Shockley diode Id↔Vd. Canonical T_K; UI/query alias T_C. Defaults: mode=id, n=1, T_K=300. Inverse domain Id > -Is. (calculation_version 1.1.0)"
}
