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 - 283 -
  • Benutzer
  • Version
    • Vollversion
    • Textversion
  • Sprache
    • Deutsch
    • English - Englisch

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

Bild der Seite - 283 -

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

Text der Seite - 283 -

8.6 Exercises 283 A general vector ODE u′ = f(u,t), where u and f are vectors, can use this approximationas follows: un−un−1 Δt =f(un,tn), which leads toanequationfor the newvalueun: un−Δtf(un,tn)=un−1 . Fora generalf , this is a systemofnonlinearalgebraicequations. However, theODE(8.43)–(8.44)is linear, so aBackwardEuler scheme leads to asystem of two algebraicequationsfor twounknowns: un−Δtvn=un−1, (8.89) vn+Δtω2un=vn−1 . (8.90) a) Solve thesystemforun andvn. b) Implement the found formulas for un and vn in a program for computing the entirenumerical solutionof (8.43)–(8.44). c) Run the program with a Δt corresponding to 20 time steps per period of the oscillations (see Sect. 8.4.3 for how to find such aΔt). What do you observe? Increase to 2000 time steps per period. How much does this improve the solution? Filename:osc_BE.py. Remarks While the Forward Euler method applied to oscillation problemsu′′ + ω2u = 0 gives growing amplitudes, the Backward Euler method leads to signifi- cantlydampedamplitudes. Exercise8.20:Use Heun’sMethod for theSIR Model Makea programthat computes the solutionof the SIRmodel fromSect. 8.3.1both by the Forward Euler method and by Heun’s method (or equivalently: the second- order Runge-Kutta method) from Sect. 8.4.5. Compare the two methods in the simulation case from Sect. 8.3.3. Make two comparison plots, one for a large and one for a small time step. Experiment to find what “large” and “small” should be: the large one gives significant differences, while the small one lead to very similar curves. Filename:SIR_Heun.py. Exercise8.21:Use OdespytoSolvea Simple ODE Solve u′ =−au+b, u(0)=U0, t∈ (0,T]
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