New NAG library software for first-order partial differential ... - CiteSeerX

3 downloads 0 Views 2MB Size Report
library software is reused. Results are presented for several computational examples to show that the software provides physically realistic numerical solutions.
New NAG Library Software for First-Order Partial Differential Equations S. V. PENNINGTON and M. BERZINS The University of Leeds

New NAG Fortran Library routines are described for the solution of systems of nonlinear, first-order, time-dependent partial differential equations in one space dimension, with scope for coupled ordinary differential or algebraic equations. The method-of-lines is used with spatial discretization

by either

the

central-difference

Keller

box scheme

or an upwind

scheme

for

hyperbolic systems of conservation laws. The new routines have the same structure as existing library routines for the solution of second-order partial differential equations, and much of the existing library software is reused. Results are presented for several computational examples to show that the software provides physically realistic numerical solutions to a challenging class of problems. Categories

methods, hyperbolic

Mathematical General

G. 1.8 [Numerical

and Subject Descriptors:

—difference

equations,

Analysis]:

Partial

Differential

method of lines; G.4 [Mathematics

Equations

of Computing]:

Software

Terms: Algorithms

Additional

Key Words and Phrases:

NAG Fortran

Library

1. INTRODUCTION In

recent

packages

years

differential such feature

of a number approach

initial-value PDEs. Berzins range

and

been

the

solution

(PDEs). since

example

et al. [1989],

a number

there

and have

software

packages ordinary

is used for the time of a method-of-lines

of one-dimensional,

offers

Sweet

[1980]

many is that

integration package PDEs.

gave

additions. they

software partial a survey

of

A common

use a method-of-

differential

a set of routines

time-dependent

general-purpose of time-dependent

been

sophisticated

which

of

of systems

Machura

then

of these

in which software

One

have

for

equations

software,

lines

there

developed

equation

(ODE)

of the semi-discretized is SPRINT, aimed The

developed

at solving

modular

by

a wide

structure

of

Authors’ address: School of Computer Studies, The University of Leeds, Leeds LS2 9JT, United Kingdom. Permission to copy without fee all or part of this material is granted provided that the copies are not made or distributed for direct commercial advantage, the ACM copyright notice and the title of the publication and its date appear, and notice is given that copying is by permission of the Association for Computing Machinery. To copy otherwise, or to republish, requires a fee and/or specific permission. @ 1994 ACM 0098-3500/94/0300-0063 $03.50 ACM Transactions

on Mathematical

Software, Vol. 20, No. 1, March 1994, Pages 63-99.

64

S. V. Pennington

.

this

package

tion,

time

evolved

over in the

parabolic

of the

form

PDEs,

there

is

used

software

a number

methods and

within

have

been

a finite

the

ordinary

Although

the

of the

available

second-order described

of many

in the

new

can

tended

and

suited

common

to

layer

the

in this

although

solution

of are

or by first-

and

equations.

Systems

of one or more

form.

Some

schemes

care must

as

much

problems

by the introduction

discretization

to solve

[1990]),

physical laws,

boundary

amenable

spatial

problems,

has been

as conservation order

more

most

matrix for the

and

be taken

first-order

software

in-

in the imposi-

conditions.

many

first-order

characteristic

introduced

is many

such to first

often

using

for higher-order

of boundary

time

are

be solved

However,

area

and

Schryer

Spa-

scheme,

is available

packages

such as the inviscid

can be reduced

variables

PDEs

this

Fortran

equations.

integration

(see, for example,

However,

PDEs,

systems,

order

in

PDEs.

by first-order

of mixed

method-of-lines

NAG

of second-order

differential time

has

academic

or a CO collocation

regarding

as possible

software

parabolic

second-order

tion

aim

a class of problems

package and

solution

algebra (see Berzins [1990]). Adaptive spatial remeshing finite-difference scheme in the Mark 16 (1993) release. wide

discretiza-

the

industrial

included

for

difference

of options

in spatial

as such

both

routines

scope for coupled

is by either

are

algebra,

of individual

with

of new

matrix

SPRINT

discretization

and

the inclusion and

time.

Versions

Library tial

has enabled integration,

research.

and M. Berzins

via

problems

behavior

is

second-order

encing is essential for The principal difficulty

are hyperbolic

important.

terms,

some

in nature,

Unless type

artificial

and

space-

dissipation

of one-sided

or upwind

is

differ-

hyperbolic problems with steep gradients or shocks. with upwind schemes is in determining the direction

of information flow which may change in space or time, and hence it is generally inappropriate to specify or determine a fixed direction of upwinding before

integration

first-order teristics.

commences.

hyperbolic

must

As far as the authors

but no widely

available

a wide

range

of hyperbolic

This

paper

describes

first-order Library:

Also,

PDEs

PDEs (i)

packages

two

spatial

problem for scheme

Library,

and those

new routines for the solution

at each

have

ACM

TransactIons

mesh

for scheme the same

point

D03P

offer

conditions

for

of the charac-

experimental

upwind

(ii)

box

codes

differencing

combined

for

Vol

20,

No.

for

with

the

of

Fortran

solution

a flux-limiter

16 (1993)

release

for the Mark much

will demonstrate that of first-order systems

Software,

solution

of

scheme for the solution of based on the solution of a

and flexibility reusing

for the

of the NAG

scheme

an upwind law form,

are intended

PDEs,

schemes

subchapter

in the Mark

structure

of second-order

on Mathematical

the nature

are many

which

Keller

(i) are included

based software. This paper software for a wide range framework.

there

discretization

in the

central-difference

Riemann

of boundary

account

problems.

general first-order problems and (ii) hyperbolic problems in conservation Routines

into

are aware,

software

to be included

the

the imposition

take

1, March

method. of the NAG

17 release.

as the existing of the existing

The

routines SPRINT-

it is possible to provide within a method-of-lines

1994.

NAG Library Software 2. PROBLEM The

65

CLASSES

master

finite

.

equation

difference

form

routines

of the

PDEs

and

for second-order

coupled

problems

ODES

for

the

existing

is

NPDE

+ Q,

PL,, ~

~

‘X-m

;(q),

j=l

i=l,2 F,(t,~,~,~,~*,g:,~*>~;~E~t where P, ~ and x,t, g,gx, _ v and

NPDE,

a, ~+~=sL,

equation

finite-difference conservation

for

the

scheme law

form

PDEs probwith

a

is i=l,2,

. . .. NPDE.

(lo)

j=l

where P, ~ and F, depend on x, t,g, and g, and S, depends on x, t,g, g and linearly on ~. Note that F, does not depend on Z_LXas the equations would then be of second order and thus in the problem class of the existing finite-difference routines. The ODE

part

is exactly

as in the Keller

box scheme,

boundary conditions have a similar general scheme given by Eqs. (8) and (9), but will Sections

given

by Eq. (7). The

form to those in the Keller box be described in more detail in

3.2 and 5.

3. ALGORITHM

DESCRIPTION

The PDEs are solved using the method-of-lines (see Berzins et al. [1989]), in which the PDEs are discretized in space on a mesh x,, z = 1, 2, . . . . NPTS, using an appropriate spatial discretization method, resulting in a system of NPTS nonlinear coupled ODES for each PDE. A number of these ODES may be without a time derivative, in which case the system is of differential algebraic form. Algebraic equations often arise at the boundaries of the spatial domain where the PDEs are replaced by boundary conditions not involving time derivatives. The system is of the form

(11) ACM

Transactions

on Mathematical

Software,

Vol

20,

No

1, March

1994

NAG Library Software where braic

the

square

system.

matrix

& may

be singular,

vector

y(t)

The solution

y~(t) = ZLJ(X[,t), fori=l

,.. ., NPTS,

j=l,

where

67

a differential

alge-

by

k = NPDE

. . .. NPDE.

y~(t) = Urn(t),

indicating

is defined

.

(12)

x (i – 1) +.j,

and

where

1 = NPDE

X NPTS

(13)

+ m,

m = 1,...,NCODE.

for

The solution

vector

y(t)

is thus

point xl, all the PDE ;ariables ODE variables, making a total nents.

made

The ODE (or differential algebraic) initial condition y(0) = ~ say, forms be integrated 3.1

in time

Spatial

by standard

variables

system given an initial-value

methods

at mesh

by any coupled solution compo-

by Eq. (11), along with an problem which can then

(see Section

3.3).

Discretization

3.1.1 Finite-Difference new

up of all the PDE

at mesh point Xz etc., followed of NPDE X NPTS + NCODE

routines

have

Scheme.

some

similarities

The spatial discretization to the finite-difference

and Berzins [1990] used in the existing is given here for future reference. Consider

for notational

convenience

routines,

methods for the scheme of Skeel

and hence

the single

general

a brief

summary

PDE

6’U ~z+q=?

(14)

dx ‘ where

p, q, and

The spatially hipt-1/2

r are functions discretized

of x, t, u, and

form

+ h~+lp,+l/zu

of the above

+ h,q, -1/z

u,.

equation

+ h,+lq,

+l/z

is =

rz+

1/2



rz–

112

(15)

,

h,+hi+l where



L, denotes

h, + h,+l

the time

derivative

l/2(h,

+ hi+l)

of u,, h, = xi – xi_ ~, and the subscript

i + 1/2

on p, q, and r denotes evaluation at x = (xi + x,+l)/2, u = (u, + u,+l)/2, and u, = (U,+ I – u,)/hZ., (and similarly for the subscript i – 1/2). The Skeel and Berzins scheme is in fact a modified form of the Keller box

scheme

which

discretizes

explicit ODE system, that Eq. (17)). This is achieved can be found 3.1.2

Keller

in Skeel Box

second-order

PDEs

in such

a way

as to obtain

is, each ODE involves just one time by the introduction of a second-order

and Berzins

Scheme.

Keller

an

derivative (cf. error. Details

[1990]. [1970]

introduced

method for the spatial and temporal discretization (or higher) reduced to first order by the introduction

this

finite-difference

of PDEs of second of new variables.

order

Within the method-of-lines framework the box scheme is used to discretize the PDEs in space only. Spatial derivati~es are replaced by central differences using mesh points x, and xl+ ~, for each i, and all variables and their time derivatives are averaged over these two mesh points. ACM

Transactions

on Mathematical

Software,

Vol.

20,

No.

1, March

1994.

68

.

S. V. Penmngton

For the single

general

and M. Berzins PDE du p~+q=o,

where is

p and

(16)

of x, t,u, and

q are functions

the spatially

u,,

(ziL+ Zi,+l) PL+l/2

where, i + 1/2 Ul+l)/2,

Note

as before, on

p

u,

and

denotes q

the

denotes

time

derivative

evaluation

and u. = (uZ+l – u,)/hZ+I, that since Eq. (17) involves

=

+ q,+ 1/2

2

at

discretized

o, of

(17) u,,

x = (xl

and

the

+ x,+l)/2,

subscript u = (u,

where h, = x, – x,_l. two time derivatives, the ODE

this scheme is implicit (cf. the explicit As an example consider the simple

form

system

+ for

form of Eq. (15)). first-order system du

13u =

dt

a—~x

(18)

7

(19) resulting order.

from

the reduction

The semidiscrete

of the heat

form

equation

of the system

tit + riz+l

d u/ d t = ad 2u\ dx 2 to first

(18) and (19) is

‘2+1 — ‘L

=a! 2

(20)

h’ 1+1

UL+Z), +l

UL+l —UL (21)

2 The

Keller

intended existing

box

scheme

(see problem

3.1,3 Upwind general

equations Exceptions

1.1 for example) Scheme.



in

this

paper

are

not

primarily

problems reduced to first order. The problems are generally more efficient

directly, include

for which

the

The discretization

thus higher existing scheme

involving fewer or mixed-order routines will

variables problems

are unsuitable.

be described

for the

PDE Ju px+z=s,

where The

h,+l

described

for the solution of second-order NAG routines for second-order

as they solve second-order and function evaluations.

single

routines

=

p, f, and convective

df (22)

s are functions of x, t, and u. flux term d f/ ?X is discretized

using

an upwind

scheme

based on Godunov’s [1959] method involving the solution of a Riemann problem at each midpoint of the mesh, combined with a flux-limiter method (see LeVeque form of this ACM

Transactions

[19901, Chapter 17, and Osher [1985]). The two-dimensional discretization method on quadrilateral meshes is analyzed on

Mathematical

Software,

Vol

20,

No.

1, March

1994

in

NAG Library Software

.

69

depth by Spekreijse [1987] and has been used on a variety of problems Koren [1989] and others. The source term s is treated as in the finite-difference method of Skeel

and

Berzins [1990] The spatially

the

(see Section discretized

finite-difference

scheme

hip,_l/z

+ h,+lp, h,+h,

where

3.1.1). form of Eq.

(Eq. (15)),

+l/zu,

+

+l



hz = xi — X,.l

as before,

S1+

1/2

that

(22)



;(h,

+ h,+,)

ft-1/2

S,+1,2

is defined +

contributions at internal 12). occurs in the calculation

, (23)

by (24)

‘i+l)),

to the

average

1 then the discretization is conservative, of u over the whole domain depends only

boundaries-flux [1990], Chapter The upwinding

for

h, + h,+l

where XJ+1,2 = (l\2)(xt + Xz+l). Note that if u, is viewed as an approximation [x,- 1/2> x,+,l/2 time variation

to that

hisL_ l/2 + hL+lsL+ 1,2

.

‘(xL+l/2>t)*(u~

=

similar

is,

f,++

and

is very

by

cell interfaces of the flux

over the cell

meaning that the on the flux at the cancel

terms

(see LeVeque

in Eq. (23), given

by f,+,/2

=?(x,

+1,2,

t,uL(x!

+1,2,

t),

uR(x,

where ~( x, t, u~( x, t), UR( x, t)) is the numerical expressed in terms of the upwinded Left and UR( x, t) at (x, t).These upwinding [1990])

techniques suitably

uL(%+

left

and

combined

modified

right with

values a flux

for a nonuniform

l/2>

t)=u,

1/2)

t)=u,

h ,+, +— 2

+,,2,

fZux Right

function values

are calculated

limiter mesh,

where the function B scheme is that proposed

(see later) UL( x, t) and

using

standard

(see for example

LeVeque

so that

(UL – u,_,) (26)

B(r,),

h,

h ,+~ (Zq+z – U,+l)B %(~2+

(25)

t))>

+l–~

(27)

?

hi~2

is some limiter function, by Van Leer [1974] given

1 (-)rl+l

which by

for

this

particular

ri + [ril B(ri)

=

(28) 1 + 17-,1‘

and r~ =

ACM

Transactions

~:+

1/2



Ui

u?+

1/2

—ui’

(29)

on Mathematical

Software,

Vol.

20,

No.

1, March

1994.

70

S. V. Pennington

.

where (left)

the

superscripts

upwind

values

and M. Berzms C and

c

given +(UL

=

uL+ l/2

linearly

interpolated

centered

and

by (30)

+ uL+~),

h ,+~ (UL – U,_l)

u

=u[+—

‘L+l/’2

Alternatively

U denote

respectively,

r, can be written

h,



in the form (u

ri

(31)

2

u,)\h,+l

2+1—

(32)

= (Ul



z~,-l)\hL



which is the ratio of the derivatives of the centered and (left) upwind interpol ants. In the case of a system of equations the individual solution components are “limited”

using

Eqs.

(26)

and

(27) to give

a vector

of left

and

right

solution

values at each midpoint, as in Spekreijse [1987] and Koren [1989]. Having obtain~d the left and right values of u at each midpoint X,, ~lz, the numerical

flux

f (a vector

in the case of systems)

some method.

A simple

way would

and calculate

the corresponding

f= or to average

the fluxes

be to average flux,

to be calculated and right

values

(33)

to the left

Hf(~j~,uL)

by of u

is,

f(x, t,+(u~ + u~)),

corresponding

f=

that

is then the left

values,

that

is, (34)

ul?)).

+f(x>t,

Note that these two averages are generally However, such averaging is equivalent

and right

not equal. to central differencing

and

hence

does not physically

take into account the nature of the space-time characteristics. The correct value for ~ is obtained from the solution of the Riemann

problem

given

by du/dt

+ r?f/c7x

(where x is the distance to the midpoint values u=u~forxO. The numerical flux is required at every step. In theory [1959] original

these Riemann method), but

=

o,

(35)

x,+ ~,z) with midpoint

discontinuous

of the mesh

at every

initial time

problems can be solved exactly (as in Godunov’s to do so in practice would be computationally

expensive, particularly for nonlinear equations which may require an iteraand much of the information tive solution. Since u~ and u~ are approximate, from the Riemann solution is subsequently lost by averaging, a much less expensive approximate solution is considered adequate (see LeVeque [1990] for example). Indeed Roe [1989] gives examples where an approximate Riemann solver gives better results than the exact solution. Approximate

Riemann

Solvers.

There

are a number

of methods

for obtain-

ing an approximate solution to the Riemann problem, due to Harten and Lax, Steger and Warming, Van Leer, Osher, and Roe among others. Van Leer et ACM

TransactIons

on

Mathematical

Software,

Vol.

20.

No.

1, March

1994

NAG Library Software

give references

al. [1987] pare them [Engquist schemes

for

shocks,

and

brief

descriptions

for the Euler and Navier-Stokes and Osher 1981; Osher and their

ability

boundary

For Osher’s

layers,

to accurately and contact

approximate

Riemann

and Solomon [1982] the numerical t for notational convenience)

methods

and

71 com-

equations, recommending Osher’s Solomon 1982] and Roe’s [1981] represent

flow

phenomena

such

as

discontinuities. solver

flux

f(uL,uR)= +j(f(uL)

of these

.

[Engquist

and Osher

is (omitting

+f(uR))

1981; Osher

the dependence

on x and

- :( URIA(u)ldu,

(36)

‘UL

where

A(u)

= df\

6’u is the Jacobian

matrix,

IAI=A+–

and

IAl is a matrix

defined

A-,

by (37)

where pA+p-~

A+=

where

A is the

diagonal

diagonal

matrices

A-=

7

matrix

such that

only the negative, right eigenvectors

PA-P-

I

and

of eigenvalues

A+

has only

of A,

the positive

and

in Eq. (36) is carried of A(u), that is, along

out along the wave

and

A-

of A, and

are A-

a path piecewise parallel to paths in the phase space of

u (see Engquist and Osher [1981] and Osher and Solomon An example of the application of Osher’s approximate

[1982] for details). Riemann solver is

in the Appendix.

For Roe’s [1981]

approximate

Riemann

f(u~,u~)= $(f(uJ

+f(uR))

where A–(u~, u~ ) is a linearized satisfflng the following: (i)

l(u~,

u~)(.u~

(ii)

I(u,

u) = A(u);

(iii)

~ has real

I~

A+

elements

so that A = A++ A-. The columns of the matrix P are the of A, and the rows of P-l are the left eigenvectors of A.

The integration the eigenvectors

given

(38)

A = PAP-I,

is defined

form

– u~) = f(~~)

eigenvalues

with

solver

the numerical

flux

is

+II(ZLL, Z%)I(Z+ – rJL),



(generally

nonunique)

of the Jacobian

(39) A

– ~(~~);

linearly

independent

as in Eqs. (37) and (38). Equation

where Aj and ej are the eigenvalues ~, and the a~ are obtained from

and (right)

eigenvectors.

(39) can also be written

eigenvectors

respectively

as

of

NPDE

u~ -

ACM

Transactions

u= =

(41)

~ ajej. j= 1

on Mathematical

Software,

Vol.

20,

No.

1, March

1994.

72

S. V. Pennington

.

As

a simple

consider

example

Burgers’

and M. Berzins

of the

equation

numerical

flux

in the inviscid

obtained

using

these

schemes,

limit:

(42) Osher’s

scheme

gives

f(uL,

12 ?UL?

uL, u~>o,

$U; ,

uL, uE0, and the initial 0, and W( x, 0) = O for x >0. Note that problem

time

is not

domain

O s x s

the plate, plate

with

u and

respectively.

that

that

changes

rapidly

boundary there

are

the

initial

t = 0.2); until provide

TransactIons

on

to

is no further

change

be truncated

at some

CPU

the

function. in

initial

mesh at the

3 show

the

shown)

at

(i.e., in

time

problem

the

layer,

in

the the

finite

transformation

distance number

required. Note

u has been is chosen

Mathematical

the gradient

thickness

second

points spatial

remeshing

smoothed to be finer

is

of the

Also,

since

should

have

derivative

of

performed

(at about

somewhat towards

only

the

plate

to

start.

approximate

solutions

t = 5.0, that

Software,

solution

the

downstream). of mesh

The that

as the and

is,

for

at a distance

is with xmax = 100. An adaptive mesh of 61 points Newton iteration, and banded method of time integration, ACM

t,the spatial t along

t = 5, meaning

around

coordinate

boundary

time

a reduction

resolution

2 and

must

for this

of the

discontinuity

w is not

at

there

a simple

with

with

monitor

then

adequate

Figures variable

edge

on the

as the

u is used

and

plate

of

a distance

and perpendicular

constant

domain

is appropriate the

PDEs,

effect

on the

at

to be O < x < 1.

changes

three

a significant after

at

layer

point

value

plate

parallel

becomes

semi-infinite

at any

to the

the velocities

solution

say,

can be taken domain An adaptive mesh

space variable;

perpendicular

u being

the

x = xmax

of

line

of this

Note

value

a second

The

downstream

solution.

but

m is the

u(O, t) = u(O, t) = O

are

are U(X, 0) = 1, u(.K, O) = conditions the independent variable t in this

Vol

20,

No.

1, March

1994

u

and

u (the

5.0 along used, with matrix

extra

the plate, the b.d.f. algebra.

NAG Library Software

.

83

1.2

1

0.8

u

0.6

0.4

0.2

0 0

0.2

0.4

0.6

0.8

1

x Fig. 2. points.

The approximate

solution

for u in Problem

1.1 at t = 5.0 using an adaptive

mesh of 61

0.45 0.4 0.35 0.3 0.25 v 0.2 0.15

0.1 0.05 0 0.2

0

0.4

0.6

0.8

1

x Fig.

3.

The

approximate

solution

for

u in

Problem

1.1

at

t=

5.0

using

an

adaptive

mesh

of

61

points.

ACM

Transactions

on Mathematical

Software,

Vol.

20,

No.

1, March

1994

84

.

S. V. Pennington

Problem ferential

1.2.

A population

equation

L6pez-Marcos

and M. Berzins dynamics

a nonlocal

with

by an integro-dif-

governed

condition

(from

Fairweather

and

[1991]): du — dt

for O

Suggest Documents