Date post: | 04-Apr-2018 |
Category: |
Documents |
Upload: | jennifer-gonzalez |
View: | 224 times |
Download: | 0 times |
of 81
7/31/2019 ODE 03 Posted
1/81
ORDINARY DIFFERENTIAL EQUATIONS
ENGR 351
Numerical Methods for Engineers
Southern Illinois University Carbondale
College of Engineering
Dr. L.R. ChevalierDr. B.A. DeVantier
7/31/2019 ODE 03 Posted
2/81
Ordinary DifferentialEquationswhere to use them
The dissolution (solubilization) of a contaminant into
groundwater is governed by the equation:
where kl is a lumped mass transfer coefficient and Csis the maximum solubility of the contaminant into the
water (a constant). Given C(0)=2 mg/L, Cs= 500
mg/L and kl= 0.1 day-1, estimate C(0.5) and C(1.0)using a numerical method for ODEs.
CCkdtdC
sl
7/31/2019 ODE 03 Posted
3/81
A mass balance for a chemical in a completely mixed
reactor can be written as:
where Vis the volume (10 m3), cis concentration (g/m3), Fis the feed rate (200 g/min), Qis the flow rate (1 m3/min),and kis reaction rate (0.1 m3/g/min). If c(0)=0, solve theODE forc(0.5) and c(1.0)
2
kVcQcFdt
dcV
Ordinary DifferentialEquationswhere to use them
7/31/2019 ODE 03 Posted
4/81
Before coming to an exam Friday afternoon, Mr.Bringer forgot to place 24 cans of a refreshing
beverage in the refrigerator. His guest are arriving in5 minutes. So, of course he puts the beverage in therefrigerator immediately. The cans are initially at75, and the refrigerator is at a constant temperatureof 40.
Ordinary DifferentialEquationswhere to use them
7/31/2019 ODE 03 Posted
5/81
The rate of cooling is proportional to the difference inthe temperature between the beverage and thesurrounding air, as expressed by the following equation
with k = 0.1/min.
Use a numerical method to determine the temperatureof the beverage after 5 minutes and 10 minutes.
airTTkdt
dT
Ordinary DifferentialEquationswhere to use them
7/31/2019 ODE 03 Posted
6/81
Ordinary Differential Equations
A differential equation defines a relationshipbetween an unknown function and one or
more of its derivatives Physical problems using differential equations
electrical circuits
heat transfer
motion
7/31/2019 ODE 03 Posted
7/81
Ordinary Differential Equations
The derivatives are of the dependentvariable with respect to the
independent variable First order differential equation with y
as the dependent variable and x as the
independent variable would be: dy/dx = f(x,y)
7/31/2019 ODE 03 Posted
8/81
Ordinary Differential Equations
A second order differential equationwould have the form:
d y
dxf x y
dy
dx
2
2
, ,
}
does not necessarily have to include
all of these variables
7/31/2019 ODE 03 Posted
9/81
Ordinary Differential Equations
An ordinary differential equation is onewith a single independent variable.
Thus, the previous two equations areordinary differential equations
The following is not:
dy
dxf x x y
1
1 2 , ,
7/31/2019 ODE 03 Posted
10/81
Ordinary Differential Equations
The analytical solution of ordinarydifferential equation as well as partial
differential equations is called theclosed form solution
This solution requires that the constants
of integration be evaluated usingprescribed values of the independentvariable(s).
7/31/2019 ODE 03 Posted
11/81
Ordinary Differential Equations
An ordinary differential equation of order nrequires that nconditions be specified.
Boundary conditions Initial conditions
7/31/2019 ODE 03 Posted
12/81
Ordinary Differential Equations
An ordinary differential equation of order nrequires that nconditions be specified.
Boundary conditions Initial conditions
consider this beam where thedeflection is zero at the boundariesx= 0 and x = LThese are boundary conditions
7/31/2019 ODE 03 Posted
13/81
consider this beam where thedeflection is zero at the boundaries
x= 0 and x = LThese are boundary conditions
a
yo
P
In some cases, the specific behavior of a system(s)
is known at a particular time. Consider how the deflectionof a beam at x = ais shown at time t=0 to be equal to yo.Being interested in the response fort> 0, this is calledthe initial condition.
7/31/2019 ODE 03 Posted
14/81
Ordinary Differential Equations
At best, only a few differentialequations can be solved analytically in a
closed form. Solutions of most practical engineering
problems involving differential
equations require the use of numericalmethods.
7/31/2019 ODE 03 Posted
15/81
Scope of Lectures on ODE
One Step Methods
Eulers Method
Heuns Method Improved Polygon
Runge Kutta
Systems of ODEAdaptive step size control
7/31/2019 ODE 03 Posted
16/81
Boundary value problems
Case studies
Scope of Lectures on ODE
7/31/2019 ODE 03 Posted
17/81
Specific Study Objectives
Understand the visual representation ofEulers, Heuns and the improved polygonmethods.
Understand the difference between local andglobal truncation errors
Know the general form of the Runge-Kuttamethods.
Understand the derivation of the second-order RK method and how it relates to theTaylor series expansion.
7/31/2019 ODE 03 Posted
18/81
Specific Study Objectives
Realize that there are an infinite number ofpossible versions for second- and higher-order RK methods
Know how to apply any of the RK methods tosystems of equations
Understand the difference between initial
value and boundary value problems
7/31/2019 ODE 03 Posted
19/81
Review of Analytical Solution
dy
dxx
dy x dx
yx
C
4
4
4
3
2
2
3
At this point lets consider
initial conditions.
y(0)=1
and
y(0)=2
7/31/2019 ODE 03 Posted
20/81
yx
C
for y
C
then C
for y
C
and C
4
3
0 1
14 0
31
0 2
2
4 0
3
2
3
3
3
What we see are differentvalues ofCfor the twodifferent initial conditions.
The resulting equations
are:
y
x
yx
4
3 1
4
32
3
3
7/31/2019 ODE 03 Posted
21/81
0
4
8
1 2
1 6
0 0.5 1 1 .5 2 2 .5x
y
y (0)=1
y (0)=2
y (0)=3
y (0)=4
7/31/2019 ODE 03 Posted
22/81
One Step Methods
Focus is on solving ODE in the form
dydx
f x y
y y hi i
,
1
y
x
slope = yi
yi+1
h
This is the same as saying:new value = old value + slope x step size
7/31/2019 ODE 03 Posted
23/81
Eulers Method
The first derivative provides a directestimate of the slope at xi
The equation is applied iteratively, orone step at a time, over small distancein order to reduce the error
Hence this is often referred to as EulersOne-Step Method
7/31/2019 ODE 03 Posted
24/81
Example
24x
dx
dy
For the initial condition y(1)=1, determine yforh= 0.1 analytically and using Eulers
method given:
7/31/2019 ODE 03 Posted
25/81
Error Analysis of EulersMethod
Truncation error- caused by the nature ofthe techniques employed to approximatevalues ofy
local truncation error (from Taylor Series) propagated truncation error
sum of the two = global truncation error
Round off error- caused by the limited
number of significant digits that can beretained by a computer or calculator
7/31/2019 ODE 03 Posted
26/81
....end of example
Example
0
2
4
6
8
1 0
1 2
0 0.5 1 1 .5 2 2 .5
x
y
A n a ly t ica l
Solution
Numerical
Solution
7/31/2019 ODE 03 Posted
27/81
Higher Order Taylor SeriesMethods
This is simple enough to implement withpolynomials
Not so trivial with more complicated ODE
In particular, ODE that are functions of both
dependent and independent variables requirechain-rule differentiation
Alternative one-step methods are needed
y y f x y hf x y
hi i i ii i
12
2,
' ,
7/31/2019 ODE 03 Posted
28/81
Modification of EulersMethodsA fundamental error in Eulers method
is that the derivative at the beginning ofthe interval is assumed to apply across
the entire interval Two simple modifications will be
demonstrated
These modification actually belong to alarger class of solution techniques calledRunge-Kutta which we will explorelater.
7/31/2019 ODE 03 Posted
29/81
Heuns Method
Determine the derivative for the interval the initial point
end point Use the average to obtain an improved
estimate of the slope for the entireinterval
7/31/2019 ODE 03 Posted
30/81
y
xi xi+1
Use this average slope
to predict yi+1
h
yxfyxfyy iiiiii
2
,,11
1
{
7/31/2019 ODE 03 Posted
31/81
y
xi xi+1
y
x
xi xi+1
hyxfyxfyy iiiiii2
,, 111
7/31/2019 ODE 03 Posted
32/81
y
x
xi xi+1
h
yxfyxfyy iiiiii
2
,,11
1
hyy ii 1
7/31/2019 ODE 03 Posted
33/81
Improved Polygon Method
Another modification of Eulers Method
Uses Eulers to predict a value of y at
the midpoint of the interval This predicted value is used to estimate
the slope at the midpoint
7/31/2019 ODE 03 Posted
34/81
We then assume that this slope represents avalid approximation of the average slope forthe entire interval
Use this slope to extrapolate linearly from xito xi+1 using Eulers algorithm
Improved Polygon Method
7/31/2019 ODE 03 Posted
35/81
Both Heuns and the Improved Polygon
Method have been introduced graphically.
However, the algorithms used are not as
straight forward as they can be.
Lets review the Runge-Kutta Methods.
Choices in values of variable will give us
these methods and more. It is recommendthat you use this algorithm on your homework
and/or programming assignments.
Runge-Kutta Methods
7/31/2019 ODE 03 Posted
36/81
Runge-Kutta Methods
RK methods achieve the accuracy of a Taylorseries approach without requiring thecalculation of a higher derivative
Many variations exist but all can be cast inthe generalized form:
y y x y h hi i i i 1 , ,
{
is called the incremental function
7/31/2019 ODE 03 Posted
37/81
, Incremental Function
can be interpreted as a representativeslope over the interval
a k a k a k
where the a s are constant and the k s are
k f x y
k f x p h y q k h
k f x p h y q k h q k h
k f x p h y q k h q k h q k h
n n
i i
i i
i i
n i n i n n n n n
1 1 2 2
1
2 1 11 1
3 2 21 1 22 2
1 1 1 1 2 2 1 1 1
' ' :
,
,
,
,, , ,
7/31/2019 ODE 03 Posted
38/81
a k a k a k
where the a s are constant and the k s are
k f x yk f x p h y q k h
k f x p h y q k h q k h
k f x p h y q k h q k h q k h
n n
i i
i i
i i
n i n i n n n n n
1 1 2 2
1
2 1 11 1
3 2 21 1 22 2
1 1 1 1 2 2 1 1 1
' ' :
,
,
,
,, , ,
NOTE:
ks are recurrence relationships,that is k1 appears in the equation for k2
which appears in the equation for k3This recurrence makes RK methods efficient for
computer calculations
7/31/2019 ODE 03 Posted
39/81
Second Order RK Methods
y y a k a k h
where
k f x y
k f x p h y q k h
i i
i i
i i
1 1 1 2 2
1
2 1 11 1
,
,
a k a k a k
where the a s are constant and the k s are
k f x y
k f x p h y q k h
k f x p h y q k h q k h
k f x p h y q k h q k h q k h
n n
i i
i i
i i
n i n i n n n n n
1 1 2 2
1
2 1 11 1
3 2 21 1 22 2
1 1 1 1 2 2 1 1 1
' ' :
,
,
,
,, , ,
7/31/2019 ODE 03 Posted
40/81
7/31/2019 ODE 03 Posted
41/81
f x yf
x
f
y
dy
dx
substituting
y y f x y hf
x
f
y
dy
dx
h
i i
i i i i
' ,
,
1
2
2
Now, f(xi , yi ) must be determined by the
chain rule for differentiation
The basic strategy underlying Runge-Kutta methodsis to use algebraic manipulations to solve for values
ofa1, a2, p1 and q11
7/31/2019 ODE 03 Posted
42/81
7/31/2019 ODE 03 Posted
43/81
a a
a p
a q
1 2
2 1
2 11
1
1
2
1
2
Because we have three equations with four unknowns,
we must assume a value of one of the unknowns.
Suppose we specify a value for a2.
What would the equations be?
7/31/2019 ODE 03 Posted
44/81
a a
p q a
1 2
1 11
2
1
1
2
Because we can choose an infinite number of values
for a2 there are an infinite number of second orderRK methods.
Every solution would yield exactly the same result
if the solution to the ODE were quadratic, linear or aconstant.
Lets review three of the most commonly used and
preferred versions.
7/31/2019 ODE 03 Posted
45/81
y y a k a k h
where
k f x y
k f x p h y q k ha a
a p
a q
i i
i i
i i
1 1 1 2 2
1
2 1 11 1
1 2
2 1
2 11
1
1
2
1
2
,
,
Consider the following:
Case 1: a2 = 1/2
Case 2: a2 = 1
These two methods
have been previously
studied.
What are they?
7/31/2019 ODE 03 Posted
46/81
a a
a p
a q
p qa
y y k k h
where
k f x y
k f x h y k h
i i
i i
i i
1 2
2 1
2 11
1 11
2
1 1 2
1
2 1
1 1 1 2 1 2
1
2
1
2
1
21
1
2
1
2
/ /
,
,
Case 1: a2 = 1/2
This is Heuns Method with
a single corrector.
Note that k1 is the slope at
the beginning of the interval
and k2 is the slope at theend of the interval.
y y a k a k h
wherek f x y
k f x p h y q k h
i i
i i
i i
1 1 1 2 2
1
2 1 11 1
,
,
7/31/2019 ODE 03 Posted
47/81
a a
a p
a q
p q a
y y k h
where
k f x y
k f x h y k h
i i
i i
i i
1 2
2 1
2 11
1 112
1 2
1
2 1
1 1 1 0
1
2
1
2
1
2
1
2
1
2
1
2
,
,
y y a k a k h
where
k f x y
k f x p h y q k h
i i
i i
i i
1 1 1 2 2
1
2 1 11 1
,
,
Case 2: a2 = 1
This is the ImprovedPolygon Method.
7/31/2019 ODE 03 Posted
48/81
Ralstons Method
Ralston (1962) and Ralston and Rabinowitiz (1978)
determined that choosing a2 = 2/3 provides a minimum
bound on the truncation error for the second order RK
algorithms.
This results in a1 = 1/3 and p1 = q11 = 3/4
y y k k h
wherek f x y
k f x h y k h
i i
i i
i i
1 1 2
1
2 1
1
3
2
3
3
4
3
4
,
,
7/31/2019 ODE 03 Posted
49/81
Example
1.0
11..11..
42
hsizestep
yeixatyCI
yxdx
dy Evaluate the following
ODE using Heuns
Methods
7/31/2019 ODE 03 Posted
50/81
Third Order Runge-Kutta Methods
Derivation is similar to the one for the second-order
Results in six equations and eight unknowns.
One common version results in the following
y y k k k h
where
k f x y
k f x h y k h
k f x h y hk hk
i i
i i
i i
i i
1 1 2 3
1
2 1
3 1 2
16
4
1
2
1
2
2
,
,
,
Note the third term
NOTE: if the derivative is a function of x only, this reduces to Simpsons 1/3 Rule
7/31/2019 ODE 03 Posted
51/81
Fourth Order Runge Kutta
The most popular
The following is sometimes called theclassical fourth-order RK method
y y k k k k h
where
k f x y
k f x h y k h
k f x h y hk
k f x h y hk
i i
i i
i i
i i
i i
1 1 2 3 4
1
2 1
3 2
4 3
16
2 2
1
2
1
2
1
2
1
2
,
,
,
,
7/31/2019 ODE 03 Posted
52/81
Note that for ODE that are a function of x alone thatthis is also the equivalent of Simpsons 1/3 Rule
34
23
12
1
43211
,
2
1,
2
1
2
1,
2
1,
226
1
hkyhxfk
hkyhxfk
hkyhxfk
yxfk
where
hkkkkyy
ii
ii
ii
ii
ii
7/31/2019 ODE 03 Posted
53/81
Example
Use 4th Order RK to solve the following differential equation:
dy
dx
xy
xI C y 1
1 12 . .
using an interval ofh= 0.1
7/31/2019 ODE 03 Posted
54/81
Higher Order RK Methods
When more accurate results arerequired, Buchers (1964) fifth order RK
method is recommended There is a similarity to Booles Rule
The gain in accuracy is offset by added
computational effort and complexity
7/31/2019 ODE 03 Posted
55/81
Systems of Equations
Many practical problems in engineering andscience require the solution of a system ofsimultaneous differential equations
dydx
f x y y y
dy
dxf x y y y
dy
dxf x y y y
n
n
n
n n
1
1 1 2
2
2 1 2
1 2
, , , ,
, , , ,
, , , ,
7/31/2019 ODE 03 Posted
56/81
Solution requires ninitial conditions
All the methods for single equations can be
used The procedure involves applying the one-step
technique for every equation at each step
before proceeding to the next step
dy
dxf x y y y
dy
dx
f x y y y
dy
dxf x y y y
n
n
n
n n
1
1 1 2
2
2 1 2
1 2
, , , ,
, , , ,
, , , ,
7/31/2019 ODE 03 Posted
57/81
Boundary Value Problems
Recall that the solution to an nthorder ODErequires nconditions
If all the conditions are specified at the samevalue of the independent variable, then weare dealing with an initial value problem
Problems so far have been devoted to this
type of problem
7/31/2019 ODE 03 Posted
58/81
Boundary Value Problems
In contrast, we may also have conditions adifferent value of the independent variable.
These are often specified at the extreme
point or boundaries of as system andcustomarily referred to as boundary valueproblems
To approaches to the solution
shooting method
finite difference approach
G l M th d f B d
7/31/2019 ODE 03 Posted
59/81
General Methods for BoundaryValue Problems
The conservation of heat can be used to develop a heat
balance for a long, thin rod. If the rod is not insulated
along its length and the system is at steady state. The
equation that results is:
d T
dxh T Ta
2
20 '
T1 T2
Ta
Ta
7/31/2019 ODE 03 Posted
60/81
T1 T2
Ta
Ta
d T
dx
h T Ta
2
20 '
Clearly this second order
ODE needs 2 conditions.
This can be satisfied by
knowing the temperatureat the boundaries,
i.e. T1 and T2
T(0) = T1
T(L) = T2
7/31/2019 ODE 03 Posted
61/81
7/31/2019 ODE 03 Posted
62/81
Shooting Method
d T
dxh T T
dTdx
z
dz
dxh T T
a
a
2
20
'
'
Given:
We need an initial value
of z.
For the shooting method, guess
an initial value.
Guessing z(0) = 10
7/31/2019 ODE 03 Posted
63/81
dz
dxh T Ta '
Using a fourth-order RK method with a step size
of 2, T(10) = 168.38
This differs from the BC T(10) = 200
Making another guess, z(0) = 20
T(10) = 285.90
Because the original ODE is linear, the estimates
of z(0) are linearly related.
Guessing z(0) = 10
7/31/2019 ODE 03 Posted
64/81
Using a linear interpolation formula between the values
of z(0), determine a new value of z(0)
Recall:
first estimate z(0) = 10 T(20) = 168.38
second estimate z(0)=20 T(20) = 285.90
What is z(0) that would give us T(20)=200?
150
200
250
300
0 5 10 15 20 25
z(0)
T(20)
7/31/2019 ODE 03 Posted
65/81
z 0 10
20 10
285 90 168 38200 168 38 12 69
. .. .
150
200
250
300
0 5 10 15 20 25
z(0)
T(20)
d T
dxh T T
dT
dx z
dz
dxh T T
a
a
2
20
'
'
We can now use
this to solve the firstorder ODE
7/31/2019 ODE 03 Posted
66/81
For nonlinear boundary value problems, linear
interpolation will not necessarily result in an accurate
estimation. One alternative is to apply three
applications of the shooting method and use quadratic
interpolation..
0
5 0
1 00
1 5 0
2 00
2 5 0
0 5 1 0
distance (m )
T
A n a ly t ic a l
Solution
Shooting
Method
7/31/2019 ODE 03 Posted
67/81
Finite Difference Methods
The finite divided difference approximation for
the 2nd derivative can be substituted into the
governing equation.
d T
dx
T T T
x
d T
dxh T T
T T T
xh T T
i i i
a
i i ia i
2
2
1 1
2
2
2
1 1
2
2
0
20
'
'
7/31/2019 ODE 03 Posted
68/81
T T T
x
h T T
T h x T T h x T
i i ia i
i i i a
1 1
2
1
2
1
2
20
2
'
' '
Collect terms
We can now apply this equation to each interior nodeon the rod.
Divide the rod into a grid, and consider a node to be
at each division. i.e.. x = 2m
T1 T2L = 10 m
x = 2 m
7/31/2019 ODE 03 Posted
69/81
aiii TxhTTxhT2
1
2
1''2
T(0) T(10)L = 10 m
x = 2 m
Consider the previous problem:
L = 10 mTa = 20
T(0) = 40
T(10) = 200
h = 0.01
We need to solve for the
temperature at the interior
nodes (4 unknowns).
Apply the governingequation at these nodes (4
equations).
What is the matrix?
7/31/2019 ODE 03 Posted
70/81
aiii TxhTTxhT2
1
2
1''2
T(0) T(10)
x=0 2 4 6 8 10
i=0 1 2 3 4 5
Notice the labeling for numbering xand i
7/31/2019 ODE 03 Posted
71/81
aiii TxhTTxhT2
1
2
1''2
T(0) T(10)
x=0 2 4 6 8 10
i=0 1 2 3 4 5
40 200
Note also that the dependent values are
known at the boundaries (hence the termboundary value problem)
7/31/2019 ODE 03 Posted
72/81
aiii TxhTTxhT2
1
2
1''2
T(0) T(10)
x=0 2 4 6 8 10
i=0 1 2 3 4 5
40 200
Apply the governing equation at node 1
8.4004.2
8.004.240
''2
21
21
2
21
2
0
TT
TT
TxhTTxhT a
7/31/2019 ODE 03 Posted
73/81
7/31/2019 ODE 03 Posted
74/81
aiii TxhTTxhT2
1
2
1''2
T(0) T(10)
x=0 2 4 6 8 10
i=0 1 2 3 4 5
40 200
We get a similar equation at node 3
8.004.2
''2
432
2
43
2
2
TTT
TxhTTxhT a
7/31/2019 ODE 03 Posted
75/81
aiii TxhTTxhT2
1
2
1''2
T(0) T(10)
x=0 2 4 6 8 10
i=0 1 2 3 4 5
40 200
8.20004.2
8.020004.2
''2
43
43
2
54
2
3
TT
TT
TxhTTxhT a
At node 4, we consider the
boundary at the right.
7/31/2019 ODE 03 Posted
76/81
For the four interior nodes, we get the following
4 x 4 matrix
48.15954.12478.9397.65
8.200
8.0
8.0
8.40
04.2100
104.210
0104.21
00104.2
4
3
2
1
TT
T
T
T
T
7/31/2019 ODE 03 Posted
77/81
0
5 0
1 00
1 5 0
2 00
2 5 0
0 5 1 0
distan ce (m )
T
A n a ly t ica l
Solution
ShootingMethod
Finite
Difference
7/31/2019 ODE 03 Posted
78/81
Example
Consider the previous example, but
with x=1. What is the matrix?
7/31/2019 ODE 03 Posted
79/81
Specific Study Objectives
Understand the visual representation ofEulers, Heuns and the improved polygonmethods.
Understand the difference between local andglobal truncation errors
Know the general form of the Runge-Kuttamethods.
Understand the derivation of the second-order RK method and how it relates to theTaylor series expansion.
7/31/2019 ODE 03 Posted
80/81
Specific Study Objectives
Realize that there are an infinite number ofpossible versions for second- and higher-order RK methods
Know how to apply any of the RK methods tosystems of equations
Understand the difference between initialvalue and boundary value problems
7/31/2019 ODE 03 Posted
81/81
end of lecture on ODE