# 25. Thermal and losses

A converter is done when its hottest junction stays under the data sheet's limit with margin. This chapter takes one shipped example from a switching run to a junction temperature: the losses of each part (`analysis.losses`), the thermal network that turns watts into degrees (parts, heatsink, ambient), the steady and transient junction temperature (`analysis.thermal`, `thermal.summary`), the margin to the limit, and what to change when a part is too hot. [Chapter 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/04-simulation-settings/#thermal-parts-on-the-schematic) lists the thermal parts, [chapter 6](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/06-analyses/#losses-thermal-and-fft) the analyses; this chapter puts them in one order. The numbers are from a run of the example on a Linux computer; another computer can differ in the last digits.

## 1. The commands

| Command | What it does |
|---|---|
| `simulation.run` | Runs the circuit. The thermal network is part of it: its nodes are signals `T(<node>)` in °C. |
| `analysis.losses` | Average conduction and switching loss of each switch and diode, and the winding and core loss of magnetics, over a window. |
| `analysis.thermal` | First, minimum, maximum and final value of each thermal node; a junction with a limit also gets `limit`, `marginK` and `pass`. |
| `thermal.summary` | A temperature for every part that loses power, from the run, a placed heatsink or the data sheet's RthJA, with its margin. |
| `thermal.placeHeatsink` | Places a catalogue heatsink and its ambient on a case net, at the heat and airflow you give. |
| `thermal.placeFan` | Adds a fan that lowers the heatsinks' resistance at an airflow. |
| `design.thermal` | Picks a heatsink and pad (or board copper) for each device and, with `apply`, draws the whole network in one undo step. |

## 2. Losses of a switching run

Open **File › Open Example** and pick `buckThermal`: a buck whose switch `Q1` and diode `D1` each heat a thermal net. The same from the command line:

```sh
powercraft-cli run --accept-terms --cmd file.openExample --params '{"name":"buckThermal"}' \
  --cmd simulation.run --params '{}' \
  --cmd analysis.losses --params '{}'
```

The run is 20 ms long, 400 000 steps. `analysis.losses` reads the whole run (`window` 0 to 20 ms; give `t0` and `t1` for a steady part):

| Part | Conduction | Switching | Average |
|---|---|---|---|
| `Q1` | 2.93 mJ | 269.9 mJ | 13.64 W |
| `D1` | 39.1 mJ | 0 | 1.95 W |

The semiconductors lose 15.60 W in all (`semiconductorW`); this circuit has no magnetic loss model (`magneticsW` 0). The switch loses almost all of its heat while switching, the diode while conducting.

**Analysis › Loss Chart** draws the same budget as a picture:

![The loss chart of buckThermal: efficiency and total loss, the Sankey from input to output and losses, one bar per part, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/thermal-chart/01-losses.png)

1. Efficiency 79.53 % and the total loss, 15.6 W: the input 76.2 W less the output 60.6 W. Below it, the input splits into the output, conduction (2.1 W) and switching (13.5 W), and each loss into the parts that cause it.
2. **[Copy CSV]** copies the numbers, one row per part and category.
3. **Show data** lists the same numbers under the chart.

## 3. From watts to degrees

A loss becomes a temperature only through a thermal network: a junction net (the part's `thermal` parameter), a resistance or a Foster chain from the junction to the case (`rth`, `foster`, or the chain of the part's library device), a heatsink and an `ambient`. The network is solved with the circuit, so a loss that changes with the switching raises the temperature with its own time constants. In `buckThermal` the junction net is `tj` and the heatsink net `hs`. Place a heatsink on any case net with `thermal.placeHeatsink`; [chapter 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/04-simulation-settings/#example-a-mosfet-on-a-foster-chain-and-a-catalogue-heatsink) runs one end to end (2.30 W into a 11.97 K/W heatsink at a 40 °C ambient gives a 67.59 °C case). With no network at all, `design.thermal {"apply": true}` draws one for you.

## 4. Steady and transient junction temperature

```sh
  --cmd analysis.thermal --params '{}' \
  --cmd thermal.summary --params '{"ambient": 40}'
```

`analysis.thermal` reports, for `T(tj)`, a minimum of 40.00 °C (the start, at ambient), a maximum of 59.05 °C and a final value of 59.03 °C after 20 ms; `T(hs)` stays at 40.00 °C in this run. The curve between the minimum and the final value is the transient: `T(tj)` is a signal like any other, so the scope shows how fast the junction heats at start-up. To begin from the settled state instead of ambient, set `simulation.settings {"thermalStart": "steady"}` ([chapter 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/04-simulation-settings/)); then the first sample is already the steady temperature.

`thermal.summary` lists each part that loses power, hottest first. For `Q1` it reads 13.64 W and 59.05 °C with `source` `simulated`: the run's own peak. `D1` has no thermal network and no RthJA in the catalogue, so its `tC` is empty and it says it needs an Rth: nothing is guessed. A temperature needs a source.

## 5. The margin to the data sheet's limit

A switch or diode's limit is its `tjMax` (°C), else that of its library device. The example's `Q1` has no limit, so `marginK` is empty and nothing is flagged. With a device from the library, `analysis.thermal` adds `limit`, `limitFrom`, `marginK` (the limit minus the peak), `pass` and `crossedAt`; a run that passes a limit puts the part in `overTemperature`, warns with the time it first crossed, and `circuit.problems` lists an over-temperature problem. `simulation.settings {"stopOnOverTemperature": true}` ends the run at the first crossing. The overlay (**View › Overlays › Thermal Overlay**) tints each part up to its `tjMax` and outlines one that passes it.

## 6. Fixing a part that is too hot

Work down the chain; each step shows in the next run:

1. **Cut the loss.** A switch that loses its heat while switching: a slower frequency, a faster gate drive, a lower-Qg device. `analysis.losses` after each change shows what moved.
2. **Lower the case-to-ambient resistance.** A larger heatsink (`thermal.placeHeatsink` at the new part), more airflow (`thermal.placeFan`), a better pad.
3. **Split the heat.** `nParallel` puts N devices on one symbol: each junction carries 1/N of the current. In the shipped `halfBridgeParallelSic` three Wolfspeed C3M0065090D per switch lose 25.9 W in `Q1` (8.6 W each) and reach 67.5 °C on a 58.8 °C heatsink (chapter 4 has the circuit and the test that checks it).
4. **Let the tool choose.** `design.thermal` picks a catalogue heatsink and pad (or board copper) for each device and, with `apply`, puts them on the schematic in one undo step.

Then run again and read `thermal.summary`: the hottest part, its margin, and whether any part still says it needs an Rth.

### A worked fix

Take `buckThermal` and give `Q1` a poor path to air: set `Rth` to 10 K/W and `Cth` to 200 µJ/K, and give `Q1` a limit of 125 °C (`tjMax`; this generic switch has no data sheet, so the limit here is the reader's own, not a part's). Turn on **View › Overlays › Thermal Overlay** and run:

```sh
  --cmd circuit.setParam --params '{"component":"Rth","key":"r","value":10}' \
  --cmd circuit.setParam --params '{"component":"Cth","key":"c","value":0.0002}' \
  --cmd circuit.setParam --params '{"component":"Q1","key":"tjMax","value":125}' \
  --cmd simulation.run --params '{}' --cmd analysis.thermal --params '{}'
```

![The buck with the thermal overlay: Q1 red at 177 °C, past its 125 °C limit, and the 10 K/W Rth, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/thermal-fix/01-too-hot.png)

1. `Q1` loses 13.69 W, and its junction passes 125 °C at 1.94 ms and peaks at 177.19 °C: `marginK` −52.19, `pass` false. The run lists it in `overTemperature`, and the overlay outlines it and labels its peak.
2. `Rth`, 10 K/W: 13.7 W across it is about 137 K above the 40 °C ambient.

Almost all of `Q1`'s loss is switching loss, which scales with frequency, so cut the loss first (step 1 above): set the `PWM` block's `freq` from 100 kHz to 50 kHz and run again.

![The same buck at 50 kHz: Q1 at 111 °C, under its limit, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/thermal-fix/02-fixed.png)

1. `Q1` now loses 7.06 W (switching 137.7 mJ over the 20 ms run, half of the 269.7 mJ before), and its junction peaks at 110.93 °C: `marginK` 14.07, `pass` true, and `overTemperature` is empty.
2. The `PWM` block at 50 kHz. Half the frequency doubles the inductor's current ripple, so check the output ripple and the inductor's saturation current before you keep the change; a larger heatsink (step 2) is the fix that leaves the power stage as it is.
