adv ection cs

Upload: mrclueless

Post on 04-Jun-2018

230 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/13/2019 Adv Ection Cs

    1/20

    University of Exeter

    ECMM713: Modelling Applications andCase Studies

    Numerical Advection Schemesin Two Dimensions

    Author:Hugo Winter

    Supervisor:Prof. John Thuburn

    April 26, 2011

  • 8/13/2019 Adv Ection Cs

    2/20

    1 INTRODUCTION

    1 Introduction

    Computational models lie at the heart of forecasting in the 21st century.The process of forecasting is much more than numerical weather predictionalone, yet without it the whole system would collapse. With these mod-els it has become possible to predict on wide ranging time-scales, from theweather outside tomorrow to the level of greenhouse gases in the atmospherein hundreds of years time. Such important applications have necessitatedthe development of more and more complicated and ingenious schemes totry and model the dynamics of the climate system. It is this developmentthat has progressed numerical weather prediction forwards which makes this

    a significant and interesting area to research.The science of fluid dynamics revolves around the idea of fluid particles

    being transported in time and space. This can occur in many types of mediafrom water to air and is known as advection. This process is very importantwhen understanding the atmosphere and as such necessary when attemptingto predict the weather (Holton 2004). Without a good understanding of theadvective processes at work it would be near impossible to give a predictionon the weather a day in advance, let alone a week in advance. Due to theincrease in computing power in recent years it has become possible to createcomplicated algorithms which model this advection process. As such, many

    different numerical advection algorithms have sprung up giving much scopefor model choice (Rood 1987). Many of these models have originated indifferent branches of science, some have come from plasma physics othersfrom oceanography, but most can be used to model the advective processesin the atmosphere.

    With such choice on offer it therefore becomes paramount to choose thecorrect algorithm for the situation. Factors such as computing cost andaccuracy needed have to be taken into account. Problems with the stabilityof certain schemes also contribute to their utility. There is little point inrunning a global climate model for several years if the results have blown

    up after a week. On the other hand, an accurate and stable scheme thattakes five days to predict the weather tomorrow is also of little use. Many ofthe so-called classical advection schemes work well on standard grids withconstant velocity of the flow, but may not be able to model more complicatedfeatures of the flow. On the other hand more complicated schemes that takeinto account these factors may simply be too expensive for all but a largesupercomputer (Staniforth and Cote 1991).

    The aim of this report is to look at the two-dimensional (2D) advectionequation. Two-dimensional fields produce interesting problems for advec-

    1

  • 8/13/2019 Adv Ection Cs

    3/20

    2 THE ADVECTION EQUATION

    tion schemes. Stability properties change compared to the one-dimensionalequation and there is the possibility of advecting at different speeds in dif-ferent directions. Certain schemes can be directly extended from the one-dimensional (1D) scheme, whereas others might require each step to be splitin two orthogonal directions (LeVeque 2002).

    2 The advection equation

    2.1 Deriving the advection equation

    In a fixed volume of fluid which does not contain any sources or sinks, therate of change of a constituent is equal to the amount transported in andout of the fixed volume (Rood 1987). This gives the constituent continuityequation

    DC

    Dt C

    t + u C

    Another important quantity is the mixing ratio. It is defined below

    C

    When the two equations above are combined, we can rewrite the continuityequation as,

    D

    Dt =

    t + u =

    t+ u

    However, now the right hand side of the continuity equation is just the masscontinuity equation for the fluid which is equal to zero so finally the advectionequation can be written

    t + u = 0For the purpose of this report we are going to work with the two-dimensionaladvection equation. If we take this case and assume the velocity of the flowin the x and y directions to be positive and constant the above equation canbe rewritten

    t +u

    x+v

    y = 0 (1)

    2

  • 8/13/2019 Adv Ection Cs

    4/20

    2.2 Taylor Series 2 THE ADVECTION EQUATION

    For this equation an analytical solution is known. Having an analytical solu-tion allows us to see how well our transport scheme is doing in comparison.If a scheme has good properties it can then be extended to more complicatedcases. To create our different schemes for solving the advection equation itis first important to define a Taylor Series.

    2.2 Taylor Series

    The Taylor series expansion provides a method with which the advectionequation can be solved computationally. The point at (i+ 1, j) can be ex-pressed as a Taylor Series

    i+1,j =i,j+ xdi,j

    dx +

    x2

    2

    d2i,j

    dx2 + O(x3) (2)

    This Taylor series has been expanded around the point (i, j) although it canbe used to expand around any point. The point at (i 1, j) can also bewritten as a Taylor Series expanded about the point (i, j)

    i1,j =i,j

    x

    di,j

    dx

    +x2

    2

    d2i,j

    dx2

    O(x3) (3)

    TheO(xn) term at the end of the expression is called the truncation errorof our finite difference approximation (Tu et al. 2008). Ideally we wouldlike the truncation error to be of as small order as possible. However, it isimportant to balance out the added accuracy with the extra complexity thatthe additional terms provide.

    Two fundamental schemes are the forward difference scheme (FTBS) andthe centred difference scheme (CTCS). Both of these schemes have benefitsand drawbacks in terms of errors and stability. These schemes are cheapin terms of computational cost, however FTBS is diffusive and CTCS is

    dispersive (discussed in section 2.3) and both produce large truncation errors.Using the Taylor expansion (2) (expanded with respect to y and talso) it ispossible to rewrite the advection equation (1) to obtain the forward differencescheme

    m+1i,j mi,jt

    = u mi+1,j mi,j

    x v

    mi,j+1 mi,j

    y + O(x, y, t)

    Which can be rearranged to give

    3

  • 8/13/2019 Adv Ection Cs

    5/20

    2.3 Errors and Stability 2 THE ADVECTION EQUATION

    m+1i,j =mi,j U(mi+1,j mi,j) V(mi,j+1 mi,j) + O(x, y, t) (4)

    Where U and Vare Courant numbers which are defined as

    U=ux

    t, V =v

    y

    t

    From the definition of the scheme in equation (4), it can be seen that thescheme has first order error. The scheme only requires the points upwind of

    (i, j) to make the step and does not require information from any previoustime steps. By taking equation (1) minus equation (2) we can then obtainthe centred difference scheme

    m+1i,j m1i,j2t

    = u mi+1,j mi1,j

    2x v

    mi,j+1 mi,j1

    2y + O(x2, y2, t2)

    Which can be rewritten as

    m+1i,j =m1i,j U(mi+1,j mi1,j) V(mi,j+1 mi,j1) + O(x2, y2, t2) (5)Where the Courant numbers are defined in the same way as above. Thisscheme has an error of the second order which is an improvement on theforward difference scheme. To obtain this extra accuracy, points either sideof (i, j) and values from the previous time step are also required. When usingan advection scheme we want the errors to be as small as possible. However,for finite difference methods the validity of the model is determined more byits stability, a process closely linked to the Courant number defined above.

    2.3 Errors and Stability

    When modelling an advective process it is important to know the type oferrors that might occur. A perfect numerical advection scheme would trans-port a fluid particle in space, returning it to exactly the same place that itstarted. However when truncating the Taylor Series errors are introducedinto the system. Roughly these errors split into two different types, dis-persion and diffusion (Rood 1987). Dispersion errors occur when a schemeintroduces small-scale waves, as different Fourier components propagate at

    4

  • 8/13/2019 Adv Ection Cs

    6/20

    3 ADVECTING IN TWO DIMENSIONS

    different phase speeds. These type of errors are most commonly seen on cen-tred difference schemes. Forward differencing suffers from diffusion errors,which are problematic when dealing with shock fronts. Any rectangular dis-tributions will be smoothed and eventually all types of distribution will bedissipated across the field. Many of the classical numerical methods (suchas the ones discussed in this report) are designed to reduce one of these twotypes of error. Modern schemes attempt to use a combination of methodswhen solutions become too dispersive or to diffusive (Van Leer 1974).

    It is also vital for a numerical advection scheme to be stable. An unstablescheme is of little use, if the solution is not bounded as time goes to infinity wecannot have confidence that it will produce accurate results for any usefullength of time. The Courant number defined earlier usually needs to bebounded to within a certain set of values for a scheme to be stable. Usingthe example of FTBS again, in one dimension it turns out that for the schemeto be stable the Courant number Uneeds to be bounded 0< U

  • 8/13/2019 Adv Ection Cs

    7/20

    3.1 Direct extension 3 ADVECTING IN TWO DIMENSIONS

    Now substituting equation (6) into equation (7) we obtain after some rear-rangement

    A= i (Usin(kx) +Vsin(ly)) [1 (Usin(kx) +Vsin(ly))]1/2

    For stability we need that|A| 1. This holds if

    |Usin(kx) +Vsin(ly)| 1 (7)At this point we shall consider the simple case of a square grid x= y= q.This permits the velocities u and v to be defined in terms of a specific flowspeed (fs)

    u= fscos(), v= fssin() (8)

    In this way equation (7) becomes

    fst

    q |cos()sin(kq) + sin()sin(lq)| 1 (9)

    For this to be satisfied for all waves in the 2D plane it serves to prove it forthe most rigorous case, when sin(kq) = sin(lq) = 1. This reduces equation(10) to

    fst

    q |cos() + sin()| 1 (10)

    We wish to look at the limiting case for which the flow is moving diagonally.This implies that =

    4and the value of|cos() + sin()|= 2. So for the

    two-dimensional case where we are on a square grid box and u and v areadvecting with the same flow speed, this implies that

    fstq 1

    2(11)

    The explanation behind this can be seen better in figure 1. With CTCS awave signal cannot propagate more than one grid interval without becomingunstable. When combined with equations (8) and (9) the conditions on Uand V are

    U 0.5, V 0.5 (12)

    6

  • 8/13/2019 Adv Ection Cs

    8/20

    3.2 Directional splitting 3 ADVECTING IN TWO DIMENSIONS

    d

    0.707d

    Figure 1: 2D wave propagation

    3.2 Directional splitting

    It is not possible to extend all numerical advection methods into two dimen-sions quite so easily. An interesting example is the Lax-Wendroff method.In one dimension the method is defined as

    m+1i =mi

    U

    2(mi+1 mi1) +

    U2

    2 (mi+1 2mi +mi1) + O(x2, t2)

    whereU is the 1D Courant numberu t

    x

    . For this case the Courant number isstable between 1 and 1. However if we just add on the additional terms forthe y-direction the scheme becomes completely unstable. The explanationfor this lies within the derivation of the Lax-Wendroff method. The startingpoint for the derivation is the Taylor series of about t

    (x , y , tt) =(x,y,t) t (x , y , t)t

    +t2

    2

    2(x,y,t)

    t2 +... (13)

    Using equation (1) each of the derivatives with respect to t can be written interms ofx and y. For notational simplicity we shall use the convention that(x,y,t)

    t can be rewrittent. As such we have that

    t = ux vy (14)tt = u2xx v2yy + 2uvxy (15)

    Substituting in the formulae for the first and second derivatives of second-order centred differences (Rood 1987)

    7

  • 8/13/2019 Adv Ection Cs

    9/20

    3.2 Directional splitting 3 ADVECTING IN TWO DIMENSIONS

    x = i+1,j i1,j

    2x (16)

    xx = i+1,j 2i,j+ i1,j

    x2 (17)

    we obtain the fully 2D Lax-Wendroff scheme

    m+1i,j = mi,j

    U

    2(mi+1,j mi1,j)

    V

    2(mi,j+1 mi,j+1)

    U2

    2 (mi+1,j 2mi,j+ mi1,j) V

    2

    2 (mi,j+1 2mi,j+ mi,j1)

    +U V

    4 (mi+1,j+1 mi1,j+1 mi+1,j1+mi1,j1)

    As can be seen from the above equation there is a cross derivative term inthe fully 2D Lax-Wendroff scheme. However, if the 1D scheme is simplyextended this term is completely omitted, hence the direct extension methodbecomes completely unstable. One method that can be used to remedy thisproblem is to use directional splitting. This method consists of breakinga finite-difference formula into a series of steps (Durran 1999). In the 2D

    problem that we have been using, it corresponds to taking the x step firstfollowed by ay step. So the fully 2D Lax-Wendroff equation can be rewritten,using differential operator notation (see appendix I), as

    (m+1i,j ) = mi,j ut2xmi,j+

    (ut)2

    2 xx

    mi,j (18)

    m+1i,j = (mi,j)

    vt2y(mi,j) +(vt)2

    2 yy(

    mi,j)

    (19)

    The main benefit of this method is that fewer computations are required

    to solve the split system, thus reducing computational cost. It also relieson the only the 1D form of Lax-Wendroff which is a scheme that is wellunderstood. The stability restrictions on the Courant number are also muchless severe than for fully 2D schemes. Here, each of the steps is boundedby the stability condition for the 1D Courant number (1 U 1). Onemajor drawback is the necessity to choose orthogonal steps for this methodto work. As such we are restricted in the types of grid that can be chosen forthe 2D problem. The choice of steps is interesting and there are two mainoptions here. Figure 2(a) shows splitting defined in equations (18) and (19).

    8

  • 8/13/2019 Adv Ection Cs

    10/20

    3.3 Fully 2D schemes 3 ADVECTING IN TWO DIMENSIONS

    (a) Splitting from equations(18) and (19)

    (b) Strang splitting

    Figure 2: Different types of directional splitting

    On the other hand, figure 2(b) shows Strang splitting which takes one stepof the previous method and then reverses it for one step. It may be intuitivethat the second method would give a more accurate solution, however thedifference is not always that great (LeVeque 2002). The splitting of theproblem could also lead to some loss of accuracy and spurious error terms ofO(t)2. It is very difficult to know in advance whether satisfactory resultswill be obtained using directional splitting (Kuzmin and Lohner 2005). Assuch we have to be careful when using this method, implying that a morerobust fully 2D scheme is required.

    3.3 Fully 2D schemes

    The methods above have aimed to take schemes and extend them usingthe 1D form of the advection equation. There are benefits to this, the 1Dadvection equation is well known and many of the methods are relativelysimple. On the other hand there will be some loss in accuracy since we are

    trying to use 1D schemes to approximate what is a fully 2D process. Assuch it would be beneficial to have a fully 2D scheme to use, which shouldbe the most accurate scheme that we can create. In the previous sectionwe defined the 2D Lax-Wendroff scheme to illustrate the cross-derivativeterm that appears. Implementing this directly should hopefully give themost accurate representation and reduce the errors to their minimum. Thestability condition for the fully 2D method is defined as

    U2/3 +V2/3 1 (20)

    9

  • 8/13/2019 Adv Ection Cs

    11/20

    4 SIMULATION STUDY

    This condition is very restrictive, much more so than that for CTCS and thedirectional split Lax-Wendroff method. It is possible to improve the stabilityif a different approximation to the mixed spatial derivative term in the fully2D Lax-Wendroff scheme is used. If u 0 and v 0 we must replace thecross-derivative term (Durran 1999)

    U Vt2x2ymi,j (21)

    with the term

    U Vtxymi1

    2,j1

    2

    (22)

    The change in the term means that the fully 2D Lax-Wendroff scheme isstable for 0 U 1 and 0 V 1. This adaptation makes the schememore flexible and as such is the best scheme to illustrate the fully 2D Lax-Wendroff scheme during my simulation study.

    4 Simulation study

    Each of the methods which have been set out so far have their strengths andweaknesses. To test which of these methods is better I have set up a sim-ulation study, which has been undertaken using the mathematical programMatlab. Three schemes shall be under scrutiny in this section, CTCS, Lax-Wendroff with directional splitting and the fully 2D Lax-Wendroff scheme.For the directional split I have used the methodology outlined in equations(18) and (19) since there is no difference between the results obtained by thismethod and the Strang splitting. Intuition suggests that both Lax-Wendroffschemes should be superior to CTCS, with the added robustness of the 2DLax-Wendroff scheme making it the best for all situations.

    The study will consist of different initial conditions being set up on a boxof size 0 x 1, 0 y 1. Within this box it is possible to set up a gridmesh, for the purpose of this study I shall keep to a square grid mesh. Eachscheme will then be used to transport the initial condition around the boxand back to the original place that it started from. At this point it is possibleto quantify the error in terms of the deviation from the initial condition. Aperfect scheme would bring the initial condition back around to the sameplace after any number of revolutions. The 2-norm and infinity norm are twoways to quantify the error and are defined as

    10

  • 8/13/2019 Adv Ection Cs

    12/20

    4 SIMULATION STUDY

    2 =

    1

    NNi=1

    Nj=1| numi,j exi,j |2

    1/2(23)

    = Maxi,j| numi,j exi,j | (24)where numi,j is the numerical solution and

    exi,j is the exact solution. The

    2-norm takes into account the errors from all over the plane whereas theinfinity norm is only concerned with the one point where the largest erroroccurred. To build an accurate picture of the accuracy of each method itis important to provide both types of error. One scheme may create large

    errors on the wave being advected but small errors across the rest of the planewhich leads to a small 2-norm, however this scheme may not necessarily beany better.

    The simulation will also take into account two different types of initialcondition. A curved wave such as that created by a Gaussian distribution willbe the first type tested and it would be expected that the errors for this initialcondition would be relatively small. There are no sudden changes from onegrid point to another which can strongly affect the error. Secondly advectinga square wave will test how well each of the schemes deal with shock fronts.These type of waves can be the most difficult schemes to advect accurately,

    especially for even order schemes such as the ones being tested since they aredispersive.

    It is important to note that during this study the flow will be advectingwith a constant velocity in both directions. All the equations that have beenderived up until this point are done so with this assumption in mind. Thegrid mesh will also be set to a 100x100 grid so that the Courant number canonly be varied by increasing or decreasing the flow velocity or time step.

    Table 1: Error results for Gaussian wave U=V = 0.5

    2 Error ErrorCTCS 0.0038 0.0214DSLW 0.0042 0.02742DLW 0.0054 0.0343

    The error results for the Gaussian wave are very interesting since theyseem to suggest that the CTCS scheme is best when it comes to reducing theerror. CTCS is a dispersive scheme with no diffusion, but the diffusive natureof the wave being advected helps to reduce the error. The error results for the

    11

  • 8/13/2019 Adv Ection Cs

    13/20

    4 SIMULATION STUDY

    x

    y

    0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

    0.1

    0.2

    0.3

    0.4

    0.5

    0.6

    0.7

    0.8

    0.9

    1

    0.5

    0

    0.5

    1

    1.5

    (a) CTCS

    x

    y

    0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

    0.1

    0.2

    0.3

    0.4

    0.5

    0.6

    0.7

    0.8

    0.9

    1

    0.2

    0

    0.2

    0.4

    0.6

    0.8

    1

    1.2

    (b) Directional split Lax-Wendroff

    x

    y

    0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

    0.1

    0.2

    0.3

    0.4

    0.5

    0.6

    0.7

    0.8

    0.9

    1

    0.2

    0

    0.2

    0.4

    0.6

    0.8

    1

    1.2

    (c) Fully 2D Lax-Wendroff

    x

    y

    0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

    0.1

    0.2

    0.3

    0.4

    0.5

    0.6

    0.7

    0.8

    0.9

    1

    0

    0.1

    0.2

    0.3

    0.4

    0.5

    0.6

    0.7

    0.8

    0.9

    1

    (d) True Solution

    Figure 3: Square wave advected once around plane U=V = 0.5

    Lax-Wendroff schemes are close to that of CTCS, but introduce slightly moreerror. The directional split Lax-Wendroff scheme also appears to be reducingthe error better than the fully 2D Lax-Wendroff. This is a surprising resultsince it would be expected that a fully 2D scheme would work better whenadvecting in two dimensions.

    The results obtained in table 2 and figure 3 show what occurs for a square

    wave. The wave has again been advected once around the plane and withCourant numbers U = V = 0.5. The dispersive CTCS scheme creates largeerrors when transporting a square wave since the scheme is quickly domi-nated by shortwaves.The diffusion of the Lax-Wendroff method controls thisdispersive effect. For this reason the Lax-Wendroff method is far superiorto the CTCS for carrying the square wave. It is again significant that thedirectional split Lax-Wendroff method produces less error than the fully 2DLax-Wendroff. This pattern suggests that the tests being performed withconstant flow velocities do not create any spurious errors in the directional

    12

  • 8/13/2019 Adv Ection Cs

    14/20

    4 SIMULATION STUDY

    0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

    0.02

    0.04

    0.06

    0.08

    0.1

    0.12

    0.14

    0.16

    0.18

    0.2

    Courant Number

    2Error

    CTCS

    TSLW

    2DLW

    (a) 2-error

    0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

    0.5

    1

    1.5

    Courant Number

    IninityError

    CTCS

    TSLW

    2DLW

    (b)

    -error

    Figure 4: How errors vary with courant number

    split method. In 3(a), peaks and troughs between0.5 and 0.5 in the fieldaway from the initial condition (figure 3(d)) show that CTCS is a more dis-persive scheme. This result compares to peaks and troughs of just between

    0.2 and 0.2 for the Lax-Wendroff methods. Figures 3(b) and 3(c) suggestthat the square wave is being advected in a similar manner by both Lax-Wendroff schemes, but it is the rest of the field that is having an effect on

    the error values. The fully 2D scheme seems to produce more and slightlystronger dispersive waves in its wake, whereas the dispersion created by thedirectional split Lax-Wendroff is weaker.

    So far we have set the Courant number to a certain rate and lookedat how the different schemes perform. A situation may occur where forcertain Courant numbers, different schemes may be better. As such figure4 looks at how the error varies with different Courant numbers. For thisgraph the square wave from figure 3 was chosen with U = V. The graphsshow that the directional split Lax-Wendroff method reduces the error for allCourant numbers compared to its fully two dimensional counterpart. The

    -

    error of the CTCS is smaller for certain Courant numbers than the fully 2DLax-Wendroff scheme. Physically, the change in Courant number representsthe size of the time-step being taken (when the grid spacing and velocitieshave been fixed). The reduction in time step improves the CTCS greatlysince it requires three-time levels. Conversely, as the time-step is increased,the undamped computational mode of CTCS generates instability (time-splitting). Figure 4 shows that stability becomes a problem when U and Vare greater that 0.5 (equation (12)).

    13

  • 8/13/2019 Adv Ection Cs

    15/20

    5 CONCLUSION

    Table 2: Error results for square wave U=V = 0.5

    2 Error ErrorCTCS 0.1977 1.3888DSLW 0.1073 0.79112DLW 0.1170 0.8050

    5 Conclusion

    The aim of this project was to take the well known one-dimensional advection

    equation and extend it into two-dimensions. By comparing three differentsecond order schemes, the different processes behind model extension havebeen discussed. Schemes such as CTCS can be extended straight from their1D counterparts and remain stable, although under restricted stability con-ditions. The Lax-Wendroff scheme on the other hand is an example of ascheme that becomes totally unstable if the 1D case is simply extended. Toovercome this it is either necessary to split directionally or derive a fully two-dimensional scheme. These schemes have the benefit of less strict stabilityconditions which make them more useful.

    To test the theory, Matlab was used to construct simulations of an ad-

    vecting fluid. Analysis of the errors produced by each of the different schemesallows the accuracy of each of them to be quantified. For a Gaussian wave itturned out that CTCS was a very good scheme to use which performed bet-ter than both of the Lax-Wendroff methods. On the other hand, for squarewaves the small amount of dissipation added by the Lax-Wendroff schememade it a better scheme to use. One interesting result was the fact thatthe directional split scheme worked better than the fully two-dimensionalscheme. An extension to this study would be to see if this holds for non-constant advecting velocities. I would expect that the fully 2D scheme wouldbe better when advecting with these non-constant velocities or maybe with

    different grid shapes.The application of advection schemes within numerical weather prediction

    continues to be very important to modern weather forecasting. If one thinghas become apparent over this project is that there is such a large amountof schemes available for the user. The schemes that I have studied here maynot be the ones that are being used for modern applications, but they arestill important. They highlight where numerical weather prediction has comefrom and the rapid growth suggests that it can improve many years into thefuture.

    14

  • 8/13/2019 Adv Ection Cs

    16/20

    REFERENCES REFERENCES

    Appendix I

    Finite-difference operator notation is used to write formulae in compact form.Necessary combinations ofx and y directions can be made from the following(Durran 1999)

    2xmi,j =

    mi+1,j mi1,j2x

    2xmi,j =

    mi+1,j 2mi,j mi1,j(x)2

    References

    [1] Durran, D.R., Numerical Methods for Wave Equations in GeophysicalFluid Dynamics, Springer, 1999.

    [2] Holton, J.R.,An introduction to dynamic meteorology, 4th ed., Elsevier,2004.

    [3] Kuzmin, D., Lohner, R.,Flux-corrected transport: principles, algorithms,and applications, Springer, 2005.

    [4] LeVeque, R.J., Finite volume methods for hyperbolic problems, Cam-bridge, 2002.

    [5] Rood, R.B., 1987, Numerical Advection Algorithms and Their Role inAtmospheric Transport and Chemistry Models, Review of Geophysics,25, 71-100.

    [6] Staniforth, A. and Cote, J., 1991, Semi-Lagrangian Integration Schemesfor Atmospheric Models - A Review, Monthly Weather Review,119, 2206-2223.

    [7] Tu, J., Yeoh, G.H. and Liu., C.,Computational Fluid Dynamics: A Prac-tical Approach, Butterworth-Heinemann, 2008.

    [8] Van Leer, B., 1974, Towards the Ultimate Conservative DifferenceScheme. II. Monotonicity and Conservation Combined in a Second-OrderScheme, Journal of Computational Physics, 14, 361-370.

    15

  • 8/13/2019 Adv Ection Cs

    17/20

    REFERENCES REFERENCES

    Appendix II

    Matlab code used for simulation study in section 4.

    % Domain size (periodic)

    l = 1.0;

    % Number of grid points in domain

    n = 100;

    % Grid

    dx = l/n;

    dy = 1/n;

    [x,y] = meshgrid(linspace(dx,l,n),linspace(dy,l,n));% Advecting velocity

    u = 1.0;

    v = 1.0;

    % Time step

    dt = input(Timestep > );

    % Courant number

    cu = u*dt/dx

    cv = v*dt/dy

    % Number of steps to take in order to go

    % once aroundnstop = ceil(n/cu);

    for k = 1:n

    for j = 1:n

    xx = x(k,j);

    yy = y(k,j);

    % Gaussian wave initial condition

    f(k,j) = (1/(2*pi*0.4*0.4))*exp(-(1/2)*

    (((xx-0.5)^2)/(0.1)^2 +((yy-0.5)^2)/(0.1)^2));

    % Square wave initial condition

    if (xx+yy >= 0.4 & xx+yy < 0.8 &

    yy >= xx-0.3 & yy < 0.3+xx)

    f(k,j) = 1.0;

    else

    f(k,j) = 0.0;

    16

  • 8/13/2019 Adv Ection Cs

    18/20

    REFERENCES REFERENCES

    end

    end

    end

    h = f ;

    contourf(x,y,f)

    scheme = input( 1. CTCS \n 2. Lax-Wendroff \n 3. Lax-Wendroff

    with time splitting \n 4. Alternate split LW \n

    5. Fully 2D LW \n Which scheme? );

    % Is user ready?hh

    ready = input( Ready ? );

    % Set up arrays of indices k, k-1 and k+1,

    % but allowing for wrap-around (periodic domain)

    k = 1:n;

    k m = k - 1 ;

    km(1) = n;

    k p = k + 1 ;

    kp(n) = 1;

    p = 1:n;

    p m = p - 1 ;

    pm(1) = n;

    p p = p + 1 ;

    pp(n) = 1;

    % One step needed if using CTCS

    if scheme == 1

    d(k,p) = f(k,p);

    end

    % Loop over time steps

    for istep = 1:nstop

    % CTCS

    if scheme == 1

    g(k,p) = d(k,p) - cu * (f(kp,p) - f(km,p))

    - cv * (f(k,pp) - f(k,pm));

    d(k,p) = f(k,p);

    f(k,p) = g(k,p);

    17

  • 8/13/2019 Adv Ection Cs

    19/20

    REFERENCES REFERENCES

    end

    % Lax-Wendroff scheme

    if scheme == 2

    f(k,p) = f(k,p) - (cu/2)*(f(kp,p) - f(km,p)) +

    ((cu^2)/2)*(f(kp,p)-(2*f(k,p))+f(km,p))

    -(cv/2)*(f(k,pp) - f(k,pm)) +

    ((cv^2)/2)*(f(k,pp)-2*f(k,p)+f(k,pm));

    end

    % Splitting for Lax-Wendroff

    if scheme == 3

    f(k,p) = f(k,p) - (cu/2)*(f(kp,p) - f(km,p)) +

    ((cu^2)/2)*(f(kp,p)-2*f(k,p)+f(km,p));

    f(k,p) = f(k,p) - (cv/2)*(f(k,pp) - f(k,pm)) +

    ((cv^2)/2)*(f(k,pp)-2*f(k,p)+f(k,pm));

    end

    % Strang split

    if scheme == 4

    if mod(istep,2)==0

    f(k,p) = f(k,p) - (cu/2)*(f(kp,p) - f(km,p)) +

    ((cu^2)/2)*(f(kp,p)-2*f(k,p)+f(km,p));

    f(k,p) = f(k,p) - (cv/2)*(f(k,pp) - f(k,pm)) +

    ((cv^2)/2)*(f(k,pp)-2*f(k,p)+f(k,pm));

    else

    f(k,p) = f(k,p) - (cv/2)*(f(k,pp) - f(k,pm)) +

    ((cv^2)/2)*(f(k,pp)-2*f(k,p)+f(k,pm));

    f(k,p) = f(k,p) - (cu/2)*(f(kp,p) - f(km,p)) +

    ((cu^2)/2)*(f(kp,p)-2*f(k,p)+f(km,p));

    end

    end

    % Fully 2D LW

    if scheme == 5

    fiplusm(k,p) = (1/2)*(f(k,p)+f(kp,p)) -

    (1/2)*cu*(f(kp,p)-f(k,p));

    fjplusm(k,p) = (1/2)*(f(k,p)+f(k,pp)) -

    18

  • 8/13/2019 Adv Ection Cs

    20/20

    REFERENCES REFERENCES

    (1/2)*cv*(f(k,pp)-f(k,p));

    fiminusm(k,p) = (1/2)*(f(km,p)+f(k,p)) -

    (1/2)*cu*(f(k,p)-f(km,p));

    fjminusm(k,p) = (1/2)*(f(k,pm)+f(k,p)) -

    (1/2)*cv*(f(k,p)-f(k,pm));

    f(k,p) = f(k,p) - cu*(fiplusm(k,p)-fiminusm(k,p)) -

    cv*(fjplusm(k,p)-fjminusm(k,p)) +

    cu*cv*(f(k,p)-f(k,pm)-f(km,p)+f(km,pm));

    end

    % Plot f at this timestep

    contourf(x,y,f)

    pause(0.1)

    end

    err = abs(f - h);

    rss = sum(sum(err.^2));

    rss3 = sum(sum(err.^3));

    error2 = (rss/(n^2))^(1/2);

    error3 = (rss3/(n^2))^(1/3);

    errorinf = max(max(err));

    errorstuff = [error2;error3;errorinf]

    contourf(x,y,f);

    xlabel(x)

    ylabel(y)

    19