PLUTO
init.c
Go to the documentation of this file.
1 /* ///////////////////////////////////////////////////////////////////// */
2 /*!
3  \file
4  \brief Relativistic magnetized Kelvin-Helmholtz problem.
5 
6  Implements the initial condition for a relativistic KH flow in
7  2D Cartesian coordinates as in section 6.6 of Mignone et al. (ApJS, 2012).
8  Density and pressure are initially constant and equal to
9  \f$\rho = 1\f$ and \f$p = p_0\f$ where the latter value is retrieved
10  from the definition of the Mach number \f$M = v/c_s\f$.
11  The sound speed is \f$c_s=\sqrt{\Gamma p/w}\f$ for the \c IDEAL equation
12  of state and \f$c_s = \sqrt{\frac{p}{3w}\frac{5w - 8p}{w - p}}\f$ for the
13  \c TAUB EoS (see Eq. [17], [31] and [32] of Mignone \& McKinney
14  [MNRAS, 2007]), where \f$ w = \rho h\f$ is the gas enthalpy.
15 
16  The velocity is parallel to the \c x axis with a hyperbolic tangent
17  shear profile.
18  Magnetic field has the form
19  \f[
20  \vec{B} = \left(\sqrt{2\sigma_{\rm pol}p_0},\, 0,\,
21  \sqrt{2\sigma_{\rm tor}p_0}\right)
22  \f]
23  where \f$\sigma_{\rm pol}\f$ and \f$\sigma_{\rm tor}\f$ control the strength
24  of the poloidal and toroidal component, respectively.
25 
26  Periodic boundary conditions are assumed in the horizontal direction while
27  zero-gradient (outflow) conditions hold at the lower and upper
28  boundaries in the \c y direction.
29 
30  The presence of a magnetic field gives rise to a filamentary structure
31  and to the formation of a number of vortices arranged symmetrically
32  with respect to the central point.
33  The figure below shows density for configuration #03 using AMR
34  with 4 levels of refinement at \c t = 5
35 
36  The control parameters for this problem are:
37 
38  -# <tt>g_inputParam[SIGMA_TOR]</tt>: control the strength of the toroidal
39  (\c z) component of magnetic field;
40  -# <tt>g_inputParam[SIGMA_POL]</tt>: control the strength of the poloidal
41  (\c x) component of magnetic field;
42  -# <tt>g_inputParam[VEL0]</tt>: the flow velocity (in units of the speed of
43  light);
44  -# <tt>g_inputParam[MACH]</tt>: the flow Mach number used to recover the
45  pressure value;
46 
47 
48  \image html rmhd_kh.03.jpg "...".
49 
50  \b References
51  - "The PLUTO Code for Adaptive Mesh Computations in Astrophysical
52  Fluid Dynamics", Mignone et al., ApJS (2012) 198, 7.
53  - "Equation of state in relativistic magnetohydrodynamics:
54  variable versus constant adiabatic index",
55  Mignone \& McKinney, MNRAS (2007) 378, 1118.
56 
57  \author A. Mignone (mignone@ph.unito.it)
58  \date Sep 22, 2014
59 */
60 /* ///////////////////////////////////////////////////////////////////// */
61 #include "pluto.h"
62 
63 /* ********************************************************************* */
64 void Init (double *v, double x1, double x2, double x3)
65 /*
66  *
67  *
68  *
69  *********************************************************************** */
70 {
71  static int first_call = 1;
72  double x,y, arg, eps, kx;
73  double alpha, beta;
74  static double pr0;
75 
76  if (first_call == 1){
78  arg = arg*arg;
79  #if EOS == IDEAL
80  g_gamma = 4./3.;
81  pr0 = (g_gamma - 1.0)/((g_gamma - 1.0)*arg - 1.0)/g_gamma;
82  #else
83  {
84  double a,b,c; /* See Eq. 32 of Mignone \& McKinney (MNRAS 2007) */
85  a = 15.0 - 6.0*arg; b = 24.0 - 10.0*arg; c = 9.0;
86  arg = 0.5*(- b - sqrt(b*b - 4.0*a*c))/a;
87  pr0 = 2.0/3.0*sqrt(arg*arg/(1.0 - arg*arg));
88  }
89  #endif
90  first_call = 0;
91  }
92 
93  x = x1;
94  y = x2;
95 
96  kx = 2.0*CONST_PI*x1;
97  alpha = 1.0/100.0;
98  beta = 1.0/10.0;
99 
100  arg = y*y/(beta*beta);
101  eps = 0.01*g_inputParam[VEL0];
102 
103  v[RHO] = 1.0;
104  v[VX1] = -g_inputParam[VEL0]*tanh(y/alpha);
105  v[VX2] = eps*0.5*(sin(kx) - sin(-kx))*exp(-arg);
106  v[VX3] = 0.0;
107 
108 /* --------------------------------------------
109  find pressure values given the Mach number
110  -------------------------------------------- */
111 
112  v[PRS] = pr0;
113 
114 /* v[PRS] = 20.0; */
115 
116  v[TRC] = (y < 0.0 ? 1.0:-1.0);
117 
118  #if PHYSICS == MHD || PHYSICS == RMHD
119 
120  v[BX1] = sqrt(2.0*v[PRS]*g_inputParam[SIGMA_POL]);
121  v[BX2] = 0.0;
122  v[BX3] = sqrt(2.0*v[PRS]*g_inputParam[SIGMA_TOR]);
123 
124  v[AX1] = 0.0;
125  v[AX2] = 0.0;
126  v[AX3] = y*v[BX1];
127 
128  #endif
129 }
130 /* ********************************************************************* */
131 void Analysis (const Data *d, Grid *grid)
132 /*
133  *
134  *
135  *********************************************************************** */
136 {
137 
138 }
139 /* ********************************************************************* */
140 void UserDefBoundary (const Data *d, RBox *box, int side, Grid *grid)
141 /*
142  *
143  *
144  *********************************************************************** */
145 {
146 }
static double alpha
Definition: init.c:3
static double a
Definition: init.c:135
double g_gamma
Definition: globals.h:112
#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 VEL0
#define RHO
Definition: mod_defs.h:19
#define AX2
Definition: mod_defs.h:86
#define TRC
Definition: pluto.h:581
#define VX1
Definition: mod_defs.h:28
#define eps
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
tuple c
Definition: menu.py:375
#define BX3
Definition: mod_defs.h:27
PLUTO main header file.
Definition: structs.h:30
#define AX1
Definition: mod_defs.h:85
#define BX1
Definition: mod_defs.h:25
#define VX3
Definition: mod_defs.h:30
#define CONST_PI
.
Definition: pluto.h:269
#define BX2
Definition: mod_defs.h:26
#define SIGMA_POL
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