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

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

Bild der Seite - 165 -

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

Text der Seite - 165 -

5.1 FiniteDifferenceMethods 165 Weremark that a separateODE for the (known)boundaryconditionu0 D s.t/ is not strictly needed.Wecan justworkwith theODEsystem foru1;:: :;uN, and in theODEforu0, replaceu0.t/by s.t/. However, these authorsprefer tohavean ODEforeverypointvalueui, i D0;:: :;N ,whichrequiresformulatingtheknown boundaryatxD0asanODE.Thereason for including theboundaryvalues in the ODE system is that the solution of the system is then the complete solution at all meshpoints,which is convenient, since special treatmentof theboundaryvalues is thenavoided. The condition @u=@x D 0 at x D L is a bit more complicated, but we can approximate thespatial derivativebyacenteredfinitedifference: @u @x ˇ ˇ ˇ ˇ iDN uNC1 uN 1 2 x D0: ThisapproximationinvolvesafictitiouspointxNC1outside thedomain.Acommon trick is to use (5.7) for i DN andeliminateuNC1byuseof thediscreteboundary condition (uNC1 DuN 1): duN.t/ dt Dˇ2uN 1.t/ 2uN.t/ x2 CgN.t/: (5.8) That is,wehaveaspecial versionof (5.7)at theboundary i DN . Whataboutsimplerfinitedifferencesattheboundary? Somereadermay think that a smarter trick is to approximate theboundarycon- dition@u=@x atxDLbyaone-sideddifference: @u @x ˇ ˇ ˇ ˇ iDN uN uN 1 x D0: This gives a simple equationuN D uN 1 for the boundaryvalue, and a corre- spondingODEu0N Du0N 1. However, this approximationhas anerror of order x,while thecenteredapproximationweusedabovehasanerroroforder x2. The finite difference approximationwe used for the second-order derivative in the diffusion equation also has an error of order x2. Thus, ifweuse the sim- pler one-sideddifferenceabove, it turnsout thatwe reduce theoverall accuracy of themethod. We are now in a position to summarize howwe can approximate the partial differential equationproblem(5.1)–(5.4)byasystemofordinarydifferential equa- tions: du0 dt D s0.t/; (5.9) dui dt D ˇ x2 .uiC1.t/ 2ui.t/Cui 1.t//Cgi.t/; i D1;:: :;N 1; (5.10) duN dt D 2ˇ x2 .uN 1.t/ uN.t//CgN.t/: (5.11)
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