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

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

Image of the Page - 179 -

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

Text of the Page - 179 -

5.2 Exercises 179 TheOdespypackageoffers thismethodasodespy.Backward2Step.Thepurpose of this exercise is tocompare threemethodsandanimate the threesolutions: 1. TheBackwardEulermethodwith t D0:001 2. Thebackward2-stepmethodwith t D0:001 3. Thebackward2-stepmethodwith t D0:01 Choose themodelproblemfromSect. 5.1.4. Filename:rod_BE_vs_B2Step.py. Exercise5.4:Exploreadaptiveand implicitmethods Weconsider the sameproblemas inExercise5.2. Nowwewant to explore theuse ofadaptiveand implicitmethods fromOdespy to see if theyaremoreefficient than the Forward Euler method. Assume that youwant the accuracy provided by the ForwardEulermethodwith itsmaximum t value. Since thereexists ananalytical solution,youcancomputeanerrormeasure that summarizes theerror in spaceand timeover thewhole simulation: E D s x t X i X 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 the sameorderofaccuracy. Hint Toavoidoscillations in thesolutionswhenusingtheRKFehlbergmethod, the rtol andatolparameters toRKFFehlbergmust be set no larger than 0.001 and 0.0001,respectively.Youcanprintoutsolver_RKF.t_alltoseeall thetimesteps usedbytheRKFehlbergsolver(ifsolver is theRKFehlbergobject).Youcanthen compare thenumberof timestepswithwhat is requiredby theothermethods. Filename:ground_temp_adaptive.py. Exercise5.5: Investigate the rule a) The Crank-Nicolsonmethod for ODEs is very popular when combined with diffusionequations. For a linearODEu0 Dau it reads unC1 un t D 1 2 .aunCaunC1/: 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"
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