Page - 308 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition
Image of the Page - 308 -
Text of the Page - 308 -
308 9 SolvingPartialDifferentialEquations
∂u/∂x = 0. Reformulate the problem in Exercise 9.6 such that we compute only
forx ∈ [0,1]. Display the solution and observe that it equals the right part of the
solution inExercise9.6.
Filename:symmetric_gaussian_diffusion.py.
Remarks In 2D and 3D problems, where the CPU time to compute a solution of
PDEcanbehoursanddays, it isvery important toutilizesymmetryaswedoabove
to reduce thesize of theproblem.
Also note the remarks in Exercise 9.6 about the constant area under theu(x,t)
curve: here, the area is 0.5 and u → 0.5 as t → 0.5 (if the mesh is sufficiently
fine—onewill get convergenceto smaller values for smallσ if the mesh is not fine
enoughtoproperlyresolvea thin-shapedinitial condition).
Exercise9.9:ComputeSolutionsas t→∞
Many diffusion problems reach a stationary time-independent solution as t →∞.
The model problem from Sect.9.2.4 is one example whereu(x,t)= s(t)= const
for t→∞.Whenudoesnotdependon time, thediffusionequationreduces to
−βu′′(x)=f(x),
inonedimension,and
−β∇2u=f(x),
in 2D and 3D. This is the famous Poisson equation, or iff = 0, it is known as the
Laplaceequation. In this limit t→∞, there is noneed foran initial condition,but
theboundaryconditionsare thesameas for thediffusionequation.
We nowconsidera one-dimensionalproblem
−u′′(x)=0, x∈ (0,L), u(0)=C, u′(L)=0, (9.38)
which is known as a two-point boundary value problem. This is nothing but the
stationary limit of the diffusion problem in Sect.9.2.4. How can we solve such a
stationaryproblem(9.38)?Thesimplest strategy,whenwealreadyhaveasolver for
the corresponding time-dependentproblem, is to use that solver and simulate until
t → ∞, which in practice means that u(x,t) no longer changes in time (within
some tolerance).
A nice feature of implicit methods like the Backward Euler scheme is that one
can takeonevery long time step to“infinity”andproducethesolutionof (9.38).
a) Let (9.38)bevalidatmeshpointsxi inspace,discretizeu′′ byafinitedifference,
and set up a system of equations for the point valuesui,i= 0,.. .,N, whereui
is theapproximationat meshpointxi.
b) Showthat ifΔt→∞ in (9.16)–(9.18), it leads to thesame equationsas in a).
c) Demonstrate, by running a program, that you can take one large time step with
the Backward Euler scheme and compute the solution of (9.38).The solution is
veryboringsince it is constant:u(x)=C.
Filename:rod_stationary.py.
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