Seite - 128 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python
Bild der Seite - 128 -
Text der Seite - 128 -
128 4 SolvingOrdinaryDifferentialEquations
getu1 D2,v1 D 1:25663706,u2 D1:80260791, andv2 D 2:51327412. Such
calculations show that the program is seemingly correct. (Later, we can use such
values toconstruct aunit test andacorrespondingtest function.)
Thenext step is to reduce the discretization parameter t and see if the results
becomemore accurate. Figure 4.17 shows the numerical and exact solution for
the cases t D P=40;P=160;P=2000. The results clearly become better, and
the finest resolution gives graphs that cannot be visually distinguished. Neverthe-
less, the finest resolution involves 6000 computational intervals in total, which is
considered quitemuch. This is no problemon amodern laptop, however, as the
computations take just a fractionofa second.
Although 2000 intervals per oscillation period seem sufficient for an accurate
numerical solution, the lower rightgraph inFig. 4.17 shows that ifwe increase the
simulation time, here to20periods, there is a little growthof the amplitude,which
becomes significant over time. The conclusion is that the Forward Eulermethod
has a fundamental problemwith its growing amplitudes, and that a very small t
is required to achieve satisfactory results. The longer the simulation is, the smaller
t has tobe. It is certainly time to lookformoreeffectivenumericalmethods!
Fig.4.17 Simulation of an oscillating systemwith different time steps. Upper left: 40 steps per
oscillation period. Upper right: 160 steps per period. Lower left: 2000 steps per period. Lower
right: 2000 stepsperperiod, but longer simulation
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