# OP and DC Analyses¶

## Operating Point Analysis (.op)¶

The operating point analysis is useful to find the biasing point of nonlinear devices. After the netlist is loaded:

```ngspice 469 -> source rfswitch.cir

Circuit: *** rf switch circuit ***

ngspice 470 -> edit
Waiting for Emacs...

Circuit: *** rf switch circuit ***

run circuit? n
ngspice 471 -> op
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000

No. of Data Rows : 1
ngspice 472 -> print v(4)-v(5)
v(4)-v(5) = 7.329920e-01
ngspice 473 ->  print v(4,5)
v(4,5) = 7.329920e-01
ngspice 474 -> print -i(vcc)
-i(vcc) = 2.031909e-03
ngspice 475 ->
```

Typing op runs the operating point analysis. The analysis calculates DC voltages in all circuit nodes plus DC currents in voltage sources. Results can be printed as shown above. Note that v(4,5) is equivalent to v(4)-v(5). Reference direction for currents is from positive node in voltage source to negative node (thus i(vcc) is negative in the example).

Detailed bias point information for nonlinear devices can be obtained with the show command:

```ngspice 475 -> show d1
Diode: Junction Diode model
device                    d1
model               mydiode
vd              0.732992
id            0.00203199
gd             0.0785639
cd                     0
```

Note that the DC current is the same as in the voltage source. Also, the small signal parameters are given here: gd is the dynamic conductance of the diode at the operating point. We can verify that result directly from the NGSpice prompt:

```ngspice 476 -> print 0.00203199/26m
0.00203199/26m = 7.815346e-02
ngspice 477 -> print 26m/0.00203199
26m/0.00203199 = 1.279534e+01
```

Note: any analysis command can also be included in the netlist. Just precede the analysis command with a dot as shown below:

```*** RF switch circuit ***

* Input source
vs 1 0 dc 0V ac 1V
Rs in 1 50ohm

* Switch
Ci in 4 1.6nF
Rb 4 3 2.1k
Lc1 3 2 100uH
D1 4 5 mydiode
Lc2 5 0 100e-6
cout 5 out 1.6n

* DC biasing
vcc 2 0 5V

.model mydiode d (is=1e-15A n=1)

.op

.end
```

## DC sweep (dc)¶

Often it is useful to sweep one parameter in a circuit and plot the variations of nodal voltages or small-signal parameters as a function of the parameter being swept. For example, suppose that we want to plot the diode voltage as a function of Vcc. We run a DC analysis sweeping Vcc from 1V to 10V in increments of 0.01V:

```ngspice 24 -> dc vcc 1V 10V .01V
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000

Reference value :  1.00000e+00

No. of Data Rows : 901

ngspice 25 -> plot v(4,5)
ngspice 26 ->
```

The following plot is produced:

We can compare the simulated current value with the approximation used for manual calculations (they are almost identical):

```ngspice 26 -> plot -i(vcc), (v(2) - .7) / 2.1k
ngspice 27 ->
```

We can also sweep temperature (this was not possible in the original Spice program, but it is supported in many Spice-based simulators):

```ngspice 196 -> dc temp -40 100 1
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000

No. of Data Rows : 141
ngspice 197 -> plot v(4,5)
ngspice 198 ->
```

Note how the voltage drop in the diode decreases linearly with temperature (sice the current is almost fixed by the external circuit):

Introduction

#### Next topic

Small-Signal Analysis (AC)