PLUTO
init.c File Reference

2D Blast wave problem with thermal conduction. More...

#include "pluto.h"
Include dependency graph for init.c:

Go to the source code of this file.

Functions

void Init (double *us, 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

2D Blast wave problem with thermal conduction.

Sets the initial conditions for a 2D Blast wave problem with thermal conduction. For the HD case:

\[ \rho = \rho_{\rm out} + \frac{\rho_{\rm in} - \rho_{\rm out}}{\cosh\left[10(r/r_0)^{10}\right]}\,, \quad\quad\quad T = \left\{\begin{array}{ll} T_{\rm in} & \quad{\rm for} \quad r \le r_0 \\ \noalign{\medskip} T_{\rm out} & \quad{\rm for} \quad r > r_0 \end{array}\right.\,, \]

where $r_0$ is the cloud radius.

Input Parameters are that are read from pluto.ini are

  • g_inputParam[T_IN], g_inputParam[T_OUT]: Temperature inside and outside the circle (in K);
  • g_inputParam[RHO_IN], g_inputParam[RHO_OUT]: Density inside and outside (in dimensionless units);
  • g_inputParam[BMAG]: Magnetic field strength (in Gauss);
  • g_inputParam[THETA]: Orientation of the field (in degrees);

Configurations:

  • #01-04 have the same initial condition and are done either with an explicit time stepping or STS, HD and MHD and do not show evidence for any numerical artifact.
  • #05-06, on the other hand, show that STS suffers from some kind of unstable behavior due to the flux limiter switching from classical to saturated regimes. Only small CFL (0.1 or less) or larger values of STS_NU (e.g 0.05) mitigate the problem. Future improvement (RKC/RKL ?) should address this issue.
Author
A. Mignone (migno.nosp@m.ne@p.nosp@m.h.uni.nosp@m.to.i.nosp@m.t)
Date
Aug 27, 2015

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 89 of file init.c.

94 { }
void Init ( double *  us,
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 42 of file init.c.

47 {
48  static int first_call=1;
49  double r, r0, mu, T, prs_ref, prof;
50 
51  mu = 1.26;
52  g_gamma = 5.0/3.0;
53 
55 
56 /* ----------------------------------------------
57  Use c.g.s units
58  ---------------------------------------------- */
59 
60  r = sqrt(EXPAND(x1*x1, + x2*x2, + x3*x3));
61  r0 = 1.0; /* -- cloud radius -- */
62  prof = 1.0/cosh(10.0*pow(r/r0,10));
63 
64  us[VX1] = us[VX2] = 0.0;
65  T = g_inputParam[T_OUT] + (g_inputParam[T_IN] - g_inputParam[T_OUT])*(r <= r0);
67 
68  us[PRS] = T*us[RHO]/KELVIN;
69 
70  #if PHYSICS == MHD
71  us[BX1] = g_inputParam[BMAG]*cos(g_inputParam[THETA]*CONST_PI/180.0);
72  us[BX2] = g_inputParam[BMAG]*sin(g_inputParam[THETA]*CONST_PI/180.0);
73  us[BX3] = 0.0;
74 
75  us[BX1] /= sqrt(prs_ref*4.0*CONST_PI);
76  us[BX2] /= sqrt(prs_ref*4.0*CONST_PI);
77  us[BX3] /= sqrt(prs_ref*4.0*CONST_PI);
78 
79  us[AX1] = us[AX2] = 0.0;
80  us[AX3] = x2*us[BX1] - x1*us[BX2];
81  #endif
82 
83  #ifdef GLM_MHD
84  us[PSI_GLM] = 0.0;
85  #endif
86 
87 }
tuple T
Definition: Sph_disk.py:33
double g_gamma
Definition: globals.h:112
#define UNIT_DENSITY
Unit density in gr/cm^3.
Definition: pluto.h:369
#define VX2
Definition: mod_defs.h:29
#define RHO_IN
#define RHO
Definition: mod_defs.h:19
#define PSI_GLM
Definition: mod_defs.h:34
#define AX2
Definition: mod_defs.h:86
#define T_OUT
#define RHO_OUT
#define KELVIN
Definition: pluto.h:401
#define VX1
Definition: mod_defs.h:28
#define BMAG
#define UNIT_VELOCITY
Unit velocity in cm/sec.
Definition: pluto.h:377
#define AX3
Definition: mod_defs.h:87
double g_inputParam[32]
Array containing the user-defined parameters.
Definition: globals.h:131
#define BX3
Definition: mod_defs.h:27
#define AX1
Definition: mod_defs.h:85
#define THETA
#define BX1
Definition: mod_defs.h:25
#define CONST_PI
.
Definition: pluto.h:269
#define T_IN
#define BX2
Definition: mod_defs.h:26
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.

Definition at line 97 of file init.c.

101 {
102  static int first_call = 1;
103  int i, j, k, nv;
104  static double vin[256];
105 
106  if (side == X2_BEG){ /* -- X2_BEG boundary -- */
107  if (first_call){
108  Init(vin, 0.0, -10.0, 0.0);
109  first_call = 0;
110  }
111  if (box->vpos == CENTER){
112  for (nv = 0; nv < NVAR; nv++ ) BOX_LOOP(box,k,j,i){
113  d->Vc[nv][k][j][i] = vin[nv];
114  }
115  }
116  }
117 }
#define CENTER
Definition: pluto.h:200
int vpos
Location of the variable inside the cell.
Definition: structs.h:359
#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
int j
Definition: analysis.c:2
int k
Definition: analysis.c:2
int i
Definition: analysis.c:2
#define X2_BEG
Boundary region at X2 beg.
Definition: pluto.h:148
#define NVAR
Definition: pluto.h:609
void Init(double *v, double x1, double x2, double x3)
Definition: init.c:17

Here is the call graph for this function: