PLUTO
init.c
Go to the documentation of this file.
1 #include "pluto.h"
2 
3 /* ********************************************************************* */
4 void Init (double *us, double x1, double x2, double x3)
5 /*
6  *
7  *
8  *
9  *********************************************************************** */
10 {
11  static int first_call = 1;
12  double Bx, By, Bz, B0;
13  double vx, vy, vz, vA;
14  double eta, w, kx, scrh;
15  double c,s;
16 
17  g_gamma = 4.0/3.0;
18 
19  B0 = eta = 1.0;
20  us[RHO] = 1.0;
21  us[PRS] = 1.0;
22 
23  w = us[RHO] + g_gamma*us[PRS]/(g_gamma - 1.0);
24  vA = B0*B0/(w + B0*B0*(1.0 + eta*eta));
25  vA /= 0.5*(1.0 + sqrt(1.0 - 4.0*eta*eta*vA*vA));
26  vA = sqrt(vA);
27 
28  #if DIMENSIONS == 1
29  c = 1.0;
30  s = 0.0;
31  kx = 2.0*CONST_PI*x1;
32  #elif DIMENSIONS == 2
33  c = 1.0/sqrt(2.0);
34  s = 1.0/sqrt(2.0);
35  kx = 2.0*CONST_PI*sqrt(2.0)*(c*x1 + s*x2);
36  #endif
37 
38 /* -------------------------------------------------
39  define 1D solution
40  ------------------------------------------------- */
41 
42  Bx = B0;
43  By = eta*B0*cos(kx);
44  Bz = eta*B0*sin(kx);
45 
46  vx = 0.0;
47  vy = -vA*By/B0;
48  vz = -vA*Bz/B0;
49 
50 /* -------------------------------------------------
51  rotate solution
52  ------------------------------------------------- */
53 
54  us[VX1] = vx*c - vy*s;
55  us[VX2] = vx*s + vy*c;
56  us[VX3] = vz;
57 
58  us[BX1] = Bx*c - By*s;
59  us[BX2] = Bx*s + By*c;
60  us[BX3] = Bz;
61 
62  us[AX1] = 0.0;
63  us[AX2] = 0.0;
64  us[AX3] = B0*((-x1*s + x2*c) - eta*sin(kx)/(2.0*CONST_PI*sqrt(2.0)));
65 
66  if (first_call == 1){
67  print1 ("vA = %18.12e\n",vA);
68  print1 ("T = %18.12e\n",c/vA);
69  first_call = 0;
70  }
71 /*
72 restart;
73 B[t] := eta*B[0]*cos(k*(c*x+s*y));
74 B[x] := B[0]*c - B[t]*s;
75 B[y] := B[0]*s + B[t]*c;
76 
77 A[z]:= B[0]*((-x*s+y*c) - eta*sin(k*(c*x+s*y))/k);
78 simplify( diff(A[z],y) - B[x]);
79 simplify(-diff(A[z],x) - B[y]);
80 */
81 
82 
83 }
84 /* ********************************************************************* */
85 void Analysis (const Data *d, Grid *grid)
86 /*
87  *
88  *
89  *********************************************************************** */
90 {
91 
92 }
93 #if PHYSICS == MHD
94 /* ************************************************************** */
95 void BACKGROUND_FIELD (real x1, real x2, real x3, real *B0)
96 /*
97  *
98  * PURPOSE
99  *
100  * Define the component of a static, curl-free background
101  * magnetic field.
102  *
103  *
104  * ARGUMENTS
105  *
106  * x1, x2, x3 (IN) coordinates
107  *
108  * B0 (OUT) vector component of the background field.
109  *
110  *
111  **************************************************************** */
112 {
113  B0[0] = 0.0;
114  B0[1] = 0.0;
115  B0[2] = 0.0;
116 }
117 #endif
118 
119 /* ********************************************************************* */
120 void UserDefBoundary (const Data *d, RBox *box, int side, Grid *grid)
121 /*!
122  * Assign user-defined boundary conditions.
123  *
124  * \param [in/out] d pointer to the PLUTO data structure containing
125  * cell-centered primitive quantities (d->Vc) and
126  * staggered magnetic fields (d->Vs, when used) to
127  * be filled.
128  * \param [in] box pointer to a RBox structure containing the lower
129  * and upper indices of the ghost zone-centers/nodes
130  * or edges at which data values should be assigned.
131  * \param [in] side specifies on which side boundary conditions need
132  * to be assigned. side can assume the following
133  * pre-definite values: X1_BEG, X1_END,
134  * X2_BEG, X2_END,
135  * X3_BEG, X3_END.
136  * The special value side == 0 is used to control
137  * a region inside the computational domain.
138  * \param [in] grid pointer to an array of Grid structures.
139  *
140  *********************************************************************** */
141 { }
142 
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
double real
Definition: pluto.h:488
void print1(const char *fmt,...)
Definition: amrPluto.cpp:511
#define RHO
Definition: mod_defs.h:19
tuple scrh
Definition: configure.py:200
static double *** eta[3]
Definition: res_functions.c:94
#define AX2
Definition: mod_defs.h:86
#define VX1
Definition: mod_defs.h:28
Definition: structs.h:78
#define AX3
Definition: mod_defs.h:87
static double Bx
Definition: hlld.c:62
tuple c
Definition: menu.py:375
#define s
#define BX3
Definition: mod_defs.h:27
PLUTO main header file.
Definition: structs.h:30
#define AX1
Definition: mod_defs.h:85
void BACKGROUND_FIELD(real x1, real x2, real x3, real *B0)
Definition: init.c:95
#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
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