GADGET-4
constants.h
Go to the documentation of this file.
1/*******************************************************************************
2 * \copyright This file is part of the GADGET4 N-body/SPH code developed
3 * \copyright by Volker Springel. Copyright (C) 2014-2020 by Volker Springel
4 * \copyright (vspringel@mpa-garching.mpg.de) and all contributing authors.
5 *******************************************************************************/
6
12#ifndef CONSTANTS_H
13#define CONSTANTS_H
14
15#define GADGET_VERSION "4.0" /* code version string */
16
17#define FILEFORMAT_LEGACY1 1
18#define FILEFORMAT_LEGACY2 2
19#define FILEFORMAT_HDF5 3
20
21#define MODE_LOCAL_PARTICLES 0
22#define MODE_IMPORTED_PARTICLES 1
23#define MODE_DEFAULT 2
24#define MODE_LOCAL_NO_EXPORT 3
25
26#define FIRST_HALF_STEP 0
27#define SECOND_HALF_STEP 1
28
29#define FLAG_OUTSIDE 0
30#define FLAG_INSIDE 1
31#define FLAG_BOUNDARYOVERLAP 2
32
33#define LOW_MESH 0 /* low-res mesh selector */
34#define HIGH_MESH 1 /* high-res mesh selector */
35
36#define MAX_THREADS 128
37
38#ifndef DIRECT_SUMMATION_THRESHOLD
39#define DIRECT_SUMMATION_THRESHOLD 500
40#endif
41
42#define NUMBER_OF_MEASUREMENTS_TO_RECORD 6
43
44#define MAX_FIRST_ELEMENTS_CONSIDERED \
45 5 /* This sets the number of lowest loaded tasks to be considered for assignment of next domain patch */
46
47#define COMMBUFFERSIZE (32 * 1024LL * 1024LL)
48
49#ifndef MPI_MESSAGE_SIZELIMIT_IN_MB
50#define MPI_MESSAGE_SIZELIMIT_IN_MB 200
51#endif
52
53#define MPI_MESSAGE_SIZELIMIT_IN_BYTES ((MPI_MESSAGE_SIZELIMIT_IN_MB)*1024LL * 1024LL)
54
55#ifndef M_PI
56#define M_PI 3.14159265358979323846
57#endif
58
59#define TO_MBYTE_FAC (1.0 / (1024.0 * 1024.0))
60
61#ifndef LIGHTCONE_ALLOC_FAC
62#define LIGHTCONE_ALLOC_FAC 0.1
63#endif
64
65#ifndef LIGHTCONE_MASSMAP_ALLOC_FAC
66#define LIGHTCONE_MASSMAP_ALLOC_FAC 1.0
67#endif
68
69#ifndef LIGHTCONE_MAX_FILLFACTOR
70#define LIGHTCONE_MAX_FILLFACTOR 0.9
71#endif
72
73#ifndef ALLOC_TOLERANCE
74#define ALLOC_TOLERANCE 0.2
75#endif
76
77#define ALLOC_STARBH_ROOM 0.02
78
79#define MAX_FLOAT_NUMBER 1e37
80#define MIN_FLOAT_NUMBER 1e-37
81#define MAX_DOUBLE_NUMBER 1e306
82#define MIN_DOUBLE_NUMBER 1e-306
83#define SMALLNUM 1e-60
84
85#ifdef DOUBLEPRECISION
86#if(DOUBLEPRECISION == 2)
87#define MAX_REAL_NUMBER MAX_FLOAT_NUMBER
88#define MIN_REAL_NUMBER MIN_FLOAT_NUMBER
89#else
90#define MAX_REAL_NUMBER MAX_DOUBLE_NUMBER
91#define MIN_REAL_NUMBER MIN_DOUBLE_NUMBER
92#endif
93#else
94#define MAX_REAL_NUMBER MAX_FLOAT_NUMBER
95#define MIN_REAL_NUMBER MIN_FLOAT_NUMBER
96#endif
97
98#if !defined(GAMMA) && !defined(ISOTHERM_EQS)
99#define GAMMA (5.0 / 3)
100#endif
101
102#ifdef ISOTHERM_EQS
103#if defined(GAMMA)
104#error "ISOTHERM_EQS overwrites your definition of GAMMA"
105#endif
106#undef GAMMA
107#define GAMMA 1.0
108#endif
109
110#define GAMMA_MINUS1 (GAMMA - 1)
111
112#define HYDROGEN_MASSFRAC 0.76
114#define METAL_YIELD 0.02
116/* ... often used physical constants (cgs units; NIST 2010) */
117
118#define GRAVITY 6.6738e-8
119#define SOLAR_MASS 1.989e33
120#define BOLTZMANN 1.38065e-16
121#define CLIGHT 2.99792458e10
122
123#define PARSEC 3.085678e18
124#define PROTONMASS 1.67262178e-24
125#define HUBBLE 3.2407789e-18 /* in h/sec */
126
127#define SEC_PER_MEGAYEAR 3.15576e13
128#define SEC_PER_YEAR 3.15576e7
129
130#ifndef FOF_PRIMARY_LINK_TYPES
131#define FOF_PRIMARY_LINK_TYPES 2
132#endif
133
134#ifndef FOF_SECONDARY_LINK_TYPES
135#define FOF_SECONDARY_LINK_TYPES 0
136#endif
137
138#ifndef FOF_LINKLENGTH
139#define FOF_LINKLENGTH 0.2
140#endif
141
142#ifndef FOF_GROUP_MIN_LEN
143#define FOF_GROUP_MIN_LEN 32
144#endif
145
146#if defined(PMGRID) && !defined(HRPMGRID)
147#define HRPMGRID PMGRID
148#endif
149
150#if !defined(RANDOMIZE_DOMAINCENTER_TYPES) && defined(PLACEHIGHRESREGION)
151#define RANDOMIZE_DOMAINCENTER_TYPES PLACEHIGHRESREGION
152#endif
153
154#if defined(SUBFIND) && !defined(SELFGRAVITY)
155#error "Running SUBFIND without SELFGRAVITY enabled does not make sense."
156#endif
157
158#if defined(SUBFIND) && !defined(FOF)
159#error "Running SUBFIND without FOF is not possible."
160#endif
161
162#if defined(TILING) && !defined(RECREATE_UNIQUE_IDS)
163#error "Running with TILING requires RECREATE_UNIQUE_IDS"
164#endif
165
166#if defined(MULTIPOLE_ORDER)
167#if(MULTIPOLE_ORDER < 1) || (MULTIPOLE_ORDER > 5)
168#error "MULTIPOLE_ORDER must be either 1, 2, 3, 4, or 5"
169#endif
170#else
171#define MULTIPOLE_ORDER 1
172#endif
173
174#if defined(FORCETEST) && !defined(EVALPOTENTIAL)
175#error "Running with FORCETEST requires EVALPOTENTIAL."
176#endif
177
178#if defined(DEBUG_ENABLE_FPU_EXCEPTIONS) && !defined(__linux__)
179#warning "DEBUG_ENABLE_FPU_EXCEPTIONS only works under Linux."
180#undef DEBUG_ENABLE_FPU_EXCEPTIONS
181#endif
182
183#if defined(HOST_MEMORY_REPORTING) && !defined(__linux__)
184#warning "HOST_MEMORY_REPORTING only works under Linux."
185#undef HOST_MEMORY_REPORTING
186#endif
187
188#if !defined(HOST_MEMORY_REPORTING) && defined(__linux__)
189#define HOST_MEMORY_REPORTING // let's switch it always on under Linux
190#endif
191
192#if defined(STARFORMATION) && !defined(COOLING)
193#error "STARFORMATION requires COOLING"
194#endif
195
196#if defined(FORCE_EQUAL_TIMESTEPS) && defined(HIERARCHICAL_GRAVITY)
197#error "FORCE_EQUAL_TIMESTEPS cannot be used together with HIERARCHICAL_GRAVITY"
198#endif
199
200#if defined(EXTRAPOTTERM) && !defined(EVALPOTENTIAL)
201#error "EXTRAPOTTERM makes only sense for EVALPOTENTIAL"
202#endif
203
204#if defined(MERGERTREE) && !defined(SUBFIND)
205#error "MERGERTREE requires SUBFIND."
206#endif
207
208#if defined(POWERSPEC_ON_OUTPUT) && !(defined(PERIODIC) && defined(PMGRID))
209#error "The option POWERSPEC_ON_OUTPUT requires PMGRID and PERIODIC."
210#endif
211
212#if defined(CREATE_GRID) && !defined(NGENIC)
213#error "CREATE_GRID only makes sense with NGENIC"
214#endif
215
216#if defined(OUTPUT_COORDINATES_AS_INTEGERS) && !defined(PERIODIC)
217#error "The OUTPUT_COORDINATES_AS_INTEGERS option is only allowed when PERIODIC is on"
218#endif
219
220#if defined(ALLOW_DIRECT_SUMMATION) && !defined(HIERARCHICAL_GRAVITY)
221#error "The option ALLOW_DIRECT_SUMMATION is only availble when HIERARCHICAL_GRAVITY is used"
222#endif
223
224#if defined(PMGRID) && !defined(PERIODIC) && !defined(TREEPM_NOTIMESPLIT)
225#error "If PMGRID is used without PERIODIC, TREEPM_NOTIMESPLIT needs to be activated"
226#endif
227
228#if defined(PMGRID) && defined(HIERARCHICAL_GRAVITY) && !defined(TREEPM_NOTIMESPLIT)
229#error "If PMGRID is used together with HIERARCHICAL_GRAVITY, you also need to use TREEPM_NOTIMESPLIT"
230#endif
231
232#if defined(PLACEHIGHRESREGION) && !defined(RANDOMIZE_DOMAINCENTER)
233#error "PLACEHIGHRESREGION requires RANDOMIZE_DOMAINCENTER."
234#endif
235
236#if defined(PLACEHIGHRESREGION) && !defined(PMGRID)
237#error "PLACEHIGHRESREGION requires PMGRID."
238#endif
239
240#if defined(TREEPM_NOTIMESPLIT) && !defined(PMGRID)
241#error "The option TREEPM_NOTIMESPLIT requires PMGRID."
242#endif
243
244#if defined(HRPMGRID) && !defined(PMGRID)
245#error "It doesn't make sense to set HRPMGRID without having PMGRID."
246#endif
247
248#if defined(POSITIONS_IN_64BIT) && defined(POSITIONS_IN_128BIT)
249#error "The options POSITIONS_IN_64BIT and POSITIONS_IN_128BIT should not be activated together."
250#endif
251
252#if !defined(EVALPOTENTIAL) && defined(FORCETEST)
253#error "When you enable FORCETEST you should also switch on EVALPOTENTIAL"
254#endif
255
256#if(defined(LONG_X_BITS) || defined(LONG_Y_BITS) || defined(LONG_Z_BITS)) && !defined(PERIODIC)
257#error "LONG_X/Y/Z_BITS requires the PERIODIC option"
258#endif
259
260#if defined(LIGHTCONE_PARTICLES) && !defined(LIGHTCONE)
261#error "The option LIGHTCONE_PARTICLES requires LIGHTCONE"
262#endif
263
264#if defined(LIGHTCONE_MASSMAPS) && !defined(LIGHTCONE)
265#error "The option LIGHTCONE_MASSMAPS requires LIGHTCONE"
266#endif
267
268#if defined(LIGHTCONE) && !defined(LIGHTCONE_PARTICLES) && !defined(LIGHTCONE_MASSMAPS)
269#error "The option LIGHTCONE requires selection of at least one of LIGHTCONE_PARTICLES or LIGHTCONE_MASSMAPS"
270#endif
271
272#if defined(SUBFIND_HBT) && !defined(MERGERTREE)
273#error "The option SUBFIND_HBT requires MERGERTREE"
274#endif
275
276#if defined(LIGHTCONE_PARTICLES) && defined(LIGHTCONE_OUTPUT_ACCELERATIONS) && defined(PMGRID) && \
277 (!defined(TREEPM_NOTIMESPLIT) || defined(HIERARCHICAL_GRAVITY))
278#error "LIGHTCONE_OUTPUT_ACCELERATIONS only works with PMGRID if TREEPM_NOTIMESPLIT is used and HIERARCHICAL_GRAVITY is not used"
279#endif
280
281#if defined(EXTERNALGRAVITY_STATICHQ) && !defined(EXTERNALGRAVITY)
282#error "EXTERNALGRAVITY_STATICHQ only works when EXTERNALGRAVITY is activated"
283#endif
284
285#ifndef ASMTH
287#define ASMTH 1.25
288#endif
289#ifndef RCUT
293#define RCUT 7.0
294#endif
295
296#ifndef MAXLEN_OUTPUTLIST
297#define MAXLEN_OUTPUTLIST 1100
298#endif
299
300#define MAXLEN_PATH 512
301#define MAXLEN_PATH_EXTRA 2048
303#define BASENUMBER 100
304
305#define MAXITER 10000
306
307#ifndef NTYPES
308#define NTYPES 6
309#endif
310
311#ifndef NSOFTCLASSES
312#define NSOFTCLASSES NTYPES
313#endif
314
315#ifdef ADAPTIVE_HYDRO_SOFTENING
316#ifndef NSOFTCLASSES_HYDRO
317#define NSOFTCLASSES_HYDRO 64
318#endif
319#else
320#undef NSOFTCLASSES_HYDRO
321#define NSOFTCLASSES_HYDRO 0
322#endif
323
324#ifdef ENLARGE_DYNAMIC_RANGE_IN_TIME
325typedef long long integertime;
326#define TIMEBINS 60
327#define TIMEBASE \
328 (((long long)1) << TIMEBINS) /* The simulated timespan is mapped onto the integer interval [0,TIMESPAN], \
329 * where TIMESPAN needs to be a power of 2. */
330#else
331typedef int integertime;
332#define TIMEBINS 29
333#define TIMEBASE (1 << TIMEBINS)
334#endif
335
336#if(NSOFTCLASSES + NSOFTCLASSES_HYDRO) >= 128
337#error "(NSOFTCLASSES + NSOFTCLASSES_HYDRO) must be smaller than 128"
338#endif
339
340#if NSOFTCLASSES < 1
341#error "NSOFTCLASSES must be at least 1"
342#endif
343
344#ifdef GADGET2_HEADER
345#if NTYPES > 6
346#error "NTYPES may not be larger than 6 if GADGET2_HEADER is set"
347#endif
348#endif
349
350#ifndef STAR_TYPE
351#define STAR_TYPE 4
352#endif
353
354#if defined(STARFORMATION) && (STAR_TYPE >= NTYPES)
355#error "STAR_TYPE must be an available type according to the set NTYPES"
356#endif
357
358#ifdef ONEDIMS
359#define NUMDIMS 1
360#define KERNEL_COEFF_1 (4.0 / 3)
361#define KERNEL_COEFF_2 (8.0)
362#define KERNEL_COEFF_3 (24.0)
363#define KERNEL_COEFF_4 (16.0)
364#define KERNEL_COEFF_5 (8.0 / 3)
365#define KERNEL_COEFF_6 (-8.0)
366#define NORM_COEFF 2.0
367#else
368#ifndef TWODIMS
369#define NUMDIMS 3
370#define KERNEL_COEFF_1 2.546479089470
371#define KERNEL_COEFF_2 15.278874536822
372#define KERNEL_COEFF_3 45.836623610466
373#define KERNEL_COEFF_4 30.557749073644
374#define KERNEL_COEFF_5 5.092958178941
375#define KERNEL_COEFF_6 (-15.278874536822)
376#define NORM_COEFF 4.188790204786
377#else
378#define NUMDIMS 2
379#define KERNEL_COEFF_1 (5.0 / 7 * 2.546479089470)
380#define KERNEL_COEFF_2 (5.0 / 7 * 15.278874536822)
381#define KERNEL_COEFF_3 (5.0 / 7 * 45.836623610466)
382#define KERNEL_COEFF_4 (5.0 / 7 * 30.557749073644)
383#define KERNEL_COEFF_5 (5.0 / 7 * 5.092958178941)
384#define KERNEL_COEFF_6 (5.0 / 7 * (-15.278874536822))
385#define NORM_COEFF M_PI
386#endif
387#endif /* ONEDIMS */
388
389#define SOFTFAC1 (32.0 / 3)
390#define SOFTFAC2 32.0
391#define SOFTFAC3 (-38.4)
392#define SOFTFAC4 (-2.8)
393#define SOFTFAC5 (16.0 / 3)
394#define SOFTFAC6 6.4
395#define SOFTFAC7 (-9.6)
396#define SOFTFAC8 (64.0 / 3)
397#define SOFTFAC9 (-48.0)
398#define SOFTFAC10 38.4
399#define SOFTFAC11 (-32.0 / 3)
400#define SOFTFAC12 (-1.0 / 15)
401#define SOFTFAC13 (-3.2)
402#define SOFTFAC14 (1.0 / 15)
403#define SOFTFAC15 (-16.0)
404#define SOFTFAC16 9.6
405#define SOFTFAC17 (-64.0 / 30)
406#define SOFTFAC18 128.0
407#define SOFTFAC19 (-115.2)
408#define SOFTFAC20 (64.0 / 3)
409#define SOFTFAC21 (-96.0)
410#define SOFTFAC22 115.2
411#define SOFTFAC23 (-128.0 / 3)
412#define SOFTFAC24 (4.0 / 30)
413
414#define SOFTFAC30 (32.0 / 3)
415#define SOFTFAC31 (-576.0 / 5)
416#define SOFTFAC32 (128.0)
417#define SOFTFAC33 (-1152.0 / 5)
418#define SOFTFAC34 (384.0)
419#define SOFTFAC35 (2.0 * 384.0)
420
421#define SOFTFAC40 (64.0 / 3)
422#define SOFTFAC41 (2.0 / 15)
423#define SOFTFAC42 (-96.0)
424#define SOFTFAC43 (576.0 / 5)
425#define SOFTFAC44 (-128.0 / 3)
426#define SOFTFAC45 (-96.0)
427#define SOFTFAC46 (-2.0 / 5)
428#define SOFTFAC47 (1152.0 / 5)
429#define SOFTFAC48 (-128.0)
430#define SOFTFAC49 (8.0 / 5)
431#define SOFTFAC50 (-256.0)
432#define SOFTFAC51 (-8.0)
433
434#define SQRT_PI 1.772453850906 /* sqrt(M_PI) */
435#define FACT1 0.366025403785 /* FACT1 = 0.5 * (sqrt(3)-1) */
436#define FACTSQRT3HALF 0.866025403785 /* sqrt(3)/2 */
437#define FACTSQRT3 (2.0 * 0.866025403785) /* sqrt(3) */
438#endif
int integertime
Definition: constants.h:331