+ All Categories
Home > Documents > Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The...

Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The...

Date post: 19-May-2020
Category:
Upload: others
View: 5 times
Download: 0 times
Share this document with a friend
98
Meteorological Training Course Lecture Series ECMWF, 2002 1 Numerical methods Revised March 2001 By R. W. Riddaway (revised by M. Hortal) Table of contents 1 . Some introductory ideas 1.1 Introduction 1.2 Classification of PDE's 1.3 Existence and uniqueness 1.4 Discretization 1.5 Convergence, consistency and stability 2 . Finite differences 2.1 Introduction 2.2 The linear advection equation: Analytical solution 2.3 Space discretization: Dispersion and round-off error 2.4 Time discretization: Stability and computational mode 2.5 Stability analysis of various schemes 2.6 Group velocity 2.7 Choosing a scheme 2.8 The two-dimensional advection equation . 3 . The non-linear advection equation 3.1 Introduction 3.2 Preservation of conservation properties 3.3 Aliasing 3.4 Non-linear instability 3.5 A necessary condition for instability 3.6 Control of non-linear instability 4 . Towards the primitive equations 4.1 Introduction 4.2 The one-dimensional gravity-wave equations 4.3 Staggered grids 4.4 The shallow-water equations.
Transcript
Page 1: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Meteorological Training Course Lecture Series

ECMWF, 2002 1

Numerical methodsRevised March 2001

By R. W. Riddaway (revised by M. Hortal)

Table of contents

1 . Some introductory ideas

1.1 Introduction

1.2 Classification of PDE's

1.3 Existence and uniqueness

1.4 Discretization

1.5 Convergence, consistency and stability

2 . Finite differences

2.1 Introduction

2.2 The linear advection equation: Analytical solution

2.3 Space discretization: Dispersion and round-off error

2.4 Time discretization: Stability and computational mode

2.5 Stability analysis of various schemes

2.6 Group velocity

2.7 Choosing a scheme

2.8 The two-dimensional advection equation .

3 . The non-linear advection equation

3.1 Introduction

3.2 Preservation of conservation properties

3.3 Aliasing

3.4 Non-linear instability

3.5 A necessary condition for instability

3.6 Control of non-linear instability

4 . Towards the primitive equations

4.1 Introduction

4.2 The one-dimensional gravity-wave equations

4.3 Staggered grids

4.4 The shallow-water equations.

Page 2: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

2 Meteorological Training Course Lecture Series

ECMWF, 2002

4.5 Increasing the size of the time step

4.6 Diffusion

5 . The semi-Lagrangian technique

5.1 Introduction

5.2 Stability in one-dimension

5.3 Cubic spline interpolation

5.4 Cubic Lagrang interpolation and shape preservation

5.5 Various quasi-Lagrangian schemes in 2D

5.6 Stability on the shallow water equations

5.7 Computation of the trajectory

5.8 Two-time-level schemes

6 . The spectral method

6.1 Introduction

6.2 The one-dimensional linear advection equation

6.3 The non-linear advection equation

6.4 The one-dimensional gravity wave equations

6.5 Stability of various time stepping schemes

6.6 The spherical harmonics

6.7 The reduced Gaussian grid

6.8 Diffusion in spectral space

6.9 Advantages and disadvantages

6.10 Further reading

7 . The finite-element technique

7.1 Introduction

7.2 Linear advection equation

7.3 Second-order derivatives

7.4 Boundaries, irregular grids and asymmetric algorithms

7.5 Treatment of non-linear terms

7.6 Staggered grids and two-dimensional elements

7.7 Two dimensional elements

7.8 The local spectral technique

7.9 Application for the computation of vertical integrals in the ECMWF model

8 . Solving the algebraic equations

Page 3: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 3

8.1 Introduction

8.2 Gauss elimination

8.3 Iterative methods

8.4 Decoupling of the equations

8.5 The Helmholtz equation

REFERENCES

1. SOME INTRODUCTORY IDEAS

1.1 Introduction

Theuseof numericalmodelsfor weatherpredictioninvolvesthesolutionof asetof couplednon-linearpartialdif-

ferentialequations.In generaltheseequationsdescribethreeimportantdynamicalprocesses—advection,adjust-

ment(how themassandwind fieldsadjustto oneanother)anddiffusion.In thisnotewewill concentrateuponhow

to solvesimplelinearone-dimensionalversionsof theequationswhichdescribeeachof theseprocesses.Thesecan

be conveniently derived ftom the shallow-water equations in which

(a) the earth's rotation is ignored

(b) there is no motion in the -direction

(c) there are no variations in the -direction

The set of equations we are going to consider is then

Linearising the equations about a basic state constant in space and time gives

where and aretheperturbationsin the -componentof velocityandtheheightof thefreesurface.Theparts

of these equations describing the three main processes are as follows.

Advection

��

�∂∂� ���

∂∂�

– � �∂∂�

– �∂∂ � �

∂∂�

+=

�∂∂� ���

∂∂�

– � �∂∂�

– �∂∂ � �

∂∂�

+=

advectionadjustmentdiffusionadjustment

� 0�

,( )

∂ �∂ �------ � 0

∂ �∂�------+ � ∂ �

∂�------–

∂∂�------ � ∂ �

∂�------

+=

∂ �∂ �------ � 0

∂ �∂�------+

� ∂ �∂�------–

∂∂�------ � ∂ �

∂�------

+=

� � �

Page 4: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

4 Meteorological Training Course Lecture Series

ECMWF, 2002

In general the one-dimensional linearised advection equation can be written as

As well asinvestigatingthelinearadvectionequation,it is necessaryto considerthenon-linearproblem.For this

we use the one-dimensional non-linear advection equation

Adjustment

These are often called the one-dimensional linearised gravity-wave equations.

Diffusion

The general form of the one-dimensional diffusion equation (with constant eddy diffusivity ) is

Many of the ideasandtechniquesusedto solve thesesimplified equationscanbe extendedto dealwith the full

primitive equations.

Finitedifferencetechniqueswere,historically, themostcommonapproachto solvingpartialdifferentialequations

(PDE's)in meteorologybut, sincea numberof yearsnow, spectraltechniqueshave becomevery usefulin global

modelsandlocalrepresentationssuchasthefinite elementsor thelocalspectralmethodarebecomingincreasingly

researched, mainly in connection with the massive parallel-processing machines.

1.2 Classification of PDE's

Mostmeteorologicalproblemsfall into oneof threecategories—thesearereferredto asboundaryvalueproblems,

initial valueproblemsandeigenvalueproblems.In this notewe will bemainly concernedwith initial valueprob-

lems.

∂ �∂ �------ � 0

∂ �∂�------+ 0=

∂ �∂ �------ � 0

∂ �∂�------+ 0=

∂ϕ∂ �------ � 0

∂ϕ∂�------+ 0=

∂ �∂ �------ � ∂ �

∂�------+ 0=

∂ �∂ �------ � ∂ �

∂�------+ 0=

∂ �∂ �------

� ∂ �∂�------+ 0=

∂ �∂ �------

∂∂�------ � ∂ �

∂�------

=

∂ �∂ �------

∂∂�------ � ∂ �

∂�------

=

∂ϕ∂ �------

� ∂2ϕ∂� 2

---------=

Page 5: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 5

1.2 (a) Boundary value problems.

Theproblemis to determine in a certaindomainD, wherethedifferentialequationgoverning within D is

, and on the boundary; here L and B are differential operators.

Typical examples of this type of problem involve the solution of the Helmholtz or Poisson equations.

1.2 (b) Initial value problems.

Thesearepropagationproblemsin whichwewantto predictthebehaviour of asystemgiventheinitial conditions.

This is doneby solvingthedifferentialequation within D wheretheinitial conditionis and

theprescribedconditionsontheopenboundariesare . Problemsinvolving thesolutionof theadvection

equation, gravity wave equations and diffusion equation fall into this category.

1.2 (c) Eigenvalue problems.

Theproblemis to determine and suchthat is satisfiedwithin domainD. Problemsof thistype

occur in baroclinic instability studies.

An alternative method of classification has been devised for linear second order PDE's of the form

Theclassificationis basedonthepropertiesof thecharacteristics(notdiscussedhere)of theequation.Wefind that

therearethreebasictypesof equation:hyperbolic,parabolicandelliptic. Hyperbolicandparabolicequationsare

initial value problems, whereas an elliptic equation is a boundary value problem.

1.3 Existence and uniqueness

Let us consider an initial value problem for a real function of time only

(1)

where is a known function of the two variables.

We could be unable to solve explicitly Eq. (1) and therefore we ask ourselves the following questions.

TABLE 1. CHARACTERISTICSOF HYPERBOLIC, PARABOLIC AND ELLIPTIC PDES

TypeCharacteristic

directionsCondition Example

hyperbolic Real Wave equation

parabolic Imaginary Diffusion equation

elliptic non-existent Poisson equation

ϕ ϕL ϕ( ) = B ϕ( ) �=

L ϕ( ) in solution domain D=

B ϕ( ) � on the boundary=

L ϕ( ) = I ϕ( ) �=

B ϕ( ) �=

λ ϕ L ϕ( ) λϕ=

∂2ϕ∂ξ2--------- 2� ∂2ϕ

∂ξ∂η------------- � ∂2ϕ

∂η2--------- 2 ∂ϕ

∂ξ------ 2 � ∂ϕ

∂η------ ϕ+ + + + + 0=

� 2 � 0>–

� 2 �– 0=

� 2 � 0<–

d�d�------ � �,( ) � �

0( ); �0= =

Page 6: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

6 Meteorological Training Course Lecture Series

ECMWF, 2002

1) How are we to know that the initial value problem(1) actually has a solution?

2) How do we know that there is only one solution of (1)?

3) Why bother asking the first two questions?

Theanswerto thethird questionis thatour equationis just anapproximationto thephysicalproblemwe wantto

solveand,therefore,if it hasnotoneandonly onesolutionit cannotbeagoodrepresentationof thephysicalproc-

ess;that is, theproblemis not well posed.On theotherhand,if theproblemis well posedwe canhopeto getby

somemeansasolutioncloseenoughto therealsolutionevenif weareunableto find theexactsolutionor theexact

solutionis not ananalyticalone.Thesituationis thenexactly thesameasin thetheoryof limits whereit is often

possibleto prove thatasequenceof functions hasa limit withoutourhaving to know whatthis limit is, and

we can use any member of the sequence from a place onwards to represent an approximation to the limit.

This suggests the following algorithm for proving the existence of a solution of (1):

(a) Construct a sequence of functions that come closer and closer to solving(1);

(b) Show that the sequence of functions has a limit on a suitable interval ;

(c) Prove that is a solution of(1) on this interval.

This is thesocalledsuccessiveapproximationsor Picarditerates.By thismethod,it is possibleto show thefollow-

ing

Picard's Theorem:

Let and be continuous in the rectangle R: , . Then the initial-value problem

has a unique solution on the interval .

Unfortunately, theequationsinvolvedin meteorologyarenotordinarydifferentialequationsbut partialdifferential

equationsandtheproof of existenceanduniquenessof its solutionis not asstraightforwardasapplyingPicard's

theorem.Nevertheless,theexampleservesto illustratetheimportanceor proving anexistenceanduniquenessthe-

orem as a hunting license to go looking for this solution or for a close approximation to it.

For thelinearequationswe aredealingwith in this setof lectures,we canfind thegeneralanalyticsolutionto the

equationand,therefore,donotneedto provetheexistencetheorem.But it will still beniceto provetheuniqueness

of it, givenasuitablesetof initial andboundaryconditions.Nevertheless,this fallsoutsidethescopeof thecourse

and we will only hope that such a uniqueness could be proven.

1.4 Discretization

Thenon-linearequationsdescribingtheevolution of theatmospheredo not have analyticalsolutionseven if the

problemis well posed.An analyticalfunction is themostperfectway of representinga givenphysicalfield asit

gives us the value of this field in any of the infinite number of points of space and at any instant in time.

If ananalyticalsolutiondoesnot exist, we have to resortto numericaltechniquesto find a certainapproximation

to thetruesolutionof thesystemof equations,thatis, we have to usecomputers.But computerscannotdealwith

infinite amountsof numbers,sowe have to representour meteorologicalfieldsby a finite numberof values.This

is called the discretization process.

As a simple example consider the linear one-dimensional evolutionary problem

� �( )

��� �( )

� �( )��� �( )��� �( ) � �( ) �

0���

0 α+≤ ≤� �( )

∂∂�------

�0���

0+≤ ≤ � �

0– �≤

d�d�------ � �,( ) � �

0( ); �0= =

� �( ) �0���

0+≤ ≤

Page 7: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 7

(2)

whereH is a lineardifferentialspaceoperator(thoughthetechniquesconsideredcanalsobeappliedto non-linear

problems).Wewill assumethat is specifiedat gridpointsin ourdomain , andthatthereare

suitableboundaryconditionsfor . Wenow wantto considerhow wecannumericallyfind , giventhegrid

point values —that is we only consider the space discretization.

Thecommonway of tacklingthis problemis to simply expressthederivativeswhich occuron theright handside

of (2) in termsof thedifferencesbetweenthegridpointvaluesof . This is thefinite differencetechnique, which

will bediscussedat lengthlater. Notethatwhenusingthis techniqueno assumptionis madeabouthow varies

between the grid points.

An alternative approachis to expand in termsof a finite seriesof linearly independentfunctions ,

where ,where , so that

(3)

Thisseriesis only anexactsolutionof theoriginalPDEin veryspecialcircumstances.Therefore,when(3) is sub-

stituted into(2) there will be a residual

We now wantto choosethetime derivatives by minimising in someway. Onemethodfor doingthis

is to use a least square approach—we then have to minimise

with respect to the time derivatives. Carrying this out and rearranging gives:

(4)

This equation could also be derived using the Galerkin method in which we set

wherethe canbeany setof linearly independenttestfunctions.If theexpansionfunctionsareusedastestfunc-

tionsweget(4). Sincetheexpansionfunctionsareknown (3) canbeusedto providetheexpansioncoefficients

given the gridpoint values . Also the integrals

and

in (4) canbecalculatedexactly for all possiblevaluesof and . Therefore,(4) reducesto asetof coupledordi-

nary differential equations that can be solved for the given the . The complete solution is then

∂ϕ∂ �------ H ϕ( )=

ϕ � 1+( ) 0� �

≤ ≤( )ϕ ∂ϕ ∂ �⁄

ϕ �

ϕϕ

ϕ � 1+( ) ���� �1 … �

2,= �2�

1– �=

ϕ ϕ � �( ) � � �( )���1=

�2

∑=

� dϕ� �---------- ��� ϕ� � ���( )�∑–�∑=

dϕ �� �⁄�

� � �d∫=

dϕ� �-------- ��� ��� �d∫�∑ ϕ�!��� � ���( )

� �;d∫�∑�

1 … �2,= =

�ψ " �d∫ 0 #; 1 2 …� 1+, ,= =

ψ "ϕ �

ϕ �

��� ��� �d∫ ��� � ���( )�

d∫� $

dϕ�� �⁄ ϕ�

Page 8: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

8 Meteorological Training Course Lecture Series

ECMWF, 2002

This general approach is often referred to as the Galerkin technique.

For thecasewheretheexpansionfunctionsareorthogonalweendupwith uncoupledordinarydifferential

equations for the rate of change of the expansion coefficients

An exampleof this kind of approachis thespectralmethodin which a Fourierseriesis used.In this case(3) be-

comes

where the are complex Fourier coefficients and .

With spherical geometry, it is natural to use spherical harmonics.

For thespectralmethodtheexpansionfunctionsareglobal.An alternative approachis to usea setof expansion

functionswhichareonly locally non-zero;this is thebasisof thefinite elementmethod. With thismethodwestill

have a setof nodes(i.e. grid points)with nodalvalues , but now we assumethat thevariationin within an

element(i.e. a setof nodes)canbedescribedby a low-orderpolynomial,with therequirementthatthereis conti-

nuity in betweenadjacentelements.Thesimplestcaseis to assumea linearvariationin acrossanelement

which has only two nodes (the end points); i.e. a linear piecewise fit. Then(3) becomes

wherethe arethenodalvaluesandthe are"hat" functions(sometimescalledchapeaufunctions)asin

Fig. 1.

Theexpansionfunctionsarenot orthogonal,but they arenearlyso; thereforetheintegralswhich occurin (4) can

beeasilyevaluated.Theresultof this processis to producea setof coupledequationsfrom which thetime deriv-

ative can be determined.

∂ϕ∂ �------

dϕ� �---------- ����∑=

� 1+( )

dϕ �d�---------- ϕ�!��� � ���( )

� �;d∫�∑�

1 … �2,= =

ϕ ϕ � �( ) i2π��----------

exp� %–=

%∑=

ϕ � & � 2⁄=

ϕ � ϕ

ϕ ϕ

ϕ ϕ � �( ) �'� �( )� 1=

(1+

∑=

ϕ � �'� �( )

Page 9: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 9

Figure 1. Representation of a "hat" function or piecewise linear finite element.

An interestingfeatureof theGalerkintechniqueis that if theoriginal equation(2) hasa quadraticinvariant(e.g.

energy)

thenthispropertyis retainedwhenaGalerkinapproximationis madefor thespatialvariations(whenfinite differ-

encesareusedthereis no guaranteeof this happening).However, notethatquadraticinvarianceis lost whentime

stepping is introduced.

Thespectralandfinite elementmethodswill bedealtwith in Sections6 and7, but now we will concentrateupon

the finite difference technique.

1.5 Convergence, consistency and stability

(a) Convergence: a discretizedsolution of a differential equation is said to be convergent if it

approachesthesolutionof thecontinuousequationwhenthediscretizationbecomesfiner andfiner

(that is the distancebetweengrid pointsin the finite differencetechniquebecomessmaller, or the

number of basis functions in the spectral or the finite element techniques becomes higher).

Wewould like to ensureconvergence,but this is difficult to do.However thereis a theoremwhichovercomesthis

problem, but before it can be stated we need to introduce two more definitions.

(b) Consistency: a discretizationtechniqueis consistentwith a PDE if the truncationerror of the

discretized equation tends to zero as the discretization becomes finer and finer.

Notethatconsistency meansonly thatthediscretizedequationis similar to thecontinuousequation

but this doesnot guaranteeby itself that the correspondingsolutionsare close to eachother

(convergence).

Consistency is easyto test. Suppose is thetruesolutionof thePDE(2) atposition andtime

. This solutionis now substitutedinto thefinite differenceequationandTaylor expansionsused

to expresseverythingin termsof thebehaviour of at position andtime . Rearrangingthe

equation then gives:

∂)∂ �------- 0 with ) ϕ2

2-----

�d

0

*∫= =

ϕ �+ � �� +ϕ

� � � +

Page 10: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

10 Meteorological Training Course Lecture Series

ECMWF, 2002

If the truncationerror approacheszero as the grid length and time step approachzero, the

scheme is consistent Hereafter consistency will be assumed without comment

(c) Stability: a discretizationschemeis stableif their solutionsareuniformly boundedfunctionsof the

initial statefor any value of small enough,that is if the numericalsolution doesnot go to

infinity as increases.

There are various techniques for testing stability, three of which will be described later.

Theconsistency andstabilityof discretizationschemescanbeinvestigated;therefore,wecancheckif thescheme

is convergent by making use of the following theorem.

The Lax–Richtmeyer Theorem

If a discretization scheme is consistent and stable, then it is convergent (the converse is also true).

2. FINITE DIFFERENCES

2.1 Introduction

Supposewe have an interval which is coveredwith equallyspacedgrid points.Thegridlengthis then

andthegrid pointsareat . Let thevalueof at berepre-

sented by .

We arenow goingto derive expressionswhich canbeusedto give anapproximatevalueof a derivative at a grid

point in termsof grid-pointvalues.In orderto constructa finite differenceapproximationto thefirst derivative at

point , wehaveinitially to deriveexpressionsfor and in termsof thebehaviour of atpoint . Using

a Taylor expansion gives:

(5)

(6)

Solving(5) and(6) for gives

Alternatively, subtracting(6) from (5) leaves

(7)

∂ϕ∂ �------ �+ �

ϕ( ) �+ )+=

)

∆ ��

� � 1+

∆� � �⁄=

� � , 1–( )∆�

,= , 1 2 …� 1+, ,= ϕ� �

ϕ �

, ϕ � 1– ϕ � 1+ ϕ ,

ϕ � 1+ ϕ� � ∆

�+( ) ϕ � ϕ � ′∆� ϕ � ′′ ∆

� 2

2!---------

ϕ′′′� θ1+∆� 3

3!---------

+ + += =

ϕ � 1– ϕ� � ∆–

�( ) ϕ � ϕ �– ′∆

�ϕ � ′′ ∆

� 2

2!---------

ϕ′′′� θ2+–∆� 3

3!---------

+= =

ϕ � ′

ϕ � ′ ϕ � 1+ ϕ �–

∆�------------------------ ) );+ ϕ � ′′ ∆

�2!-------

– ϕ′′′� θ1+∆� 2

3!---------

–= =

ϕ � ′ ϕ � ϕ � 1––

∆�------------------------ ) );+ ϕ � ′′ ∆

�2!-------

ϕ′′′� θ2+∆� 2

3!---------

–= =

ϕ � ′ ϕ � 1+ ϕ � 1––

2∆�------------------------------ ) );+

∆� 2

3!2---------

ϕ′′′� θ1+ ϕ′′′� θ2++( )= =

Page 11: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 11

When is omitted,theseexpressionsgive theforward,backwardandcentredfinite differenceapproximationsto

thefirst derivative.Thetruncationerroris givenby andtheorderof theapproximationis definedby thelowest

powerof in . Thereforetheforwardandbackwardschemesarefirst orderandthecentredschemeis second

order. Thehighertheorderof thescheme,thegreateris theaccuracy of thefinite differenceapproximation.All

threeschemesareconsistentif thederivativesarebounded,becausethentheerrorapproacheszerowhen tends

to zero.

A fourthorderschemecanbederivedby using(5) and(6) with expansionsof and . The

result is:

(8)

The usual finite difference approximation to the second derivative, derived from(5) and(6), is

(9)

Finally it is worth introducing the notation that is often used for finite differences:

Using this notation(7) and(9) become

2.2 The linear advection equation: Analytical solution

The one-dimensional linearised advection equation is

(10)

For convenience cyclic boundary conditions will be prescribed for at and .

The initial condition for is

In orderto find ananalyticalsolutionfor thelinearadvectionequationwemakeuseof thetechniqueof separation

of variables:

We look for a solution of the form

))

∆� )

∆�

ϕ� � 2∆

�+( ) ϕ

� � 2∆�

–( )

ϕ � ′ 43---

ϕ � 1+ ϕ � 1––

2∆�------------------------------ 1

3---

ϕ � 2+ ϕ � 2––

4∆�------------------------------– O ∆

� 4( )+=

ϕ � ″ ϕ � 1+ 2ϕ �– ϕ � 1++

∆� 2

---------------------------------------------- O ∆� 2( )+=

δ�.- ϕ � ϕ �/� 2⁄+ ϕ �0� 2⁄––� ∆�-------------------------------------------=

ϕ � �.- ϕ �/� 2⁄+ ϕ �0� 2⁄–+

2--------------------------------------------=

ϕ � ′ δ - ϕ � - δ2- ϕ � and ϕ � ″ δ -2ϕ �= = =

∂ϕ∂ �------ � 0

∂ϕ∂�------+ 0 ϕ; ϕ

� �,( ) � 0; constant= = =

ϕ�

0=� �

=

ϕ 0�,( ) ϕ

� �,( )=

ϕ

ϕ�

0,( ) �( ) 0� �

with � �+( )≤ ≤ �( )= =

ϕ� �,( )

Page 12: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

12 Meteorological Training Course Lecture Series

ECMWF, 2002

substituting in the partial differential equation(10) we get

dividing by we get

theleft-handsideis a functionof only while theright-handsideis a functionof only: therefore,they canbe

equal only if both of them are constant

we have two "eigenvalue problems" for the operators and , whose solutions are

and the solution of the advection equation is

(11)

Thereforewe geta functionpropagatingwithout changeof shapealongthepositive axiswith speed (phase

speed).

If we have periodicboundaryconditions, hasonly certain(imaginary)values,if they aresinusoidalwith time,

wemusthave where is thewavenumberand thefrequency. Of courseif is to representa

physical field, this field is the real part of the found solution.

As theadvectionequationis linear, any linearcombinationof solutionsof thetypefoundis alsoa solutionof the

equation.As all thecomponentwavesof a disturbancetravel with thesamespeedthereis no dispersionandthe

disturbance does not change shape with time.

ϕ� �,( ) 1 �

( ) 2 �( )=

1 �( )d2

d�------- � 0 2 �( )d1

d�--------+ 0=

1 �( ) 2 �( )

12----

d2d�------- � 0

11-----

d1d�--------–=

� �

11-----

d1d�-------- λ d1

d�-------- λ1= =

12----

d2d�------- � 0λ d2

d�-------– � 0λ 2–= =

d d�

⁄ d d�⁄

1 1 0 λ�

[ ]exp=

2 2 0 � 0λ �–[ ]exp=

ϕ� �,( ) 1 0 2 0 λ

� � 0λ �–[ ]exp ϕ0 λ� � 0

�–( )⋅[ ]exp � � 0

�–( )= = =

� � 0

λλ i 3= 3 3 � 0 ω= ϕ

Page 13: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 13

Figure 2. Representation of the solution of the analytical linear advection equation.

It is interesting to consider the "energy" defined by

(12)

Multiplying the advection equation by and integrating with respect to then gives

Therefore the energy is conserved—as indeed it must be since there is no change in shape of the disturbance.

2.3 Space discretization: Dispersion and round-off error

Let us consider again the one-dimensional linear advection equation

(13)

and represent the space derivative by means of centred finite differences

(14)

To solve this space discretized equation we try a solution of similar form to the continuous equation, namely

(15)

Substituting in the discretized equation(14) we get

(16)

whose solution is

) �( ) 12--- ϕ2 �d

0

*∫=

ϕ�

∂)∂ �-------

� 0

2----- ∂ϕ2

∂�---------

� 0

*∫–

� 0

2----- ϕ2[ ]0

*– 0= = =

∂ �∂ �------ 4 ∂ �

∂�------+ 0=

∂ � �∂ �--------- 4 � � 1+ � � 1––

2∆�------------------------------–=

� � �( ) ℜ �65 �( ) i 3�, ∆�

( )exp{ }=

d 5d�-------- i 374 3 ∆

�sin3 ∆�------------------

5+ 0=

Page 14: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

14 Meteorological Training Course Lecture Series

ECMWF, 2002

(17)

and therefore the phase speed is

(18)

A dispersion(phasespeeddependentonwavenumber ) is introducedby thespacediscretizationin thesenseof

decreasing the computed phase speed compared with the continuous solution.

The phase speed becomes 0 when (wavelength )

The group velocity (at which energy is carried) is

in the continuous equation

in the discretized equation

which reaches a value of (propagation in the wrong direction) for the shortest waves .

It is illuminatingto seehow accuratelyafinite differenceapproximationrepresentsthederivativeof aknown func-

tion. Suppose , where is thewavenumberand is thewavelength.Substi-

tuting into (7) gives (dropping the and ignoring ).

Therefore,thefinite differenceapproximationis equalto theexactvaluemultipliedby acorrectionfactor . If the

wavelength consists of grid lengths we have , and the correction factor becomes

Similar calculation for the fourth order scheme shows that

Plotting against for theseschemes(seeFig. 4 lateron) shows thatabout10 grid lengthsarerequiredto de-

scribeaccuratelythebehaviour of onewave andtheshortestwavesarebadlymistreated.Theplotsalsoshow that

thefourth-orderschemeis moreaccuratethanthesecond-orderscheme.This canbeillustratedby examiningthe

behaviour of for the large wavelengths ( large, small). Using series expansions we find that

5 5 0 i 384 * �( )exp=

4 * 4 3 ∆�

sin3 ∆�------------------ 93( )= =

3

3 ∆�

π= λ 2∆�

=

4 gd 384( )

d3---------------- 4= =

4;:* d 3<4 *( )d3------------------ 4 3 ∆

�( )cos= =

4– 3 ∆�

π=

ϕ�

( ) ℜ � i 3 �( )exp{ }= 3 2π�

⁄=�

ϕ ℜ � )

ϕ � ′ i 3 � ∆�

+( )[ ] i 3 � ∆�

–( )[ ]exp–( )exp2∆�---------------------------------------------------------------------------------------------

i 3 �[ ]exp2∆�----------------------- i 3 ∆

�[ ] i 3 ∆

�–[ ]exp–exp( )= =

i 3 i 3 �[ ] 3 ∆�

sin3 ∆�------------------

exp=

=$ 3 2π $ ∆�⁄=

= >sin>----------- >; 2π$------= =

43---

>sin>----------- 1

3--- 2sin >

2>--------------–=

= $

= $ >

Page 15: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 15

Sincethecorrectvalueof is unity, this shows that secondandfourth-orderschemeshave secondandfourth-

order errors. In general, if the scheme is said to beth order.

2.4 Time discretization: Stability and computational mode

Finitedifferencescanbeusedfor timederivativesaswell asspacederivatives—thatiswerepresenttimederivatives

in termsof valuesatdiscretetimelevels.If is thetimeinterval (usuallycalledthetimestep)then thetimelevels

aregivenby with Now thegrid-pointvalueof atposition at time is denotedby

.

Usually either forward or centred time differences are used:

(i) forward

(ii) centred

Once again, centred differences are more accurate than forward time differences

In orderto solve aninitial valueproblemwe mustcastthePDEin finite differenceform. Thedifferenceequation

is thenmanipulatedsoasto giveanalgorithmwhichgivesthegrid-pointvalueof at timelevel in terms

of the values at earlier time levels.

As anexampleconsidertheadvectionequationwith aforwardtimedifferenceandbackward(upstream)spacedif-

ference

This schemeis describedasbeingfirst orderin time andspace.Manipulationof thedifferenceequationprovides

the following algorithm for solving the equation

(19)

Knowing everywhereat time allows usto calculatethenew valueat time grid point by grid point;

this is an example of anexplicit scheme.

Let’s try a solution of the form

Substituting in (19) we get

second order=

1> 2

6-----– 1 O > 2( )+= =

fourth order=

1> 4

30------– 1 O > 4( )+= =

==

1 O > +( )+= ?

∆ �� + ? ∆ �= ? 0 1 …, ,= ϕ� � � +

ϕ �+

∂ϕ∂ �------

�+ ϕ �+ 1+ ϕ �+–

∆ �------------------------- O ∆ �( )+→

∂ϕ∂ �------

�+

2ϕ �+ 1+ ϕ �+ 1––

2∆ �------------------------------- O ∆ � 2( )+→

ϕ ? 1+( )

∂ϕ∂ �------ � 0

∂ϕ∂�------+ 0

ϕ �+ 1+ ϕ �+–

∆ �------------------------- � 0

ϕ �+ ϕ � 1–

+–

∆�------------------------

+→ 0 � 0 0>( );= =

ϕ �+ 1+ ϕ �+ α ϕ �+ ϕ � 1–

+–( ) α;–

� 0∆ �∆�------------= =

ϕ � ? ? 1+( )

ϕ �+ ϕ0 #@3�, ∆�

ω ? ∆ �–( )exp=

Page 16: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

16 Meteorological Training Course Lecture Series

ECMWF, 2002

where (complex number).

If b>0 is exponentially increasing with time (unstable)

if b<0 the solution is damped

if b=0 the solution is neutral (amplitude constant in time)

Also, as we have approximated the operator , we introduce yet another dispersion

Another scheme that arises is

Now we have a setof simultaneousequationswhich have to besolvedfor the ; this is anexampleof anim-

plicit scheme.

Both theabove schemesareexamplesof two-time-level schemes.That is thefinite differenceequationonly uses

information from two time levels. Later we will come across examples of three-time-level schemes.

Justbecausewecanproduceanalgorithmfor solvinganequation,it doesnot follow thatits usewill provide real-

istic solutions.For example,if weuseaforwardtimedifferenceandcentredspacedifferencein theadvectionequa-

tion we get

This is anexplicit two-time-level schemewhich is first orderin time andsecondorderin space.It appearsto bea

suitablealgorithmfor solvingtheequation.However it will beshown laterthat it hasthepropertythatthediffer-

ence between its exact and numerical solution increases exponentially with time—the scheme is unstable.

The ratio is called the C.F.L. number(after Courant,Freidrichsand Levy), or sometimesjust the Courant

number. We will see that it is of great significance when we consider the stability of numerical schemes.

In three-time-level schemes there is an extra complication. Let us consider the (leapfrog) scheme:

andtry a solution wherethesuperindex of meansexponentiation.If themodulusof

is greaterthanone,thesolutionis unstable.If it is smallerthanonethesolutionis dampedandif it is onethe

solution is neutral. Now substitute into the discretized equation and we get

which has two solutions

# ω �–( )exp α # 3 ∆�

( )sin–=

ω #A�+=

ϕ �+

�∂∂

ϕ �+ 1+ α4--- ϕ � 1+

+ 1+ ϕ � 1–

+ 1+–( )+ ϕ �+ α4--- ϕ � 1+

+ϕ � 1–

+–( )–=

ϕ+ 1+

ϕ �+ 1+ ϕ �+ α2--- ϕ � 1+

+ϕ � 1–

+–( )–=

α

ϕ �+ 1+ ϕ �+ 1– α ϕ � 1+

+ϕ � 1–

+–( )–=

ϕ �+ ϕ0λB+ #A3�, ∆�

( )exp= λλ

λ2 2# C λ 1–+ 0; p α 3 ∆�

( )sin–≡=

Page 17: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 17

It is now necessaryto show that theschemeunderconsiderationis convergentby makinguseof theLax–Richt-

meyer theorem.It caneasilybeshown thattheaboveschemesareconsistent,andsoconvergenceis assuredif they

arestable.To do this we have to considerthebehaviour of initial errorsandexamineif they grow exponentially.

However, there are various ways in which this can be done. Here we will consider only three approaches.

(a) The energy methodin which the schemeis consideredunstableif the "energy" definedearlier

increases with time.

(b) ThevonNeumannseriesmethodin whichthebehaviour of asingleFourierharmonicis studied;the

stability of all admissible harmonics is a necessary condition for the stability of the scheme.

(c) The matrix method

2.5 Stability analysis of various schemes

2.5 (a) Methods of stability analysis .

(i) Energy method.

Earlierwe foundthat,for theadvectionequationwith periodicboundaryconditions,theenergy wascon-

served. We now want to study an analogous quantity given by

As anexampleof how to applythismethod,wewill studythestabilityof (19). Thefirst stepis to deriveanexpres-

sion for . This is done by multiplying(19) by to give

Substituting for in the RHS and rearranging

Summing over all gridpoints and using the boundary condition leaves

Therefore, in order to prevent the energy growing from step to step we require

(a) which implies

(b) which implies

λ #DC 1 C 2– ------------>1 physical mode+=

λ # C 1 C 2––= -------------> 1 computational mode–∆ - 0 ∆ E 0→;→

∆ - 0 ∆ E 0→;→

) �( )) +

) + 12--- ϕ � +( )

2∆�

� 2=

(1+

∑=

ϕ � + 1+( )2

ϕ �+ 1+ ϕ �++( )

ϕ �+ 1+( )2

ϕ �+( )2

– α– ϕ �+ 1+ ϕ �++( ) ϕ �+ ϕ � 1–

+–( )=

ϕ �+ 1+

ϕ �+ 1+( )2

ϕ �+( )2

– α ϕ �+( )2

ϕ � 1–

+( )

2–{ }– α 1 α–( ) ϕ �+ ϕ � 1–

+–( )

2–=

ϕ1

+ϕ ( 1+

+=

) + 1+ ) +– α 1 α–( ) ϕ �+ ϕ � 1–

+–( )

2∆�

� 2=

(1+

∑–=

α 0≥ � 0 0≥

1 α–( ) 0≥ α� 0∆ �∆�------------ 1≤=

Page 18: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

18 Meteorological Training Course Lecture Series

ECMWF, 2002

Thismeansthat,having chosenthegrid length , wewill only getastablesolutionif thetimestepis chosenso

that . But notethatif weensurestabilityby having , theenergy is forcedto decayfrom step

to step.

Theenergy methodis a quitegeneralapproachfor analysingdifferenceschemesandcanbeusedfor non-linear

problemswith complicatedboundaryconditions.However for mostcasesit requiresconsiderableeffort andinge-

nuity in order to derive practical stability criteria.

(ii) Fourier series method.

Thiswasintroducedby J.vonNeumannand,by comparisonwith theenergy method,it is simpleto applyandpro-

vides considerable insight into the performance of different schemes.

Once again consider the original advection equation(10). If the initial condition is given by

where is the number of waves, then we know that the true solution is

(20)

Now consider the finite difference equation. The initial condition is

and, in general, the solution is given by

(21)

where is a complex quantity which depends upon the finite difference scheme and the wavemunber .

If we have (22)

Therefore, gives the fractional change in amplitude/timestep and provides information about the phase.

Comparing(22) with the analytic solution(20) shows the following.

(a) Thestability of the finite difference scheme is assured if for all

(b) The numericalschemehasintroduceda fictitious dampingof per time step;if

(no damping) the scheme is said to beneutral.

(c) Thephasespeedof thenumericalsolutionis givenby ; this is usuallydifferentfrom

andso a phaseerror is introduced.A convenientmeasureof this is the relative phasespeed

.

(d) Since the speedof the disturbancedependsupon the wave number there is computational

dispersion; this meansthata disturbancemadeup of a varietyof Fouriercomponentswill not keep

its shape. In other words the group velocity is not the same as the phase velocity.

For partialdifferentialequationswith constantcoefficients,thestabilitycriteriongivenin (a) is toostringentsince

∆�

∆ � ∆� � 0⁄≤ 0 α 1≤ ≤

ϕ�

0,( ) �( ) 4FB i 3 �[ ] 3;exp2π�------ �= = =

ϕ� �,( ) 4FB i 3 � � 0

�–( )[ ]exp=

ϕ �0 4FB i 3 � �[ ]exp=

ϕ �+ λ B( )+ 4FB i 3 � �[ ]exp=

λB 3

λB λ B iθ[ ]exp= ϕ �+ 4FB λB + i 3 � � ? θ3-------+

exp=

λB θ

λB 1≤ 3G

λ B=G

1=

� θ 3 ∆ �⁄–=� 0H � � 0⁄=

� g ∂ 3 �( ) ∂ 3⁄=

Page 19: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 19

a legitimateexponentialgrowth of aphysically realisticsolutionmaybepossible.Thereforethestability criterion

should be

whichallowsanexponential,but not faster, growth of thesolution.However, whenweknow thatthetruesolution

does not grow (as for the advection equation), it is customary to ensure that .

(iii) The matrix method.

Let be a vector at time ; if we can express as

(scheme of two time levels)

where is called the amplification matrix, the method runs as follows:

Let be the eigenvectors of corresponding to the eigenvalues

We project vectors onto the space defined by these eigenvectors

Therefore we obtain, by repeated multiplication by the amplification matrix

where superindex stands for the exponential operation.

This solution will be bounded when for all and, in this case, the scheme is stable.

Thismethodis equivalentto thevonNewmanmethodwhentheFourierbasisfunctionsareeigenvaluesof theam-

plification matrix.

2.5 (b) Forward time schemes.

(i) Forward time differencing with non-centred space differencing.

This is the scheme introduced inSubsection 2.4 and may conveniently be written as

Thisisanexplicit two-time-level schemewhichisfirstorderin spaceandtime.It is calledupwindschemeif

and downwind if .

Substituting into the above algorithm yields

λB 1 O ∆ �( )+≤

λ B 1≤

U + ? ∆ � U + 1+

U+ 1+ AU +=

A

V B A λB

AV B λB V B=

U

U0 5 0

BV BB∑=

U+ U0

BλB +( )V BB∑=

?( )

? ∞→ λB 1≤

ϕ �+ 1+ ϕ �+ α ϕ �+ ϕ � 1–

+–( ) α;–

� 0∆ �∆�------------= =

� 0 0>� 0 0<

ϕ �+ λB( )+ 4 i 3 � �[ ]exp=

Page 20: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

20 Meteorological Training Course Lecture Series

ECMWF, 2002

Since is complex we can express it as

Substitutingthis expressionin theabove,andequatingrealandimaginarypartsgivestwo equationsfor and

in terms of and

To study the stability we require an expression for . Squaring and adding then gives

Since wecanonly satisfythestabilitycriterion if ; therefore,werequire

(upwind) and (CFL limit) (the sameresult as when the energy methodwas used).The

scheme is said to be conditionally stable.

To studythedampingandphaseerrors,it is oftenconvenientto think in termsof wavelengthsconsistingof grid

lengths;we thenreplace by . It canthenbe shown that the dampingper time step andrelative

phase error can be expressed as

(23)

(24)

Thecharacteristicsof aschemecanbeconvenientlydisplayedby plottinggraphsof and againstI for various

choicesof . However, to make comparisonsbetweenschemeseasier, we will only considervaluesof and

for and10 with . Theseareshown in Table2. Clearly theupstreamdifferencingscheme

reproducesthephasespeedverywell (thoughtherearephaseerrorswhen when and

when ), but the damping is excessive.

(ii) Forward time differencing with centred space differencing (FTCS).

Using the Fourier series method it is easy to show that

Therefore, alwaysandsotheschemeis unstablefor all valuesof and ; theschemeis thensaidto be

λB 1 α 1 i 3 ∆�

–[ ]exp–{ }–=

=1–α 1 3 ∆�

i 3 ∆�

sin+( )cos–( )

λB

λ B λB θ i θsin+cos( )=

λ Bθ α 3 ∆

λB θcos 1 α 1 3 ∆�

cos–( )–=

λ B θsin α 3 ∆�

sin–=

λB

λB 2 1 2κ α 1–( ) 1 3 ∆�

cos–( )–=

1 3 ∆�

0≥cos– λB 1≤ α α 1–( ) 0≤( )� 0 0≥ � 0∆ � ∆

�⁄ 1≤

$3 2π∆

� $⁄ G( )H( )

G1 2α α 1–( ) 1 >cos–( )+[ ]

12--- >; 2π$------= =

H 1α >------- α >sin–

1 α 1 >cos–( )–---------------------------------------

atan–=

G H $α

G H$ 2 3 4 6, , ,= α 0.5=

α 1: H 1<≠ 0 α 1 2⁄< <H 1> 1 2⁄ α 1< <

ϕ �+ 1+ ϕ �+–

∆ �------------------------- � 0

ϕ � 1+

+ϕ � 1–

+–

2∆�------------------------------

+ 0=

λB 2 1 α2 3 ∆�

sin( )2+=

λB 2 1≥ α 3

Page 21: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 21

absolutelyunstable,althoughthespacediscretizationis moreaccuratethanin theupwindscheme,which is condi-

tionally stable.

(iii) Implicit Schemes.

Considerwhathappenswhenthespacederivative is replacedby theaveragevalueof thecentredspacedifference

at time levels and . Usingforwardtimedifferencingandthenotationfor spatialdifferencesintroducedin

Subsection 1.4, we have

Rearranging yields

(25)

This is animplicit two-time-level scheme(theCrank–Nicolsonscheme)which is secondorderin timeandsecond

orderin space.Performinga stability analysesin theusualway we find that . Thereforetheschemeis

absolutelystableandneutral(no damping),but furtheranalysisshows that therearesignificantphaseerrors(see

Table 2).

Notethattheproblemwith usingthistypeof schemeis thatwecannotsimplyexpressthenew value in terms

of known valuesat previous times.Thus,we have a large numberof simultaneousequationswhich have to be

solved(i.e. a tridiagonalmatrix hasto beinverted).For simplecasesthis canbedoneexactly, but for morecom-

plicated problems expensive successive approximation methods have to be used.

This implicit approach can be generalised to

where and are weights such that .

There are three special cases which should be highlighted:

(a) and gives the absolutely unstable FTCS scheme.

(b) and results in the fully forward implicit scheme.

(c) yields the schemedescribedabove in which the derivativesat time levels

and are equally weighted.

A stability analysis of the general scheme shows that

Thereforethere is absoluteinstability if the presentvaluesare weightedmore heavily than the future ones

whereasthereis absolutestability if moreor equalweight is given to the future values

? ? 1+

ϕ �+ 1+ ϕ �+–

∆ �-------------------------� 0

2----- δ2- ϕ �

+δ2- ϕ �

+ 1++( )+ 0=

ϕ �+ 1+ α4--- ϕ � 1+

+ 1+ ϕ � 1–

+ 1+–( )+ ϕ �+ α4--- ϕ � 1+

+ϕ � 1–

+–( )–=

λB 1=

ϕ �+ 1+

ϕ �+ 1+ ϕ �+–

∆ �------------------------- � 0 β + δ2- ϕ �+

β+ 1+ δ2- ϕ �+ 1++( )+ 0=

β+ β+ 1+ β + β + 1++ 1=

β+ 1= β+ 1+ 0=

β+ 0= β+ 1+ 1=

β+ β+ 1+ 1 2⁄= = ?? 1+

λ 2 1 α2β+2 3 ∆�

sin( )2+

1 α2β + 1+2 3 ∆

�sin( )2+

------------------------------------------------------=

β+ 1/2, β+ 1+ 1/2<>( )β+ 1/2, β+ 1+ 1/2≥( )≤( )

Page 22: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

22 Meteorological Training Course Lecture Series

ECMWF, 2002

2.5 (c) The leapfrog scheme.

This is probablythemostcommonschemeusedfor meteorologicalproblems.The"leapfrog"refersto thecentred

time difference which is used in conjunction with centred space differences

(26)

This is anexplicit three-time-level schemewhich is secondorderin spaceandtime.UsingtheFourierseriestech-

nique to test stability, we find that

giving

Thereforetherearetwo solutionsfor which is a consequenceof usinga three-time-level scheme(in generalan

-time-level scheme will have solutions for with each solution being referred to as a mode).

It canbeshown thatfor oneof themodes as ; this is referredto asthephysicalmode.Theother

mode has no physical significance and is called the computational mode (for this mode as ).

If we have andso is real.Consequently for bothmodesandso theschemeis

conditionally stable and neutral. Further analysis shows that for the physical mode

, (27)

whereasfor thecomputationalmodethephasespeedis in theoppositedirectionto ( ) andtheamplitude

of themodechangessignevery time step.In general,thesolutionto thefinite differenceequationwill bea com-

bination of the physical and computational modes.

Thetablesof and against (Table2) for thephysicalmoderevealthatthephaseerrorsareworsethanfor the

upstreamdifferencescheme,but theleapfrogschemehastheimportantpropertythatthereis no dampingfor any

choice of .

Thecharacteristicsof theleapfrogschemecanbeimprovedby usingafourthorderfinite differenceschemefor the

spacederivative (seeSubsection2.1)—theschemeis thensaidto have fourth-orderadvection.Table2 shows that

this hasno effect on thedamping(theschemeremainsneutral),but it doesleadto an improvementin thephase

speed. However the stability condition is now more restrictive since we require .

Theleapfrogschemeis very popularbecauseit is simple,secondorderandneutral;however therearestill phase

errorsandcomputationaldispersion.Also, thecomputationalmodehasto becontendedwith andthedependent

variable has to be kept at two time levels.

To starttheleap-frogschemeit is customaryto usea forwardtimestepand,in orderto suppressseparationof the

solutions at odd and even time steps, it is usual to either

(i) use an occasional forward time step

(ii) use a weak time filter of the type

ϕ �+ 1+ ϕ �+ 1– α ϕ � 1+

+ϕ � 1–

+–( )–=

λ2 2iC λ 1–+ 0 C; α 3 ∆�

sin–= =

λ iC 1 C 2–±=

λ� � 1– λ

λ 1→ ∆�

∆ � 0→,λ 1–→ ∆

�∆ � 0→,

α 1≤ C 1≤ 1 C 2– λ 1=

H 1α >------- C–

1 C 2–-------------------

; p=-α > q=2π$---;sinatan–=

� 0H 1–=

G H $

α

α 0.73≤

Page 23: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 23

where the tilde denotes the filtered value ( is typically 0.005).

Anothervariantof theleapfrogschemeis thesemi-momentumapproximation.For this,thewind field is smoothed

before multiplying by the derivative. Using the notation introduced inSubsection 2.1, the scheme becomes

For constant , this reduces to(26).

2.5 (d) The Lax–Wendroff scheme.

This is a usefulschemebecauseit is secondorderin spaceandtime.but (unlike theleapfrogscheme)it is only a

two-time-level scheme and so has no computational mode.

TheLax–Wendroff schemecannotbeconstructedby anindependentchoiceof finite differenceapproximationsfor

the space and time derivatives. It is derived from a second-order accurate Taylor series expansion

Using the advection equation this becomes

(28)

Replacing the derivatives by second order accurate finite difference approximation gives

(29)

This scheme can be replaced by one in which there are two steps:

(i) provisional values of are calculatedusing a forward time step with centred space

differencing

(ii) The are calculatedfrom centredspaceand time differencesusing the provisional values

The stability analysis shows that

ϕ �+ 1– ϕ �+ 1– ϕ �+ 2–2ϕ �+ 1–– ϕ �++( )+=

δE ϕ E � - δ - ϕ-

–=

ϕ� � ∆ �+,( ) ϕ

� �,( ) ∆ � ∂ϕ∂ �------ ∆ � 2

2--------∂2ϕ

∂ � 2---------+ +=

ϕ� � ∆ �+,( ) ϕ

� �,( ) � 0– ∆ � ∂ϕ∂�------ � 0

2∆ � 22

--------------∂2ϕ∂� 2

---------+ +=

ϕ �+ 1+ ϕ �+ α2--- ϕ � 1+

+ϕ � 1–

+–( )–

α2

2------ ϕ � 1+

+2ϕ �+– ϕ � 1–

++( )+=

ϕ � 1 2⁄+

+ 1 2⁄+

ϕ � 1 2⁄+

+ 1 2⁄+ 12--- ϕ � 1+

+ϕ �++( ) α

2--- ϕ � 1+

+ϕ �+–( )–=

ϕ �+ 1+

ϕ � 1 2⁄+

+ 1 2⁄+

ϕ �+ 1+ ϕ �+ α ϕ � 1 2⁄+

+ 1 2⁄+ ϕ � 1 2⁄–

+ 1 2⁄+–( )–=

Page 24: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

24 Meteorological Training Course Lecture Series

ECMWF, 2002

(30)

and so the scheme is stable provided . The ratio of the phase speed to the advection velocity is given by:

(31)

Table3 showsthatthecharacteristicsof theLax–Wendroff schemefall betweenthoseof theupstreamdifferencing

and leapfrog schemes. The characteristics of the scheme can be improved by using fourth order advection.

2.5 (e) Intuitive look at stability.

If theinformationfor thefuturetime step“comesfrom” insidetheinterval usedfor thecomputationof thespace

derivadive,theschemeis stable.Otherwiseit is unstable.TheCFL number is thefractionof travelledby an

air parcel during seconds.

-Downwind scheme (unstable):

Upwind scheme (conditionally stable):

Leapfrog (conditionally stable)

Implicit (unconditionallystable).Theinterval coversthewholex-axisbecausewehave to solveacoupledsystem

of equations including all the points:

G1 α2 1 α2–( ) 1 >cos–( )2–[ ]

12--- >; 2π$------= =

α 1≤

H 1α >------- α >sin–

1 α2 1 >cos–( )–-----------------------------------------

atan––

α ∆�

∆ �

j-1 j j+1

x

U0

— interval used for thecomputation of ¶φ/¶x

x: point where the informationcomes from (xj – U0∆t

j-1 j j+1

x

U0

o

x:

o: α 1>

α 1<

j-1 j j+1

x

U0

o

Page 25: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 25

2.6 Group velocity

For a non-dispersive equation,planewave solutionshave theform , wherethephasevelocity

is independentof thewave number . However, if thereis dispersionthewave solutionshave thesameform, but

now . Even if the original equation is non-dispersive, a discrete model will introduce dispersion.

In order to understand the effect of dispersion it is necessary to introduce the group velocity given by

This representsthespeedof propagationof theenergy of wave number andwhenthereis dispersionwe have

and . For a non dispersive medium .

For thelinearadvectionequationweknow thatany disturbanceshouldmovewithoutchangeof shapewith thead-

vectingvelocity (which is independentof ). However, whentheproblemis solvednumericallywe find that

and dispersion is introduced. For example, the phase velocity from the leapfrog scheme is such that

However the group velocity gives

Therefore, when we get the following (Table 2).

Notethatthetwo gridlengthwaves( ) travel in thewrongdirectionwith speed , whilst thelongerwaves

move with a speed approaching the advecting velocity.

To illustrate the effect of computationaldispersionconsiderthreecasestaken from VichenevetskyandBowles

(1982).Eachintegrationwascarriedout with the leapfrogschemeusing (henceany effectsaremainly

due to the space discretization).

TABLE 2. RATIO OF THE RELATIVE PHASEERROR AND THE RELATIVE GROUP VELOCITY ERROR FOR

DIFFERENTWAVELENGTHS.

2 3 4 6 10

0.00 0.43 0.67 0.86 0.92

-1.00 -0.55 0.00 0.59 0.85

j-1 j j+1

x

U0

o

i 3 � � �–( )[ ]exp �3

� � 3( )=

� g

� g∂

∂ 3------ 3 �( )–

3� � 3( )= � g � g 3( )= � g �=

� 0 3� � 3( )=

H �� 0-----

1α >------- α >sin–

1 α 1 >cos–( )–---------------------------------------

>;atan 2π$------= = =

Hg

� g

� 0-----

>cos

1 α >sin( )2–[ ]1 2⁄-------------------------------------------= =

α 0.5=

H( ) Hg( )

$HH

g

$ 2= � 0

α 0.2=

Page 26: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

26 Meteorological Training Course Lecture Series

ECMWF, 2002

For thecaseshown in Fig. 3 (a), thelong-wave componentsmove with a groupvelocity of about ( for

thelongwaves)whilst thetwo-gridlengthwavestravel upstreamwith speed ; thefour gridlength

waves are stationarysince . Therefore,during the integration the computationaldispersionhas

causeda broadeningof thedisturbance(this is not causedby dissipationbecausethe leapfrogschemeis neutral)

and has generated parasitic short gridlength waves which travel upstream.

Thedisturbanceshown in Fig. 3 (b) is dominatedby waveswith . Thereforethedominantfeatureof thein-

tegration is the upstream movement of the wave packets with a group velocity of about ,

Figure 3. llustration of computational dispersion using the leapfrog scheme with . Taken from

Vichenevetsky and Bowles (1982).

In thelastcase,Fig. 3 (c), theinitial disturbanceconsistsof two-gridlengthwavessuperimposedupona broader-

� 0H

g 0≈� g$ 2=( ) �– 0=

� g$ 4=( ) 0=

$ 2=� 0–

α 0=

Page 27: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 27

scalefeature.Consequently, asin case(a), thetwo-gridlengthwavesmove upstream,whilst thepartof theinitial

disturbance composed of the larger wavelengths moves downstream with a group velocity of about .

Numericalschemesshouldbe examinedfor their computationaldispersion.However, in practicethe effectsof

computationaldispersionareobscuredbecauseof thedissipationinherentin many numericalschemesor theex-

plicit diffusion that is introduced to control the two-gridlength waves.

2.7 Choosing a scheme

Thereis agreatvarietyof finite differenceschemesandsoit is worthconsideringwhatfactorsshouldbetakeninto

account when choosing one.

(a) It is desirableto have high-ordertruncationerrorsfor the spaceand time differences.In general

centred differences are more accurate than one-sided differences.

(b) Ideally we would like thephaseerrorsanddampingto besmall;however, it is usuallynecessaryto

compromisebetweenthesetwo. Plotsof and against area convenientway of examining

these aspects.

(c) Theadvantageof anexplicit schemeis that it is easyto program,but it will only beconditionally

stableandsothechoiceof time stepis limited. Implicit schemesareabsolutelystable;however the

price we pay for this is that at every time step a system of simultaneous equations has to be solved.

(d) If the schemehas more than two time levels there will be computationalmodesand possibly

separationof the solutionat odd andeven timesteps.Also morefields of the dependentvariable

have to be stored than for the a two-time-level scheme.

� 0

G H $

Page 28: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

28 Meteorological Training Course Lecture Series

ECMWF, 2002

Figure 4. Response function () against number of gridlengths per wavelength ( ) for various semi-discrete

versionsof theone-dimensionallinearadvectionequation.Notethatfor theleapfrogscheme is thesameasthe

correction factor introduced inSubsection 2.3.

� $�

=

Page 29: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 29

Figure 5. Solutions of the linear advection equation using various numerical methods for a Gaussian initial

disturbance and a uniform wind. Full line:- numerical solution; dot-dashed line: exact solution.

Page 30: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

30 Meteorological Training Course Lecture Series

ECMWF, 2002

Figure 0. Continued

Page 31: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 31

Figure 6. Solutions of the linear advection equation using various numerical methods for the Crowley test . Full

line:- numerical solution; dot-dashed line: exact solution..

Page 32: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

32 Meteorological Training Course Lecture Series

ECMWF, 2002

Figure 0. Continued.

A convenientway of comparingschemesis to considertheir behaviour for the longerwaves( large so and$ 3

Page 33: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 33

small).For eachschemewe canderive expressionsfor and in termsof ; thesecanthenbeex-

pandedaspower seriesundertheassumptionthat is small.If theschemeis saidto have th

orderdissipation,whereas indicatesthatthereare th orderphaseerrors.Thehighertheorderof

accuracy of the amplitude and phase speed the better.

Sometimesit is interestingto examinejust theeffectof spacediscretization.UsingasingleFouriercomponent,the

semi-discrete finite difference version of the linear advection equation may be expressed as:

where is the responsefunction.For the original PDE, for all and,ideally, our differencescheme

shouldreproducethis. Fig. 4 shows for secondandfourth orderspacedifferencingasa functionof (this is

thesameasthecorrectionfactor describedin Subsection2.3); alsoshown arethevaluesfor thespectraland

finite elementmethodswhicharediscussedlater. Theseresultssuggestthatthestandardfinite differenceapproxi-

mations for the advection are inferior to the spectral and finite element representations.

As well asexaminingthebehaviour of schemestheoretically, it is oftenilluminating to actuallysolve theequation

numericallyusingthevarioustechniques.For exampleGadd(1978)consideredthebehaviour of aGaussianprofile

whilst Carpenter(1981)useda stepfunction.Collins (1983)preferreda severetestfirst introducedby Crowley

(1968).For this theadvectingvelocity varieswith ( with and constant).It is theneasyto

show that if then the analytical solution to the advection equation is

The particular functions chosen by Collins are:

alongwith . It canbeshown thatthefluid particleswill all repeattheir relative positionsaftera

time

Fig. 5 showstheresultsof usingvariousfinite differenceschemesto advectaGaussianshapeddisturbancewith a

constantwind (alsoshown arethe resultsof usingthe semi-Langrangian,spectralandfinite-elementtechniques

discussed later). For these calculations we have used

(maximum possible time step)

andthe integrationhascontinueduntil thedisturbancecrossesthedomainonce.In Fig. 6 arethecorresponding

resultsfor theCrowley testin whichtheinitial disturbancewasnormalisedsothatit hasamaximumvalueof unity.

Examination of these results gives a clear indication of the characteristics of each of the schemes.

No matterwhatmethodsareusedto selecta finite differencescheme,therewill inevitably beanelementof com-

promise—the perfect scheme does not exist.

2.8 The two-dimensional advection equation .

Before leaving the advection equation it is worth considering the two-dimensional version

> 2π $⁄=G H $

> G1 O > +( )+= ?H 1 O > +( )+= ?

∂ϕ∂ �------ i 3 � 0

�ϕ–=

� �1= 3� $

=

� � � � �+= �ϕ�

0,( ) �( )ln[ ]=

ϕ� �,( ) � �–( )ln[ ]=

� 0.9 1.6��---- 0

� �2---- �≤ ≤– 0.7– 1.6

��----

�2----

� �≤ ≤+= =

ϕ�

0,( ) �( )ln=

2 2�

1.6-------

� 0( )� � 2⁄( )--------------------ln=

� 110------ u0 1.0 ∆

�1.0 ∆ � 1

2---= = = =

Page 34: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

34 Meteorological Training Course Lecture Series

ECMWF, 2002

If this is put in finite difference form, the stability of the resulting difference equation can be examined by using

For conditionally stable schemes, the stability criterion usually has the form

where and .

Let and , and . We then have

If we maximise with respect to , and we get

Substituting for these in gives the stability criterion

If this becomes

Theappearanceof the is typicalwhengoingfrom oneto two-dimensionalproblems.It meansthatthestability

criterion is more restrictive than in the one-dimensional cases.

This problem can be overcome by the splitting technique discussed inSubsection 4.5 (a).

TABLE 3. DAMPING/TIME STEP( ) AND RELATIVE PHASEERROR ( ) FOR VARIOUS SCHEMESTO SOLVE THE ONE

DIMENSIONAL LINEAR ADVECTION EQUATION WHEN THE C.F.L. STABILITY CRITERION (FOR ABSOLUTELY STABLE SCHEMES).

(a) Damping/time step( )

Upstream differencing 0.00 0.50 0.71 0.87 0.95

Crank–Nicholson 1.00 1.00 1.00 1.00 1.00

Lax–Wendroff 0.50 0.76 0.90 0.98 1.00

Gadd 0.13 0.79 0.95 0.99 1.00

Leapfrog 1.00 1.00 1.00 1.00 1.00

4th-order leapfrog 1.00 1.00 1.00 1.00 1.00

∂ϕ∂ �------ � 0

∂ϕ∂�------ I 0

∂ϕ∂�------+ + 0=

ϕ+

ϕ0λ+ #J3 � $ �+( )[ ]exp=

K∆ � � 0 αsin

∆�------------------

I 0 βsin

∆�-----------------+ 1≤=

α 3 ∆�

= β $ ∆�=

� 0

�θcos= I 0

�θsin=

� � 02 I 0

2+( )1 2⁄

=

Kα β θ, ,( )

�∆ � θ αsincos

∆�-------------------------- θ βsinsin

∆�------------------------+=

Kα β θ

αsin βsin 1 and θtan∆�

∆�------- βsinαsin

-----------= = =

K

∆ � � 1

∆� 2

--------- 1

∆ � 2---------+

1 2⁄1≤

∆�

∆� ∆ L= = ∆ � ∆ L�2

------------≤

2

G Hα 1 2⁄ ×= α 1 2⁄=

G2∆�

3∆�

4∆�

6∆�

10∆�

Page 35: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 35

3. THE NON-LINEAR ADVECTION EQUATION

3.1 Introduction

An importantpropertyof theprimitive equationsis thattheadvective termsarenon-linear. In this sectionwe will

consider the simple non-linear advection equation

(32)

If initially thenthesolutionis . However, unlikethelinearadvection,this is animplicit

equationfor the dependentvariableandthe solutionno longerconsistsof the initial disturbancetravelling with

speed withoutchangeof shape.As it is anon-linearequation,in generalit doesnothaveananalyticalsolution.

Spectral 1.00 1.00 1.00 1.00 1.00

Finite element 1.00 1.00 1.00 1.00 1.00

Semi-Lagrangian(p=0, linear interpolation)

0.00 0.50 0.71 0.87 0.95

Semi-Lagrangian(p=0, cubic spline)

0.00 0.88 0.97 1.00 1.00

TABLE 2. CONTINUED

(b) Relative phase error ( )

Upstream differencing 1.00 1.00 1.00 1.00 1.00

Crank–Nicholson 0.00 0.41 0.63 0.81 0.93

Lax–Wendroff 0.00 0.58 0.75 0.88 0.95

Gadd 0.00 0.98 1.03 1.04 1.02

Leapfrog 0.00 0.43 0.67 0.86 0.95

4th-order leapfrog 0.00 0.65 0.89 0.99 1.00

Spectral 1.05 1.02 1.01 1.00 1.00

Finite element 0.00 0.87 0.99 1.01 1.00

Semi-Lagrangian(p=0, linear interpolation)

1.00 1.00 1.00 1.00 1.00

Semi-Lagrangian(p=0, cubic spline)

1.00 1.00 1.00 1.00 1.00

TABLE 3. DAMPING/TIME STEP( ) AND RELATIVE PHASEERROR ( ) FOR VARIOUS SCHEMESTO SOLVE THE ONE

DIMENSIONAL LINEAR ADVECTION EQUATION WHEN THE C.F.L. STABILITY CRITERION (FOR ABSOLUTELY STABLE SCHEMES).

(a) Damping/time step( )

G Hα 1 2⁄ ×= α 1 2⁄=

G2∆�

3∆�

4∆�

6∆�

10∆�

H2∆�

3∆�

4∆�

6∆�

10∆�

∂ �∂ �------ � ∂ �

∂�------+ 0=

� �( )= � � � �–( )=

Page 36: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

36 Meteorological Training Course Lecture Series

ECMWF, 2002

The propertiesof finite differenceforms of the non-linearadvectionequationcannotbe studiedusingthe tech-

niquesintroducedearlierfor investigatingthestability, phaseerrorsanddampingof thelinearversionof theequa-

tion. However we can usethe integral propertiesof the non-linearadvection equationto give guidanceabout

suitable finite difference schemes.

3.2 Preservation of conservation properties

Multiplying (32) by and integrating over the domain (assuming cyclic boundary conditions), we get

where is thetotalkineticenergy. Hence is conservedandit wouldbedesirablethatthefinite differenceform

of the equations preserved this property.

Considerthesemi-discreteform of theequationin whichonly theadvectiontermhasbeendiscretised.For various

schemes we will examine

and try to find schemes for which is conserved. The most obvious finite difference scheme is

Multiplying by and summing over all points gives

Sincethetermsarenot of theform therewill not becancellationof all thetermsandsotheenergy

is not conserved.

An alternative finite difference scheme can be derived by casting(32) in flux form

and then using

Analysis of this scheme reveals that once again energy is not conserved. However, the scheme

∂)∂ �------- 0 ) 1

2--- � 2 �d

0

*∫= =

) )

∂) ′∂ �--------- where ) ′ 1

2--- � �2∆

��∑=

) ′

∂ � �∂ �--------- � � � � 1+ � � 1––

2∆�------------------------------

–=

� �

∂) ′∂ �---------

12--- � �2 � � 1+ � �2 � � 1––( )�∑–=

M � 1+

M �–( )) ′

∂ �∂ �------

∂∂�------ �

2

2-----

–=

∂ � �∂ �---------

12---� � 1+

2 � � 1–2–

2∆�------------------------------

–=

� � 1+ � � 1–+

2-------------------------------

� � 1+ � � 1––

2∆�------------------------------

–=

Page 37: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 37

does conserve energy. Let us multiply both sides by and add over all the points of our domain, we get:

The terms joined by arrows cancel from consecutive grid-points and therefore the total sum is zero.

This suggests that suitable averaging can produce energy conserving schemes.

3.3 Aliasing

Aliasingoccurswhenthenon-linearinteractionsin theadvectiontermproduceawavewhichis tooshortto berep-

resented on the grid; this wave is then falsely represented (aliased) as a wave with a larger wavelength.

Supposewehaveadiscretemeshwith grid pointsandgrid length , giving adomain . The

shortestresolvablewaveonthisgrid hasawavelengthof ; thereforethemaximumwavenumber

is given by

Now consider how the non-linear product

is representedonourgrid.Suppose and aresingleFouriercomponentswith wavenumbers and respec-

tively.

Substitution in(32) gives

andso hascontributionsfrom wavenumbers and . Now if themagnitudesof boththesenew

wavenumbersarelessthan , canbecorrectlyrepresented.However, if either or aregreater

than , the non-linear product will be misrepresented on the grid.

∂ � �∂ �---------

� � 1+ � � � � 1–+ +

3-------------------------------------------

� � 1+ � � 1––

2∆�------------------------------

–= =

� � ∆�

�∂∂ ) '

16--- � � 1+

2 � � � �2 � � 1+ � �2 � � 1–– � � 1–2 � �–+( )�∑–=

� 1+( ) ∆� � � ∆

�=

λmin 2∆�

= $max

$max

�λmin---------- �

2-----= =

M � �( )∂ϕ∂�------=

� ϕ $1

$2

� �( ) 2π�------ $ 1� ϕ

�( );sin

2π�------ $ 2� � �;sin , 1–( )∆

�= = =

M 2π�------ $ 2 2π�------ $ 1� 2π�------ $ 2�

cossin=

2π�------ $ 212--- 2π�------ $ 1 $

2+( )� 2π�------ $ 1 $

2–( )�

sin+ sin

=

M $1$2+( ) $

1$2–( )$

max

M $1$2+ $

1$2–$

max

Page 38: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

38 Meteorological Training Course Lecture Series

ECMWF, 2002

Now considerwhatawavewith wavenumber will look likeonourgrid. A little trigonometricalmanipu-

lation reveals that

Thereforeon thegrid it is not possibleto distinguishbetweenwave numbers and . This means

thatif thenon-linearinteractionleadsto a wave number , then is misrepresentedas —hencethereis

aliasing

As an example,supposewe have a wave with wavelength , which correspondsto wave number

. Since , this wave numberis representedas , giving a wave-

length . This is illustrated below.

Figure 7. Graphical representation of aliasing.

3.4 Non-linear instability

As explainedabove,whentwo wave numbers and interactto give which is greaterthan , the

resultingwave is misrepresentedaswave number . Now if is oneof theoriginal waves

( say), then we have

giving (33)

To gettherangeof possiblevaluesof thatcansatisfy(33), weinsertthemaximumandminimumvaluesthat

can have.

(i) The maximum value of is which gives —that is .

(ii) The minimum values of is 0 which gives —that is .

Therefore,if one of the waves involved in the non-linear interactionhas a wavelength less than (i.e.

), aliasingcausesachannelingof energy towardsthesmallwavelengths.Thecontinuousfeedback

of energy leadsto a catastrophicrise in thekinetic energy of wavelengths to —this processis referred

to as non-linear instability.

Notethatevenif wavelengthslessthan arenot initially present,non-linear interactionswill eventuallypro-

duce them.

$N$max>

2π�------ $ � � sin

2π�------ 2$ max$–( )� �sin–=

$ $ * 2$ max$–=$O$

max> $ $ *

λ 4∆�

3⁄=$ �λ⁄ 3� 4⁄= = $N$

max≥ � 2⁄= $ * � 4⁄=

λ* � $ *⁄ 4∆�

= =

$1

$2

$1$2+( ) $

max$ * 2$ max$1$2+( )–= $ *

$2

$1 2$ max

$1$2+( )–= 2$ 1 2$ max

$2–=

$1

$2

$2

$max

$1

$max 2⁄= λ1 4∆

�=

$2

$1

$max= λ1 2∆

�=

4∆�

2∆�

λ1 4∆�

≤ ≤2∆�

4∆�

4∆�

Page 39: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 39

3.5 A necessary condition for instability

Consider the semi-discrete case

(34)

If everywhere,(34) can be rewritten as

Define the weighted energy as

We then have

The sums of the products are zero if there are cyclic boundary conditions. Therefore

and so is conserved. This means that if initially the weighted energy is , then at any time we have

If , then this gives

,

which shows that thesolutionis boundedevenif is rough.Clearly it is necessaryfor theadvectingvelocity to

change sign in order to obtain instability. But note that this no longer holds when time stepping is introduced.

3.6 Control of non-linear instability

(a) Eliminatethewavesthatcausenon-linear instability by Fourieranalysingthefields,discardingthe

wavelengthslessthan andthenreconstitutingthefield (in fact it is only necessaryto discard

wavelengths less than ).

∂ϕ �∂ �--------- � � �( )

ϕ � 1+ ϕ � 1––

2∆�------------------------------

–=

� � �( ) 0>

1� �-----

∂ϕ �∂ �---------

ϕ � 1+ ϕ � 1––

2∆�------------------------------

–=

) w

) w1� �-----

ϕ �22-----∑=

∂) w

∂ �----------- ϕ � ϕ � 1+ ϕ � 1––

2∆�------------------------------

�∑–=

12∆�---------- ϕ � ϕ � 1+ ϕ � ϕ � 1–�∑–�∑

–=

∂ ) w

∂ �----------- 0=

) w ) �

1�P�-----

ϕ �2 �( )2

-------------�∑ )=

& minimum 1 � �⁄( )=

ϕ �2 �( )�∑2&------ )=

4∆�

3∆�

Page 40: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

40 Meteorological Training Course Lecture Series

ECMWF, 2002

(b) Usea smoothingoperatorwhich reducestheamplitudeof theshortwaveswhile having little effect

on the meteorologically important waves.

(c) Introduce an explicit diffusion term.

(d) Use a time integration scheme with built-in diffusion (e.g. the Lax–Wendroff scheme).

(e) Introduce smoothing directly into the finite difference schemein order to preserve integral

constraintssuchasenergy conservation.A classicexampleof this is the Arakawa schemefor the

non-linear vorticity equation.

(f) Usea Galerkintechnique(spectralor finite element).For these,thespacediscretizationconserves

quadratic invariants, though this property cannot be guaranteedwhen time discretization is

introduced.

(g) Use a semi-Lagrangian scheme for advection.

4. TOWARDS THE PRIMITIVE EQUATIONS

4.1 Introduction

A majorproblemin numericalweatherpredictionis to haveaproperrepresentationof thegeostrophicadjustment

process—this is associated with gravity–inertia waves.

In theearlydaystheadjustmentprocessin numericalforecastswastakencareof by usingthegeostrophicapprox-

imationin thevorticity equation;theeffect of this wasto eliminatethegravity wavesentirely. Latertheprimitive

equations were used and then the treatment of the gravity–inertia waves became very important.

4.2 The one-dimensional gravity-wave equations

The one-dimensional linearised gravity-wave equations (derived from the shallow-water equations) are

(35)

Theseequationscanbeeasilymanipulatedinto two separatewaveequationsfor and , hencethey form asys-

temof hyperbolicequations.Takingthetimederivativeof the -equationandthe -derivativeof the -equation

we get, upon elimination of ,

and similarly for

If we seek solutions of the form

(36)

wefind thatthephasespeedof thewavesis givenby . Therefore,therearetwo wavestravelling in

opposite directions along the-axis.

∂ �∂ �------ � ∂ �

∂ �------+ 0∂ �∂ �------

� ∂ �∂�------+ 0= =

� �� � �

∂2 �∂ � 2--------- � � ∂2 �

∂� 2

---------+ 0=

� � ˆ i 3 � � �–( )[ ] �exp � ˆ i 3 � � �–( )[ ]exp= =

� � �( )1 2⁄±=�

Page 41: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 41

We now considerwaysof solvingtheseequationsusingfinite differencetechniques.It is convenientto divide the

schemes into two categories—explicit and implicit.

4.2 (a) Explicit schemes.

When(35) is put in finite difference form using centred space and time differences (leapfrog scheme), we have

(37)

(38)

where representsthecentredfinite differenceoperatorcorrespondingto thefirst derivative.Thestabilityof this

scheme is determined by substituting the following into(37) and(38)

and then finding the condition for which This procedure gives

Proceedingasin Subsection2.5whendealingwith theleapfrogschemefor advection,it canbeshown that there

is linear computational stability provided.

,

andthatthis schemeis neutral.However, althoughthereis no damping,therearephaseerrorsandcomputational

dispersion; also there is a computational mode since it is a three-time-level scheme.

When forward time differences are used with centred space differences, we find that

therefore this scheme is absolutely unstable.

4.2 (b) Implicit schemes.

Considerwhathappenswhenthespacederivativesarereplacedby centredspacedifferencesaveragedover time

levels and ; centred differences will be used for the time derivatives.

(39)

� �+ 1+ � �+ 1––

2∆ �------------------------------- � δ � �+–=

�P�+ 1+ �P�+ 1––

2∆ �-------------------------------�

δ � �+–=

δ

� �+ � ˆ λ+

i 3 � �[ ] �Q�+ � ˆ λ+

i 3 � �[ ]exp=exp=

λ 1≤

λ2 2iC λ 1–+ 0 C � � ∆ �∆�------- 3 ∆

�sin–= =

∆ � ∆�

� �( )1 2⁄---------------------≤

λ 2 1 � � ∆ �∆�-------

2 3 ∆�

sin( )2+=

? 1– ? 1+

� �+ 1+ � �+ 1––

2∆ �------------------------------- � δ �P�+ 1+ δ �P�+ 1–+

2--------------------------------------

–=

Page 42: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

42 Meteorological Training Course Lecture Series

ECMWF, 2002

(40)

where representsacentredfinite differenceoperatorcorrespondingto thefirst derivative.Applying to (39)we

find , which is then substituted into(40) to give

(41)

Therefore,sincethe RHS is known, (41) is an elliptic equationwhich canbe solved for , given suitable

boundary conditions; can be found in a similar fashion.

It canbeshown thatthisschemeis absolutelystableandsoany timestepcanbeused.However, aHelmholtzequa-

tion has to be solved every time step and this can be computationally expensive.

An implicit schemeusing forward time differencescan be constructedusing the Crank–Nicolsonapproachin

which

(42)

(43)

where and areweightssuchthat ( correspondsto theforwardtime-

centred space scheme, which is absolutely unstable).

A stability analysis of (42) and (43) shows that there is instability if and absolute stability if

4.3 Staggered grids

We now consider the best way of distributing the variables and on the grid.

Initially we might expect that and should be held at each grid point.

However carefulexaminationshows that, if centreddifferencesareused,we have two separatesubgrids.This

means that the solutions on the subgrids can become decoupled from one another.

Displacingthegrid pointswhichcarrythe variableto themiddlebetweenthe pointswegetrid of thisproblem

as now the centred space derivative uses successive points of the same variable.

Thisalsohastheeffectof improving thedispersioncharacteristicsof any schemebecausetheeffectivegrid length

if halved. These ideas can be extended to the two dimensional problem

�Q�+ 1+ �Q�+ 1––

2∆ �-------------------------------� δ � �+ 1+ δ � �+ 1–+

2--------------------------------------

–=

δ δδ � �+ 1+

� � ∆ �( )2δ2 �P�+ 1+ �P�+ 1+–= � + 1– � + 1–,( )=

�P�+ 1+

� �+ 1+

� �+ 1+ � �+ 1––

2∆ �------------------------------- � β+ δ �Q�+ β + 1+ δ �Q�+ 1++( )–=

�P�+ 1+ �P�+ 1––

2∆ �-------------------------------�

β+ δ � �+ β + 1+ δ � �+ 1++( )–=

β + β+ 1+ β+ β+ 1++ 1= β+ 1 β+ 1+, 0= =

β + 1/2> β+ 1/2≤

� �� �

x x x x x� �, � �, � �, � �, � �,

� �

x o x o x o x o x o� � � � � � � � � �

Page 43: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 43

There are various grids that can be used, they are known as Arakawa A–E grids and are shown below:

As well asspacestaggeringit is often desirableto have time staggering.This is particularlyusefulfor leapfrog

schemeswherethemostcommondistribution of variablesis known astheEliassengrid. However grid E is the

same as grid B tilted by 45˚.

Thereis not a generalconsensusasto which grid hasthebestpropertiesalthoughgridsA andD areknown to be

worst. Grid C was used in the grid-point model of ECMWF.

Figure 8. The arrangement of variables on the Arakawa A–E grids.

4.4 The shallow-water equations.

To makeourequationsmorerealisticweshouldincludetheadvection.Therefore,stickingto thelinearone-dimen-

sion case we get

∂ �∂ �------ � ∂ �

∂�------+ 0

∂ I∂ �------ � ∂ �

∂�------+ 0∂ �∂ �------

� ∂ �∂�------ ∂ I

∂�------+ + 0= = =

Page 44: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

44 Meteorological Training Course Lecture Series

ECMWF, 2002

(44)

Substituting(36) into (44) gives the dispersion relationship

When the leapfrog scheme is used with centred space differencing, the stability criterion becomes

If , thephasespeedof thegravity wavesis 313m/s;now if and thesta-

bility criterion becomes . Note that this criterion is mainly determined by the gravity wave speed.

Thestabilityanalysisof theshallow-waterequationswill beperformedin two dimensionsusingthespectralmeth-

od.Thepoint we wantto stresshereis thattheadjustmenttermslimit theuppersizeof thetime stepto, typically,

one third of the one possible for the stable treatment of the advection terns.

4.5 Increasing the size of the time step

We saw in the formersectionthat in anexplicity treatmentof theshallow waterequationsrepresentingsynoptic

scalefeaturesonly ( ) the time stepfor stability is restrictedto a valuemuchlower thanthe typical

time scaleof suchfeatures,thereforeincreasingthe amountof calculationsto be performedmuchabove what

would be desirable.

Severalwaysof increasingtheallowedtime stephave beendevisedbut only themostsuccessfuloneswill bere-

vised here.

4.5 (a) The splitting method.

For thesetof equationsdiscussedin Subsection4.4, thereareclearly two differentphysicalmechanismsacting.

Therefore,it may be desirableto treatthe advectionandgravity partsseparately. Marchukdevisedthe splitting

technique which makes this possible.

The equations are split as follows:

(45)

(46)

The following procedure is then used.

(a) Usestandardfinite differencetechniquesto solve (45). If and denotenew valuesafterone

time step we have

∂ �∂ �------ � 0

∂ �∂�------ � ∂ �

∂�------+ + 0=

∂ �∂ �------ � 0

∂ �∂�------ � ∂ �

∂�------+ + 0=

� � 0 � �( )1 2⁄±=

∆ � ∆�

� 0 � �( )1 2⁄+---------------------------------≤

�10 km= ∆

�105 m= � 0 100 m/s=

∆ � 4.0 min≤

∆�

100 km≈

∂ �∂ �------ � 0

∂ �∂�------+ 0

∂ �∂ �------ � 0

∂ �∂�------+ 0 advection= =

∂ �∂ �------ � ∂ �

∂�------+ 0

∂ �∂ �------

� ∂ �∂�------+ 0 adjustment= =

� * � *

Page 45: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 45

(b) The new values are now used as the starting point for solving(46)

Substituting for and gives

Thecompleteschemeis stableprovided . andthis will besatisfiedif and,therefore,thereis sta-

bility if each of the separate steps is stable.

It is possibleto exploit the fact that thesametime stepdoesnot have to beusedfor eachstep.For example,the

gravity wave speedis largerthantheadvectionspeedandsoit appearsreasonableto usea largetime stepfor ad-

vection ( say) and a numberof smaller time stepsfor the gravity wave equations( stepsof , with

). The two steps will be stable provided

Typically is aboutthreetimeslargerthan andsoit is appropriateto use andto takethreeadjustment

steps to each advection step. This approach has been used effectively by the UK Met. Office—seeGadd (1978).

4.5 (b) Forward–backward scheme.

Let usconsidertheadjustmenttermsof theone-dimensionalshallow-waterequationsasgivenby (35). Theproce-

dureis to solve thesecondequationby meansof a FTSCstepandthento usethecalculatedvaluesof theheight

for calculating new values ofu using the first equation.

This can be stated as follows:

If we use the von Neumann method for analysing the stability of this scheme we find that

which is twice thetimestepallowedby theleapfrogmethod.Furthermore,theschemeis neutraland,althoughthe

secondequationlookssimilar to animplicit scheme,thesetof equationsis decoupledasin anexplicit methodand

we don't have to solve a coupled system of simultaneous equations. .

4.5 (c) Pressure averaging.

A proceduresomewhat similar to the forward–backward schemeis the pressureaveragingtechnique.Thename

� * λadv �+ � * λadv �

+= =

� + 1+ λadj � * � + 1+ λadj � *==

� * � *

� + 1+ λ � + and � + 1+ λ � + where λ= λadjλadv= =

λ 1≤ λadj 1≤

∆ � & δ �∆ � & δ �=

� 0∆ �∆�------- 1 � δ �

∆�-------≤ � ∆ �

& δ �----------- 1≤=

� � 0 & 3=

�Q�+ 1+ �P�+�2----- ∆ �

∆�------- � � 1+

+ � � 1–

+–( ) forward–=

� �+ 1+ � �+ �2--- ∆ �

∆�------- �Q� 1+

+ 1+ �Q� 1–

+ 1+–( ) backward–=

∆ � 2∆�

� �( )1 2⁄---------------------≤

Page 46: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

46 Meteorological Training Course Lecture Series

ECMWF, 2002

comesfrom theprimitiveequationsusing astheverticalco-ordinate,wheretheadjustmentternfor themomen-

tumequationsis givenby theso-calledpressuregradientterm.As wearedealingherewith theshallow-waterequa-

tions, it would be more adequate to call it height or geopotential averaging.

Theideais to takeastheheightin thewind equationsomeaverageof theprevious,presentandfuturetimevalues

and using centred time derivatives.

Therefore the momentum equation reads

whichreducesto theleapfrogschemeif . If wetake weget,from thevonNeumannstabilityanal-

ysis, the condition

,

which is the same as we got for the forward-backward scheme.

4.5 (d) Semi-implicit scheme.

It wasstatedin sectionSubsection4.2(b) thatanimplicit treatmentof thegravity waveequationisabsolutelystable

for any sizeof thetimestep,therefore,wecouldtry suchatreatmentfor theadjustmenttermsin theshallow water

equations while keeping an explicity formulation of the advection terms.

The disretized equations in two dimensions then read

(47)

where

and and arethe centredapproximationsto the and derivatives,respectively. Upon substitutionof

and from the first two equations into the third equation we get

where . This is a Helmholtzequationwhich hasto besolvedat every time stepand,therefore,it

is moreexpensive thantheexplicit method.Nevertheless,therearefastHelmholtzsolverswhich aredescribedin

chapter8 anda stability analysis,which we will performin Section6 usingthespectralapproachshows that the

timestepsizeis no longerlimited by thephasespeedof the(fast)gravity waves,but by thespeedof themoreslow

R

� �+ 1+ � �+ 1––

2∆ �-------------------------------�

2∆�---------- 1 2ε–( ) � � 1+

+ � � 1–

+–( ) ε � � 1+

+ 1+ � � 1–

+ 1+–( ) � � 1+

+ 1– � � 1–

+ 1––( )+[ ]+{ }–=

ε 0= ε 1 4⁄=

∆ � 2∆�

� �( )1 2⁄---------------------≤

� �+ 1+ � �+ 1– ∆ �TS �+ ∇ � �+ � ∆ �2

----------– ∇ -U�P�+ 1+ �Q�+ 1–+( )⋅–=

I �+ 1+ I �+ 1– ∆ �TS �+ ∇ I �+ � ∆ �2

----------– ∇VW�P�+ 1+ �Q�+ 1–+( )⋅–=

�P�+ 1+ �Q�+ 1– ∆ �TS �+ ∇ �Q�+�

∆ �2

-----------– ∇ ∇ �+ 1+∇ �+ 1–

+( )⋅ ⋅–=

S �+ � �+ , I �+( ) ∇ ∇ - ,∇V( )= =

∇ - ∇V � �� �+ 1+ I �+ 1+

∇2 �P�+ 1+ 4 ∆ L( )2

� � ∆ �( )2---------------------- �P�+ 1+–

= +X+ 1–,=

∆ L ∆�

∆�= =

Page 47: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 47

Rossby modes.

Computertestsshow thattheincreasedsizeof thetimestepovercomesthehigheramountof work neededatevery

timestep,andsothesemi-implicittimeschemeis fasterthantheexplicit oneTheadvantageis mostnotableif we

usethe spectraltechniquewith sphericalharmonicsas theseareeigenfunctionsof the Laplacianoperatorand,

therefore,theset(47)becomesadecoupledsetof equations,onefor everyspectralcomponentof theheightfunc-

tion.

4.6 Diffusion

Theonly termsnot treatedsofar from theshallow-waterequationsin its linearizedform arethediffusionterms.

The linear diffusion equation for a function in one dimension can be written as:

(48)

This is a parabolicequationwhoseanalyticalsolution,whenwe useperiodicboundaryconditionsanda single

wave of wave number as the initial condition can be shown to be

which represents the initial disturbance with an amplitude decaying with time.

We will considerhereonly threetime-steppingschemescombinedwith centredsecond-orderspacedifferencing

in orderto show that,asit wasthecasewith theotherterms,anexplicit treatmentis in generalconditionallystable

while an implicit treatment is normally stable.

4.6 (a) Explicit forward scheme.

(49)

As usual, we consider the behaviour of a single harmonic and assume

Substituting this into(49) gives

For stability we require andthis is satisfiedfor all wavelengthsprovided . However, thoughsta-

bility is ensuredby usingthis condition,a valueof in the range givesa negative valueof ,

which causesthe amplitudeof the wave to switch sign betweensuccessive time steps.This may be avoidedby

choosing .

In numericalmodels,a typical valueof theeddydiffusivity is . With thestability

condition is satisfiedif . This is sufficiently largefor it notto produceany problems.How-

M

∂M

∂ �-------� ∂2 M

∂� 2

---------- K 0>;=

3M � �,( )

M0 3 �( ) 3 2� �–[ ]expsin=

M �+ 1+ M �+–

∆ �--------------------------- � M � 1+

+2M �+–

M � 1–

++

∆�

( )2--------------------------------------------------=

M �+ λ+ 4 i 3 � �[ ]exp=

λ 1 4σ 3 ∆�

2----------sin

2with σ–

� ∆ �∆�

( )2--------------= =

λ 1≤ σ 1 2⁄≤σ 1 4⁄ σ 1 2⁄≤ ≤ λ

σ 1 4⁄≤�

105 m2/s= ∆�

100 km=

σ 1 4⁄≤ ∆ � 2 106× s≤

Page 48: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

48 Meteorological Training Course Lecture Series

ECMWF, 2002

ever, this is not the case in the vertical where a typical grid spacing of leads to .

4.6 (b) Classical implicit scheme.

In this scheme, the space derivative is evaluated at time level . The scheme then reads:

and the usual stability analysis gives

which has for all values of and . Therefore, the scheme is absolutely stable.

4.6 (c) Crank–Nicholson scheme.

This is a meanbetweenthe two former schemesandthe spacederivative is evaluatedat time level by

averaging over time levels and .

Like theclassicalimplicit method,theCrank–Nicholsonschemeis absolutelystable.However, theadvantageof

thisschemeis thatit is second-orderaccuratein timeasopposedto first-orderaccuracy in timeof boththeexplicit

and the classical implicit methods.

It is interestingto generalizethis approachby weightingthepresentandfuturevaluesof theright handsidewith

weights and , subject to the condition . Someexperimentssuggestthat valuesof

give an accurate scheme with which long time steps can be used.

When the eddy diffusivity and the grid spacing vary, the continuous diffusion equation is

and the generalized time stepping just described can be written

where , and .

1 km ∆ � 2 s≤

? 1+

M �+ 1+ M �+–

∆ �--------------------------- � M � 1+

+ 1+ 2M �+ 1+–

M � 1–

+ 1++

∆�

( )2----------------------------------------------------------+=

λ 1

1 4σ2 3 ∆�

2----------sin

2+

---------------------------------------------=

λ 1≤ 3 σ

? 1 2⁄+

? ? 1+

β+ β + 1+ β+ β+ 1++ 1=

β + 1 4⁄ β+ 1+, 3 4⁄= =

∂M

∂ �-------∂

∂�------ � ∂

M∂�-------

=

M �+ 1+ M �+–

∆ �---------------------------1

∆� �---------

� � 1 2⁄+

∆� � 1 2⁄+

--------------------

β+ M � 1+

+ M �+–( ) β + 1+

M � 1+

+ 1+ M �+ 1+–( )+[ ]=

� � 1 2⁄( )–

∆� � 1 2⁄( )–

------------------------ β+ M �+ M � 1–

+–( ) β+ 1+

M �+ 1+ M � 1–

+ 1+–( )+[ ]

∆� � � � 1 2⁄+

� � 1 2⁄––= ∆� � 1 2⁄+

� � 1+� �–= ∆

� � 1 2⁄–� � � � 1––=

Page 49: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 49

5. THE SEMI-LAGRANGIAN TECHNIQ UE

5.1 Introduction

Sofar we have takenanEulerianview andconsideredwhatwastheevolution in time of a dependentvariableat

fixedpointsin spaceandin thespectralandfinite elementswe will considerwhat is the time evolution of some

coefficientsmultiplying somebasisfunctionsalsofixedin space;in otherwords,weusedthepartialtimederivative

.

A few yearsago,severalattemptsweremadeto build stabletime integrationschemespermittinglargetimesteps.

Robert(1981)proposedusingthequasi-Lagrangiantechniquefor thetreatmentof theadvective partof theequa-

tions.

Let us consider the one-dimensional advection equation

(50)

where is the advected property and is the advection velocity. This equation can be recast in the form

(51)

wherethe left-handsidestandsfor theLagrangianderivative andits meaningis the time evolution of a material

volumeandequation(51)couldbereadas:theproperty is conservedwithin anair parcel.Thediscretizationcan

be written as

wheresubindexesA andD indicatethearrival (at time instant ) anddeparture(at time instantt) pointsof

the considered air parcel.

If we know the initial distribution of (defined,for example,on a regulararrayof points)thenby trackingthe

fluid parcelswe endup with informationaboutthedistribution of at somelater time,but in generalthepoints

wherewe know thevalueof will not beuniformly distributedany moreandthis makestheprocedurevery dif-

ficult to apply.

Thesemi-Lagrangiantechniqueovercomesthis difficulty by consideringtheendpointsasconsistingof a regular

meshandtrackingbacktheorigin of eachparcel.Thesimplestmethodfor finding thevalueof atgridpoint at

timelevel consistsin trackingbacktheair parceloveronetimestepto find whereit wasattime

level . Having locatedit origin wenow find its valueby interpolationfrom thevaluesat theneighbouringgrid

points at time level .

If the interpolated value is we have

(52)

5.2 Stability in one-dimension

Let us consider the linear advection equation

∂ ∂ �⁄

∂∂ �----- � ∂

∂�------+

ϕ 0=

ϕ �

dϕd�------ 0=

ϕ

ϕY E ∆ E+ ϕ ZE–

∆ �--------------------------- 0=

� ∆ �+

ϕϕ

ϕ

ϕ ,? 1+ ϕ �+ 1+ say( )

? ϕ?

ϕ*

+

ϕ �+ 1+ ϕ*

+=

Page 50: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

50 Meteorological Training Course Lecture Series

ECMWF, 2002

(53)

Thedistancetravelledduringthelast interval by anair parcelarriving at point is , thereforeit comes

from a point

(54)

If thispoint liesbetweengrid points and , andwecall thefractionof grid lengthfrom point

to point we have

(55)

and using linear interpolation to find we get

(56)

(Notethatwhen , and(56)becomesidenticalto theupstreamdifferencingscheme).We

study the stability using the von Neumann method and, therefore, assume a solution of the form

(57)

substituting we get

(58)

and

. (59)

Therefore as long as , that is

(60)

theschemeis, therefore,stableif theinterpolationpointsarethetwo nearestonesto thedeparturepoint, but it is

neutral only if or ,that is to say when no interpolation is needed. We will come to this point later.

We find that heavy dampingoccursfor the shortestwavelengths(thereis completeextinction when and

). but thedampingdecreasesas increases.A strangefeatureof thisscheme(peculiarto thecaseof con-

stantwind) is that for a given thephaseerrorsanddissipationdecreaseas increases.This happensbecause

the departure point can be located precisely using only the wind at the arrival point.

A similaranalysisto theabovecanbecarriedout for quadraticinterpolation.Onceagain theschemeis absolutely

stableprovided is computedby interpolationfrom thenearestthreegrid points.Thisschemehaslessdamping

thanthelinearinterpolation,but thephaserepresentationis notimproved.It is easyto show thatwhenthedeparture

point is within half agrid lengthfrom thegrid point (i.e. ), thisschemebecomesidenticalto theLax–Wen-

droff scheme.

Theseideascanbeextendedto two-dimensionalflow. It hasbeenfoundthatbi-quadraticinterpolationis absolutely

dϕd�------ ∂ϕ

∂ �------ 4 ∂ϕ∂�------+≡ 0=

∆ � � � 4 ∆ �

�*

� �[4 ∆ �–=

,\C–( ) ,\C– 1–( ) α�*

� �^]–

4 ∆ � C α+( )∆�

=

ϕ*

+

ϕ �+ 1+ ϕ*

+1 α–( )ϕj-p

+αϕj-p-1

++= =

C 0= α 4 ∆ � ∆�

⁄=

ϕj

+ϕ0λ

+i 3 � �[ ]exp=

λ 1 α 1 i 3 ∆�

–[ ]exp–( )–{ } iCJ3 ∆�

–[ ]exp=

Gλ≡ 1 2α 1 α–( ) 1 3 ∆

�( )cos–{ }–[ ]1 2⁄=

λ 1≤ α 1 α–( ) 0≥

0 α 1≤ ≤

α 0= α 1=

$ 2=

α 0.5= $α C

ϕ*

+

C 0=

Page 51: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 51

stablefor constantflow (providedtheninegrid pointsnearestthedeparturepoint areusedfor interpolation)and

that the characteristics of this scheme are superior to those of a bilinear interpolation scheme.

5.3 Cubic spline interpolation

An accurateway of finding thevalueof at thedeparturepoint is to usecubicsplineinterpolation.Thespline

is defined to be a cubic polynomial within any grid interval, where the coefficients are chosen so that

(i) at each gridpoint

(ii) the gradient of is continuous

(iii) is minimised

It can then be shown that, in the interval , the spline is

(61)

where and arethegrid-pointvaluesof at and , and and arethecorrespondinggra-

dients of the splines derived from

(62)

The implementation of this scheme requires two steps:

(a) Thederivativesof thesplinesat eachgrid point andat time level ( say)arederived from

the set of simultaneous equations defined by(62).

(b) Having foundthepoint from which anair parceloriginates,thevalueof is calculatedfrom

(61)usingthevaluesof and at thetwo neighbouringgrid points.If point liesbetweengrid

points and at a distance from point , then(61) givesanexpressionfor

in terms of , , , and . The time stepping algorithm(52) then becomes

(63)

A corresponding expression can obviously be derived for the case when .

Althoughcubicsplineinterpolationrequiresmuchmorecomputationthanalinearinterpolation(compare(56)with

(63)), thecharacteristicsof thecubicsplineschemearefarsuperior. Therefore,in choosingaschemeit is necessary

to balance accuracy against computational expense.

Letusnow turnto thenon-linearadvectionequation.In thiscasetheadvectingvelocity, andhencethedisplacement

ϕK �( )

K � �( ) ϕ �=K �

( )

d2 K d� 2⁄( )

�d*∫ � � 1–

� � �≤ ≤

K �( )

G � 1–

∆� 2

-------------� � �

–( )2 � � � 1––( )G �∆� 2

---------� � � 1––( )2 � � �

–( )–=

+ϕ � 1–

∆� 3

------------� � �

–( )2 2� � � 1––( ) ∆

�+{ }

ϕ �∆� 3

---------� � � 1––( )2 2

� � �–( ) ∆

�+{ }+

ϕ � 1– ϕ � ϕ , 1– , G � 1–

G �

G � 1– 4G � G � 1++ +

6--------------------------------------------------

ϕ � 1+ ϕ � 1––

2∆�------------------------------=

, ? G �+

G � 1–

+4G �+ G � 1+

++ +

6--------------------------------------------------

ϕ � 1+

+ϕ � 1–

+–

2∆�------------------------------=

�* ϕ*

G �*� ,\C–= � 1– α∆

� �ϕ*

+ϕ � 1–

+ϕ�+ G � 1–

+ G �+ α

ϕ �+ 1+ ϕ�+ αG �+ ∆

�– α2 G � 1–

+2G �++( )∆

�3 ϕ� 1–

+ϕ�+–( )+{ }+=

α3 G � 1–

+ G �++( )∆�

2 ϕ� 1–

+ϕ �+–( )+{ }–

� 0 0<

Page 52: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

52 Meteorological Training Course Lecture Series

ECMWF, 2002

of every air parcel, is a function of . We can still use the samemethodand estimatethe displacementby

and, therefore, and will depend upon .

A moreaccurateestimateof thedisplacementis foundby usinganadvectingvelocity from midway betweenthe

departureandarrival points;this couldbeestimatedin many ways.This is theequivalentto theCrank–Nicholson

schemeif we estimatetheadvectingvelocity at time , or to thecentredtime-differencingschemesif we

use the estimate at time and the departure point at time .

5.4 Cubic Lagrang interpolation and shape preservation

Cubicsplineinterpolationis quiteexpensiveandcanbeunusablein morethanonedomension.A simpleralthough

not so accurate interpolation is provided by the cubic Lagrange polynomials defined as follows:

Q(x) is a cubic polynomial covering 4 consecutive gridpoints

Q(xj)= at each of these four grid-points.

Then Q(x) can be expressed as

where the functions Ci(x) can be computed as

Cubic Hermiteinterpolationis somewhatsimilar but the input dataarethevaluesandthederivativesat the two

gridpoints surrounding the interpolation point.

Any highorderinterpolationcanproduceartificial maximaandminimanotpresentin theoriginaldata.Suposewe

wantto interpolateto pointD, by meansof acubicpolynomial,thefunctiongivenat the4 consecutivegrid-points

(j-1), j, (j+1) and (j+2)

As pureadvectioncannot producenew maximain theadvectedfunction,it is convenientto avoid possibleover-

shootingin thecubicinterpolations.If theinterpolationwasdoneby Hermitepolynomials,appropriatemodifica-

tion of thederivativesatpointsj andj+1 canleadto theeliminationof maximain theinterpolationinterval. In the

caseof cubicLagrangepolynomials,thetechniquecalledquasi-monotoneinterpolationcanbeapplied:afterinter-

polation, the interpolated value is restricted to stay within the interval

� Q� � � ∆ �= C α ,

� ∆ � 2⁄+� � ∆ �–

ϕ �

_ �( ) 4F" �( )ϕ"" 1=

4

∑=

4F" �( )

� � B–( )B`"≠

4

� " � B–( )B`"≠

4

∏------------------------------=

x

+

++

+

j j+1 j+2j-1 D

x interpolated value

ϕ � ϕ � 1+→

Page 53: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 53

5.5 Various quasi-Lagrangian schemes in 2D

Wewill considerhereonly schemesusingcentredtimedifferences.Thegeneralform of theevolutionequationfor

a given parameter can be written

(64)

where is the linear part of the equation and the non-linear part.

The left-hand side is the Lagrangian total derivative

5.5 (a) Method with interpolation (Robert 1982).

The evolution equation is discretized as follows:

is thevalueof at grid point , is thevalueof at thepoint wheretheparticlecomesfrom,

is thevalueof at themid-pointbetween and . Superscripts , and referto time levels.This

method needs the interpolation of at point and at point .

5.5 (b) Method avoiding one interpolation (Ritchie 1986).

We define point as the closest grid point to and as the mid-point between and . We can write

where and are the components of vector .

Themethodconsistsin asemi-Lagrangiantreatmentof theadvectionby thewind , theadvectionby the

residualwind beingincorporatedinto thenon-linearpartof theright-handside.Thisdiscretizationreads:

This methodavoidstheinterpolationat point , andtheresidualinterpolationat thepoint is very simpledue

to thethreepossiblelocationsshown in Fig. 9 . Thedamping,on theotherhand,is reduceddueto thelack of in-

terpolation at the departure point.

ϕ �ϕ � 1+

+

+x

1 � � �, ,( )

∂1∂ �------- 5 ∂1

∂�-------

S ∂1∂�-------+ +

� 1 ��1( )+⋅=

� 1⋅ ��1( )

d1d�-------- ∂1

∂ �------- 5 ∂1∂�-------

S ∂1∂�-------+ +≡

1 GE ∆ E+ 1 O

E ∆– E–

2∆ �-----------------------------------� 1 G

E ∆ E+ 1 OE ∆– E+

2----------------------------------- ��1 E( ){ }I+⋅=

1 G 1 G 1 O 1 O 1 I

1 O G� � ∆ �–

� ∆ �+

1 E ∆ E– O 1 E G

O′ O I ′ O′ G

5 5 * 5 ′ S+

S * S ′+= =

2 5 * ∆ � 2S * ∆ � O′G

5 * S *,( )5 ′ S ′,( )

1 GE ∆ E+ 1 O′

E ∆– E–

2∆ �-----------------------------------� 1 G

E ∆ E+ 1 O′E ∆– E+

2----------------------------------- ��1 E( ){ }I ′ 5 ′∂1∂�-------

S ′∂1∂�-------+

I ′

E–+⋅=

O I ′

Page 54: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

54 Meteorological Training Course Lecture Series

ECMWF, 2002

Figure 9. Location of the points where the interpolation is performed for quasi-Lagrangian techniques.

5.5 (c) Method without any interpolation interpolation .

Onesupplementarysimplificationcanbeachievedby evaluatingthenon-lineartermsby takingtheaverageat time

between their values at grid points and .

5.5 (d) Method used at ECMWF.

Figure 10: 12-point interpolation used in the horizontal at ECMWF

At ECMWF themethodof Robertis usedwith cubicLagrangepolynomialsandquasi-monotonelimiter. In order

to reducethecostof theinterpolation,theinterpolationin longitudeat therows not immediateadjacentto thede-

parturepointO is donelinearly(singlyunderlinedpointsin Figure10). Theprocedureis asfollowsandis valid for

areducedGaussiangrid to bedescribedlater. Thelongitudeandlatitudeof thedeparturepointO is found(seelat-

er).At eachof thetwo rows of grid-pointssecondnearestneighboursto thedeparturepoint, linear interpolations

�G O′

��1 E( ){ }I ′ 5 ′∂1∂�-------S ′∂1∂�-------+

I ′

E–

12--- ��1 E( )( )

G��1 E( )( )O′+=

5 ′∂1∂�-------S ′∂1∂�-------+

G

E– 5 ′∂1∂�-------

S ′∂1∂�-------+

O′

E–+

x x x x x x x

xx x x x x x x

xx

xxxxx x

x

x

xxxx

G

O

λ

θ

Page 55: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 55

areperformedto thelongitudeof thedeparturepoint.At thenearestneighboringgrid pointrows,cubicquasi-mon-

otoneinterpolationsareperformedto thesamelongitude.Finally aquasi-monotonecubicinterpolationin latitude

is performedusingthe4 interpolatedvalues.In theverticalasimilarprocedureis followed:ateachnearestneigh-

boring level to thedeparturepoint a 12-pointinterpolationis performedandat thesecondnearestneighbouring

levelsabilinearinterpolationis done.Finally aquasi-monotone(or standard,dependingof thevariableto beinter-

polated)cubic interpolationis donein theverticaldirection.A total of 32 pointsareusedthenfor eachthree-di-

mensional interpolation.

5.6 Stability on the shallow water equations

We canperformthestability analysesof the threemethods,asappliedto theshallow waterequations,in a form

exactlysimilar to thewaywedid it in theEuleriancase.Wearenotgoingto follow theprocedureagainbut instead

we present the results on stability and dispersion characteristics of the three schemes.

(a) For the Robert scheme the stability criterion is

aslong asthe interpolationis doneby usingthegrid point valuesaroundtheorigin point, andthe

adjustment terms are treated implicitly.

(b) The Ritchie scheme leads to a stability criterion for the advective part of

which is analogousto theoneweobtainedwith thesemi-implicit schemereplacing and by

theresidualvelocity . This relationshipcanbeshown to bealwaystrue,dueto theway in

which the residual velocity was defined.

(c) Thestability criterionof the fully non-interpolatingschemeis completelyanalogousto the former

one.

Thedispersion is givenin Fig.11 asafunctionof for theanalyticalslow solutionin theone

dimensional case.

2∆ � 2 1<

&a5 ′ � S ′+( )∆ � 1≤

5 OS

O

5 ′ S ′,( )

H αnumerical

αanalytical--------------------≡ 2 5 O

∆ �∆�-------

Page 56: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

56 Meteorological Training Course Lecture Series

ECMWF, 2002

Figure 11. Effect of time integration on the slow wave for various values of the wavelength.

5.7 Computation of the trajectory

Thecomputationof thedeparturepoint for aparcelof air arriving atagrid-pointG at time canbedoneby

solving the vector semi-Lagrangian equation defining the velocity of the parcel

� ∆ �+

�ddr V=

Page 57: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 57

The cedntered discretization of this equation in a three-time-level scheme is

where is thearrival positionvectorof pointG (thegrid-pointwheretheparcelarrivesattime ),

is thepositionvectorof thedeparturepoint O (wheretheparcelwasat time ) and is thevelocity vector

at thepresenttime at themiddleof thetrajectory. In planegeometrythetrajectoryis asumedto beastraightline

(velocity constantduringtheinterval ). Now, thepositionof themiddleof thetrajectorydepends

onthepositionof thedeparturepoint,which is whatwetry to determinewith thisequation,thereforetheequation

is an implicit equation and has to be solved by an iterative method, depicted inFig. 12

Figure 12: Iterative trajectory computation

In thefirst iteration,wetakethevelocity at thearrival pointG. Usingthisvelocitywegobackwardsadistance

to reachpointO1, this is thefirst guessof ourdeparturepoint.ThenwetakethepointM1 midwaybetween

pointsG andO1 andinterpolatethevelocity at thepresenttime to thatpoint.Usingthatvelocity we go back

from G adistance to pointO2 andrepeattheprocedureuntil it converges.At ECMWFonly threeiterations

are done and no test of convergence is performed.

In sphericalgeometrythetrajectoryis asumedto beanarcof a greatcircle insteadof a straightline, which com-

plicatessomewhatthecomputationsbut theidearemainsthesame.Also in sphericalgeometryonehasto takeinto

accountthat theinterpolatedwind componentsrefer to a local frameof referencepointingto thelocal North and

East and, in order to use the interpolated values at grid point G, they have to be “rotated”.

In orderto haveanideaabouttheconvergenceof theiterativeprocedurejustdescribed,let usapplythisprocedure

to thecomputationof thesemi-Lagrangiantrajectoryin onedimension.For theshakeof simplicitywewill consider

atwo-time-level schemeandusethevelocitiesonly at thedeparturepoint insteadof interpolatingthemat themid-

dle of the trajectory. At the n’th iteration the departure point is computed as

r t ∆t+ r E ∆ E––2∆ �------------------------------- V E=

r E ∆ E+ � ∆ �+ r E ∆ E–

� ∆ �– V E�� ∆ � � ∆ �+→–

x x x x x

x x x x x

x x x x x

x x x x x

x x x x x

G

O1

O2

M1

V0V1

V0

2V0∆ �V1

2V1∆ �

r + 1+

r + 1+ b ∆ �TS +–=

Page 58: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

58 Meteorological Training Course Lecture Series

ECMWF, 2002

Now assume that V varies linearly between grid-points

then

For the iterative procedure to converge, this equation must have a solution of the form

Substituting we get

therefore for convergence we must have

Thisconditionmeansthattheparcelsdonotovertakeeachotherduringtheinterval andis muchlessrestrictive

than the CFL stability limit. Also it does not depend on the mesh size.

5.8 Two-time-level schemes

A centered discretization (second order accurate in space and time) of the general semi-Lagrangian equation

using only two time levels is

whereR has to be extrapolated in time before being interpolated to the middle point of the trajectory

An alternativesecond-orderaccurateschemecanbedevelopedfromaTaylorseriesexpansionin thesemi-Lagrang-

ian sense arround the departure point of the trajectory

S � r+ �⇒r∂

∂S= =

r + 1+ b ∆ �– � r + ∆ �–=

r + λ+ � λ 1<( );+=

�= b ∆ �–

1 � ∆ �+--------------------

λ= � ∆ �–

∆ � 1�------<

∆ �

�ddX R=

X Y E ∆ E+ X ZE–

∆ �---------------------------- R %E∆ E2------+

=

RE ∆ E

2------+ 3

2---RE 1

2---RE ∆ E––≈

Page 59: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 59

Noticethat thetime level andthepositionin thetrajectoryareconsistentasrequestedin theLagrangianpoint of

view. Here subindex AV means some average value along the trajectory.

In thecaseof thecomputationof thetrajectory, X is thepositionvectorof theparcelof air andthisequationis the

equationof a uniformly acceleratedmovementwith initial velocity andacceleration .

Thetrajectorycannot any morebeconsideredasa straightline in this caseandthemiddlepoint of thetrajectory

is not half way between the arrival and the departure points.

Now, substituting by and by we get

(65)

and needs to be evaluated. This is done at ECMWF as

which is not strictly compatiblewith theLagrangianpoint of view becauseit usesvaluesat time t at thearrival

pointof thetrajectoryandvaluesat time at thedeparturepointof thepresenttrajectorywhichrunsbetween

timest and . It is therefore only an approximation.

With this choice,Eq. (65) becomes

and the computation of the trajectory

6. THE SPECTRAL METHOD

6.1 Introduction

Whenusingfinite differencetechniquesfor evolutionaryproblems,we only considergrid-pointvaluesof thede-

pendentvariables;no assumptionis madeabouthow thevariablesbehave betweengrid points.An alternative ap-

proachis to expandthedependentvariablesin termsof afinite seriesof smoothorthogonalfunctions.Theproblem

is thenreducedto solvingasetof ordinarydifferentialequationswhichdeterminethebehaviour in timeof theex-

pansion coefficients.

As an example consider the linear one-dimensional evolutionary problem

X Y E ∆ E+ X ZE ∆ � �ddX

Z

E ∆ �( )2

2------------- � 2

2

d

d X

Ydc+ +=

X / �( ) ZE 2X / � 2( )Y<c

X / �( ) ZE R ZE 8egf7h� � e( )Ydc R/ �( )Ydc

X Y E ∆ E+ X ZE ∆ � R ZE ∆ �( )2

2------------- �

ddR

Ydc+ +=

R/ �( )Ydc

�ddR

Ydc

RY E R ZE ∆ E––

∆ �----------------------------≈

� ∆ �–� ∆ �+

X Y E ∆ E+ X ZE ∆ �2------ RY E 2RE RE ∆ E––{ } Z+( )+=

r Y E ∆ E+ r ZE ∆ �2------ V Y E 2V E V E ∆ E––{ } Z+( )+=

Page 60: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

60 Meteorological Training Course Lecture Series

ECMWF, 2002

(66)

where is a linear differential operator. Expanding in terns of a set of orthogonal functions

we have

(67)

The aretheexpansioncoefficientswhosebehaviour wewantto determine.Wenow usetheprocedureoutlined

earlierin Subsection1.4—thatis weminimisetheintegralof thesquareof theresidualcausedby usingtheapprox-

imatesolution(67)in theoriginalequation(66)(alternativelywecouldusetheGalerkinmethodwith theexpansion

functions as test functions). Since the expansion functions are orthonormal we have

where is the complex conjugate of . Using this condition we get

(68)

That is, we have a setof ordinarydifferentialequationsfor therateof changewith time of theexpansioncoeffi-

cients.

It is now interesting to consider how our choice of expansion functions can greatly simplify the problem

(a) If the expansionfunctionsareeigenfunctionsof we have , wherethe arethe

eigenvalues;(68) then becomes

and the equations have become decoupled.

(b) If the original equation is

where is a linearoperator, thenour problemis simplifiedby usingexpansionfunctionsthatare

eigenfunctions of with eigenvalues ; we then have

∂ϕ∂ �------ H ϕ( )=

H ϕ��� �( ) �, �

1 … �2,=

ϕ ϕ� �( ) ��� �( )�∑=

ϕ�

���* ��� �d

0

*∫

1 $ �=

0 $ �≠

=

���* ���

dϕ�d�---------- ϕ�W���* H ���( )

�for all �d

0

*∫�∑=

H H ���( ) λ�i���= λ �

dϕ�d�-------- λ � ϕ�=

L∂ϕ∂ �------

H ϕ( )=

L

L λ�

λ� dϕ�d�---------- ϕ �j���* H ���( )

�d

0

*∫�∑=

Page 61: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 61

6.2 The one-dimensional linear advection equation

It is convenientto write theadvectionequationin termsof the longitude andtheangularvelocity

.

(69)

with boundaryconditions: , andinitial conditions: . For

any reasonable function the analytical solution to(69) is

If wearegoingto usetheapproachoutlinedin Subsection6.1, wemustchoosesuitableexpansionfunctions.The

obvious choice is the finite Fourier series

(70)

becausetheexpansionfunctionsaretheneigenfunctionsof thedifferentialspaceoperator. Here is themaximum

wave numberandthe arethecomplex expansioncoefficients.Since we needonly becon-

cerned with for , rather than the full set of expansion coefficients.

We shouldnow usetheGalerkinmethod,but for this simpleproblemit is sufficient to substitute(70) in (69) and

equate coefficients of the expansion functions. This yields (as does the formal Galerkin method)

(71)

giving equations for the 's. For this particular case(71) can be integrated exactly to give

(72)

If is also represented by a truncated Fourier series the complete solution is

which is thesameastheexactsolution.Thereis no dispersiondueto thespacediscretization,unlike in thefinite

differencesmethod.This factis dueto thespacederivativesbeingcomputedanalyticallywhile they wereapprox-

imated in the finite difference method.

Theexpression(72)canberepresentedgraphicallyasavectorin thecomplex planerotatinganticlockwisewith a

constant angular velocity .

Scalarlymultiplying Eq. (70) by eachof thebasisfunctionsandusingtheorthogonalitypropertyof theFourier

basis we get at the initial time

(73)

where Am are the normalization factors (which is known as the direct Fourier transform).

λ 2π�k�

⁄=

γ 2π � 0�

⁄=

∂ω∂ �------- γ ∂ω

∂λ-------+ 0 ω 2π�------ �= =

ω λ �,( ) ω λ 2πC �,+( ) for integerC= ω λ 0,( ) λ( )=

λ( ) ω λ �,( ) λ γ �–( )=

ω λ �,( ) ω� �( ) i � λ[ ]exp� %–=

%∑≈

&ω� ω �– �( ) ω�* �( )=

ω� 0 � &≤ ≤

dω�d�----------- i � γ ω�+ 0 0 � &≤ ≤=

2& 1+ ω�

ω� �( ) ω� 0( ) i � γ �[ ]exp=

λ( )

ω λ �,( ) � i � λ γ �–( )[ ] where λ( )exp�∑ � i � λ[ ]exp�∑= =

� γ /2π

ω � 0( )M � ω λ 0,( ) # � λ–[ ]exp λ

0

∫=

Page 62: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

62 Meteorological Training Course Lecture Series

ECMWF, 2002

At any futuretime we canapplyEq. (70) to get thespacedistribution of thesolution.This is normallyknown as

inverse Fourier transform.

In thepracticethe initial conditionscanbegiven in the form of grid-pointdata( pointswith spacing

say).Therefore,wethink of thetruncatedFourierseriesasrepresentinganinterpolatingfunctionwhichexactlyfits

the values of at the grid points.Eq. (73) then has to be computed as a discrete sum

(74)

which is known as discrete direct Fourier transform. The corresponding discrete inverse Fourier transform is

(75)

Bothof themcanbecomputedwith theFastFourierTransform(FFT)algorithm.It canbeshown that,startingfrom

thesetof , goingto theset andreturningto werecoverexactlytheoriginal

values(thetransformsareexact)aslongas andthepointsareequallyspacedin . Thisdistribution

of pointswith is known asthelineargrid. On theotherhandit canbeshown alsothattheproduct

of two functionscanbe computedwithout aliassingby the transformmethodof transformingboth functionsto

grid-pointspace,multiplying togetherthefunctionsateachgrid-pointandtransformingbacktheproductto Fourier

space,aslongas . Thedistributionof pointsfor which is known asthequadraticgrid.

Having derivedtheinitial conditionsin termsof thespectralcoefficientswe mustnow integratetheordinarydif-

ferentialequationsfor theexpansioncoefficientsat somefuturetime.Normally this hasto bedoneusinga time-

stepping procedure such as the leapfrog scheme, i.e.

This schemeis stableprovided for all ; but sincethe maximumvalue of is we require

. In termsof theoriginalgrid, giving —hencethereis stabilityprovided

. Thisshows thatthestabilitycriterionis morerestrictive thanfor conventionalexplicit finite difference

schemes.However, thespectralschemehasthegreatadvantagethatit hasonly very smallphaseerrorswhich are

not significant even for two gridlength waves.

Table1 showshow and varywith when . Theresultsof usingthespectralmethodonthe

testproblemsdescribedin Subsection2.6aregivenin Figs.5 and6 . Notetheimpressivecharacteristicsandresults

of the spectral model.

If westartthespectralmethodfrom agrid-pointdistributionandusethevalueof M whichcorrespondsto thequad-

raticgrid,Eq.(74)givesusanumberof degreesof freedomsmallerthantheoriginalnumberof degreesof freedom

andthereforeuponreturnto grid-pointspaceby meansof Eq. (75) we maynot recover theoriginal information.

Theresulting“fitted” functiondisplayswhat is known asspectralripples.This doesnot happendwith the linear

grid in which thenumberof degreesof freedomin Fourierspaceis thesameasthenumberof degreesof freedom

in grid-pointspace.To illustratethispointFig.13showsafunctioncomposedof severalabruptstepsandtheresult

of transformingit to Fourierspaceandbackto grid-pointspaceusingaspectraltruncationfor whichthegrid-point

distribution corresponds either to the linear or the quadratic grid for that spectral truncation.

� 1+ ∆�

ω � 1+

ω� 0( )M

'� ω λ"( ) # � λ"–[ ]exp" 1=

l∑=

ω λ " 0,( ) ω � 0( ) # � λ"[ ]exp� %–=

%∑=

ω� 0( ) ω λ " 0,( ) i=1, .....,K; ω� 0( )� 2& 1+≥ λ� 2& 1+=

� 3& 1+≥ � 3& 1+=

dω �d�-----------

= � becomes ω �+ 1+ ω �+ 1– 2∆ � = �++= =

� γ∆ � 1≤ � � && γ∆ � 1≤

�2& ∆

�= γ π � 0 & ∆

�⁄=

α 1 π⁄≤

G H $ α 0.5 1 π⁄( )×=

Page 63: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 63

Figure 13: Step functions spectrally fitted using the quadratic and the linear grids

6.3 The non-linear advection equation

(76)

If we again use the truncated Fourier series(70), the right-hand side of(76) becomes

Similarly the left-hand side of(76) is written as

Sincetheserieson eithersideof (76) aretruncatedat differentwave numbers,therewill alwaysbea residual .

UsingtheGalerkinmethod(theleastsquaresgivesthesameresult)we now choosethetime derivatiessubjectto

the condition

Unfittedfunction

Fitted withquadraticgrid

Fitted withlinear grid

∂ω∂ �------- ω∂ω

∂λ-------–=

= = � i � λ[ ] where= �exp� 2%–=

2%∑ i � � ′–( )ω� ′� ′ �m%–=

%∑–= = ω ��� ′– for � 0≥

∂ω∂ �-------

dω�d�----------- i � λ[ ]exp� %–=

%∑=

�i � λ–[ ]exp

0

∫ dλ 0 for all �=

Page 64: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

64 Meteorological Training Course Lecture Series

ECMWF, 2002

It can be shown that this yields

(77)

Thus,theFouriercomponents with wavenumberslargerthan aresimplyneglected.Thismeansthatthere

is no aliasing of small-scale components outside the original truncation and, hence, no non-linear instability.

In practicetherearetwo approachesto theproblemof calculatingnon-lineartermsin thecontext of thespectral

method—using interaction coefficients or the transform method

(a) Interaction coefficients.

An alternative way of expressing(77) is

wherethe aretheinteractioncoefficients.If thereareonly asmallnumberof possiblewaves,

then it is possibleto calculateandstorethe interactioncoefficients.However, for mostproblems

this is not possible and so the transform method is used for calculating the non-linear terns.

(b) Transform method.

UsingFastFourierTransforms(FFTs)it is easyto move from thespectralrepresentation(spectral

space)to a grid-point representation(physical space).Therefore,the essenceof the transform

methodis to calculatederivativesin spectralspace,but to transformto physical spaceusingFFTs

whenever a product is required.Once all the productshave beencomputedat grid points, the

spectralcoefficientsof this productfield arecalculated—thatis we useFFTsto returnto spectral

space. Now, consider how we apply this to the non-linear advection equation.

Giventhe we want to computethespectralcoefficientsof thenon-linearterm (i.e. the

on the right-hand side of(77)). The following three steps are required to do this:

(i) Calculate and at grid points by using the spectral coefficients

(ii) Calculate the advection term at each grid point in physical space

(iii) Return to spectral space by calculating the Fourier coefficients

In practicethis procedurehasto beemployedto calculatethespectralcoefficientsof thenon-linear

term at every time level. As the productof the two functionsis computedin grid-point spaceand

dω�d�-----------

= � & � &≤ ≤–=

= � &

dω�d�----------- i $ ω B ω� i 3 λ[ ] i $ λ[ ] i � λ–[ ]expexpexp λd∫�∑B∑–=

iωB ω � � Bn���, , where� BF���, ,�∑B∑– $ i 3 λ[ ] i $ λ[ ] i � λ–[ ]expexpexp λd∫= =

� BF���, ,

ω � ω∂ω∂λ-------–= �

ωG ∂ω

∂λ-------= λ �

ω λ �( ) ω� i � λ �[ ]G

λ �( )exp�∑ i � ω � i � λ �[ ]exp�∑= =

=λ �( ) ω λ �( )

Gλ �( )–=

= � 12π------

=λ �( ) i � λ �–[ ]exp�∑=

Page 65: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 65

not in spectralspace,wegetaliassingunlessthenumberof grid-pointscorrespondsto thequadratic

grid. Even so, products of more than two functions will still have aliassing.

6.4 The one-dimensional gravity wave equations

Sincetheseequationsarelinear, they canbedealtwith in thesamewayasthelinearadvectionequationdescribed

in Subsection 6.2. Writing the gravity wave equations in terms of the longitude gives

where is the angular velocity . Using

it is found that the Galerkin procedure gives

Therefore, with centred time differences, the time stepping algorithms for the Fourier coefficients are

Therefore, since our original equations were linear, the complete integration can be carried out in spectral space.

6.5 Stability of various time stepping schemes

6.5 (a) The forward time scheme.

(i) Linear advection equation

Using von Neumann we find

similar to the FTCS scheme and always unstable as .

(ii) Gravity wave equations

λ 2π�k�

⁄=

∂ω∂ �------- � ∂ �

∂λ------+ 0

∂ �∂ �------

� ∂ω∂λ-------+ 0= =

ω 2π � �⁄

ω λ �,( ) ω� �( ) i � λ[ ] � λ �,( ) �8� �( ) i � λ[ ]exp� %–=

%∑=exp� %–=

%∑=

dω�d�----------- i � �.�<�+ 0

d�<�d�---------- i � � ω�+ 0==

ω�+ 1+ ω�+ 1– 2i � ∆ � �.�<�+–=

�<�+ 1+ �<�+ 1– 2i � ∆ � � ω �+–=

ϕ �+ 1+ ϕ�+–

∆ �-------------------------- 5 0i � ϕ�+–=

λ 1 i � 5 0∆ �–=

λ 1>

Page 66: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

66 Meteorological Training Course Lecture Series

ECMWF, 2002

: always unstable.

6.5 (b) The leapfrog time scheme.

(i) Linear advection equation

: if , but otherwise.Thereforethe

schemeis conditionallystableandneutral,but thestability criterion is morerestrictive thanusing

finite differences as already stated inSubsection 6.2.

(ii) Gravity-wave equations

: if , but otherwise,andthe

stability condition for the scheme to be neutral is more restrictive than in finite differences.

The leapfrog scheme can be represented graphically as follows:

from which it is clearthat if is too large cannot stayin thecircle andthereforeits moduluswill

increase unlike in the analytical solution.

6.5 (c) Implicit centred scheme.

� �+ 1+ � �+–

∆ �-------------------------- � i � � �+–=

�<�+ 1+ �<�+–

∆ �--------------------------�

i � � �+–=

λ 1 i � � � ∆ � λ 1>→±=

ϕ�+ 1+ ϕ�+ 1––

2∆ �------------------------------- 5 0i � ϕ �+–=

λ 1 5 02 � 2 ∆ �( )2– i 5 0

� ∆ �–±= λ 1= 5 0� ∆ � 1≤ λ 1>

� �+ 1+ � �+ 1––

2∆ �------------------------------- � i � �<�+–=

�<�+ 1+ �<�+ 1––

2∆ �-------------------------------�

i � � �+–=

λ 1 � � � 2 ∆ �( )2– i � � � ∆ �–±= λ 1= � � � ∆ � 1≤ λ 1>

ω � �( )

ω� � ∆ �–( )ω� � ∆ �+( )

2∆ � �∂∂ω�

∆ � ω� � ∆ �+( )

Page 67: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 67

(i) Linear advection equation

: always neutral

(ii) Gravity wave equations

: always neutral.

6.5 (d) Shallow water equations.

(i) Explicit scheme

Asume a solution of the form

Substituting we get

ϕ �+ 1+ ϕ�+ 1––

2∆ �------------------------------- i � 5 0

2------- ϕ�+ 1+ ϕ �+ 1–+( )–=

λ2 1 i � 5 0∆ �–( ) 1 i � 5 0∆ �+( )⁄ λ→ 1= =

� �+ 1+ � �+ 1––

2∆ �------------------------------- i � �2--- �<�+ 1+ �<�+ 1–+( )–=

�<�+ 1+ �<�+ 1––

2∆ �------------------------------- i ��2----- � �+ 1+ � �+ 1–+( )–=

λ2 1 i � ∆ � � �–( ) 1 i � ∆ � � �+( )⁄ λ→ 1= =

Non-linear equations Linearized version

∂ �∂ �------ � ∂ �

∂�------ I ∂ �

∂�------ I– ∂ϕ∂�------+ + + 0=

∂ � ′∂ �-------- 5 0

∂ � ′∂�--------

S0∂ � ′∂�-------- 0 I ′– ∂ϕ′

∂�--------+ + + 0=

∂ I∂ �------ � ∂ I

∂�------ I ∂ I

∂�------ � ∂ϕ∂�------+ + + + 0=

∂ I ′∂ �-------- 5 0

∂ I ′∂�--------

S0∂ I ′∂�-------- 0 � ′ ∂ϕ′

∂�--------+ + + + 0=

∂ϕ∂ �------ � ∂ϕ

∂�------ I ∂ϕ

∂�------ ϕ ∂ �∂�------ ∂ I

∂�------+ + + + 0=

∂ϕ′∂ �-------- 5 0

∂ϕ′∂�--------

S0∂ϕ′∂�-------- Φ0

∂ � ′∂�-------- ∂ I ′

∂�--------+ + + + 0=

� ′ � 0 i α � � � ? �+ +( )[ ]exp=

I ′ I 0 i α � � � ? �+ +( )[ ]exp=

ϕ′ ϕ0 i α � � � ? �+ +( )[ ]exp=

� 0iα∆ �[ ] iα∆ �–[ ]exp–exp

2∆ �-------------------------------------------------------------- i � 5 0 � 0 i ? S 0 � 0 0 I 0– i � ϕ0+ + + 0=

I 0iα∆ �[ ] iα∆ �–[ ]exp–exp

2∆ �-------------------------------------------------------------- i � 5 0 I 0 i ? S 0 I 0 0 � 0 i ? ϕ0+ + + + 0=

ϕ0iα∆ �[ ] iα∆ �–[ ]exp–exp

2∆ �-------------------------------------------------------------- i � 5 0ϕ0 i ? S 0ϕ0 iΦ0� � 0 ? I 0+( )+ + + 0=

Page 68: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

68 Meteorological Training Course Lecture Series

ECMWF, 2002

i.e.

where

Projecting on the eigenvectors of matrix , for which

i.e.

We obtain three vector equations

the most restrictive of the three is when

which gives the stability condition that

The values for the atmosphereof these quantities are ; ;

. For a model representing waves down to a wavelength of ~380 km,

which gives for a value of ~4 min

(ii) Semi-implicit scheme

� 01

∆ �------ α∆ �( )sin � 5 0 � 0 ? S 0 � 0 i 0 I 0� ϕ0+ + + + 0=

I 01

∆ �------ α∆ �( )sin � 5 0 I 0 ? S 0 I 0 i 0– � 0 ? ϕ0+ + + 0=

ϕ01

∆ �------ α∆ �( )sin � 5 0ϕ0 ? S 0ϕ0 Φ0� � 0 ? I 0+( )+ + + 0=

1∆ �------ α∆ �( )sin Z � 5 0 ? S 0+( )Z HZ++ 0=

Z � 0 I 0 ϕ0, ,( ) and H

0 i 0�

i 0– 0 ?Φ0� Φ0 ? 0

= =

Z X H

HX λX H I λ–( )X⇒ 0 λ3 Φ0γ � 2– Φ0λ ? 2– λ 02–⇒ 0= = =

λ1 0=

λ2 Φ0� 2 ? 2+( )– 0

2– 0 λ2 3,⇒ 02 Φ0

� 2 ? 2+( )+±= =

1∆ �------ α∆ �( )Y 5 0

� S0 ?+( )Y λ " Y++sin 0=

α∆ �( )sin⇒ ∆ � 5 0� S

0 ? λ"+ +( )– 1≤=

λ" 02 Φ0

� 2 ? 2+( )++=

∆ � 1

5 0& S0� 0

2 Φ0� 2 ? 2+( )++ +

--------------------------------------------------------------------------------------- &≤ max �( ) � max ?( )= =

Φ0 9 104m2/s2⋅≈ 5 0 20m/s≈ 0 10 4– s 1–≈& � 2.65 10 6–× m 1–∼= ∆ �

Page 69: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 69

i.e.

where

Continuing as above, the eigenvalues of are given by

i.e.

Hence

If this gives:

The functionon the left handsidehasa maximumnegative valuewhen , in

which case there is a real solution for

� 0iα∆ �[ ]exp i∆ �–[ ]exp–

2∆ �---------------------------------------------------------- i � 5 0 � 0 i ? S 0 � 0 0 I 0– i � ϕ0iα∆ �[ ] α∆ �–[ ]exp+( )exp

2∆ �------------------------------------------------------------------+ + + 0=

I 0iα∆ �[ ] i∆ �–[ ]exp–exp

2∆ �---------------------------------------------------------- i � 5 0 I 0 i ? S 0 I 0 0 � 0 i ? ϕ0iα∆ �[ ] α∆ �–[ ]exp+( )exp

2∆ �------------------------------------------------------------------+ + + + 0=

ϕ0iα∆ �[ ] i∆ �–[ ]exp–exp

2∆ �---------------------------------------------------------- i � 5 0ϕ0 i ? S 0ϕ0 iΦ0� � 0 ? I 0+( ) iα∆ �[ ] α∆ �–[ ]exp+( )exp

2∆ �------------------------------------------------------------------+ + + 0=

i � 0

∆ �-------- α∆ �( ) i � 5 0 � 0 i ? S 0 � 0 0 I 0– i � ϕ0 α∆ �( )cos+ + +sin 0=

i I 0

∆ �------- α∆ �( ) i � 5 0 I 0 i ? S 0 I 0 0 I 0 i ? ϕ0 α∆ �( )cos+ + + +sin 0=

iϕ0

∆ �------- α∆ �( ) i � 5 0ϕ0 i ? S 0ϕ0 iΦ0� � 0 ? I 0+( ) α∆ �( )cos+ + +sin 0=

α∆ �( )sin∆ �-----------------------Z 5 0

� S0 ?+( )Z HZ++ 0=

Z � 0 I 0 φ0, ,( ) H

0 i 0� α∆ �( )cos

i 0– 0 ? α∆ �( )cos� Φ0 α∆ �( )cos ? Φ0 α∆ �( )cos 0

= =

λ H

λ3 Φ0λ � 2 ? 2+( ) 2 α∆ �( ) λ 02–cos– 0=

λ 0=

λ2 Φ0� 2 ? 2+( ) 2 α∆ �( ) 0

2–cos– 0 λ⇒ 02 Φ0

� 2 ? 2+( ) 2 α∆ �( )cos+±= =

α∆ �( ) ∆ � 02 Φ0

� 2 ? 2+( ) 2 α∆ �( )cos+ ∆ � 5 0� S

0 ?+( )+ +sin 0=

0 0=

α∆ �( ) ∆ � α∆ �( )cos Φ0� 2 ? 2+( )+sin ∆ � 5 0

� S0 ?+( )–=

∆ � Φ0� 2 ? 2+( ) 1≤

α

Page 70: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

70 Meteorological Training Course Lecture Series

ECMWF, 2002

If the condition is less restrictive. The numerical phase speed is:

while the analytical one is given by the same formula, but with the frequency given by

We can therefore compute the dispersion error

6.6 The spherical harmonics

Whenusingsphericalgeometryit is naturalto expandany dependentvariable in termsof a truncatedseriesof

spherical harmonics

(78)

where is thelongitudeand . Again is thezonalwavenumber, now n thetotalwavenumber

and represents the effective meridional wave number. In (78) we can choose the truncation that we want.

(a) If the truncationis describedastriangular(a modelwith this truncationand is

said to be a T40 model).

(b) For rhomboidal truncation .

Thereasonfor thesedescriptionsbecomesapparentwhenweplot adiagramof permissiblevaluesof and for

fixed ; such diagrams for are shown in Fig. 14.

∆ � 5 0� S

0 ?+( ) 1 ∆ � 15 0� S

0 ?+------------------------------≤⇒≤

∆ � Φ0� 2 ? 2+( ) 1>

� numα

� 2 ? 2+( )------------------------–=

αanal

αanal 1,� 5 0 ? S 0+( ) slow solution (or Rossby wave)–=

αanal 2.3,� 5 0 ? S 0+( ) 0

2 Φ0� 2 ? 2+( )+ fast solution (inertia–gravity waves)±–=

H � num

� anal----------- α

αanal-----------= =

ϕ

ϕ λ µ �, ,( ) ϕ+�po +� λ µ,( )+ �=

q∑

� %–=

%∑=

λ µ lati tude( )sin= �? �–

r &= � 40=

r & �+=

? �& & 4=

Page 71: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 71

Figure 14. Permissible vales of and for triangular and rhomboidal truncation.

The spherical harmonics have the property that

(79)

where is the Laplacian in spherical coordinates and is the earth's radius. Another property is that

where is the associated Legendre polynomial of degree and order , which may be computed as

and are orthogonal:

The space derivatives can be computed analytically as:

and using the properties of the Legendre polynomial we have

� ?

∇2 o +� ?s? 1+( ) 2

---------------------o +�–=

∇2

o +� λ µ,( ) t +� µ( ) i � λ[ ]exp=

t +� ? �

t +� µ( )= 2? 1+( ) ? �–( )!? �+( )!

----------------------˜ 1

2+ ? !

----------- 1 µ– 2( )

�2-----

µ+ �+

+ �+( )

d

d µ2 1–( )+

m 0≥;

t + �– µ( )=t +� µ( )

12--- t +� µ( ) tvu� µ( ) µ

1–

1

∫ δ+ u,=

∂∂λ------o +� i � o +� � 0≥=

Page 72: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

72 Meteorological Training Course Lecture Series

ECMWF, 2002

For weusethefactthat . With theserelationshipsspacederivativescanbecalculatedexactly

leaving a setof ordinarydifferentialequationsfor the time rateof changeof thesphericalharmoniccoefficients

.

Normallywehave to dealwith non-lineartermsin which two sphericalharmonicsinteractto producea third. Un-

lessthetruncationis very severethecalculationsarevery time consuming.This problemcanbeovercomeby the

transform method introduced in sectionSubsection 6.3.

(a) Startingin spectralspace,thespectralcoefficientsareusedto calculatethedependentvariablesona

latitude–longitudegrid (inversespectraltransform).For a regularly spacedlongitudegrid with at

least pointsanda speciallychosenlatitudegrid (theGaussianlatitudeswhich arealmost

regularly spaced), the transformation can be done exactly.

(b) Thenon-lineardynamicsandphysicalprocesstermsof eachprognosticequationarecalculatedin

real space.

(c) The non-linear terms are transformed back to the spectral domain (direct spectral transform).

In order to perform the spectral transforms it is convenient to introduce the Fourier coefficients

Scalarlymultiplying Eq. (78) by eachof thesphericalharmonicsandmakinguseof theorthogonalityproperties

of both the Fourier basis functions and the Legendre polynomials, we get

which is thedirectspectraltransform.This transformcanbedoneby first performingtheintegral with respectto

. This is a Fourier transformwhich will computetheFouriercoefficients.If theoriginal function is given in a

discretesetof longitudepoints,thetransformis a discreteFourier transformand,asdiscusedearlierit is exact if

the longitude points are equally spaced and its number is at least 2M+1.

The integral with respectto the latitudecanbeperformedfrom theFourier coefficientsby meansof a Gaussian

quadratureformulaandit canbeshown thatthis integral is exact if thelatitudesat which theinput dataaregiven

are taken at the points where

(thesearecalledtheGaussianlatitudes)with . Furthermoreproductsof two functionscanbe

computedalias-freeif the numberof Gaussianlatitudesis . The Gaussianlatitudesare not

equallyspacedasthepointsto computethediscreteFourier transformsbut they arenearlysoandthereforethis

1 µ2–( ) ∂∂µ------o +� ? ε+ 1+

� o + 1+

�– ? 1+( )ε+�po + 1–

� � 0≥+=

ε+� ? 2 � 2–

4 ? 1–( )-----------------------

1 2⁄

=

� 0>o + �– o +�( )

*=

ϕ+�

2& 1+

ϕ� µ �,( ) 12π------ ϕ λ µ �, ,( ) # � λ–[ ]exp λ

0

∫ ϕ+� �( ) t +� µ( )+ �=

(∑= =

ϕ +� �( ) 14π------ ϕ λ µ �, ,( ) t +� µ( ) # � λ–[ ]exp λ µ

0

2π( )

∫0

1

∫=

λ

t (xw0 µ( ) 0=

�zy 2& 1+( )/2≥�zy 3& 1+( )/2≥

Page 73: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 73

spacing is approximately the same as the longitudinal spacing.

Thedistribution of pointsallowing exact transformsis calledthe linearGaussiangrid andit hasat least(2M+1)

longitudepointsequallyspacedateachof at least(2M+1)/2Gaussianlatituderows.Productsof two functionscan

becomputedalias-freeif weuseaquadraticGaussiangrid which is madeof at least(3M+1) equallyspacedpoints

in each of at least (3M+1)/2 Gaussian latitudes.

Thesamedistributionof grid-pointsof aGaussiangrid canrepresenta linearor aquadraticGaussiangrid depend-

ing on thespectraltruncationusedin conjunctionwith thatgrid. As anexample,thequadraticgrid corresponding

to a spectraltruncationof T213coincideswith the linearGaussiangrid correspondingto thespectraltruncation

T319.

Finally it shouldbenotedthatonly truescalarsshouldbe representedby a seriesof sphericalharmonics:hence

whenspectralmethodsareused,theprimitiveequationsareput in their vorticity anddivergenceform, ratherthan

in their momentum (u and v) form.

6.7 The reduced Gaussian grid

WhenusingaregularGaussiangrid asdescribedabove,eitheraquadraticor a linearGaussiangrid, thenumberof

longitudepointsperrow of latitudeis thesamenomatterhow closeweareto thepole.Thereforethegeographycal

distancebetweenpointsof thesamerow decreasesaswe approachthepolesandtheresolution,which is nearly

isotropic close to the equator becomes highly anisotropic close to the poles.

Thetriangulartruncationin spectralspaceis isotropicbecausetheshortestwavelengthrepresentable(wavenumber

n=M) is independentof thewavedirection(givenby thevalueof thezonalwavenumberm). Ontheotherhandthe

amplitudeof theassociatedLegendrepolynomialsisverysmallwhenmis largeand approaches1.Thissuggest

thepossibilityof ignoringsomeof thevaluesof m in theFouriertransformsatGaussianlatitudesapproachingthe

poles.Thenumberof longitudepointsneededto representproperlytheretainedwavelengthsis thensmallerand

thedistancebetweenpointsdecreaseslessdramaticallythanwith theregular(or full) grid, resultingin amoreiso-

tropic resolution.

The Gaussian grid resulting from these considerations is called thereducedGaussiangrid.

In sphericalgeometry, evenusingthereducedlinearGaussiangrid, thenumberof degreesof freedomin grid-point

spaceis largerthanthenumberof degreesof freedomin spectralspaceandtherefore,if westartwith therepresen-

tationof afield in grid-pointspace,go to spectralspaceandreturnto grid-pointspace,partof thedegreesof free-

dom in the initial dataare lost andspectralor “Gibbs” ripplesappearasa consequenceof the spectralfitting.

Nevertheless,the problemis lessnoticeablewhenusingthe linear Gaussiangrid thanwhenusingthe quadratic

Gaussiangrid becausein theformertheratiobetweenthenumberof degreesof freedomin grid-pointspaceandin

spectral space is closer to 1 than in the latter.

6.8 Diffusion in spectral space

The linear diffusion equation in two dimensions for a variable A is

Transformingto spectralspaceandmakinguseof thepropertyof thesphericalharmonicsgivenby Eq.(79), weget

µ

�∂∂M � ∇2 M K 0>;=

Page 74: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

74 Meteorological Training Course Lecture Series

ECMWF, 2002

Applying theleapfrogtimediscretizationwegettwo solutions,thephysicalsolutionwhich is unconditionallysta-

ble anda computationalsolutionwhich is unconditionallyunstable.If we applya forwardtime-steppingscheme

wegetonesolutionwhich is conditionallystable.Finally if weapplya fully implicit (or backward)time-stepping

scheme we get

which is a decoupled system of equations and the scheme is unconditionally stable.

Thereis no penaltyfor usinganimplicit time-steppingschemebecausethebasisfunctionsareeigenfunctionsof

theequationoperator. It is alsostraightforwardto applya superharmonicoperatorsuchas , or even with

any integer value of m. It sufices to substitute in the solution by .

6.9 Advantages and disadvantages

6.9 (a) Advantages.

(i) Space derivatives calculated exactly.

(ii) Non-linearquadraticternscalculatedwithout aliasing(if computedin spectralspaceor usingthe

quadratic grid).

(iii) For a given accuracy fewer degrees of freedom are required than in a grid-point model.

(iv) Easy to constructsemi-implicit schemessince sphericalharmonicsare eigenfunctionsof the

Helmholtz operator.

(v) On the sphere there is no pole problem.

(vi) Phase lag errors of mid-latitude synoptic disturbances are reduced.

(vii) The use of staggered grids is avoided.

6.9 (b) Disadvantages.

(i) The schemes appear complicated, though they are relatively easy to implement.

(ii) The calculation of the non-linear terms takes a long time unless the transform method is used.

(iii) Physical processes cannot be included unless the transform method is used.

(iv) As the horizontal resolutionis refined, the numberof arithmetic operationsincreasesfaster in

spectralmodelsthanin grid-pointmodelsdueto theLegendretransformswhosecostincreasesas

N3.

(v) Spherical harmonics are not suitable for limited-area models.

�∂∂M +� � ?s? 1+( )

2---------------------

M +�–=

M +� � ∆ �+( )M +� �( )–

∆ �-------------------------------------------------- � ?7? 1+( )---------------------M +� � ∆ �+( )–=

M +� � ∆ �+( )=M +� �( )

1 ∆ � � ?7? 1+( )/ 2+---------------------------------------------------

∇4 ∇2�?7? 1+( )/ 2 ?7? 1+( )/ 2( )

Page 75: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 75

6.10 Further reading

Theoriginal versionof this noteis basedmainly on a review articleby Machenhaueron "The spectralmethod"

which is Chapter3 of GARPPublicationSeriesNo.17,VolumeII. Thatarticlecontainsfarmoreinformationthan

is in this note, except for the linear and the reduced Gaussian grids.

7. THE FINITE -ELEMENT TECHNIQ UE

7.1 Introduction

As with thespectralmethod,thefinite elementtechniqueapproximatesthefield of adependentvariableby afinite

seriesexpansionin termsof linearly independentanalyticalfunctions.This meansthat thedependentvariableis

definedover thewholedomainratherthanjust at discretepointsasin thegrid-pointmethod.Thedifferencebe-

tweenthespectralandfinite-elementtechniquesliesin theform of theexpansionfunctions:for thespectralmethod

these are global functions whereas for the finite elements they are only locally non zero (seeSubsection 1.4).

There are two basic steps in the finite-element technique:

(a) expandthe dependentvariablesin termsof a set of low-order polynomials(the basisfunctions)

which are only locally non-zero.

(b) insert theseexpansionsinto the governing equationsand orthogonalizethe error with respectto

some test functions.

As anexampleconsiderhow wecanrepresentafield in finite-elementnotationwhenwearegiventhevaluesof

at equallyspacedpointsalongthe -direction.Let thepointsbegivenby (thenodes)andthevaluesof the

dependentvariableby (thenodalvalue)—seeFig.15. Now supposethat varieslinearlybetweenthenodes—

thereis a piecewise linearfit. Thereforethebehaviour of within anelement(theregion betweenthenodes)is

determinedby thenodalvalues.If wedefineasetof basisfunctions givenby thehat(chapeau)function(see

Fig. 15), the field of can be represented by

(80)

An example of this is given inFig. 15. This approach is called collocation method.

ϕϕ

� � �ϕ � ϕ

ϕ�'� �( )

ϕ

ϕ ϕ �{�'� �( )�∑=

Page 76: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

76 Meteorological Training Course Lecture Series

ECMWF, 2002

Figure 15.Illustrationsof (a) linearpiecewisefit, (b) linearbasisfunctionsand(c) of how alinearpiecewisefit is

made up of a linear combination of basis functions.

Anotherapproachto thecalculationof theexpansioncoefficients whenwe aregivena continuousfunctionis

to minimizethedistancebetweenthecontinuousfunction andthediscreteapproximation . In order

to apply this approach,we needfirst to definea topologywhich is usuallydoneby defininga scalarproduct( , )

andthecorrespondingnorm ; thereforethespaceof functionsis given thestructureof a Hilbert

space.It canbeeasilyshown thatthis proceduregivesthesameresultastheGalerkinapproachof scalarlymulti-

plying both sides of(80) by each of the basis functions

(81)

which is a system of simultaneous linear equations for the unknown coefficients .

7.2 Linear advection equation

7.2 (a) . Once again we consider the linear advection equation with periodic boundary conditions

ϕ �ϕ ϕ �A�'� �( )∑

ψ 2 ψ ψ,( )=

��� �( )

ϕ ��� �( ),( ) ϕ �J�'� �( ) ��� �( ),( )�∑=

ϕ �

Page 77: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 77

Definea meshof points , with . We assumethat the finite-ele-

ment approximation to the exact solution has a piecewise linear representation using the as the nodes.

Substituting in the original equation gives

(82)

where is theresidual.If wesimplyset (point collocation)wehave theproblemthat is notde-

finedat thenodes.If this is overcomeby makingfurtherapproximationswe endup with theusualcentreddiffer-

enceapproximation.However, theuseof higher-orderfinite-elementinterpolationwith point collocationdoesnot

lead to standard higher order difference schemes.

An alternative approachis to usethe Galerkinmethodwith the basisfunctionsas the test functions(the least-

squares method gives the same results). Therefore, we have

(83)

Substituting for from (82) into (83) gives

(84)

Sincethebasisfunctionsarehat-functions,therearegoingto bemany combinationsof and for which thein-

tegralsarezero.In fact, for a given , therewill only be non-zerocontributionsfor (that is

). It is easy to show that

Using these results in(84) gives

(85)

Wefind thatthisimplicit schemehasaslightly smallertruncationerrorfor thespacederivativethantheusualfourth

order scheme.

∂ϕ∂ �------ � 0

∂ϕ∂�------+ 0 ϕ

� � �,+( ) ϕ� �,( ) ϕ

�0,( ) �( )= = =

� � , 1–( )∆�

= , 1 2 …� 1+, ,= ∆� � �⁄= � �

ϕ� �,( ) ϕ � �( ) �'� �( )� 1=

(1+

∑=

� dϕ �d�--------- �'� � 0 ϕ � d�'�

d�--------�∑+�∑=

� �0= d �'� d

�⁄

� ��" �d∫ 0 # 1 2 …� 1+, ,= =

dϕ �d�--------- ��"i�'� � � 0 ϕ � �'�d �

d------- ��" �d

0

*∫�∑+d

0

*∫�∑ 0=

# ,, # , 1 ,|, 1+, ,–=� � 1–

� � � 1+≤ ≤

�'� 1+ �'� �d∫16---∆�

= �'�2 �d∫23---∆�

=

e� 1±d �d

-------------- �}� �d∫12---±=

e�d �d------- �'� �d∫ 0=

� �~]± � � �d∫ 0=e�~]±d �d

--------------- � � �d∫ 0 p 1>=

16---

dϕ � 1+

d�--------------- 4

dϕ �d�---------

dϕ � 1–

d�---------------+ +

� 0

ϕ � 1+ ϕ � 1––

2∆�------------------------------

+ 0=

Page 78: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

78 Meteorological Training Course Lecture Series

ECMWF, 2002

Now considerhow theschemedefinedby (85) is used.in practice.Let representthe time derivative of at

node and time level .

(86)

Applying (85) at time level yields

(87)

SincetheRHSof (87) is known, this setof simultaneouslinearequationscanbesolvedfor all the . Thenext

step is to introduce a time stepping scheme. For example, if the leapfrog scheme is used(86) becomes

(88)

To study the stability of this scheme we combine(87) and(88) to give the complete numerical algorithm

(89)

andthenusethevonNeumannseriesmethodin theusualway. For thisschemeit canbeshown thatthereis stability

if ; this is morerestrictive thanfor thecorrespondingfinite differenceschemewhich is cen-

tredin spaceandtime.Furtheranalysisshowsthattheschemeis neutral , with therelativephasespeedof

the physical mode being given by

The variation of and with for the finite elementmethod is given in Table 3 for the casewhere

. Also theresultsof usingthis techniqueonthetestproblemgivenin Subsection2.6areshown

in Figs.5 and6 . Comparisonof thesewith theresultsfrom thefourthorderleapfrogschemeshows thatthey ap-

pear to produce forecasts of a similar quality. The major disadvantage of this method is that it is implicit.

Theschemedefinedby (87)and(88) (or (89)) is a three-level scheme.If a two-level schemeis required(i.e.a for-

wardtime difference)we cantake theCrank–Nicolsonapproachandusea weightedmeanof theadvectionterms

at time levels and with weights and . The expressions corresponding to(87) and(88) are then

which can be combined to give

= �+ ϕ, ?

dϕ �+d�---------

= �+=

?

16---= � 1+

+4= �+ = � 1–

++ +( ) � 0

ϕ � 1+ ϕ � 1––

2∆�------------------------------

for all ,–=

= �+

ϕ �+ 1+ ϕ �+ 1– 2∆ � = �++=

ϕ � 1–

+ 1+ 4ϕ �+ 1+ ϕ � 1–

+ 1++ + ϕ � 1–

+1 6α+( ) 4ϕ �+ ϕ � 1+

+1 6α–( )+ +=

α � 0∆ � ∆�

⁄ 3≤= G1=( )

H 1α >------- C

L 2 C 2–( )1 2⁄-----------------------------

atan=

C α > Lsin–2 >cos+

3--------------------- > 2π$------= = =

G H $α 0.5 1 3⁄( )×=

? ? 1+ β+ β + 1+

16---= � 1+

+4= �+ = � 1–

++ +( ) β+ 1+

M �+ 1+ β+ M �++=

ϕ � 1–

+ 1+ ϕ �+ ∆ � = �++=

ϕ � 1–

+ 1+ 1 3αβ + 1+–( ) 4ϕ �+ 1+ ϕ � 1+

+ 1+ 1 3αβ+ 1++( )+ + ϕ � 1–

+1 3αβ++( ) 4ϕ � 1+

+1 3αβ +–( )+=

Page 79: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 79

A stability analysisshows that for thereis instability, whereasfor thereis absolutestability

with giving aneutralscheme(i.e.nodamping,thoughtherearephaseerrors).As theexplicit

schemegivesa coupledsystemof equations,no penaltyis paidin usinganimplicit approachwhich is absolutely

stable if both systems can be solved using the same kind of solver.

7.2 (b) . In the piecewise linear elementrepresentation,the function is obligedto behave linearly between

nodes.To improve this fit we canusesecond-orderpolynomialsasthebasisfunctionsastheconvolution polyno-

mialsrepresentedin Fig. 16 . With this representationwegetnotonly continuityof thefunctionat thenodesasin

the piecewise linear case but also continuity of the first derivative.

Figure 16. Second order polynomials as basis functions.

Figure 17. Linear together with quadratic elements.

An alternative is to use simultaneously linear and quadratic elements as the ones shown in Fig. 17.

Wedon'tautomaticallygetcontinuityof thederivativeatthenodesin thisrepresentation,but thefit of agivenfunc-

tion between the nodes can be improved.

Now, if we applytheGalerkinapproachto thelinearadvectionequation,aswasdonein thepiecewiselinearrep-

resentation, we get a similar system of simultaneous equations

(90)

but thematrix insteadof beingtridiagonalasit wasin equations(89) is a lesssparsematrix andthereforemore

expensive to solve.

7.3 Second-order derivatives

Let usnow turn to thetreatmentby meansof finite elementsof anequationinvolving second-orderspacederiva-

tives.Asanexample,wewill show how finite-elementtechniquescanbeusedtosolveasimpleHelmholtzequation

β + 1 2⁄> β + 1 2⁄≤β + β+ 1+ 1 2⁄= =

AΨ+ 1+ F

+=

Page 80: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

80 Meteorological Training Course Lecture Series

ECMWF, 2002

(91)

A first alternative is to use quadratic elements as the basis functions and use the Galerkin method as before

(92)

sothatthesecondderivativesof thebasisfunctionscanbecalculatedanalyticallyandthenthefive-diagonalsystem

(92) solved.

A second alternative using linear elements is as follows:

Let us assume that we use the scalar product of space, that is

then(92) can be written as

The first term can be integrated by parts

thefirst termof theRHSis zerofor all and , andnow all thederivativesarefirst orderandcanbe

calculated analytically using linear elements.

The matrix of the resulting system of equationsis tridiagonal except for the elements ,

, , .

7.4 Boundaries, irregular grids and asymmetric algorithms

Thefinite-elementmethodcaneasilycopewith boundariesandirregulargridsbychoosingsuitablebasisfunctions.

Also asymmetricalgorithmscanbederivedby choosingtestfunctionsthataredifferentfrom thebasisfunctions.

Theseaspectsof thefinite-elementmethodwill beillustratedby their applicationto thelinearadvectionequation

using a linear piecewise fit.

7.4 (a) Boundaries.Supposewe have boundariesat nodes and . Making a linearpiece-

wisefit it is easyto seethatthebasisfunctionsfor aretheusualhatfunctions,whereasthebasisfunc-

tionsassociatedwith theboundarynodeshaveavalueof 1 at theboundaryfalling to 0 atthefirst internalnode(see

Fig. 18). The usual Galerkin procedure then gives

∂2ψ∂� 2

--------- α2ψ– 0=

ψ � d2 �'�d� 2

---------- �'�,

α2 ψ �J�'�U��",( )�∑–�∑ 0=

/�,( ) A���d0

*∫=

ψ � d2 �'�d� 2

---------- ��" � α2 ψ ���∫ � ��"�∑–d�

d∫�∑ 0=

d2 �}�d� 2

---------- ��" �d∫d�'�d�-------- ��"

0

*d�'�d�--------

d ��"d�-------�

d∫–=

# 1≠ #m� 1+≠

, 1 #, 1= =( ), 2 #, 1= =( ) , � 1+ #, � 1+= =( ) , ��#, � 1+= =( )

, 1= , � 1+=

2 ,��≤ ≤

Page 81: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 81

(93)

This set of equations can be solved for the at all nodes, including the boundary nodes.

Now aparadoxarises:weknow thatthelinearadvectionequationhasauniquesolutiongivenasuitablesetof initial

andboundaryconditions,but thesystem(93)givesus,in principle,thevaluesof atall nodesand,therefore,

doesnotallow ustospecifyany boundarycondition.Thesameis truefor theHelmholtzequationof Subsection7.3.

Thesolutionof this paradoxis thateitherthematrix of theresultingsystemis singularand,therefore,thesystem

of equationscannotbe solved,or the systemis over specifiedandthe solutionwe get doesn'tcorrespondto the

boundary conditions.

The cureis thento scalarlymultiply only by the interior elementsthat is, usein (84) or (92) only the valuesof

andcompute and from theboundaryconditions.Thesystemthenhas equationsand

can be solved for the interior coefficients

7.4 (b) Irregular grids. Usingthebasisfunctionsshown in Fig. 18 , it is straightforwardto show that thefi-

nite-element formulation of the advection equation on an irregular grid is

Naturally this reduces to(85) when the grid is uniform, i.e. .

7.4 (c) Asymmetric algorithms.Sofar thechoiceof linearbasisfunctionshasleadto symmetricalgorithms.

However, this symmetrycanbebrokenby usingasymmetrictestfunctions.For example,theuseof thebasisand

testfunctionsillustratedin Fig. 15 in theadvectionequationproducesanalgorithmwhich hassomeof thechar-

acteristics of the upstream finite difference scheme.

13---

dϕ2

d�--------- 2

dϕ1

d�---------+

� 0

ϕ1 ϕ2–

∆�-----------------

+ 0=

16---

dϕ � 1–

d�--------------- 4

dϕ �d�---------

dϕ � 1+

d�---------------+ +

� 0

ϕ � 1+ ϕ �–

∆�------------------------

+ 0 2 , ?≤ ≤=

13---

dϕ (d�----------- 2

dϕ ( 1+

d�-----------------+

� 0

ϕ ( 1+ ϕ (–

∆�---------------------------

+ 0=

dϕ d�⁄

dϕ d�⁄

2 #m�≤ ≤ ψ1 ψ ( 1+ � 1–

� 1– ψ � 2 ,��≤ ≤( )

16---

dψ � 1–

d�---------------- 2

dψ �d�---------+

∆� � 1 2⁄–

16--- 2

dψ �d�---------

dψ � 1+

d�----------------+

∆� � 1 2⁄+ � 0 ψ � 1+ ψ � 1––( )+ + 0=

∆� � 1– ∆

� � 1+ ∆�

= =

13---

dψ � 1–

d�---------------- 2

dψ �d�---------+

� 0

ψ � ψ � 1––

∆�-------------------------

+ 0=

Page 82: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

82 Meteorological Training Course Lecture Series

ECMWF, 2002

Figure 18. llustrations of (a) linear basis functions in the vicinity of a boundary, (b) linear basis functions for an

irregular grid and (c) linear basis and test functions which would give asymmetric algorithms.

7.5 Treatment of non-linear terms

Consider the treatment of the non-linear tern in the one-dimensional advection equation

A straightforward one-step approach is to use

Substitution in the non-linear equation and making the Galerkin assumption yields

∂ �∂ �------ � ∂ �

∂�------+ 0=

� � �A�'� G�∑

∂ �∂�------ � � d�'�

d�--------�∑= = =

Page 83: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 83

Alternatively, a two-stepmethodcanbeused.In thiswefirst find thebestpiecewiseapproximationto by using

the Galerkin assumption

Having solvedthis setof equationsfor the , thesecondstepis to find thebestapproximationto by again

using the Galerkin assumption

This is moreaccuratethantheone-stepprocedure.but it hasthedisadvantagethatanextra matrix inversionis re-

quired to find the .

Finally, it is worthnotingthatfinite elementschemesdonotappearto suffer from aliasingandnon-linearinstabil-

ity. This happensbecausetheinteractionswhich normallygive riseto aliasingareheavily smoothedin thefinite-

element method.

7.6 Staggered grids and two-dimensional elements

Figure 19. Staggered piecewise linear elements.

In Subsection4.3 it wasshown thatit is naturalto usea staggeredgrid whendealingwith thegravity-wave equa-

tions.Therefore,wewill now considerthefinite-elementapproximationsto theseequationsusinglinearbasisfunc-

tions and a staggered grid.

Define two sets of basis functions ( and ) shown in Fig. 19and assume that

16---

d� � 1+

d�--------------- 4

d� �d�---------

d� � 1–

d�---------------+ +

12∆�----------

� � 1+ 2� �+( )3

--------------------------------- � � 1+ � �–( )� � 1– 2� �+( )

3-------------------------------- � � � � 1––( )+

–=

G

16---G � 1+ 4

G � G � 1–+ +( )� � 1+ � � 1––

2∆�------------------------------=

G � � G

16---

d� � 1+

d�--------------- 4

d� �d�---------

d� � 1–

d�---------------+ +

112------ � � 1–

G � 1–G �+( ) � � 1+

G � 1+G �+( ) � � G � 1+ 6

G � G � 1–+ +( )+ +{ }–=

G �

�'� �}� 1 2⁄+

Page 84: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

84 Meteorological Training Course Lecture Series

ECMWF, 2002

Substituting the expansions in the following equation

and using the Galerkin procedure with the as test functions gives

Calculation of the integrals leads to

The corresponding finite element approximation to the other equation

is the following

7.7 Two dimensional elements

With rectangularmeshwe candefinerectangularelementswherethe linear basisfunction associated

with node( ) hasavalueof unity at thisnodeandfalls to zeroat the8 adjacentnodes(seeFig. 20 ). A variable

can then be expanded in terms of these basis functions.

Substitutingthis in theoriginalpartialdifferenceequationandusingtheusualGalerkinprocedureto orthogonalize

the error leads to a set of equations describing the behaviour of the expansion coefficients .

� �P�A�'� and ��∑ � � 1 2⁄+ �'� 1 2⁄+�∑= =

∂ �∂ �------

� ∂ �∂�------+ 0=

�}�

d�P�d�--------- ��"i�'� � � � � 1 2⁄+ �'� d�'� 1 2⁄+

d�-------------------

�d∫∑+d∫∑

16---

d�Q� 1–

d�--------------- 4

d�Q�d�---------

d�Q� 1+

d�---------------+ +

� � � 1 2⁄+ � � 1 2⁄––( )∆�---------------------------------------------+ 0=

∂ �∂ �------ � ∂ �

∂�------+ 0=

16---

d� � 3 2⁄+

d�-------------------- 4

d� � 1 2⁄+

d�--------------------

d� � 1 2⁄–

d�--------------------+ +

� �Q� 1+ �Q� 1––( )∆�-----------------------------------+ 0=

��" � � �,( )#U,,

ϕ

ϕ� � �, ,( ) ϕ" �{��" � � �,( )"<�,∑=

ϕ " �

Page 85: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 85

Figure 20. llustration of a two dimensional linear basis function for a rectangular grid. In the shaded area the

basis function is non-zero; the basis function is zero at nodes marked by • and unity at the node marked X.

For solvingequationswith sphericalgeometry, it is possibleto generateagrid of icosohedra,with eachtriangular

facedividedinto equilateraltriangles.Eachelementthenhastheform shown in Fig. 21 . To illustratethekind of

algorithmsproduced,justoneexamplewill begiven.Usinglinearelementsit canbeshown thatthefinite element

description of the derivative is

Cullen (1974) has used this approach in a primitive equation model using spherical geometry.

Figure 21. An element is made up of 6 triangles.

7.8 The local spectral technique

Oneof theadvantagesof thefinite-elementmethodis thepossibilityof usingirregulargridswhile still maintaining

a high degreeof accuracy, asopposedto thefinite differencetechnique.This allows usto defineelementswhose

shapeis adaptedto thegeometryof thedomainin which we want to solve our equations.This possibility is the

basisof thesuccessthatfinite elementshave hadin engineeringproblemsinvolving complicatedstructures.The

mainweaknessof themethodis that, insideeachelementthe function is assumedto have a linearbehaviour, or

otherwisewe endup with a systemof equationswhosematrix is not sparseand,therefore,is very expensive to

solve both in terms of CPU time and storage memory.

A wayroundthisproblemis providedby thelocalspectraltechnique.In thisapproachwedefineasetof localdo-

mains,justasin thefinite-elementmethod,but weuseinsideeachelementaspectralrepresentation,takingasbasis

X

G∂ϕ ∂

�⁄=

112------G

1

G2

G3 6

G4

G5

G6

G7+ + + + + +( ) 1

6∆�---------- ϕ2 ϕ1–( ) 2 ϕ5 ϕ3–( ) ϕ7 ϕ6–( )+ +[ ]=

Page 86: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

86 Meteorological Training Course Lecture Series

ECMWF, 2002

functionsasetof Lagrangeinterpolatingpolynomialsandimposingcontinuityof thesolutionthroughtheelement

boundaries.This givesusa systemof equationswith a blockedmatrix, eachblock beingdiagonalandtherefore

very sparse.

Thetechniqueis verywell suitedfor implementationonaparallelcomputerif theinteriorof eachelementis solved

in asingleprocessor, thecommunicationsbeinglimited to passingasmallquantityof informationbetweennearest

neighbours only.

7.9 Application for the computation of vertical integrals in the ECMWF model

In thesemi-Lagrangianversionof theECMWF forecastmodel,theverticaldiscretizationis neededonly in order

to computetheverticalintegralsof thecontinuityandthehydrostaticequations.Thequantitiesto beintegratedare

definedat “full” levelsandtheintegrationis performedby themid-pointrule,sothattheintegralsarein principle

only availableat “half” levels.Extrapolationor averagingto full levelscompromisethesecond-orderaccuracy of

the integration.

As an alternative, a finite-elementschemehasbeendevelopedusingcubic splinesasbasisfunctions.TheseB-

splinesdiffer from thecubicsplinesdefinedin Subsection5.3. TheB-splinesaredefinedaspiecewisecubic (at

eachinterval) polynomialswhicharenon-zeroonly over4 grid intervals,whosezeroth,first andsecondderivatives

are continuous and whose integral over the whole domain is prescribed.

Thesepolynomialscanbeusedasbasisfunctionsfor thefinite-elementmethod.Unlikethecasewith thepiecewise

linearelements,we cannot usethecollocationmethodbecausethecoefficientsof theexpansionof a function in

terms of these basis functions are not the values of the function at the nodes.

Let’s compute the value of a vertical integral using this method:

ThenweexpandbothF(x) andf(y) asa linearcombinationof B-splines(thebasisfuctionschosento expandboth

functionscouldbedifferent.In ourcasethey arethesameexceptfor theboundarieswherethey aremodifiedto suit

the appropriate boundary conditions)

Now we apply the Galerkin procedure using some “test functions” ti(x)

which can be expressed in matrix form

(94)

Theinitial informationwe getto performtheintegral is thesetof valuesof f(x), say , at the“full levels” of the

modelandthefinal resultweneedis thevalueof F(x) alsoonthefull levelsof themodel,say . If wechoosethe

= �( ) �( ) �

0

-∫=

Ψ "� <" �( )" 1=

(∑ ψ "!��" �( ) �

0

-∫" 1=

(∑=

Ψ " d" �( ) � � �( )�

0

1

∫" 1=

(∑ ψ " � � �( ) ��" �( ) � ( )

0

-∫

� 0

1

∫" 1=

(∑=

Ψ �˜

ψ => ΨM˜

1– �˜

ψ= =

˜ = ˜

Page 87: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 87

numberof basisfunctionsthesameasthenumberof degreesof freedomof f(x) (includingappropriateboundary

conditions)thentransformingthissetof valuesto thevector issimplyamatrixmultiplicationbyasquarematrix,

say , andtheprojectionfrom to thevaluesof F(x) is amultiplicationby anothermatrix,say . Therefore

expression(94) can be written as

and the matrix is our integration operator.

8. SOLVING THE ALGEBRAIC EQUATIONS

8.1 Introduction

In all themethodswehaveseenfor solvingthepartialdifferentialequationsof atmosphericmotionwefinally arrive

atasetof simultaneousalgebraicequationswheretheunknownsarethegrid pointsor thecoefficientsat timestep

and we have to solve this system.

The spectral method leads to the simplest case where the matrix of the system to be solved

is diagonaldueto theorthogonalityof thebasisfunctionschosen,andsotheequationsof thesystemaredecoupled

from oneanother. Thesolutionthenis straightforward,eachequationhaving only oneunknown.Ontheotherhand,

aswe saw in the chapteron the spectraltechnique,the transformationsto grid-point spaceandbackto spectral

spacearevery expensive in termsof computing,mainly whenthenumberof degreesof freedomin themodelis

increasedandsofinite-differenceandfinite-elementmethodscannotbediscarded,evenin thehorizontaldiscreti-

zation.

In thesecases,thesystemof algebraicequationswearriveat is coupled,mostlyin theform of tridiagonalor block

tridiagonal matrices.

Thesimplestmethodof solvinga systemof simultaneousequationsis by matrix inversion,sothat if matrix is

non-singular, it has an inverse and the system can be transformed into

Thedrawbackof this methodis that,with largematrices,the inversionoperationis very expensive both in terms

of memory and CPU time.

8.2 Gauss elimination

Let usassumewehaveaone-dimensionalmodeltreatedby meansof finite differences(centred)or finite elements

(linear)of dimension (thenumberof grid pointsor thenumberof elements).Weendupwith thefollowing sys-

tem of equations at every time step

ψK˜

ΨK

1–

= ˜ K'

˜1– M

˜1– �

˜

K˜ ˜=

K'

˜1– M

˜1– �

˜

� ∆ �+

Ax B=

AA 1–

A 1– Ax A 1– B x⇒ A 1– B= =

?

Page 88: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

88 Meteorological Training Course Lecture Series

ECMWF, 2002

or with tridiagonal

Themostusedmethodfor solvingthissystemis theso-calledGausselimination,or forwardeliminationandback

substitution.The methodis implementedin mostscientificsubroutinelibrariesandcan,therefore,be usedby a

simple subroutine call. It runs as follows:

From the first equation, we extract

and substitute in the second equation

now we extract

and substitute in the third equation ... and so on

Whenwereachthelastequationandsubstitute from thelastbut one,weareleft with anequationin asingle

unknown which canthereforebesolvedandtheresultsubstitutedin theexpressionfor takenfrom thelast

but one equation, and so on until we arrive back at the expression for .

Themethodworksaslong asthematrix of thesystemis not quasi-singularandthedenominators(pivots)of the

expressionsarenot toosmall.It is, therefore,usefulto reordertheunknownssothatthepivots ,

11�

1

21�

2+ � 1=

12�

1

22�

2

32�

3+ + � 2=

23�

2

33�

3

43�

4+ + � 3=

+ 1 +,–� + 1–

+�+, � ++ � +=

Ax B= A

A

11

21 0 0 0 … 0

12

22

32 0 0 … 0

0 23

33

43 0 … 0

0 0

0 0

. . .

. . . 0 + 1 +,– +�+,

=

�1

�1

� 1

21�

2–( )11

------------------------------=

12

� 1

21�

2–( )11

------------------------------ 22�

2

32�

3+ + � 2=

�2

�2

� 2

21� 1

11-------------–

32�

3–

22

2111

-------–

---------------------------------------------------=

� + 1– � + 1–�1

11

22

21

11⁄–

Page 89: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 89

are as big as possible; this is always done in the scientific subroutines from well developed libraries.

In matrix form, the method is equivalent to decomposing the original matrix in the form

where is diagonal and

where and is the rank of matrix ( is the transpose of )

8.3 Iterative methods

Whenthematrix is notassparseasin thepreviousexampleof Gausselimination,adirectmethodof solutioncould

beintractabledueto memoryand/orCPUlimitations,largeamountsof bothresourcesbeingneededfor inverting

a large matrix. The most straightforward methods are then the iterative methods. We need to solve the system.

(95)

andstartoff with a guess for thesolution . This not beingin generalthetruesolution,we cancalculatea re-

sidual.

(96)

and use it to get a new estimate and a new residual

(97)

andsoon. If the residuals aresmalleras increases,themethodconvergesandwe stopwhenthe residual

becomes smaller than a pre-defined magnitude.

The general procedure for iterative methods can be expressed as follows

(98)

where is known asthesplitting,or preconditioning,matrixandcouldbesimply theunity matrix.Thenweadd

and subtract

A

A M K M T≡

K

M

1 0 0�1 1 0

0 �2 1

� � 1+ 1 � � 2+

0 1 � � 3+

0 1 � +1

=

, int?2---

= ? A M T M

Ax B=

�0

R0 Ax0 B–=

�1

R1

Mx1 B–=

R + ?

Ax B=

Q 1– Ax Q 1– B=

QI x

Page 90: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

90 Meteorological Training Course Lecture Series

ECMWF, 2002

(99)

(100)

we then obtain the th iterative estimate of from the th estimate by

(101)

This equation can be viewed as the discrete analogue (with unit time step) of

(102)

which has a stationary solution when the right hand side becomes zero.

The general solution of evolutionary problem(102) is

(103)

where is aneigenvalueof matrix (thediagonalelementsof thediagonalized matrix) and is

aconstantvector. Thesolutionapproachesthestationarysolution whentherealpartof is negative, that

is to say, if all theeigenvaluesof matrix haverealpositiveparts(elliptic problem).Thesolutioncanbemade

to converge quicker by multiplying the eigenvalues by a constant greater than 1 (successive over-relaxation).

Theiterationprocedure(101)is performedsuccessively over eachcomponentof vector ; if we usein theright-

handsideof (101)alwaysthecomponentsof from the th iterationthemethodis calledJacobiiteration;onthe

otherhand,if weuseon theright-handsideof thenew iterationvaluesof thecomponentsof whenever they are

available,theprocedureis calledGauss–Seideliteration,it cutsdown thestoragerequirementon a computeras

only onevalueof eachcomponentof (eitherthe th iterationor theestimate)needsto bekeptandit canbe

shown to converge quicker than the Jacobi method.

As an example, let us work out the iterative solution of the Helmholtz equation in centred finite-difference form

(104)

where is thediscreteLaplaceoperatorand and areknown. If is the th iterationfor thissolution,

we get the "residual" vector

(105)

or

(106)

and we take the th iteration of such that the new residual is zero

(107)

x Q 1– A I–( )x+ Q 1– B=

x I Q 1– A–( )x Q 1– B+=

? 1+( )� ?

x+ 1+ I Q 1– A–( )x

+Q 1– B+=

dxd�------ Q 1– Ax Q 1– B+–=

x λ �[ ] k–exp=

λ Q– 1– A Q– 1– A kx k= λ

Q 1– A

x� ? �

� ?

∇2� " � λ" �2 � " �–= " �=

∇2 λ" � = " � � " �+ ?

∇2� "<�,+

λ "<�,2 � "<�,–= "<�,–

� "<�,+

=

� " 1 �,–

+ � " 1 �,+

+ � "8� 1–,+ � "<� 1+,

+4– λ"<�,2–( )

� "8�,+ = "<�,–+ + + +

� "<�,+

=

? 1+( )� "8�,

� " 1 �,–

+ � " 1 �,+

+ � "<� 1–,+ � "<� 1+,

+4– λ"<�,2–( )

� "<�,+ 1+ = "<�,–+ + + + 0=

Page 91: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 91

(108)

This is the Jacobi iterative method.

If we proceedfor thecalculationof thenew componentsin thesenseof increasingsub-indexes and , we can

usein (106)thealreadyavailablevaluesof and insteadof the th iterationvaluesandwe getthe

Guass–Seidel procedure.

If we multiply in (108) thefractionby a factor (theover-relaxationfactor)beforeaddingit to we get the

successive overrelaxation method or SOR

(109)

It canbeshown that,in aniterativemethod,theshort-scaleerrorsof thefirst guesswith respectto thetruesolution

convergeveryquickly towardszero.Whatmakesiterativemethodsexpensivein termsof computertimeis theslow

convergenceof thelong-rangefeaturesof theinitial error. This suggeststheso-calledmultigrid methodsin order

to speeduptheconvergenceof aniterativemethodto thepointof makingit competitivewith directmethods,such

as the ones which are described later.

If wechoseasubsetof grid pointsfrom theoriginalgrid, sayoneof every four pointsandsolve theequationover

this reducedgrid, the long-scalefeaturesareseenfrom this grid asshorterscalebecausethey cover a smaller

numberof grid pointsand,therefore,theconvergenceis faster. Onceasolutionis foundonacoarsegrid, we inter-

polateit to thefiner grid andrefinethesolutionin this grid. Theprocedurecanrun over a rangeof grid sizesand

can be iterated forwards and backwards from the coarser to the finer grids.

A furtherrefinementof themethodis calledtheadaptive multigrid method.In this procedurewe definethefiner

grid onwhich thesolutionfrom thecoarsegrid hasto berefinedonly in thedomainregionswherewefind thatthe

truncation error of the completed solution exceeds a certain predefined threshold value.

8.4 Decoupling of the equations

Thefieldsto beforecastedin P.E.modelsarethreedimensionaland,therefore,thematricesof thealgebraicsystem

to whichwearrivewhenwediscretizethepartialdifferentialequationsare,in principle,six-dimensionalandthere-

fore too big to be treated directly by any direct or iterative means.

The general system of equations can be expressed as

(110)

8.4 (a) Separable case.

The simplest case would be that the matrix be factorizable, i.e.

(111)

but this case is unfortunately very rare.

� "<�,+ 1+ � "<�,

+ � "8�,+

4 λ"<�,2+------------------+=

# ,� " 1– �,+ 1+ � "<� 1–,

+ 1+ ?

µ� "<�,+

� "<�,+ 1+ � "<�,

+ � "<�,+

4 λ"<�,2+------------------

µ+=

M " ��B��� + � " ��BB∑�∑"∑� ��� +=

M " ��B��� + 4F"� G �� )!B+≡

Page 92: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

92 Meteorological Training Course Lecture Series

ECMWF, 2002

The procedure would then be as follows:

(i) Define

(112)

where

(113)

(ii) Solve

(114)

for each pair

(iii) Solve

(115)

for each pair

(iv) Finally solve

(116)

for each pair

8.4 (b) Use of the eigenvector matrix.

Let us consider the case of Poisson equation in the three dimensions

(117)

where is the horizontal Laplacian in Cartesian coordinates.

If we apply centred finite differences in the vertical we get the system of coupled equations

(118)

where is the vector of fields at the different vertical levels and matrix stands for

� "� + G �� ) B+ � " ��BB∑�∑G �� o " �+�∑= =

o " �+ )!B+ � " ��BB∑=

4F"� � "� +"∑� ��� +=

� ?,( )

G �� o " �+�∑� "� +=

� #,( )

)!B+ � " ��BB∑o " �+=

#�,,( )

∇32ϕ

=∇h

2ϕ ∂2ϕ∂ R 2---------+= =

∇h2

∇2ϕ˜

M ϕ˜

+ F=

ϕ˜

ϕ M

Page 93: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 93

of rank (the number of levels)

Let ( )be the eigenvectors of this matrix which form the columns of matrix

Then the system(118) may be written as

(119)

where and .

Matrix is adiagonalmatrixmadeof theeigenvaluesof andtherefore(119)is asystemof decoupled

bi-dimensional equations.

8.4 (c) Fourier transform in a bi-dimensional roblem.

Let

(120)

where

(direct Fourier transform)

taking into account the orthogonality relationship

(121)

for the Fourier functions, the original bidimensional system

(122)

is reduced to

(123)

which are systems of one-dimensional equations from whose solution we can then find

M

2– 1 0 …1 2– 1 0 …0 1 2– 1 0 …

. . . . . .

. . . . . .

= �

)�� , 1 …�,= E

∇2ϕ′˜

E 1– M Eϕ′˜

+ F′=

ϕ′˜

E 1– ϕ˜

= F′ E 1– F=

E 1– M E M �

� ]�� 1&------ ) " � " � # C π

&--------- and � ] +sin" 0=

%∑ 1

&------ ) � � � + � C π&------------

sin� 0=

%∑= =

) " 1 2⁄ if # 0 or # &= =

1 otherwise

=

3 � π&------------

3�C π&----------

sinsinB 0=

%∑ 1

2--- & δ]��,=

M "� + � " ��∑"∑� � +=

M �+ C( )�ˆ ]���∑

� � +=

& 1+ (p=0,… & )

Page 94: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

94 Meteorological Training Course Lecture Series

ECMWF, 2002

(inverse Fourier transform)

Thereductionof thesystemto form (123)canbeaccomplishedfor matriceswhoseeigenvectorsaretheFourier

bases,suchastheonefor a Poissonor a Helmholtzequation.Let usconsiderthePoissonequationusingcentred

second order finite differences

where

being the grid point value of the unknown at row

being the grid point value of the second number at row

The eigenvalues of are ; , and the corresponding eigenvectors

The same holds for any matrix of the form

whose eigenvalues are

This matrix appears in the finite difference discretization of a Helmholtz equation.

Calling

� " � 2 ) ] � ˆ ]�� #DC π&---------

sin] 0=

%∑=

∇2U V or BU V= =

B

A I 0 …I A I 0 …0 I A I …. . . . …

U

U1

U2

.

U (V

V1

V2

.

V (= = =

U+ ?V + ?

A

4– 1 0 . . …1 4– 1 0 . …0 1 4– 1 0 …. . . . . …

I

1 0 0 …0 1 0 …0 0 1 …. . . …

= =

A λ � 4– 2 , π &⁄( )cos+= , 1 …&,=

q � , π&------

sin2, π&---------

sin3, π&---------

sin . …=

A *

� 0 . …� � 0 …0 � � …. . . . …. . . . …

=

λ � 2� , π &⁄( )cos+=

Q q1 q2 … q %=

Page 95: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 95

we have

The original system may be written as

Multiplication by in this system gives

Theproductof by avector is thediscreteFouriertransformof thevector , namely , andthereforewe

get

and the equation for Fourier component is

which is asetof decoupledequationsfor theFouriercomponents.Thismethodis thereforeidenticalto thevertical

decouplingof sectionSubsection8.4 (b) but, whenthe eigenvectorsarethe Fourier basisfunctions,thereis the

advantage of using the Fast Fourier Transform algorithm in projecting onto the eigenvector space.

8.5 The Helmholtz equation

In many of thepresentforecastmodels,theequationof thesemi-implicit time steppingschemeleadsto a Helm-

holtz equation

(124)

where is a matrix for the vertical coordinate and its dimension is the number of levels in the model.

By themethodof verticaldecouplingof Subsection8.4 we canconvert set(124) into a setof "horizontal"equa-

tions,onefor eachlevel. Nevertheless,oneof the advantagesof usingthe spectraltechniqueon a global model

basedonthesphericalharmonicsis thatthesefunctionsareeigenfunctionsof theLaplacianoperatorsothateffec-

tively thesetof equations(124)arealreadydecoupledin thehorizontalandthecouplingis betweenthedifferent

vertical levels for each spectral coefficient of , that is

(125)

the system

(126)

QAQT diag λ �( ) Λ and QTQ≡ I= =

U B 1+ AUB U B 1–+ + V B=

Q

QUB 1+ QAQTQUB QUB 1–+ + QV B=

Q UB U UB

UB 1+ ΛUB UB 1–+ + V B=

,

5@B 1+

�λ ��5JB � 5JB 1–

�+ +

S B �=

1 Γ∇2–( )x B=

Γ

x

1 Γ∇2–( )x[ ] +� 1?7? 1+( ) 2

---------------------Γ+ x+�≡

1?s? 1+( ) 2

---------------------Γ+ x+� � +�=

Page 96: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

96 Meteorological Training Course Lecture Series

ECMWF, 2002

is, for fixed , a systemof ( = numberof vertical levels)equations,easilysolvedby simplematrix

inversion.

In thecaseof finite differencesor finite elementsin thehorizontalthingsarenot aseasyandwe have to decouple

the equations in the vertical to arrive at a set of horizontal Helmholtz equations

(127)

whose matrices are very large but sparse.

We cansolve eachsystem(127)by an iterative (expensive) method,by usetheFourier transformmethod(if we

have the appropriate boundary conditions) or by a block reduction algorithm as follows:

Let the problem be to solve equation

(128)

in two dimensions,where is ablock tridiagaonalmatrixasfoundwith centredsecondorderfinite differencesor

piecewise linear finite elements

(129)

where is a matrix (normally also tri-diagaonal) and the unit matrix corresponding to one dimension. ,

Therefore,if wehavediscretizeddimension by valuesanddimension by values, and are

matrices and has blocks.

Now multiply each even row by and add the odd rows immediately above and below giving

(130)

the fourth block equation reads

whichincludesonlyevennumbered ’s;wecanthereforewritedownasystemof equationsfor theevennumbered

's

� ?,( ) � �

1� ∇2–( )x B=

Dψ G=

D

D

E I– 0 0 …I– E I– 0 …

0 I– E I– …. . . . …

=

E I

� & � � E I & &×D � �×

E

E I– 0 0 . …

0 E2 2I– 0 I– 0 …0 I– E I– 0 …. . . . . …

ψ1

ψ2

.

ψ (

g1

g1 g3 Eg2+ +

g3

.

=

E2 2I–( )ψ4 I ψ2 ψ6+( )– g3 g5 Eg4+ +=

ψψ

Page 97: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

Meteorological Training Course Lecture Series

ECMWF, 2002 97

(131)

which is of thesameform astheoriginal systembut with thedimensionreducedandthemethodcanbeiterated

until left with a single block

(132)

is of the form

(133)

In the trigometric identity , let and we get

(134)

Now is the Chebyshev polynomial of order for which the zeros are

(135)

by analogy, is expressible as a product of linear factors

(136)

and(132) takes the form

Thematrix is factorizedand,therefore,themethodof Subsection8.3canbeappliedto obtain,for instance , and

from (131) and the same method gives

Having solvedfor theevennumberedfields,theoddnumberedonesareobtainedfrom theoriginal systemassys-

tems of equations.

REFERENCES

(a) General

Kreiss, H. andJ. Oliger, 1973:Methodsfor theapproximatesolutionof time dependentproblems.WMO/ICSU

Joint Organising Committee, GARP Publications Series No. 10, 107 pp.

E2 2I– I– 0 . …

I– E2 2I– I– . …

0 I– E2 2I– I– …. . . . …

ψ2

ψ4

.

.

g1 g3 Eg2+ +

g1 g5 Eg4+ +

.

.

=

E+( )ψ " g" +( )=

E+( )

E � 1+( ) E �( ){ }2

2I–=

2θcos 2 θcos( )2 1–= θ 2� β=

2 2� 1+ β( )cos 2 H 2β( )cos{ }2

2–=

2 2� β( )cos 2�

α � �( ) 2 π2� 1–

2� 1+-----------

,cos 1 2 …2�, ,= =

E �( )

E �( ) E 2 π2� 1–

2� 1+-----------

Icos–� 1=

2�∏=

E α1I–( ) E α2I–( )… E αI–( )ψ " g" +( )=

ψ2

ψ4 ψ6 …, ,

& &×

Page 98: Numerical methods Revised March 2001 · 6.2 The one-dimensional linear advection equation 6.3 The non-linear advection equation 6.4 The one-dimensional gravity wave equations 6.5

Numerical methods

98 Meteorological Training Course Lecture Series

ECMWF, 2002

Mesinger, F. andA. Arakawa,1976:Numericalmethodsusedin atmosphericmodels.WMO/ISCUJointOrganis-

ing Committee, GARP Publications Series No. 17, Volumes I and II, pp 64 and 499.

(b) Specific

Bates,J.R. andA. McDonald,1982:Multiply-upstream,semi-Lagrangianadvectiveschemes:analysisandappli-

cation to a multi-level primitive equation model. Mon. Wea. Rev., 10, 1831–1842.

Carpenter, K. M., 1981:Theaccuracy of Gadd'smodifiedLax–Wendroff algorithmfor advection.Quart.J.R.Met.

Soc., 107, 468–70.

Collins, W. G., 1983:An accuracy variationof the two-stepLax–Wendroff integrationof horizontaladvection.

Quart. J. R. Met. Soc., 109. 255–261.

Crowley, W.P., 1968: Numerical advection experiments. Mon. Wea. Rev., 96, 1-11

Cullen, M. J. P., 1979: The finite element method. GARP Publication Series, No. 17, Vol. II. 302–337.

Gadd,A. J.,1978:A numericaladvectionschemewith smallphasespeederrors.Quart.J.R. Met. Soc.,104,569–

582.

Leslie, L. M. and B. J. McAvaney, 1973: Comparative test of direct and iterative methodsfor solving Helm-

holtz-type equations. Mon. Wea. Rev., 101, 235–239.

Machenhauer, B., 1979: The spectral method. GARP Publication Series No. 17, Vol. II, 124–275.

Pudykiewicz, J. andA. Staniforth,1984:Somepropertiesandcomparative performanceof thesemi-Lagrangian

method of Robert in the solution of the advection-diffusion equation. Atmosphere–Ocean, 22, 283–308.

Ritchie, H., 1986:Eliminating the interpolationassociatedwith the semi-Lagrangianscheme.Mon. Wea.Rev.,

114, 135-146.

Robert,A., 1981:A stablenumericalintegrationschemefor theprimitivemeteorologicalequations.Atmosphere–

Ocean, 19, 35-46.

Robert,A., 1982:A semi-Lagrangianandsemi-implicitnumericalintegrationschemefor theprimitive meteoro-

logical equations. J. Meteor. Soc. Japan, 60, 319-325.

Strong,G. andG. J.Fix, 1973:An analysisof thefinite elementmethod.Prentice-Hall Seriesin AutomaticCom-

putation, Prentice-Hall, 306 pp.

Temperton,C., 1977:Direct methodsfor the solutionof the discretePoissonequation:somecomparisons.EC-

MWF Research Dept. Internal Report No. 13.

Vichenevetsky, R. andJ.B. Bowles,1982:Fourieranalysisof numericalapproximationsof hyperbolicequations.

SIAM, Philadelphia.


Recommended