Professional Documents
Culture Documents
Numerical methods for ordinary differential equations are methods used to find
numerical approximations to the solutions of ordinary differential equations (ODEs).
Many differential equations cannot be solved using symbolic computation
("analysis"). For practical purposes, however – such as in engineering – a numeric
approximation to the solution is often sufficient. The algorithms studied here can be
used to compute such an approximation.
where f is a function that maps [t0,∞) × Rd to Rd, and the initial condition y0 ∈ Rd
is a given vector. First-order means that only the first derivative of y appears in the
equation, and higher derivatives are absent. Without loss of generality to higher-
order systems, we restrict ourselves to first-order differential equations, because a
higher-order ODE can be converted into a larger system of first-order equations by
introducing extra variables. For example, the second-order equation y'' = −y can
be rewritten as two first-order equations: y' = z and z' = −y.
From any point on a curve, you can find an approximation of a nearby point on the
curve by moving a short distance along a line tangent to the curve. Starting with
the differential equation (1), we replace the derivative y' by the finite difference
approximation
This formula is usually applied in the following way. We choose a step size h, and
we construct the sequence t0, t1 = t0 + h, t2 = t0 + 2h, … We denote by yn a
numerical estimate of the exact solution y(tn). Motivated by (3), we compute these
estimates by the following recursive scheme
www.ravivarmans.com Page 1 of 15
Digital Control of Power Electronic And Drives Systems Unit I
by way of Heun's method, is to first calculate the intermediate yi 1 value and then
the final approximation yi 1 at the next integration point.
1
Finally calculate, k k1 2k2 2k3 k4
6
Which gives approximate value of y as
y1 = y0 + k
Here yn+1 is the RK4 approximation of y(tn+1), and the next value (yn+1) is
determined by the present value (yn) plus the weighted average of four increments,
www.ravivarmans.com Page 2 of 15
Digital Control of Power Electronic And Drives Systems Unit I
where each increment is the product of the size of the interval, h, and an estimated
slope specified by function f on the right-hand side of the differential equation.
k1 is the increment based on the slope at the beginning of the interval, using y
(Euler's method);
k2 is the increment based on the slope at the midpoint of the interval, using y
and k1;
k3 is again the increment based on the slope at the midpoint, but now using y
and k2;
k4 is the increment based on the slope at the end of the interval, using y and k3.
The RK4 method is a fourth-order method, meaning that the local truncation error
is on the order of O(h5), while the total accumulated error is on the order of O(h4).
In many practical applications the function f is independent of y (so called
autonomous system, or time-invariant system), and their increments are not
computed at all and not passed to function f, with only the final formula for tn+1
used.
Starting at (x0, y0, z0) and taking the step-sizes for x, y, z to be h, k, l respectively,
and the Runge-Kutta method gives
www.ravivarmans.com Page 3 of 15
Digital Control of Power Electronic And Drives Systems Unit I
Example
Find the first three approximations y1, y2, y3 using Euler’s method for the initial
value problem. y′ = 1+y, y(0) = 1, starting at x0 = 0 with h = 0.1.
Solution:
ƒ(x, y) = 1 + y
We have the starting values x0 = 0 and y0 = 1. Next we determine the values of x
at which the Euler approximations will take place: x1 = x0 + h = 0.1,
x2 = x0 + 2h = 0.2, and x3 = x0 +3h = 0.3. Then we find
First: y1 = y0 + h ƒ(x0, y0)
= y0 + h (1 + y0) = 1 + (0.1) (1 + 1) = 1.2
Second: y2 = y1 + h ƒ(x1, y1)
= y1 + h (1 + y1) = 1.2 + (0.1) (1 + 1.2) = 1.42
Third: y3 = y2 +h ƒ(x2, y2)
= y2 + h (1 + y2) = 1.42 + (0.1) (1 + 1.42) = 1.662
The step-by-step process used in Example can be continued easily. Using equally
spaced values for the independent variable in the table for the numerical solution,
and generating n of them, set
x1 = x0 + h x2 = x1 + h ... xn = xn-1 + h.
Then calculate the approximations to the solution,
y1 = y0 + h ƒ(x0, y0)
y2 = y1 + h ƒ(x1, y1)
.
.
.
yn = yn-1 + h ƒ(xn-1, yn-1).
The number of steps n can be as large as we like.
Example
Function: y′=f(x,y) = y′=f(t,y) = 3x+y
Step size, h = 0.1
Initial condition, y(1) = 1
Calculate y(1.3) using Heun’s (improved Euler) method.
Solution:
The improved Euler method states that yn+1 = yn + (h/2) [f(xn,yn) + f(xn+1,ỹn+1)],
where ỹn+1 = yn + h⋅ f(xn,yn) and xn+1 = xn + h.
We have that h = 0.1, x0=1, y0=1, f(x,y)=3x+y
Step 1.
x1 = x0 + h = 1+0.1 = 1.1
ỹ1 = y0 + h⋅f(x0,y0) = 1 + h⋅f(1,1) = (1)+(0.1)⋅(4) = 1.4
www.ravivarmans.com Page 4 of 15
Digital Control of Power Electronic And Drives Systems Unit I
Example
Using Runge-Kutta method solve y’’ = xy’2 – y2 for x = 0.2 correct to 4 decimal
places. Initial conditions are x = 0, y = 1, y’ = 0.
Solution
Given equation of second order is
www.ravivarmans.com Page 5 of 15
Digital Control of Power Electronic And Drives Systems Unit I
1.2.1 RL Circuit
Consider a first-order circuit containing only one inductor. The diagram in Figure
represents an electrical circuit whose total resistance is a constant R ohm and whose
self-inductance, shown as a coil, is L henry, also a constant. There is a switch whose
terminals can be closed to connect a constant electrical source of V volt.
By solving this equation, we can predict how the current will flow after the switch
is closed.
www.ravivarmans.com Page 6 of 15
Digital Control of Power Electronic And Drives Systems Unit I
V t
R
20 t
24
i t 1 e 1 e 4 0.83333 1 e 6t
L
R 24
www.ravivarmans.com Page 7 of 15
Digital Control of Power Electronic And Drives Systems Unit I
The transient curves of the ODE solution and analytical solution is given below.
1.2.2 RC Circuit
Let us consider a simple series RC - circuit shown in figure is connected through a
switch ‘S’ to a constant voltage source V.
The switch ‘S’ is closed at time, t = 0. It is assumed that the capacitor is initially
not charged, vc(0) = 0 and the current flowing through the circuit at any instant of
time ‘t ’ after closing the switch is i(t).
The KVL equation around the loop can be written as
www.ravivarmans.com Page 8 of 15
Digital Control of Power Electronic And Drives Systems Unit I
y(n+1) =
y(n)+(h/6)*(k1
n x(n) y(n) k1 k2 k3 k4
+ 2*k2 + 2*k3
+ k4)
0 0 0 2 1.6 1.68 1.328 3.296
1 2 3.296 1.3408 1.07264 1.126272 0.890291 5.5056384
2 4 5.505638 0.898872 0.719098 0.755053 0.596851 6.986979983
3 6 6.98698 0.602604 0.482083 0.506187 0.400129 7.980071381
4 8 7.980071 0.403986 0.323189 0.339348 0.268247 8.645839854
5 10 8.64584 0.270832 0.216666 0.227499 0.179832 9.092171038
6 12 9.092171 0.181566 0.145253 0.152515 0.12056 9.391391464
7 14 9.391391 0.121722 0.097377 0.102246 0.080823 9.591988837
8 16 9.591989 0.081602 0.065282 0.068546 0.054184 9.726469317
9 18 9.726469 0.054706 0.043765 0.045953 0.036325 9.81662503
10 20 9.816625 0.036675 0.02934 0.030807 0.024352 9.87706542
11 22 9.877065 0.024587 0.01967 0.020653 0.016326 9.917584658
12 24 9.917585 0.016483 0.013186 0.013846 0.010945 9.944748754
13 26 9.944749 0.01105 0.00884 0.009282 0.007337 9.962959565
14 28 9.96296 0.007408 0.005926 0.006223 0.004919 9.975168092
15 30 9.975168 0.004966 0.003973 0.004172 0.003298 9.983352689
16 32 9.983353 0.003329 0.002664 0.002797 0.002211 9.988839643
17 34 9.98884 0.002232 0.001786 0.001875 0.001482 9.992518097
18 36 9.992518 0.001496 0.001197 0.001257 0.000994 9.994984132
19 38 9.994984 0.001003 0.000803 0.000843 0.000666 9.996637362
20 40 9.996637 0.000673 0.000538 0.000565 0.000447 9.997745688
10 1 e 10 1 e
vc t V 1 e RC 5 0.2 t
www.ravivarmans.com Page 9 of 15
Digital Control of Power Electronic And Drives Systems Unit I
Substituting the current, i(t) expression in loop equation and rearranging the terms,
The above equation is a 2nd-order linear differential equation and the parameters
associated with the differential equation are constant with time.
In the case of the series RLC circuit, the damping factor is given by,
R C
2 L
The value of damping factor determines the type of transient that the circuit will
exhibit.
If,
ζ > 1, the system is called over damped.
ζ = 1, the system is called critically damped.
ζ < 1, the system is called under damped.
By using RK4 method, the values of capacitor voltage vc(t) are calculated.
dy
Let, y vc t ; z f1 t , y , z
dt
www.ravivarmans.com Page 10 of 15
Digital Control of Power Electronic And Drives Systems Unit I
dz dy
LC RC y VS
dt dt
dz 1 R V
y z S f 2 t , y, z
dt LC L LC
Assume zero initial conditions, x0 = 0, y0 = 0 and z0 = 0. Step value = 5
We compute k1, k2, k3, k4 for f1(t, y, z) and l1, l2, l3, l4 for f2(t, y, z).
Assume Vs = 10V, R = 10Ω, L = 50H, C = 0.4F
R C
Damping factor, 0.4 . The given system is underdamped.
2 L
n t k1 k2 k3 k4 k l1 l2 l3 l4 l y y' = z
0 0 0.0000 6.2500 3.1250 5.4688 4.0365 2.5000 1.2500 1.0938 0.6250 1.3021 0.0000 0.0000
1 5 6.5104 6.9824 4.7119 4.8889 5.7980 0.1888 -0.7194 -0.3243 -0.6649 -0.4272 4.0365 1.3021
2 10 4.3742 2.2906 1.9654 1.1841 2.3450 -0.8335 -0.9635 -0.6380 -0.6868 -0.7872 9.8345 0.8748
3 15 0.4381 -1.1431 -0.4894 -1.0824 -0.6516 -0.6325 -0.3710 -0.3041 -0.2060 -0.3648 12.1795 0.0876
4 20 -1.3859 -1.6479 -1.0838 -1.1821 -1.3385 -0.1048 0.1208 0.0408 0.1254 0.0573 11.5279 -0.2772
5 25 -1.0994 -0.6681 -0.5402 -0.3784 -0.6491 0.1725 0.2237 0.1442 0.1634 0.1786 10.1894 -0.2199
6 30 -0.2063 0.1841 0.0534 0.1998 0.0781 0.1562 0.1039 0.0812 0.0616 0.0980 9.5403 -0.0413
7 35 0.2837 0.3803 0.2434 0.2796 0.3018 0.0387 -0.0161 -0.0008 -0.0214 -0.0028 9.6184 0.0567
8 40 0.2699 0.1848 0.1430 0.1111 0.1728 -0.0340 -0.0507 -0.0317 -0.0380 -0.0395 9.9202 0.0540
9 45 0.0723 -0.0219 0.0026 -0.0327 0.0002 -0.0377 -0.0279 -0.0210 -0.0173 -0.0255 10.0930 0.0145
10 50 -0.0551 -0.0857 -0.0532 -0.0647 -0.0663 -0.0123 0.0007 -0.0019 0.0030 -0.0019 10.0931 -0.0110
11 55 -0.0648 -0.0492 -0.0367 -0.0309 -0.0446 0.0062 0.0112 0.0068 0.0086 0.0085 10.0269 -0.0130
12 60 -0.0224 -0.0001 -0.0043 0.0041 -0.0045 0.0089 0.0072 0.0053 0.0047 0.0064 9.9823 -0.0045
13 65 0.0098 0.0188 0.0113 0.0146 0.0141 0.0036 0.0006 0.0010 -0.0002 0.0011 9.9778 0.0020
14 70 0.0152 0.0127 0.0092 0.0082 0.0112 -0.0010 -0.0024 -0.0014 -0.0019 -0.0018 9.9919 0.0030
15 75 0.0064 0.0013 0.0019 -0.0001 0.0021 -0.0021 -0.0018 -0.0013 -0.0012 -0.0016 10.0031 0.0013
16 80 -0.0015 -0.0040 -0.0023 -0.0032 -0.0029 -0.0010 -0.0003 -0.0003 -0.0001 -0.0004 10.0052 -0.0003
www.ravivarmans.com Page 11 of 15
Digital Control of Power Electronic And Drives Systems Unit I
n t k1 k2 k3 k4 k l1 l2 l3 l4 l y y' = z
0 0 0.0000 6.2500 -0.750 10.273 3.5456 2.5000 -0.300 2.0548 -1.915 0.6824 0.0000 0.0000
1 5 3.4120 3.6245 2.3202 4.0173 3.2198 0.0850 -0.436 0.1211 -0.766 -0.218 3.5456 0.6824
2 10 2.3183 1.7434 1.6628 1.5472 1.7796 -0.229 -0.262 -0.154 -0.300 -0.227 6.7654 0.4637
3 15 1.1825 0.7674 0.8628 0.5889 0.8386 -0.166 -0.127 -0.118 -0.115 -0.129 8.5451 0.2365
4 20 0.5366 0.3208 0.3948 0.2221 0.3650 -0.086 -0.056 -0.062 -0.044 -0.061 9.3837 0.1073
5 25 0.2285 0.1296 0.1690 0.0831 0.1515 -0.039 -0.023 -0.029 -0.016 -0.027 9.7487 0.0457
6 30 0.0935 0.0512 0.0694 0.0309 0.0609 -0.016 -0.009 -0.012 -0.006 -0.011 9.9002 0.0187
7 35 0.0372 0.0198 0.0277 0.0114 0.0240 -0.007 -0.003 -0.005 -0.002 -0.004 9.9611 0.0074
8 40 0.0145 0.0076 0.0108 0.0042 0.0093 -0.002 -0.001 -0.002 -0.000 -0.001 9.9851 0.0029
9 45 0.0056 0.0029 0.0042 0.0015 0.0035 -0.001 -0.000 -0.000 -0.000 -0.000 9.9943 0.0011
10 50 0.0021 0.0011 0.0016 0.0006 0.0013 -0.000 -0.000 -0.000 -0.000 -0.000 9.9979 0.0004
11 55 0.0008 0.0004 0.0006 0.0002 0.0005 -0.000 -0.000 -0.000 0.0000 -0.000 9.9992 0.0002
12 60 0.0003 0.0001 0.0002 0.0001 0.0002 -0.000 0.0000 0.0000 0.0000 0.0000 9.9997 0.0001
13 65 0.0001 0.0001 0.0001 0.0000 0.0001 0.0000 0.0000 0.0000 0.0000 0.0000 9.9999 0.0000
14 70 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 10.000 0.0000
15 75 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 10.000 0.0000
16 80 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 10.000 0.0000
www.ravivarmans.com Page 12 of 15
Digital Control of Power Electronic And Drives Systems Unit I
n t k1 k2 k3 k4 k l1 l2 l3 l4 l y y' = z
0 0 0.0000 1.5625 -0.3906 3.8574 1.0335 1.2500 -0.3125 1.5430 -2.5586 0.1921 0.0000 0.0000
1 2.5 0.4801 1.2810 0.2424 2.4760 1.0005 0.6407 -0.1902 0.7983 -1.3854 0.0786 1.0335 0.1921
2 5 0.6766 1.0755 0.5240 1.6879 0.9273 0.3191 -0.1221 0.4045 -0.7576 0.0211 2.0340 0.2706
3 7.5 0.7293 0.9175 0.6252 1.2224 0.8395 0.1506 -0.0832 0.1973 -0.4207 -0.0070 2.9613 0.2917
4 10 0.7117 0.7907 0.6364 0.9345 0.7501 0.0632 -0.0603 0.0891 -0.2391 -0.0197 3.8008 0.2847
5 13 0.6624 0.6858 0.6048 0.7460 0.6650 0.0187 -0.0461 0.0334 -0.1405 -0.0245 4.5509 0.2650
6 15 0.6012 0.5972 0.5552 0.6150 0.5868 -0.0031 -0.0368 0.0055 -0.0863 -0.0253 5.2158 0.2405
7 18 0.5378 0.5214 0.4999 0.5182 0.5164 -0.0132 -0.0303 -0.0078 -0.0561 -0.0243 5.8026 0.2151
8 20 0.4772 0.4558 0.4452 0.4431 0.4538 -0.0171 -0.0256 -0.0136 -0.0387 -0.0224 6.3191 0.1909
9 23 0.4213 0.3989 0.3940 0.3825 0.3983 -0.0179 -0.0219 -0.0155 -0.0283 -0.0202 6.7728 0.1685
10 25 0.3709 0.3493 0.3473 0.3321 0.3494 -0.0173 -0.0189 -0.0155 -0.0219 -0.0180 7.1711 0.1484
.
.
.
30 75 0.0267 0.0249 0.0250 0.0234 0.0250 -0.0014 -0.0013 -0.0013 -0.0012 -0.0013 9.7979 0.0107
31 78 0.0234 0.0218 0.0219 0.0205 0.0219 -0.0012 -0.0012 -0.0012 -0.0011 -0.0012 9.8229 0.0093
32 80 0.0205 0.0191 0.0192 0.0179 0.0192 -0.0011 -0.0010 -0.0010 -0.0009 -0.0010 9.8448 0.0082
33 83 0.0180 0.0168 0.0168 0.0157 0.0168 -0.0009 -0.0009 -0.0009 -0.0008 -0.0009 9.8640 0.0072
34 85 0.0157 0.0147 0.0148 0.0138 0.0147 -0.0008 -0.0008 -0.0008 -0.0007 -0.0008 9.8808 0.0063
35 88 0.0138 0.0129 0.0129 0.0121 0.0129 -0.0007 -0.0007 -0.0007 -0.0006 -0.0007 9.8955 0.0055
36 90 0.0121 0.0113 0.0113 0.0106 0.0113 -0.0006 -0.0006 -0.0006 -0.0006 -0.0006 9.9084 0.0048
37 93 0.0106 0.0099 0.0099 0.0093 0.0099 -0.0006 -0.0005 -0.0005 -0.0005 -0.0005 9.9198 0.0042
38 95 0.0093 0.0087 0.0087 0.0081 0.0087 -0.0005 -0.0005 -0.0005 -0.0004 -0.0005 9.9297 0.0037
39 98 0.0081 0.0076 0.0076 0.0071 0.0076 -0.0004 -0.0004 -0.0004 -0.0004 -0.0004 9.9384 0.0033
40 100 0.0071 0.0067 0.0067 0.0062 0.0067 -0.0004 -0.0004 -0.0004 -0.0003 -0.0004 9.9460 0.0029
www.ravivarmans.com Page 13 of 15
Digital Control of Power Electronic And Drives Systems Unit I
By solving this equation, we can predict how the current will flow after the switch
is closed.
www.ravivarmans.com Page 14 of 15
Digital Control of Power Electronic And Drives Systems Unit I
www.ravivarmans.com Page 15 of 15