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 - 305 -
  • User
  • Version
    • full version
    • text only version
  • Language
    • Deutsch - German
    • English

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

Image of the Page - 305 -

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

Text of the Page - 305 -

9.3 Exercises 305 3. Thebackward2-stepmethodwithΔt=0.01 Choose the modelproblemfromSect.9.2.4. Filename:rod_BE_vs_B2Step.py. Exercise9.4:ExploreAdaptiveand Implicit Methods WeconsiderthesameproblemasinExercise9.2.Nowwewant toexploretheuseof adaptiveandimplicitmethodsfromOdespytosee if theyaremoreefficient than the ForwardEulermethod.AssumethatyouwanttheaccuracyprovidedbytheForward Eulermethodwith its maximumΔt value.Since thereexistsananalytical solution, youcancomputeanerrormeasure that summarizes theerror inspaceand timeover thewholesimulation: E= √ ΔxΔt ∑ i ∑ n (Uni −uni )2 . Here,Uni is theexactsolution.UsetheOdespypackagetorunthefollowingimplicit andadaptivesolvers: 1. BackwardEuler 2. Backward2Step 3. RKFehlberg Experiment to see if you can use larger time steps than what is required by the ForwardEulermethodandget solutionswith thesameorderofaccuracy. Hint Toavoidoscillationsin thesolutionswhenusingtheRKFehlbergmethod, the rtol andatolparameters toRKFFehlbergmust be set no larger than 0.001 and 0.0001,respectively.Youcanprintoutsolver_RKF.t_alltoseeall the timesteps usedbytheRKFehlbergsolver(ifsolver is theRKFehlbergobject).Youcanthen compare thenumberof timestepswithwhat is requiredby theothermethods. Filename:ground_temp_adaptive.py. Exercise9.5: Investigate theθ Rule a) The Crank-Nicolson method for ODEs is very popular when combined with diffusionequations.Fora linearODEu′ =au it reads un+1 −un Δt = 1 2 (aun+aun+1). Apply the Crank-Nicolson method in time to the ODE system for a one- dimensionaldiffusionequation. Identify the linear system tobesolved.
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