PLUTO
init.c File Reference

Relativistic magnetized Kelvin-Helmholtz 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 UserDefBoundary (const Data *d, RBox *box, int side, Grid *grid)
 

Detailed Description

Relativistic magnetized Kelvin-Helmholtz problem.

Implements the initial condition for a relativistic KH flow in 2D Cartesian coordinates as in section 6.6 of Mignone et al. (ApJS, 2012). Density and pressure are initially constant and equal to $\rho = 1$ and $p = p_0$ where the latter value is retrieved from the definition of the Mach number $M = v/c_s$. The sound speed is $c_s=\sqrt{\Gamma p/w}$ for the IDEAL equation of state and $c_s = \sqrt{\frac{p}{3w}\frac{5w - 8p}{w - p}}$ for the TAUB EoS (see Eq. [17], [31] and [32] of Mignone & McKinney [MNRAS, 2007]), where $ w = \rho h$ is the gas enthalpy.

The velocity is parallel to the x axis with a hyperbolic tangent shear profile. Magnetic field has the form

\[ \vec{B} = \left(\sqrt{2\sigma_{\rm pol}p_0},\, 0,\, \sqrt{2\sigma_{\rm tor}p_0}\right) \]

where $\sigma_{\rm pol}$ and $\sigma_{\rm tor}$ control the strength of the poloidal and toroidal component, respectively.

Periodic boundary conditions are assumed in the horizontal direction while zero-gradient (outflow) conditions hold at the lower and upper boundaries in the y direction.

The presence of a magnetic field gives rise to a filamentary structure and to the formation of a number of vortices arranged symmetrically with respect to the central point. The figure below shows density for configuration #03 using AMR with 4 levels of refinement at t = 5

The control parameters for this problem are:

  1. g_inputParam[SIGMA_TOR]: control the strength of the toroidal (z) component of magnetic field;
  2. g_inputParam[SIGMA_POL]: control the strength of the poloidal (x) component of magnetic field;
  3. g_inputParam[VEL0]: the flow velocity (in units of the speed of light);
  4. g_inputParam[MACH]: the flow Mach number used to recover the pressure value;
rmhd_kh.03.jpg
...

.

References

  • "The PLUTO Code for Adaptive Mesh Computations in Astrophysical Fluid Dynamics", Mignone et al., ApJS (2012) 198, 7.
  • "Equation of state in relativistic magnetohydrodynamics: variable versus constant adiabatic index", Mignone & McKinney, MNRAS (2007) 378, 1118.
Author
A. Mignone (migno.nosp@m.ne@p.nosp@m.h.uni.nosp@m.to.i.nosp@m.t)
Date
Sep 22, 2014

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

Compute volume-integrated magnetic pressure, Maxwell and Reynolds stresses. Save them to "averages.dat"

Definition at line 131 of file init.c.

136 {
137 
138 }
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 64 of file init.c.

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 }
static double alpha
Definition: init.c:3
static double a
Definition: init.c:135
double g_gamma
Definition: globals.h:112
#define MACH
#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
#define AX3
Definition: mod_defs.h:87
double g_inputParam[32]
Array containing the user-defined parameters.
Definition: globals.h:131
double * x
Definition: structs.h:80
tuple c
Definition: menu.py:375
#define BX3
Definition: mod_defs.h:27
#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
#define SIGMA_TOR
void UserDefBoundary ( const Data d,
RBox box,
int  side,
Grid grid 
)

Assign user-defined boundary conditions.

Parameters
[in,out]dpointer to the PLUTO data structure containing cell-centered primitive quantities (d->Vc) and staggered magnetic fields (d->Vs, when used) to be filled.
[in]boxpointer to a RBox structure containing the lower and upper indices of the ghost zone-centers/nodes or edges at which data values should be assigned.
[in]sidespecifies the boundary side where ghost zones need to be filled. It can assume the following pre-definite values: X1_BEG, X1_END, X2_BEG, X2_END, X3_BEG, X3_END. The special value side == 0 is used to control a region inside the computational domain.
[in]gridpointer to an array of Grid structures.

Assign user-defined boundary conditions in the lower boundary ghost zones. The profile is top-hat:

\[ V_{ij} = \left\{\begin{array}{ll} V_{\rm jet} & \quad\mathrm{for}\quad r_i < 1 \\ \noalign{\medskip} \mathrm{Reflect}(V) & \quad\mathrm{otherwise} \end{array}\right. \]

where $ V_{\rm jet} = (\rho,v,p)_{\rm jet} = (1,M,1/\Gamma)$ and M is the flow Mach number (the unit velocity is the jet sound speed, so $ v = M$).

Assign user-defined boundary conditions:

  • left side (x beg): constant shocked values
  • bottom side (y beg): constant shocked values for x < 1/6 and reflective boundary otherwise.
  • top side (y end): time-dependent boundary: for $ x < x_s(t) = 10 t/\sin\alpha + 1/6 + 1.0/\tan\alpha $ we use fixed (post-shock) values. Unperturbed values otherwise.

Assign user-defined boundary conditions at inner and outer radial boundaries. Reflective conditions are applied except for the azimuthal velocity which is fixed.

Assign user-defined boundary conditions.

Parameters
[in/out]d pointer to the PLUTO data structure containing cell-centered primitive quantities (d->Vc) and staggered magnetic fields (d->Vs, when used) to be filled.
[in]boxpointer to a RBox structure containing the lower and upper indices of the ghost zone-centers/nodes or edges at which data values should be assigned.
[in]sidespecifies on which side boundary conditions need to be assigned. side can assume the following pre-definite values: X1_BEG, X1_END, X2_BEG, X2_END, X3_BEG, X3_END. The special value side == 0 is used to control a region inside the computational domain.
[in]gridpointer to an array of Grid structures.

Set the injection boundary condition at the lower z-boundary (X2-beg must be set to userdef in pluto.ini). For $ R \le 1 $ we set constant input values (given by the GetJetValues() function while for $ R > 1 $ the solution has equatorial symmetry with respect to the z=0 plane. To avoid numerical problems with a "top-hat" discontinuous jump, we smoothly merge the inlet and reflected value using a profile function Profile().

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).

The user-defined boundary is used to impose stress-free boundary and purely vertical magnetic field at the top and bottom boundaries, as done in Bodo et al. (2012). In addition, constant temperature and hydrostatic balance are imposed. For instance, at the bottom boundary, one has:

\[ \left\{\begin{array}{lcl} \DS \frac{dp}{dz} &=& \rho g_z \\ \noalign{\medskip} p &=& \rho c_s^2 \end{array}\right. \qquad\Longrightarrow\qquad \frac{p_{k+1}-p_k}{\Delta z} = \frac{p_{k} + p_{k+1}}{2c_s^2}g_z \]

where $g_z$ is the value of gravity at the lower boundary. Solving for $p_k$ at the bottom boundary where $k=k_b-1$ gives:

\[ \left\{\begin{array}{lcl} p_k &=& \DS p_{k+1} \frac{1-a}{1+a} \\ \noalign{\medskip} \rho_k &=& \DS \frac{p_k}{c_s^2} \end{array}\right. \qquad\mathrm{where}\qquad a = \frac{\Delta z g_z}{2c_s^2} > 0 \]

where, for simplicity, we keep constant temperature in the ghost zones rather than at the boundary interface (this seems to give a more stable behavior and avoids negative densities). A similar treatment holds at the top boundary.

Assign user-defined boundary conditions. At the inner boundary we use outflow conditions, except for velocity which we reset to zero when there's an inflow

Definition at line 140 of file init.c.

145 {
146 }