Page - 259 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition
Image of the Page - 259 -
Text of the Page - 259 -
8.4 Oscillating1DSystems:ASecondOrderODE 259
Note that with the choices f(u′) = 0, s(u) = ku, andF(t) = 0 we recover the
originalODEu′′+ω2u=0 withω=√k/m.
How can we solve (8.66)? As for the simple ODE u′′ +ω2u = 0, we start by
rewriting thesecond-orderODEasa systemof two first-orderODEs:
v′ = 1
m (F(t)−s(u)−f(v)), (8.68)
u′ =v. (8.69)
The initial conditionsbecomeu(0)=U0 andv(0)=V0.
Any method for a system of first-order ODEs can be used to solve foru(t) and
v(t).
The Euler-Cromer Scheme An attractive choice from an implementational, ac-
curacy, and efficiency point of view is the Euler-Cromer scheme where we take a
forwarddifference in (8.68)andabackwarddifference in (8.69):
vn+1 −vn
Δt = 1
m (
F(tn)−s(un)−f(vn) )
, (8.70)
un+1 −un
Δt =vn+1, (8.71)
We caneasily solve for thenewunknownsvn+1 andun+1:
vn+1 =vn+Δt
m (
F(tn)−s(un)−f(vn) )
, (8.72)
un+1 =un+Δtvn+1 . (8.73)
Remarkonthe orderingof the ODEs
The ordering of the ODEs in the ODE system is important for the extended
model (8.68)–(8.69). Imagine that we write the equation foru′ first and then
the one for v′. The Euler-Cromer method would then first use a forward
differenceforun+1 andthenabackwarddifferenceforvn+1.Thelatterwould
lead toa nonlinearalgebraicequationforvn+1,
vn+1 +Δt
m f(vn+1)=vn+Δt
m ( F(tn+1)−s(un+1) )
,
iff(v) is a nonlinear function of v. This would require a numerical method
fornonlinearalgebraicequations tofindvn+1,whileupdatingvn+1 througha
forwarddifferencegivesanequationforvn+1 that is linearandtrivial tosolve
byhand.
Programming for Computations – Python
A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition
- Title
- Programming for Computations – Python
- Subtitle
- A Gentle Introduction to Numerical Simulations with Python 3.6
- Volume
- Second Edition
- Authors
- Svein Linge
- Hans Petter Langtangen
- Publisher
- Springer Open
- Date
- 2020
- Language
- English
- License
- CC BY 4.0
- ISBN
- 978-3-319-32428-9
- Size
- 17.8 x 25.4 cm
- Pages
- 356
- Keywords
- Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
- Category
- Informatik