We have an assignment at the Parallel processing class, the target is to implement a Non-linear Equations solver on cuda based on Newton Raphson method and to interface this solver with an application that deals with nonlinear set of equations. We wanted to interface our solver with circuit simulators. We have picked up an open source simulator and every time the simulator is performing a DC operating point simulation it will invoke our cuda code. At this point we wanted to compare the performance of our solver against solvers implemented in other circuit simulators such as
And also other software solvers e.g. Matlab optimization toolbox
We have tested these solvers against a circuit [which should map to a huge set of nonlinear eqns.]
The circuit netlist is generated by a script where the number of the nodes is given. We have formulated the set of nonlinear equations governing the above circuit as the following
x[i] in this set of equations are the voltage nodes and the current at each resistor
We have managed to write this as a matlab function to test this circuit against matlab nonlinear solver algorithms featured in the optimization toolbox.
function F = non_linear_diode(X) % Len(x) is always even 2*d d = length(X)/2; F = zeros(1, d*2); i = 1e-3; % Current source magnitude r = 50; % Resistors value c1 = 1e-15; % Diodes I_s c2 = 0.0258; % Diodes N*V_th F(1) = X(1) - X(2) - i*r; F(d) = X(d) - X(d+1) - X(2*d)*r; F(d+1) = i - c1*(exp(X(2)/c2) -1) - X(d+2); for ii = 2:(d -1) F(ii) = X(ii) - X(ii+1) - X(ii+d)*r; F(ii+d) = X(ii+d) - c1*(exp(X(ii+1)/c2) -1) - X(ii + d + 1); end F(d*2) = X(2*d) - c1*(exp(X(d+1)/c2) -1); end
We have also written a script to generate Spice netlist for this problem
def gen_ckt(num): ret = "" for i in range(1, num): ret += 'R'+str(i)+" "+str(i)+" "+str(i+1)+" 50\n" ret += 'D'+str(i)+" "+str(i+1)+" 0 DI1N4004\n"
DI1N4004 is our diode model defined in the netlist. When testing the above solvers against the problem with
70,000 nodes i.e.
140,000 equations and unknowns
- Matlab runs out of memory
- Qucs takes forever
- All the spice based solvers somehow solved this problem in less than 2 seconds
We actually have no idea how spice solvers managed to avoid this memory problem, and even when testing this problem against fewer number of unknowns e.g.
3,000 the spice solvers always outperform matlab and qucs. Though as mentioned in    spice uses the damped Newton-Raphson approach to solve circuits with nonlinear components which is the same as all the solvers mentioned above
Fsolve: dogleg method [Newton + Trust-region + steepest decent] 
- Qucs : damped Newton-Raphson 
My questions are
- How spice managed to solve such a huge system of nonlinear equations quickly and without running out of memory ? is it exploiting the circuit structure making use of the repeated elements ?
- Is this example fair enough ? i mean do we need to consider more practical circuits ? and if so can any one give an example for a circuit(s) where DC operating point simulation might be the bottleneck of the simulation time ?
- In  the authors mentioned ISCAS85 benchmark circuits should we consider these circuits in our tests ?
- Is the DC operating point the simulation type we should be targeting ? i mean should we focus to interface our solver to other types of simulations e.g. the transient analysis ?