96 void Init (
double *v,
double x,
double y,
double z)
101 static int first_call = 1;
102 double Bz0, rnd, dvy, cs, H;
107 print1 (
"! ShearingBox module has not been included.\n");
108 print1 (
"! Cannot continue.\n");
126 if (first_call == 1){
127 srand(time(NULL) +
prank);
130 rnd = (double)(rand())/((
double)RAND_MAX + 1.0);
138 dvy = sin(kx*x + 0.20) + sin(2.0*kx*x - 0.37);
139 dvy *= sin(ky*y + 0.13) + sin(2.0*ky*y + 0.04);
140 dvy *= sin(kz*z + 0.56) + sin(2.0*kz*z + 0.62);
151 #if STRATIFICATION == YES
152 v[
RHO] = exp(-z*z/(H*H));
162 v[PRS] = cs*cs*v[
RHO];
163 #elif EOS == ISOTHERMAL
164 g_isoSoundSpeed = cs;
192 v[
BX3] = Bz0*sin(kx*x);
195 v[
AX2] = -Bz0*cos(kx*x)/kx;
201 v[
BX1] = Bz0*sin(ky*y);
207 v[
AX3] = -Bz0*cos(ky*y)/ky;
220 static int first_call=1;
221 double *dx, *dy, *dz;
223 double Lx, Ly, Lz,
scrh;
224 double pm, Mxy, Rxy, tot_vol, aM, aR, dV;
245 pm = Mxy = Rxy = 0.0;
247 dV = dx[
i]*dy[
j]*dz[
k];
251 pm += 0.5*(EXPAND( d->
Vc[
BX1][k][j][i]*d->
Vc[
BX1][k][j][i],
253 + d->
Vc[
BX3][k][j][i]*d->
Vc[
BX3][k][j][i]))*dV;
274 MPI_Allreduce (&pm, &scrh, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
277 MPI_Allreduce (&Mxy, &scrh, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
280 MPI_Allreduce (&Rxy, &scrh, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
283 MPI_Barrier (MPI_COMM_WORLD);
289 static double tpos = -1.0;
292 sprintf (fname,
"%s/averages.dat",
RuntimeGet()->output_dir);
293 fp = fopen(fname,
"w");
294 fprintf (fp,
"# %4s %12s %12s %12s %12s\n",
295 "time",
" step ",
" <B^2/2> ",
" <Bx*By> ",
"<rho*ux*duy>");
300 fp = fopen(
"averages.dat",
"r");
301 while (fgets(sline, 512, fp)) {
303 sscanf(sline,
"%lf\n",&tpos);
306 fp = fopen(
"averages.dat",
"a");
309 fprintf (fp,
"%12.6e %4d %12.6e %12.6e %12.6e\n",
350 double ***rho = d->
Vc[
RHO];
352 double ***prs = d->
Vc[PRS];
355 EXPAND(
double ***vx = d->
Vc[
VX1]; ,
356 double ***vy = d->
Vc[
VX2]; ,
357 double ***vz = d->
Vc[
VX3];)
358 EXPAND(
double ***
Bx = d->
Vc[
BX1]; ,
359 double ***By = d->
Vc[
BX2]; ,
360 double ***Bz = d->
Vc[
BX3];)
362 EXPAND(
double ***Bxs = d->
Vs[
BX1s]; ,
363 double ***Bys = d->
Vs[
BX2s]; ,
364 double ***Bzs = d->
Vs[
BX3s];)
374 if (d->
Vc[
RHO][k][j][i] < 1.e-5) d->
Vc[
RHO][
k][
j][
i] = 1.e-5;
383 a = 0.5*dz[
k]*gz/cs2;
385 prs[
k][
j][
i] = prs[
KBEG][
j][
i]*(1.0 -
a)/(1.0 + a);
386 rho[
k][
j][
i] = prs[
k][
j][
i]/cs2;
387 #elif EOS == ISOTHERMAL
388 rho[
k][
j][
i] = rho[
KBEG][
j][
i]*(1.0 -
a)/(1.0 + a);
390 EXPAND(vx[k][j][i] = vx[2*
KBEG-k-1][j][i]; ,
394 EXPAND(
Bx[k][j][i] = -
Bx[2*
KBEG-k-1][j][i]; ,
413 a = 0.5*dz[
k]*gz/cs2;
415 prs[
k][
j][
i] = prs[
KEND][
j][
i]*(1.0 +
a)/(1.0 - a);
416 rho[
k][
j][
i] = prs[
k][
j][
i]/cs2;
417 #elif EOS == ISOTHERMAL
418 rho[
k][
j][
i] = rho[
KEND][
j][
i]*(1.0 +
a)/(1.0 - a);
420 EXPAND(vx[k][j][i] = vx[2*
KEND-k+1][j][i]; ,
424 EXPAND(
Bx[k][j][i] = -
Bx[2*
KEND-k+1][j][i]; ,
460 #if STRATIFICATION == YES
470 if (z > ze) g[
KDIR] += 2.0*om2*ze;
471 else if (z < zb) g[
KDIR] += 2.0*om2*zb;
489 #if STRATIFICATION == YES
490 psi = om2*(0.5*z*z -
SB_Q*x*x);
492 if (z > ze) psi -= 2.0*om2*ze*(z - ze);
493 if (z < zb) psi -= 2.0*om2*zb*(z - zb);
497 return -om2*
SB_Q*x*x;
#define X3_BEG
Boundary region at X3 beg.
double **** Vs
The main four-index data array used for face-centered staggered magnetic fields.
void UserDefBoundary(const Data *d, RBox *box, int side, Grid *grid)
double FARGO_SetVelocity(double x1, double x2)
void print1(const char *fmt,...)
int vpos
Location of the variable inside the cell.
#define BOX_LOOP(B, k, j, i)
double **** Vc
The main four-index data array used for cell-centered primitive variables.
long int g_stepNumber
Gives the current integration step number.
Runtime * RuntimeGet(void)
double g_inputParam[32]
Array containing the user-defined parameters.
#define SB_OMEGA
Disk local orbital frequency .
double g_domBeg[3]
Lower limits of the computational domain.
#define SB_Q
The shear parameter, .
#define X3_END
Boundary region at X3 end.
double g_time
The current integration time.
double BodyForcePotential(double x, double y, double z)
long int KBEG
Lower grid index of the computational domain in the the X3 direction for the local processor...
long int KEND
Upper grid index of the computational domain in the the X3 direction for the local processor...
double g_domEnd[3]
Upper limits of the computational domain.
#define QUIT_PLUTO(e_code)
void Analysis(const Data *d, Grid *grid)
void Init(double *v, double x1, double x2, double x3)
void BodyForceVector(double *v, double *g, double x, double y, double z)