PLUTO
init.c
Go to the documentation of this file.
1 /* ///////////////////////////////////////////////////////////////////// */
2 /*!
3  \file
4  \brief Relativistic magnetized jet in axisymmetric coordinates.
5 
6  The jet problem is set up in axisymmetric cylindrical coordinates
7  \f$ (r,z) \f$ as described in section 4.2.3 of
8  Mignone, Ugliano \& Bodo (2009, [MUB09] hereafter).
9  We label ambient and jet values with the suffix "a" and "j", respectively.
10  The ambient medium is at rest and is characterized by uniform density
11  and pressure, \f$ \rho_a \f$ and \f$ p_a \f$.
12  The beam enters from the lower-z boundary from a circular nozzle of
13  radius 1, carries a constant poloidal field \f$ B_z \f$
14  and a (radially-varying) toroidal component \f$ B_\phi(R) \f$.
15  Flow variables are prescribed as
16  \f[ \left\{\begin{array}{lcl}
17  \rho(R) &=& \rho_j \\ \noalign{\medskip}
18  v_z(R) &=& v_j \\ \noalign{\medskip}
19  B_\phi(R) &=& \DS \left\{\begin{array}{ll}
20  -\gamma_j b_m R/a & \quad{\rm for}\quad r<a \\ \noalign{\medskip}
21  -\gamma_j b_m a/R & \quad{\rm for}\quad r>a
22  \end{array}\right. \\ \noalign{\medskip}
23  B_z(R) &=& B_{z0}\quad\mathrm{(const)}
24  \end{array}\right. \f]
25  Here \c a is the magnetization radius while \f$ v_r = B_r = 0 \f$.
26  The pressure distribution is found by solving the radial momentum
27  balance between thermal, centrifugal and magnetic forces.
28  Neglecting rotation and assuming \c Bz to be constant the solution
29  is given by
30  \f[
31  p(R) = p_j + b_m^2\left[1-\min\left(\frac{r^2}{a^2},1\right)\right]
32  \f]
33  Here \f$p_j=p_a\f$ is the jet/ambient pressure at \c r=1 and its
34  value depends on the Mach number, see [MUB09].
35 
36  The parameters controlling the problem is
37  -# <tt>g_inputParam[MACH]</tt>: the jet Mach number
38  \f$ M = v_j/cs \f$ where \f$c_s=\sqrt{\Gamma p_j/(\rho h)}\f$ is
39  the sound speed and \f$\rho h = \rho + \Gamma p_j/(\Gamma-1)\f$.
40  This is used to recover \f$p_j\f$;
41  -# <tt>g_inputParam[LORENTZ]</tt>: the jet Lorentz factor;
42  -# <tt>g_inpurParam[RHOJ]</tt>: the jet density;
43  -# <tt>g_inpurParam[SIGMA_POL]</tt>: magnetization strength for poloidal
44  magnetic field component (see [MUB09], Eq [65]);
45  -# <tt>g_inpurParam[SIGMA_TOR]</tt>: magnetization strength for toroidal
46  magnetic field component (see [MUB09], Eq [65]);
47 
48  The different configurations are:
49 
50  - configurations #01-02 employ a purely poloidal field and are similar
51  to section 4.3.3 of Mignone \& Bodo (2006);
52  - configuration #03
53 
54  The following image show the (log) density map at the end of
55  simulation for setup #01.
56 
57  \image html rmhd_jet.01.jpg "Density map at the end of the computation for configuration #01"
58 
59  \b References
60  - "A five-wave Harten-Lax-van Leer Riemann solver for relativistic
61  magnetohydrodynamics", Mignone, Ugliano \& Bodo, MNARS (200) 393, 1141
62  - "An HLLC Rieman solver for relativistic flows - II. Magnetohydrodynamics"
63  Mignone \& Bodo, MNRAS (2006) 368, 1040
64 
65  \author A. Mignone (mignone@ph.unito.it)
66  \date Sept 17, 2014
67 
68 */
69 /* ///////////////////////////////////////////////////////////////////// */
70 #include "pluto.h"
71 
72 static void GetJetValues (double x1, double x2, double x3, double *vj);
73 static double pj;
74 
75 #if EOS == TAUB
76  static double g_gamma;
77 #endif
78 
79 /* ********************************************************************* */
80 void Init (double *v, double x1, double x2, double x3)
81 /*
82  *
83  *
84  *
85  *********************************************************************** */
86 {
87  int nv;
88  double r, z, p0, vjet[256], vamb[256];
89 
90  g_gamma = 5./3.;
91  GetJetValues (x1, x2, x3, vjet);
92 
93 /* -- set ambient values -- */
94 
95  v[RHO] = g_inputParam[RHOA];
96  EXPAND(v[VX1] = 0.0; ,
97  v[VX2] = 0.0; ,
98  v[VX3] = 0.0;)
99  v[PRS] = pj;
100  #if PHYSICS == RMHD
101  EXPAND(v[BX1] = 0.0; ,
102  v[BX2] = vjet[BX2]; ,
103  v[BX3] = 0.0;)
104  v[AX1] = 0.0;
105  v[AX2] = 0.0;
106  v[AX3] = vjet[AX3];
107  #endif
108  #if NTRACER > 0
109  v[TRC] = 0.0;
110  #endif
111  #ifdef PSI_GLM
112  v[PSI_GLM] = 0.0;
113  #endif
114 
115  g_smallPressure = 1.e-5;
116 }
117 /* ********************************************************************* */
118 void Analysis (const Data *d, Grid *grid)
119 /*
120  *
121  *
122  *********************************************************************** */
123 {
124 
125 }
126 
127 /* ********************************************************************* */
128 void UserDefBoundary (const Data *d, RBox *box, int side, Grid *grid)
129 /*
130  *
131  *
132  *********************************************************************** */
133 {
134  int i, j, k, nv;
135  double *x1, *x2, *x3;
136  double ***bxs, ***bys, ***bzs;
137  double prof, vjet[256], vout[NVAR];
138 
139  #ifdef STAGGERED_MHD
140  D_EXPAND(bxs = d->Vs[BX1s]; ,
141  bys = d->Vs[BX2s]; ,
142  bzs = d->Vs[BX3s];)
143  #endif
144 
145  x1 = grid[IDIR].xgc;
146  x2 = grid[JDIR].xgc;
147  x3 = grid[KDIR].xgc;
148 
149  if (side == X2_BEG){ /* -- X2_BEG boundary -- */
150  if (box->vpos == CENTER){ /* -- cell-centered boundary conditions -- */
151  BOX_LOOP(box,k,j,i){
152  GetJetValues (x1[i], x2[j], x3[k], vjet); /* Jet Values */
153  VAR_LOOP(nv) vout[nv] = d->Vc[nv][k][2*JBEG - j - 1][i]; /* Ambient */
154 
155  vout[VX2] *= -1.0;
156  EXPAND(vout[BX1] *= -1.0; ,
157  ; ,
158  vout[BX3] *= -1.0;)
159  #ifdef PSI_GLM
160  vjet[PSI_GLM] = d->Vc[PSI_GLM][k][JBEG][i] - d->Vc[BX2][k][JBEG][i];
161  vout[PSI_GLM] *= -1.0;
162  #endif
163 
164  prof = (fabs(x1[i]) <= 1.0);
165  VAR_LOOP(nv) d->Vc[nv][k][j][i] = vout[nv] - (vout[nv] - vjet[nv])*prof;
166  }
167 
168  }else if (box->vpos == X1FACE){ /* -- staggered fields -- */
169  #ifdef STAGGERED_MHD
170  x1 = grid[IDIR].xr;
171  vjet[BX1] = 0.0;
172  BOX_LOOP(box,k,j,i){
173  vout[BX1] = -bxs[k][2*JBEG - j - 1][i];
174  prof = (fabs(x1[i]) <= 1.0);
175  bxs[k][j][i] = vout[BX1] - (vout[BX1] - vjet[BX1])*prof;
176  }
177  #endif
178  }
179  }
180 }
181 
182 /* **************************************************************** */
183 void GetJetValues (double x1, double x2, double x3, double *vj)
184 /*
185  *
186  *
187  *
188  *
189  ****************************************************************** */
190 {
191  static int first_call = 1;
192  double bm, b2_av, bphi, lor, a = 0.5;
193  double r, x, scrh, sig_z, sig_phi;
194 
195  r = x1;
196  lor = g_inputParam[LORENTZ];
197  sig_z = g_inputParam[SIGMA_POL];
198  sig_phi = g_inputParam[SIGMA_TOR];
199  if (fabs(r) < 1.e-9) r = 1.e-9;
200 
201  x = r/a;
202  vj[RHO] = g_inputParam[RHOJ];
203 
204  EXPAND(vj[VX1] = 0.0; ,
205  vj[VX2] = sqrt(1.0 - 1.0/(lor*lor)); , /* 3-vel */
206  vj[VX3] = 0.0;)
207 
208  scrh = g_inputParam[MACH]/vj[VX2];
209  pj = vj[RHO]/(g_gamma*scrh*scrh - g_gamma/(g_gamma - 1.0));
210 
211  bm = 4.0*pj*sig_phi;
212  bm /= a*a*(1.0 - 4.0*log(a) - 2.0*sig_phi);
213  bm = sqrt(bm);
214 
215  scrh = MIN(x*x, 1.0);
216  vj[PRS] = pj + bm*bm*(1.0 - scrh);
217 
218  bphi = bm*(fabs(x) < 1.0 ? x: 1.0/x);
219 
220  #if GEOMETRY == CYLINDRICAL
221  EXPAND(vj[iBR] = 0.0; ,
222  vj[iBZ] = sqrt(sig_z*(bm*bm*a*a + 2.0*pj)); ,
223  vj[iBPHI] = lor*bphi;)
224  vj[AX1] = 0.0;
225  vj[AX2] = 0.0;
226  vj[AX3] = 0.5*r*vj[iBZ];
227  #endif
228 
229 /* -- set tracer value -- */
230 
231  #if NTRACER > 0
232  vj[TRC] = 1.0;
233  #endif
234  #ifdef PSI_GLM
235  vj[PSI_GLM] = 0.0;
236  #endif
237 
238 }
static double a
Definition: init.c:135
double **** Vs
The main four-index data array used for face-centered staggered magnetic fields.
Definition: structs.h:43
#define MACH
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
#define RHOA
int vpos
Location of the variable inside the cell.
Definition: structs.h:359
double * xr
Definition: structs.h:81
#define iBZ
Definition: mod_defs.h:138
#define RHO
Definition: mod_defs.h:19
tuple scrh
Definition: configure.py:200
#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 PSI_GLM
Definition: mod_defs.h:34
#define AX2
Definition: mod_defs.h:86
#define BX3s
Definition: ct.h:29
#define TRC
Definition: pluto.h:581
double g_smallPressure
Small value for pressure fix.
Definition: globals.h:110
#define iBR
Definition: mod_defs.h:150
#define VX1
Definition: mod_defs.h:28
#define KDIR
Definition: pluto.h:195
#define X1FACE
Definition: pluto.h:201
#define MIN(a, b)
Definition: macros.h:104
#define VAR_LOOP(n)
Definition: macros.h:226
#define IDIR
Definition: pluto.h:193
Definition: structs.h:78
#define AX3
Definition: mod_defs.h:87
double g_inputParam[32]
Array containing the user-defined parameters.
Definition: globals.h:131
int j
Definition: analysis.c:2
#define iBPHI
Definition: mod_defs.h:152
#define RHOJ
int k
Definition: analysis.c:2
#define BX1s
Definition: ct.h:27
double * xgc
Cell volumetric centroid (!= x when geometry != CARTESIAN).
Definition: structs.h:84
#define BX3
Definition: mod_defs.h:27
PLUTO main header file.
static double pj
Definition: init.c:73
D_EXPAND(tot/[n]=(double) grid[IDIR].np_int_glob;, tot/[n]=(double) grid[JDIR].np_int_glob;, tot/[n]=(double) grid[KDIR].np_int_glob;)
Definition: analysis.c:27
Definition: structs.h:30
int i
Definition: analysis.c:2
void GetJetValues(double, double *)
Definition: init.c:264
static double g_gamma
Definition: init.c:76
#define AX1
Definition: mod_defs.h:85
#define LORENTZ
#define BX1
Definition: mod_defs.h:25
#define VX3
Definition: mod_defs.h:30
#define BX2s
Definition: ct.h:28
#define X2_BEG
Boundary region at X2 beg.
Definition: pluto.h:148
#define BX2
Definition: mod_defs.h:26
#define SIGMA_POL
#define JDIR
Definition: pluto.h:194
long int JBEG
Lower grid index of the computational domain in the the X2 direction for the local processor...
Definition: globals.h:39
#define NVAR
Definition: pluto.h:609
Definition: structs.h:346
#define SIGMA_TOR
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