PLUTO
init.c
Go to the documentation of this file.
1 /* ///////////////////////////////////////////////////////////////////// */
2 /*!
3  \file
4  \brief Reconnection test (Harris sheet) in 2D.
5 
6  In this setup - see also Section 5.3 of Mignone et al., ApJS (2012) 198:7 -
7  we reproduce a 2D Harris current sheet with magnetic field profile given by
8  \f[
9  B_x(y) = B_0 \tanh(y/l)
10  \f]
11  where \c l is the half thickness of the layer.
12  The density profile is given by
13  \f[
14  \rho(y) = \rho_0 \cosh^{-2}(y/l) + \rho_{\infty}
15  \f]
16  We use \f$ \rho_0=1 \f$ and \f$ \rho_{\infty} = 0.2 \f$,
17  following the guidelines of Birn et al., 2001, while
18  \c l is user supplied. \n
19  In order to achieve equilibrium with the magnetic pressure,
20  the thermal pressure is chosen to be \f$ p = c_s^2 \rho \f$, where
21  \f$ c_s^2 = \frac{B_0^2}{2\rho_0} \f$.
22  The initial equilibrium is pertubed by an additional magnetic field
23  defined as
24  \f[
25  \begin{array}{lcl}
26  B_x(x,y) &=& \DS -\Psi_0\frac{\pi}{L_y}\cos\left(\frac{2\pi x}{L_x}\right)
27  \sin\left(\frac{\pi y}{L_y}\right), \\ \noalign{\medskip}
28  B_y(x,y) &=& \DS +\Psi_0 \frac{2\pi}{L_x}\sin\left(\frac{2\pi x}{L_x}\right)
29  \cos\left(\frac{\pi y}{L_y}\right).
30  \end{array}
31  \f]
32 
33  The Lundquist number \f$ S \f$ of a plasma is defined as
34  \f[
35  S = \frac{v_A L}{\eta}
36  \f]
37  where \f$ v_A \f$ is the Alfvén velocity,
38  \f$ v_A = \DS \frac{B}{\sqrt{\rho}}\f$, \f$ L \f$ is a typical lenght scale,
39  and \f$ \eta \f$ the plasma resistivity.
40  The reconnection rate \f$\mathcal{E} = \DS \frac{v_{in}}{v_{out}}\f$, with
41  \f$ v_{in} \f$ and \f$ v_{out}\f$ the plasma inflow and outflow velocities,
42  follows the Sweet-Parker scaling law
43  \f$\mathcal{E} \sim \frac{\delta}{L} \sim \frac{1}{\sqrt{S}}\f$.
44  In this example several values of the resitivity \f$ \eta \f$,
45  that correspond to different values of the Lundquist number \f$ S \f$,
46  are provided.
47  The reconnection rate, calculated as the ratio \f$ \frac{\delta}{L} \f$
48  (see Mignone et al., 2012) verifies the Sweet-Parker scaling in the range
49  \f$ \eta = 10^{-2} - 10^{-4} \f$ (see the first figure below).
50 
51  The input parameters (read from \c pluto.ini) for this test problem are:
52 
53  - <tt> g_inputParam[ETA]</tt>: sets the value of resistivity \f$ \eta \f$;
54  - <tt> g_inputParam[WIDTH]</tt>: sets the layer width \c l;
55  - <tt> g_inputParam[PSI0]</tt>: sets the amplitude of perturbation \f$\Psi_0\f$.
56 
57  \note
58  - Configuration #02 employs a small width (l -> 0, current-sheet)
59  large resistivity (test passes only with the new implementation of
60  the resistive-CT module in PLUTO 4.1. Crash with PLUTO 4.0).
61  - Configuratation #09 employs adaptive mesh refinement as in the original
62  PLUTO-Chombo paper (ApJS 2012).
63 
64 
65  \image html fig1.png "Computed Sweet-Parker scaling for different values of eta with a resolution of 512x256."
66  \image html vx_rho_plot__137.png "Density map and magnetic field lines for eta = 2.e-3 at t = 137."
67 
68  \authors E. Striani (edoardo.striani@iaps.inaf.it)\n
69  A. Mignone (mignone@ph.unito.it)
70  \date July 29, 2014
71 
72  \b Reference
73  - "The PLUTO Code for Adaptive Mesh Computations in
74  Astrophysical FLuid Dynamics" Mignone et al., ApJS (2012) 198,7
75  - "Geospace Environmental Modeling (GEM) magnetic
76  reconnection challenge" Birn et al., JGR (2001) 106, 3715
77 */
78 /* ///////////////////////////////////////////////////////////////////// */
79 #include "pluto.h"
80 
81 /* ********************************************************************* */
82 void Init (double *v, double x, double y, double x3)
83 /*
84  *********************************************************************** */
85 {
86 #if 1
87  double cs2 = 0.5, b0 = 1.0, l, Psi0;
88  double Lx, Ly, kx, ky;
89 
90  l = g_inputParam[WIDTH];
91  v[RHO] = 0.2 + 1.0/(cosh(y/l)*(cosh(y/l)));
92  v[PRS] = cs2*v[RHO]; /* v[PRS] = 0.5 in the original PLUTO (2012) paper. */
93  v[VX1] = 0.0;
94  v[VX2] = 0.0;
95 
96  #if PHYSICS == MHD || PHYSICS == RMHD
97  v[BX1] = b0*tanh(y/l);
98  v[BX2] = 0.0;
99 
100  Lx = g_domEnd[IDIR] - g_domBeg[IDIR]; kx = CONST_PI/Lx;
101  Ly = g_domEnd[JDIR] - g_domBeg[JDIR]; ky = CONST_PI/Ly;
102 
103 
104  Psi0 = g_inputParam[PSI0];
105  v[BX1] += -Psi0*ky*sin(ky*y)*cos(2.0*kx*x);
106  v[BX2] += Psi0*2.0*kx*sin(2.0*kx*x)*cos(ky*y);
107  #endif
108 #endif
109 
110 
111 }
112 /* ********************************************************************* */
113 void Analysis (const Data *d, Grid *grid)
114 /* *********************************************************************** */
115 {
116 
117 }
118 #if PHYSICS == MHD
119 /* ********************************************************************* */
120 void BackgroundField (double x1, double x2, double x3, double *B0)
121 /* *********************************************************************** */
122 {
123  B0[0] = 0.0;
124  B0[1] = 0.0;
125  B0[2] = 0.0;
126 }
127 #endif
128 
129 /* ********************************************************************* */
130 void UserDefBoundary (const Data *d, RBox *box, int side, Grid *grid)
131 /* *********************************************************************** */
132 {
133  int i, j, k, nv;
134  double *x1, *x2, *x3;
135 
136  x1 = grid[IDIR].x;
137  x2 = grid[JDIR].x;
138  x3 = grid[KDIR].x;
139 
140  if (side == 0) { /* -- check solution inside domain -- */
141  DOM_LOOP(k,j,i){}
142  }
143 
144 }
145 
146 #if BODY_FORCE != NO
147 /* ********************************************************************* */
148 void BodyForceVector(double *v, double *g, double x1, double x2, double x3)
149 /* *********************************************************************** */
150 {
151  g[IDIR] = 0.0;
152  g[JDIR] = 0.0;
153  g[KDIR] = 0.0;
154 }
155 /* ********************************************************************* */
156 double BodyForcePotential(double x1, double x2, double x3)
157 /* *********************************************************************** */
158 {
159  return 0.0;
160 }
161 #endif
162 
163 
void UserDefBoundary(const Data *d, RBox *box, int side, Grid *grid)
Definition: init.c:98
DOM_LOOP(k, j, i)
Definition: analysis.c:22
#define VX2
Definition: mod_defs.h:29
void BackgroundField(double x1, double x2, double x3, double *B0)
Definition: init.c:79
#define RHO
Definition: mod_defs.h:19
#define PSI0
#define VX1
Definition: mod_defs.h:28
#define KDIR
Definition: pluto.h:195
#define IDIR
Definition: pluto.h:193
Definition: structs.h:78
double g_inputParam[32]
Array containing the user-defined parameters.
Definition: globals.h:131
int j
Definition: analysis.c:2
int k
Definition: analysis.c:2
double g_domBeg[3]
Lower limits of the computational domain.
Definition: globals.h:125
double * x
Definition: structs.h:80
PLUTO main header file.
Definition: structs.h:30
int i
Definition: analysis.c:2
#define WIDTH
double BodyForcePotential(double x, double y, double z)
Definition: init.c:479
#define BX1
Definition: mod_defs.h:25
#define CONST_PI
.
Definition: pluto.h:269
#define BX2
Definition: mod_defs.h:26
double g_domEnd[3]
Upper limits of the computational domain.
Definition: globals.h:126
#define JDIR
Definition: pluto.h:194
Definition: structs.h:346
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
void BodyForceVector(double *v, double *g, double x, double y, double z)
Definition: init.c:441