Lecture 2 Numeric Solution of Differential Equations
Lecture 2 Numeric Solution of Differential Equations
2
Power System Stability Terms
• Terms continue to evolve, but a good reference is [1]; image shows Figure 1
from this reference
[1] IEEE/CIGRE Joint Task Force on Stability Terms and Definitions, “Definitions and Classification of Power
System Stability,” IEEE Transactions Power Systems, May 2004, pp. 1387-1401 3
Physical Structure
Power System Components
4
Physical Structure
Power System Components
Mechanical System Electrical System
Stabilizer Load
Line
Exciter Relay Relay
Supply Pressure Speed Voltage Network Load
control control control Control control control
Fuel Furnace
Turbine Generator Network Loads
Source and Boiler
Machine Load
Fuel Steam Torque V, I P, Q Char.
Governor
5
Differential Algebraic Equations
• Many problems, including many in the power area, can
be formulated as a set of differential, algebraic
equations (DAE) of the form
x f (x, y )
0 g ( x, y )
8
Power System Application
• A typical power system application is to assume
the power flow solution represents an equilibrium
point
• Back solve to determine the initial state variables,
x(0)
• At some point a contingency occurs, perturbing the
state away from the equilibrium point
• Time domain simulation is used to determine
whether the system returns to the equilibrium point
9
Initial value Problem Examples
Example 1: Exponential Decay
A simple example with an analytic solution is
x x with x(0) x 0
This has a solution x(t) x 0et
Example 2: Mass-Spring System
k x gM Mx Dx
or
x 1 x2
1
x 2 k x1 g M D x2
M
10
Numerical Solution Methods
15
Euler’s Method Example 1
Consider the Exponential Decay Example
x x with x(0) x 0
This has a solution x(t) x 0e t
Since we know the solution we can compare the accuracy
of Euler's method for different time steps
16
Euler’s Method Example 1, cont’d
t xactual(t) x(t) Dt=0.1 x(t) Dt=0.05
0 10 10 10
0.1 9.048 9 9.02
0.2 8.187 8.10 8.15
0.3 7.408 7.29 7.35
… … … …
1.0 3.678 3.49 3.58
… … … …
2.0 1.353 1.22 1.29
17
Euler’s Method Example 2
Consider the equations describing the horizontal
position of a cart attached to a lossless spring:
x 1 x2
x 2 x1
Assuming initial conditions of x1(0) 1 and x 2 (0) 0,
the analytic solution is x1(t ) cos t.
18
Euler's Method Example 2, cont'd
Starting from the initial conditions at t =0 we next
calculate the value of x(t) at time t = 0.25.
x1 (0.25) x1 (0) 0.25 x2 (0) 1.0
x2 (0.25) x2 (0) 0.25 x1(0) 0.25
Then we continue on to the next time step, t = 0.50
x1 (0.50) x1 (0.25) 0.25 x2 (0.25)
1.0 0.25 (0.25) 0.9375
x2 (0.50) x2 (0.25) 0.25 x1(0.25)
0.25 0.25 (1.0) 0.50
19
Euler's Method Example 2, cont'd
t x1actual(t) x1(t) Dt=0.25
0 1 1
Since we
know from
0.25 0.9689 1 the exact
0.50 0.8776 0.9375 solution that
x1 is bounded
0.75 0.7317 0.8125
between
1.00 0.5403 0.6289 -1 and 1,
… … … clearly the
method is
10.0 -0.8391 -3.129
numerically
100.0 0.8623 -151,983 unstable
20
Euler's Method Example 2, cont'd
actual -0.8391
0.25 -3.129
0.10 -1.4088
0.01 -0.8823
0.001 -0.8423
21
Second Order Runge-Kutta Method
• Runge-Kutta methods improve on Euler's method by
evaluating f(x) at selected points over the time step
• Simplest method is the second order method in which
1
x t t x t k 1 k 2
2
where
k1 t f x t
k 2 t f x t k 1
23
RK2 Oscillating Cart
• Consider the same example from before the
position of a cart attached to a lossless spring.
Again, with initial conditions of x1(0) =1 and x2(0)
= 0, the analytic solution is x1(t) = cos(t)
x 1 x2
x 2 x1
0 0
• With Dt=0.25 k1 (0.25)
1
0.25
at t = 0
1 0 1
x(0) k1
0
0.25 0.25
24
RK2 Oscillating Cart
0.0625
k 2 (0.25) f x(0) k1
0.25
1 1 0.96875
x(0.25) k1 k 2
0
2 0.25
25
Comparison
• The below table compares the numeric and exact
solutions for x1(t) using the RK2 algorithm
time actual x1(t) x1(t) with RK2
Dt=0.25
0 1 1
0.25 0.9689 0.969
0.50 0.8776 0.876
0.75 0.7317 0.728
1.00 0.5403 0.533
10.0 -0.8391 -0.795
100.0 0.8623 1.072
26
Comparison of x1(10) for varying Dt
27
RK2 Versus Euler's
• RK2 requires twice the function evaluations per
iteration, but gives much better results
• With RK2 the error tends to vary with the cube of
the step size, compared with the square of the step
size for Euler's
• The smaller error allows for larger step sizes
compared to Eulers
28
Fourth Order Runge-Kutta
• Other Runge-Kutta algorithms are possible, including
the fourth order
1
x t t x t k 1 2k 2 2k 3 k 4
6
where
k1 t f x t
1
k 2 t f x t k 1
2
1
k 3 t f x t k 2
2
k 4 t f x t k 2
29
RK4 Oscillating Cart Example
• RK4 gives much better results, with error varying with
the time step to the fifth power
time actual x1(t) x1(t) with RK4
Dt=0.25
0 1 1
0.25 0.9689 0.9689
0.50 0.8776 0.8776
0.75 0.7317 0.7317
1.00 0.5403 0.5403
10.0 -0.8391 -0.8392
100.0 0.8623 0.8601
30
Multistep Methods
• Euler's and Runge-Kutta methods are single step
approaches, in that they only use information at
x(t) to determine its value at the next time step
• Multistep methods take advantage of the fact that
using we have information about previous time
steps x(t-Dt), x(t-2Dt), etc
• These methods can be explicit or implicit
(dependent on x(t+Dt) values; we'll just consider
the explicit Adams-Bashforth approach
31
Multistep Motivation
• In determining x(t+Dt) we could use a Taylor series
expansion about x(t)
t 2
x(t t ) x(t ) t x (t ) x(t ) O (t 3 )
2
t 2 f (x(t )) f ( x(t t ))
x(t t ) x(t ) t f (t ) O( t )
2 t
3 1
x(t t ) x(t ) t f x(t ) f x(t t ) O(t 3 )
2 2
33
Adams-Bashforth Versus
Runge-Kutta
• The key Adams-Bashforth advantage is the
approach only requires one function evaluation per
time step while the RK methods require multiple
evaluations
• A key disadvantage is when discontinuities are
encountered, such as with limit violations;
• Another method needs to be used until there are
sufficient past solutions
• They also have difficulties if variable time steps are
used
34
Numerical Instability
• All explicit methods can suffer from numerical
instability if the time step is not correctly chosen for
the problem eigenvalues
Values are scaled by the
time step; the shape
for RK2 has similar
dimensions but is closer
to a square. Key point
is to make sure the time
step is small enough
relative to the eigenvalues
38
Backward Euler Cart Example
• Returning to the cart example
0 1
x x(t ))
1 0
Then using backward Euler with t 0.25
1
1 1 0.25
x(t t ) I t A x(t ) x(t )
0.25 1
39
Backward Euler Cart Example
• Results with Dt = 0.25 and 0.05
time actual x1(t) with x1(t) with
x1(t) Dt=0.25 Dt=0.05
0 1 1 1
0.25 0.9689 0.9411 0.9629
0.50 0.8776 0.8304 0.8700
0.75 0.7317 0.6774 0.7185
1.00 0.5403 0.4935 0.5277
2.00 -0.416 -0.298 -0.3944
41
Trapezoidal Cart Example
• Results with Dt = 0.25, comparing between backward
Euler and trapezoidal
time actual Backward Trapezoidal
x1(t) Euler
0 1 1 1
0.25 0.9689 0.9411 0.9692
0.50 0.8776 0.8304 0.8788
0.75 0.7317 0.6774 0.7343
1.00 0.5403 0.4935 0.5446
2.00 -0.416 -0.298 -0.4067
42
Example Transient Stability Results
• Figure shows simulated generator frequencies after a
large generator outage contingency
43
Spatial Variation of Frequency
Response: EI Model
44
Electromagnetic Transients
• The modeling of very fast power system dynamics
(much less than one cycle) is known as electromagnetics
transients program (EMTP) analysis
– Covers issues such as lightning propagation and switching
surges
• Concept originally developed by Prof. Hermann
Dommel for his PhD in the 1960's (now emeritus at
Univ. British Columbia)
– After his PhD work Dr. Dommel worked at BPA where he was
joined by Scott Meyer in the early 1970's
– Alternative Transients Program (ATP) developed in response to
commercialization of the BPA code
45