Details on the initial conditions
- Theta: for
the 'official' problem, use usual bubble formula but set
the Y radius to some very large number. So: your
thermal perturbations on each side are north-south lines
centered along & parallel to the X
boundaries. Because of periodic Y boundary
conditions, this thermal line effectively continues
indefinitely in +/-Y.
- V-wind: you
set a perturbation value in the same bubble code as theta.
Your sinking cold sources on the left and/or right X
boundaries carry the imposed V perturbations into the
lower levels of the model. And yes, the grid
location for v is different from theta, but don't
worry about that here -- use the same code you do for
theta perturbations to also set V perturbations.
My (Fortran) code looks like the following:
t1
=
300.0
(everywhere)
v1 = 0.0
(everywhere)
Triply-nested do-loop: do k,
do j, do i; also
loop over up to two thermal perturbations m=1,2 --
as in program 6 ...
Compute staggered grid
coordinates the usual way for x,y,z
xdiff = (x-x0)
ydiff
= (y-y0)
zdiff = (z-z0)
radius
= sqrt( (xdiff/xradius(m))**2 +
(ydiff/yradius(m))**2 + (zdiff/zradius)**2 )
if (radius.lt.1.0) then
t1(i,j,k)
=
t1(i,j,k)
+
tpertur(m)*0.5*(cos(pi*radius)+1.0)
(tpertur is theta perturbation)
v1(i,j,k) = v1(i,j,k)
vpertur(m)*0.5*(cos(pi*radius)+1.0) (vpertur is V perturbation)(ignore
staggering!)
endif
End of loops for i,j,k, and m
v2=v1
- U-wind:
u1 = u2 = a random number. Please use the
default
Intel fortran/C random number generator;
- In fortran my code looks like the following.
real ranval,upertur,rand
call
srand(0.0)
(srand
initializes the random number generator)
Triply-nestd
do-loop: do k, do j, do i=1,nx+1
ranval =
rand(0)
(rand() is the
Intel Fortran/C random number generator,
returning number from 0-1)
u1(i,j,k)
=
(ranval-0.5)*upertur
(upertur=25.0
here, so perturbations are up to +/- 12.5 m/s)
Enddo for i,
enddo for j, enddo for k
u2 = u1
- The C language standard
library supports srand() and rand(), though
rand() behavior is different in C than
Fortran. You can probably get away with using
the following for numbers between (-upertur/2.) and
(+upertur/2.0); note RAND_MAX is defined in
stdlib.h:
#include <stdlib.h>
main()
...
float
upertur;
...
srand(0.0);
/* only do this once; suggest using same "seed"
(e.g. 0.0) each time, for reproducibility */
Triply-nested for-loop: for k, for j, for i; also loop over up to two
thermal perturbations m=1,2 -- as in program 6
...
Compute staggered grid
coordinates the usual way for x,y,z
u1[i][j][k] = upertur * ( rand() / (RAND_MAX +
1.0) ) - upertur/2.0;
End of loops for i,j,k, and m
[Set u2=u1]
- ... and, some added references and warnings
regarding use of rand() in C include: here
|