Web-Books
im Austria-Forum
Austria-Forum
Web-Books
Informatik
Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition
Seite - 246 -
  • Benutzer
  • Version
    • Vollversion
    • Textversion
  • Sprache
    • Deutsch
    • English - Englisch

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

Bild der Seite - 246 -

Bild der Seite - 246 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition

Text der Seite - 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.
zurück zum  Buch Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition"
Programming for Computations – Python A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition
Titel
Programming for Computations – Python
Untertitel
A Gentle Introduction to Numerical Simulations with Python 3.6
Band
Second Edition
Autoren
Svein Linge
Hans Petter Langtangen
Verlag
Springer Open
Datum
2020
Sprache
englisch
Lizenz
CC BY 4.0
ISBN
978-3-319-32428-9
Abmessungen
17.8 x 25.4 cm
Seiten
356
Schlagwörter
Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
Kategorie
Informatik
Web-Books
Bibliothek
Datenschutz
Impressum
Austria-Forum
Austria-Forum
Web-Books
Programming for Computations – Python