Seite - 297 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition
Bild der Seite - 297 -
Text der Seite - 297 -
9.2 FiniteDifferenceMethods 297
Fig. 9.1 Unstable simulation of the temperature in a rod
The -i option specifies the naming of the plot files, and -r specifies the number
of frames per second in the movie. On Mac, run ffmpeg instead of avconvwith
the same options. Other video formats, such as MP4, WebM, and Ogg can also be
produced:
Terminal
Terminal> ffmpeg -i tmp_%04d.png -r 4 -vcodec libx264 movie.mp4
Terminal> ffmpeg -i tmp_%04d.png -r 4 -vcodec libvpx movie.webm
Terminal> ffmpeg -i tmp_%04d.png -r 4 -vcodec libtheora movie.ogg
An Unstable Solution The results of a simulation start out as seen from the
two snapshots in Fig.9.1. We see that the solution definitely looks wrong. The
temperature is expected to be smooth, not having such a saw-tooth shape. We
say that this solution is unstable, meaning that it does not display the same
characteristics as the true, physical solution. Even though we tested the code
carefullyin theprevioussection, itdoesnotseemtoworkforaphysicalapplication!
Why Is the Solution Unstable? The problem is thatΔt is too large, making the
solutionunstable. It turnsout that theForwardEuler time integrationmethodputsa
restrictionon thesize ofΔt. For theheat equationand the way we havediscretized
it, this restrictioncanbeshowntobe [14]
Δt≤ Δx 2
2β . (9.15)
Thisiscalledastabilitycriterion.Withthechosenparameters,(9.15)tellsusthat the
upper limit isΔt =0.9527439,which is smaller thanour choiceabove.Rerunning
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