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

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

Bild der Seite - 274 -

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

Text der Seite - 274 -

274 8 SolvingOrdinaryDifferentialEquations runsa numberof steps inode_FEandcompares the computedsolution with the listed formulaforun. Filename:test_ode_FE.py. Exercise8.4: Implement andEvaluateHeun’sMethod a) Asecond-orderRunge-Kuttamethod,alsoknownhasHeun’smethod, isderived in Sect. 8.4.5. Make a functionode_Heun(f, U_0, dt, T) (as a counterpart toode_FE(f, U_0, dt, T) inode_FE.py) forsolvingascalarODEproblem u′ = f(u,t), u(0) = U0, t ∈ (0,T], with this method using a time step size Δt. b) Solve the simple ODE problemu′ = u, u(0) = 1, by the ode_Heun and the ode_FE function. Make a plot that compares Heun’s method and the Forward Euler method with the exact solutionu(t) = et for t ∈ [0,6]. Use a time step Δt=0.5. c) For the case in b), find through experimentation the largest value ofΔt where the exact solution and the numerical solution by Heun’s method cannot be distinguished visually. It is of interest to see how far off the curve the Forward Euler method is when Heun’s method can be regarded as “exact” (for visual purposes). Filename:ode_Heun.py. Exercise8.5:Find anAppropriateTime Step;LogisticModel Compute the numerical solution of the logistic equation for a set of repeatedly halved time steps: Δtk = 2−kΔt, k = 0,1,.. .. Plot the solutions corresponding to the last two time stepsΔtk andΔtk−1 in the same plot.Continuedoing thisuntil you cannot visually distinguish the two curves in the plot. Then one has found a sufficientlysmall time step. Hint Extendthelogistic.pyfile. Introducea loopoverk,writeoutΔtk, andask theuser if the loop is tobecontinued. Filename:logistic_dt.py. Exercise8.6:Find anAppropriateTime Step;SIR Model RepeatExercise8.5 for theSIRmodel. Hint Import the ode_FE function from the ode_system_FEmodule and make a modifieddemo_SIR function thathasa loopover repeatedlyhalvedtimesteps.Plot S, I, andRversus timefor the two last timestep sizes in thesame plot. Filename:SIR_dt.py. Exercise8.7:Modelan AdaptiveVaccinationCampaign In the SIRV model with time-dependent vaccination from Sect. 8.3.9, we want to test the effect of an adaptive vaccination campaign where vaccination is offered
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