17.11.2012 Views

Numerical recipes

Numerical recipes

Numerical recipes

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

844 Chapter 19. Partial Differential Equations<br />

Figure 19.1.6. Origin of mesh-drift instabilities in a staggered leapfrog scheme. If the mesh points<br />

are imagined to lie in the squares of a chess board, then white squares couple to themselves, black to<br />

themselves, but there is no coupling between white and black. The fix is to introduce a small diffusive<br />

mesh-coupling piece.<br />

in Figure 19.1.6. This mesh drifting instability is cured by coupling the two meshes<br />

through a numerical viscosity term, e.g., adding to the right side of (19.1.31) a small<br />

. For more on stabilizing difference<br />

coefficient (≪ 1) times un j+1 − 2unj + unj−1 schemes by adding numerical dissipation, see, e.g., [4].<br />

The Two-Step Lax-Wendroff scheme is a second-order in time method that<br />

avoids large numerical dissipation and mesh drifting. One defines intermediate<br />

values uj+1/2 at the half timesteps tn+1/2 and the half mesh points xj+1/2. These<br />

are calculated by the Lax scheme:<br />

u n+1/2<br />

j+1/2<br />

= 1<br />

2 (un j+1 + u n j ) − ∆t<br />

2∆x (F n j+1 − F n j ) (19.1.37)<br />

Using these variables, one calculates the fluxes F n+1/2<br />

j+1/2 . Then the updated values<br />

u n+1<br />

j are calculated by the properly centered expression<br />

u n+1<br />

j<br />

= un j<br />

∆t<br />

�<br />

− F<br />

∆x<br />

n+1/2<br />

j+1/2<br />

�<br />

n+1/2<br />

− Fj−1/2 (19.1.38)<br />

The provisional values u n+1/2<br />

j+1/2 are now discarded. (See Figure 19.1.7.)<br />

Let us investigate the stability of this method for our model advective equation,<br />

where F = vu. Substitute (19.1.37) in (19.1.38) to get<br />

u n+1<br />

j<br />

= un j<br />

�<br />

1<br />

− α<br />

2 (unj+1 + un 1<br />

j ) −<br />

2 α(unj+1 − unj )<br />

− 1<br />

2 (un j + u n j−1)+ 1<br />

2 α(unj − u n j−1)<br />

� (19.1.39)<br />

Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5)<br />

Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by <strong>Numerical</strong> Recipes Software.<br />

Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copying of machinereadable<br />

files (including this one) to any server computer, is strictly prohibited. To order <strong>Numerical</strong> Recipes books or CDROMs, visit website<br />

http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!