# Matrix Solver

To simulate a circuit, SIMetrix formulates a set of linear equations from the non-linear equations that govern the devices in the circuit. This is part of an iterative algorithm that is repeated successively to converge on the solution to the non-linear system. The linear system of equations is solved using a matrix solver.

SIMetrix has two matrix solvers and you can choose between them. The two solvers are:
1. Sparse 1.3 developed by Kenneth Kundert and which is the solver supplied with SPICE 3
2. KLU developed by a research group at the University of Florida under Prof. Tim Davis. This was developed for circuit simulation and was moulded to perform well for the type of matrix that circuit simulators tend to generate. The solver makes use of more modern techniques than the original SPICE3 solver which was developed in the 1980s.
SIMetrix uses KLU by default and for most applications this is the better choice. For circuits with more than about 500 nodes it is almost always faster for the following reasons:
1. It has uses superior ordering algorithms. The matrix that arises from circuit simulation problems is sparse which means that nearly all terms are zero. Exploiting sparsity to greatest effect depends on the row and column ordering. KLU makes use of modern research to produce superior ordering to Sparse 1.3
2. The factorisation algorithm is superior
3. It can be reordered efficiently and rapidly. The optimum matrix ordering that is ideal for DC and long time steps is often different to that needed for small time steps. Sparse 1.3 can not be reordered very efficiently and tends to use the same ordering throughout the simulation. KLU can be reordered much more frequently providing optimal ordering at all times

Although KLU is usually the best choice, Sparse 1.3 can give better results for small circuits. To change the matrix solver use this option:

`.options spsolver=solver`

Where solver is:

KSPARSE for Sparse 1.3

or

KLU for KLU

Currently .SENS analyses always use Sparse 1.3 regardless of the spsolver setting.