step
Run the circuit stepped, as .step
General form
step [lin] what start stop increment step dec|oct what start stop points step what list value [value ...] step
Run the circuit several times, once for each of a set of values of a parameter, and collect the results of all the runs. step steps the circuit by the one specification given, instead of by the circuit's .step cards; with no arguments it is the same as run. The circuit is run with the analyses given by its own analysis cards (.ac, .tran, and so on); see Analyses.
Note: in the original Spice3, step [number] was the debugger's command to run a fixed number of timepoints. That command is now called iterate; step is the stepped run described here.
Usually the steps are given in the circuit with .step cards, which take the same arguments:
.step c1 list 0.5n 1n 2n .step param rval list 1k 2k
A run (the run command, the Run menu, or batch mode) then runs the circuit once for each step.
Analyses
Stepping applies to a run, and a run performs the analyses that the circuit itself specifies: its .op, .dc, .ac, .tran, .noise, .tf, .pz, .disto and .sens cards. So the circuit must have at least one analysis card, and each step runs all of them, with the stepped value in place. For example, a circuit with both .ac and .tran cards gives an AC and a transient result for every step.
step and .step have no analysis argument, and do not step an analysis command typed at the prompt, such as ac dec 10 1 1meg or tran 1u 10u. Those run once, with the circuit as it is (any .step cards are ignored), and make an ordinary plot. To step an analysis, put its card in the circuit and use run or step.
Values
[lin] what start stop increment- From start to stop in steps of increment.
dec|oct what start stop points- Logarithmically from start to stop, with points values per decade or octave.
what list value ...- Each of the values listed.
What can be stepped
param name- A
.param. The circuit is read again with each value, and the other.params are evaluated again. temp- The circuit temperature.
dev- A device's principal value, for example
r1,c1orv1. type model(param)- A model parameter, for example
npn q2n2222(bf). @name[param]- Any device or model parameter.
Results
Several .step cards nest, the first card varying fastest. At the end of the run, the .meas results of all the steps are printed in a table.
The plots made by the steps are then merged: for each analysis there is one plot in which each vector has a dimension for each .step card (the last card's first) as well as its own. So in examples/step_demo.cir, which steps c1 and then the parameter rval, a transient vector has the dimensions [rval][c1][time], and
plot v(out)draws a curve for each step, labelled with the step's values;plot v(out)[1][1]draws one step's curve (hererval=2k andc1=1n; indices count from 0).
If the steps' scales differ (for example their transient timesteps), each step's results are interpolated onto a common scale. Results with one value per step, such as an operating point or a .meas result, instead become vectors over the steps, with the first card's values as their scale, so plot risetime draws the rise time against the stepped value. The stepped values are vectors too, named after what was stepped, so a plot against them is labelled with that name.
The plots of the individual steps are deleted unless the variable keepsteps is set. run file writes each step's plot to the rawfile.
Afterwards the stepped values are restored. Stepping a .param reads the circuit again, which loses any changes made by alter or optimise.
Example
From examples/step_demo.cir: an RC low pass whose resistor is set by a .param, stepped over three capacitor values and two resistor values, six runs in all. The 10%–90% rise time is 2.2·R·C.
.param rval=1k vin in 0 pulse(0 1 1u 1n 1n 50u 100u) r1 in out 'rval' c1 out 0 1n .tran 0.05u 20u .meas tran risetime TRIG v(out) VAL=0.1 RISE=1 TARG v(out) VAL=0.9 RISE=1 * Step c1 (the first card varies fastest), then the .param .step c1 list 0.5n 1n 2n .step param rval list 1k 2k .control run display * A curve for each step plot v(out) * The rise time against c1, for each rval plot risetime * One step's curve: rval=2k (index 1), c1=1n (index 1) plot v(out)[1][1] .endc