PLUTO
init.c
Go to the documentation of this file.
1 /* ///////////////////////////////////////////////////////////////////// */
2 /*!
3  \file
4  \brief Relativistic jet propagation.
5 
6  This problem sets initial and boundary conditions for a jet
7  propagating into a uniform medium with constant density and pressure.
8  The computation can be carried using \c CYLINDRICAL or \c SPHERICAL
9  coordinates.
10  In the first case, the jet enters at the lower z-boundary with speed
11  \f$ v_z = \beta\f$ while in the second case, a conical beam with a
12  small aperture (\f$\theta = 5^\circ\f$) is injected with the same
13  speed from the lower radial boundary.
14  At the border of the nozzle, jet values are smoothly joined with
15  ambient values using the Profile() function
16  (in the current setting the profile is a sharp transition).
17  The jet is pressure-matched so that the beam and ambient pressure
18  coincide.
19 
20  The configuration is defined in terms of the following parameters:
21 
22  -# <tt>g_inputParam[BETA]</tt>: the jet velocity;
23  -# <tt>g_inputParam[RHO_IN]</tt>: the jet density;
24  -# <tt>g_inputParam[RHO_OUT]</tt>: the ambient density.
25  -# <tt>g_inputParam[PRESS_IN]</tt>: the jet pressure (also equal to ambient
26  pressure)
27 
28  defined in \c pluto.ini.
29  The \c TAUB equation of state is used.
30 
31  - Configurations #01 and #02 use \c CYLINDRICAL coordinates;
32  - Configuration #03 employs \c SPHERICAL coordinates (see snapshot below)
33 
34  \image html rhd_jet.03.jpg "Density (log) for configuration #03 at t=200"
35 
36  \author A. Mignone (mignone@ph.unito.it)
37  \date Sept 18, 2014
38 */
39 /* ///////////////////////////////////////////////////////////////////// */
40 #include "pluto.h"
41 
42 static double Profile(double r, int nv);
43 static void GetJetValues (double *vjet);
44 
45 /* ********************************************************************* */
46 void Init (double *v, double x1, double x2, double x3)
47 /*
48  *
49  *
50  *
51  *********************************************************************** */
52 {
53  double scrh;
54  #if EOS == IDEAL
55  g_gamma = 5.0/3.0;
56  #endif
57 
58  v[RHO] = g_inputParam[RHO_OUT];
59  v[VX1] = 0.0;
60  v[VX2] = 0.0;
61  v[PRS] = g_inputParam[PRESS_IN];
62 
63  g_smallPressure = v[PRS]/500.0;
64 }
65 /* ********************************************************************* */
66 void Analysis (const Data *d, Grid *grid)
67 /*
68  *
69  *
70  *********************************************************************** */
71 {
72 
73 }
74 /* ********************************************************************* */
75 void UserDefBoundary (const Data *d, RBox *box, int side, Grid *grid)
76 /*
77  *
78  *
79  *********************************************************************** */
80 {
81  int nv, i, j, k;
82  double r, vjet[NVAR], vout[NVAR];
83 
84  #if GEOMETRY == SPHERICAL
85  if (side == X1_BEG){
86  GetJetValues(vjet);
87  X1_BEG_LOOP(k,j,i){
88  VAR_LOOP(nv) vout[nv] = d->Vc[nv][k][j][2*IBEG-i-1];
89  vout[VX2] *= -1.0;
90 
91  r = grid[JDIR].x[j];
92  VAR_LOOP(nv)
93  d->Vc[nv][k][j][i] = vout[nv] + (vjet[nv] - vout[nv])*Profile(r,nv);
94  }
95  }
96  #endif
97 
98  #if GEOMETRY == CYLINDRICAL || GEOMETRY == CARTESIAN
99  if (side == X2_BEG){
100  GetJetValues(vjet);
101  X2_BEG_LOOP(k,j,i){
102  VAR_LOOP(nv) vout[nv] = d->Vc[nv][k][2*JBEG-j-1][i];
103  vout[VX2] *= -1.0;
104 
105  r = grid[IDIR].x[i];
106  for (nv = 0; nv < NVAR; nv++)
107  d->Vc[nv][k][j][i] = vout[nv] + (vjet[nv] - vout[nv])*Profile(r,nv);
108  }
109  }
110  #endif
111 }
112 
113 /* ********************************************************************* */
114 void GetJetValues (double *vjet)
115 /*
116  *
117  *
118  *********************************************************************** */
119 {
120  vjet[RHO] = g_inputParam[RHO_IN];
121  #if GEOMETRY == CYLINDRICAL || GEOMETRY == CARTESIAN
122  vjet[VX1] = 0.0;
123  vjet[VX2] = g_inputParam[BETA];
124  #elif GEOMETRY == SPHERICAL
125  vjet[VX1] = g_inputParam[BETA];
126  vjet[VX2] = 0.0;
127  #endif
128  vjet[PRS] = g_inputParam[PRESS_IN];
129 }
130 
131 /* ********************************************************************* */
132 double Profile(double r, int nv)
133 /*
134  *
135  *
136  *********************************************************************** */
137 {
138  int xn = 14;
139  double r0 = 1.0;
140 
141  if (nv == RHO) r0 = 1.1;
142 
143  #if GEOMETRY == SPHERICAL
144  r0 = 5.0/180.0*CONST_PI;
145  #endif
146  return 1.0/cosh(pow(r/r0,xn));
147 }
#define X1_BEG
Boundary region at X1 beg.
Definition: pluto.h:146
double g_gamma
Definition: globals.h:112
void UserDefBoundary(const Data *d, RBox *box, int side, Grid *grid)
Definition: init.c:98
#define VX2
Definition: mod_defs.h:29
#define BETA
#define RHO_IN
#define RHO
Definition: mod_defs.h:19
tuple scrh
Definition: configure.py:200
double **** Vc
The main four-index data array used for cell-centered primitive variables.
Definition: structs.h:31
double g_smallPressure
Small value for pressure fix.
Definition: globals.h:110
#define RHO_OUT
#define VX1
Definition: mod_defs.h:28
#define X2_BEG_LOOP(k, j, i)
Definition: macros.h:47
#define VAR_LOOP(n)
Definition: macros.h:226
#define IDIR
Definition: pluto.h:193
Definition: structs.h:78
double g_inputParam[32]
Array containing the user-defined parameters.
Definition: globals.h:131
#define PRESS_IN
int j
Definition: analysis.c:2
int k
Definition: analysis.c:2
double * x
Definition: structs.h:80
PLUTO main header file.
#define X1_BEG_LOOP(k, j, i)
Definition: macros.h:46
Definition: structs.h:30
int i
Definition: analysis.c:2
void GetJetValues(double, double *)
Definition: init.c:264
#define CONST_PI
.
Definition: pluto.h:269
#define X2_BEG
Boundary region at X2 beg.
Definition: pluto.h:148
#define JDIR
Definition: pluto.h:194
long int JBEG
Lower grid index of the computational domain in the the X2 direction for the local processor...
Definition: globals.h:39
#define NVAR
Definition: pluto.h:609
Definition: structs.h:346
long int IBEG
Lower grid index of the computational domain in the the X1 direction for the local processor...
Definition: globals.h:35
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
static double Profile(double r, int nv)
Definition: init.c:132