PLUTO
init.c
Go to the documentation of this file.
1 /* ///////////////////////////////////////////////////////////////////// */
2 /*!
3  \file
4  \brief Propagation of a conduction front.
5 
6  The problem sets the initial condition for a propagating conduction front
7  for which an analytical solution exists (Reale 1995).
8 
9  The equation
10  \f[
11  \frac{\partial T}{\partial t} = a\frac{\partial}{\partial s}
12  \left(T^n\frac{\partial T}{\partial s}\right)
13  \f]
14  has the solution
15  \f[
16  T = T_c\left(1 - \frac{s^2}{s_f^2}\right)^{1/n}
17  \f]
18  where
19  \f[
20  T_c = \left(\frac{Q^2}{at}\right)^{1/(n+2)}
21  \left(\frac{n}{2(n+2)}\zeta_0^2\right)^{1/n}\,,
22  \quad\quad\quad
23  s_f = (aQ^nt)^{1/(n+2)}\zeta_0\,,
24  \quad\quad\quad
25  \zeta_0 = \left[\frac{(n+2)^{1+n}2^{1-n}}{n\pi^{n/2}}\right]^{1/(n+2)}
26  \left[\frac{\Gamma(1/2 + 1/n)}{\Gamma(1/n)}\right]^{n/(n+2)}\,,
27  \f]
28  \f$Q\f$ is the integral over the whole space, and \f$\Gamma\f$ is the
29  gamma function.
30 
31  The setup is built to compare the numerical solution with the analytical one.
32 
33  \image html 1D-hd-exp.jpg "Evolution of the TC front in the 1D case; numerical solution (points) and analytical (lines)".
34 
35  Configurations (\c EXPLICIT and \c STS):
36  - #01-#04: 1D cartesian
37  - #05-#06: 2D cartesian
38  - #07-#09: 3D cartesian
39  - #10-#11: 3D polar
40  - #12-#13: 3D spherical
41 
42  \author A. Mignone (mignone@ph.unito.it)
43  \date July 09, 2014
44 
45  \b References:
46  - Section 4 of Reale, F. Computer Physics Communications (1995), 86, 13
47 
48 */
49 /* ///////////////////////////////////////////////////////////////////// */
50 
51 
52 #include "pluto.h"
53 /* ********************************************************************* */
54 void Init (double *us, double x1, double x2, double x3)
55 /*
56  *********************************************************************** */
57 {
58 #if DIMENSIONS == 1
59  double n0, k0, Q, t0, j0, xf, Tc, T0;
60  double G1_2p1_n, G1_n;
61 
62  n0 = 5./2.;
63  k0 = 4.412;
64  Q = 1.2e15;
65  t0 = 0.1;
66 
67  G1_2p1_n = 1.068628702119319;
68  G1_n = 2.218159543757688;
69 
70  j0 = pow((pow(n0+2.,1.+n0)*pow(2.,1.-n0))/(n0*pow(CONST_PI,n0/2.)),1./(n0+2.))*pow(G1_2p1_n/G1_n,n0/(n0+2.));
71  xf = pow(k0*pow(Q,n0)*t0, 1./(n0+2.))*j0/1.0e8;
72  Tc = pow(Q*Q/(k0*t0), 1./(n0+2.))*pow(n0*j0*j0/(2*(n0+2.)), 1./n0);
73  T0 = 6.05736872274111e7;
74 
75  us[RHO] = 1.0;
76  us[VX1] = 0.0;
77  us[VX2] = 0.0;
78  us[VX3] = 0.0;
79 
80  if ((1.0 - x1*x1/xf/xf) < 1.0e-20){
81  us[PRS] = us[RHO]*Tc/T0*pow(1.0e-20,0.4);
82  }else{
83  us[PRS] = us[RHO]*Tc/T0*pow( (1.0 - x1*x1/xf/xf) ,0.4);
84  }
85  us[TRC] = 0.0;
86 
87  #if PHYSICS == MHD
88  us[BX1] = 1.0;
89  us[BX2] = 0.0;
90  us[BX3] = 0.0;
91  #endif
92 
93 #else
94 
95  double n0, k0, Q, t0, j0, xf, Tc, T0;
96  double G5_2p1_n, G1p1_n, G3_2, x;
97 
98  n0 = 5./2.;
99  k0 = 4.412;
100  Q = 1.2e30;
101  t0 = 0.1;
102 
103  G5_2p1_n = 1.827355080624036;
104  G1p1_n = 0.887263817503075;
105  G3_2 = 0.886226925452758;
106 
107  j0 = pow((3.*n0+2.)/(pow(2., n0-1.)*n0*pow(CONST_PI,n0)),1./(3.*n0+2.))*pow(G5_2p1_n/G1p1_n/G3_2,n0/(3.*n0+2.));
108  xf = pow(k0*pow(Q,n0)*t0, 1./(3.*n0+2.))*j0/1.e8;
109  Tc = j0*j0*j0/xf/xf/xf*1.e-24*Q*pow(n0*j0*j0/(2.*(3.*n0+2.)), 1./n0);
110  T0 = 6.05736872274111e7;
111 
112  #if GEOMETRY == CARTESIAN || GEOMETRY == CYLINDRICAL
113  x = sqrt(D_EXPAND(x1*x1, + x2*x2, + x3*x3));
114  #elif GEOMETRY == POLAR
115  x = sqrt(D_EXPAND(x1*x1, + 0.0, + x3*x3));
116  #elif GEOMETRY == SPHERICAL
117  x = x1;
118  #endif
119 
120 
121  us[RHO] = 1.0;
122  us[VX1] = 0.0;
123  us[VX2] = 0.0;
124  us[VX3] = 0.0;
125  if ((1.0 - x*x/xf/xf) < 1.0e-20){
126  #if GEOMETRY == SPHERICAL
127  us[PRS] = us[RHO]*Tc/T0*pow(1.0e-8,0.4);
128  #else
129  us[PRS] = us[RHO]*Tc/T0*pow(1.0e-20,0.4);
130  #endif
131  }else{
132  us[PRS] = us[RHO]*Tc/T0*pow( (1.0 - x*x/xf/xf) ,0.4);
133  }
134  us[TRC] = 0.0;
135 #endif
136 }
137 
138 /* ********************************************************************* */
139 void Analysis (const Data *d, Grid *grid)
140 /*
141  *
142  *
143  *********************************************************************** */
144 {
145 }
146 /* ********************************************************************* */
147 void UserDefBoundary (const Data *d, RBox *box, int side, Grid *grid)
148 /*
149  *
150  *********************************************************************** */
151 {
152  int i, j, k, nv;
153  double x1, x2, x3;
154 
155  if (side == 0) { /* -- check solution inside domain -- */
156  DOM_LOOP(k,j,i){
157  EXPAND(d->Vc[VX1][k][j][i] = 0.0; ,
158  d->Vc[VX2][k][j][i] = 0.0; ,
159  d->Vc[VX3][k][j][i] = 0.0;)
160  }
161  #if ENTROPY_SWITCH == YES
162  TOT_LOOP(k,j,i) d->flag[k][j][i] |= FLAG_ENTROPY;
163  #endif
164  }
165 
166  if (side == X1_BEG){ /* -- X1_BEG boundary -- */
167  if (box->vpos == CENTER){
168  BOX_LOOP(box,k,j,i){
169  x1 = grid[IDIR].x[i];
170  d->Vc[RHO][k][j][i] = d->Vc[RHO][k][j][2*IBEG - i - 1];
171  EXPAND(
172  d->Vc[VX1][k][j][i] = -d->Vc[VX1][k][j][2*IBEG - i - 1]; ,
173  d->Vc[VX2][k][j][i] = d->Vc[VX2][k][j][2*IBEG - i - 1]; ,
174  d->Vc[VX3][k][j][i] = d->Vc[VX3][k][j][2*IBEG - i - 1];
175  )
176  d->Vc[PRS][k][j][i] = d->Vc[PRS][k][j][2*IBEG - i - 1];
177  #if PHYSICS == MHD
178  EXPAND(
179  d->Vc[BX1][k][j][i] = d->Vc[BX1][k][j][2*IBEG - i - 1]; ,
180  d->Vc[BX2][k][j][i] = d->Vc[BX2][k][j][2*IBEG - i - 1]; ,
181  d->Vc[BX3][k][j][i] = d->Vc[BX3][k][j][2*IBEG - i - 1];
182  )
183  #endif
184  }
185  }
186  }
187 
188  if (side == X1_END){ /* -- X1_END boundary -- */
189  X1_END_LOOP(k,j,i){}
190  }
191 
192  if (side == X2_BEG){ /* -- X2_BEG boundary -- */
193  X2_BEG_LOOP(k,j,i){}
194  }
195 
196  if (side == X2_END){ /* -- X2_END boundary -- */
197  X2_END_LOOP(k,j,i){}
198  }
199 
200  if (side == X3_BEG){ /* -- X3_BEG boundary -- */
201  X3_BEG_LOOP(k,j,i){}
202  }
203 
204  if (side == X3_END) { /* -- X3_END boundary -- */
205  X3_END_LOOP(k,j,i){}
206  }
207 }
208 
#define X3_BEG
Boundary region at X3 beg.
Definition: pluto.h:150
#define X1_BEG
Boundary region at X1 beg.
Definition: pluto.h:146
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
#define CENTER
Definition: pluto.h:200
int vpos
Location of the variable inside the cell.
Definition: structs.h:359
#define RHO
Definition: mod_defs.h:19
#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
#define X3_END_LOOP(k, j, i)
Definition: macros.h:52
#define TRC
Definition: pluto.h:581
#define X1_END
Boundary region at X1 end.
Definition: pluto.h:147
#define VX1
Definition: mod_defs.h:28
#define X2_BEG_LOOP(k, j, i)
Definition: macros.h:47
unsigned char *** flag
Pointer to a 3D array setting useful integration flags that are retrieved during integration.
Definition: structs.h:55
#define X2_END_LOOP(k, j, i)
Definition: macros.h:51
#define TOT_LOOP(k, j, i)
Definition: macros.h:44
#define FLAG_ENTROPY
Update pressure using entropy equation.
Definition: pluto.h:182
#define IDIR
Definition: pluto.h:193
#define X2_END
Boundary region at X2 end.
Definition: pluto.h:149
Definition: structs.h:78
int j
Definition: analysis.c:2
int k
Definition: analysis.c:2
double * x
Definition: structs.h:80
#define X1_END_LOOP(k, j, i)
Definition: macros.h:50
#define BX3
Definition: mod_defs.h:27
#define X3_END
Boundary region at X3 end.
Definition: pluto.h:151
PLUTO main header file.
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
int i
Definition: analysis.c:2
#define BX1
Definition: mod_defs.h:25
#define VX3
Definition: mod_defs.h:30
#define CONST_PI
.
Definition: pluto.h:269
#define X2_BEG
Boundary region at X2 beg.
Definition: pluto.h:148
#define BX2
Definition: mod_defs.h:26
Definition: structs.h:346
#define X3_BEG_LOOP(k, j, i)
Definition: macros.h:48
long int IBEG
Lower grid index of the computational domain in the the X1 direction for the local processor...
Definition: globals.h:35
static double t0
Definition: failsafe.c:5
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