Upload
ricardo-lufkin
View
220
Download
3
Tags:
Embed Size (px)
Citation preview
Chem 302 - Math 252
Chapter 6Differential Equations
Differential Equations
• Many problems in physical chemistry (eg. kinetics, dynamics, theoretical chemistry) require solution to a differential equation
• Many can not be solved analytically
• Deal only with first order ODE– Higher order equations can be reduced to a system of 1st order DE
2y k y
2z k y
y z
Differential Equations
• Simplest form y f x
dy f x dx
y f x dx
00
x
xy y f x dx
• Can integrate analytically or numerically (using techniques of Chapter 4)
Differential Equations
• General case ,y f x y
• Many simpler problems can be solved analytically
• Many involve ex
• However, in chemistry (physics & engineering) many problems have to be solved numerically (or approximately)
Picard Method ,y f x y
• Can not integrate exactly because integrand involves y
• Approximate iteratively by using approximations for y
,dy f x y dx ,y f x y dx
0
1 0 0,x
xy y f x y dx
0
2 0 1,x
xy y f x y dx
0
1 0 ,x
i ixy y f x y dx
• Continue to iterate until a desire level of accuracy is obtained in y
• Often gives a power series solution
Picard Method – Example 1 0,1y xy
0
1 0 0
0
212
1
1 1
1
x
x
x
y y xy dx
x dx
x x
• Continue to iterate until a desire level of accuracy is obtained in y
0
21
2 0 1
0
2 3 41 13 8
2
12
1
1 1
1
1
x
x
xx x
y y xy dx
x dx
x x x x
0
2 3 41 1 12 3 8
3 0 2
0
2 3 4 5 61 1 1 1 12 3 8 15 48
1
1 1 1
1
x
x
x
y y xy
x x x x
dx
x dx
x x x x x x
0
4 0 3
0
2 3 4 5 6 7 81 1 1 1 1 1 12 3 8 15
2 3 4 5 61 1 1 1 12 3 8 15 48
48 105 384
1
1 1 1
1
x
x
xx x x x x x
y y xy dx
x dx
x x x x x x x x
Picard 1.mws
Picard Method – Example 2 0,1
dyy
dt
0
1 0 0
0
,
1 1
1
t
t
t
y y f t y dt
dt
t
ty e
0
2 0 1
0
212
,
1 1
1
t
t
t
y y f t y dt
t dt
t t
0
3 0 2
2120
2 31 12 6
,
1 1
1
t
t
t
y y f t y dt
t t dt
t t t
0
4 0 3
2 31 12 60
2 3 41 1 12 6 24
,
1 1
1
t
t
t
y y f t y dt
t t t dt
t t t t
1!
0
nk
n kk
y t
Picard 2.mws
Euler Method 0 0, ,y f x y x y
• Assume linear between 2 consecutive points
• Between initial point and 1st (calculated) point
0 0
0 0
0 0
1 0 0 0
,
,
,
,
dyf x y
dxy
f x yxy f x y x
y y f x y x
1 ,i i i iy y f x y x
• User selects x
• Need to be careful - too big or too small can cause problems
Euler Method – Example
00,dC
kC Cdt
1 1
1 1 1 1,
1i i
i i i i it C
dCC C t C t kC C k t
dt
0kt
trueC C e
Euler 1.mwsAdobe Acrobat
Document euler_debug.txt euler_release.txt
Taylor Method• Based on Taylor expansion
0 0 0
0
2 32 3
0 0 0 02 3
00
1 1
2 3!
1
!
x x x
nn
nn x
df d f d ff x f x x x x x x x
dx dx dx
d fx x
n dx
2 31 11 , , ,2 3!i i i i i ii i x y x y x yy y y x y x y x
,
,, , ,, ,
,
,
i i
i i
i i i i i ii i i i
x y i i
x y i ix y x y x yx y x y
y f x y
f f dy f fy f x y
x y dx x y
Use chain rule
Euler method is Taylor method of order 1
Taylor Method – Example 00,
dCkC C
dt
2
2 3
iv 3 4
C kC
C C dCC k kC k C
t C dt
C C dCC k kC k C
t C dt
C C dCC k kC k C
t C dt
0kt
trueC C e
2 2 3 3 4 41 1 11 2 3! 4!i i i i i iC C kC x k C x k C x k C x
taylor.mws
Improved Euler (Heun’s) Method 0 0, ,y f x y x y
• Euler Method– Use constant derivative between points i & i+1
– calculated at xi
• Better to use average derivative across the interval 12 1
1 , ,i i iiy f x y f x y
1
112
1
1
,
, ,
i i i i
i
ii i i
i
y y f x y x
y f x y f x
y y y
y
x
• yi+1 is not knownPredict – Correct
(can repeat)
Improved Euler Method – Example
00,dC
kC Cdt
1 1
1 1 1 1,
112
1
1
*i i
i i i i it C
i i
i i
dCC C t C t kC C k t
dt
y kC k C
C C ty
0kt
trueC C e
Euler 1.mws Improved Euler.mws
Modified Euler Method 0 0, ,y f x y x y
• Modified Euler Method– Use derivative halfway between points i & i+1
12
1 12 2
1
,2
,
i i ii
i i
i i
xy y f x y
y f x y
y y y x
Modified Euler Method – Example
00,dC
kC Cdt
12
1 1
12
,
1
12 2 2
i i
i i i iit C
i
i i
t dC t tC C C kC C k
dt
y kC
C C ty
0kt
trueC C e
Euler 1.mws Improved Euler.mws Modified Euler.mws
Runge-Kutta Methods 0 0, ,y f x y x y
• Improved and Modified Euler Methods are special cases– 2nd order Runge-Kutta
• 4th order Runge-Kutta– Runge– Kutta– Runge-Kutta-Gill
Runge Methods 0 0, ,y f x y x y
1 1 2 3 42 26i i
xy y s s s s
1
2 12 2
3 22 2
3 3
,
,
,
,
i i
x xi i
x xi i
i i
s f x y
s f x y s
s f x y s
s f x x y xs
Runge.mws
Kutta Methods 0 0, ,y f x y x y
1 1 2 3 43 38i i
xy y s s s s
1
2 13 3
2 13 2 13 3
3 1 2 3
,
,
,
,
i i
x xi i
xi i
i i
s f x y
s f x y s
s f x y x s s
s f x x y x s s s
Kutta.mws
Runge-Kutta-Gill Methods 0 0, ,y f x y x y
1 11 1 2 3 42 2
2 1 2 16i i
xy y s s s s
1
2 12 2
1 1 13 1 22 2 2 2
1 13 2 32 2
,
,
, 1
, 1
i i
x xi i
xi i
i i
s f x y
s f x y s
s f x y x s s
s f x x y x s s
Runge Kutta Gill.mws
Systems of Equations
1 2, , , , 1, 2, ,jj n
dyf x y y y j n
dx
• All the previous methods can be applied to systems of differential equations
• Only illustrate the Runge method
, 1 , 1, 2, 3, 4,2 26j i j i j j j j
xy y s s s s
1, 1, 2, ,
2, 1, 1,1 2, 1,2 , 1,2 2 2 2
3, 1, 2,1 2, 2,2 , 2,2 2 2 2
4, 1, 3,1 2, 3,2 , 3,
, , , ,
, , , ,
, , , ,
, , , ,
j j i i i n i
x x x xj j i i i n i n
x x x xj j i i i n i n
j j i i i n i n
s f x y y y
s f x y s y s y s
s f x y s y s y s
s f x x y xs y xs y xs
Systems of Equations – Example 1
A 1
dAf A k A
dt
1 1A 2A 3A 4A2 26i i
tA A s s s s
1,A A 1
2,A A 1,A 1 1,A2 2
3,A A 2,A 1 2,A2 2
4,A A 3,A 1 3,A
i i
t ti i
t ti i
i i
s f A k A
s f A s k A s
s f A s k A s
s f A ts k A ts
1 2A B Pk k
B 1 2,dB
f A B k A k Bdt
P 2
dPf B k B
dt
1 1B 2B 3B 4B2 26i i
tB B s s s s
1 1P 2P 3P 4P2 2
6i i
tP P s s s s
1,B B 1 2
2,B B 1,A 1,B 1 1,A 2 1,B2 2 2 2
3,B B 2,A 2,B 1 2,A 2 2,B2 2 2 2
4,B B 3,A 3,B 1 3,A 2 3,B
,
,
,
,
i i i i
t t t ti i i i
t t t ti i i i
i i i i
s f A B k A k B
s f A s B s k A s k B s
s f A s B s k A s k B s
s f A ts B ts k A ts k B ts
1,P P 2
2,P P 1,B 2 1,B2 2
3,P P 2,B 2 2,B2 2
4,P P 3,B 2 3,B
i i
t ti i
t ti i
i i
s f B k B
s f B s k B s
s f B s k B s
s f B ts k B ts
Consecutive reactions Runge.mws
Systems of Equations – Example 2
A 1
dAf A k A
dt
31 2 4A B C E Fkk k k
B 1 2,dB
f A B k A k Bdt
F 4
dFf E k E
dt
C 2 3,dC
f B C k B k Cdt
E 3 4,dE
f C E k C k Edt
Consecutive reactions 2 Runge.mws
Systems of Equations – Example 3
A 1 2, ,dA
f A B C k AB k Cdt
1
3
2
A B C Ek
k
k
B 1 2, ,dB
f A B C k AB k Cdt
C 1 2 3, ,dC
f A B C k AB k C k Cdt
E 3
dEf C k C
dt Consecutive reactions 3 Runge.mws
Systems of Equations – Example 4
0dX
dt
X+A 2A
A+B 2B
B P
A 1 2,dA
f A B k A k ABdt
B 2 3,dB
f A B k AB k Bdt
P 3
dPf B k B
dt Lotka Volterra Runge.mws
Systems of Equations – Example 5
A 1 2
dAf B k k B
dt
B 3 4 5,dB
f A B k AB k C k Bdt
C 6 7,dC
f B C k BC k Cdt
oscillating reaction 2 Runge.mws