This shows you the differences between two versions of the page.
|
gnucap:manual:commands:dc [2020/02/15 15:03] felixs [Comments] |
gnucap:manual:commands:dc [2025/11/20 04:10] (current) felixs update, parameter sweeps, mention pipe |
||
|---|---|---|---|
| Line 3: | Line 3: | ||
| ===== Purpose ===== | ===== Purpose ===== | ||
| - | Performs a nonlinear DC steady state analysis, and sweeps the signal input, or a component value. | + | Performs a nonlinear DC steady state analysis, and sweeps the signal input, a component value or a parameter value. Components must be of type "element", such as voltage/current sources and resistors. Sweeping parameters that are used to control expansion (binning or generate) will not trigger re-expansion, and hence might lead to unexpected results. |
| ===== Syntax ===== | ===== Syntax ===== | ||
| dc start stop stepsize {options ...} | dc start stop stepsize {options ...} | ||
| - | dc label start stop stepsize {options ...} | + | dc label start stop stepsize {options ...} |
| + | dc param start stop stepsize {options ...} | ||
| + | dc param1 start1 stop1 stepsize1 param2 start2 stop2 stepsize2 [..] {options ...} | ||
| + | |||
| ===== Comments ===== | ===== Comments ===== | ||
| Line 16: | Line 18: | ||
| If there are numeric arguments, without a part label, they represent a ramp from the generator function. They are the start value, stop value and step size, in order. They are saved between commands, so no arguments will repeat the previous sweep. | If there are numeric arguments, without a part label, they represent a ramp from the generator function. They are the start value, stop value and step size, in order. They are saved between commands, so no arguments will repeat the previous sweep. | ||
| - | A single parameter represents a single input voltage. Two parameters instruct the computer to analyze for those two points only. | + | A single argument represents a single input voltage. Two arguments instruct the computer to analyze for those two points only. |
| In some cases, you will get one more step outside the specified range of inputs due to internal rounding errors. The last input may be beyond the end point. | In some cases, you will get one more step outside the specified range of inputs due to internal rounding errors. The last input may be beyond the end point. | ||
| Line 24: | Line 26: | ||
| The program will sweep any simple component, including resistors, capacitors, and controlled sources. SPICE sweeps only fixed sources (types V and I). | The program will sweep any simple component, including resistors, capacitors, and controlled sources. SPICE sweeps only fixed sources (types V and I). | ||
| - | This command will sweep up to 4 components, nested. | + | This command will sweep up to 4 component values or parameters, nested. Modify s_dc.cc if you need more. |
| - | The original models of the sweep component(s) will be restored after the simulation has been completed. | + | Sweeping parameters may be noticeably slower than an equivalent element sweep, as all parameters are re-evaluated before each step. Time used is added to the setup function timer (cf. [[gnucap:manual:commands:status|status]]). |
| + | |||
| + | The original models of the sweep component(s) and parameter values will be restored after the simulation has been completed. | ||
| + | |||
| + | A subprocess can be a shell commmand with arguments. Use '{' and '}' to delimit the command string. | ||
| ===== Options ===== | ===== Options ===== | ||
| Line 42: | Line 48: | ||
| |> //file// |Send results of analysis to file. | | |> //file// |Send results of analysis to file. | | ||
| |>> //file// |Append results to file. | | |>> //file// |Append results to file. | | ||
| + | || //command//|Pipe output to a subprocess, eg. convert to CSV| | ||
| |noplot |Suppress plotting. | | |noplot |Suppress plotting. | | ||
| |plot |Graphic output, when plotting is normally off. | | |plot |Graphic output, when plotting is normally off. | | ||
| Line 62: | Line 69: | ||
| Sweep the circuit input from -10 to +15 in steps of 1. (usually volts.) Do a DC transfer simulation at each step. | Sweep the circuit input from -10 to +15 in steps of 1. (usually volts.) Do a DC transfer simulation at each step. | ||
| dc | dc | ||
| - | With no parameters, it uses the same ones as the last time. In this case, from -10 to 15 in 1 volt steps. | + | With no arguments, it uses the same ones as the last time. In this case, from -10 to 15 in 1 volt steps. |
| dc V13 -10 15 1 | dc V13 -10 15 1 | ||
| - | Sweep the "value" of the component "V13" from -10 to +15 in steps of 1. Do a DC transfer simulation at each step. | + | Sweep the "value" of the element "V13" from -10 to +15 in steps of 1. Do a DC transfer simulation at each step. (Soon:) If there is no element by this name, but a parameter, then sweep the parameter instead. |
| dc 20 0 -2 | dc 20 0 -2 | ||
| You can sweep downward, by asking for a negative increment. Sometimes, this will result in better convergence, or even different results! (For example, in the case of a bi-stable circuit.) | You can sweep downward, by asking for a negative increment. Sometimes, this will result in better convergence, or even different results! (For example, in the case of a bi-stable circuit.) | ||
| Line 71: | Line 78: | ||
| dc temperature=75 | dc temperature=75 | ||
| Simulate at 75 degrees, this time. Since we didn't specify new sweep parameters, do the same as last time. (Without the loop.) | Simulate at 75 degrees, this time. Since we didn't specify new sweep parameters, do the same as last time. (Without the loop.) | ||
| + | dc a 0 1 .5 b 0 1 .5 | { sed -e 's/ \+$//' -e 's/\([^ ]\) /\1, /g' } | ||
| + | Sweep a and b, display as CSV. | ||