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

Page - 164 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Image of the Page - 164 -

Image of the Page - 164 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Text of the Page - 164 -

164 5 SolvingPartialDifferentialEquations to reduce the partial differential equation to ordinary differential equations. One important technique for achieving this, is based on finite difference discretization of spatial derivatives. 5.1.1 ReductionofaPDEtoaSystemofODEs Introducea spatialmesh in˝withmesh points x0 D0<x1 <x2 < <xN DL: The space between twomeshpointsxi andxiC1, i.e. the interval Œxi;xiC1 , is call a cell. We shall here, for simplicity, assume that each cell has the same length xDxiC1 xi, i D0;:: :;N 1. Thepartial differential equation is valid at all spatial pointsx 2˝, butwemay relax this condition anddemand that it is fulfilled at the internalmeshpoints only, x1;:: :;xN 1: @u.xi;t/ @t Dˇ@ 2u.xi;t/ @x2 Cg.xi;t/; i D1;:: :;N 1: (5.5) Now, at any point xi we can approximate the second-order derivative by a finite difference: @2u.xi;t/ @x2 u.xiC1;t/ 2u.xi;t/Cu.xi 1;t/ x2 : (5.6) It is commonto introduceashortnotationui.t/ foru.xi;t/, i.e.,uapproximatedat somemesh pointxi in space. With this newnotationwe can, after inserting (5.6) in (5.5), write an approximation to the partial differential equation atmesh point .xi;t) as dui.t/ dt DˇuiC1.t/ 2ui.t/Cui 1.t/ x2 Cgi.t/; i D1;:: :;N 1: (5.7) Note thatwehaveadopted thenotationgi.t/ forg.xi;t/ too. What is (5.7)? This is nothingbut a system of ordinary differential equations in N 1unknownsu1.t/;: : : ;uN 1.t/! In otherwords,with aid of thefinite differ- ence approximation (5.6), we have reduced the single partial differential equation toasystemofODEs,whichweknowhowtosolve. In the literature, this strategy is called themethod of lines. Weneedto lookinto the initial andboundaryconditionsaswell. Theinitialcon- ditionu.x;0/D I.x/ translates to an initial condition for everyunknownfunction ui.t/: ui.0/ D I.xi/, i D 0;:: :;N . At the boundaryx D 0weneed anODE in ourODEsystem,whichmust comefromtheboundaryconditionat thispoint. The boundaryconditionreadsu.0;t/D s.t/.WecanderiveanODEfromthisequation bydifferentiatingbothsides:u00.t/D s0.t/. TheODEsystemabovecannotbeused foru00 since that equation involves somequantityu 0 1 outside thedomain. Instead, we use the equationu00.t/ D s0.t/ derived from the boundary condition. For this particular equationwealsoneed tomake sure the initial condition isu0.0/D s.0/ (otherwisenothingwill happen:wegetuD283Kforever).
back to the  book Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python"
Programming for Computations – Python A Gentle Introduction to Numerical Simulations with Python
Title
Programming for Computations – Python
Subtitle
A Gentle Introduction to Numerical Simulations with Python
Authors
Svein Linge
Hans Petter Langtangen
Publisher
Springer Open
Date
2016
Language
English
License
CC BY-NC 4.0
ISBN
978-3-319-32428-9
Size
17.8 x 25.4 cm
Pages
248
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