PLUTO
init.c
Go to the documentation of this file.
1 /* ///////////////////////////////////////////////////////////////////// */
2 /*!
3  \file
4  \brief MHD Rotor test problem.
5 
6  The rotor problem consists of a rapidly spinning cylinder embedded in
7  a static background medium with uniform density and pressure and
8  a constant magnetic field along the x direction
9  \f$B_x = 5/\sqrt{4\pi}\f$.
10  The cylinder rotates uniformly with constant angular velocity
11  \f$ \omega \f$ and has larger density:
12  \f[
13  (\rho, v_\phi) = \left\{\begin{array}{ll}
14  (10, \omega r) & \qquad {\rm for}\quad r < r_0
15  \\ \noalign{\medskip}
16  (1+9f,f\omega r_0) & \qquad {\rm for}\quad r_0 \le r \le r_1
17  \\ \noalign{\medskip}
18  (1,0) & \qquad {\rm otherwise}
19  \end{array}\right.
20  \f]
21  Here \f$ r_0=0.1\f$ and \f$ = (r_1-r)/(r_1-r_0)\f$ is a taper function.
22  The ideal equation of state with \f$\Gamma = 1.4\f$ is used.
23  As the disk rotates, strong torsional Alfven waves form and propagate
24  outward carrying angular momentum from the disk to the ambient.
25 
26  A list of tested configurations is given in the following table:
27 
28  <CENTER>
29  Conf.| GEOMETRY| divB |BCK_FIELD| AMR
30  -----|---------| ------|---------|-----
31  #01 |CARTESIAN| CT | NO | NO
32  #02 |POLAR | CT | NO | NO
33  #03 |POLAR | 8W | NO | NO
34  #04 |POLAR | CT | YES | NO
35  #05 |POLAR | GLM | NO | NO
36  #06 |CARTESIAN| GLM | NO | NO
37  #07 |CARTESIAN| GLM | NO | YES
38  #08 |CARTESIAN| 8W | NO | YES
39  #09 |POLAR | CT | YES | NO
40  #10 |POLAR | CT | YES | NO
41  #11 |POLAR | GLM | YES | YES
42  </CENTER>
43 
44  A snapshot of the solution using static and AMR grid is given below.
45 
46  \image html 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."
47  \image html 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)."
48 
49  \author A. Mignone (mignone@ph.unito.it)
50  \date July 08, 2014
51 
52  \b Reference:
53  - "On the divergence-free condition in Godunov-type schemes
54  for ideal MHD: the upwind constrained transport method"
55  P. Londrillo, L. Del Zanna, JCP (2004), 195, 17
56  - "PLUTO: A numerical code for computational astrophysics"
57  Mignone et al., ApJS (2007) 170, 228 (see Sect. 5.4)
58 */
59 /* ///////////////////////////////////////////////////////////////////// */
60 #include "pluto.h"
61 
62 /* ********************************************************************* */
63 void Init (double *v, double x1, double x2, double x3)
64 /*
65  *
66  *
67  *********************************************************************** */
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 }
131 /* ********************************************************************* */
132 void Analysis (const Data *d, Grid *grid)
133 /*
134  *
135  *
136  *********************************************************************** */
137 {
138 
139 }
140 
141 #if PHYSICS == MHD
142 /* ************************************************************** */
143 void BackgroundField (double x1, double x2, double x3, double *B0)
144 /*
145  * Sets the initial curl-free magnetic field.
146  **************************************************************** */
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 }
161 #endif
162 
163 /* ********************************************************************* */
164 void UserDefBoundary (const Data *d, RBox *box, int side, Grid *grid)
165 /*!
166  * Provide inner radial boundary condition in polar geometry.
167  * Zero gradient is prescribed on density, pressure and magnetic field.
168  * For the velocity, zero gradient is imposed on v/r (v = vr, vphi).
169  *
170  *********************************************************************** */
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
double **** Vs
The main four-index data array used for face-centered staggered magnetic fields.
Definition: structs.h:43
double g_gamma
Definition: globals.h:112
void UserDefBoundary(const Data *d, RBox *box, int side, Grid *grid)
Definition: init.c:98
#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
void BackgroundField(double x1, double x2, double x3, double *B0)
Definition: init.c:79
#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 AX2
Definition: mod_defs.h:86
#define VX1
Definition: mod_defs.h:28
#define IDIR
Definition: pluto.h:193
Definition: structs.h:78
#define AX3
Definition: mod_defs.h:87
static double Bx
Definition: hlld.c:62
int j
Definition: analysis.c:2
int k
Definition: analysis.c:2
double * x
Definition: structs.h:80
#define BX3
Definition: mod_defs.h:27
PLUTO main header file.
Definition: structs.h:30
int i
Definition: analysis.c:2
#define AX1
Definition: mod_defs.h:85
#define BX1
Definition: mod_defs.h:25
#define CONST_PI
.
Definition: pluto.h:269
#define BX2s
Definition: ct.h:28
#define BX2
Definition: mod_defs.h:26
Definition: structs.h:346
#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
void Analysis(const Data *d, Grid *grid)
Definition: init.c:66
void Init(double *v, double x1, double x2, double x3)
Definition: init.c:17