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

Seite - 243 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition

Bild der Seite - 243 -

Bild der Seite - 243 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition

Text der Seite - 243 -

8.4 Oscillating1DSystems:ASecondOrderODE 243 Fig. 8.19 Simulation ofan oscillating system First of all, even before trying to run the program, you should sit down and computetwosteps in the timeloopwithacalculatorsoyouhavesomeintermediate results to compare with. Using X0 = 2, dt = 0.157079632679, and ω = 2, we getu1 = 2,v1 =−1.25663706,u2 = 1.80260791,andv2 =−2.51327412.Such calculations show that the program is seemingly correct. (Later, we can use such values to constructaunit test anda correspondingtest function.) The next step is to reduce the discretization parameterΔt and see if the results become more accurate. Figure 8.20 shows the numerical and exact solution for the casesΔt=P/40,P/160,P/2000.Theresultsclearlybecomebetter,andthefinest resolutiongivesgraphsthatcannotbevisuallydistinguished.Nevertheless,thefinest resolution involves6000computational intervals in total, which is consideredquite much. This is no problem on a modern laptop, however, as the computations take just a fractionofasecond. Although 2000 intervals per oscillation period seem sufficient for an accurate numerical solution, the lower right graph in Fig. 8.20 shows that if we increase the simulation time, here to 20 periods, there is a little growth of the amplitude,which becomessignificantovertime.Theconclusionis that theForwardEulermethodhas a fundamental problem with its growing amplitudes, and that a very small Δt is requiredtoachievesatisfactory results.The longer thesimulation is, thesmallerΔt has tobe. It is certainly time to lookformoreeffectivenumericalmethods! 8.4.4 AMagicFixoftheNumericalMethod In the ForwardEuler scheme, un+1 =un+Δtvn, vn+1 =vn−Δtω2un,
zurück zum  Buch Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition"
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
Web-Books
Bibliothek
Datenschutz
Impressum
Austria-Forum
Austria-Forum
Web-Books
Programming for Computations – Python