Seite - 170 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python
Bild der Seite - 170 -
Text der Seite - 170 -
170 5 SolvingPartialDifferentialEquations
The plotting statements update the u.x;t/ curve on the screen. In addi-
tion, we save a fraction of the plots to files tmp_0000.png, tmp_0001.png,
tmp_0002.png, and so on. These plots can be combined to ordinary video files.
Acommontool isffmpegor its sisteravconv.
These programs take the same typeof command-lineoptions. TomakeaFlash
videomovie.flv, run
Terminal
Terminal> ffmpeg -i tmp_%04d.png -r 4 -vcodec flv movie.flv
The-ioptionspecifies thenamingof theplotfiles inprintf syntax,and-rspecifies
the number of frames per second in themovie. OnMac, run ffmpeg instead of
avconvwith thesameoptions.Othervideoformats, suchasMP4,WebM,andOgg
canalsobeproduced:
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
Theresultsofasimulation start outas inFigs. 5.1and5.2.Wesee that thesolu-
tiondefinitely lookswrong. The temperature is expected tobe smooth, not having
such a saw-tooth shape. Also, after some time (Fig. 5.2), the temperature starts to
increasemuchmore than expected. We say that this solution isunstable,meaning
that it doesnotdisplay the samecharacteristics as the true, physical solution. Even
thoughwetested thecodecarefully intheprevioussection, itdoesnotseemtowork
foraphysicalapplication!Howcan thatbe?
The problem is that t is too large,making the solution unstable. It turns out
that theForwardEuler time integrationmethodputsa restrictionon the sizeof t.
For the heat equation and the waywe have discretized it, this restriction can be
showntobe [15]
t x 2
2ˇ : (5.15)
This is called a stability criterion. With the chosenparameters, (5.15) tells us that
the upper limit is t D 0:0003125, which is smaller than our choice above. Re-
runningthecasewitha t equal to x2=.2ˇ/, indeedshowsasmoothevolutionof
u.x;t/. Find theprogramrod_FE.pyand run it to see ananimationof theu.x;t/
functionon thescreen.
Scalinganddimensionlessquantities
Our settingof parameters requiredfinding threephysical propertiesof a certain
material. The time interval for simulationand the timestepdependcruciallyon
thevaluesforˇandL,whichcanvarysignificantlyfromcase tocase.Often,we
aremore interested inhowtheshapeofu.x;t/develops, than in theactualu,x,
and t values for a specificmaterial.Wecan thensimplify the settingofphysical
parametersby scaling theproblem.
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