Seite - 137 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python
Bild der Seite - 137 -
Text der Seite - 137 -
4.3 OscillatingOne-DimensionalSystems 137
Fig.4.22 Illustrationof the impact of resolution (timestepsperperiod) and lengthof simulation
right). However, after 194–200periods the errors havegrown (lower left), but can
besufficiently reducedbyhalving the timestep (lower right).
With all themethods inOdespy at hand, it is noweasy to start exploring other
methods, such as backward differences instead of the forward differences used in
theForwardEuler scheme. Exercise4.17addresses thatproblem.
Odespy contains quite sophisticated adaptivemethodswhere the user is “guar-
anteed” toget a solutionwith prescribedaccuracy. There is nomathematical guar-
antee, but the error will for most cases not deviate significantly from the user’s
tolerance that reflects the accuracy. A very popular method of this type is the
Runge-Kutta-Fehlbergmethod, which runs a 4th-order Runge-Kuttamethod and
uses a 5th-orderRunge-Kuttamethod to estimate the error so that t can be ad-
justed to keep the error below a tolerance. Thismethod is alsowidely known as
ode45, because that is the nameof the function implementing themethod inMat-
lab. Wecan easily test theRunge-Kutta-Fehlbergmethod as soon asweknow the
correspondingOdespyname,which isRKFehlberg:
compare(odespy_methods=[odespy.EulerCromer, odespy.RKFehlberg],
omega=2, X_0=2, number_of_periods=200,
time_intervals_per_period=40)
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