Docsity

MEA712 Assignment 2: Setting up the Grid and Initial Condition for Mesoscale Modeling - Pr, Assignments of Earth Sciences

Toggle sidebar
bg1
MEA712: Mesoscale Modeling
Class mesoscale model (CMM) project, assignment 2
Due at start of class on Tuesday, 17 October.
In–class supervised work period on Tuesday, 10 October.
1. Model task: read chapter 11, complete model task 3, and turn in plots similar to Fovell’s p. 121. I have
provided subroutines to interface the code with GrADS. You can get them on unity from:
/afs/eos.ncsu.edu/courses/mea/mea712/common/examples
If you want to use something else, feel free.
2. Model task: following the guidelines presented in class, convert your code into a modular style that is
ready for the implementation of our model equations during the next task. In other words, upgrade your
code so that all variables are declared in one place, you can set important parameters in one place, different
kinds of operations are handled by individual subroutines, etc.
1
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download MEA712 Assignment 2: Setting up the Grid and Initial Condition for Mesoscale Modeling - Pr and more Assignments Earth Sciences in PDF only on Docsity!

MEA712: Mesoscale Modeling Class mesoscale model (CMM) project, assignment 2

Due at start of class on Tuesday, 17 October. In–class supervised work period on Tuesday, 10 October.

  1. Model task: read chapter 11, complete model task 3, and turn in plots similar to Fovell’s p. 121. I have provided subroutines to interface the code with GrADS. You can get them on unity from:

/afs/eos.ncsu.edu/courses/mea/mea712/common/examples If you want to use something else, feel free.

  1. Model task: following the guidelines presented in class, convert your code into a modular style that is ready for the implementation of our model equations during the next task. In other words, upgrade your

code so that all variables are declared in one place, you can set important parameters in one place, different kinds of operations are handled by individual subroutines, etc.

Chapter 11

Model Task #3: Grid setup and

initial condition

In this task, we set up the model’s two-dimensional (2D) grid and specify the initial

condition. Figure 1 shows the grid setup. Remember, in each grid box the velocity

components are defined on the outer edges and the scalar variables reside at the center.

The physical domain is completely surrounded by a set of artificial grid boxes; this

just makes coding the model a little easier. There are a total of N X points in the x

direction (index i) and N Z points in the z direction (index k).

In the horizontal direction, the physical boundaries are u points and are located

at i-index locations 2 and N X for Fortran (Fig. 1) or 1 and N X-1 for C++ (Fig.

2). In the vertical, the physical boundaries coincide with w points at index locations

2 and N Z in Fortran or 1 and N Z-1 in C++. We will force w to be zero at these

points, this corresponding to rigid, free-slip (frictionless) boundaries. For this task,

we’ll take the domain to be laterally periodic, though we will likely want to reconsider

this later.

First, we need to set up the required arrays. We will eventually be using the

leapfrog scheme, a three time level method. Thus, for each prognostic variable — u,

w, θ′^ and π′^ — we need to carry three arrays, corresponding to the past, present and

future values. For the u variable, for example, these will be called U M , U and U P ,

respectively. There is a more storage-efficient way of handling this, but that is not

our present concern.

So, we have something like this for Fortran

physical boundaries

0 0

1 1

2 2

3 nx-2 nx- nx-

nx- i -index nx-3 nx-

0

1

2

0

1

3

2

nz-

nz-

nz-

nz-

nz-

k -index

u u

w

w

θ

2D domain configuration

(C++ model)

nz-

Figure 11.2: Model grid arrangement for C++.

c set parameters c grid dimensions parameter(nx=27,nz=27) c grid box lengths parameter(dx=1000.,dz=700.) c variable arrays dimension thp(nx,nz),th(nx,nz),thm(nx,nz) dimension wp(nx,nz),w(nx,nz),wm(nx,nz) dimension up(nx,nz),u(nx,nz),um(nx,nz) dimension pip(nx,nz),pi(nx,nz),pim(nx,nz) c base state vectors dimension tb(nz),qb(nz),pb(nz),pib(nz),rhou(nz),rhow(nz)

or for C++

// grid dimensions const int nx = 29; const int nz = 29;

// grid box lengths const double dx = 1000.; const double dz = 700.;

// base state arrays double tb[nz], qb[nz], pb[nz], pib[nz], rhou[nz], rhow[nz];

// prognostic arrays double thp[nx][nz], th[nx][nz], thm[nx][nz]; double up[nx][nz], u[nx][nz], um[nx][nz]; double wp[nx][nz], w[nx][nz], wm[nx][nz]; double pip[nx][nz], pi[nx][nz], pim[nx][nz];

To simplify things, we’ll consider a dry and neutral environment, so set T B to

300 at every vertical point and set QB to zero.

Second, make sure the base state arrays are handled correctly at the artificial

points above and below the physical grid. Since w = 0 at the physical boundaries,

there can be no transport through the boundary. Thus, we can specify the temper-

ature and pressure at these artificial points to be anything we want; it won’t make

a difference. For reasons better appreciated later, it is best to take the mean state

fields to possess no gradient across the boundaries. We’ve already set up T B and

P IB (for example) for the real scalar points (k = 2,N Z-1 in Fortran or k = 1,N Z-

in C++). Now we need to do:

TB(1)=TB(2)

The leapfrog scheme, having three time levels, has to be started off not only with

the present time value at each grid point, but also with the past time value (time level

n-1). We don’t have this information, so we typically assign the same perturbation

to T HM (i, k). This actually causes some problems; we’ll see this later.

Once the initial thermal perturbation is in place, we need to construct a per-

turbation pressure field in balance with it. If we do not, large amplitude, ferocious

acoustic waves will be excited immediately. (Try this later and see.) The perturba-

tion hydrostatic equation may be written in continuous and discrete representations

as:

∂π′ ∂z

g cpd

θ′ θ^ ¯^2 (11.3)

and

TUP = TH(i,k )/(TB(k )2) TDN = TH(i,k-1)/(TB(k-1)2) PI(i,k) = PI(i,k-1)-0.5(G/CPD)(TUP+TDN)*DZ

or

tup = th[i][k+1]/(TB[k+1]TB[k+1]); tdn = th[i][ k ]/(TB[ k ]TB[ k ]); pi[i][k] = pi[i][k+1]-0.5(g/cpd)(tup+tdn)*dz;

In C++, remember to decare “tup” and “tdn” as doubles.

We have to assume a value (such as zero) for π′^ somewhere. It is easiest to choose

this to be at the topmost π′^ point (P I(i, nz − 1)), so actually we need to integrate

(11.3) downward. Thus, the above code has to be rearranged. We can do that in this

fashion:

DO i = 2,nx- c set the assumed point PI(i,nz-1) = 0. c integrate perturbation hydrostatic equation downward DO k = nz-2, 2, - TUP = TH(i,k+1)/(TB(k+1)2) TDN = TH(i,k )/(TB(k )2) PI(i,k) = PI(i,k+1)-0.5(G/CPD)(TUP+TDN)*DZ c finesse the first PIM value PIM(i,k) = PI(i,k) ENDDO

c get the artificial point below the grid PI(i,1)=PI(i,2) PIM(i,1)=PIM(i,2) ENDDO

for(i = 1; i <= nx2; i++){ pi[i][nz1] = 0.; for(k = nz2; k >= 1; k--){ tup = th[i][k+1]/(TB[k+1]TB[k+1]); tdn = th[i][ k ]/(TB[ k ]TB[ k ]); pi[i][k] = pi[i][k+1]-0.5(g/cp)(tup+tdn)*dz; pim[i][k] = pi[i][k]; } // end of for k pi[i][0] = pi[i][1]; pim[i][0] = pim[i][1]; }

In the above, I am using nz1 and nz2 to represent nz-1 and nz-2, respectively.

Of course, those constants have to be declared somewhere in the code.

You may wish to plot dimensional pressure perturbation p′^ instead. Recall from

Chap. 3 that π′^ and p′^ are related by:

p′^ = π′cpd ρ¯θ¯v.

This can be coded as:

PPRT(i,k) = PI(i,k)CPDRHOU(k)TB(k)(1.+0.61*QB(k))

in Fortran. Of course, for now we’re neglecting moisture. However, just in case you

want to add moisture later, you might as well be prepared for it.

Finally, plot the initial θ′^ and π′^ (or p′) fields. I will be giving you a subprogram

that creates output files which, after postprocessing, can be viewed using the VMO

(View Model Output) visualization program. VMO is based on NCAR graphics but

is interactive. Here are initial fields for θ′^ and p′. Contour intervals are 0.1 K and 6

Pa, respectively.