Professional Documents
Culture Documents
Numerical Solution of Partial Differential Equations (Pdes)
Numerical Solution of Partial Differential Equations (Pdes)
dy ∂U ∂U 2
= −5 y = −10 2
dt Initial condition ∂t ∂x
is a function
y (t0 ) = y0 ⎡π x ⎤
U ( x, t = t0 ) = sin ⎢ ⎥
⎣ 3 ⎦
ODEs: Initial condition is a
number (scalar ODE), or U ( x = 0, t ) = 0
set of numbers (ODE system)
U ( x = 3, t ) = exp( −7t )
PDEs are almost always
Boundary conditions
harder to solve than ODEs (also functions)
Partial differential eqns (PDEs)
General 2nd
order PDE with
2 independent
variables
3 main categories
of PDEs
k (“conductivity”)
x is a property of the
material
∂U ∂ 2U
= −k 2 Some applications:
Conditions
at which
∂t ∂x * Transient groundwater flows
the material U ( x, t = t0 ) = f ( x ) * Mixing processes in chemical
is initially, engineering
or will be U ( x = 0, t ) = g (t )
subjected to
U ( x = L, t ) = h(t )
Boundary-value (“elliptic”) PDE problems
Ordinary differential
Boundary conditions
equation
∂U ∂U
2 2
+ 2 = f ( x, y ); U ( Γ) = g ( x, y )
∂x 2
∂y
Usually describes the
steady-state distribution of
a quantity through space
Some applications:
* Steady-state groundwater flows
* Loaded beams/foundations in structures
Analytical (exact) solutions
Exact solutions almost always preferable …
… but are very rarely available for PDEs
∂U
= − kU
∂t U (t ) = U 0 exp( − Kt )
U (t = 0) = U 0
Strong analogies between initial-
value ODE and PDE problems,
but PDE’s are much harder
∂U ∂ 2U
= −k 2
∂t ∂x
U ( x, t ) = sin( x ) exp( − Kt )
U ( x, t = 0) = sin( x )
U ( x = 0, t ) = U ( x = 1, t ) = 0 In many cases analytical solution
of PDEs is not possible
Approximate numerical solutions
Recall that numerical ODE solution required approximating a
continuous solution by discrete points
y
y(t)
y0 1) Discretization
2) Approximation
t0 t
Approximate numerical solutions
Same concepts apply to PDE approximation, but in more dimensions
y Ui,j ≈ U(xi , yj)
j
U(x,y)
i, j+1
x i-1, j i+1, j
Replace a continuous
i, j
domain by a grid
i, j-1
Solve for solution
values on the grid
i
Numerical approximation of initial-value
(“parabolic”) PDE problems
Original continuous
solution of the PDE
Discrete approximation of
the solution of the PDE
∂U ∂ 2U
= −k 2
∂t ∂x
U ( x, t = t0 ) = f ( x )
U ( x = 0, t ) = g (t )
U ( x = L, t ) = h(t )
Potential problems with PDE
approximations (“instability”)
Uncontrolled error growth
or oscillations are
is a particular concern when
solving PDEs
U More common problem than in
ODE approximations
Numerical PDE
t = t2
approximations should
be checked to ensure
approximation errors
t = t1
are adequately small
(often easier said than
t = t0
done! If we knew the
error we would have
x
exact solution!)
Initial-value
(“parabolic”) PDEs
Computational mesh (‘discretization’)
“time” n
i, n+1
n +1
i, n-1
U i
Spatial node index
“space” i
Explicit-central approximation
∂U ∂ 2U
Forward difference = −k Central finite
approximation to ∂t ∂x 2 difference
∂U/ ∂t – relative to
time-level tn approximation
to ∂2U/ ∂x2 at
time-level tn
U in +1 − U in U in−1 − 2U in − U in+1
= k
Δt Δx 2
Explicit = forward
(different name,
Re-arrange
same thing)
Δt
U n +1
= U − k 2 ⎡⎣U in−1 − 2U in + U in+1 ⎤⎦
n
Δx
i i
Explicit-central scheme
“time” n
Δt
Uin+1 = Uin − k ⎡
2 ⎣
U n
−1 − 2U n
+ U n
+1 ⎤
⎦
Δx
i i i
Boundary
Boundaryconditions
conditions
must be known
Keep “stepping” thru
time, updating an entire
“time level” before
proceeding to the next
n → n +1
Initial conditions (“initial
“space” i profile”) must be known
How does the resolution
(temporal and spatial) affect the
approximation error?
Error of forward-central approximation
∂U ∂ 2U Central finite difference
= −k 2 approximation to ∂2U/ ∂x2
∂t ∂x
U = U (t , xi ) + error
i
n n
error ≈ C1Δt + C2 Δx 2
U in +1 − U in U in−1 − 2U in − U in+1
=k
Δt Δx 2
Approximation Approximation
error arising error arising
from time- from space-
Forward finite difference discretization, discretization,
approximation to ∂U/ ∂t O(Δt) O(Δx2)
PDE “stiffness”
Potential problems with PDE
approximations Uncontrolled error growth
(“instability”) or oscillations are
is a particular concern when
solving PDEs
U
x
Exact solution decays
“Stiffness” U with time, but explicit
approximation is unstable
∂U ∂U 2
= −k 2
∂t ∂x
U in +1 − U in U in−1 − 2U in − U in+1
=k
Δt Δx 2 x
The forward (explicit) scheme
U → ±∞ as n → ∞
i
n
is conditionally stable:
if Δt > Δx 2 / 2k If Δt exceeds a certain limit,
the scheme becomes unstable
Forward-central scheme does and ‘blows up’ (produces
not preserve exponential meaningless results)
decline of exact solution
1) Use smaller time steps? Overcoming “stiffness”:
Works sometimes, but ODE analogy
may not be practical
2) Use a “stiff” (implicit) y
solver (preferred)
dU
Equation to be
solved = − kU
dt
t
n +1 “Small” change, but
U −U n
totally different
Explicit Euler
approximation = −kU n
Δt numerical behaviour
∂U ∂ 2U t
dU
= kU =k 2
dt ∂t ∂x
Re-arrange
j
∂T ∂T
2 2
+ 2 =0
∂x 2
∂y
x and y are space
coordinates
i
Defines a linear
1
Ti , j = ( Ti −1, j −1 + Ti −1, j +1 + Ti +1, j −1 + Ti +1, j +1 )
relationship between
unknown solution
4 values at the nodes
1 K
T K +1
i, j = ( Ti −1, j −1 + Ti −K1, j +1 + Ti +K1, j −1 + Ti +K1, j +1 ) Iteration index (DO
4 NOT confuse with
time level!)
Spatial K +1
Iterate until Ti , j ≈ Ti , j
K
location index
Laplace equation
j
∂T ∂T
2 2
+ 2 =0
∂x 2
∂y
x and y are space
coordinates
i
1 K
T K +1
i, j = (Ti −1, j −1 + Ti −K1, j +1 + Ti +K1, j −1 + Ti +K1, j +1 ) Unlike initial-value
4 PDEs, where solution
progressed level-by-
level, elliptic PDEs
K +1
Iterate until Ti , j ≈ Ti , j
K
need to be solved
simultaneously over
entire domain
Fundamental differences
between solving
initial- vs boundary-value
differential equations
Initial-value (time-dependent) PDEs Boundary-value (space-dependent) PDEs
n
j
i i
∂U ∂ 2U ∂U ∂U
2 2
= −k 2 + 2 =0
∂t ∂x ∂x 2
∂y
Δt
U n +1
= U − k 2 ⎡⎣U in−1 − 2U in + U in+1 ⎤⎦ U iK, j+1 = 1 (U iK−1, j −1 + U iK−1, j +1 + U iK+1, j −1 + U iK+1, j +1 )
n
Δx
i i
4
∂U ∂U 2
∂U 2
= −k 2 0= 2
∂t ∂x ∂x
Parabolic PDE in 1D space Boundary-value ODE
t→∞
∂U ∂ U ∂ U 2 2
∂U ∂U2 2
= 2 + 2 0= 2 + 2
∂t ∂x ∂y ∂x ∂y
Parabolic PDE in 2D space Boundary-value PDE (2D)
Irregular domains (intro)
Finite-differences vs finite-elements
Finite-difference
approximation Finite-element
(forces a regular approximation
Actual system grid unto an (more suitable for
irregular system!) complex systems)
END OF PDE SECTION