Web-Books
in the Austria-Forum
Austria-Forum
Web-Books
Informatik
Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition
Page - 292 -
  • User
  • Version
    • full version
    • text only version
  • Language
    • Deutsch - German
    • English

Page - 292 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition

Image of the Page - 292 -

Image of the Page - 292 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition

Text of the Page - 292 -

292 9 SolvingPartialDifferentialEquations ThisapproximationinvolvesafictitiouspointxN+1 outside thedomain.Acommon trick is to use (9.7) for i =N and eliminateuN+1 by use of the discrete boundary condition(uN+1 =uN−1): duN(t) dt =β2uN−1(t)−2uN(t) Δx2 +gN(t). (9.8) That is, we haveaspecialversionof (9.7)at theboundary i=N. Whataboutsimpler finitedifferencesat theboundary? Some reader may think that a smarter trick is to approximate the boundary condition∂u/∂x atx=Lbya one-sideddifference: ∂u ∂x ∣ ∣ ∣ ∣ i=N ≈ uN −uN−1 Δx =0 . This gives a simple equation uN = uN−1 for the boundary value, and a corresponding ODEu′N = u′N−1. However, this approximation has an error oforderΔx,while thecenteredapproximationwe usedabovehasan errorof orderΔx2. The finite differenceapproximationwe used for the second-order derivative in the diffusion equation also has an error of orderΔx2. Thus, if weuse thesimplerone-sideddifferenceabove, it turnsout thatwe reduce the overallaccuracyof themethod. We are now in a position to summarize how we can approximate the PDE problem(9.1)–(9.4)bya systemofordinarydifferentialequations: du0 dt = s′(t), (9.9) dui dt = β Δx2 (ui+1(t)−2ui(t)+ui−1(t))+gi(t), i=1,.. .,N−1, (9.10) duN dt = 2β Δx2 (uN−1(t)−uN(t))+gN(t). (9.11) The initial conditionsare u0(0)= s(0), (9.12) ui(0)= I(xi), i=1,.. .,N . (9.13) We canapplyanymethodfor systemsofODEs tosolve (9.9)–(9.11).
back to the  book Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition"
Programming for Computations – Python A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition
Title
Programming for Computations – Python
Subtitle
A Gentle Introduction to Numerical Simulations with Python 3.6
Volume
Second Edition
Authors
Svein Linge
Hans Petter Langtangen
Publisher
Springer Open
Date
2020
Language
English
License
CC BY 4.0
ISBN
978-3-319-32428-9
Size
17.8 x 25.4 cm
Pages
356
Keywords
Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
Category
Informatik
Web-Books
Library
Privacy
Imprint
Austria-Forum
Austria-Forum
Web-Books
Programming for Computations – Python