Seite - 175 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python
Bild der Seite - 175 -
Text der Seite - 175 -
5.1 FiniteDifferenceMethods 175
time, is thevisualizationon the screen, but for that purposeonecanvisualize only
a subset of the time steps. However, there are occasions when you need to take
larger time steps with the diffusion equation, especially if interest is in the long-
termbehavioras t !1. Youmust then turn to implicit methods forODEs. These
methodsrequire thesolutionsof linearsystems, if theunderlyingPDEis linear, and
systemsofnonlinearalgebraic equations if theunderlyingPDEisnon-linear.
The simplest implicitmethod is theBackwardEuler scheme,whichputs no re-
strictions on t for stability, but obviously, a large t leads to inaccurate results.
TheBackwardEuler schemefora scalarODEu0 Df.u;t/ reads
unC1 un
t Df.unC1;tnC1/:
This equation is to be solved forunC1. Iff is linear inu, it is a linear equation,
but iff is nonlinear inu, oneneedsapproximatemethods for nonlinear equations
(Chap.6).
Inourcase,wehaveasystemof linearODEs(5.9)–(5.11).TheBackwardEuler
schemeapplied toeachequation leads to
unC10 un0
t D s0.tnC1/; (5.16)
unC1i uni
t D ˇ
x2 .unC1iC1 2unC1i CunC1i
1 /Cgi.tnC1/; (5.17)
i D1;:: :;N 1;
unC1N unN
t D 2ˇ
x2 .unC1N
1 unC1N /Cgi.tnC1/: (5.18)
This is a systemof linear equations in the unknownsunC1i , i D 0;:: :;N , which
is easy to realize bywriting out the equations for the caseN D 3, collecting all
theunknowntermson the left-handsideandall theknowntermson the right-hand
side:
unC10 Dun0 C ts0.tnC1/; (5.19)
unC11 t ˇ
x2 .unC12 2unC11 CunC10 /Dun1 C tg1.tnC1/; (5.20)
unC12 t 2ˇ
x2 .unC11 unC12 /Dun2 C tg2.tnC1/: (5.21)
Asystemof linearequations like this, isusuallywrittenonmatrixformAuDb,
whereA is a coefficientmatrix,u D .unC10 ;: : :;nnC1N / is the vector of unknowns,
andb is avectorofknownvalues. Thecoefficientmatrix for thecase (5.19)–(5.21)
becomes
AD 0
B
@ 1 0 0
t ˇ
x2 1C2 t ˇ
x2 t ˇ
x2
0 t 2ˇ
x2 1C t 2ˇ
x2 1
C
A
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