cholla
global.h
1 
5 #ifndef GLOBAL_H
6 #define GLOBAL_H
7 
8 #ifdef COOLING_CPU
9 #include <gsl/gsl_spline.h>
10 #include <gsl/gsl_spline2d.h>
11 #endif
12 
13 #ifndef FLOAT_TYPEDEF
14 #error Float precision must be defined in the Makefile
15 #endif
16 typedef FLOAT_TYPEDEF Real;
17 
18 #define MAXLEN 100
19 #define TINY_NUMBER 1.0e-20
20 #define PI 3.141592653589793
21 #define MP 1.672622e-24 // mass of proton, grams
22 #define KB 1.380658e-16 // boltzmann constant, cgs
23 //#define GN 6.67259e-8 // gravitational constant, cgs
24 #define GN 4.49451e-18 // gravitational constant, kpc^3 / M_sun / kyr^2
25 
26 #define MYR 31.536e12 //Myears in secs
27 #define KPC 3.086e16 // kpc in km
28 #define G_COSMO 4.300927161e-06; // gravitational constant, kpc km^2 s^-2 Msun^-1
29 #define MSUN_CGS 1.98847e33; //Msun in gr
30 #define KPC_CGS 3.086e21; //kpc in cm
31 #define KM_CGS 1e5; //km in cm
32 
33 #define TIME_UNIT 3.15569e10 // 1 kyr in s
34 #define LENGTH_UNIT 3.08567758e21 // 1 kpc in cm
35 #define MASS_UNIT 1.98855e33 // 1 solar mass in grams
36 #define DENSITY_UNIT (MASS_UNIT/(LENGTH_UNIT*LENGTH_UNIT*LENGTH_UNIT))
37 #define VELOCITY_UNIT (LENGTH_UNIT/TIME_UNIT)
38 #define ENERGY_UNIT (DENSITY_UNIT*VELOCITY_UNIT*VELOCITY_UNIT)
39 #define PRESSURE_UNIT (DENSITY_UNIT*VELOCITY_UNIT*VELOCITY_UNIT)
40 #define SP_ENERGY_UNIT (VELOCITY_UNIT*VELOCITY_UNIT)
41 
42 #define LOG_FILE_NAME "run_output.log"
43 
44 //Conserved Floor Values
45 #define TEMP_FLOOR 1e-3
46 #define DENS_FLOOR 1e-5
47 
48 //Parameter for Enzo dual Energy Condition
49 #define DE_ETA_1 0.001 //Ratio of U to E for wich Inetrnal Energy is used to compute the Pressure
50 #define DE_ETA_2 0.035 //Ratio of U to max(E_local) used to select wich Internal Energy is used for the update.
51 
52 // Maximum time step for cosmological simulations
53 #define MAX_DELTA_A 0.001
54 #define MAX_EXPANSION_RATE 0.01 // Limit delta(a)/a
55 
56 #ifdef COOLING_GRACKLE
57 #define NSCALARS 7
58 #else
59 #ifdef SCALAR
60 // Set Number of scalar fields when not using grackle
61 #define NSCALARS 1
62 #endif//SCALAR
63 #endif//COOLING_GRACKLE
64 
65 // Inital Chemistry fractions
66 #define INITIAL_FRACTION_HI 0.75984603480
67 #define INITIAL_FRACTION_HII 1.53965115054e-4
68 #define INITIAL_FRACTION_HEI 0.23999999997
69 #define INITIAL_FRACTION_HEII 9.59999999903e-15
70 #define INITIAL_FRACTION_HEIII 9.59999999903e-18
71 #define INITIAL_FRACTION_ELECTRON 1.53965115054e-4
72 #define INITIAL_FRACTION_METAL 1.00000000000e-10
73 
74 
75 #ifdef GRAVITY
76 #ifdef GRAVITY_5_POINTS_GRADIENT
77 #define N_GHOST_POTENTIAL 3 // 3 ghost cells are needed for 5 point gradient, ( one is for the CIC interpolation of the potential )
78 #else
79 #define N_GHOST_POTENTIAL 2 // 2 ghost cells are needed for first order gradient, ( one is for the CIC interpolation of the potential )
80 #endif
81 #ifdef GRAVITY_LONG_INTS
82 typedef long int grav_int_t;
83 #else
84 typedef int grav_int_t;
85 #endif//GRAVITY_LONG_INTS
86 #endif
87 
88 #ifdef PARTICLES
89 #ifdef PARTICLES_LONG_INTS
90 typedef long int part_int_t;
91 #else
92 typedef int part_int_t
93 #endif//PARTICLES_LONG_INTS
94 
95 #include <vector>
96 typedef std::vector<Real> real_vector_t;
97 typedef std::vector<part_int_t> int_vector_t;
98 #ifdef MPI_CHOLLA
99 // Constants for the inital size of the buffers for particles transfer
100 // and the number of data transfered for each particle
101 extern int N_PARTICLES_TRANSFER;
102 extern int N_DATA_PER_PARTICLE_TRANSFER;
103 #endif//MPI_CHOLLA
104 
105 #ifdef AVERAGE_SLOW_CELLS
106 #define SLOW_FACTOR 10
107 #endif//AVERAGE_SLOW_CELLS
108 
109 #endif//PARTICLES
110 
111 
112 #define SIGN(a) ( ((a) < 0.) ? -1. : 1. )
113 
114 
115 
116 /* Global variables */
117 extern Real gama; // Ratio of specific heats
118 extern Real C_cfl; // CFL number (0 - 0.5)
119 extern Real t_comm;
120 extern Real t_other;
121 
122 #ifdef COOLING_CPU
123 extern gsl_interp_accel *acc;
124 extern gsl_interp_accel *xacc;
125 extern gsl_interp_accel *yacc;
126 extern gsl_spline *highT_C_spline;
127 extern gsl_spline2d *lowT_C_spline;
128 extern gsl_spline2d *lowT_H_spline;
129 #endif
130 #ifdef COOLING_GPU
131 extern float *cooling_table;
132 extern float *heating_table;
133 #endif
134 
137 extern void Set_Gammas(Real gamma_in);
138 
141 extern double get_time(void);
142 
145 extern int sgn(Real x);
146 
147 #ifndef CUDA
148 
150 extern Real calc_eta(Real cW[], Real gamma);
151 #endif
152 
153 
155 {
156  int nx;
157  int ny;
158  int nz;
159  double tout;
160  double outstep;
161  int n_steps_output;
162  Real gamma;
163  char init[MAXLEN];
164  int nfile;
165  int nfull;
166  Real xmin;
167  Real ymin;
168  Real zmin;
169  Real xlen;
170  Real ylen;
171  Real zlen;
172  int xl_bcnd;
173  int xu_bcnd;
174  int yl_bcnd;
175  int yu_bcnd;
176  int zl_bcnd;
177  int zu_bcnd;
178 #ifdef MPI_CHOLLA
179  int xlg_bcnd;
180  int xug_bcnd;
181  int ylg_bcnd;
182  int yug_bcnd;
183  int zlg_bcnd;
184  int zug_bcnd;
185 #endif /*MPI_CHOLLA*/
186  char custom_bcnd[MAXLEN];
187  char outdir[MAXLEN];
188  char indir[MAXLEN]; //Folder to load Initial conditions from
189  Real rho;
190  Real vx;
191  Real vy;
192  Real vz;
193  Real P;
194  Real A;
195  Real rho_l;
196  Real v_l;
197  Real P_l;
198  Real rho_r;
199  Real v_r;
200  Real P_r;
201  Real diaph;
202 #ifdef ROTATED_PROJECTION
203  int nxr;
204  int nzr;
205  Real delta;
206  Real theta;
207  Real phi;
208  Real Lx;
209  Real Lz;
210  int n_delta;
211  Real ddelta_dt;
212  int flag_delta;
213 #endif /*ROTATED_PROJECTION*/
214 #ifdef COSMOLOGY
215  Real H0;
216  Real Omega_M;
217  Real Omega_L;
218  Real Init_redshift;
219  Real End_redshift;
220  char scale_outputs_file[MAXLEN]; //File for the scale_factor output values for cosmological simulations
221 #endif //COSMOLOGY
222 #ifdef TILED_INITIAL_CONDITIONS
223  Real tile_length;
224 #endif //TILED_INITIAL_CONDITIONS
225 
226 #ifdef SET_MPI_GRID
227  // Set the MPI Processes grid [n_proc_x, n_proc_y, n_proc_z]
228  int n_proc_x;
229  int n_proc_y;
230  int n_proc_z;
231 #endif
232 };
233 
234 
237 extern void parse_params (char *param_file, struct parameters * parms);
238 
239 
240 #endif //GLOBAL_H
Definition: global.h:154