# Diode (`diode`)

> Lets current flow one way, with a forward drop when it conducts.

![diode](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/diode.svg)

[Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/switches/diode/)

**Group:** Switches · **Kind:** `{"kind":"diode"}`

## When to use it

Use it for rectifiers, freewheeling paths and clamps. Use Ideal Switch to control turn-on, or Thyristor for gate-triggered turn-on.

## Pins

| Pin | Domain | Meaning |
|---|---|---|
| `a` | electrical | Anode; forward current flows from a to k |
| `k` | electrical | Cathode; the other end |

## Common parameters

- `vf`: Voltage lost while it conducts (Default: 0)
- `ron`: Resistance when it is on (Default: 1m)
- `qrr`: Charge released as the diode recovers (Default: 0)

## Parameters

| Key | Unit | Default | Typical range | Description |
|---|---|---|---|---|
| `ron` | Ω | 1m |  | Resistance when it is on |
| `roff` | Ω | 1meg |  | Resistance when it is off |
| `vf` | V | 0 |  | Voltage lost while it conducts |
| `device` | — | optional (off) |  | Device name used to look up losses |
| `thermal` | — | optional (off) |  | Where the lost heat goes |
| `eon` | J | 0 |  | Energy lost each time it turns on |
| `eoff` | J | 0 |  | Energy lost each time it turns off |
| `err` | J | 0 |  | Energy lost when the diode recovers |
| `vref` | V | 0 |  | Voltage used to measure those energies |
| `iref` | A | 0 |  | Current used to measure those energies |
| `tc` | 1/K | 0 |  | How on-resistance changes with heat |
| `tj` | °C | 25 |  | Junction temperature for the loss tables |
| `nParallel` | — | 1 |  | Identical devices this one switch stands for: the current is shared, the losses add up, each device keeps its own junction |
| `tjMax` | °C | optional (off) |  | Highest junction temperature allowed; overrides the device's rating |
| `ls` | H | 0 | 500p – 50n H | Unwanted inductance in series with it |
| `coss` | F | 0 | 10p – 5n F | Capacitance across the device |
| `cj` | F | 0 | 5p – 2n F | Extra capacitance across the junction |
| `tdon` | s | 0 | 1n – 500n s | Delay before it turns on |
| `tdoff` | s | 0 | 1n – 500n s | Delay before it turns off |
| `qrr` | C | 0 | 1n – 5u C | Charge released as the diode recovers |
| `trr` | s | 100n | 10n – 1u s | How long the diode takes to recover |
| `qrrTemp` | — | optional (off) |  | Junction temperature (°C) and factor pairs that scale qrr, from the datasheet's curve |
| `part` | — | optional (off) |  | Part number; the catalogue part number, such as BSC070N10NS5, written on the schematic; information only, not simulated |
| `vRating` | V | optional (off) |  | Voltage rating; the largest blocking voltage of the data sheet's maximum ratings (VDS, VCES, VRRM), written on the schematic; information only, not simulated |
| `iRating` | A | optional (off) |  | Current rating; the continuous current of the data sheet's maximum ratings (ID, IC, IF), written on the schematic; information only, not simulated |
| `level` | — | ideal |  | Diode model: `ideal` is piecewise linear (ron, vf); `exponential` follows the Shockley law with is, n and rs |
| `is` | A | 10f |  | Saturation current of the exponential law; exponential level only |
| `n` | — | 1 |  | Ideality factor of the exponential law; exponential level only |
| `rs` | Ω | 0 |  | Series resistance of the exponential diode; exponential level only |
| `cjo` | F | 0 |  | Junction capacitance at zero volts; exponential level only |
| `vj` | V | 1 |  | Junction potential of the junction capacitance; exponential level only |
| `m` | — | 0.5 |  | Grading coefficient; how the junction capacitance falls with the reverse voltage; exponential level only |
| `fc` | — | 0.5 |  | Forward-bias coefficient; above fc·vj the junction capacitance continues as a straight line; exponential level only |
| `tt` | s | 0 |  | Transit time; the stored charge is tt times the diode current, as in SPICE; exponential level only, instead of qrr and trr |
| `bv` | V | optional (off) |  | Reverse breakdown voltage; past it the reverse current grows exponentially, as in SPICE; exponential level only |
| `ibv` | A | 1m |  | Reverse current at the breakdown voltage bv; exponential level only |
| `nbv` | — | optional (off) |  | Emission coefficient of the breakdown; the reverse current grows e-fold every nbv·k·T/q past bv; defaults to n; exponential level only |
| `ikf` | A | 0 |  | Forward knee current; above it the forward current grows half as steeply (high injection), as in SPICE; 0 for none; exponential level only |
| `isr` | A | 0 |  | Recombination saturation current; adds isr·(exp(v/(nr·Vt)) − 1), scaled by the depletion width through vj and m, as in SPICE; 0 for none; exponential level only |
| `nr` | — | 2 |  | Emission coefficient of the recombination current isr; exponential level only |
| `isw` | A | 0 |  | Sidewall saturation current: the perimeter junction's own exponential law, isw·(exp(v/(ns·Vt)) − 1), added to the bottom junction's, as in SPICE (JSW times the perimeter pj); 0 for none; exponential level only |
| `ns` | — | optional (off) |  | Emission coefficient of the sidewall current isw; defaults to n; exponential level only |
| `cjsw` | F | 0 |  | Sidewall junction capacitance at zero volts, as in SPICE (CJP times the perimeter pj); exponential level only |
| `vjsw` | V | 1 |  | Junction potential of the sidewall capacitance; exponential level only |
| `mjsw` | — | 0.33 |  | Grading coefficient of the sidewall capacitance; exponential level only |
| `fcs` | — | 0.5 |  | Forward-bias coefficient of the sidewall capacitance; above fcs·vjsw it continues as a straight line; exponential level only |

_Parameter descriptions are in English in both languages._

**Use for:** Rectifiers · Freewheeling paths · Clamps

**Not for:** Voltage references and clamps at a set voltage → [`zener`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/zener/) · Gate-triggered rectifiers → [`thyristor`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/thyristor/)

## Formulas

| Formula | Equation | Source |
|---|---|---|
| Forward drop | V = vf + ron·I | IEC 60747-2:2016 (threshold voltage and forward slope resistance of rectifier diodes) |
| Conduction loss | P = vf·Iavg + ron·Irms² | Mohan, Undeland & Robbins, Power Electronics, 3rd ed. (2003), ch. 2 (on-state power loss) |

## Quick check

Inputs:

- `vf`: Threshold voltage = 700m V, `vf`
- `ron`: Slope resistance = 20m Ω, `ron`
- `iavg`: Average forward current = 5 A
- `irms`: RMS forward current = 7 A

Outputs:

- `vdrop`: Drop at the average current = `vf + ron*iavg` V
- `pcond`: Conduction loss = `vf*iavg + ron*irms^2` W

## Model logic

- At the default level ideal it turns on once v(a) - v(k) exceeds vf, then conducts i = (v - vf)/ron; it turns off when its current goes negative.
- Off means the resistor roff, 1 Mohm by default; vf defaults to 0, so an unset diode has no forward drop.
- The state is settled by iteration inside each step, so the turn-off lands on a step end; a smaller step places the zero crossing closer.
- With qrr above 0 a charge fills toward qrr with time constant trr, and reverse current must remove it before turn-off; level exponential uses the Shockley law.

## Model

The diode turns on when v(a) - v(k) exceeds vf and then follows i = (v - vf) / ron. It turns off when its current goes negative, and it blocks through roff. With qrr above zero, a stored charge builds toward qrr with the time constant trr, and the diode keeps conducting in reverse until that charge is removed, which gives the reverse-recovery spike.

## Common mistakes

- vf defaults to 0, so a diode without vf has no forward loss. Set vf to about 0.4 V for a Schottky diode or 0.7 V for silicon.
- A diode in series with an ideal current source, or switches arranged in a loop, may never settle on one state. Add a resistance or a snubber across the part.
- trr here is a charge time constant, not the recovery time on the datasheet. With a library device set, a warning appears when the current nears its rating.

Problems rules: `solver.not_settled`, `param.out_of_range`, `device.rating`

## Datasheet and sources

vf and ron come from the forward curve, with vf at a low current and ron as the slope near your working current. qrr is the reverse-recovery charge, and vref and iref are the test point of the loss energies (or name a library device for table losses).

## Example

Open the example with the command `file.openExample` and the name `demo:diode`.

---
Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand.
