Web-Books
in the Austria-Forum
Austria-Forum
Web-Books
Informatik
Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition
Page - 246 -
  • User
  • Version
    • full version
    • text only version
  • Language
    • Deutsch - German
    • English

Page - 246 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition

Image of the Page - 246 -

Image of the Page - 246 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition

Text of the Page - 246 -

246 8 SolvingOrdinaryDifferentialEquations The standard way of expressing this scheme in physics is to change the orderof theequations, v′ =−ω2u, (8.53) u′ =v, (8.54) andapplya forwarddifference to (8.53)anda backwarddifference to (8.54): vn+1 =vn−Δtω2un, (8.55) un+1 =un+Δtvn+1 . (8.56) Thatis,first thevelocityv isupdatedandthenthepositionu,usingthemostrecently computedvelocity.There is no difference between (8.55)–(8.56)and (8.49)–(8.50) with respect to accuracy, so how you order the original differential equations does not matter. The scheme (8.55)–(8.56) goes by the name Semi-implicit Euler,5 or Euler-Cromer (a first-ordermethod).The implementationof (8.55)–(8.56) is found in thefileosc_EC.py.Thecoreof thecodegoes like u = zeros(N_t+1) v = zeros(N_t+1) # Initial condition u[0] = 2 v[0] = 0 # Step equations forward in time for n in range(N_t): v[n+1] = v[n] - dt*omega**2*u[n] u[n+1] = u[n] + dt*v[n+1] Explicitand implicit methods When we solve an ODE (linear or nonlinear) by the Forward Euler method, we get an explicit updating formula for the unknown at each time step, see, e.g., (8.6). Methods with this characteristic are known as explicit. We also have implicit methods. In that case, one or more algebraic equations must typically be solved for each time step. The Backward Euler method, for example, is such an implicit method (you will realize that when you do Exercise8.24). 8.4.5 TheSecond-OrderRunge-KuttaMethod(orHeun’s Method) A very popular method for solving scalar and vector ODEs of first order is the second-orderRunge-Kuttamethod(RK2),alsoknownasHeun’smethod.The idea, 5 http://en.wikipedia.org/wiki/Semi-implicit_Euler_method.
back to the  book Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition"
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
Web-Books
Library
Privacy
Imprint
Austria-Forum
Austria-Forum
Web-Books
Programming for Computations – Python