Sie sind auf Seite 1von 35

Numerical Methods for PDEs

Spring 2007

Jim E. Jones
Computational Science and Engineering
Seminar Series

Fridays Time: TBD


Computational Science and Engineering
CS&E is a broad multidisciplinary area that encompasses
applications in science/engineering, applied mathematics,
numerical analysis, and computer science. Computer models
and computer simulations have become an important part of the
research repertoire, supplementing (and in some cases
replacing) experimentation. Going from application area to
computational results requires domain expertise, mathematical
modeling, numerical analysis, algorithm development, software
implementation, program execution, analysis, validation and
visualization of results. CS&E involves all of this.
Computational Science and Engineering is
inherently interdisciplinary

Applied Computer
Mathematics Science

Science
Engineering
Disciplines
Computational Science and Engineering is
inherently interdisciplinary

Applied Computer
Mathematics Science
CS&E

Science
Engineering
Disciplines
A CS&E example we will come back to later

• Simulating variably saturated flow is an important


tool for water resource management.
Jones & Woodward
Well 2000 & 2001
Seepage Pond

Ground

Water Table
Realistic simulation of variably saturated flow
requires many components
• Environmental Sciences: define physical problem,
determine parameters, mathematical modeling,
validation of results, …
• Applied Mathematics: mathematical modeling,
solution algorithms, error control, …
• Computer Science: efficient implementation of
algorithms, impact of computer architecture on
implementation and algorithm, …
PDEs, Grids, and Matrices
Many physical processes can be modeled with
Partial Differential Equations (PDEs)
Poisson Equation modeling steady-
state temperature in 2d plate H
  E  
t
u xx  u yy  f
E
 H    E
t
Wave Equation modeling wave Maxwell’s equations relating
propagation at speed v
electric and magnetic fields

1  2
  2 2
2

v t
Partial Differential Equations (PDEs) :
2nd order model problems
au xx  bu xy  cu yy  du x  eu y  fu  g
• PDE classified by discriminant: b2-4ac.
– Negative discriminant = Elliptic PDE. Example
Laplace’s equation
u xx  u yy  0

– Zero discriminant = Parabolic PDE. Example Heat


equation
ut  u xx  0

– Positive discriminant = Hyperbolic PDE. Example


Wave equation
u xx  utt  0
Richards’ equation is a common model for two-
phase air/water flow

s( p)  Kk ( p) 
    r p  gz   q
t   

p = pressure s(p) = water saturation


 = porosity  = density
t = time K = absolute permeability
kr(p) = relative permeability  = water viscosity
g = gravity q = water source/sink
Richards’ equation is a common model for two-
phase air/water flow

s( p)  Kkr ( p)  


    p  gz   q
t   

Simplifying:
s(p)=p, kr(p) and constants =1
 p 
   p  z   q
t
or
pt  pxx  g
Challenging features of Richards equation for
numerical simulation

• Statistical realization of the absolute permeability


field. Large jumps and very fine scale.
– Heterogeneity: amount of variation from point to point.
– Anisotropy: amount of variation from one direction to
the next.
• Nonlinearity in the diffusion term.
Solving PDEs on a computer typically involves
discretizing on a grid
Computers typically don’t understand continuous
quantities, only discrete ones.

Rather than asking for the


temperature as a function u(x,y),
we seek to find an approximation
to the temperature at each point
on a grid.
Discretization approximates the differential
problem by an algebraic one
u xx  u yy  f

Au  f
Finite difference discretization based on Taylor’s
approximation.
1
u xx ( x, y )  (u ( x  h, y )  2u ( x, y )  u ( x  h, y ))
h2
Finite difference discretization based on Taylor’s
approximation.
1
u xx ( x, y )  (u ( x  h, y )  2u ( x, y )  u ( x  h, y ))
h2

Approximated derivative at a
point by an algebraic equation
involving function values at
nearby points

By Taylor’s Theorem, the error


in this approximation (the
truncation error) is O(h2)
Finite difference discretization based on Taylor’s
approximation.
1
u xx  u yy  f h2
(u ( x  h, y )  u ( x, y  h)  4u ( x, y )  u ( x  h, y )  u ( x, y  h))  f ( x, y )

Equation for each grid point (x,y)

Au  f
Error in approximation is
determined by the mesh
size h. Difference between
differential solution and
algebraic solution goes to
zero as h does.
A Few details of the Richards equation
discretization used

• Time-stepping by implicit backward Euler.


u 1
 L(u )  (u t  u t 1 )  L(u t )
t t
• Finite difference approximations for spatial derivatives.
• First order upstream weighting for relative permeability terms.
• Harmonic averaging for absolute permeability.

K i K i 1
K 
K i  K i 1
1
i i+1
2 i
Richards’ equation is a common model for two-
phase air/water flow

s( p)  Kk ( p) 
    r p  gz   q
t   

p = pressure s(p) = water saturation


 = porosity  = density
t = time K = absolute permeability
kr(p) = relative permeability  = water viscosity
g = gravity q = water source/sink
Results in a coupled system of nonlinear
equations to be solved at each time step
s( p)  Kk ( p) 
    r p  gz   q
t   

F ( p)  0
Solution algorithms for the algebraic system in
the linear case
Au  f
• The linear system is very sparse
– Each grid point couples only to nearby neighbors.
– Number of non-zeros in A << n2, typically O(n).
• Option 1: Direct solvers (Gaussian elimination), very good
(parallel) codes exit, but for large problems can be too costly.
• Option 2: Iterative methods.
– “Classical methods”: Jacobi, Gauss-Seidel, SOR
– Krylov Methods: Conjugate Gradient, GMRES r  f  Auk
– Multigrid Methods
Solution algorithms for the algebraic system in
the nonlinear case
F (u )  0
• Recall single variable Newton’s Method via Taylor’s
approximation
f ( x)  f ( x0 )  f ( x0 )( x  x0 )

• Find zero of the right hand side


x  x0  f ( x0 ) / f ( x0 )

• Iterate
xk 1  xk  f ( xk ) / f ( xk )
Solution algorithms for the algebraic system in
the nonlinear case
F (u )  0
• Multivariate Newton
uk 1  uk  ( J (uk )) 1 F (uk )

• The Jacobian Matrix


J (u )i , j  Fi (u ) / u j
• For nonlinear systems coming from PDEs the Jacobian is
sparse.
For nonlinear problems solved by Newton, a
solver for the linear problem is needed

• Multivariate Newton
uk 1  uk  ( J (uk )) 1 F (uk )

• Each Newton step requires solving a linear system with the


Jacobian matrix.
J (uk )   F (uk )
uk 1  uk  

• Options for linear solve, same as linear case.


A few features of the nonlinear solver used in
Richards equation simulation

• Nonlinear system solved by Newton method


– Line search to take fraction of step in some regimes
J (uk )   F (uk )
uk 1  uk  
– Inexact Newton as linear system solved to tolerance

J (uk )  F (uk )  TOL


A few features of the linear solver used in
Richards equation simulation

• Linear Solver GMRES


– Loose tolerance on early Newton iterations.
– Jacobian vector products approximated by differences of nonlinear
function.

F (uk  v)  F (uk )


J (uk )v 

– Preconditioned by one cycle of multigrid.


– Preconditioner reused for several Newton iterations.
Structure of Richards equation solution
algorithm.
for time_level = 1,T
{
while newton not converged
{
while krylov not converged
{
preconditioning step with multigrid
}
}
}
Challenging features of Richards equation
simulation problem

• Permeability must be resolved on the scale of meters


• Regional models encompass several hundred square
kilometers
• Upwards of one billion grid points are needed
• Massively parallel processing is required, but not
enough

Scalable algorithms are necessary


Metrics can be used to measure how well our
code uses parallel resources.
• Let T(N,P) be the time to solve a problem of size N
using P processors.
• Speedup (solve same problem faster)
S(N,P) = T(N,1)/T(N,P)
perfect speedup when S(N,P)=P.
• Scaled Efficiency (solve bigger problem in same time)
E(N,P) = T(N,1)/T(PN,P)
perfect scalability when E(N,P)=1.
Features of Richards equation simulation code
• Spatial Domain Decomposition used to parallelize code.

• Implemented in C & MPI using existing codes and frameworks when possible
– Hypre and KINSOL
Richards equation simulation scaled efficiency
results

Processors Unknowns NL iterations Lin iterations Run Time (min)

1 55,296 33 86 16.57

2 110,592 33 86 17.23

4 221,184 33 85 17.01

8 442,386 33 83 18.13

16 884,736 33 83 18.14

32 1,769,472 32 80 19.62

64 3,538,944 31 76 19.65

128 7,077,888 30 74 23.33


PDE Simulation, a simple view

Physical Problem PDE Model Grid Generation

Discrete Model

Discrete Solver

Validate Results Visualize Results


Finally, and in reality
• Arrows go both ways
– Results made lead to changes in the model or even the way we
think about the physical process.
• Many of these boxes encompasses whole fields of study
– My research is mostly inside a little part of the discrete solvers
box.
• Implementing these boxes on a computer is a large task in
itself.
• Computational Science and Engineering is about the what’s in
each box, but also about the integration of the entire process.
References
• Papers
• Jones and Woodward, "Preconditioning Newton-Krylov Methods for Variably Saturated Flow,"
in Computational Methods in Water Resources, Vol. 1, L.R. Bentley, J.F. Sykes, C.A. Brebbia, W.G.
Gray, and G.F. Pinder, eds., (Rotterdam, 2000), pp. 101-106.
• Jones, and Woodward, "Newton-Krylov-Multigrid Solvers for Large-Scale, Highly
Heterogeneous, Variably Saturated Flow Problems," Advances in Water Resources, 24 (July
2001), 763-774.

• Codes
– hypre linear solvers library
http://www.llnl.gov/CASC/linear_solvers/
– KINSOL nonlinear solvers
http://www.llnl.gov/CASC/sundials/

Das könnte Ihnen auch gefallen