PLUTO
init.c File Reference

MHD Rotor test problem. More...

#include "pluto.h"
Include dependency graph for init.c:

Go to the source code of this file.

Functions

void Init (double *v, double x1, double x2, double x3)
 
void Analysis (const Data *d, Grid *grid)
 
void BackgroundField (double x1, double x2, double x3, double *B0)
 
void UserDefBoundary (const Data *d, RBox *box, int side, Grid *grid)
 

Detailed Description

MHD Rotor test problem.

The rotor problem consists of a rapidly spinning cylinder embedded in a static background medium with uniform density and pressure and a constant magnetic field along the x direction $B_x = 5/\sqrt{4\pi}$. The cylinder rotates uniformly with constant angular velocity $ \omega $ and has larger density:

\[ (\rho, v_\phi) = \left\{\begin{array}{ll} (10, \omega r) & \qquad {\rm for}\quad r < r_0 \\ \noalign{\medskip} (1+9f,f\omega r_0) & \qquad {\rm for}\quad r_0 \le r \le r_1 \\ \noalign{\medskip} (1,0) & \qquad {\rm otherwise} \end{array}\right. \]

Here $ r_0=0.1$ and $ = (r_1-r)/(r_1-r_0)$ is a taper function. The ideal equation of state with $\Gamma = 1.4$ is used. As the disk rotates, strong torsional Alfven waves form and propagate outward carrying angular momentum from the disk to the ambient.

A list of tested configurations is given in the following table:

Conf.GEOMETRYdivB BCK_FIELDAMR
#01 CARTESIANCT NO NO
#02 POLAR CT NO NO
#03 POLAR 8W NO NO
#04 POLAR CT YES NO
#05 POLAR GLM NO NO
#06 CARTESIANGLM NO NO
#07 CARTESIANGLM NO YES
#08 CARTESIAN8W NO YES
#09 POLAR CT YES NO
#10 POLAR CT YES NO
#11 POLAR GLM YES YES

A snapshot of the solution using static and AMR grid is given below.

mhd_rotor.01.jpg
Density map (in log scale) at t = 0.15 in Cartesian coordinates using 400 x 400 grid zones (configuration #01). Field lines are super-imposed.
mhd_rotor.08.jpg
Density map (in log scale) at t = 0.15 in Cartesian coordinates using a base grid of 64x64 and 4 levels of refinement (conf. #08).
Author
A. Mignone (migno.nosp@m.ne@p.nosp@m.h.uni.nosp@m.to.i.nosp@m.t)
Date
July 08, 2014

Reference:

  • "On the divergence-free condition in Godunov-type schemes for ideal MHD: the upwind constrained transport method" P. Londrillo, L. Del Zanna, JCP (2004), 195, 17
  • "PLUTO: A numerical code for computational astrophysics" Mignone et al., ApJS (2007) 170, 228 (see Sect. 5.4)

Definition in file init.c.

Function Documentation

void Analysis ( const Data d,
Grid grid 
)

Perform runtime data analysis.

Parameters
[in]dthe PLUTO Data structure
[in]gridpointer to array of Grid structures

Definition at line 132 of file init.c.

137 {
138 
139 }
void BackgroundField ( double  x1,
double  x2,
double  x3,
double *  B0 
)

Definition at line 143 of file init.c.

147 {
148  double Bx;
149  Bx = 5.0/sqrt(4.0*CONST_PI);
150 
151  #if GEOMETRY == CARTESIAN
152  B0[0] = Bx;
153  B0[1] = 0.0;
154  B0[2] = 0.0;
155  #elif GEOMETRY == POLAR
156  B0[0] = Bx*cos(x2);
157  B0[1] = - Bx*sin(x2);
158  B0[2] = 0.0;
159  #endif
160 }
static double Bx
Definition: hlld.c:62
#define CONST_PI
.
Definition: pluto.h:269
void Init ( double *  v,
double  x1,
double  x2,
double  x3 
)

The Init() function can be used to assign initial conditions as as a function of spatial position.

Parameters
[out]va pointer to a vector of primitive variables
[in]x1coordinate point in the 1st dimension
[in]x2coordinate point in the 2nd dimension
[in]x3coordinate point in the 3rdt dimension

The meaning of x1, x2 and x3 depends on the geometry:

\[ \begin{array}{cccl} x_1 & x_2 & x_3 & \mathrm{Geometry} \\ \noalign{\medskip} \hline x & y & z & \mathrm{Cartesian} \\ \noalign{\medskip} R & z & - & \mathrm{cylindrical} \\ \noalign{\medskip} R & \phi & z & \mathrm{polar} \\ \noalign{\medskip} r & \theta & \phi & \mathrm{spherical} \end{array} \]

Variable names are accessed by means of an index v[nv], where nv = RHO is density, nv = PRS is pressure, nv = (VX1, VX2, VX3) are the three components of velocity, and so forth.

Definition at line 63 of file init.c.

68 {
69  double r, r0, r1, Bx, f, omega;
70 
71  g_gamma = 1.4;
72  omega = 20.0;
73  Bx = 5.0/sqrt(4.0*CONST_PI);
74  r0 = 0.1;
75  r1 = 0.115;
76 
77  #if GEOMETRY == CARTESIAN
78  r = sqrt(x1*x1 + x2*x2);
79 
80  v[PRS] = 1.0;
81  v[BX1] = Bx;
82  v[BX2] = 0.0;
83 
84  f = (r1 - r)/(r1 - r0);
85  if (r <= r0) {
86  v[RHO] = 10.0;
87  v[VX1] = -omega*x2;
88  v[VX2] = omega*x1;
89  }else if (r < r1) {
90  v[RHO] = 1.0 + 9.0*f;
91  v[VX1] = -f*omega*x2*r0/r;
92  v[VX2] = f*omega*x1*r0/r;
93  } else {
94  v[RHO] = 1.0;
95  v[VX1] = 0.0;
96  v[VX2] = 0.0;
97  }
98 
99  v[AX1] = v[AX2] = 0.0;
100  v[AX3] = Bx*x2;
101  #elif GEOMETRY == POLAR
102  r = x1;
103 
104  v[BX1] = Bx*cos(x2);
105  v[BX2] = -Bx*sin(x2);
106  v[VX1] = 0.0;
107  v[PRS] = 1.0;
108 
109  f = (r1 - r)/(r1 - r0);
110  if (r <= r0) {
111  v[RHO] = 10.0;
112  v[VX2] = omega*r;
113  }else if (r < r1) {
114  v[RHO] = 1.0 + 9.0*f;
115  v[VX2] = f*omega*r0;
116  } else {
117  v[RHO] = 1.0;
118  v[VX2] = 0.0;
119  }
120 
121  v[AX1] = v[AX2] = 0.0;
122  v[AX3] = - r*sin(x2)*Bx;
123  #endif
124 
125  #if BACKGROUND_FIELD == YES /* With background splitting, the initial
126  condition should contain deviation only */
127  v[BX1] = v[BX2] = v[BX3] =
128  v[AX1] = v[AX2] = v[AX3] = 0.0;
129  #endif
130 }
double g_gamma
Definition: globals.h:112
#define VX2
Definition: mod_defs.h:29
#define RHO
Definition: mod_defs.h:19
#define AX2
Definition: mod_defs.h:86
#define VX1
Definition: mod_defs.h:28
#define AX3
Definition: mod_defs.h:87
static double Bx
Definition: hlld.c:62
#define BX3
Definition: mod_defs.h:27
#define AX1
Definition: mod_defs.h:85
#define BX1
Definition: mod_defs.h:25
#define CONST_PI
.
Definition: pluto.h:269
#define BX2
Definition: mod_defs.h:26
void UserDefBoundary ( const Data d,
RBox box,
int  side,
Grid grid 
)

Provide inner radial boundary condition in polar geometry. Zero gradient is prescribed on density, pressure and magnetic field. For the velocity, zero gradient is imposed on v/r (v = vr, vphi).

Definition at line 164 of file init.c.

171 {
172  int i, j, k, nv;
173  double *r, slp;
174 
175  if (side == X1_BEG){
176  r = grid[IDIR].x;
177  if (box->vpos == CENTER) {
178  BOX_LOOP(box,k,j,i){
179  slp = r[i]/r[IBEG];
180  d->Vc[RHO][k][j][i] = d->Vc[RHO][k][j][IBEG];
181  d->Vc[VX1][k][j][i] = slp*d->Vc[VX1][k][j][IBEG];
182  d->Vc[VX2][k][j][i] = slp*d->Vc[VX2][k][j][IBEG];
183  d->Vc[PRS][k][j][i] = d->Vc[PRS][k][j][IBEG];
184  d->Vc[BX1][k][j][i] = d->Vc[BX1][k][j][IBEG];
185  d->Vc[BX2][k][j][i] = d->Vc[BX2][k][j][IBEG];
186  }
187  }else if (box->vpos == X2FACE){
188  #ifdef STAGGERED_MHD
189  BOX_LOOP(box,k,j,i) d->Vs[BX2s][k][j][i] = d->Vs[BX2s][k][j][IBEG];
190  #endif
191  }
192  }
193 }
#define X1_BEG
Boundary region at X1 beg.
Definition: pluto.h:146
#define VX2
Definition: mod_defs.h:29
#define CENTER
Definition: pluto.h:200
int vpos
Location of the variable inside the cell.
Definition: structs.h:359
#define RHO
Definition: mod_defs.h:19
#define BOX_LOOP(B, k, j, i)
Definition: macros.h:70
double **** Vc
The main four-index data array used for cell-centered primitive variables.
Definition: structs.h:31
#define VX1
Definition: mod_defs.h:28
#define IDIR
Definition: pluto.h:193
int j
Definition: analysis.c:2
int k
Definition: analysis.c:2
double * x
Definition: structs.h:80
int i
Definition: analysis.c:2
#define BX1
Definition: mod_defs.h:25
#define BX2s
Definition: ct.h:28
#define BX2
Definition: mod_defs.h:26
#define X2FACE
Definition: pluto.h:202
long int IBEG
Lower grid index of the computational domain in the the X1 direction for the local processor...
Definition: globals.h:35