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

Page - 131 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Image of the Page - 131 -

Image of the Page - 131 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Text of the Page - 131 -

4.3 OscillatingOne-DimensionalSystems 131 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] 4.3.5 The2nd-OrderRunge-KuttaMethod(orHeun’sMethod) A very popular method for solving scalar and vector ODEs of first order is the 2nd-orderRunge-Kuttamethod (RK2), also known asHeun’smethod. The idea, first thinkingofascalarODE, is to formacentereddifferenceapproximationto the derivativebetween two timepoints: u0.tnC 1 2 t/ u nC1 un t : Thecentereddifferenceformula isvisualized inFig.4.20. Theerror in thecentered difference is proportional to t2, oneorderhigher than the forwardandbackward differences,whichmeans that ifwehalve t, theerror ismoreeffectively reduced in thecentereddifferencesince it is reducedbya factorof four rather than two. Theproblemwith such a centered scheme for thegeneralODEu0 D f.u;t/ is thatweget unC1 un t Df.unC12 ;tnC12/; which leads to difficulties sincewe do not knowwhatunC 1 2 is. However,we can approximate the value off between two time levels by the arithmetic average of Fig.4.20 Illustrationof acentereddifferenceapproximation to thederivative
back to the  book Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python"
Programming for Computations – Python A Gentle Introduction to Numerical Simulations with Python
Title
Programming for Computations – Python
Subtitle
A Gentle Introduction to Numerical Simulations with Python
Authors
Svein Linge
Hans Petter Langtangen
Publisher
Springer Open
Date
2016
Language
English
License
CC BY-NC 4.0
ISBN
978-3-319-32428-9
Size
17.8 x 25.4 cm
Pages
248
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