Ce205 Ode

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

CE 205: Numerical Methods

Ordinary
O
di
Diff
Differential
ti l
Equations

CE205:NumericalMethods

Dr.Tanvir Ahmed

WhystudyDifferentialEquations?
Manyphysicalphenomenaarebestformulated
mathematically in terms of their rate of change.
mathematicallyintermsoftheirrateofchange.
Motionofaswingingpendulum
Bungeejumper
j
Equation

d 2 g
+ sin = 0
2
dt
l

dv
cd 2
= g v
dt
m

CE205:NumericalMethods

Dr.Tanvir Ahmed

ODEandEngineeringpractice
F = ma

PhysicalLaws

dv
d
cd 2
= g v
dt
m

ODE

Analytical

v(t) =

gc
gm
d
tanh
t
cd
m

Numerical

2
v(ti +1 ) = v(ti ) + g d v(ti ) (ti +1 ti )
m

Solution

Independentvariable:spatialortemporal
CE205:NumericalMethods

Dr.Tanvir Ahmed

Initialvalueandboundaryvalueproblems
BoundaryValueproblems: Solve
GeneralSolution
ApplyingB.C.

InitialValueproblems: Solve
GeneralSolution
ApplyingI.C.
l

CE205:NumericalMethods

Dr.Tanvir Ahmed

Solvinginitialvalueproblems
dy
= f (t, y)
dt

ODEoftheform
willbesolvedusingtheone
step methods having the general form:
stepmethodshavingthegeneralform:

yi+1 = yi + h
iscalledanincrementfunction,and
isusedto
is
used to extrapolate fromanold
from an old
valueyi toanewvalueyi+1

Techniques:
Euler
Heun
Midpoint
FourthOrder
RungeKutta
Fourth
OrderRunge
Kutta
CE205:NumericalMethods

Dr.Tanvir Ahmed

EulersMethod
Thefirstderivativeprovidesadirectestimateofthe
slope at ti:
slopeatt
dy
= f (t i , yi )
dt ti
Eulermethodusesthat
Euler
method uses that
estimateastheincrement
function:

= f (t i , yi )
yi+1 = yi + f (t i , yi )h

CE205:NumericalMethods

Dr.Tanvir Ahmed

ErrorsinODE
ThenumericalsolutionofODEsinvolvestwotypesof
yp
error:
Truncationerrors,causedbythenatureofthetechniquesemployed
Roundoff
Roundoff errors,causedbythelimitednumbersofsignificantdigitsthatcan
errors caused by the limited numbers of significant digits that can
beretained

Thetotal,orglobaltruncationerrorcanbefurthersplit
into:
localtruncationerror thatresultsfromanapplicationmethodinquestion
overasinglestep,and
propagatedtruncationerror thatresultsfromtheapproximations
producedduringprevioussteps.

CE205:NumericalMethods

Dr.Tanvir Ahmed

ErrorAnalysisinEulersMethod
ThelocaltruncationerrorforEulersmethodisO(h2)and
proportionaltothederivativeoff(t,y)whiletheglobal
truncationerrorisO(h).
i
i (h)

Globalerrorcanbereducedbydecreasingthestepsize
CE205:NumericalMethods

Dr.Tanvir Ahmed

ImprovementofEulersMethod
Mainlimitation:thederivativeatthebeginningofthe
intervalisassumedtoapplyacrosstheentireinterval

Twomodificationscanbemade:
(1) Heuns method
(2) Midpointmethod
CE205:NumericalMethods

Dr.Tanvir Ahmed

Heuns Method(Predictorcorrectorapproach)
Determinederivativesatthebeginningandpredicted
endingoftheintervalandaveragethemtoobtainan
i
improvedestimateoftheslope
d i
f h l

Predictor:
Corrector:

yi0+1 = yi + f (ti , yi )h
f (ti , yi ) + f (ti +1 , yi0+1 )
yi +1 = yi +
h
2

CE205:NumericalMethods

Dr.Tanvir Ahmed

Heuns Method(Predictorcorrectorapproach)
predictorcorrectorapproachcanbeiteratedto
convergence:

CE205:NumericalMethods

Dr.Tanvir Ahmed

MidpointMethod
SimilartoHeuns method,butpredictstheslopeatthe
midpointofanintervalratherthanattheend

yi +1/ 2 = yi + f (ti , yi )h / 2
yi +1 = yi + f (ti +1/ 2 , yi +1/ 2 )h
CE205:NumericalMethods

localtruncationerrorO(h3)
gglobalerrorO(h
( 2)
Dr.Tanvir Ahmed

RungeKutta Methods:generalform
CanachievetheaccuracyofaTaylorseriesapproach
withoutrequiringthecalculationofhigherderivatives.
Theincrementfunction canbegenerallywrittenas
= a1k1 + a2 k2 +L+ an kn
k1 = f (t i , yi )
k2 = f (t i + p1h, yi + q11k1h)
k3 = f (t i + p2 h, yi + q21k1h + q22 k2 h)
M
kn = f (t i + pn1h,
h yi + qn1,1k1h + qn1,2 k2 h +L+ qn1,n1kn1h)
as,ps
, p andqs
q areconstants
CE205:NumericalMethods

Dr.Tanvir Ahmed

4th orderRungeKutta method


Themostpopularlyusedmethod
1
yi+1 = yi + (k1 + 2k2 + 2k3 + k4 )h
6

where
k1 = f (t i , yi )

1
1
k2 = f t i + h,
h yi + k1h

2
2

1
1
k3 = f t i + h,
h yi + k2 h

2
2
k4 = f (t i + h, yi + k3h)
CE205:NumericalMethods

Dr.Tanvir Ahmed

Performanceofdifferentmethods

CE205:NumericalMethods

Dr.Tanvir Ahmed

AsystemofODE
dy1
= f1 (t, y1 , y2 ,L, yn )
dt
dy2
= f2 (t, y1 , y2 ,L, yn )
dt
M
dyn
= fn (t, y1 , y2 ,L, yn )
dt

n initialconditionsbeknownatthestartingvalueoft.
Onestepmethodisappliedforeveryequationateach
step before proceeding to the next step
stepbeforeproceedingtothenextstep
Eulersmethod
4th orderRK
CE205:NumericalMethods

Dr.Tanvir Ahmed

Adaptivesolutionmethods
ThesolutionstosomeODE
problems exhibit multiple time
problemsexhibitmultipletime
scales forsomepartsofthe
solution the variable changes
solutionthevariablechanges
slowly,whileforothersthereare
abruptchanges.
Adaptivealgorithmscan
changestepsizedepending
ontheregion
Stephalving
S
h l i
PerformingtwoRKpredictionsof
differentorder

CE205:NumericalMethods

Dr.Tanvir Ahmed

Boundaryvalueproblems
Conditionsarenot
C
di i
knownatasinglepoint
but rather are given at
butratheraregivenat
differentvaluesofthe
independent variable
independentvariable
BoundaryConditions:
y
valuesofvariables
valuesofderivativesofvariables

CE205:NumericalMethods

Dr.Tanvir Ahmed

Example:Boundaryvalueproblem
Noninsulatedrodpositionedbetweenbodiesofconstant
i l d d
ii
db
b di
f
butdifferenttemperature
d 2T
+ h(T T ) = 0
2
dx

Bo ndar conditions
Boundaryconditions:

T (0) = T1 = 40, T ( L) = T2 = 200

L = 10m Ta = 20 h = 0.01m 2

Analyticalsolution:
CE205:NumericalMethods

Dr.Tanvir Ahmed

Numericalsolution:theshootingmethod
theboundaryvalueproblemisconvertedintoan
equivalentinitialvalueproblem.
q
p
dT
=
z
2

d T
dx

(
)
+
h
T

T
=
0

dz
dx 2

= h(T T )
dx

Generally,theequivalentsystemwillnothavesufficient
G
ll th
i l t t
ill t h
ffi i t
initialconditions
Aguessismadeforanyundefinedvalues.
A guess is made for any undefined values
TheguessesarechangeduntilthefinalsolutionsatisfiesalltheB.C.

FForlinearODEs,onlytwoshotsarerequired
li
ODE
l t h t
i d the
th
properinitialconditioncanbeobtainedasalinear
interpolation of the two guesses
interpolationofthetwoguesses.
CE205:NumericalMethods

Dr.Tanvir Ahmed

Numericalsolution:theshootingmethod
SolutionusingRKmethod:

CE205:NumericalMethods

Dr.Tanvir Ahmed

Numericalsolution:finitedifference
finitedifferencesaresubstitutedforthederivativesin
theoriginalequation
g
q
d 2T
+ h(T T ) = 0
2
dx

d 2T Ti1 2Ti + Ti+1


=
2
dx
x 2
Ti1 2Ti + Ti+1
+ h(T Ti ) = 0
2
x
Ti1 + (2 + hx 2 )Ti Ti+1 = hx 2T
CE205:NumericalMethods

Dr.Tanvir Ahmed

Numericalsolution:finitedifference
Thelineardifferentialequationistransformedintoaset
ofsimultaneousalgebraicequations.
SinceT0 andTn areknown(Drichlet boundaryconditions),
they will be on the right hand side of the linear algebra
theywillbeontherighthandsideofthelinearalgebra
system
2 + hx 2
11

1
2 + hx 2
O

CE205:NumericalMethods

1
1
O
1
1

T hx 2T + T0
T1 hx 2T

2 =

O M
M

2 + hx 2 Tnn11 hx 2T + Tn

Dr.Tanvir Ahmed

Numericalsolution:finitedifference
Ifthereisaderivativeboundarycondition(Neumann
B.C.),thecentereddifferenceequationissolvedatthe
pointandrewritingthesystemequationaccordingly.
ForaNeumannconditionatT0point:

dT
dT
T1 T11
=
T1 = T1 2x
2

dx 0
2x
dx 0
T
T1 + (2 + hx 2 )T0 T1 = hx 2T

dT
2
2

T1 2x
+
2
+
x
T

T
=
x
T
h
h

(
)
0
1
d 0
dx

dT
2
2
(2 + hx )T0 2T1 = hx T 2x dx
0
CE205:NumericalMethods

Dr.Tanvir Ahmed

You might also like