Simulation Objective –Given a circuit, to find out whether it behaves in the desired manner or not...
-
Upload
julia-fisher -
Category
Documents
-
view
216 -
download
0
Transcript of Simulation Objective –Given a circuit, to find out whether it behaves in the desired manner or not...
Simulation
• Objective– Given a circuit, to find out whether it behaves in the desired
manner or not
• How accurate do we want to be?– Device-level simulation– Circuit-level simulation (SPICE)– Timing simulation/logic simulation– etc.
Circuit simulation
• Given a netlist of elements– transistors, resistors, capacitors, transmission lines, etc.
• Find currents and voltages at all points of interest• Example
R=1R=1V=1
More formally...
• Write the network equations– Topological equations
• Kirchoff’s Current Law (KCL): current entering each node is 0
• Kirchoff’s Voltage Law (KVL): voltage around each loop is 0
– Device equations: describe the behavior of the device, e.g., V= IR
• Solve the system of equations to find V, I everywhere
The incidence matrix
• Properties– nxb matrix (n = number of nodes, b = number of branches)– Each column has exactly one +1 and one -1– Rank = n-1 for a connected graph
1 3
4
2
b1
b2
b4
b3
b5
11001
10100
01110
00011
4
3
2
1
A
KCL and KVL
• KCL: A I = 0 (A: n x b, I: b x 1)
• KVL: vb = AT vn (vb: b x 1, vn: n x 1)
1 3
4
2
b1
b2
b4
b3
b5
0
0
0
0
)5(
)4(
)3(
)2(
)1(
11001
10100
01110
00011
bi
bi
bi
bi
bi
4
3
2
1
1100
1010
0110
0011
1001
)5(
)4(
)3(
)2(
)1(
v
v
v
v
bv
bv
bv
bv
bv
Device equations
• General form:– Ib = Y vb + s
• If b1 is a current source, others are resistors
1 3
4
2
b1
b2
b4
b3
b5
0
0
0
0
)5(
)4(
)3(
)2(
)1(
50000
04000
00300
00020
00000
)5(
)4(
)3(
)2(
)1( I
bv
bv
bv
bv
bv
g
g
g
g
bi
bi
bi
bi
bi
Circuit equations
• (Use reduced incidence matrix now – remove ground node)• Set of equations describing the circuit
– KCL: A Ib = 0
– KVL: vb = AT vn
– DE: Ib = Y vb + s
• Some simple algebra:– DE + KVL: Ib = Y AT vn + s
– DE + KVL + KCL: A (Y AT vn + s) = 0
AY AT vn = - A s
• This is the nodal formulation of circuit equations
Modified nodal formulation
• Nodal formulation cannot handle all device types (e.g., voltage sources)
• DE’s can be of two types– Type 1 branches: Ib1 = Y vb1 + s1
– Type 2 branches: Z Ib2 + G vb2 = s2
• Rewrite KCL and KVL slightly– KCL:
– KVL:
0
2
121
b
b
I
IAA
nvv
v
T
T
A
A
2
1
b2
b1
Modified nodal formulation (Contd.)
• Set of equations describing the circuit– KCL: A1 Ib1 + A2 Ib2 = 0
– KVL: vb1 = A1T vn
vb2 = A2T vn
– DE: Ib1 = Y vb1 + s1
Z Ib2 + G vb2 = s2
• Simple algebra again leads to
2
11
22
211s
sv A
IZGA
AYAA
b
nT
T
Writing the circuit equations
• Multiplying matrices can be messy!– Can write circuit equations by inspection by creating element
“stamps”; need not multiply any matrices
• Basic circuit elements– Conductance: i = g v– Current source: i = k– Voltage source: v = k– Controlled sources
• CCCS: i = k i’• CCVS: v = k i’• VCCS: i = k v’• VCVS: v = k v’
Stamp for a conductance
• Nodal formulation– DE + KVL: Ib = Y AT vn + s
– DE + KVL + KCL: A (Y AT vn + s) = 0, i.e., AY AT vn = - A s
– KCL << DE << KVL
• Conductance– KCL:
– KCL+DE:
– KCL+DE+KVL:
n1 n2g
0
:
:
:
........
....1..
........
....1..
2
1
gi
n
n
0
:
:
:
........
......
........
......
2
1
gv
g
g
n
n
0
:
:
:
..........
......
..........
......
2
1
2
1
n
n
v
v
gg
gg
n
n
Element Stamps: Admittances (Type 1)
• Conductance g
• For AC analysis only– Single frequency excitation– Inductance: admittance of 1/j L– Capacitance: admittance of j C– Similar stamp: replace g by 1/j L or j C
..........
......
..........
......
2
1
gg
gg
n
n
Independent current source (Type 1)
• Current source– KCL:
– KCL+DE:
• iJ has been eliminated entirely
• Does not impact KVL since Ib1 = Y vb1 + s1has zero entries in Y
• Alternative interpretation: voltage across a current source can take on any value
n1 n2
J
0
:
:
:
........
....1..
........
....1..
2
1
Ji
n
n
J
J
:
:
:
:
........
........
........
........
2
1
n
n
Independent voltage source (Type 2)
– KCL: A1 Ib1 + A2 Ib2 = 0
– KVL: vb1 = A1T vn
vb2 = A2T vn
– DE: Ib1 = Y vb1 + s1
Z Ib2 + G vb2 = s2
– Current through voltage source is a variable that is not eliminated
– Assume: value of the voltage source = K volts– KCL KVL+DE
0
Vi
n
n
:
:
:
:
:
............
1..........
............
1..........
2
1
Ki
v
v
n
n
V
n
n
:
:
:
:
:
:
:
:
......1..1
............
............
1..........
............
1..........
2
1
2
1
VCCS
Device equations:
Ijk = 0
Ilm = g Vjk
• Type I element: can write as I = Y V + s
• Stamp
+
-
v gv
j
k
l
m
0
:
:
............
........
........
............
............
............
:
:
m
l
k
j
v
v
v
v
gg
gg
m
l
k
j
Col j Col k
Using the stamps
• b1 is a current source J, others are conductances g2..g5
• All are Type 1 elements• KCL+KVL+DE gives us
1 3
0
2
b1
b2
b4
b3
b5
0
0
5330
34322
022
3
2
1
3
2
1 J
v
v
v
ggg
ggggg
gg
Another example
• Equations:
• Solution (easy to check) v1 = 1, v2 = 0.5, iv = -0.5
R=1V=1
1 2
0
1
0
0
001
021
111
3
2
1
2
1
vi
v
v
R=1
Solution of nonlinear equations
• Solution by iteration– Find linear approximation around
a guess solution– Solve resulting system of linear eqs.– Iterate until convergence
• Example:– Diode equation: I = f(V) = Io (eV/Vt – 1)
– Assume a kth iteration guess (Ik, Vk)
– Taylor series expansion
I = Ik + [df/dV]k (V-Vk) + higher order terms
I
V
(neglected)
Local linearapproximation
Diode example (contd.)
• Linearizing the diode equation– I = f(V) = Io (eV/Vt – 1); df/dV = (I0/Vt) eV/Vt
– First order Taylor series expansion
I = Ik + [df/dV]k (V-Vk)
= Ik + (I0/Vt) exp(Vk/Vt) (V-Vk)
= ak V + bk
where ak = (I0/Vt) exp(Vk/Vt); bk = Ik - (I0/Vt) exp(Vk/Vt) Vk
• Circuit interpretation: – conductance of ak in parallel with a current source of bk
conductance ak
bk
Solution of a circuit containing diodes
• Example:– Linearize the circuit as shown earlier
– Solve the linear circuit;get (Inewk+1,Vnew
k+1)
– This lies on the linear approx.,
not on the I-V characteristic!– Choose (Ik+1, Vk+1) on diode characteristic– Continue iteratively until convergence
conductance ak
bk
cond
ucta
nce
g
+V-
cond
ucta
nce
g
+V-
I
V(Inew
k+1,Vnewk+1)
(Ik,Vk)(Ik+1,Vk+1)
“Current and voltage iterations”
• While mapping (Inewk+1,Vnew
k+1) to (Ik,Vk), need to get reasonable values for both– In previous example: fixed Vk+1= Vnew
k+1; found corresponding Ik+1 from diode equation
– Fixing Ik+1=Inewk+1 would have been a bad idea – no Vk+1!
• Heuristic for a diode:– If Vnew
k+1 Vcutin
• set Ik+1= Inewk+1; find Vk+1 = Vt log(Ik+1/I0 + 1)
– If Vnewk+1 < Vcutin
• set Vk+1= Vnewk+1; find Ik+1 = I0 (exp(Vk+1/Vt) – 1)
General procedure for nonlinear elements
• Intuition: Consider one function F of one variable xF(x) = 0
• First order Taylor series about a guess xk
F(x) = F(xk) + [dF/dx]k (x – xk) = 0 x = xk – {[dF/dx]k}-1 F(xk)
(Newton-Raphson update formula)• Can also write this as
{[dF/dx]k} x = {[dF/dx]k} xk – F(xk)• Analogy: for a vector of m functions F = [F1 F2 … Fm]T of
variables x = [x1 x2 … xn]T
Jk x =Jk xk – F(xk)where J = Jacobian matrix = analog of the derivative
Definition of Jacobian
• For a system of m nonlinear equations
F = [F1 F2 F3 … Fm]T
in n variables x = [x1 x2 x3 … xn]T, the Jacobian J is defined as
n
mmmm
n
n
x
F
x
F
x
F
x
F
x
F
x
F
x
F
x
Fx
F
x
F
x
F
x
F
J
321
2
3
2
2
2
1
2
1
3
1
2
1
1
1
Solution of a set of linear+nonlinear equations
• Given a set of equations in n variables– A x = b (m linear equations)– F(x) = 0 (n-m nonlinear equations)
• Choose initial guess xk, k = 01. Linearize F(x) = 0 as Jk x =Jk xk – F(xk) to get n-m linear eqs2. Solve these and A x = b – together n linear eqs in n vars.
3. Call this solution xnewk+1; map to xk+1 and increment k
4. If converged, quit; else go to step 1
• Convergence criterion||xk+1 – xk|| < and ||Fk+1 – Fk|| <
Simple example
• Solve x + y – 10 = 0, xy – 25 = 0– (We know that the solution is at x=5, y=5)
• Choose a guess (x0,y0) = (6,4)• Linearize nonlinear equation, f(x,y) = xy – 25 = 0
– Jk = [{df/dx}k {df/dy}k] = [yk xk]
– Linearized equation: • [yk xk] [x y]T = [yk xk] [xk yk]T – f(xk,yk), i.e., yk x + xk y = xk yk + 25
• Iteration 1: Solve x+y=10;4x+6y=49 x1 = 5.5, y1 = 4.5• Iteration 2: Solve x+y=10;4.5x+5.5y=49.75 x2= 5.25, y1 = 4.75• and so on…• Converges towards (5,5)
Another problem in this example!
• At the solution (5,5), the linearized equation is– 5x+5y = 50, or x+y=10 – identical to the other equation!– Solution will be anywhere along this line
• In this case, this happened because we got (un)lucky• However, this illustrates a problem of ill-conditioned
equations– Example: x+y = 10 and (1+) x + y = 10– A solution exists, but suffers from numerical problems for
small epsilon– As we will see later: this can cause pivots to become very
small in LU factorization, leading to inaccuracies under finite machine precision
Typical application to circuits
• Linearize elements one by one based on guess• Generate stamps for these linearized elements
– For the diode, this is the stamp for conductance ak and current source bk
– Combine with stamps for other (type 1 and type 2) elements
• Solve equations• Find values for next iterate and repeat until
convergence
Solving these equations
• Given a system of linear equations
A x = b (A: n x n; x,b: n x 1)
Solve for x• Simple approaches
– Cramer’s rule - requires determinant computation: expensive– Gaussian elimination
• Perform row transformations on the A matrix to make it upper triangular
• Perform the same row transformations on the RHS vector b
• Solve upper triangular system
LU factorization: outline
• Perform LU decomposition– Write A = L . U
• L: lower triangular matrix
• U: upper triangular matrix
• A is written as a product of L and U
• A x = b becomes L U x = b• Substitute U x = y where y is an intermediate variable
(vector)• Solve L y = b (easy) to find y• Then solve U x = y to find x
Gaussian Elimination (GE)
• Step 1– Row2 – 1/3 Row1– Row3 – 1/3 Row1– In other words,
m21 = 1/3, m31 = 1/3
• Step 2– Row3 –1/4 Row2
– i.e., m32 = ¼
• Step 3: Backward sub.– x3 = x2 = x1 = 1
5
5
5
311
131
113
3
2
1
x
x
x
3/10
3/10
5
3/83/20
3/23/80
113
3
2
1
x
x
x
2/5
3/10
5
2/500
3/23/80
113
3
2
1
x
x
x
GE in general
• Given A x = b, or
• Convert to
U x = y, i.e.,
where i.e.,
nnnnnn
n
n
b
b
b
x
x
x
aaa
aaa
aaa
2
1
2
1
21
22221
11211
'
'2
'1
2
1
222
11211
00
0
nnnn
n
n
b
b
b
x
x
x
u
uu
uuu
'11,
'22
'11
'
'232
'1313
'3
'1212
'2
1'1
nnnnnnn bmbmbmbb
bmbmbb
bmbb
bb
nnnnn b
b
b
b
x
x
x
x
mmm
mm
m
3
2
1
3
2
1
321
3231
21
1
01
001
0001
(L y = b)
Relation to LU factorization
• Perform LU decomposition– Write A = L . U
• L: lower triangular matrix• U: upper triangular matrix• A is written as a product of L and U
• A x = b becomes L U x = b• Substitute U x = y where y is an intermediate
variable (vector)• Solve L y = b (easy) to find y• Then solve U x = y to find x• Previous slide tells us how to find L, U !!
Versions of LU factorization
• Gauss– Store multipliers in L, find U– 1’s on the diagonals of L
– While processing multipliers mk*, update as
(k,k)
Updated
submatrix
Computational cost
• An update at (k,k) involves a constant number of arithmetic operations on (n – k)(n – k + 1) elements
• Cost k=1 to n-1 (n – k)(n – k + 1) = O(n3)
Other versions of LU
• Same operations in a different order– Doolittle: 1’s on diagonal of L– Crout: 1’s on diagonal of U
• Order of operations: while processing (k,k)
(k,k)
Updated entries(L, U stored in thesame matrix here)
Doolittle
(k,k)
1
1,,1,;
k
ppjkpkjkj nkkjulau
nkkiu
ula
lkk
k
ppkipik
ik ,,1,;
1
1
(Need to calculate ukj values before lik values – ukk required for lik)
Complexity: same as Gauss (same operations, different order)
Crout: similar update formulae
Pivoting
• Cannot find m32 – divide by 0• Does not mean solution does not exist• Can overcome by reordering rows 2 and 3 to get a
nonzero on the diagonal – pivoting• (Coincidentally, in this case, that also means that
GE is over!)
5
6
5
311
213
113
3
2
1
x
x
x
5
6
5
3/83/20
100
113
3
2
1
x
x
x
m21 = 1
m31 = 1/3
Sparsity
• Consider a matrix structure– x implies non-zero element
• After LU factorization, get– All sparsity lost– Many fill-in’s (0 x)
• Can use pivoting to reduce fill-in’s
xx
xx
xx
xxxx
00
00
00
xxxx
xxxx
xxxx
xxxx
When is a fill-in created?
• Computations during LU factorization
• Fill-in created if is a zero and any one pair of are both nonzeros
(k,k)
Pivoting for sparsity - example
• Reorder the matrix– Row 1 Row 4– Column 1 Column 4
becomes
– LU factors have the structure
xx
xx
xx
xxxx
00
00
00
xxxx
xx
xx
xx
00
00
00
xxxx
xx
xx
xx
00
00
00
xx
xx
xx
xxxx
00
00
00
Iterative solution of linear equations
• For a system of equations
• For an initial guess x1(0), …, xn
(0), can write
(Gauss-Jacobi) (Gauss-Seidel)
nnnnnn
nn
bxaxaxa
bxaxaxa
2211
11212111
nnnnnnnn
nn
nn
axaxabx
axaxaxabx
axaxabx
/
/
/
)0(11,
)0(11
)1(
22)0(
2)0(
323)0(
1212)1(
2
11)0(
1)0(
2121)1(
1
nnnnnnnn
nn
nn
axaxabx
axaxaxabx
axaxabx
/
/
/
)1(11,
)1(11
)1(
22)0(
2)0(
323)1(
1212)1(
2
11)0(
1)0(
2121)1(
1
In matrix form
• Write A = L + D + U– L: lower matrix; U: upper matrix; D: diagonal matrix
• G-J: (L+D+U) x = bimplies D x(k+1) = b – (L+U) x(k)
i.e., x(k+1) = D-1 b – D-1 (L+U) x(k)
• G-S (L+D) x(k+1) = b – U x(k)
i.e., x(k+1) = (L+D)-1 b – (L+D)-1 U x(k)
• For both, the update formula has the formx(k+1) = M x(k) + c
Convergence of Iterative Methods
x(k+1) = M x(k) + cconverges when x(k+1) = x(k) = x*, i.e., when x* = (I – M)-1 c• Progress of iterations:
– x(1) = M x(0) + c– x(2) = M x(1) + c = M2 x(0) + (M+I) c– x(3) = M x(2) + c = M3 x(0) + (M2+M+I) c– :– x(k) = M x(k-1) + c = Mk x(0) + (Mk-1+…+M+I) c
• x(k) converges to x* for large k if – Mk 0 – (Mk-1+…+M+I) (I-M)-1
Convergence (Contd.)
• This happens if (M) < 1 where (M) is the spectral radius of M (M) is defined as the magnitude of the largest eigenvalue of
M– In reality can have convergence if max eigenvalue
magnitude is 1 and the eigenvalue is simple (i.e., not a multiple root of the characteristic equation)
Back to circuit equations..
• Diagonal dominance of a matrix A
|akk| j=1 to n, j k |akj|
• Diagonal dominance with at least one inequality being strict for a connected circuit implies positive definiteness of A– Resistive circuits with current sources and at least one
resistance to ground satisfy this.
Transient analysis
• Requires the solution of differential equations• Elements such as capacitors
– I = C dV/dt : C is constant for a linear capacitor, can be a function of voltage for a nonlinear capacitor
– V = L dI/dt : L is constant for a linear inductor, can be a function of current for a nonlinear inductor
• First consider the basic problem of solving a differential equation
Intuitive way of numerically solving a differential equation
• Consider dx/dt = f(x); x(t=0) = x0
– Start an x vs. t plot from given initial value x(t=0) = x0
– Derivative at x0 is f(x0)– In the plot, find x1 at time t=h based on a linear extrapolation using
the derivative – thjs is reasonable if h is small– Having obtained x1, find derivative at t=h as f(x1); extrapolate
linearly to get x2 and so on.
• Update formula– x(t+(n+1)h) = x(t+nh) + h [dx/dt](t+nh)– Or using simpler notation,
xn+1 = xn + h dxn/dt – Basically, all this says is dxn/dt = (xn+1-xn)/h!
• This is the Forward Euler method0 h 2h 3h t
x
A few simple numerical integration methods
• Forward Euler method:
xn+1 = xn + h dxn/dt • Backward Euler method:
xn+1 = xn + h dxn+1/dt • Trapezoidal rule
xn+1 = xn + h/2 (dxn/dt + dxn+1/dt)• These are all based on local linear approximations• Can also use more derivatives and get formulas
based on approximations that are locally quadratic, cubic, etc.
Numerical Stability
• Test equation: dx/dt = x, x(t=0) = x0
• Behavior of this equation:– If > 0, x as t (real systems don’t do this!)
– If = 0, x = x0 for all t
– If < 0, x 0 as t – (The last two are the meaningful regions)
• Necessary condition for any numerical integration formula: must satisfy the above limiting conditions. This is a criterion for stability of the formula.
• (Other definitions of stability also exist)
Numerical Stability: Forward Euler
• Test equation: dx/dt = x, x(t=0) = x0
• FE: – xn+1 = xn + h dxn/dt, i.e., xn+1 = xn + h xn = (1+ h ) xn
• For a constant time step h,– x1 = (1+ h ) x0
– x2 = (1+ h ) x1 = (1+ h )2 x0
– x3 = (1+ h ) x2 = (1+ h )3 x0
– :– xk = (1+ h )k x0
• As t , k and xk must satisfy stability conditions
FE stability (contd.)
• FE formula for test equation: xk = (1+ h )k x0
• Possible values of – If > 0, xk as k provided |1+ h | > 1 (always true)
– If = 0, xk = x0 for all t
– If < 0, xk 0 as k provided |1+ h | < 1
• This is true provided –1 < 1+ h < 1, i.e., if h < 2/||
• In other words, there is an upper bound on the maximum step size in the physically meaningful region!
– Region of stabilityh plane
(-1,0)
Radius = 1
• BE: xn+1 = xn + h dxn+1/dt, i.e., xn+1 = xn + h xn+1, i.e., xn+1 = xn/(1-h)
– x1 = x0 /(1-h); x2 = x1 /(1-h) = x0/(1-h)2; …xk = x0/(1-h)k
• Stability:– If > 0, xk as k provided |1- h| < 1
• This is true provided –1 < 1 - h < 1, i.e., if h < 2/• Here, the upper bound on the maximum step size in the physically non-
meaningful region!
– If = 0, xk = x0 for all t– If < 0, xk 0 as k provided |1-h | > 1 (always true)
• Region of stability
• Conclusion: BE is a better formula for physical systems
Backward Euler stability
h plane
(1,0)
Radius = 1
• TR: xn+1 = xn + h/2 (dxn/dt + dxn+1/dt), i.e., xn+1 = xn + h/2 (xn + xn+1)
– i.e., xn+1 = xn (1+h/2) /(1-h/2)
– Can infer that xk = x0 [(1+h/2)/(1-h/2)]k
• Stability:– If > 0, xk as k provided |(1+h/2)/(1- h/2)| > 1
• Always true!
– If = 0, xk = x0 for all t
– If < 0, xk 0 as k provided |(1+h/2)/(1- h/2)| < 1
• Always true!
• Region of stability– Entire h plane!
• WARNING!! Stability guaranteed, not accuracy!
Trapezoidal rule stability
h plane
Stability and accuracy
• Stability is a necessary but not sufficient condition• Need accuracy too!• If h is chosen so that h = -4 then
– xk = x0 [(1+h/2)/(1-h/2)]k = x0 (-1/3)k
– Oscillates between position and negative values – not true for the actual solution!
• Similarly h = 2 means that the solution shoots to infinity at the first time step
Linear multistep formulae
• Try to fit a kth order polynomial– FE/BE fit a linear function and are order 1 LMS formulae– For dx/dt = f(x), require k values of function f or derivative
df/dx at previous time points
• Explicit formulae (e.g., FE)– Evaluation of xn+1 does not depend on dxn+1/dt
• Implicit formulae (e.g., BE, TR)– Evaluation of xn+1 depends on dxn+1/dt
• No details in this class – for further reference, see Chua and Lin’s book
Gear’s formulae
• LMS formulae that belong to the family
xn+1 = (j=1 to k j xn-j ) + h dxn/dt
(the above is a kth order Gear’s formula)• Specific formulae
– First order (=BE):xn+1 = xn + h dxn+1/dt
– Second order:xn+1 = 4/3 xn – 1/3 xn-1 + 2/3 h dxn+1/dt
– Third order:xn+1 = 18/11 xn – 9/11 xn-1 + 2/11 xn-2 + 6/11 h dxn+1/dt
• Good stability properties (“stiffly stable”) and used for circuit simulation applications
Application to circuit elements
• Capacitor– I = C dV/dt
– Work instead with charge: q = C V
(better formulation for nonlinear caps)
– Objective: to find a “companion model” converting a differential equation to a linear equation (perhaps going through a nonlinear equation on the way)
• Forward Euler– qn+1 = qn + h dqn/dt (CV)n+1 = (CV)n + h In
– Linear capacitor: C is constant, so that Vn+1 = Vn + h/C In
– Since Vn+1 is the unknown, can rewrite as V = Vn + h/C In
– Capacitor is replaced by a constant voltage source at this time step!
Problem with forward Euler
• Loop of capacitors becomes a loop of V sources
• No guarantee that KVL will hold around the loop– (There are some ways of getting around this)
• This, plus stability problems, imply that FE is not used in circuit simulation
• Also: possible numerical problems if C is very small• In general: avoid the use of any explicit formula
+V1
-
+V3
-
+ V2 -
Backward Euler – Companion models
• Linear capacitor– qn+1 = qn + h dqn+1/dt (CV)n+1 = (CV)n + h In+1
– Linear capacitor: C is constant, so that
(C/h)Vn+1 = (C/h) Vn + In+1
– Since Vn+1, In+1 are unknowns, can rewrite as
I = (C/h) V – (C/h) Vn
– Capacitor is replaced by a type 1 element: constant current source in parallel with a conductance - at this time step!
• Linear inductor: work with flux = LI; V = d/dt n+1 = n + h dn+1/dt (LI)n+1= (LI)n + h Vn+1
V = L/h I – L/h In
– Resistance in series with a voltage sourceResistance L/h - L/h In +
Choice of timestep and LTE
• LTE = Local truncation error
• FE/BE can be thought of as truncated Taylor series– xn+1 = xn + h dxn/dt + h2/2 d2xn/dt2 + higher order terms
– Truncation error = h2/2! d2xn/dt2 + higher order terms, which is approximated as h2/2! d2xn/dt2
• Choose a time step so that LTE = h2/2 d2xn/dt2 <
i.e., h < sqrt(2/xn”)
xn” is estimated by divided differences
• For BE,LTE = h2/2 d2xn+1/dt2 < h < sqrt(2/xn+1”)
(Can use FE to estimate xn+1” and then apply divided differences)
The direct method
• Finds the sensitivity of all responses to a single parameter change
• System equation (e.g., MNA): A x = b• Perturbation: A A + A ; b b + b
– x x + x
• After perturbation– (A + A)(x + x) = (b + b)
– Substituting A x = b and neglecting products of terms, we get
A x = b - A x
– Solve this system of equations to get the sensitivity change of all parameters x wrt a single parameter perturbation
• Same LHS as the original system; LU factors available
Adjoint sensitivities: Tellegen’s theorem
• Finds the sensitivity of a single response to all parameter changes
• For any pair of circuits with the same topology (i.e., incidence matrix)
(branch_voltage_vector)^T (branch_current_vector) = 0
• Consider three circuits with the same topology
– Circuits 1 and 3: VT = 0; TI = 0• [Also, T = VT I = 0 – conservation of power]
– Circuits 2 and 3: T (V + V) = 0; T(I + I) = 0– Combining the two, TV = 0 and TI = 0– Subtracting the second equation from the first,
(TV - TI) = 0, i.e., all branches (j Vj - j Ij ) = 0
Circuit 1The original circuitVoltage = VCurrent = I
Circuit 2The perturbed circuitVoltage = V + VCurrent = I + I
Circuit 3The adjoint circuit(to be defined)Voltage = Current =
Perturbations in circuits
• Consider circuits with R, V, J only
• Rewrite all branches (j Vj - j Ij ) = 0 as
R(j Vj - j Ij) + V(j Vj - j Ij) + J (j Vj - j Ij) = 0
• Perturbations:– Increase the value of a voltage source to vj vj + vj
Vj = vj ; Ij is determined by the rest of the circuit
– Increase the value of a current source Jj Jj + Jj
Ij = Jj ; Vj is determined by the rest of the circuit
– Increase the value of a resistor Rj Rj + Rj
Vj = IjR
(Vj+Vj) = (Ij+Ij)(R Rj)
Therefore (neglecting products of terms)
Vj = Ij Rj + Rj Ij
Perturbations (contd.)
• Therefore, for a resistor,
R(j Vj - j Ij ) = R(j Ij Rj + j Rj Ij - j Ij )
• At this point, we have no specs on the adjoint circuit but its topology: we are free to choose the - relations as we want– Choose j = j Rj
– Why? • This cancels out the last two terms with circuit-dependent Ij terms
R(j Vj - j Ij ) = R(j Ij Rj + j Rj Ij - j Ij ) = Rj Ij Rj
• This term now depends only on the perturbation, not on the circuit
Adjoint sensitivity computation
R(j Vj - j Ij) + V(j Vj - j Ij) + J (j Vj - j Ij) = 0
Rewrite as
V j Ij - J j Vj = R j Ij Rj + V j Vj + J j Ij
• LHS contains terms corresponding to circuit-determined variations
• RHS contains terms corresponding to parameter variations
– To find sensitivities of voltages with respect to parameters• Set j = 0; x = -1 for the voltage of interest, 0 for all others
Vx = R j Ij Rj + V j Vj + J j Ij
Vx/Rj = j Ij ; Vx/Vj = j ; Vx/Ij = j
Adjoint sensitivities
• To find sensitivities of currents with respect to multiple parameters– Set x = 1 for the current of interest, 0 for all others; j = 0
Ix = R j Ij Rj + V j Vj + J j Ij
Ix/Rj = j Ij ; Ix/Vj = j ; Ix/Ij = j
• In general: to find sensitivities of f(Vx,Ix) with respect to multiple parameters f = f/Ix Ix + f/Vx Vx
– Compare with LHS of
V j Ij - J j Vj = R j Ij Rj + V j Vj + J j Ij
– Set x = f/Ix ; j = 0 for all others,
x = - f/Vx j = 0 for all others
f/Rj = j Ij ; f/Vj = j ; f/Ij = j
Example: Adjoint sensitivity computation
• Response of interest: voltage Vx
Original circuit Modified circuit
Adjoint circuit for Vx sensitivity = 0 for all voltage sources
x = -1 for the current source related to Vx ; 0 else
Solve adjoint circuit for all branch ,
Vx = R j Ij Rj + V j Vj + J Ij
Vx/Rj = j Ij ; Vx/Vj = j ; Vx/Ij = j
[Pillage, Rohrer and Visweswariah}
R3
V=1R2R1
VxV1
gnd
R3
V=1R2R1
VxV1
gnd
I = 0
R3
=0R2R1
x 1
gnd
= -1
Add a fake current source (open ckt) since the response must be V across a current source (or I through a V source)
Transient adjoint sensitivities
• So far, all discussions on linear/linearized nonlinear elements
• Handling circuits with capacitors (for example)
• Starting point: integrate all branches (j Vj - j Ij ) = 0
Transient sensitivity (contd.)
T
0
jjjjjj
T
0jj
T
0
jj
T
0jj
T
0
jj
b
a
b
a
b
a
T
0
jjjjjj
jjjcj
capacitors all
T
0
jjjj
dt ))CδC(ψδCV)(ψ(t))(()CδC(ψ-
becomes integral entire The
dt)CδC(ψ)CδC(ψdt V)Cδ(ψ
dt vdt dt
du -vdt u uvdt partsby Integrate
dt (t))V)Cδ(ψ(t)δtV)(ψ(t))((
becomes termsummation Each
VCδδCV(t)δIVC(t)I
dt (t)))(ψ(t))((
Numerous minor notational errors in this slide – struggles with MS Equation Editor.Please see the handout on the web page for correct info.
Transient sensitivity (contd.)
)t-(t(t)V fselect ,C
)(tV LHSget To
dt (t)V)(ψdt C
f
interest of for V, I, select the circuit toadjoint in the sources voltagecurrent, Choose
above defined as is where0)0(ψ ),(Cψ)(byselection temporary theReplace
-dt)d (i.e.,t Tset Now ?capacitor? Negative
dt (t)δtV)(ψ
becomes integral The
0] voltageinitial with circuit,adjoint in thecapacitor negative"" a is [This
0)0(ψ ),(Cψ-)(select ly)(Temporari
cxcx
T
0
jj
T
0
jjj
T
0
jj
jjj
Numerous minor notational errors in this slide – struggles with MS Equation Editor.Please see the handout on the web page for correct info.