Professional Documents
Culture Documents
Outline
* Circuit simulation: introduction * Nodal analysis * Modied nodal analysis * Sparse tableau approach * Nonlinear circuits * Transient (dynamic) analysis
Circuit simulation
* DC analysis * transient (time-domain) analysis * AC (frequency-domain) analysis * logic-level simulation * mixed-signal simulation * noise computation * periodic steady state computation * sensitivity analysis
R1 is Vs R2
Example 1
M. B. Patil, IIT Bombay
R1 is Vs R2 R3
Example 1
M. B. Patil, IIT Bombay
R1 is Vs R4 R2 R3
Example 1
M. B. Patil, IIT Bombay
R5 R1 is Vs R4 R2 R3
Example 1
M. B. Patil, IIT Bombay
R5 R1 is R6 Vs R4 R2 R3
Example 1
M. B. Patil, IIT Bombay
R1
VC 1 Vs (t)
C1
Example 2
M. B. Patil, IIT Bombay
R1
VC 1 Vs (t)
C1
Example 2
M. B. Patil, IIT Bombay
R1
R2
VC 1 Vs (t)
C1
C2
Example 2
M. B. Patil, IIT Bombay
R3
R1
R2
VC 1 Vs (t)
C1
C2
Example 2
M. B. Patil, IIT Bombay
* Must be ecient in terms of CPU time (especially for large circuits). * Must make good use of the memory available. If a matrix is sparse, it should not be stored in the a(i , j ) form.
* Must be ecient in terms of CPU time (especially for large circuits). * Must make good use of the memory available. If a matrix is sparse, it should not be stored in the a(i , j ) form. * The approach must be systematic. Tricks such as resistors in series or parallel, star-to-delta conversion, etc. will work in special cases. What we need is a general-purpose method that will work for all circuits.
Outline
* Circuit simulation: introduction * Nodal analysis * Modied nodal analysis * Sparse tableau approach * Nonlinear circuits * Transient (dynamic) analysis
* Take some node as the reference node and denote the node voltages of the remaining nodes by e1 , e2 , etc.
e1
R1 R2
e2 R3 v3 k v3
I0
0
R4
e3
* Take some node as the reference node and denote the node voltages of the remaining nodes by e1 , e2 , etc. * Write KCL at each node in terms of the node voltages. Follow a xed convention, e.g., current leaving a node is positive.
e1
R1 R2
e2 R3 v3 k v3
I0
0
R4
e3
* Take some node as the reference node and denote the node voltages of the remaining nodes by e1 , e2 , etc. * Write KCL at each node in terms of the node voltages. Follow a xed convention, e.g., current leaving a node is positive. * When all KCL equations are treated, we have the admittance matrix and the RHS vector.
e1
R1 R2
e2 R3 v3 k v3
I0
0
R4
e3
* Take some node as the reference node and denote the node voltages of the remaining nodes by e1 , e2 , etc. * Write KCL at each node in terms of the node voltages. Follow a xed convention, e.g., current leaving a node is positive. * When all KCL equations are treated, we have the admittance matrix and the RHS vector. * Solve the resulting linear system of equations, Ye = Is for the node voltages.
e1
R1 R2
e2 R3 v3 k v3
I0
0
R4
e3
* Take some node as the reference node and denote the node voltages of the remaining nodes by e1 , e2 , etc. * Write KCL at each node in terms of the node voltages. Follow a xed convention, e.g., current leaving a node is positive. * When all KCL equations are treated, we have the admittance matrix and the RHS vector. * Solve the resulting linear system of equations, Ye = Is for the node voltages. * The equation assembly (also called parsing) can be done element-by-element, i.e., by considering one line of the circuit le at a time.
e1
R1 R2
e2 R3 v3 k v3
I0
0
R4
e3
* Take some node as the reference node and denote the node voltages of the remaining nodes by e1 , e2 , etc. * Write KCL at each node in terms of the node voltages. Follow a xed convention, e.g., current leaving a node is positive. * When all KCL equations are treated, we have the admittance matrix and the RHS vector. * Solve the resulting linear system of equations, Ye = Is for the node voltages. * The equation assembly (also called parsing) can be done element-by-element, i.e., by considering one line of the circuit le at a time. * The computer cannot see the entire circuit; it can, however, go through the circuit le line by line.
e1
R1 R2
e2 R3 v3 k v3
I0
0
R4
e3
Step 1: Initialize
e1
R1 R2
e2 R3 v3
KCL at 1
e1
I0
0
e2
k v3
3 0 0 0 e3 0
R4
e3
Step 2
e1
R1 R2
e2 R3 v3
KCL at 1
e1
I0
0
e2
k v3
3 0 0 0 e3 0
R4
e3
Step 2
e1
R1 R2
e2 R3 v3
KCL at 1
e1
I0
I0
0
e2
k v3
3 0 0 0 e3 0
R4
e3
Step 3
e1
R1 R2
e2 R3 v3
KCL at 1
e1
I0
I0
0
e2
k v3
3 0 0 0 e3 0
R4
e3
Step 3
e1
R1 R2
e2 R3 v3
KCL at 1
G1 G1
0
G1 G1
0
e1
I0
I0
0
e2
k v3
3 0 e3 0
R4
e3
Step 4
e1
R1 R2
e2 R3 v3
KCL at 1
G1 G1
0
G1 G1
0
e1
I0
I0
0
e2
k v3
3 0 e3 0
R4
e3
Step 4
e1
R1 R2
e2 R3 v3
KCL at 1
G1 G1
0
G1 G1+G2
0
e1
I0
I0
0
e2
k v3
3 0 e3 0
R4
e3
Step 5
e1
R1 R2
e2 R3 v3
KCL at 1
G1 G1
0
G1 G1+G2
0
e1
I0
I0
0
e2
k v3
3 0 e3 0
R4
e3
Step 5
e1
R1 R2
e2 R3 v3
KCL at 1
G1 G1
0
G1 G1+G2 G3 G3
e1
I0
I0
0
G3 G3
e2
k v3
3
e3
R4
e3
Step 6
e1
R1 R2
e2 R3 v3
KCL at 1
G1 G1
0
G1 G1+G2 G3 G3
e1
I0
I0
0
G3 G3
e2
k v3
3
e3
R4
e3
Step 6
e1
R1 R2
e2 R3 v3
KCL at 1
G1 G1
0
G1 G1+G2 G3 G3
e1
I0
I0
0
G3 G3+G4
e2
k v3
3
e3
R4
e3
Step 7
e1
R1 R2
e2 R3 v3
KCL at 1
G1 G1
0
G1 G1+G2 G3 G3
e1
I0
I0
0
G3 G3+G4
e2
k v3
3
e3
R4
e3
Step 7
e1
R1 R2
e2 R3 v3
KCL at 1
G1 G1
0
G1 k G1+G2 G3 G3 +k
e1
I0
I0
0
G3 G3+G4
k
e2
k v3
3
e3
R4
e3
Outline
* Circuit simulation: introduction * Nodal analysis * Modied nodal analysis * Sparse tableau approach * Nonlinear circuits * Transient (dynamic) analysis
R2 v2
e2 i1 V0
R3
e3 i2
v 2
R1
+
0
* When a voltage source is involved, we cannot write its current in terms of node voltages (e1 , e2 , etc.). The NA approach has to be modied MNA.
R2 v2
e2 i1 V0
R3
e3 i2
v 2
R1
+
0
* When a voltage source is involved, we cannot write its current in terms of node voltages (e1 , e2 , etc.). The NA approach has to be modied MNA. * Treat the current through the voltage source as an additional unknown.
R2 v2
e2 i1 V0
R3
e3 i2
v 2
R1
+
0
* When a voltage source is involved, we cannot write its current in terms of node voltages (e1 , e2 , etc.). The NA approach has to be modied MNA. * Treat the current through the voltage source as an additional unknown. * We also need to get an additional equation since the number of unknowns has gone up by 1. This equation is provided by the branch equation of the voltage source.
R2 v2
e2 i1 V0
R3
e3 i2
v 2
R1
+
0
* When a voltage source is involved, we cannot write its current in terms of node voltages (e1 , e2 , etc.). The NA approach has to be modied MNA. * Treat the current through the voltage source as an additional unknown. * We also need to get an additional equation since the number of unknowns has gone up by 1. This equation is provided by the branch equation of the voltage source. * The solution vector now contains the voltage source currents in addition to the node voltages.
M. B. Patil, IIT Bombay
R2 v2
e2 i1 V0
R3
e3 i2
v 2
R1
+
VS1 0 VS2
KCL at 1 KCL at 2
e1
e2
KCL at 3
e3
i1 i2
R2 v2
e2 i1 V0
R3
e3 i2
v 2
R1
+
VS1 0 VS2
KCL at 1 KCL at 2
G1
e1
e2
KCL at 3
e3
i1 i2
R2 v2
e2 i1 V0
R3
e3 i2
v 2
R1
+
VS1 0 VS2
KCL at 1 KCL at 2
G1+G2 G2 G2
G2
e1
e2
KCL at 3
e3
i1 i2
R2 v2
e2 i1 V0
R3
e3 i2
v 2
R1
+
VS1 0 VS2
KCL at 1 KCL at 2
G1+G2 G2
G2 G2+G3 G3 G3 G3
e1
e2
KCL at 3
e3
i1 i2
R2 v2
e2 i1 V0
R3
e3 i2
v 2
R1
+
VS1 0 VS2
KCL at 1 KCL at 2
G1+G2 G2
G2 G2+G3 G3
1
e1
G3 G3
e2
KCL at 3
e3
i1 i2
V0
R2 v2
e2 i1 V0
R3
e3 i2
v 2
R1
+
VS1 0 VS2
KCL at 1 KCL at 2
G1+G2 G2
G2 G2+G3 G3
1
e1
G3 G3
e2
KCL at 3
e3
i1 i2
V0
Outline
* Circuit simulation: introduction * Nodal analysis * Modied nodal analysis * Sparse tableau approach * Nonlinear circuits * Transient (dynamic) analysis
* Variables: node voltages, branch currents, and branch voltages * No need for special treatment of voltage sources or any other elements
* Variables: node voltages, branch currents, and branch voltages * No need for special treatment of voltage sources or any other elements * Circuit topology and element equations are decoupled.
* Variables: node voltages, branch currents, and branch voltages * No need for special treatment of voltage sources or any other elements * Circuit topology and element equations are decoupled. * Easier to implement as compared to MNA
STA example
v2
V2 i2
v 4
v3 R2 i3 v6 R1
V3 i6 V0
v4 R3 i4 v5
V4 i5 I0
V1
v1
i1
1 1 1 1 1 1 1 1 1
0
R1 R2 R3
i1 i2 0 i3 i4 i5 1 1 i6 1 1 1 v1 1 1 1 1 1 v2 1 1 v3 1 v4 1 1 v5 1 v6 1 V 1 1 0 V 1 2 V3 V 1 4
I0 V0
STA example
v2
V2 i2
v 4
v3 R2 i3 v6 R1
V3 i6 V0
v4 R3 i4 v5
V4 i5 I0
V1
v1
i1
KCL
1 1 1 1 1 1 1 1 1
0
R1 R2 R3
i1 i2 0 i3 i4 i5 1 1 i6 1 1 1 v1 1 1 1 1 1 v2 1 1 v3 1 v4 1 1 v5 1 v6 1 V 1 1 0 V 1 2 V3 V 1 4
I0 V0
STA example
v2
V2 i2
v 4
v3 R2 i3 v6 R1
V3 i6 V0
v4 R3 i4 v5
V4 i5 I0
V1
v1
i1
KCL
1 1 1 1 1 1 1 1 1
0
R1 R2 R3
i1 i2 0 i3 i4 i5 1 1 i6 1 1 1 v1 1 1 1 1 1 v2 1 1 v3 1 v4 1 1 v5 1 v6 1 V 1 1 0 V 1 2 V3 V 1 4
I0 V0
STA example
v2
V2 i2
v 4
v3 R2 i3 v6 R1
V3 i6 V0
v4 R3 i4 v5
V4 i5 I0
V1
v1
i1
KCL
1 1 1 1 1 1 1 1 1
0
R1
Branch Equations
R2 R3
i1 i2 0 i3 i4 i5 1 1 i6 1 1 1 v1 1 1 1 1 1 v2 1 1 v3 1 v4 1 1 v5 1 v6 1 V 1 1 0 V 1 2 V3 V 1 4
I0 V0
* STA matrix is larger, but more sparse. * If A is an N N matrix, the CPU time to solve Ax = b is proportional to N , where is 3 for a dense matrix and typically 1.5 to 2 for a sparse matrix.
* STA matrix is larger, but more sparse. * If A is an N N matrix, the CPU time to solve Ax = b is proportional to N , where is 3 for a dense matrix and typically 1.5 to 2 for a sparse matrix. * STA is generally slower than MNA, but this is not a concern for relatively small problems (including many problems in power electronics).
* STA matrix is larger, but more sparse. * If A is an N N matrix, the CPU time to solve Ax = b is proportional to N , where is 3 for a dense matrix and typically 1.5 to 2 for a sparse matrix. * STA is generally slower than MNA, but this is not a concern for relatively small problems (including many problems in power electronics). * Historically, STA was the rst systematic approach used for circuit simulation (ASTAP by IBM). SPICE, based on MNA, was developed subsequently at UC Berkeley.
* STA matrix is larger, but more sparse. * If A is an N N matrix, the CPU time to solve Ax = b is proportional to N , where is 3 for a dense matrix and typically 1.5 to 2 for a sparse matrix. * STA is generally slower than MNA, but this is not a concern for relatively small problems (including many problems in power electronics). * Historically, STA was the rst systematic approach used for circuit simulation (ASTAP by IBM). SPICE, based on MNA, was developed subsequently at UC Berkeley. * Most of the circuit simulation programs available today are based on MNA, and many of them make use of SPICE.
Outline
* Circuit simulation: introduction * Nodal analysis * Modied nodal analysis * Sparse tableau approach * Nonlinear circuits * Transient (dynamic) analysis
V1
V2 + V0 R D
Vs
+
0
V1
V2 + V0 R D
Vs
+
0
V0 V2 R
V1
V2 + V0 R D
Vs
+
0
V0 V2 R V0 V2 R
V1
V2 + V0 R D
Vs
+
0
V0 V2 R V0 V2 R
Rewrite as f (V2 ) = 0. In general, consider f (x ) = 0. Expand around an initial guess x0 . f (x0 + x ) = f (x0 ) + x f (x0 ) + We want x such that f (x0 + x ) = 0 . x = f (x0 ) f (x0 )
800
600
f (x)
400
1 2
200
0 2 3 4
3
5
10
i 1 2 3 4 5 6 7
0.447214101 0.447214101
0.748105 0.4701012
Consider solving f (x ) = 0 with the N-R method. Dene g (x ) = x The N-R iteration can be written as [8], x (n+1) = x (n) + x (n) = g (x (n) ) . (2) f (x ) . f (x ) (1)
Consider solving f (x ) = 0 with the N-R method. Dene g (x ) = x The N-R iteration can be written as [8], x (n+1) = x (n) + x (n) = g (x (n) ) . Application of Taylors theorem to Eq. 1 yields, g (x ) = g (r ) + g (r )(x r ) + where lies between x and r . g ( ) (x r )2 , 2 (3) (2) f (x ) . f (x ) (1)
Consider solving f (x ) = 0 with the N-R method. Dene g (x ) = x The N-R iteration can be written as [8], x (n+1) = x (n) + x (n) = g (x (n) ) . Application of Taylors theorem to Eq. 1 yields, g (x ) = g (r ) + g (r )(x r ) + where lies between x and r . The derivative g (x ) can be obtained from Eq. 1 as, g (x ) = 1 [f (x )]2 f (x )f (x ) . [f (x )]2 (4) g ( ) (x r )2 , 2 (3) (2) f (x ) . f (x ) (1)
Since f (r ) = 0, we get g (r ) = r from Eq. 1 and g (r ) = 0 from Eq. 4. Substituting for g (r ) and g (r ) in Eq. 3, we get, g (x ) = r + g ( ) (x r )2 . 2 (5)
Since f (r ) = 0, we get g (r ) = r from Eq. 1 and g (r ) = 0 from Eq. 4. Substituting for g (r ) and g (r ) in Eq. 3, we get, g (x ) = r + g ( ) (x r )2 . 2 (5)
Replace x by x (n) and use the fact that g (x (n) ) is the same as x (n+1) in the N-R procedure, to get 2 g ( ) (n ) x r . x (n+1) r = 2
(6)
Since f (r ) = 0, we get g (r ) = r from Eq. 1 and g (r ) = 0 from Eq. 4. Substituting for g (r ) and g (r ) in Eq. 3, we get, g (x ) = r + g ( ) (x r )2 . 2 (5)
Replace x by x (n) and use the fact that g (x (n) ) is the same as x (n+1) in the N-R procedure, to get 2 g ( ) (n ) x r . (6) x (n+1) r = 2 As x (n) converges to r , so does ; and we can replace g ( ) by g (r ), a constant. Further, if we dene (n) x (n) r (the error at the nth N-R iteration), we can write Eq. 6 as (n+1) = k [ ( n ) ]2 , (7) where k = g (r )/2. Eq. 7 describes the well-known feature of quadratic convergence of the N-R method, i.e., the error goes down quadratically as x (n) r .
log [ (n+1) ]
25 4
5 6 7 8 9 5
10 5
log [
(n)
log ( (n+1) ) versus log ( (n) ) with the N-R scheme and the xed-point iteration method for f (x ) = x 2 6x + 8 = 0, with x = 0 as the initial guess. The green line represents g ( r ) (n ) 2 (n+1) = ( ) . The iteration numbers are also shown for each scheme. Note the quadratic 2 convergence of the N-R method. (Both schemes were found to converge to r = 2 for the specied initial guess.)
M. B. Patil, IIT Bombay
Consider a system of N ODEs: f1 (x1 , x2 , . . , xN ) = 0 , f2 (x1 , x2 , . . , xN ) = 0 , .... , 2 fN (x1 , x2 , . . , xN ) = 0 . The correction vector x can be obtained by solving J
(i )
(i )
= f
(i )
where i is the iteration number, J is the Jacobian matrix, and f is the function vector.
i 1 2 3 4 5 6 7 8 9 10
x1
(i )
x2
(i )
|| f ||2 0.10241102 0.78909101 0.61523101 0.48512101 0.3848110 0.3062010 0.95091 0.3148710 0.3873510 0.5885510
1 4 10 1 1
x1
(i )
x2
(i )
0.40000101 0.25244101 0.18371101 0.14793101 0.1264610 0.1123110 0.62883 0.70976 0.71263 0.71263
1 1
0.15000102 0.14675102 0.13922102 0.13128102 0.1242110 0.1182610 0.9371110 0.9290210 0.9287310 0.9287310
2 2 1 1 1 1
0.73776 101 0.34368 101 0.17887 101 0.10737 101 0.70747 0.49427 0.8093210 0.2869010 0.3538110 0.5375910
1 2 5 11
0.16223 101 0.37631 101 0.39712 101 0.35342 101 0.29789 101 0.24548 101 0.80932 101 0.28690 102 0.35381 105 0.53753 1011
Application of the N-R method to a system of two equations, with f1 x1 + x2 10 = 0, and f2 x2 15 tan1 (x1 ) = 0.
1 3 14 4 5 12 6 4.0 3.0 2.0 1.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 8 12.0 2
x2
10
x1
Application of the N-R method to a system of two equations, with f1 x1 + x2 10 = 0, and f2 x2 15 tan1 (x1 ) = 0. The contours are labelled by the 2-norm, || f ||2 . Circled integers represent the iteration numbers.
2 1.5 1 3 1 P
f(x)
20
30
40
Application of the N-R method to f (x ) = tan1 x = 0, with x = 1.5 as the initial guess.
Instead of x (n+1) = x (n) + x (n) , as in the standard N-R algorithm, we use x (n+1) = = x (n ) + k x (n ) n o x (n) + k [f (x (n) )]1 f (x (n) ) ,
1.5 1 0.5
f(x)
0 0.5 2 1 1.5 2
1.5
0.5
0.5
1.5
Application of the N-R method to f (x ) = tan1 x = 0, with x = 1.5 as the initial guess and a damping factor k = 0.7.
M. B. Patil, IIT Bombay
10 2 No damping k=0.2 10
2
k=0.5 |f| 10
6
10
10
10
14
12
16
20
Iteration Number
Application of the N-R method to f (x ) = tan1 x = 0, with x = 1.5 as the initial guess and f dierent damping factors. (For the case with no damping, N-R iterations stopped due to x becoming too small.)
* Damping improves chances of convergence. * However, it makes convergence slower as compared to the standard N-R method.
* Damping improves chances of convergence. * However, it makes convergence slower as compared to the standard N-R method. * Damping should be used only when the standard N-R method fails to converge.
* Damping improves chances of convergence. * However, it makes convergence slower as compared to the standard N-R method. * Damping should be used only when the standard N-R method fails to converge. * Damping is very useful in power electronic circuits since they are highly non-linear (due to switches).
* Damping improves chances of convergence. * However, it makes convergence slower as compared to the standard N-R method. * Damping should be used only when the standard N-R method fails to converge. * Damping is very useful in power electronic circuits since they are highly non-linear (due to switches). * For transient simulation, in addition to damping, reducing the time step may also help in convergence.
(8)
k (x1 + x2 6 3) = 0 ,
2 2 10x1 x2 + 45 = 0 .
1010 Double Precision 10 5
(8)
k=105 k=1
100 10 10
5
10
10
15
10
15
|| f || 2 versus N-R iteration number for Eq. 8, with x1 = x2 = 1 as the initial guess, (a) Single precision arithmetic, (b) Double precision arithmetic.
k (x1 + x2 6 3) = 0 ,
2 2 10x1 x2 + 45 = 0 .
1010 Double Precision 10 5
(8)
k=105 k=1
100 10 10
5
10
10
15
10
15
|| f || 2 versus N-R iteration number for Eq. 8, with x1 = x2 = 1 as the initial guess, (a) Single precision arithmetic, (b) Double precision arithmetic.
k (x1 + x2 6 3) = 0 ,
2 2 10x1 x2 + 45 = 0 .
1010 Double Precision 10 5
(8)
k=105 k=1
100 10 10
5
10
10
15
10
15
|| f || 2 versus N-R iteration number for Eq. 8, with x1 = x2 = 1 as the initial guess, (a) Single precision arithmetic, (b) Double precision arithmetic.
* If k is made larger, the norm saturates at a higher value. * Precision has a signicant eect on the lowest achievable norm.
M. B. Patil, IIT Bombay
MNA equations:
e1 i1 Vs e2
= = =
0, 0, V0 ,
+
0
+ V0
R D
iD
* The circuit equations can be assembled using the MNA or STA approach.
MNA equations:
e1 i1 Vs e2
= = =
0, 0, V0 ,
+
0
+ V0
R D
iD
* The circuit equations can be assembled using the MNA or STA approach. * Since the equations are non-linear, the N-R method is used to solve them.
MNA equations:
e1 i1 Vs e2
= = =
0, 0, V0 ,
+
0
+ V0
R D
iD
* The circuit equations can be assembled using the MNA or STA approach. * Since the equations are non-linear, the N-R method is used to solve them. * More expensive than a linear circuit of the same size, since several (typically 3 to 5) N-R iterations are involved, each requiring the solution of Jx = f .
Outline
* Circuit simulation: introduction * Nodal analysis * Modied nodal analysis * Sparse tableau approach * Nonlinear circuits * Transient (dynamic) analysis
V s (t)
V s (t)
(a)
(b)
V s (t)
V s (t)
(c)
(d)
V s (t)
V s (t)
(a)
(b)
V s (t)
V s (t)
(c)
(d)
* In (a) and (b), we can use the techniques seen earlier. At a given time t , we simply need to replace the source with a DC source with voltage = Vs (t ).
V s (t)
V s (t)
(a)
(b)
V s (t)
V s (t)
(c)
(d)
* In (a) and (b), we can use the techniques seen earlier. At a given time t , we simply need to replace the source with a DC source with voltage = Vs (t ). * In (c) and (d), the situation is very dierent due to the presence of a capacitor which involves time derivatives.
M. B. Patil, IIT Bombay
Transient analysis
a
R
b
iC vC
0
dvC * The capacitor current, iC = C , cannot be written in terms of the dt instantaneous node voltages or branch voltages since its value depends on the past behaviour of vC .
Transient analysis
a
R
b
iC vC
0
dvC * The capacitor current, iC = C , cannot be written in terms of the dt instantaneous node voltages or branch voltages since its value depends on the past behaviour of vC . * We need some way of approximating the derivative in terms of the past behaviour of vC .
Discretization of time
t1 t2 t0 t begin t1
t3 ...... t2 t3
t N1 t N1 t N t end
time
* Discretization of time is required since numerical solution can only be obtained at a nite number of points.
Discretization of time
t1 t2 t0 t begin t1
t3 ...... t2 t3
t N1 t N1 t N t end
time
* Discretization of time is required since numerical solution can only be obtained at a nite number of points. * The time steps (ti ) may not be uniform.
Discretization of time
t1 t2 t0 t begin t1
t3 ...... t2 t3
t N1 t N1 t N t end
time
* Discretization of time is required since numerical solution can only be obtained at a nite number of points. * The time steps (ti ) may not be uniform. * Generally, the time steps are computed dynamically, not a priori.
Discretization of time
R Vs 0 C V
10 8 V (Volts) V (Volts) 6 4 2
10 8 6 4 2 V (Volts)
10 8 6 4 2
(a)
0 0 5 10 15 Time (sec) 20 25 0 0 5 10 15 Time (sec) 20
(b)
25 0 0 5 10 15 Time (sec) 20
(c)
25
Discretization of time
R Vs 0 C V
10 8 V (Volts) V (Volts) 6 4 2
10 8 6 4 2 V (Volts)
10 8 6 4 2
(a)
0 0 5 10 15 Time (sec) 20 25 0 0 5 10 15 Time (sec) 20
(b)
25 0 0 5 10 15 Time (sec) 20
(c)
25
(a) Typical simulator output. (b) After connecting the output points with line segments.
Discretization of time
R Vs 0 C V
10 8 V (Volts) V (Volts) 6 4 2
10 8 6 4 2 V (Volts)
10 8 6 4 2
(a)
0 0 5 10 15 Time (sec) 20 25 0 0 5 10 15 Time (sec) 20
(b)
25 0 0 5 10 15 Time (sec) 20
(c)
25
(a) Typical simulator output. (b) After connecting the output points with line segments. (c) After removing the output points (but retaining the segments), the waveform looks continuous, but this is an illusion!
M. B. Patil, IIT Bombay
x n+1 xn
tn
t n+1
Approximation for
dx = f (t , x ) dt
xn+1 xn = f (tn , xn ) h
x n+1 xn
tn
t n+1
Approximation for
dx = f (t , x ) dt
x n+1 xn
tn
t n+1
Approximation for
dx = f (t , x ) dt
FE : BE : TRZ :
FE : BE : TRZ :
The exact solution is x (t ) = e t . Expanding around tn , we get, x n+1 = x n + h Compare with FE : xn+1 = xn (1 h) dx + = x n + h(e tn ) + = x n (1 h + h2 /2 h3 /6 + ) . dt
The exact solution is x (t ) = e t . Expanding around tn , we get, x n+1 = x n + h Compare with FE : BE : xn+1 = xn+1 = xn (1 h) xn 1 = xn (1 h + h2 + ) 1+h dx + = x n + h(e tn ) + = x n (1 h + h2 /2 h3 /6 + ) . dt
The exact solution is x (t ) = e t . Expanding around tn , we get, x n+1 = x n + h Compare with FE : BE : TRZ : xn+1 = xn+1 = xn+1 = xn (1 h) xn xn 1 = xn (1 h + h2 + ) 1+h 1 h/2 = xn (1 h + h2 /2 h3 /4 + ) 1 + h/2 dx + = x n + h(e tn ) + = x n (1 h + h2 /2 h3 /6 + ) . dt
The exact solution is x (t ) = e t . Expanding around tn , we get, x n+1 = x n + h Compare with FE : BE : TRZ : xn+1 = xn+1 = xn+1 = xn (1 h) xn xn 1 = xn (1 h + h2 + ) 1+h 1 h/2 = xn (1 h + h2 /2 h3 /4 + ) 1 + h/2 dx + = x n + h(e tn ) + = x n (1 h + h2 /2 h3 /6 + ) . dt
* If h
The exact solution is x (t ) = e t . Expanding around tn , we get, x n+1 = x n + h Compare with FE : BE : TRZ : xn+1 = xn+1 = xn+1 = xn (1 h) xn xn 1 = xn (1 h + h2 + ) 1+h 1 h/2 = xn (1 h + h2 /2 h3 /4 + ) 1 + h/2 dx + = x n + h(e tn ) + = x n (1 h + h2 /2 h3 /6 + ) . dt
* If h
* If the starting point x (tn ) is the same, the error (dierence between the exact and numerical solutions) is O (h2 ) for FE and BE, and O (h3 ) for TRZ.
M. B. Patil, IIT Bombay
104
BE TRZ
local
numerical exact 1012 104 108
local
tn
tn+1
tn+2
103
101
100
* The local error is the error made in a single step, assuming that the starting point is exact. In this case, starting from the exact value, x (0) = 1, the dierence |x (h) x (h)| has been computed.
104
BE TRZ
local
numerical exact 1012 104 108
local
tn
tn+1
tn+2
103
101
100
* The local error is the error made in a single step, assuming that the starting point is exact. In this case, starting from the exact value, x (0) = 1, the dierence |x (h) x (h)| has been computed. * If h h/10, the error decreases by a factor of 102 for the FE and BE methods, and by 103 for the TRZ method.
104
BE TRZ
local
numerical exact 1012 104 108
local
tn
tn+1
tn+2
103
101
100
* The local error is the error made in a single step, assuming that the starting point is exact. In this case, starting from the exact value, x (0) = 1, the dierence |x (h) x (h)| has been computed. * If h h/10, the error decreases by a factor of 102 for the FE and BE methods, and by 103 for the TRZ method. * The TRZ method is therefore said to be more accurate than FE or BE.
M. B. Patil, IIT Bombay
1.0
h=0.5
0.8 0.6 TRZ BE exact
x
0.4 0.2 0.0 0
1.0
h=0.5
0.8 0.6 TRZ BE exact
x
0.4 0.2 0.0 0
* The higher accuracy of the TRZ method allows larger time steps.
h=0.1 1.0 0.8 0.6 0.4 0.2 0.0 0 1 2 h=0.5 1.0 0.8 0.6 0.4 0.2 0.0 0 1 2 3 4 3 4 exact FE BE
h=0.1 1.0 0.8 0.6 0 0.4 0.2 0.0 0 1 2 h=0.5 1.0 0.8 0.6 0.4 0.2 0.0 0 1 2 3 4 3 4 1 0 5 exact FE BE 1
h=2.0
10
15
20
h=0.1 1.0 0.8 0.6 0 0.4 0.2 0.0 0 1 2 h=0.5 1.0 0.8 0.6 0.4 0.2 0.0 0 1 2 3 4 3 2 1 0 1 2 3 0 5 3 4 1 0 5 exact FE BE 1
h=2.0
10 h=2.1
15
20
10
15
20
* Although the FE and BE methods are comparable in accuracy, the FE method is unstable and therefore not useful for circuit simulation.
* Although the FE and BE methods are comparable in accuracy, the FE method is unstable and therefore not useful for circuit simulation. * Can we not use a smaller time step and avoid the instability problem?
* Although the FE and BE methods are comparable in accuracy, the FE method is unstable and therefore not useful for circuit simulation. * Can we not use a smaller time step and avoid the instability problem? Yes, but it increases the simulation time, and in some cases (sti circuits), by orders of magnitude!
* Although the FE and BE methods are comparable in accuracy, the FE method is unstable and therefore not useful for circuit simulation. * Can we not use a smaller time step and avoid the instability problem? Yes, but it increases the simulation time, and in some cases (sti circuits), by orders of magnitude! * The issue of stability rules out many other methods as well.
= xn + = xn +
2 h (xn +1 )
h 2 2 (xn xn +1 ) 2
= xn + = xn +
2 h (xn +1 )
h 2 2 (xn xn +1 ) 2
= xn + = xn +
2 h (xn +1 )
h 2 2 (xn xn +1 ) 2
* In the FE formula, xn+1 can be explicitly evaluated in terms of xn . * The BE and TRZ formulas result in equations which must be solved for xn+1 . This is much more work, and it gets worse when there are many equations involved.
= xn + = xn +
2 h (xn +1 )
h 2 2 (xn xn +1 ) 2
* In the FE formula, xn+1 can be explicitly evaluated in terms of xn . * The BE and TRZ formulas result in equations which must be solved for xn+1 . This is much more work, and it gets worse when there are many equations involved. * However, the FE method is not useful because it can be unstable in some cases.
M. B. Patil, IIT Bombay
* Two major concerns: accuracy (order) and stability * A method with a higher accuracy (order) is more ecient as it allows a larger time step fewer time points faster simulation.
* Two major concerns: accuracy (order) and stability * A method with a higher accuracy (order) is more ecient as it allows a larger time step fewer time points faster simulation. * However, high-order methods are conditionally stable, i.e., if the time step is large (compared to the smallest time constant in the circuit), the solution grows indenitely, as in the FE example.
* Two major concerns: accuracy (order) and stability * A method with a higher accuracy (order) is more ecient as it allows a larger time step fewer time points faster simulation. * However, high-order methods are conditionally stable, i.e., if the time step is large (compared to the smallest time constant in the circuit), the solution grows indenitely, as in the FE example. * Power electronic circuits are usually sti (i.e., they involve time constants which are vastly dierent), and one cannot aord to make h smaller than the smallest because (a) such a high resolution is not required, (b) it would dramatically increase the simulation time.
* Two major concerns: accuracy (order) and stability * A method with a higher accuracy (order) is more ecient as it allows a larger time step fewer time points faster simulation. * However, high-order methods are conditionally stable, i.e., if the time step is large (compared to the smallest time constant in the circuit), the solution grows indenitely, as in the FE example. * Power electronic circuits are usually sti (i.e., they involve time constants which are vastly dierent), and one cannot aord to make h smaller than the smallest because (a) such a high resolution is not required, (b) it would dramatically increase the simulation time. * The stability constraints signicantly reduce the choices available for circuit simulation. BE, Gear (order 2), and Trapezoidal methods are commonly used.
h n+1 n i + vC C C
OR
n+1 iC =
C n+1 C n v vC . h C h
h n+1 n i + vC C C
OR
n+1 iC =
C n+1 C n v vC . h C h
n+1 vC n vC
+1 in C
+
h/C h/C
iC vC
+1 in C
n vC C/h
* In some circuits, a constant t is appropriate; in others, especially with many switching events, automatic time step selection is more eective.
* In some circuits, a constant t is appropriate; in others, especially with many switching events, automatic time step selection is more eective. * Automatic time step selection is based on (a) estimate of the local truncation error at a given time step, (b) convergence behaviour of N-R iterations.
* In some circuits, a constant t is appropriate; in others, especially with many switching events, automatic time step selection is more eective. * Automatic time step selection is based on (a) estimate of the local truncation error at a given time step, (b) convergence behaviour of N-R iterations. * Power electronic circuits are generally nonlinear; time step has a signicant impact on convergence of N-R iterations. Option (b) is therefore very eective.
* In some circuits, a constant t is appropriate; in others, especially with many switching events, automatic time step selection is more eective. * Automatic time step selection is based on (a) estimate of the local truncation error at a given time step, (b) convergence behaviour of N-R iterations. * Power electronic circuits are generally nonlinear; time step has a signicant impact on convergence of N-R iterations. Option (b) is therefore very eective. * N-R convergence
* In some circuits, a constant t is appropriate; in others, especially with many switching events, automatic time step selection is more eective. * Automatic time step selection is based on (a) estimate of the local truncation error at a given time step, (b) convergence behaviour of N-R iterations. * Power electronic circuits are generally nonlinear; time step has a signicant impact on convergence of N-R iterations. Option (b) is therefore very eective. * N-R convergence - The solution obtained at ti serves as the initial guess at ti +1 .
* In some circuits, a constant t is appropriate; in others, especially with many switching events, automatic time step selection is more eective. * Automatic time step selection is based on (a) estimate of the local truncation error at a given time step, (b) convergence behaviour of N-R iterations. * Power electronic circuits are generally nonlinear; time step has a signicant impact on convergence of N-R iterations. Option (b) is therefore very eective. * N-R convergence - The solution obtained at ti serves as the initial guess at ti +1 . - t too large N-R iterations may not converge.
* In some circuits, a constant t is appropriate; in others, especially with many switching events, automatic time step selection is more eective. * Automatic time step selection is based on (a) estimate of the local truncation error at a given time step, (b) convergence behaviour of N-R iterations. * Power electronic circuits are generally nonlinear; time step has a signicant impact on convergence of N-R iterations. Option (b) is therefore very eective. * N-R convergence - The solution obtained at ti serves as the initial guess at ti +1 . - t too large N-R iterations may not converge. - t too small large simulation time.
Start (t = t0)
t = t + t
t = k1 t
Yes NR
t = t/k2
No
t = tmax ?
No Converged? Yes No
t = tmin ?
Yes Stop
Vs
R2
* very dicult to judge except for simple problems * In practice, reduce t by a factor of 2 and see if the results are dierent.
* very dicult to judge except for simple problems * In practice, reduce t by a factor of 2 and see if the results are dierent. * Usually, the user would have some idea of the time scale, For example, (a) Buck converter: t = Tc /50 may be appropriate. (b) Half-wave rectier: t = T /50 may be appropriate. Such a rule of thumb provides a good starting point.
* In many periodic systems, only the steady-state behaviour is of interest (and not how it is attained). e.g., power electronic circuits, rf circuits
* In many periodic systems, only the steady-state behaviour is of interest (and not how it is attained). e.g., power electronic circuits, rf circuits * Transient simulation (from some initial condition to the steady state) may involve thousands of cycles; this is very expensive.
* In many periodic systems, only the steady-state behaviour is of interest (and not how it is attained). e.g., power electronic circuits, rf circuits * Transient simulation (from some initial condition to the steady state) may involve thousands of cycles; this is very expensive. * Total time for which transient simulation needs to be performed to reach the steady state is not known a priori; need to rely on a trial-and-error approach.
* In many periodic systems, only the steady-state behaviour is of interest (and not how it is attained). e.g., power electronic circuits, rf circuits * Transient simulation (from some initial condition to the steady state) may involve thousands of cycles; this is very expensive. * Total time for which transient simulation needs to be performed to reach the steady state is not known a priori; need to rely on a trial-and-error approach. * It is much faster to obtain the steady-state information directly where a nonlinear problem in the state variables is solved.
+
0
20
0.03
* A large number of cycles are required if transient simulation is used. (Note that, for this example, the steady state is not quite reached as indicated by the small amplitude variation.)
+
0
20
0.03
* A large number of cycles are required if transient simulation is used. (Note that, for this example, the steady state is not quite reached as indicated by the small amplitude variation.) * If a component value (L or C ) is changed, we would not know how long to simulate to attain steady state. This is cumbersome.
M. B. Patil, IIT Bombay
0.2
* Start with an initial guess for the state variable(s) (the capacitor voltage here).
0.2
* Start with an initial guess for the state variable(s) (the capacitor voltage here). * Integrate for one cycle. Is Vc (T ) = Vc (0)?
0.2
* Start with an initial guess for the state variable(s) (the capacitor voltage here). * Integrate for one cycle. Is Vc (T ) = Vc (0)? * If yes (red curve), we have obtained the SSW solution; if not, we need to compute a better initial guess (in an outer Newton-Raphson loop) and repeat [7].
M. B. Patil, IIT Bombay
SSW: Examples
Example Buck Converter Boost Converter C uk Converter 1- half-wave rectier 1- half-controlled bridge converter 3- diode bridge rectier Induction motor
Nssw 4 3 3 3 4 4 17
* Note the dramatic reduction in computational eort for the SSW method as compared to transient analysis.
References
[1] L. O. Chua and P. M. Lin, Computer-Aided Analysis of Electronic Circuits, Englewood Clis: Prentice-Hall, 1976. [2] W. J. McCalla, Fundamentals of Computer-Aided Circuit Simulation, Boston: Kluwer Academic Publishers, 1987. [3] R. Raghuram, Computer Simulation of Electronic Circuits, New Delhi: Wiley Eastern, 1989. [4] K. S. Kundert, The Designers Guide to SPICE and SPECTRE, Boston: Kluwer Academic Publishers, 1995. [5] M. B. Patil, V. Ramanarayanan, and V. T. Ranganathan, Simulation of Power Electronic Circuits, to be published. [6] C. D. Hachtel and R. K. Brayton and F. G. Gustavson, The sparse tableau approach to network analysis and design, IEEE Trans. CT, vol. 18, pp. 101-113, 1971. [7] F. R. Colon and T. N. Trick, Fast periodic steady-state analysis for large-signal electronic circuits, IEEE J. Solid-State Circuits, vol. 8, pp. 260-269, 1973. [8] C. F. Gerald and P. O. Whitley, Applied Numerical Analysis, Delhi: Pearson Education India, 1999.