Seite - 300 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition
Bild der Seite - 300 -
Text der Seite - 300 -
300 9 SolvingPartialDifferentialEquations
Fig. 9.2 Time steps used by the Runge-Kutta-Fehlberg method: error tolerance 10−3 (left) and
10−6 (right)
step.Abovewe indicatedhowtouse theadaptiveRunge-Kutta-Fehlberg4-5solver.
While theΔt correspondingto the Forward Euler method requiresover 8000steps
for a simulation, we started theRKFehlbergmethod with 100 times this time step
and in the end it required just slightly more than 2500 steps, using the default
tolerance parameters. Lowering the tolerance did not save any significant amount
ofcomputationalwork.Figure 9.2 showsa comparisonof the lengthofall the time
steps for two values of the tolerance. We see that the influence of the tolerance is
minor in this computationalexample, so it seems that theblow-updue to instability
iswhatgovernsthetimestepsize.Thenicefeatureofthisadaptivemethodis thatwe
can just specifywhenwewant the solution to becomputed,and themethodfigures
outon itsownwhat time step thathas tobeusedbecauseof stability restrictions.
Wehaveseenhoweasyit is toapplysophisticatedmethodsforODEstothisPDE
example.We shall take theuse ofOdespyonestep further in the nextsection.
9.2.7 ImplicitMethods
A major problem with the stability criterion (9.15) is that the time step becomes
very small if Δx is small. For example, halving Δx requires four times as many
time steps and eight times the work. Now, with N = 40, which is a reasonable
resolution for the test problem above, the computations are very fast. What takes
time, is the visualization on the screen, but for that purpose one can visualize only
a subset of the time steps. However, there are occasions when you need to take
larger time steps with the diffusion equation, especially if interest is in the long-
term behavioras t →∞. You must then turn to implicit methods for ODEs. These
methodsrequire thesolutionsof linearsystems, if theunderlyingPDEis linear,and
systemsofnonlinearalgebraicequations if theunderlyingPDE isnon-linear.
The simplest implicit method is the Backward Euler scheme, which puts no
restrictionsonΔt for stability, butobviously,a largeΔt leads to inaccurate results.
TheBackwardEuler schemeforascalar ODEu′ =f(u,t) reads
un+1 −un
Δt =f(un+1,tn+1).
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