COMPARISON OF FINITE DIFFERENCE- AND PSEUDOSPECTRAL ...

Report 6 Downloads 110 Views
COMPARISON OF FINITE DIFFERENCE- AND PSEUDOSPECTRAL METHODS FOR CONVECTIVE FLOW OVER A SPHERE

BENGT FORNBERG † and DAVID MERRILL ‡

Abstract. For modeling convective flows over a sphere or within a spherical shell, pseudospectral (PS) methods are in general far more cost-effective than finite difference- (or finite element) methods. This study confirms this, and proceeds by comparing a Fourier-PS implementation (based on a longitude-latitude grid) with one using spherical harmonics. For similar resolutions, both these versions are found to be of similar accuracy. However, the former is computationally about one order of magnitude faster.

Introduction. Convective flows in spherical geometries arise in many areas, such as geophysics, astrophysics, and meteorology (key references in these areas include Bunge et.al. 1995, Glatzmaier and Roberts, 1995, Trenberth, 1992 and Zhang and Yuen, 1996). A very simple but still very useful model problem is obtained by considering solid body rotation in different directions over a spherical surface. For the four methods considered here, a third (radial) direction can be added with little further difficulty, to obtain the geometry of a 3-D spherical shell or of a full sphere. Figures 1 and 2 illustrate schematically two different discretization ideas: i. ii.

longitude-latitude - type grids, and spherical harmonics (these are not immediately associated with any specific grid, but represent functions in terms of expansion coefficients).

Numerous additional discretization ideas have been attempted, e.g. grids which refine the faces of regular polyhedra [Taylor et.al., 1997] or combine overlapping stereographic coordinate systems [Browning et.al., 1989]. In the comparisons that follow, we consider four numerical methods; three based on the discretization i and one on ii: i.

FD-2 FD-4 PS-F

Second order finite differences, Fourth order finite differences, Pseudospectral (PS) approximation based on approximating derivatives by FFTs in both longitude- and latitude directions [Merilees 1973, 1974, Fornberg 1995, 1996], and ii. PS-SH PS approximation based on a spherical harmonic (SH) representation of the dependent variable [Hack and Jakob, 1992] - derivatives are calculated by analytic manipulation of the coefficients in the SH expansion. __________________________ † Department of Applied Mathematics, University of Colorado, Boulder, CO 80309-0526. E-mail: [email protected] . The research of this author was supported in part by NSF grant DMS-9706916.



76 Park Ave #5, Portland, ME 04101. E-mail: [email protected] .

The test problem is described further in Section 2. It amounts to solid-body rotation in different directions over a sphere; generalizations to general variable coefficients and inclusion of nonlinearities are straightforward for the FD-2, FD-4 and PS-F - methods, but require for PS-SH conversions between expansion coefficients and grid-based representations during each time step [Eliasen et.al. 1970, Orszag, 1970]. Section 3 gives more details about the numerical implementations, and computational results are presented in Section 4. Section 5 presents some conclusions - notably the great advantages in accuracy and cost of the PS methods over finite differences, and in cost of PS-F over PS-SH. The basic idea when using longitude-latitude grids is to simply let FD or PS stencils extend right across the poles - taking note of the fact that a pole does not represent any physical singularity (at most causing change of sign for certain vector quantities). This very simple approach has previously been found to be more accurate than the use of special "pole conditions" in 2-D polar regions; cf. comparisons on the same Bessel eigenvalue problem [Fornberg 1995, 1996 (pp 87-88)] vs. [Huang and Sloan, 1993, Matsushima and Marcus, 1995].

Test Problem. Numerous test problems have been proposed for flows over a sphere. One set [Williamson et.al. 1992 a,b] includes seven different ones, all designed to test aspects relevant to meteorology. We confine ourselves here to the first one from this set - solid-body rotation in an arbitrary direction, cf. Figure 3. Figure 4 enlarges the area where the two equatorial lines meet, and illustrates the notation used in the two spherical coordinate systems. Solid body rotation amounts to a steady increment in the ϕ -direction. Expressed in the (ϕ, θ) -system, this amounts to solving the PDE ∂h + ∂h + v ∂h = 0 u a ∂θ a cos θ ∂ ϕ ∂t where

u = u 0 (cos θ cos α − sin θ sin ϕ sin α), v = − u 0 cos ϕ sin α .

(1)

(2)

In the test runs, we make the (dimensional) choices a = 6.37122 ⋅ 10 6 m (mean radius of the earth), u 0 = 2 π a ≈ 40 m/s (making a full rotation take 12 days). 12 days As initial condition, we choose a 'cosine bell'   h(ϕ, θ) =   

h0  1 + cos πRr  2 

if r < R

0

if r ≥ R

R = a , and r = a arccos [sin θ c sin θ + cos θ c cos θ cos (ϕ − ϕ c )] (r thus 3 becoming the great circle distance between (ϕ, θ) and the center (ϕ c , θ c ) taken as (0,0)).

with

h 0 = 1000 m,

Analytical solutions to the convection problem described by (1) and (2) can readily be obtained from the transformation rules between the spherical coordinate systems shown in Figures 3 and 4:

sin θ = −sin ϕ cos θ sin α + sin θ cos α sin ϕ cos θ = sin ϕ cos θ cos α + sin θ sin α and in reverse

sin θ = sin ϕ cos θ sin α + sin θ cos α sin ϕ cos θ = sin ϕ cos θ cos α − sin θ sin α

(3)

.

(4)

Several different choices of the inclination α of the rotation axis were tested numerically. It has been noted earlier [Williamson et.al. 1992 a,b] that the choice of α = π2 − 0.05 represents a particularly critical case. We present here results only in this case (since other cases gave similar results). Convection occurs here almost straight over the poles; the small deviation from π2 eliminates possibly beneficial symmetries.

Numerical methods. The four methods are summarized briefly below: FD-2

The spatial differences are approximated with the second order accurate FD formula ∂ h ≈  − 1 h(ϕ − ∆ϕ) + ∂ϕ  2

1 2

h(ϕ + ∆ϕ)  / ∆ϕ

(5)

and similarly for θ. The (ϕ, θ) -grid differs from the schematic illustration in Figure 1 in that the horizontal grid lines are shifted by a distance of ∆θ/2 (to eliminate the need of approximating (1) at the poles, i.e. where cos θ = 0 ). A discretization parameter M denotes that we use 4 M + 1 points in the ϕ− direction and 2 M in the θ− direction: ϕ i = i ⋅ ∆ϕ θ j =  j − M − 12  ⋅ ∆θ

, i = −2M, ... , 2M , , j= 1, ... , 2M

π where ∆ϕ = ∆θ = 2M . Whenever a FD stencil were to extend outside the basic grid, values need to be fetched according to the periodicities indicated by dashed arrows in the right part of Figure 1.

To avoid severe CFL stability restrictions near the poles, increasingly many high frequency components for h in the ϕ−direction were removed as the poles were approached, so as to obtain a roughly uniform spatial resolution over the full sphere (reminiscent of this same exact property of truncated spherical harmonics expansions). Such ϕ−direction filtering was applied for the FD-2, FD-4 and PS-F methods.

FD-4 The FD-4 scheme is implemented exactly as the FD-2 scheme above with the exception that (5) is replaced by the fourth order accurate approximation - again similarly for θ: ∂ h ≈  1 h(ϕ − 2∆ϕ) − ∂ ϕ  12

2 3

h(ϕ − ∆ϕ) +

2 3

1 h(ϕ + ∆ϕ) − 12 h(ϕ + 2∆ϕ)  / ∆ϕ .

(6)

PS-F One can implement FD formulas still wider than (6). In the limit of width (and formal order of accuracy) tending to infinity, one obtains the Fourier PS method. An effective way to implement this limit method is to transform the periodic data to Fourier space (by an FFT), perform differentiation analytically on the resulting interpolating trigonometric polynomial and, with inverse FFT, obtain the derivative values at all the grid points (see [Fornberg, 1996] for theory and implementation details).

PS-SH The spherical harmonic technique is by far the most complicated of the four to implement. We refer the reader to [Fornberg, 1996] for a brief general overview of spherical harmonics. Actual implementation has described in some detail [Hack and Jakob, 1992]. In brief: Figure 2 illustrates the top of an infinite triangular array of basis functions. Whenever this array is truncated after a full row (fixed n), an expansion using these functions will possess - for arbitrary rotations over the sphere - the same remarkable property that truncated Fourier expansions possess with regard to periodic translations: only existing expansion coefficients will get modified; no higher expansion terms will ever need to be introduced. In spite of the impossibility of distributing more than 20 grid points fully uniformly over a sphere, a truncated spherical harmonics expansion achieves an entirely uniform resolution across the whole sphere. Given the coefficients of such an expansion, differentiation in both ϕ and θ can be carried out analytically by recursive manipulations of the expansion coefficients. The inclusion of variable coefficients will either lead to complicated convolutions in spherical harmonics space or, which is more effective, the expansion is converted over to grid data, variable coefficients are applied pointwise, and the result is converted again into an expansion. In general, for each time step, one conversion each way is required. The costs for these are included in the operation count estimates given below.

Results. Figure 5 displays the numerical solutions on the 'unrolled' (ϕ,θ)-grid for methods FD-2, FD-4 and PS-F. In all cases, a standard fourth order Runge-Kutta scheme was used to advance the solutions 12 days (one full revolution) in time. The time steps were sufficiently small that time errors are negligible - all errors seen are due to the spatial approximations. For both grid densities, the error in PS-F is invisible - as it is for PS-SH. The shown PS-F results can therefore also serve to illustrate the initial cosine bells. The errors in the FD methods are far higher; grid refinement to reach an accuracy to match the PS methods is prohibitive in both computer time and memory already at the error level achieved here with the PS methods. To assess the difference between PS-F and PS-SH, we need to display the errors differently. Table 1 compares the relative errors in the L2- and L∞- norms after the 12-day (one revolution) test runs:

TABLE 1 Comparison of errors after one revolution (α = π/2 - 0.05) Norm

PS-F M = 16

PS-SH T31 (n = 31)

L2 (integrated over sphere)

0.018

0.014

L∞ (max norm)

0.016

0.012

PS-F with M = 16 and PS-SH with n = 31 (in the notation of Foster et.al. 1992, Hack and Jakob 1992) correspond to approximately the same number of unknowns (and grid points for the associated PS-SH grid). The errors are essentially equivalent (PS-SH with n = 30 instead of n = 31 would be less accurate than PS-F, M = 16). The operation counts (including all floating point operations) for one calculation of the two space derivatives in (1) become approximately: 48 M + 336 M 2 + 240 M 2 log2 4M 8 + 15.6 n + 195 n2+550 n2 log2 n + 35.2 n3

PS-F: PS-SH:

(see Foster et.al. 1992)

Table 2 compares these costs for the two grid sizes considered here:

TABLE 2 Comparisons of operation counts for equivalent resolution; PS-F vs. PS-SH PS - Fourier

PS - Spherical Harmonics

Grid Resolution

Size M =

Operation Count

Size n =

Operation Count

64 × 32

16

0.455 ⋅ 106

31

3.855 ⋅106

128 × 64

32

2.065 ⋅ 106

63

22.63⋅106

Conclusions. Four numerical schemes; FD-2, FD-4, PS-F and PS-SH have been compared for a simple convective model problem in spherical geometry. The two PS methods prove to be far more accurate than the FD methods (with FD-4 notable more accurate than FD-2 at only a minor increase in cost). At the same level of discretization, PS-F and PS-SH are of comparable accuracy. However the former is not only far easier to implement - the operation count is also approximately an order of magnitude lower. Acknowledgment. The PS-SH code was implemented for NCAR and then customized for these tests by the late Prof. Ruediger Jacob-Chien. We are grateful to him for his invaluable help with this work.

REFERENCES BUNGE, H.-P. AND BAUMGARDNER, J.R., Mantle Convection Modeling on Parallel Virtual Machines, Computers in Physics, 9, 207-215, 1995.

BROWNING, G.L. ,HACK, J.J. AND SWARZTRAUBER, P.N., A Comparison of Three Numerical Methods for Solving Differential Equations on the Sphere, Monthly Weather Review, 117, 1058-1075, 1989.

ELIASEN, E., MACHENHAUER,B. AND RASMUSSEN, E., On a Numerical Method for Integration of the Hydrodynamical Equations with a Spectral Representation of the Horizontal Fields, Report No. 2, Institute of Theoretical Meteorology, University of Copenhagen, Denmark, 1970.

FORNBERG, B., A Pseudospectral Approach for Polar and Spherical Geometries, SIAM J. Sci. Comput. 16, 1071-1081, 1995.

FORNBERG, B., A Practical Guide to Pseudospectral Methods, Cambridge University Press, 1996. FOSTER, I., GOPP, W. AND STEVENS, R., Parallel Scalability of the Spectral Transform Method, in Computer Hardware, Advanced Mathematics and Model Physics, Department of Energy Report DOE/ER-0541T, 7-10, 1992.

GLATZMAIER, G.A. AND ROBERTS, P.H., A Three-dimensional Self-consistent Computer Simulation of a Geomagnetic Field Reversal, Nature, 377, 203-209, 1995.

HACK, J.J. AND JAKOB, R., Description of a Global Shallow Water Model Based on the Spectral Transform Method, NCAR Technical Note 343+STR, 1992.

MATSUSHIMA, T. AND MARCUS, P.S., A Spectral Method for Polar Coordinates, J. Comput. Phys. 120, 365-374, 1995.

MERILEES, P. E., The Pseudospectral Approximation Applied to the Shallow Water Equations on a Sphere, Atmosphere, Vol. 11, No. 1, 13-20, 1973.

MERILEES, P. E., Numerical Experiments with the Pseudospectral Method in Spherical Coordinates, Atmosphere, Vol. 12, No. 3, 77-96, 1974.

ORSZAG, S.A., Transform Method for Calculation of Vector Coupled Sums: Application to the Spectral Form of the Vorticity Equation, J. Atmosph. Sci. 27 , 890-895, 1970.

TAYLOR, M., TRIBBIA, J. AND ISKANDARANI, M.,The Spectral Element Method for the Shallow Water Equations on the Sphere, J. Comput. Phys. 130 , 92-108, 1997.

TRENBERTH, K. (ed.), Climate System Modeling, Cambridge University Press, 1992. WILLIAMSON, D.L., DRAKE, J.B., HACK, J.J., JAKOB R. AND SWARZTRAUBER, P.N., A Standard Test Set for Numerical Approximations to the Shallow Water Equations in Spherical Geometry with Example Solutions, in Computer Hardware, Advanced Mathematics and Model Physics, Department of Energy Report DOE/ER-0541T, 41-49. 1992.

WILLIAMSON, D.L., DRAKE, J.B., HACK, J.J., JAKOB R. AND SWARZTRAUBER, P.N., A Standard Test Set for Numerical Approximations to the Shallow Water Equations in Spherical Geometry, J. Comput. Phys., 102 , 211-224, 1992.

ZHANG, S. AND YUEN, D.A., Various Influences on Plumes and Dynamics in Time-Dependent, Compressible Mantle Convection in 3-D Spherical Shell, Physics of the Earth and Planetary Interiors, 94, 241-267, 1996.

Figure 1.

Longitude-latitude (ϕ, θ)− grid for a sphere. The dotted arrows indicate how the data repeats periodically.

Figure 2.

Zero contour lines for some low-order spherical harmonics.

Figure 3.

Solid body rotation over a sphere in a direction forming an angle α relative to the computational longitude-latitude grid (as measured between the equatorial lines or between the poles).

Figure 4.

An arbitrary point expressed in both the (ϕ, θ) and (ϕ , θ ) coordinate systems (corresponding to computational grid and grid associated with rotation respectively).

M = 16 (64×32 grid)

M = 32 (128×64 grid)

FD-2

FD-4

PS-F

Figure 5.

Numerical solutions after one revolution for methods FD-2, FD-4 and PS-F.