An Efficient Procedure for Transient Analysis of Electronic Circuits with Increased Precision

This article presents an efficient procedure allowing to increase the final accuracy of the electronic circuits simulation. To obtain Transient Analysis of a nonlinear circuit the simulator needs to perform various algorithms, from an evaluation of initial DC state through a nonlinear iterative algorithm, to a numerical integration. These complex computations have to be implemented effectively with regards to memory and processor usage. Direct implementation of arbitrary precision types can directly lead to increased simulation accuracy but also significantly decrease simulation performance. As a compromise, we suggest using an additional algorithm based on Newton Iteration method for the solution of matrix inversion. The method was modified to be comparable to direct LUF solver.


Introduction
Every year significant number of articles focus on simulation core of Spice and its device models is published .As interesting works on similar problematic to this article we can point out [1][2][3][4].It is without a doubt that the accuracy of a simulation of the electronic circuits is essential.The primary importance can be seen in several aspects.The first one points to the band of the unknown variables that are simulated.They usually represent the real physical behavior of circuit devices, and their values can differ in magnitude by several orders.The difference can be in the extreme cases higher than a range of used floating point data type.To be able to simulate those extreme cases requires increasing precision of given datatype.The second aspect of the accuracy problems is related to the solution of linear systems.Although standard circuit state (i.e.OP) can be well established during transient analysis may occur situations when a circuit matrix is changed a lot.It makes a computation of specific time-points very problematic, especially in the case when matrix setup rapidly increases condition number.In that situation, some timepoints may be affected by precision inaccuracies more than others.

Simulation Overview
In the Spice program, there are four basic analysis for simulation of electronic circuits: Transient Analysis, Operation Point (DC), Small Signal Analysis and Noise Analysis.All of them shares a common family of computation algorithms.As the most critical Transient analysis can be considered which uses the most time demanding operations.Spice simulation core to compute Transient analysis needs to evaluate a system of nonlinear differential equations defined by device models.It is done by Newton-Raphson iteration algorithm together with LU factorization (LUF) method capable of handling sparse matrices and pivoting.In particular cases, when time dependent devices enter a simulation, it also needs to enumerate numerical integration using Trapezoidal, Gear or another method.Algorithm 1 characterize simulation of the circuit with nonlinear devices performed by Transient analysis.It should be pointed out that computation of each time-step requires solution of the linear system produced by Jacobian ma-

Precision Problems
Floating point numbers are designed to be an efficient representation of the real numbers but with a limited accuracy that is directly related to their magnitude.It si perfect idea that works for most cases.For double precision numbers (64 bit machine) IEEE 1987 defines 52 significant bits plus 1 sign and 11 exponent bits.It gives us range from 10 −323 to 10 308 .It seems to be an enormous scale of numbers, but there is always a catch.Nevertheless, of scalability floating point numbers are precise only within some region of magnitude.It implies that the situation when precision goes wrong can occur, and, unfortunately, it have a higher probability to happen during simulation of electronic circuits.Floating point numbers can not be as precise as their real counterparts defined by mathematical apparatus.For example number, 0.1 will become 0.1000000000000000055511151231257827021181 and the even more different result can be obtained by definition of 1.1 × 10 −8 that will become 1.099999999999999923753143406777998958290 × 10 −8 Although those numbers have a finite decimal representation, in computer memory they are an infinitely repeating numeric sequence.It is caused by the fact that they lie exactly between two representable floating point numbers and therefore in computer memory they have to be rounded to one of them.Floating point numbers also include several non-numeric definition as infinity for larger (or smaller) numbers than highest (or lowest) representative number, positive and negative zero and "not a number" (NaN) definition for undefined states (division by zero).There is another implication of problems caused by a limitting precision of the floating point numbers.In a case ill-conditioned linear systems the accuracy of the solution can be rapidly decreased.Although that matrix condition number is not directly related to the accuracy, it can be taken as an indicator that the solution may be af-fected by an error.For example, if we have a system: its computation using double precision will result in residual error r computed by L2 norm r = 4.547474 * 10 −13 it is significantly higher contrary to expected value r < 10 −15 .

Precision of the Algorithm
The original mathematical definition of Newton Iteration Method (NIM) [5,6] can be rewritten to the form applicable for implementation as an iterative algorithm for precision enhancement.Denoting Jacobian matrix as J and Identity matrix as I, for inverted Jacobian matrix J −1 we can write For an arbitrary real matrix, J, the above statement allows for each iteration step n to define a generalized inverse (pseudo inverse) denoted as X n where ε n is an error matrix.From that, we get to The above form can be rewritten using X n and X n+1 to a more readable form It is obvious that previous equation will iterate to the solution if There are two important remarks for this solution.First is connected to nature of Spice simulator.It does not compute matrix inversion of Jacobian matrix.Instead, it computes next iteration steps of NR algorithm directly evaluating equation The second remark is that the circuit matrix is going to be very sparse and more of that its density decrease with increasing matrix size.It concludes that computation of matrix inversion proves to be very inefficient for huge matrices from a point of view of memory handling.On the other hand stability of algorithm and simplicity of implementation together with possible optimization makes algorithm very efficient for computation with matrix dimension up to 200 (circuits with up to 200 independent voltage nodes).Putting it all together we finally receive final algorithm: where A −1 stands for inversion of the current computation of the Jacobian matrix in current precision that can be easily obtained from last LU factorization.This will be used as a starting point for linear solver.X D+ represents matrix inversion with increased precision.Both matrix multiplications in second line must be computed with increased arbitrary precision to achieve increased accuracy in X D+ .
Then more accurate solution of the time step is given by simple vector matrix multiplication The simplicity of implementation of NIM allows to compiler optimize the code in such a way performance can be rapidly increased, but with increasing of matrix dimension memory requirements of this method rapidly decrease performance.This can be visible from Table 3.The number of required iteration to obtain a result with particular precision, unfortunately, depends on initial estimation and matrix dimension.Therefore, this algorithm will offer best results only in a case of one iteration.

Performance
Adapt NIM algorithm as an efficient competitor to LUF is not an easy task.First of all, it's hard to optimize two matrix multiplications that must be performed during NIM computation.Secondly, with increasing size of sparse Jacobian matrix with also, increase unfortunately dense matrix J −1 .It is caused by the nature of matrix inversion, and there is no way to suppress it.Therefore, the best usage of the algorithm is for matrices with dimension up to 200 when it can be taken as dense.Although, optimization of efficiency can be done.Current compilers (e.g., GCC) offers various optimizations settings that can rapidly improve calculation performance and memory handling without a need of parallelisation or other techniques (Table 2).It should be noted that it does not directly concludes that higher optimization attribute equals more efficient result.It is nature and simplicity of NIM that it is so well optimizable.It is hard for iterative methods or even impossible to overcome direct one.Mainly it is because that direct methods evaluate directly to the solution contrary to the iterative algorithms that need several iteration loops before they obtain a result with sufficient precision.It is the reason why LUF is a better option than NIM for standard computation.Another optimization can be done reducing the number of iterations.It is obvious that fewer iterations mean less computation time.Therefore, the algorithm was limited to only one iteration.There is computation of initial inversion matrix from already precomputed LUF followed by two matrix-matrix products.This algorithm is pretty simple and straightforward (no factorisation or precision comparison is needed).It gives to NIM for small matrice an advantage among over any other algorithms.Together with very straight convergence a simplicity of the algorithm allows very fast implementation of arbitrary precision numeric types.It will be shown that usage of arbitrary precision numbers in computation even for one iteration of NIM can directly improve resulting accuracy by factor two.For instance, if the final precision of LUF was around 10 −16 next iteration with NIM could increase it up to 10 −32 .

Results
In the

Conclusion
In this article, we presented an iterative method that increases the precision of analysis of electrical circuit by suppressing errors produced by floating point variables.It can be applied to the end of OP simulation or as a final procedure after each time-step of Transient analysis.It is clear that iterative NIM will always be outperformed by direct LUF method, especially in a case of sparse matrices.However, the achievable precision during computation with floating-point precision numbers is strictly limited by a size of the variable type.It has been demonstrated that because of precision problems caused by the nature of floating point numbers, we can achieve total accuracy only in very trivial cases.Mostly computation finish regardless on used numeric type with precision around 10 −16 or less.The only way that can provide results with greater precision is to switch to arbitrary precision numbers.Arbitrary precision numbers allow to setup any precision but they are also very demanding from a point of view of performance.Standard LUF followed with a single iteration of NIM with arbitrary precision can definetely improve the accuracy with preserved performance for dense matrices.
In a case of sparse matrices efficiency of NIM is discussable and will be decreasing with growing sparsity of the matrix.Therefore method is aplicable for small circuits only (up to 200 nodes).

Table 1 .
Comparison of Performance of NIM and LUF to Matrix Dimension

Table 2 .
) Overview of Compiler Optimization Settings

Table 3 .
Table 1 there is a comparison of computation times of LUF and one iteration of NIM for different optimization levels of GCC compiler.It is clearly visible how optimization attributes to improve performance.It can be seen that up to matrix dimension 200, implementation with NIM proves as a faster solution.It is also showed in the Figure 1.Table 3 gives a slight look on efficiency of different stages of NIM iterations for various matrix dimensions.It is visible that the most critical is a fact that several iteration loops are required.It is evident that the iteration loops Computation Times in Sec. of Individual Steps of NIM

Table 4 .
Accuracy Boost Given by One Iteration Loop of NIM with Arbitrary Precision sis completed by single loop NIM with arbitrary precision is in Algorithm 2. It got an additional precision boost computed by NIM after each successful iteration time-step.