eCircuit Center 
SPICE Topics 
About SPICE 
SPICE Basics  Running SPICE
 CIRCUIT COLLECTION 
SPICE Commands  SPICE Demos and Downloads 

NONLINEAR DC ANALYSIS
CIRCUIT Using Nodal Analysis, you can find the voltage at every node in a DC linear circuit. But the technique runs into a brick wall if any nonlinear components, such as a diode, appear in the circuit. Turns out, the solution is still within reach. The secret lies in first transforming the nonlinear components into something usable by Nodal Analysis. The technique requires a little guessing, and a lot more trips to the nodal equation solver than is needed by a linear circuit.
DIODE MODEL As an example, let's look at a very nonlinear component, a diode. Its current versus voltage relationship is described by where IS is the saturation current and Vt the thermal voltage. Using a little tunnel vision around an operating voltage Vdo, you can approximate the behavior by a line tangent to its ideal curve.
Diode characteristic curve and tangent line. How does the tangent line help circuit analysis? A straight line can be modeled using linear components  a parallel combination of a conductance Geq and a current source Ieq! The conductance Geq is simply the slope of the tangent at the operating point Vdo. The term Ieq is the point where the tangent slices through the yaxis. Here's the nonlinear diode transformed into its linear companion model.
NODAL ANALYSIS Now, we can treat the diode like any other linear component in the circuit and develop the nodal equations. (See Nodal Analysis for quick review.)
We can easily solve for V1 and V2. First, to simplify bookkeeping, let G11 = 1/R1 + 1/R2, G12 = 1/R2, G21 = 1/R2, G22 = 1/R2+Geq, I1 = Is and I2 =  Ieq. The equations reduce to Then work the equations directly to get Finally, stick the calculated V2 value into the next equation to get V1. (We'll use these later in our Excel spreadsheet.)
REPEAT NODAL ANALYSIS AS
NEEDED Remember, the diode's linear companion model was created at some operating point. But, which operating point? Well, initially we don't know  we can only guess at a trial operating point. After solving the Nodal equations, the voltage found across the diode serves as the next trial operating point and a new companion model is created. Again, the nodal equations are solved and the next trial operating point is found. Repeat as necessary until it converges to a solution. How do you know when you've reached a solution? If the changes in circuit voltages and currents, between one iteration (n) and the last iteration (n1), are smaller than some limit, then you've arrived at a solution. The whole thing looks like this:
And there in a nutshell is Newton's method (or the tangent method) of solving nonlinear equations NONLINEAR DC ANALYSIS Let's jump in the nonlinear waters with an Excel spreadsheet for our diode circuit. Download and open the spreadsheet NONLINEAR_DC_ANALYSIS.XLS. Under the variables shaded in light blue, enter the diode's reverse current IS and thermal voltage Vt at 27 °C. Next, enter the resistors R1, R2 and current source Is.
How much voltage would you estimate at node 1?
You can expect V1 = Is ∙ R1 = Now, it's time to enter your guess at a trial operating point for the diode, say 0.9V. From this guess, Excel calculates the diode current Id and its companion model values Geq and Ieq (see equations above).
Just to the right, the spreadsheet calculates the conductance matrix G according to the equations
Finally, the current vector is formed
Okay, here comes the main objective  solve the equations for V1 and V2. The voltages are calculated using the equations found in the Nodal Analysis section above.
Notice the next row. The diode voltage V2 from the previous row is placed in column B as the new trial operating voltage! Another round of calculations then begins. How do you know if V1 and V2 are correct? Just look at the change in the diode voltages and currents during the last iteration. The last 2 columns holds these values. As you can see, by the 8th iteration the change is small and getting smaller. You can say, the solution is converging! ALGORITHM INSIGHT The number of iterations it takes depends a lot on your initial guess at the diode voltage. Try another initial guess like 0.65 or 0.95V. How many iterations did it take? Try changing Is, R1 and R2. What effect does it have on the voltages and number of iterations? THE SPICE CIRCUIT To verify our results, you can run a simulation of NONLINEAR_DC_ CKT.CIR. Download the file or copy this netlist into a text file with the *.cir extension. NONLINEAR_DC_CKT.CIR  SIMPLE NONLINEAR CIRCUIT * IS 0 1 DC 0.1A * R1 1 0 100 R2 1 2 10K D1 2 0 DNOM * .MODEL DNOM D(IS=1E15) * * ANALYSIS .TRAN 1MS 10MS * VIEW RESULTS .PRINT TRAN V(1) V(2) .PROBE .END Although the SPICE file runs a Transient Analysis, it essentially computes a NonLinear DC Analysis because no significant chargestorage devices exist in the circuit. Plot V(1) and V(2). Use the cursor, if needed, to get an accurate measurement. Do the voltages from SPICE and Excel agree?
Well, pass the bubbly  the companion models have been created, the voltage and current changes have fallen below their limits, and a solution has been found! But wait, what are these limits of voltage and current change? The limits are actually calculated by
By default, RELTOL is set to 0.001 or 0.1 percent. So
if your expected voltage is 5V, the change in node voltage must fall below 5
V ∙ 0.001 = 5 mV to reach a solution.
However, if your voltage swings near zero, such as 0.1 mV, then the voltage
change has to fall Some of you may recognize RELTOL, VNTOL and ABSTOL as parameters that can appear in the .OPTIONS statement of the netlist. You, as a SPICE user, have control over these parameters. When a solution does not converge and your SPICE world comes crashing down around you, adjust these parameters to help jump start the SPICE engine. Many times this means relaxing (increasing) the limits of voltage and current change.
WANT MORE INFO? Here are some gold mines of information about the SPICE engine.
For more info on these and other books go to the Bookshop.


About SPICE 
SPICE Basics  Running SPICE
 CIRCUIT COLLECTION 
SPICE Commands 