Skip to content

Losses & junction temperature

Pulsim ships a PSIM-equivalent loss panel that walks every relevant branch of a simulation result and returns per-device dissipation metrics, plus a Foster-network helper that pipes those losses through a datasheet thermal impedance to produce T_j(t). The whole pipeline is post-hoc — you run the electrical simulation once with the kernel, then call two pure-Python helpers on the result.

TL;DR

res = p.simulate(b, t_end=..., dt=..., switch_fn=pwm)
loss = p.device_loss_summary(b, res, switch_fn=pwm,
                               switch_specs={...},
                               diode_specs={...},
                               core_loss_specs={...})
therm = p.device_thermal_summary(b, res,
                                   thermal_specs={
                                     "M1": {"stages": [FosterStage(...), ...],
                                            "T_ambient_C": 40.0},
                                   },
                                   # same loss kwargs forwarded:
                                   switch_fn=pwm,
                                   switch_specs={...},
                                   diode_specs={...})

What you get per device

device_loss_summary returns a list with one dict per branch it recognises. Common fields:

Field Type Where it appears
branch_id, kind, name int / str / str every device
i_avg, i_rms, i_peak float every device
P_avg, E_total float resistor / diode / switch
duty_conducting float ∈ [0, 1] diode
duty_closed float ∈ [0, 1] switch
t_window_start, t_window_end float [s] every device

A Shockley diode (add_shockley_diode, kind shockley_diode) gets i_avg, i_rms, i_peak, P_avg and E_total from the kernel's exponential law at the recorded v_D (the parameters are kept on the builder when the diode is added); result.i() returns the same current. Against a 1 mOhm sense resistor in series it agrees to 3e-12 A.

Steady state: t_from / t_to

Every figure covers the whole run, start-up included, unless you pass a window in seconds (both device_loss_summary and device_thermal_summary):

rows = p.device_loss_summary(b, res, conduction_specs=cond, t_from=0.08)

On a 230 V bridge rectifier (0.1 Ω, 470 µF ‖ 1 kΩ, t_end = 0.1 s) a diode's V_f0 = 0.7, r_on = 0.02 conduction loss is 2.338 W over the run and 0.1358 W over 80–100 ms. A bound inside a step cuts that step's own model: the line of its current and, on a step that flips a switch or diode, the trapezoid of its end powers. Adjacent windows therefore add up to rounding wherever the cuts fall, a bound inside a flip step reads like either end of it, and a variable-step grid gives the same answer as a fine fixed one. Gate edges and diode turn-offs are found on the whole run and count when their step starts inside the window. The thermal summary still runs the Foster network from t = 0 (T_j_trace covers the run); its averages and peaks cover the window, and the constant switching offset is the window's P_sw_avg.

Switch and diode states are not inferred. Every engine records, with each stored sample, the switch / diode mask it stamped for the solve that produced it (result.switch_states, one bool column per builder.switch_index_of(name)), so a switched branch's current is exactly (g_on if closed else g_off) · v (for an ON PWL diode with a forward drop, g_on · (v − V_f)). A PWL diode needs this: its ON state is V_f + i/g_on, so a diode carrying 48 A at g_on = 1e3 sits at V_f + 48 mV — inside V_f < v_D < V_th, where the voltage alone cannot say whether it conducts. Its loss is V_f·i + i²/g_on, so P_avg already contains the drop: a conduction_specs V_f0 for the same diode is a separate estimate, not an addition. The gated PWL devices (add_igbt(reverse_blocking=True), add_gto, add_thyristor, add_triac) are diode rows with the same law: an IGBT's conduction loss is V_ce0·I_avg + R_on·I_rms² (10 A DC at V_ce0 = 0.9 V, R_on = 10 mΩ: 10.0 W; the bidirectional switch read 1.0 W). switch_fn= is only needed for a result built without the record (it is then re-evaluated, with a warning). Duties are time-weighted per step, so a variable-step grid does not bias them.

Row k of the record is the mask in force over the step (t[k-1], t[k]], and the sample's state is the solve under it. At a commutation the stored sample is therefore the state just BEFORE the switch flips (a TR-BDF2 landing, a DSED event), and the new mode appears from the next sample on. A sample 0 seeded with initial_state was not solved in the run (result.switch_states_unsolved): its recorded bits are the mask carried in, which say nothing about the solve that produced its state, so a switched branch has no defined current there. result.i() returns the first solved sample's value for a switch or diode on that row (a real current one step late, never a guessed g_on·V; every i0= / c0= run has such a row), and the loss and thermal summaries start at the first solved sample (one step less than the run on a fixed grid; every entry's t_window_start is then t[1], and an energy or charge total leaves out [t[0], t[1]]). A resume_from sample 0 is the previous run's last sample and records the mask it was solved under (SolverSnapshot.stamped_mask); it is flagged only when the snapshot lacks that field (hand-built, or pickled before it existed).

Time integrals (i_avg, i_rms, P_avg, E_total, the conduction model, the forward charge of a recovery) integrate each step as the line from its START to its end sample, exactly: h·(a + c)/2 for a current, h·(a² + a·c + c²)/3 for a square. The start of a step is the sample before it, except at a DSED event: the stored sample is the left limit there, and engine='dsed' also stores the right limit the next step starts from (result.right_limit_index / right_limit_states / right_limit_switch_states). Without it a freewheel diode's turn-on jump was drawn as a ramp over the whole next step, and a DCM boost diode's i_avg read 0.0234 A against 0.0535 A (−56 %), with no warning. The same right limit gives a switch's E_on its current AT the edge. Integrating np.trapezoid(result.i(name), result.times) yourself on a DSED result keeps that error (first order in the step); read the summary, or start each step from the right limit. A step whose two ends carry different conductances (a fixed-step or TR-BDF2 commutation step, which has no stored right limit) keeps the trapezoid of its two end powers.

With store_every > 1 a recorded row is the mask of the LAST solve before the sample, not of the whole stored interval, so duties and integrals alias on a decimated grid (a buck switch's duty read 0.554 instead of 0.500 at store_every = 67). Keep store_every = 1 for loss work.

PSIM-style datasheet annotations add:

Field Source
E_sw_total, P_sw_avg, n_turn_off_events, n_turn_off_events_dropped, E_sw_dropped, n_turn_off_events_capped, n_turn_off_events_unresolved, f_sw_estimate, t_rr diode + diode_specs
n_possible_chatter_gaps every diode (see below)
t_window_start, t_window_end every entry: the window the statistics were taken over
E_sw_on_total, E_sw_off_total, n_turn_on_events switch + switch_specs
P_core_avg, E_core_total, B_peak inductor + core_loss_specs

Resistor

P_avg = v_R² / R reconstructed from node voltages. Zero new kwargs.

b.add_resistor("R_load", "vout", "gnd", 4.0)
res = p.simulate(b, t_end=1e-3, dt=1e-5)
loss = p.device_loss_summary(b, res)
print(next(e for e in loss if e["name"] == "R_load")["P_avg"])

Capacitor ESR, inductor DCR and AC-resistance ladder

b.add_capacitor(..., esr=) and b.add_inductor(..., esr=) add a series resistor named {name}.esr; its row in device_loss_summary is the i²·esr loss (1 A rms through 50 mΩ: 50.000 mW). An inductor built with rac=p.passives.fit_rac_ladder(f, R_ac, L=...) dissipates in {name}.esr (R_dc) and the cell resistors {name}.rac_r{k}, so every harmonic of the current is charged at its own R_ac: 1 A peak at 1 kHz plus 1 A peak at 100 kHz through R_dc = 10 mΩ and one 90 mΩ ∥ 143.24 nH cell dissipates 32.50 mW. ESR is one number: read it at the switching frequency.

Switch — PSIM-style E_on / E_off

b.add_switch("M1", "ds", "gnd", g_on=1e3, g_off=1e-9)

switch_specs = {"M1": {
    "E_on_ref":  120e-6,    # 120 µJ from datasheet
    "E_off_ref": 180e-6,
    "V_ref":     48.0,      # datasheet test condition
    "I_ref":     10.0,
}}
loss = p.device_loss_summary(b, res, switch_fn=pwm,
                                switch_specs=switch_specs)

Pulsim detects turn-on / turn-off edges from your switch_fn mask and scales the datasheet energy linearly by the actual blocking voltage and load current at each edge:

E_on_event  = E_on_ref · (|V_blocking| / V_ref) · (|I_load| / I_ref)
E_off_event = E_off_ref · ...

Honest errors: V_ref or I_ref ≤ 0 → ValueError. Unknown name in switch_specs → KeyError.

Diode — Q_rr or E_rr_ref

Two equivalent entry points:

# Raw recovery charge (hard-recovery diodes):
diode_specs = {"D1": {"Q_rr": 50e-9}}

# Datasheet energy + reference voltage (fast/soft recovery):
diode_specs = {"D1": {"E_rr_ref": 30e-6, "V_R_ref": 600.0}}

# Either form takes the recovery time (default 100 ns):
diode_specs = {"D1": {"Q_rr": 50e-9, "t_rr": 35e-9}}

A turn-off is the end of a conducting stretch of the diode's recorded state, at t_off (the end of its last conducting step). Pulsim reads the reverse voltage V_R = max(−v_D, 0) one recovery time later, at t_off + t_rr — a physical instant, the same on every engine and step size — and accumulates E_rr = Q_rr · V_R or E_rr = E_rr_ref · (V_R / V_R_ref). v_D is read from the blocking samples paired into step midpoints, which cancels the fixed engine's trapezoidal alternation around a node held only by g_off. A hard-switched diode blocks its full voltage at once; a naturally commutated one (a line rectifier, a DCM turn-off) recovers against the little voltage that has built up after its current zero, so its E_rr is small — as it is in hardware.

When the step that carries a turn-off is longer than t_rr, the grid cannot show how v_D rose inside it and E_rr depends on the step size. Those turn-offs are counted in n_turn_off_events_unresolved and a RuntimeWarning names the diode. The exception is a FORCED turn-off (another switch flips on the same step while the diode still carries current) whose blocking voltage is flat after the step: the voltage jumped at the turn-off, so the reading is the plateau. Use a step no longer than t_rr around the turn-offs (engine='pwl' with dt <= t_rr, or a smaller dt_max), or pass the datasheet t_rr.

Every recorded conduction stretch counts: turn-offs, f_sw_estimate, Q_F and E_rr are read from the record as the solver stamped it. That includes numerical chatter. The fixed engine produces it on a V_th > 0 diode with a capacitor across it (or in a tight loop with it): for dt > 2·τ, τ = C·(1/g_on + R_loop), the trapezoidal rule reflects each ON step from +V_th to about −V_th, the stamp drops to OFF, and the circuit recharges the capacitor to V_th within a few steps, over and over. A 100 kHz boost with 100 nF across D1 records 4580 turn-offs at dt = T/400 (15887 at T/2000) instead of 299; a 100 µF transformer rectifier (τ = 0.5 µs) records 360 instead of 5 at dt = 2 µs, with gaps of 40 to 187 steps. n_possible_chatter_gaps counts the gaps that look like it: the reflected ON step lasts one step, so a gap counts when at least two of the three runs around it (the conducting stretch before, the gap, the stretch after) last at most 2 steps, and no step average of v_D in it falls below −2·V_th (with a forward drop, v_D − V_f against −2·(V_on − V_f)). The gap length is not used: chatter gaps measured 1 to 237 steps, and real short blocking intervals are as short (a 100 kHz pulsed charger blocking 0.5 V: 5 steps at 1 µs, between conducting stretches of 5 steps, not reported). On the fixed-step engine a RuntimeWarning fires when they are at least half the turn-offs and cover 1 % or more of the conducting time; it says the gaps MAY be chatter and that, if they are, n_turn_off_events, f_sw_estimate and E_sw_total are inflated. A smaller dt removes the chatter only once it is about 2·τ or less (a 1000 µF rectifier capacitor, τ = 5 µs: chatter at dt >= 16 µs, none at <= 12 µs); for a snubber directly across the diode τ = C/g_on is 1 ns per µF at g_on = 1e3, out of reach, and a smaller dt multiplies the gaps. To check, compare with engine='trbdf2' (or engine='auto' without dt; with dt it runs the fixed-step engine), which does not reflect this mode, and treat a disagreement as unresolved rather than taking either as the reference: TR-BDF2 has errors of its own on a stiff snubbed circuit (that same boost ends at 27.6 V on 'auto' against 54.5 V on 'pwl' at T/400 and T/4000).

Two guards keep immaterial conduction out, and both are reported:

  • a stretch whose forward charge Q_F is below 1e-3 of the recovery charge the spec asks for (Q_rr or E_rr_ref / V_R_ref) is not a recovery (n_turn_off_events_dropped; excluded from n_turn_off_events, f_sw_estimate and the total) — the fixed engine's trapezoidal stiff mode can turn a reverse-biased diode ON for single ~µA steps. With the cap below, a dropped stretch could add at most 1e-3 of one event's energy; E_sw_dropped reports what they would add together, and a RuntimeWarning fires if that exceeds 1 % of E_sw_total. The test is the stretch's own charge, not the run's peak current: a 4 kA start-up inrush made the old 1e-3 · i_peak rule drop all 237 light- load recoveries of a boost (each above Q_rr), E_sw 4.9× and f_sw_estimate 5× low. An E_rr_curve is judged on its own current axis instead: a stretch whose peak forward current is below 1e-3 of the curve's smallest tabulated positive current is dropped. (E_rr is read off the same axis, at the current the diode carries when it is cut off; the charge a curve asks for scales with that current, so a curve through the origin would have asked a 36 µA chatter blip for 1e-12 C and counted all of them.) A spec without any recovery (counts only) judges the peak forward current against 1e-3 of the median peak of the stretches that reach 1e-3 of the run's peak current;
  • no event recovers more than its own forward charge: E_rr is capped at Q_F · V_R (n_turn_off_events_capped). Capped events usually are one-step re-conductions from a ringing the grid does not resolve (a snubber faster than dt), which also inflate n_turn_off_events and f_sw_estimate, so a RuntimeWarning reports them.

The SwitchedDiode kernel model has no physical recovery charge — this is a datasheet annotation pass, matching the LTspice "ideal-diode-with-Qrr" option and the PSIM diode loss panel.

Magnetic core loss

core_loss_specs = {"L1": {
    "material": "N87",       # built-in catalogue (or CoreMaterial obj)
    "N_turns":  20,
    "A_core":   1.0e-4,      # m²
    "V_core":   5.0e-6,      # m³
    "use_igse": True,        # default; falls back to Steinmetz if trace
                              #   is shorter than one period
}}

Internally:

  1. Reconstruct B(t) = L · i(t) / (N · A_core) from the kernel state trace.
  2. Apply iGSE (Venkatachalam 2002) or classic Steinmetz at the FFT-estimated dominant frequency.
  3. Multiply by V_core to get watts.

Inline {"K": ..., "alpha": ..., "beta": ...} is accepted in place of material. Non-positive N_turns / A_core / V_core → ValueError (no silent zeros).

In-loop core loss in a magnetic network

The Steinmetz / iGSE estimate above runs after the transient: it reads B(t) from the trace and never changes the circuit. In a magnetic network (tutorial 09), b.add_magnetic_resistance(name, a, b, R_m) between two magnetic nodes dissipates R_m·(dΦ/dt)² inside the solve, so the loss damps the circuit. It is classical eddy loss (P ∝ f²·B²); device_loss_summary lists it with kind="magnetic_resistance", category="core_loss" and its R_m. b.add_excess_loss(name, a, b, c, eps) adds Bertotti's excess loss, F = c·u/(u² + eps²)^¼ for the flux rate u (P ∝ (f·B)^1.5); it is listed with kind="excess_loss", category="core_loss", c and eps. Under a sine flux rate of amplitude Û its loss is c·Û^1.5·0.556418 (the mean of |cos|^1.5) less (3/4)·(eps/Û)² of it: eps ≤ 1.15e-3·Û keeps it within 1e-6. It does not feed a thermal node: the kernel's loss port belongs to switching devices (a junction); a core temperature is not modelled.

Steinmetz / iGSE (post-hoc) magnetic elements (in loop)
frequency law f^α·B^β, fitted eddy f²·B², excess (f·B)^1.5, JA loop
changes the waveform no yes
hysteresis, excess loss inside the fit add_hysteretic_permeance, add_excess_loss

R_m is fitted to a loss figure, not predicted; neither model is validated against measurement here.

Junction temperature — device_thermal_summary

Same kwargs as device_loss_summary, plus per-device Foster networks:

foster_M1 = [
    p.FosterStage(R_th_K_per_W=0.30, tau_s=2e-3),   # die-to-case
    p.FosterStage(R_th_K_per_W=1.20, tau_s=80e-3),  # case-to-heatsink
]

therm = p.device_thermal_summary(
    b, res,
    thermal_specs={
        "M1": {"stages": foster_M1, "T_ambient_C": 40.0},
        "D1": {"stages": [p.FosterStage(R_th_K_per_W=2.0,
                                            tau_s=1e-3)]},
    },
    T_ambient_C=25.0,        # fallback default
    # everything below is forwarded into device_loss_summary:
    switch_fn=pwm,
    switch_specs=switch_specs,
    diode_specs=diode_specs,
    core_loss_specs=core_loss_specs,
)

Per-device output:

Field Meaning
P_cond_avg Average conduction loss (W)
P_sw_avg PSIM-style switching loss (W) — constant offset over the run
P_core_avg Steinmetz / iGSE core loss (inductor only)
P_total_avg P_cond_avg + P_sw_avg + P_core_avg
T_j_trace np.ndarray — full T_j(t) (°C): one value per result.times sample on engine='pwl' and 'dsed' (DSED computes it with the step-start (right-limit) power inserted, so it agrees with P_cond_avg, and samples it back for every device), on a uniform resample of the run on 'trbdf2' / 'auto'
T_j_avg, T_j_peak scalars (°C); T_j_avg is a time average, on a variable grid over a linear resample of the power (−0.50 K of a 182 K rise on a DSED boost, +0.83 K on 'auto', against the exact single-stage value)
T_ambient_C from spec or top-level default
R_th_total Σ R_th_i over the Foster stages (K/W)
t_window_start, t_window_end the window the network ran over (from the first solved sample)

The switching-loss and core-loss contributions are layered on the conduction trace as a constant offset (thermal time constants ≫ nanosecond switching transitions, so the impulse energy is smeared across the cycle — standard PSIM convention).

Event losses and T_j on the periodic orbit (design evaluator)

On the exact steady-state route (pulsim.design.Evaluator, steady=SteadySpec(method="pss"), engine dsed) the loss tables are read at every commutation of the steady period, from the period map's left and right limits at the event, by one rule:

Event Blocking voltage Current Temperature
turn-on |v(x⁻)|, before |i(x⁺)|, after T_j
turn-off |v(x⁺)|, after |i(x⁻)|, before T_j
  • Switches: switch_specs={"Q1": {"E_on_table": LossTable, "E_off_table": LossTable, "Tj": 125}}. On a three-phase SPWM inverter (10 kHz, 1 µs dead time, 600 V, 200 edges each way per 20 ms period) the kernel's E_on / E_off equal device_loss_summary's on a settled dsed period within 1.8e-13 (test, tolerance 1e-9).
  • Diodes: switch_specs={"D1": {"E_off_table": LossTable, "Tj": 125}} is the recovery energy, read at each turn-off by the turn-off row (v after, i before); it is the record's recovery loss. Its count equals the diode's turn-off count in the period. This is the exact route only: device_loss_summary refuses a diode in switch_specs by name (it used to ignore it) and takes recovery through diode_specs.
  • The junction: ThermalSpec(r_th={"Q1": 2.5}, t_amb=40) on this route defaults to mode="kernel": the orbit is fixed, P(T_j) is the device's fixed loss plus its table energies over the period, and T_j = t_amb + r_th P(T_j) is solved in C++ segment by segment between the tables' T_j knots (exact where the tables are linear; residual below 1e-9 K, counters["thermal_residual"]). It is the smallest root above t_amb, where the physical iteration settles; no root (r_th dP/dT_j >= 1) is infeasible / thermal_runaway, with the slope in the reason. mode="fixed_point" keeps the damped loop (and loss_at=, temperature_dependent=); on the buck example's best design (SYN-B, 60.5 kHz, r_th 3 K/W) T_j(Q1) is 43.27175 °C against 43.27162 °C, 1.3e-4 K apart (test: 0.1 K).
  • Conduction: by default the circuit's own dissipation (the closed-form period integrals). ThermalSpec(conduction={"Q1": {"i": [...], "tj": [...], "v_on": [[...]]}}) heats the junction with V_on(|i|, T_j)·|i| over the on-state current instead, in closed form when the table is linear in i (one or two current knots; more knots, a current that changes sign, or a table clamped at 0 in range are refused by name). It is reported as p_cond_table.<device>; the record's conduction loss stays the circuit's, so the energy balance still closes.

The tables in the tests and the examples are SYNTHETIC, as are the parts Pulsim ships (allow_synthetic=True); they illustrate the reading, not a device. Not covered: the event energy is not drawn from the circuit (the PWL switch is ideal, as in PLECS), and T_j does not feed back into the electrical solution in kernel mode.

Event losses inside the transient (set_device_losses)

The summaries above are post-hoc: the run ends, then the tables are read. CircuitBuilder.set_device_losses reads them inside the time loop of engine="pwl" and deposits the heat into a node of a thermal network built in the same circuit (°C is a node voltage, W a current):

b.add_voltage_source("Vamb", "amb", "gnd", 40.0)      # ambient, °C
b.add_resistor("Rth", "tj", "amb", 1.0)               # K/W
b.add_capacitor("Cth", "tj", "amb", 0.01)             # J/K
b.set_device_losses("Q1", junction="tj",              # closed loop
                    E_on=LossTable(...), E_off=LossTable(...),
                    V_on=ConductionTable(...), conduction="table")
res = p.simulate(b, 0.1, dt=1e-6, switch_fn=pwm)
res.v("tj")                    # junction temperature, °C
res.loss_events("Q1")          # t, kind, v, i, Tj, E (structured array)
res.device_energy("Q1")        # E_on, E_off, E_cond_electrical, E_cond_table, n_on, n_off
  • Temperature: junction="tj" reads the tables at the junction node's temperature before each event and heats that node (closed loop); Tj=125 reads at a fixed temperature, and with heat_node="tj" still heats that node (open loop), without it only records.
  • Reading rule: the table on the left of "Event losses on the periodic orbit" below, the same function (thermal::commutation_point) on both routes. On pwl, x⁻ / x⁺ are the samples before and after the step that changed the mask, the samples device_loss_summary reads: on a three-phase VSI at Tj = 125 the kernel's E_on / E_off per switch equal device_loss_summary(switch_specs=...) within 1e-9. A diode's E_off is its recovery, read at each natural turn-off.
  • Deposition: the heat of a step is a rectangular power over the next step; the trapezoid rule's capacitor history passes half of it on, so the network receives it over two steps (h/2 + h/2), exactly in sum while every step is trapezoidal (the default). A backward-Euler / SDIRK step (discontinuity_restart=True, a commutation split) keeps no capacitor current, so at each switch between step kinds up to half a step's heat can be lost or delivered twice while heat_injected counts the full amount. Measured on the 10 kHz chopper of the tests (20 ms, 1200 restart steps): the network's energy matches heat_injected within 4e-10 (2.7e-13 without restarts). Ten 1 mJ events into 0.01 J/K with no leak raise the junction 1.000 K (1e-6). res.heat_injected + res.heat_pending equals the recorded event and conduction energy within 1e-12 (the last step's heat is still pending when the run ends).
  • Conduction: conduction="electrical" (default) heats with the device's own electrical dissipation per step, as device_loss_summary reads it (energy balance closes); "table" with V_on(|i|, T_j)·|i| over the on-state ends of the step, trapezoidal. Both are reported.
  • engine="trbdf2" runs the same tracker: conduction with the integrator's stage quadrature (TR-BDF2 weights (w, w, d) at (0, γh, h), SDIRK (1-γs, γs), trapezoid on landings and probes), a commutation from the engine's left and right limits at the landed instant (the same reading rule and table call as pwl), and the heat as a power over the next step, consumed in proportion to the committed length (a landing keeps the rest owed).
  • Impulsive re-initialisation (an ideal switch closing a capacitor loop, opening a cut-set): the record's dW is booked to the device it names (cause) as device_energy(...)["E_impulse"] and heats its junction; that step's conduction is its end power only, as device_loss_summary reads the pulse step.
  • A resumed run (resume_from=) continues the tracker: the heat in flight, the ledgers and the events travel in the snapshot (pickle field 17).
  • Refusals by name (UnsupportedError / ValueError, naming the device): dsed / exact, bdf1, and auto when it resolves to dsed, refuse a circuit with a loss port; an unknown device, a device that is not a PWL switch or diode, both or neither of junction / Tj, conduction="table" without V_on, and a deposit node without a capacitor on it.
  • YAML: a losses: block on a switch, diode, mosfet, mosfet_with_body_diode or igbt (junction, Tj, heat_node, e_on, e_off, v_on, conduction; unknown keys refused).
  • Parts: part.attach_losses(b, "Q1", T_amb=40) builds the part's Foster or Cauer chain from a node Tj_Q1 and hands its tables over unreduced (a PLECS XML part through lib.import_plecs_xml); a synthetic part needs allow_synthetic=True.

Not covered: the event energy is not drawn from the circuit (the PWL switch is ideal); T_j does not change V_f or g_on; a device that flips twice inside one outer step (a commutation split) records no event, since only the step's end masks are compared; a thermal capacitor to ground starts at 0 °C from a zero initial state, and the first events read that (tie the capacitors to the ambient node, as above, or start from a DC operating point).

Device-level switching energy — add_power_mosfet

To simulate the switching transient itself instead of annotating it, build the device with CircuitBuilder.add_power_mosfet (channel, C_gs, C_gd(v), C_ds(v), R_g, body diode) and measure it with p.double_pulse_test(device_kwargs, V_dd=, I_load=, R_g_ext=, V_drive=, L_load=), which returns E_on, E_off, the Miller plateau, dv/dt, di/dt and I_rr as time-weighted integrals, starting from the off-state bias (an all-zero start turns the device on through C_gd before the gate command). Use engine="trbdf2"; on pwl the step must resolve the gate transient (0.2 ns for a 60 ns plateau). The datasheet fitters are in pulsim.datasheet. Losses of the composite are not in device_loss_summary yet (unified device interface).

What's not covered

The kernel runs at fixed dt. We don't resolve sub-dt switching waveform shapes — the PSIM annotations capture the right energy per event, not the instantaneous voltage/current trajectory through the nanosecond transition. For waveform-level accuracy on a single switching edge, drop dt ≪ T_sw or use a sub-step Newton step.

If you need a custom E_on(I, T_j) curve that doesn't fit the linear *_specs shape, fall back to a state-aware step_observer driving LossAccumulator.add_sample(...) + add_switching_event(E_sw) — documented in KNOWN_LIMITATIONS.md.

End-to-end example

examples/scripts/run_device_loss_to_thermal.py ships a 130-line buck → losses → T_j(t) pipeline with an optional --plot flag that overlays the steady-state Foster asymptote.