4. Simulation settings
Open Simulation > Settings (simulation.settings). The form shows the current settings; change the fields you want and press Enter. The settings are saved with the circuit. Copy JSON, the icon beside Cancel, copies the same settings as a JSON object for a script, the console or an agent, where you only send the keys you want to change and the others keep their values:
{"tEnd": "10m", "maxStep": "50n", "solver": "fast", "fixedStep": true}
The same settings as a form:
- Stop time.
- Solver.
- Fixed step.
- Copy JSON.
- Apply and run.
The settings
| Key | Default | What it does |
|---|---|---|
tEnd |
1m |
End time of the run, in seconds |
maxStep |
100n |
The step the solver uses. In fixed-step mode it is the step; in variable-step mode it is the largest step |
solver |
fast |
fast or reference (below) |
integration |
trapezoidal |
trapezoidal, backwardEuler or exact (below) |
fixedStep |
true |
true for a constant step, false for an error-controlled step (below) |
minStep |
0 |
Variable step only. The smallest step. 0 means maxStep / 1024 |
relTol |
1e-3 |
Variable step only. Relative error tolerance |
absTolV |
1e-6 |
Variable step only. Absolute tolerance on capacitor voltages, in volts |
absTolI |
1e-9 |
Variable step only. Absolute tolerance on inductor currents, in amperes |
maxSteps |
20meg |
The most solver steps one run may take, up to 2g (2 000 million) |
saveFrom |
0 |
Record from this time on. The run still simulates from 0 |
printStep |
0 |
Keep about one sample per interval (and a switching edge). 0 keeps every step |
printEvery |
0 |
Record every Nth step: keep one solver step in N, evenly spaced, and the last step. 0 or 1 keeps every step |
switchingLossFromCircuit |
false |
Draw switching loss: true makes each switch draw its eon, eoff or err energy (or its device tables' energy) from the circuit, so the terminal powers include it. false only adds it to the loss totals |
thermalStep |
0 |
Multi-rate: the thermal network's own step (below). 0 steps it with the circuit |
thermalStart |
ambient |
Where the thermal network starts: ambient, steady or {"<node>": °C} (below) |
fastRefactor |
true |
Reuse pivot order (fast solver): a step that lands on an event reuses the pivot order of its switch state instead of factoring the matrix in full. A reused pivot that is too small, or factors that grow too much, factor in full after all. Faster on converters with many events per period (LLC, phase-shifted bridge). Turn it off to reproduce a run made before it was on by default; the two differ at rounding level |
stopOnOverTemperature |
false |
Stop when too hot: true ends the run the first time a junction passes its tjMax (the part's, else its device's), and the reply's stoppedBy says so. false lets the run go on and only warns (see Analyses, Over-temperature) |
record |
auto |
Recorded signals: all records every signal; inUse only the ones something reads (below); auto records all of them unless that would pass 64 MB on a run the app shows, then only the ones in use |
Times accept SI suffixes: "10m", "50n". Note that m is milli: an end time of one second is 1, one minute is 60, and 1m is one millisecond. The same goes for counts: write 60 million steps as 60meg or 60e6, because 60M means 60 milli.
Test bench ports: supply and load on connectors
A board's input and output are connectors on the schematic (J1, J2), not a battery and a load resistor. What drives each one in a simulation is set under Properties › Simulation › Test bench ports and saved with the circuit. Each port row shows its connector and pins, a kind (DC supply with Voltage and Source resistance, Resistive load with Resistance, or Current load with Current and an optional Step at / Step to), its values and Remove. A value can be a number (12, 4.7m) or an expression over the circuit's variables (vin), so a sweep of vin sweeps the supply. A row whose connector has an open pin, or whose expression does not evaluate, says why under it. Picking another kind keeps the old port until the new kind's first value is typed. Add port gives a free connector a port once its first value is typed, and Make Port from Part turns a DC source, load resistor or DC current source drawn on the schematic into a port on a connector across the same nets; on the schematic, right-clicking one such part offers the same as Make test bench port. Each change is one undo step and runs testbench.setPort, testbench.removePort or testbench.fromPart; the run stamps the port as J1.bench, so i(J1.bench) is the supply's current. The same section shows under the fields of the Simulation > Settings form, so the run and what drives it are set up in one place; a port edit there applies at once, as in Properties, and the form's Apply applies only its own fields. With View › Studio Layout (Preview) on, the gear first on the Transient tab's toolbar, Simulation setup, opens that form. In the Studio layout the form lists the analyses down its left side (Transient, Steady state, AC sweep, Loop gain, DC operating point, Parameter sweep, Worst case, Monte Carlo) in place of the Analysis row: the one picked is what Apply and run runs once the settings are applied. Transient and Steady state run at once; every other analysis opens its own form.
Switching loss in the circuit
A switch with switching energies (eon, eoff, err, or a device's tables) books that energy at each switching event in its loss totals (analysis.losses). By default the circuit does not give the energy up, so the terminal powers and the efficiency read from them do not include it; design.efficiency adds it back from the tables. With Draw switching loss on (switchingLossFromCircuit: true) the circuit gives it up: the source delivers more, or the output gets less. Then the terminal powers, the efficiency read from them and analysis.losses agree. In the example buck with 60 µJ per period, energy in equals energy out plus stored energy, conduction and switching losses to within 0.5 % of the energy in (crates/refsolve/src/loss_sink_tests.rs).
How it is drawn: the switch takes the energy as an extra voltage drop while it conducts, like a small extra resistance. The drop is set when a conduction interval starts and kept for the whole interval: it is the energy the switch booked per charge it conducted over about its last 256 periods, plus what it still owes spread over 16 intervals, and at most half the blocking voltage and twice its typical value. A turn-on's energy is drawn in the same interval, a turn-off's or a recovery's in the device's next one, so a period's energy is drawn within about one period, and the end of a run may leave some still to draw. A blocking switch draws nothing. A hard turn-on is booked one step after the switch closes, at the current it carries then, so the discharge of a capacitance across the switch (coss, a snubber) is not read as load current. A diode with simulated reverse recovery (qrr) already takes its recovery energy through its reverse current, so its err is not drawn a second time. Switches at the dynamic gate level simulate the transition itself and need none of this. In an open-loop converter the drop lowers the output, as real switching loss does; a closed loop corrects for it.
It is off by default for now: in the light-load corners of some flybacks that design.auto draws, the drawn loss interacts with the control loop and those corners settle more slowly than the verification allows. Turn it on to check a design's terminal efficiency directly.
Two solvers
- fast is the everyday solver. It is built for switching circuits. It reuses matrix factorisations while the switches stay in the same state, so long runs are quick.
- reference is a deliberately simple solver. It is slower, and it always takes fixed steps. Its job is to be an independent check. When you doubt a result from the fast solver, run the same circuit with
"solver": "reference"(the Run command also accepts{"solver": "reference"}) and compare. The two solvers agree to within small tolerances on the built-in examples, and the test suite checks both against analytic answers and against ngspice.
Fixed step or variable step
Fixed step advances by maxStep every time (a step is only shortened to land exactly on a switching edge). It is predictable. Its cost is tEnd / maxStep steps, so the right step size matters:
- A good starting point for a switching converter is
maxStep = 1 / (fsw * 200), which is 200 steps per switching period. The template command uses this rule. - If the waveform looks jagged, or a ringing circuit is wrong, make the step smaller.
- If the run is slow, make the step larger and look at the result again.
Variable step ("fixedStep": false) works like SPICE. The solver estimates the local error at each step, takes big steps where the waveform is smooth and small steps where it changes fast. It still lands exactly on every switching event. Steps are chosen from the ladder maxStep * 2^-k and are never smaller than minStep.
Use variable step when:
- the circuit has fast transients followed by long quiet stretches (start-up, a load step, a resonant tank);
- the parts are non-ideal and ring (small parasitic capacitances, saturation, reverse recovery).
Stay with fixed step when you want identical sample spacing, for example before an FFT.
To tighten the accuracy, lower relTol (for example 1e-4). To stop the solver from taking tiny steps at a hard edge, raise minStep.
Exact steps
With "integration": "exact" the fast solver does not approximate the circuit between switching events: it solves it. A circuit of resistors, capacitors, inductors, coupled inductors, transformers, linear sources and ideal switches, diodes, MOSFETs, IGBTs and thyristors is linear for as long as no switch changes state, and its waveform over a step then has a closed form (a matrix exponential). The solver builds that model once for each switch state it meets, steps with it, and finds the instant a diode stops or starts conducting on the solution itself, to a billionth of maxStep. Gate edges are landed on as always.
What changes:
- The waveform no longer depends on the step. The open-loop buck example gives the same
v(out)to within 2·10⁻⁸ (relative) atmaxStep50 ns, 500 ns and 2 µs; trapezoidal steps at 50 ns are within 1.2·10⁻⁷. A ring faster than the step (a snubber, a leakage inductance) is solved exactly, not damped or aliased. maxStepnow only sets how densely the result is recorded (and how often the controls run). Choose it for the plot you want: about 20 samples per switching period draw the ripple to within about 1 %, while the values at the samples stay exact.- A switching inside a step is looked for every sixteenth of
maxStep. A current that crosses zero and comes back within less than that is missed, as it would be with a step that long. - At the same
maxStepan exact step costs about three times a trapezoidal one, but it can take far longer steps for the same accuracy. Incrates/fastsolve/tests/exact_bench.rsthe flyback example at 1 µs runs nine times faster than trapezoidal steps at 20 ns and is 70 times closer to a run at 1 ns.
The other solver and the other parts: the reference solver always integrates trapezoidally. A circuit with a part that is not piecewise linear (a saturating inductor or a core, a thermal network, reverse recovery, a machine, a level-1 MOSFET, a behavioural source, a protection device) runs with trapezoidal steps instead, and a warning names the part. So does a circuit with more than 64 capacitors and inductors. How it works, and the references: docs/design/pwl-solver.md.
Large circuits
The fast solver switches to a sparse matrix factorisation by itself when a circuit has more than 40 unknowns and at most one eighth of the matrix entries are non-zero. Most large circuits look like this: a long RC ladder, a many-phase converter, a big imported netlist. A circuit with 40 unknowns or fewer keeps the dense factorisation and gives exactly the same numbers as before. A large sparse circuit gives the same waveforms as the dense method to within rounding. If the sparse factorisation ever fails, the solver falls back to the dense one, so you see the same error messages as before. There is nothing to set.
Thermal parts on the schematic
The thermal library has, besides rth, cth and ambient, four parts with pins a (hot side) and b (cold side):
foster: a data sheet's Foster table,r(K/W) andtau(s). Into a side with no heat capacity of its own (an ambient, or resistances and heatsinks on to one) it stays a Foster chain, which then adds to them exactly; into a side that stores heat (acth, acauerladder, a device's junction ladder) it becomes the equivalent Cauer ladder, as a device's own chain does.form=fosterorcauerforces one.zth: pointst,zread off the data sheet's Zth(t) curve; a Foster chain of up totermsstages (8 at most) is fitted when the circuit is built, then it acts likefoster. End the points where the curve has levelled off.cauer: a ladder ofrandc, each node with its heat capacity to the reference.heatsink: a catalogue heatsink's sink-to-ambient resistance. Place it withthermal.placeHeatsink {part, watts, airflow, a, ambient}: it readsparts/heatsinks.jsonat that heat and airflow, asdesign.thermaldoes, so the coolingdesign.thermalpicks goes on the schematic with one command. An extrusion goes on withthermal.placeHeatsink {part, lengthMm, airflow, a, ambient}at a cut length its data sheet rates, its resistance read between the sheet's airflows. The catalogue gives no heat capacity for these heatsinks, so the part has none. On a circuit with no thermal network yet,design.thermal {apply: true}places the whole network it picked in one undo step: each device'sthermalnet and junction-to-case path, the pad and heatsink (or the board copper), one ambient part, and a steady thermal start. It refuses a circuit that already has a thermal network.coolingFan: a fan that blows across heatsinks. Place it withthermal.placeFan {part, airflow, cools}:airflowis the air speed across the heatsinks (from the fan's curve and duct, not its free-air flow), and for each heatsink incoolsthe command reads its data sheet again at that airflow and writesfanRth(and the rise tablefanCurveW,fanCurveK). The fan has no pins. While it is fitted and simulated the run uses those values; mark it DNP, switch its simulation off or leave it out of a project variant, and the heatsinks keep their ownrth. So comparing two variants shows what the fan buys, and the electrical result is the same in both.bom.exportlists it underpart, with the data sheet when that is a catalogue fan (Delta AFB0812SH, AFB0912VH, AFB1212SH-F00), andboard.addFootprintsplaces the footprint itsfootprintparameter names, every pad on no net.
None of these parts has default values: a part without its data-sheet numbers stops the build and says which are missing.
Example: a MOSFET on a Foster chain and a catalogue heatsink
An always-on MOSFET (ron 0.1 Ω) passes 24 V into 4.9 Ω, so it dissipates 2.30 W into the thermal net j. A four-stage Foster table runs from j to the case, and thermal.placeHeatsink mounts a Same Sky HSE17-252525P on the case at that heat, in still air, with a 40 °C ambient:
powercraft-cli run --cmd file.new --params '{"name": "heatsinkDemo"}' \
--cmd circuit.addComponent --params '{"name": "Vin", "kind": "dcVoltageSource", "params": {"v": 24}}' \
--cmd circuit.connect --params '{"component": "Vin", "port": "p", "net": "in"}' \
--cmd circuit.connect --params '{"component": "Vin", "port": "n", "net": "0"}' \
--cmd circuit.addComponent --params '{"name": "On", "kind": {"kind": "control", "block": "constant"}, "params": {"value": 1}}' \
--cmd circuit.connect --params '{"component": "On", "port": "out", "net": "g"}' \
--cmd circuit.addComponent --params '{"name": "Q1", "kind": "mosfet", "params": {"ron": 0.1, "thermal": "j"}}' \
--cmd circuit.connect --params '{"component": "Q1", "port": "d", "net": "in"}' \
--cmd circuit.connect --params '{"component": "Q1", "port": "s", "net": "out"}' \
--cmd circuit.connect --params '{"component": "Q1", "port": "gate", "net": "g"}' \
--cmd circuit.addComponent --params '{"name": "R1", "kind": "resistor", "params": {"r": 4.9}}' \
--cmd circuit.connect --params '{"component": "R1", "port": "p", "net": "out"}' \
--cmd circuit.connect --params '{"component": "R1", "port": "n", "net": "0"}' \
--cmd circuit.addComponent --params '{"name": "ZJC", "kind": {"kind": "thermal", "element": "foster"}, "params": {"r": "0.05, 0.1, 0.2, 0.15", "tau": "1e-4, 1e-3, 1e-2, 1e-1"}}' \
--cmd circuit.connect --params '{"component": "ZJC", "port": "a", "net": "j"}' \
--cmd circuit.connect --params '{"component": "ZJC", "port": "b", "net": "case"}' \
--cmd thermal.placeHeatsink --params '{"part": "HSE17-252525P", "watts": 2.3, "a": "case", "ambient": 40}' \
--cmd simulation.settings --params '{"tEnd": "500m", "maxStep": "5u"}' \
--cmd simulation.run --params '{}' \
--cmd scope.measure --params '{"signals": ["T(j)", "T(case)"]}'
The Foster numbers are round illustrative values, not a part. The reply to thermal.placeHeatsink gives rth 11.97 K/W: the data sheet's rise of 24.0 K at 2 W and 35.8 K at 3 W, read on the straight line between them at 2.3 W. It also cites the data sheet (revision 1.01, 2025-11-17) and names the ambient part it added (HS1_Ta1). After 0.5 s, T(case) is 67.59 °C (40 °C + 2.30 W × 11.97 K/W) and T(j) is 68.74 °C, 1.15 K higher across the chain's 0.5 K/W. The chain stays a Foster chain here, because the heatsink holds no heat.
Q1: its losses flow into the thermal netj.ZJC: the four-stage Foster chain fromjto the case.HS1: the heatsinkthermal.placeHeatsinkplaced,rth11.97 K/W.HS1_Ta1: the 40 °C ambient it added.
Paralleled devices: nParallel
One switch, diode or MOSFET on the schematic can stand for N identical devices in parallel: set nParallel (a whole number from 1 to 1024; the default 1 changes nothing). The element's current is shared, so every loss table is read at one device's current, ron and roff are one device's values (the element's are ron/N and roff/N) and the switching and conduction energies are N devices' worth. The junction chain of a library device is one device's Zth,jc divided by N (R/N, the same time constants), so the junction node reads one device's temperature while the heat into the case is the total. Two IGBTs of 0.5 K/W on one case at 2.0 K/W, 10 W in all: Tj = ambient + 10 W × (0.5/2 + 2.0) K/W, and the case sits at ambient + 10 W × 2.0 K/W. Ideal-current sharing is assumed: no mismatch of vth, ron or layout between the devices. An exponential diode and a MOSFET with gate dynamics refuse nParallel above 1; place the devices side by side there. bom.export buys the part N times (a line N x part number, each device rated for I/N), and design.thermal puts the total loss on the heatsink and one device's P/N through each junction's own case, with N in its device table.
Example: three paralleled SiC MOSFETs per switch
The example halfBridgeParallelSic (File › Open Example › DC-DC) is a synchronous half-bridge from 400 V to 200 V at 50 kHz into 6.67 Ω, so 30 A in the inductor. Each of its two switches is one MOSFET symbol with nParallel 3 and device wolfspeed/c3m0065090d: three Wolfspeed C3M0065090D from the device library (data sheet Rev. 08), whose conduction, body-diode and switching-energy tables and four-stage Foster junction-to-case chain (RthJC 1.0 K/W) come with the library entry. Both switches sit on one heatsink net hs, 0.5 K/W to a 40 °C ambient, and the run starts at its thermal steady state (thermalStart steady). The heatsink, load and filter values are illustrative.
powercraft-cli run --cmd file.openExample --params '{"name": "halfBridgeParallelSic"}' \
--cmd simulation.run --params '{}' \
--cmd analysis.losses --params '{"t0": "0.5m"}' \
--cmd analysis.thermal --params '{}'
Over the last 0.5 ms of the 1 ms run:
| Loss, the three devices | Loss per device | Tj at the end |
|
|---|---|---|---|
Q1 (hard-switched) |
25.9 W | 8.6 W | 67.5 °C |
Q2 (synchronous rectifier) |
11.8 W | 3.9 W | 62.7 °C |
The heatsink T(hs) sits at 58.8 °C: 40 °C plus the heat of all six devices times 0.5 K/W. Each junction sits one device's loss times 1.0 K/W above it: T(Q1.j) reads one device's temperature, not the sum. The same circuit with one device per switch at a third of the current (nParallel 1, the load, the inductor and the heatsink's resistance three times larger, the capacitor a third) gives each device the same loss and the same Tj; crates/engine/tests/parallel_sic.rs checks that, and that this table is what the run gives.
The Problems tab checks the device's Foster table too. Embed a copy of the device with its four stages in the wrong order (device.get, reverse thermalJc, device.add) and circuit.problems warns thermal.device_order: "the junction-to-case Foster table of device wolfspeed/c3m0065090d has time constants that do not rise", with the hint to re-enter the stages from the data sheet, fastest first. It has no one-click fix, because the table is the device's own data.
Thermal data checks
The Problems tab (chapter 8) checks the data a data sheet fills in: a foster table whose time constants do not rise (fix: sort the stages, each resistance stays with its own time constant), a zth curve whose times do not rise or whose impedance falls (fix: drop unusable points, sort by time, raise each impedance to the largest before it), a zth fit that misses the curve by more than 5 % of its largest impedance (fix: fit with the fewest terms that reach the limit, up to 8), and lists of different length or with a value that is not positive. A device's own Foster table in the circuit is checked for order, without a fix.
Limits of the thermal parts
thermal.placeHeatsinkplaces only the parts inparts/heatsinks.json. An unknown part, a heat beyond the data sheet's table or an airflow slower than any of its curves is an error, never a guess. Between two airflow curves it reads the slower one.- The heatsink's
rthis read once, atwatts, and stays fixed during the run. When the heat changes, place it again at the new heat. - The catalogue gives no heat capacity for its heatsinks, so a placed heatsink has none and its temperature follows the heat at once: in the example
T(case)is at 67.59 °C from the first step. For the warm-up, add acthfrom the heatsink's data sheet when it gives one. - A
zthfit has at most 8 stages and is only as good as its points: end them where the curve has levelled off. nParallelshares the current equally. The case, and so the heatsink, is one node: it gets the total heat of all N devices.
Multi-rate: a slower thermal step
A circuit with a thermal network (device junctions, Foster or Cauer chains, heatsinks) steps that network with every circuit step by default. Thermal time constants are milliseconds to seconds, and the circuit's step is nanoseconds to microseconds, so most of that work changes nothing you can see. Thermal step (thermalStep, in Properties › Simulation and simulation.settings) lets the thermal network step at its own, slower rate:
- The circuit keeps its own step (
maxStep, event landing, everything else as before). - The thermal network steps only on its own grid, every
thermalStepseconds. Over each interval it receives the average power the devices dissipated in it, so it gets exactly the energy they lost. A circuit step that crosses a grid instant is split there. - Between grid instants the junction temperatures the devices read (for their loss tables and on-resistance) and the recorded
T(…)signals hold their last value, so they lag by at most one thermal step and show as small steps in the scope.
Both solvers do the same, so they still agree with each other. Pick about a tenth of the fastest thermal time constant: for inverter3Thermal (fastest Foster stage 0.5 ms) that is 50u, which stays within 1 % of the single-rate run in junction and heatsink temperature, device energy and phase current. thermalStep must be 0 or between maxStep and tEnd. The device energies E(…) are still summed at every circuit step.
{"thermalStep": "50u"}
Thermal warm start
A short run starts cold; use thermalStart steady to see the operating temperature. Every thermal node starts at the ambient's temperature by default, and a heatsink takes tens of seconds to minutes to warm up, so a run of a few tens of milliseconds shows only the fast rise of the die, never the junction temperature the converter runs at. Thermal start (thermalStart in simulation.settings) changes where the network starts:
ambient(the default): every node at ambient, as before.steady: a pre-run of a few switching periods measures each loss source's average power into the thermal network. The network's DC steady state with those powers (heat capacities open) gives the starting temperatures. The losses depend on the temperature (on-resistance rises with Tj), so the pre-run measures again at the new temperatures, up to 8 rounds, until no node moves by 0.1 K. A search that ends with a node still moving by 0.5 K or more is an error naming that node, never a start. An inverter whose modulator turns an angle at a constant speed (a dq current loop, as ininverter3Thermal) repeats over its line period, not its switching period: the pre-run settles for two line periods and each round measures over one whole line period, so every switch of a leg is measured over the same complete cycle. The pre-run first finds the electrical steady state, so the losses are not those of the start-up. The run itself then starts from t = 0 with its usual electrical initial conditions and the network at those temperatures. The reply tosimulation.runhasthermalStart {method, rounds, residualK, temperatures}: the rounds taken, the last round's largest change in kelvin and every node's starting temperature.{"<node>": °C, …}: those thermal nodes start at those temperatures, the rest at ambient. A node is named as in itsT(…)signal without theT(), for exampleQ1.jfor a device junction. An unknown node, or an ambient (a fixed temperature), is an error that names it.
Both solvers pre-run with their own steps and agree. A network with a heat capacity that reaches ambient only through another capacity has no steady state, and steady says which node. The setting is saved with the circuit (left out at ambient).
{"thermalStart": "steady"}
{"thermalStart": {"Q1.j": 95, "hs": 80}}
In the app, Thermal start in Properties › Simulation › Advanced (with nothing selected) picks Ambient or Steady state. Under it, Start temperatures per node is the table of the third form: type a node's name, then its temperature in °C, and the row joins the table; edit a row's temperature in place, or Remove it. While the table holds nodes, Thermal start reads Per node; removing the last row, or choosing Ambient or Steady state, clears it. After a run the status line says how the network started, for example simulated 40000 steps, 15 signals; thermal start: steady state after 2 rounds, last change 0.015 K for buckThermal with a 2 ms end time.
- Thermal start: Per node, because the table holds a node.
- Start temperatures per node.
- The junction
tjstarts at 95 °C.
Long runs (1 s, 1 min)
A converter switching at 100 kHz needs a small step, so a run of one second or one minute takes tens or hundreds of millions of steps and records a lot of data. Four settings in Properties › Simulation (and in simulation.settings) make such runs practical. A line under the fields estimates the run from the end time, the step and these settings, for example ≈ 60 M steps · ≈ 1.8 GB for 93 signals · run ≈ 2 min to 8 min. The run time comes from a short timed probe of the circuit (a few hundred to a few thousand steps, at most 0.5 s, once per change; not in the browser), so it is an order of magnitude, as simulation.estimate's runTime is. When the middle of that range is over a minute, the line turns to the warning colour and suggests a larger Max time step, the averaged mode, fewer recorded signals or the fast solver:
- Max steps (
maxSteps, default20meg) is the most steps one run may take. A run that needs more stops with an error (a fixed-step run before it starts), and the message says to raise Max steps (or to use a largermaxStep, or a shortertEnd). You can raise it up to2g. The estimate turns red when the run is over Max steps. A command's ownmaxSteps(for examplesimulation.run {"maxSteps": 1000}) can only lower the setting, never raise it. - Save from (
saveFrom) skips the start-up in the recording. The solver still simulates from time zero, so the circuit reaches the same state, but only samples at or after Save from are kept. The first kept sample is the first step at or after that time, and the scope's time axis starts there. If a converter takes 0.9 s to settle and you want to look at the last 100 ms, set the end time to1and Save from to0.9: the recording is a tenth of the size. - Print step (
printStep, in seconds, like PSIM's print step) keeps about one sample per interval instead of every step. The solver still takes every step, so the accuracy is the same; only the recording is thinner. A plain one-sample-per-interval rule would miss every pulse that falls between two samples, so the recorder also keeps the first step in each interval where a switch changed state. Every interval that holds a switching edge shows one, so no train of pulses disappears from the recording. The trade-off: between those samples the ripple is not recorded, and when several edges fall in one interval only the first is kept. For a scope view of individual switching periods, use a print step a few times shorter than the switching period, or0. A run recorded with Save from or Print step is not split into slices in the browser; it runs in one go. - Record every Nth step (
printEvery, a whole number, under Advanced) keeps one solver step in N: steps N, 2N, 3N and so on, and always the last step. Unlike Print step it counts steps, not time, and it keeps no extra switching edge, so with a variable step the samples sit closer together where the solver took short steps. The kept samples are the full run's own samples at those steps, not averages. With Save from and Print step set too, a step is kept only when all three keep it.0or1keeps every step, and the file leaves the setting out. A run with it is not split into slices in the browser.
Recorded signals: only the ones in use
A large circuit has hundreds of signals: every node voltage, every branch current, every control signal, the nets inside each subsystem. A run records all of them at every kept step, although a scope shows a few. Recorded signals (Properties › Simulation › Advanced, simulation.settings {"record": ...}) records only the signals in use:
- the signals on the scope tabs, the probes, and what the math signals read (through other math signals and probes);
- the traces the quick view shows, its power pairs and its XY axis (the app passes them to
simulation.runasalsoRecord); - what power and efficiency read: each DC source, battery, resistor or power load to ground (its net's voltage and its current), and the source, load, inductor, capacitor and nets of the converter the circuit is recognised as, which are also what the Test Bench measures;
- what the design checks and the mode and current-flow views read: each switch's gate signal, the currents of the switches, diodes and inductors and the voltages of their nets, the CMTI rates of isolated parts, and every temperature.
The solver still computes every signal, so the results are the same; only the recording is smaller. Automatic (the default) records every signal while that recording stays under 64 MB and the signals in use past it. Below 64 MB, recording everything costs little: on the 365-signal hvdcMmc example, a 0.5 s run takes 0.29 s and 56 MB with every signal, 0.23 s and 22 MB with the 30 in use. Past 64 MB the full recording takes most of the session's memory, an earlier run that large is moved to disk as soon as the next one arrives, and past 40 million values the recorder thins it to every Nth step. The signals in use keep every step much longer: a 2 s run of hvdcMmc keeps 100 001 samples of 30 signals in 31 MB, against 50 001 samples (every second step) of 365 signals in 89 MB.
Automatic applies to runs a view shows, which is every run started in the app. A run from a script, the command line or an agent (no alsoRecord) records every signal under Automatic, because what it reads afterwards is not known before the run; set Signals in use to trim it there too.
A signal the run left out is listed in the scope's signal list with a redo arrow after its name ("not recorded in this run; run again to see it"). It is never drawn: there are no samples, and nothing stands in for them. Tick it and it is in use: the next run records it. Commands that read it (waveform.get, scope.measure) say it was not recorded in this run instead of returning data, and the run reply lists every left-out signal in unrecorded. simulation.estimate gives signals (recorded) and allSignals; the estimate line under the fields says for 30 of 365 signals (in use).
The recorder keeps at most 40 million values (about 320 MB). When the estimate is over that, it says so in the warning colour, and the run keeps one step in N to fit. Which step of each N it keeps moves from block to block (an equidistributed sequence), so the kept samples fall at every phase of the switching period and a steady state draws the same ripple from the start of the run to its end. Keeping exactly every Nth step would sample the ripple at a few fixed phases when N and the steps of a period share a factor, and the band drawn would jump wherever that changed. A larger Print step or a later Save from keeps more detail where you need it.
Steady State (the button under the settings, or Simulation › Steady-State Analysis) skips the start-up altogether: it solves for the state at the start of a period that comes back after one period (a shooting-Newton search: a few trial periods instead of the hundreds or thousands a large bulk capacitor, a resonant tank or a heatsink needs to settle), checks it by running on until the waveform repeats, then shows the last period in the scope. Save from and Print step do not apply to it; the period it shows has every step.
Hours of a battery: simulation.batteryRun
A real battery charges or discharges over hours. A switching run of one hour at a 1 µs step is 3.6 billion steps, which is why the batteryCharger example shrinks its pack to 1 mAh. simulation.batteryRun runs the real pack in under a second of solver time:
- The converter runs on its averaged model, as
simulation.run {"model": "averaged"}does, so the circuit must be one the averaged model knows: a buck, boost, buck-boost, SEPIC or flyback. A circuit that is already averaged (a system of averaged drives and rails with no switching converter, such asamrRobotSystem) runs as drawn, on its own step, with"model": "asDrawn". - It runs in short bursts, each until every battery's current settles. Between the bursts the time jumps on by seconds to minutes, and only the batteries' charge and RC branches move, by the battery's own equations at the settled current.
- The controller stays in the circuit. Its constant-current, constant-voltage or other logic is what each burst settles to, so a CC/CV charge keeps its knee and its falling current.
- The jump adapts to how fast the current changes, and it lands exactly on
stopCurrent,stopSocand every corner of a source's waveform or a load'sprofile(a mission profile's load steps).
Choose Simulation › Long Battery Run, type the end time and press Run (the tutorial Long battery runs walks through it), or run it from the console (View › Console, chapter 13), a script or the command line:
powercraft-cli run \
--cmd file.openExample --params '{"name": "batteryChargerLongRun"}' \
--cmd simulation.batteryRun --params '{"tEnd": 5400}'
| Parameter | Default | What it sets |
|---|---|---|
tEnd |
(required) | The end time in seconds, up to 120 days: a whole charge or discharge |
battery |
the only battery | The battery that stops the run and is reported |
stopCurrent |
none | End once that battery's current falls to this magnitude after it was above it: a charger's termination current |
stopSoc |
none | End once its state of charge reaches this value, 0 to 1 |
maxSocStep |
0.01 | The most one jump may move any battery's state of charge |
tolerance |
0.02 | The relative error of the battery current a jump may leave |
maxJump |
tEnd/100 |
The longest jump, in seconds |
cycle |
none | The period of a repeating mission, in seconds (below) |
model |
averaged |
asDrawn runs a circuit that is already averaged as it is |
solver, maxSteps |
as simulation.run |
maxSteps counts the whole run |
The reply is simulation.run's summary plus batteryRun: the battery, bursts and jumps, simulatedSeconds (the time the solver stepped) and jumpedSeconds, longestJump, unsettledBursts, stoppedBy (tEnd, stopCurrent, stopSoc or cancelled), and the end time t, soc, current (discharge positive, in A) and voltage. On batteryChargerLongRun (four Molicel INR-21700-P45B cells, 4.5 Ah, charged from 20 %) the 5400 s run takes 39 674 steps in 155 bursts and 153 jumps, the longest 54 s; the solver steps through 0.79 s of it. The pack charges at 4.5 A for about 44 minutes, then holds 16.8 V while the current falls, and ends full at 16.80 V with 0.4 mA flowing. A switching run of the same charge would need about 2.7 billion steps.
docs/accuracy.md ("Long battery run") checks the mode against the battery's own equations under an ideal CC/CV charger, on a 4s 5 Ah pack charged at 1 C to C/20: the change from constant current to constant voltage at 2442 s against 2449 s, the termination at 3282 s against 3264 s, and the charge at termination 95.1 % against 95.1 %, on both solvers.
What it does not show:
- The switching ripple. Every recorded signal has samples only where the solver ran, with a straight line across each jump. To see the ripple, run a switching window (below).
- Other slow states. A supercapacitor or a heatsink moves only during the bursts, not across the jumps, and the battery's
tempis a parameter, not a state.
A repeating mission: cycle
A robot doing the same task over a shift never settles from one moment to the next, but it does from one task to the next. Give cycle, the task's period, and every burst runs whole cycles, a battery's current is its mean over one cycle, and every jump is a whole number of cycles, so every waveform that repeats with the cycle keeps its phase. The corners inside a cycle are crossed, not landed on, so every waveform of the mission must repeat with cycle. Every integrator block (an energy meter, a charge counter) moves on across a jump by its change over a cycle, following that change's trend as the battery's current does; a pi controller's state stays. The last cycle always runs on the solver, so the recorded signals end where the run does.
amrRobotSystem repeats its 40 s task (Ttask), so a shift is one command:
powercraft-cli run \
--cmd file.openExample --params '{"name": "amrRobotSystem"}' \
--cmd simulation.batteryRun --params '{"tEnd": 7200, "cycle": 40, "model": "asDrawn", "maxSocStep": 0.05, "maxJump": 1800}'
Two hours, 180 tasks, run as 13 tasks on the solver (7 bursts) and 6 jumps of up to 45 tasks: 520 001 steps where 180 plain tasks take 7.2 million. The pack gives 342.9 kJ, within 0.01 % of 180 times one task's 1904.7 J, and its charge falls from 80 % to 70.5 %, 1 % more than 180 times one task's drop because the current rises as the pack's voltage falls. Meter.runtime then reads 13.7 h.
When a circuit has a battery and its run is far too long for switching steps (a stop time of 60 s or more), or a real pack (0.5 Ah or more) has a stop time of 1 s or less, in which its charge barely moves, Problems shows an info, battery.longRun, that points to simulation.batteryRun.
A switching window: simulation.batteryZoom
simulation.batteryZoom {"at": 1800, "span": 0.005} runs the long run to at, then the switching circuit itself for span seconds (up to 10 s; a few milliseconds show the ripple), from the state the long run reached. Every capacitor voltage, inductor current, battery charge and RC branch and controller state carries over by name. It takes the same stop and accuracy parameters as simulation.batteryRun. The result is the window alone, on its own time axis from at; its reply adds batteryRun (the long run to the window) and zoom (from, span, carried, steps). from is earlier than at when stopCurrent or stopSoc ended the long run first. simulation.continue extends the window with more switching.
In the window it is Simulation › Battery Run Switching Window: its form takes the start time (at) and the window length (span).
On batteryChargerLongRun, at 1800 reaches a state of charge of 70 % at 4.5 A and 15.9 V, carries 6 states over and runs the 5 ms window in 2752 switching steps.
The result as a file beside the circuit
Simulation › Save Result Beside Circuit writes every run you start from the window to a file next to the circuit, named after it: buck.pcraft gives buck.csv in the same folder. The file holds every recorded signal and every sample of the run, one column per signal after time, so a spreadsheet or another tool reads the latest run without an export dialog. Each run replaces the file. Turning the switch on writes the result on screen at once, and the status line names the file. A circuit that has no file yet is told to save first; nothing is written for it. A password-protected circuit's result is never written as a plain file. The switch is a preference of the app, off by default.
From a script or the CLI, file.saveResult {"format": "csv"} does the same once; format can also be mat (MATLAB), raw (LTspice) or cff (COMTRADE), and path names another file.
Run, stop, pause, continue
The Simulation menu has these four items with their keys. Stop and Pause are grey while no run is going.
- Settings.
- Run.
- Stop.
- Pause.
- Continue.
| Command | Shortcut | What it does |
|---|---|---|
simulation.run |
F5 | Starts a run from time zero |
simulation.stop |
Shift+F5 | Stops and keeps the partial result |
simulation.pause |
F6 | Pauses. The solver state is kept |
simulation.continue |
F7 | Carries on from the pause. {"duration": "5m"} runs a further 5 ms |
simulation.step |
Simulation › Next Time Step: runs a paused or finished run on by one Max time step and keeps it there, so you can walk through a switching edge one step at a time. {"steps": 10} takes ten steps (up to 10,000). If the scope is zoomed to the run's end, the zoom moves on with each step, and the status bar says where the run is ("Stepped to 200.3 µs"). Grey until a run is paused or finished, and the grey item says so |
|
simulation.steadyState |
Finds the periodic steady state and shows its last period. {"period": "10u"} |
|
simulation.tune |
Changes a gain, a part value or a circuit variable in the paused or finished run, from its present time on. {"component": "PI", "key": "kp", "value": 0.05} or {"variable": "Pref", "value": 6000} |
|
simulation.undoTune |
Takes the last tuning back | |
simulation.bake |
Writes the tuned values into the circuit as one undoable step | |
simulation.startFromEnd |
Simulation › Start From End State: writes the last run's end state into the circuit as one undoable step, each capacitor's end voltage as its v0, each inductor's end current as its i0, each integrator block's end output as its x0 and each PI block's end integral (its output less kp times its input) as its y0, so the next run starts where this one stopped and the saved file keeps that state. {"components": ["C1"]} writes only those parts. A part the run did not record is listed under skipped and keeps its value; parts inside subsystems and the states of other blocks (tf, ztf) are not written. The values are the recorded samples (about 7 significant digits) |
Watch it run. The scope draws the waveforms while the run goes, growing from the left over the whole span from 0 to End time. On a circuit's first run, with nothing on the scope yet, it picks the signals it would pick after the run (the output voltage and the inductor current first) from the samples so far; when the run ends it picks again from the whole run, unless you changed the shown signals meanwhile. The run card over the plots shows the progress, and the status bar keeps Simulating and Cancel; with the scope out of sight the status bar shows the progress itself.
Tune while it runs. Right-click a number in Properties and pick Tune: the parameter gets a slider in the Tune window (View › Tune). Let go of the slider while a run is going and the run pauses, takes the new value and runs on to its end time; capacitor voltages, inductor currents and controller states carry over, so the scope shows the response to the change alone. A dotted line in the scope marks each change. With the run finished, the change holds from its end and Continue (F7) runs on with it. Undo Tuning takes the last change back, and Bake Tuned Values writes the values into the circuit. Resistors, capacitors, linear inductors, sources, meter gains and the constant, gain, sum, limiter, comparator, integrator, PI, sine, step and lookup blocks, and the frequency and phase of carrier and PWM blocks, can be tuned (a frequency change keeps the carrier's position, so a frequency-controlled converter such as an LLC can be stepped in one run); a change that alters the circuit's structure (an ESR that adds a node, a model) is refused. A circuit variable can be tuned too ({"variable": "Pref", "value": 6000}): every value written as an expression of it is evaluated again and keeps its formula, so a power reference steps the current reference block Pref/(1.5*Vpk) feeds; the reply's changed lists the parts it reached, and a variable that reaches a value that cannot change while running (a PWM's duty step) is refused. simulation.tunings lists the changes, and simulation.run {"tunes": [...]} replays them from t = 0.
The run happens in a background thread, so the window stays responsive. The status bar shows how long it has been running.
simulation.steadyState takes period (if you leave it out, the engine uses the longest period among the PWM blocks, carriers, sine sources and sample-and-hold blocks), tolerance (default 1e-4), maxPeriods (default 2000) and method (auto, the default, or stepping). Use it when you want the periodic steady state and do not care about the start-up.
With auto the search first solves for the steady state with Newton's method on the state at the period boundary: the capacitor voltages, inductor currents, integrator and PI integrals and free temperatures (T. J. Aprille and T. N. Trick, "Steady-state analysis of nonlinear circuits with periodic inputs", Proc. IEEE 60(1), 1972). Each of its trial periods is simulated by the chosen solver, and every one counts against maxPeriods. When it does not converge it hands its best state to stepping, which runs period after period until the state at two boundaries in a row changes by less than tolerance; either way the answer passes that same test. The reply says which one found it (method: shooting or stepping), the residual (the relative change of the state over the last period), periods (all periods simulated) and newtonIterations. On the LLC half-bridge example it takes 10 to 11 periods where stepping takes about 160; on a boost PFC with 4.7 mF it takes 12 line periods where stepping takes about 100. After a shooting search the losses totals in the reply do not add up every period it simulated; read the losses from the last period's waveforms.
In the app, Steady-State Analysis in the arrow beside Run on the toolbar (or Simulation › Steady-State Analysis) runs the same search and shows the last period on the scope.
v(out): a mean of 48.25 V over the period shown.- The window the scope shows: one 10 µs period, from 93.8 µs to 103.8 µs.
Example: the LLC half-bridge
powercraft-cli run --cmd file.openExample --params '{"name":"llcHalfBridge"}' \
--cmd simulation.steadyState --params '{}' \
--cmd scope.measure --params '{"signals":["v(out)"]}'
The reply says "method": "shooting", "newtonIterations": 3, "periods": 10 and a residual of 2.4e-5, and the scope holds the last 10 µs period: v(out) has a mean of 48.25 V and a ripple of 0.11 V peak to peak. The same call with {"method": "stepping"} takes 156 periods to pass the same test.
Limits of the steady-state search
- The Newton search solves for at most 64 states (capacitor voltages, inductor currents, integrator and PI integrals, free temperatures). A larger circuit, or a
maxPeriodstoo small for one Jacobian (one period per state) and a few steps, goes straight to stepping, and the reply saysnewtonIterations0. - The search takes at most 3 Jacobians and 16 Newton steps. When those do not converge, it hands its best state to stepping, which may still need many periods.
- The other state of the control blocks (carrier phases, held samples, edges) is not solved for: each period starts from where the last one ended.
- After a shooting search the
lossesin the reply do not add up the periods it simulated; read the losses from the last period's waveforms.
Limits to know
- The engine keeps at most 40 million recorded values per run (about 320 MB). A longer run is thinned out automatically, and a warning says so. Print step and Save from (above) keep the recording small instead.
- A run takes at most Max steps (
maxSteps, 20 million by default, up to 2 000 million). - In the browser version each run is limited to 1,000,000 steps. Raising Max steps does not lift this limit: increase Max step, shorten End time or use the desktop app. The run goes a few milliseconds at a time, so the page keeps responding, the progress bar moves and Cancel stops it. The samples computed so far are kept. A run with a very large recording is not cut into pieces and runs in one go. Editing the circuit while it runs ends the run.
- A very small
maxStepover a longtEndis slow: 100 ms at 10 ns is ten million steps, and ten times more steps takes about ten times longer.cargo xtask benchmeasures this on your machine.
Reading a failed run
If the run stops with an error, the message names the node or element and suggests a step or a circuit change. Chapter 8 lists the common ones.




