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

Seite - 143 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Bild der Seite - 143 -

Bild der Seite - 143 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Text der Seite - 143 -

4.3 OscillatingOne-DimensionalSystems 143 Anymethod for a systemoffirst-orderODEscanbeused to solve foru.t/ and v.t/. The Euler-Cromer scheme An attractive choice from an implementational, ac- curacy, and efficiency point of view is the Euler-Cromer schemewhere we take a forwarddifference in (4.68)andabackwarddifference in (4.69): vnC1 vn t D 1 m .F.tn/ s.un/ f.vn//; (4.70) unC1 un t DvnC1; (4.71) Wecaneasily solve for thenewunknownsvnC1 andunC1: vnC1 DvnC t m .F.tn/ s.un/ f.vn//; (4.72) unC1 DunC tvnC1 : (4.73) RemarkontheorderingoftheODEs The ordering of the ODEs in the ODE system is important for the extended model (4.68)–(4.69). Imagine thatwewrite theequationforu0first and then the one forv0. TheEuler-Cromermethodwould thenfirst use a forwarddifference for unC1 and then a backward difference for vnC1. The latter would lead to anonlinearalgebraicequation forvnC1, vnC1C t m f.vnC1/DvnC t m F.tnC1/ s.unC1/ ; iff.v/ is anonlinear functionofv. Thiswould requireanumericalmethod for nonlinear algebraic equations to find vnC1, while updatingvnC1 through a for- ward difference gives an equation forvnC1 that is linear and trivial to solve by hand. Thefileosc_EC_general.pyhasafunctionEulerCromerthat implementsthis method: def EulerCromer(f, s, F, m, T, U_0, V_0, dt): from numpy import zeros, linspace N_t = int(round(T/dt)) print ’N_t:’, N_t t = linspace(0, N_t*dt, N_t+1) u = zeros(N_t+1) v = zeros(N_t+1) # Initial condition u[0] = U_0 v[0] = V_0
zurück zum  Buch Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python"
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
Web-Books
Bibliothek
Datenschutz
Impressum
Austria-Forum
Austria-Forum
Web-Books
Programming for Computations – Python