Web-Books
im Austria-Forum
Austria-Forum
Web-Books
Informatik
Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python
Seite - 174 -
  • Benutzer
  • Version
    • Vollversion
    • Textversion
  • Sprache
    • Deutsch
    • English - Englisch

Seite - 174 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Bild der Seite - 174 -

Bild der Seite - 174 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Text der Seite - 174 -

174 5 SolvingPartialDifferentialEquations Fig.5.4 Time steps used by theRunge-Kutta-Fehlbergmethod: error tolerance 10 3 (left) and 10 6 (right) # Check how many time steps are required by adaptive vs # fixed-step methods if hasattr(solver, ’t_all’): print ’# time steps:’, len(solver.t_all) else: print ’# time steps:’, len(t) The very nice thing is that we can now easily experimentwithmany different integrationmethods. Tryingout some simple onesfirst, likeRK2 andRK4, quickly reveals that the time step limitation of the Forward Euler scheme also applies to thesemore sophisticatedRunge-Kuttamethods, but their accuracy is better. How- ever, theOdespypackageoffersalsoadaptivemethods.Wecanthenspecifyamuch larger time step in time_points, and the solver will figure out the appropriate step.AboveweindicatedhowtousetheadaptiveRunge-Kutta-Fehlberg4–5solver. While the t corresponding to theForwardEulermethod requiresover8000steps for a simulation,westarted theRKFehlbergmethodwith 100 times this timestep and in the end it required just slightlymore than 2500 steps, using the default tol- erance parameters. Lowering the tolerance did not save any significant amount of computationalwork. Figure 5.4 shows a comparison of the length of all the time stepsfortwovaluesofthetolerance.Weseethattheinfluenceofthetoleranceismi- nor in this computationalexample, so it seems that theblow-updue to instability is whatgoverns the timestep size. Thenice featureof this adaptivemethod is thatwe can just specifywhenwewant thesolution tobecomputed,and themethodfigures outon its ownwhat timestep thathas tobeusedbecauseof stability restrictions. We have seen how easy it is to apply sophisticatedmethods for ODEs to this PDEexample.Weshall take theuseofOdespyonestep further in thenext section. 5.1.7 ImplicitMethods Amajor problemwith the stability criterion (5.15) is that the time step becomes very small if x is small. For example, halving x requires four times asmany time steps and eight times thework. Now, withN D 40, which is a reasonable resolution for the test problemabove, the computations are very fast. What takes
zurück zum  Buch Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python"
Programming for Computations – Python A Gentle Introduction to Numerical Simulations with Python
Titel
Programming for Computations – Python
Untertitel
A Gentle Introduction to Numerical Simulations with Python
Autoren
Svein Linge
Hans Petter Langtangen
Verlag
Springer Open
Datum
2016
Sprache
englisch
Lizenz
CC BY-NC 4.0
ISBN
978-3-319-32428-9
Abmessungen
17.8 x 25.4 cm
Seiten
248
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