PLUTO
init.c
Go to the documentation of this file.
1 /* ///////////////////////////////////////////////////////////////////// */
2 /*!
3  \file
4  \brief MHD blast wave.
5 
6  The MHD blast wave problem has been specifically designed to show the scheme ability to handle strong shock waves propagating in highly magnetized
7  environments.
8  Depending on the strength of the magnetic field, it can become a rather
9  arduous test leading to unphysical densities or pressures if the
10  divergence-free condition is not adequately controlled and the numerical
11  scheme does not introduce proper dissipation across curved shock fronts.
12 
13  In this example the initial conditions consists of a static medium with
14  uniform density \f$ \rho = 1 \f$ while pressure and magnetic field
15  are given by
16  \f[
17  p = \left\{\begin{array}{ll}
18  p_{\rm in} & \qquad\mathrm{for}\quad r < r_0 \\ \noalign{\medskip}
19  p_{\rm out} & \qquad\mathrm{otherwise} \\
20  \end{array}\right.\,;\qquad
21  \vec{B} = B_0\left( \sin\theta\cos\phi\hvec{x}
22  + \sin\theta\sin\phi\hvec{y}
23  + \cos\theta\hvec{z}\right)
24  \f]
25  The values \f$p_{\rm in},\, p_{\rm out},\, B_0,\, \theta,\, \phi,\, r_0\f$
26  are control parameters that can be changed from \c pluto.ini using,
27  respectively,
28 
29  -# <tt>g_inputParam[P_IN]</tt>
30  -# <tt>g_inputParam[P_OUT]</tt>
31  -# <tt>g_inputParam[BMAG]</tt>
32  -# <tt>g_inputParam[THETA]</tt>
33  -# <tt>g_inputParam[PHI]</tt>
34  -# <tt>g_inputParam[RADIUS]</tt>
35 
36  The over-pressurized region drives a blast wave delimited by an outer
37  fast forward shock propagating (nearly) radially while magnetic field
38  lines pile up behind the shock thus building a region of higher magnetic
39  pressure.
40  In these regions the shock becomes magnetically dominated and only weakly
41  compressive (\f$\delta\rho/\rho\sim 1.2\f$ in both cases).
42  The inner structure is delimited by an oval-shaped slow shock adjacent to a
43  contact discontinuity and the two fronts tend to blend together as the
44  propagation becomes perpendicular to the field lines.
45  The magnetic energy increases behind the fast shock and decreases
46  downstream of the slow shock.
47  The resulting explosion becomes highly anisotropic and magnetically confined.
48 
49  The available configurations are taken by collecting different setups
50  available in literature:
51 
52  <CENTER>
53  Conf.| GEOMETRY |DIM| T. STEP.|INTERP. |divB| BCK_FIELD | Ref
54  -----|-----------|---|---------| --------| ---|-----------|----------------
55  #01 |CARTESIAN | 2 | RK2 |LINEAR | CT | NO |[BS99]
56  #02 |CARTESIAN | 3 | RK2 |LINEAR | CT | NO |[Z04]
57  #03 |CYLINDRICAL| 2 | RK2 |LINEAR | CT | NO |[Z04] (*)
58  #04 |CYLINDRICAL| 2 | RK2 |LINEAR | CT | YES |[Z04] (*)
59  #05 |CARTESIAN | 3 | RK2 |LINEAR | CT | YES |[Z04]
60  #06 |CARTESIAN | 3 | ChTr |PARABOLIC| CT | NO |[GS08],[MT10]
61  #07 |CARTESIAN | 3 | ChTr |LINEAR | CT | NO |[GS08],[MT10]
62  #08 |CARTESIAN | 2 | ChTr |LINEAR | GLM| NO |[MT10] (2D version)
63  #09 |CARTESIAN | 3 | ChTr |LINEAR | GLM| NO |[GS08],[MT10]
64  #10 |CARTESIAN | 3 | RK2 |LINEAR | CT | YES |[Z04]
65  #11 |CARTESIAN | 3 | ChTr |LINEAR |EGLM| NO |[MT10] (**)
66  </CENTER>
67 
68  (*) Setups are in different coordinates and with different orientation
69  of magnetic field using constrained-transport MHD.
70  (**) second version in sec. 4.7
71 
72  The snapshot below show the solution for configuration #11.
73 
74  This setup also works with the \c BACKGROUND_FIELD spliting.
75  In this case the initial magnetic field is assigned in the
76  ::BackgroundField() function while the Init() function is used to
77  initialize the deviation to 0.
78 
79  \image html mhd_blast-rho.11.jpg "Density contours at the end of simulation (conf. #11)"
80  \image html mhd_blast-prs.11.jpg "Pressure contour at the end of simulation (conf. #11)"
81  \image html mhd_blast-pm.11.jpg "Magnetic pressure contours at the end of simulation (conf. #11)"
82 
83  \authors A. Mignone (mignone@ph.unito.it)
84  \date Sept 24, 2014
85 
86  \b References: \n
87  - [BS99]: "A Staggered Mesh Algorithm using High Order ...",
88  Balsara \& Spicer, JCP (1999) 149, 270 (Sec 3.2)
89  - [GS08]: "An unsplit Godunov method for ideal MHD via constrained
90  transport in three dimensions", Gardiner \& Stone, JCP (2008) 227, 4123
91  (Sec 5.5)
92  - [MT10] "A second-order unsplit Godunov scheme for cell-centered MHD:
93  The CTU-GLM scheme", Mignone \& Tzeferacos, JCP (2010) 229, 2117
94  (Sec 4.7)
95  - [Z04]: "A central-constrained transport scheme for ideal
96  magnetohydrodynamics", Ziegler, JCP (2004) 196, 393 (Sec. 4.6)
97 */
98 /* ///////////////////////////////////////////////////////////////////// */
99 #include "pluto.h"
100 
101 /* ********************************************************************* */
102 void Init (double *us, double x1, double x2, double x3)
103 /*
104  *
105  *
106  *
107  *********************************************************************** */
108 {
109  double r, theta, phi, B0;
110 
112  r = D_EXPAND(x1*x1, + x2*x2, + x3*x3);
113  r = sqrt(r);
114 
115  us[RHO] = 1.0;
116  us[VX1] = 0.0;
117  us[VX2] = 0.0;
118  us[VX3] = 0.0;
119  us[PRS] = g_inputParam[P_OUT];
120  if (r <= g_inputParam[RADIUS]) us[PRS] = g_inputParam[P_IN];
121 
122  theta = g_inputParam[THETA]*CONST_PI/180.0;
123  phi = g_inputParam[PHI]*CONST_PI/180.0;
124  B0 = g_inputParam[BMAG];
125 
126  us[BX1] = B0*sin(theta)*cos(phi);
127  us[BX2] = B0*sin(theta)*sin(phi);
128  us[BX3] = B0*cos(theta);
129 
130 
131  #if GEOMETRY == CARTESIAN
132  us[AX1] = 0.0;
133  us[AX2] = us[BX3]*x1;
134  us[AX3] = -us[BX2]*x1 + us[BX1]*x2;
135  #elif GEOMETRY == CYLINDRICAL
136  us[AX1] = us[AX2] = 0.0;
137  us[AX3] = 0.5*us[BX2]*x1;
138  #endif
139 
140  #if BACKGROUND_FIELD == YES
141  us[BX1] = us[BX2] = us[BX3] =
142  us[AX1] = us[AX2] = us[AX3] = 0.0;
143  #endif
144 
145 }
146 /* ********************************************************************* */
147 void Analysis (const Data *d, Grid *grid)
148 /*
149  *
150  *
151  *********************************************************************** */
152 {
153 
154 }
155 /* ********************************************************************* */
156 void UserDefBoundary (const Data *d, RBox *box, int side, Grid *grid)
157 /*
158  *
159  *********************************************************************** */
160 {
161 }
162 #if BACKGROUND_FIELD == YES
163 /* ********************************************************************* */
164 void BackgroundField (double x1, double x2, double x3, double *B0)
165 /*!
166  * Define the component of a static, curl-free background
167  * magnetic field.
168  *
169  *********************************************************************** */
170 {
171  static int first_call = 1;
172  double theta, phi;
173  static double sth,cth,sphi,cphi;
174 
175  if (first_call){
176  theta = g_inputParam[THETA]*CONST_PI/180.0;
177  phi = g_inputParam[PHI]*CONST_PI/180.0;
178  sth = sin(theta);
179  cth = cos(theta);
180  sphi = sin(phi);
181  cphi = cos(phi);
182  first_call = 0;
183  }
184  EXPAND(B0[IDIR] = g_inputParam[BMAG]*sth*cphi; ,
185  B0[JDIR] = g_inputParam[BMAG]*sth*sphi; ,
186  B0[KDIR] = g_inputParam[BMAG]*cth;)
187 
188 /*
189  theta = g_inputParam[THETA]*CONST_PI/180.0;
190  phi = g_inputParam[PHI]*CONST_PI/180.0;
191 
192  B0[IDIR] = g_inputParam[BMAG]*sin(theta)*cos(phi);
193  B0[JDIR] = g_inputParam[BMAG]*sin(theta)*sin(phi);
194  B0[KDIR] = g_inputParam[BMAG]*cos(theta);
195 */
196 
197 }
198 #endif
double g_gamma
Definition: globals.h:112
void UserDefBoundary(const Data *d, RBox *box, int side, Grid *grid)
Definition: init.c:98
#define PHI
#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 AX2
Definition: mod_defs.h:86
#define VX1
Definition: mod_defs.h:28
#define GAMMA
#define KDIR
Definition: pluto.h:195
#define BMAG
#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
#define P_OUT
#define BX3
Definition: mod_defs.h:27
PLUTO main header file.
#define RADIUS
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
#define P_IN
#define AX1
Definition: mod_defs.h:85
#define THETA
#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 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