Transient Analysis (tran)¶

Introduction¶

Transient analysis solves the complete nonlinear algebraic-differential equations of a circuit. Effects such as nonlinear distortion, intermodulation, saturation, clipping and oscillations (unstable behaviour) can be modeled with this analysis. Equations are numerically solved by default using the operating point as the initial condition.

The syntax for transient analysis is one of the following:

```tran <tstep> <tstop>

tran <tstep> <tstop> <tstart>

tran <tstep> <tstop> <tstart> <tmax>
```

The meaning of the parameters is described next:

tstep: initial time step for numerical integration. This is just a suggested value as the simulator may reduce or increase this value as needed.

tstop: simulation stops when tstop is reached

tstart: transient analysis always starts from t=0. If tstart is given results are saved only from tstart to tstop (i.e., results from 0 to tstart are calculated but discarded).

tmax: maximum allowed time step. Sometimes the simulator may choose a time step too long and details are lost or even results become inaccurate. This parameter is useful for the analysis of some oscillators.

Transient Sources¶

During transient analysis, the DC component of sources is applied to the circuit. The AC component is not used. Spice provides a variety of different source waveforms for transient analysis: sinusoidal, pulse, exponential, piecewise linear and more. Consult the program documentation for more details. In this tutorial we’ll use a sinusoidal source that has the following format:

```sin(vo va freq td theta)
```

That can be added to a current or a voltage source line as it will be shown in the example below. The following description was extracted from the Spice3 manual:

```time          value
------------------------------------------------------------
0 to td       vo
-(t - td)theta
td to tstop   vo + va e               sin(2 j freq (t + td))
```

Example¶

The RF switch is modified to include a sinusoidal source with 100 mV amplitude and 1 MHz frequency:

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

* Input source
vs 1 0 dc 0V ac 1V sin(0V 1V 100MegHz 20ns 0)
Rs in 1 50ohm

* Switch
Ci in 4 1.6nF
Rb 4 3 2.1k
Lc1 3 2 100uH
D1 4 50 mydiode
vmeter 50 5 dc 0
Lc2 5 0 100uH
cout 5 out 1.6n

* DC biasing
vcc 2 0 5V

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

.tran .1ns 100ns

.end
```

At 100 MHz one period is 10 ns. The transient analysis is specified for 100 ns and the suggested time step is (10 ns / 100) = 0.1 ns. The source (vs) will not oscillate for the first 20 ns (delay). The peak value is 1 V and the DC component is 0 V. The transient analysis is run using the run command this time (runs the analysis specified in the netlist):

```ngspice 489 -> source rfswitch2.cir

Circuit: *** rf switch circuit ***

ngspice 490 -> run
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000

Initial Transient Solution
--------------------------

Node                                   Voltage
----                                   -------
1                                            0
in                                           0
4                                     0.732992
3                                            5
2                                            5
50                                           0
5                                            0
out                                          0
lc2#branch                          0.00203191
lc1#branch                         -0.00203191
vcc#branch                         -0.00203191
vmeter#branch                       0.00203191
vs#branch                                    0

Reference value :  0.00000e+00

No. of Data Rows : 1008
ngspice 491 -> plot v(in), v(out), v(4,5)
ngspice 492 ->
```

The plot of the waveforms is shown below. As expected input and output almost overlap and the diode voltage (v(4.5)) remains approximately constant.

We now increase the input amplitude to 3 V to make nonlinear effects more evident. The results are plotted below. Clearly the output voltage (blue) is distorted because the diode runs out of current in the negative semicycle.