-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathallvars.h
More file actions
3898 lines (3364 loc) · 155 KB
/
allvars.h
File metadata and controls
3898 lines (3364 loc) · 155 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*! \file allvars.h
* \brief declares global variables.
*
* This file declares all global variables. Further variables should be added here, and declared as
* 'extern'. The actual existence of these variables is provided by the file 'allvars.c'. To produce
* 'allvars.c' from 'allvars.h', do the following:
*
* - Erase all #define statements
* - add #include "allvars.h"
* - delete all keywords 'extern'
* - delete all struct definitions enclosed in {...}, e.g.
* "extern struct global_data_all_processes {....} All;"
* becomes "struct global_data_all_processes All;"
*/
/*
* This file was originally part of the GADGET3 code developed by
* Volker Springel. The code has been modified
* in part by Phil Hopkins (phopkins@caltech.edu) for GIZMO (many new variables,
* structures, and different naming conventions for some old variables)
*/
#ifndef ALLVARS_H
#define ALLVARS_H
#include <mpi.h>
#include <stdio.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_math.h>
#include <gsl/gsl_integration.h>
#include <gsl/gsl_spline.h>
#include <gsl/gsl_errno.h>
#ifdef _OPENMP
#include <omp.h>
#endif
#include "GIZMO_config.h"
/*------- Things that are always recommended (this must follow loading GIZMO_config.h!) -------*/
#define GIZMO_VERSION 2022 /*!< code version (should be an int corresponding to the year) */
#define DOUBLEPRECISION /* using double (not floating-point) precision */
#define PEANOHILBERT /* sort particles on a Peano-Hilbert curve (huge optimization) */
#define WALLCLOCK /* track timing of different routines */
#define MYSORT /* use our custom sort (as opposed to C default, which is compiler-dependent) */
#define ALLOWEXTRAPARAMS /* don't crash (just warn) if there are extra lines in the input parameterfile */
#ifndef OUTPUT_ADDITIONAL_RUNINFO
#define IO_REDUCED_MODE
#endif
#ifndef IO_DISABLE_HDF5
#define HAVE_HDF5 /* default to using HDF5 */
#include <hdf5.h>
#endif
#if !defined(OUTPUT_POSITIONS_IN_DOUBLE) && defined(HAVE_HDF5)
#define OUTPUT_POSITIONS_IN_DOUBLE /* recommended to always default to recording positions in double-precision: there's not really a good reason not to do this unless we need to match unformatted binary */
#endif
#if !defined(LONG_INTEGER_TIME)
#define LONG_INTEGER_TIME /* always recommended: on modern machines the memory overhead cost of this is negligible */
#endif
//#if !defined(MPISENDRECV_SIZELIMIT)
//#define MPISENDRECV_SIZELIMIT /* define but without an explicit memory value so it uses the buffersize defaults instead */
//#endif
#define DO_PREPROCESSOR_EXPAND_(VAL) VAL ## 1
#define EXPAND_PREPROCESSOR_(VAL) DO_PREPROCESSOR_EXPAND_(VAL) /* checks for a NON-ZERO value of this parameter */
#define CHECK_IF_PREPROCESSOR_HAS_NUMERICAL_VALUE_(VAL) !(EXPAND_PREPROCESSOR_(VAL) == 1) /* returns True if a non-zero int value of VAL is set */
#if !defined(SLOPE_LIMITER_TOLERANCE)
#if defined(AGGRESSIVE_SLOPE_LIMITERS)
#define SLOPE_LIMITER_TOLERANCE 2
#else
#define SLOPE_LIMITER_TOLERANCE 1
#endif
#endif
#ifndef DISABLE_GAS_CELL_WAKEUP
#if (SLOPE_LIMITER_TOLERANCE > 0)
#define WAKEUP 4.1 /* allows 2 timestep bins within kernel */
#else
#define WAKEUP 2.1 /* allows only 1-separated timestep bins within kernel */
#endif
#endif
/* lock the 'default' hydro mode */
#if !(defined(HYDRO_MESHLESS_FINITE_VOLUME) || defined(HYDRO_MESHLESS_FINITE_MASS) || defined(HYDRO_DENSITY_SPH) || defined(HYDRO_PRESSURE_SPH)) // default solver is not defined
#if (defined(HYDRO_FIX_MESH_MOTION) && (HYDRO_FIX_MESH_MOTION != 7)) || defined(HYDRO_REGULAR_GRID)
#define HYDRO_MESHLESS_FINITE_VOLUME /* only makes sense to use this modules with this 'backbone' of MFV here */
#else
#define HYDRO_MESHLESS_FINITE_MASS /* otherwise default to MFM if nothing is specified */
#endif
#endif
/* define the default mesh-motion assumption, if this is not provided by the user */
#if !defined(HYDRO_FIX_MESH_MOTION)
#if defined(HYDRO_REGULAR_GRID)
#define HYDRO_FIX_MESH_MOTION 0 /* default to non-moving for regular grids */
#else
#define HYDRO_FIX_MESH_MOTION 5 /* otherwise default to smoothed motion, only relevant for MFV (MFM/SPH will always move with flow) */
#endif
#endif
/* determine whether the mesh is adaptive via splitting/merging (refinement) or 'frozen' to the initial number of elements */
#if !defined(PREVENT_PARTICLE_MERGE_SPLIT) && (HYDRO_FIX_MESH_MOTION<5)
#define PREVENT_PARTICLE_MERGE_SPLIT /* particle merging/splitting doesn't make sense with frozen grids */
#endif
#ifdef PARTICLE_MERGE_SPLIT_EVERY_TIMESTEP
#define MAINTAIN_TREE_IN_REARRANGE
#endif
#define REDUC_FAC 0.98 /* used to pad memory in domain decomposition structures, should be slightly less than unity */
#ifdef PMGRID
#define PM_ENLARGEREGION 1.1 /* enlarges PMGRID region as the simulation evolves */
/*
# - PM_ENLARGEREGION: The spatial region covered by the high-res zone has a fixed
# size during the simulation, which initially is set to the
# smallest region that encompasses all high-res particles. Normally, the
# simulation will be interrupted, if high-res particles leave this
# region in the course of the run. However, by setting this parameter
# to a value larger than one, the high-res region can be expanded.
# For example, setting it to 1.4 will enlarge its side-length by
# 40% (it remains centered on the high-res particles). Hence, with
# such a setting, the high-res region may expand or move by a
# limited amount. If in addition SYNCHRONIZATION is activated, then
# the code will be able to continue even if high-res particles
# leave the initial high-res grid. In this case, the code will
# update the size and position of the grid that is placed onto
# the high-resolution region automatically. To prevent that this
# potentially happens every single PM step, one should nevertheless
# assign a value slightly larger than 1 to PM_ENLARGEREGION.
*/
#endif
#if (defined(HYDRO_DENSITY_SPH) || defined(HYDRO_PRESSURE_SPH)) && !defined(HYDRO_SPH)
#define HYDRO_SPH /* top-level flag for SPH: must be enabled if any SPH method is used */
#endif
#ifdef HYDRO_SPH
#if !defined(SPH_DISABLE_CD10_ARTVISC) && !(defined(EOS_TILLOTSON) || defined(EOS_ELASTIC)) // fancy viscosity switches assume positive pressures //
#define SPHAV_CD10_VISCOSITY_SWITCH 0.05 /* Enables Cullen & Dehnen 2010 'inviscid sph' (viscosity suppression outside shocks) */
#endif
#ifndef SPH_DISABLE_PM_CONDUCTIVITY
#define SPHAV_ARTIFICIAL_CONDUCTIVITY /* Enables mixing entropy (J.Read's improved Price-Monaghan conductivity with Cullen-Dehnen switches) */
#endif
#endif
#if defined(DILATION_FOR_STELLAR_KINEMATICS_ONLY) && !defined(USE_TIMESTEP_DILATION_FOR_ZOOMS)
#define USE_TIMESTEP_DILATION_FOR_ZOOMS
#endif
#if defined(SPECIAL_POINT_WEIGHTED_MOTION) && !defined(SPECIAL_POINT_MOTION)
#define SPECIAL_POINT_MOTION (SPECIAL_POINT_WEIGHTED_MOTION) /* doesn't seem to be working ???? */
#endif
#if defined(SPECIAL_POINT_MOTION) && !defined(BH_CALC_DISTANCES)
#define BH_CALC_DISTANCES
#endif
#ifdef PERIODIC
#define BOX_PERIODIC
#endif
#ifdef BND_PARTICLES
#define BOX_BND_PARTICLES
#endif
#ifdef LONG_X
#define BOX_LONG_X LONG_X
#endif
#ifdef LONG_Y
#define BOX_LONG_Y LONG_Y
#endif
#ifdef LONG_Z
#define BOX_LONG_Z LONG_Z
#endif
#ifdef REFLECT_BND_X
#define BOX_REFLECT_X
#endif
#ifdef REFLECT_BND_Y
#define BOX_REFLECT_Y
#endif
#ifdef REFLECT_BND_Z
#define BOX_REFLECT_Z
#endif
#ifdef SHEARING_BOX
#define BOX_SHEARING SHEARING_BOX
#endif
#ifdef SHEARING_BOX_Q
#define BOX_SHEARING_Q SHEARING_BOX_Q
#endif
#ifdef SHEARING_BOX_QB
#define BOX_SHEARING_QB SHEARING_BOX_QB
#endif
#ifdef ANALYTIC_GRAVITY
#if CHECK_IF_PREPROCESSOR_HAS_NUMERICAL_VALUE_(ANALYTIC_GRAVITY)
#define GRAVITY_ANALYTIC ANALYTIC_GRAVITY
#else
#define GRAVITY_ANALYTIC
#endif
#endif
#ifdef NOGRAVITY
#define SELFGRAVITY_OFF
#endif
#if defined(EOS_ELASTIC)
#if !defined(DISABLE_SURFACE_VOLCORR) && !defined(HYDRO_KERNEL_SURFACE_VOLCORR)
#define HYDRO_KERNEL_SURFACE_VOLCORR
#endif
#if !defined(DISABLE_EXPLICIT_VOLUME_INTEGRATION) && !defined(HYDRO_EXPLICITLY_INTEGRATE_VOLUME)
#define HYDRO_EXPLICITLY_INTEGRATE_VOLUME
#endif
#endif
#include "eos/eos.h"
#if defined(FLAG_NOT_IN_PUBLIC_CODE) || defined(DM_FUZZY)
#define AGS_FACE_CALCULATION_IS_ACTIVE
#endif
#if defined(GRAIN_COLLISIONS)
#define DM_SIDM 8 /* use the SIDM module to handle scattering of otherwise-collisionless particles against each other -- set to Particle Type=3 here */
#endif
#if defined(PIC_MHD)
#define PIC_MHD_NEW_RSOL_METHOD /* prefer new method for dealing with RSOL, should make simulations easier if done correctly */
#ifdef GRAIN_FLUID
#define GRAIN_FLUID_AND_PIC_BOTH_DEFINED /* keyword used later to know what we need to read in */
#else
#define GRAIN_FLUID
#endif
#ifndef GRAIN_LORENTZFORCE
#define GRAIN_LORENTZFORCE
#endif
#ifndef GRAIN_BACKREACTION
#define GRAIN_BACKREACTION
#endif
#endif
#if defined(ADAPTIVE_GRAVSOFT_FORALL) || defined(FLAG_NOT_IN_PUBLIC_CODE) || defined(DM_FUZZY) || defined(AGS_FACE_CALCULATION_IS_ACTIVE) || defined(DM_SIDM)
#define AGS_HSML_CALCULATION_IS_ACTIVE
#endif
#if defined(ADAPTIVE_GRAVSOFT_FORALL)
#define ADAPTIVE_GRAVSOFT_SYMMETRIZE_FORCE_BY_AVERAGING /* comment out to revert to behavior of taking 'greater' softening in pairwise kernel interactions with adaptive softenings enabled. really only needed currently for this particular AGS model given how it computes zeta terms (could be made optional with one more loop for those as well) */
#endif
#ifdef PROTECT_FROZEN_FIRE
#define GALSF_USE_SNE_ONELOOP_SCHEME // set to use the 'base' FIRE-2 SNe coupling. if commented out, will user newer version that more accurately manages the injected energy with neighbors moving to inject a specific target
#endif
#ifdef GALSF_SFR_CRITERION // flag for pure cross-compatibility [identical functionality, just ease-of-use for galaxy simulators here]
#define SINGLE_STAR_SINK_FORMATION GALSF_SFR_CRITERION
#endif
#ifdef COSMIC_RAY_FLUID
#define GAMMA_COSMICRAY(k) (4.0/3.0)
#ifndef CRFLUID_DIFFUSION_MODEL
#define CRFLUID_DIFFUSION_MODEL 0
#endif
#ifndef N_CR_PARTICLE_BINS
#define N_CR_PARTICLE_BINS 1
#endif
#if (N_CR_PARTICLE_BINS > 2) && !defined(FLAG_NOT_IN_PUBLIC_CODE)
#endif
#endif
#ifdef COSMIC_RAY_SUBGRID_LEBRON
#define N_CR_PARTICLE_BINS 1
#endif
#if defined(COOL_GRACKLE)
#if !defined(COOLING)
#define COOLING
#endif
#include <grackle.h>
#endif
#ifdef CHIMES
#include "./cooling/chimes/chimes_proto.h"
extern struct gasVariables *ChimesGasVars;
extern struct globalVariables ChimesGlobalVars;
extern char ChimesDataPath[256];
extern char ChimesEqAbundanceTable[196];
extern char ChimesPhotoIonTable[196];
extern double chimes_rad_field_norm_factor;
extern double shielding_length_factor;
extern double cr_rate;
extern int ChimesEqmMode;
extern int ChimesUVBMode;
extern int ChimesInitIonState;
extern int Chimes_incl_full_output;
extern int N_chimes_full_output_freq;
#ifdef CHIMES_HII_REGIONS
#ifndef GALSF_FB_FIRE_RT_HIIHEATING
#define GALSF_FB_FIRE_RT_HIIHEATING // must be on, this module uses the same code
#endif
#endif
#ifdef CHIMES_STELLAR_FLUXES
// The following defines the stellar age bins that we will use to define the UV spectra from stars used in CHIMES.
#define CHIMES_LOCAL_UV_NBINS 8
#define CHIMES_LOCAL_UV_AGE_LOW 0.0
#define CHIMES_LOCAL_UV_DELTA_AGE_LOW 0.2
#define CHIMES_LOCAL_UV_AGE_MID 1.0
#define CHIMES_LOCAL_UV_DELTA_AGE_HI 1.0
#endif
#ifdef CHIMES_METAL_DEPLETION
#define DEPL_N_ELEM 17
struct Chimes_depletion_data_structure
{
double SolarAbund[DEPL_N_ELEM];
double DeplPars[DEPL_N_ELEM][3];
double DustToGasSaturated;
double ChimesDepletionFactors[7];
double ChimesDustRatio;
};
extern struct Chimes_depletion_data_structure *ChimesDepletionData;
#endif // CHIMES_METAL_DEPLETION
#endif // CHIMES
#if defined(SINGLE_STAR_AND_SSP_HYBRID_MODEL_DEFAULTS) /* options for hybrid/combined FIRE+STARFORGE simulations */
#define SINGLE_STAR_AND_SSP_HYBRID_MODEL (SINGLE_STAR_AND_SSP_HYBRID_MODEL_DEFAULTS) /* do single-star routines below this mass resolution in solar, FIRE-like above */
#define GALSF_SFR_IMF_SAMPLING /* use discrete sampling of 'number of O-stars' so we can handle the intermediate-mass regime in at least a simple approximate manner */
#define COOLING /* only physical if include cooling for both sides, using same cooling functions */
#define MAGNETIC /* enable MHD, important for systems here */
#define CONDUCTION /* enable conduction */
#define CONDUCTION_SPITZER /* compute proper coefficients and anisotropy for conduction */
#define VISCOSITY /* enable viscosity */
#define VISCOSITY_BRAGINSKII /* compute proper coefficients and anisotropy for viscosity */
#define SINGLE_STAR_FB_JETS /* enable jets from protostars */
#define SINGLE_STAR_FB_WINDS 0 /* enable continuous mass-loss feedback - will also enable ssp mass-loss */
#define SINGLE_STAR_FB_SNE /* enable SNe feedback - will also enable ssp mechanical feedback */
#define SINGLE_STAR_FB_RAD /* enable RHD feedback */
#define RT_COMOVING /* significantly more stable and accurate formulation given the structure of the problem and method we use */
#define RT_SOURCES (16+32) /* need to allow -both- ssp-particles and single-star particles to emit */
#if !defined(RT_SPEEDOFLIGHT_REDUCTION)
#define RT_SPEEDOFLIGHT_REDUCTION (0.1) /* for many problems on these scales, need much larger RSOL than default starforge values (dynamical velocities are big, without this they will severely lag behind) */
#endif
#define ADAPTIVE_TREEFORCE_UPDATE (0.0625) /* rough typical value we use for ensuring stability */
#if defined(FIRE_SUPERLAGRANGIAN_JEANS_REFINEMENT) || defined(SINGLE_STAR_AND_SSP_NUCLEAR_ZOOM)
#define OUTPUT_ACCELERATION
#define OUTPUT_HYDROACCELERATION
#define OUTPUT_MOLECULAR_FRACTION
#define OUTPUT_TEMPERATURE
#define OUTPUT_ADDITIONAL_RUNINFO
#endif
#ifdef SINGLE_STAR_AND_SSP_NUCLEAR_ZOOM
#define PARTICLE_EXCISION
#define OUTPUT_GRADIENT_RHO
#define OUTPUT_GRADIENT_VEL
#define OUTPUT_RT_RAD_FLUX
#define OUTPUT_RT_RAD_OPACITY
#define RT_RAD_PRESSURE_OUTPUT
#ifdef SINGLE_STAR_AND_SSP_NUCLEAR_ZOOM_SPECIALBOUNDARIES
#define GRAVITY_ANALYTIC
#endif
#endif
#endif // closes hybrid FIRE+STARFORGE model settings
#ifdef SINGLE_STAR_SINK_DYNAMICS
#define GALSF // top-level switch needed to enable various frameworks
#define METALS // metals should be active for stellar return
#define BLACK_HOLES // need to have black holes active since these are our sink particles
#define BH_INTERACT_ON_GAS_TIMESTEP // BH-gas interactions (feedback and accretion) occur with frequency set by the gas timestep
#define BH_CALC_DISTANCES // calculate distance to nearest sink in gravity tree
#ifdef SINGLE_STAR_ACCRETION // figure out flags needed for the chosen sink accretion model
#define BH_SWALLOWGAS // need to swallow gas [part of sink model]
#ifndef BH_ALPHADISK_ACCRETION
#define BH_ALPHADISK_ACCRETION (2.) // all models will use a 'reservoir' of some kind to smooth out accretion rates (and represent unresolved disk)
#endif
#if (SINGLE_STAR_ACCRETION <= 8)
#define BH_GRAVACCRETION (SINGLE_STAR_ACCRETION) // use one of these pre-built accretion models
#endif
#if (SINGLE_STAR_ACCRETION == 9)
#define BH_BONDI 0 // use 'normal' Bondi-Hoyle accretion rate
#endif
#if (SINGLE_STAR_ACCRETION == 10)
#define BH_BONDI 1 // use Bondi rate ignoring local relative velocities
#endif
#if (SINGLE_STAR_ACCRETION == 11)
#define BH_GRAVCAPTURE_GAS // use gravitational capture swallow criterion for resolved gravitational capture
#endif
#if (SINGLE_STAR_ACCRETION == 12)
#define BH_GRAVCAPTURE_GAS
#define BH_GRAVCAPTURE_FIXEDSINKRADIUS // modify grav capture to Bate-style, fixed (in time) sink radius based on SF neighbor distance, plus angular momentum criterion
#endif
#endif
#if (defined(SINGLE_STAR_FB_JETS) || defined(SINGLE_STAR_FB_WINDS) || defined(SINGLE_STAR_FB_RT_HEATING) || defined(SINGLE_STAR_FB_SNE) || defined(RT_OTVET) || defined(RT_FLUXLIMITEDDIFFUSION) || defined(RT_M1) || defined(RT_LOCALRAYGRID) || defined(SINGLE_STAR_FB_LOCAL_RP)) && defined(SINGLE_STAR_TIMESTEPPING) && defined(SINGLE_STAR_SINK_DYNAMICS)
#define SINGLE_STAR_FB_TIMESTEPLIMIT // general flag indicating feedback is on
#endif
#if defined(SINGLE_STAR_FB_RT_HEATING) && !(defined(RT_OTVET) || defined(RT_FLUXLIMITEDDIFFUSION) || defined(RT_M1) || defined(RT_LOCALRAYGRID))
#define GALSF_FB_FIRE_RT_LONGRANGE // turn on FIRE RT approximation: no Type-4 particles so don't worry about its approximations
#define BH_PHOTONMOMENTUM // enable BHs within the FIRE-RT framework.
#define RT_DISABLE_RAD_PRESSURE
#endif
#if (defined(SINGLE_STAR_FB_WINDS) || defined(SINGLE_STAR_FB_SNE)) && !defined(GALSF_FB_MECHANICAL)
#define GALSF_FB_MECHANICAL // we will use the mechanical wind module for low mass loss rate stars (spawning leads to issues). enable regardless if either the winds or sne module is active
#define GALSF_USE_SNE_ONELOOP_SCHEME
#endif
#ifdef SINGLE_STAR_FB_SNE
#if !(CHECK_IF_PREPROCESSOR_HAS_NUMERICAL_VALUE_(SINGLE_STAR_FB_SNE)) /* no numerical value is set, so set one as our 'default' */
#undef SINGLE_STAR_FB_SNE
#define SINGLE_STAR_FB_SNE 1 // fraction of the SN energy in the kinetic energy of particles vs internal
#endif
#endif
#if defined(SINGLE_STAR_FB_JETS) || ((defined(SINGLE_STAR_FB_WINDS) || defined(SINGLE_STAR_FB_SNE)) && defined(FLAG_NOT_IN_PUBLIC_CODE))
#define BH_WIND_SPAWN (2) // leverage the BHFB model already developed within the FIRE-BHs framework. gives accurate launching of arbitrarily-structured jets.
#if !defined(SINGLE_STAR_AND_SSP_NUCLEAR_ZOOM)
#define MAINTAIN_TREE_IN_REARRANGE // don't rebuild the domains/tree every time a particle is spawned - salvage the existing one by redirecting pointers as needed
#endif
#endif
#if defined(SINGLE_STAR_FB_LOCAL_RP) // use standard angle-weighted local coupling to impart photon momentum from stars
#if !defined(BH_PHOTONMOMENTUM)
#define BH_PHOTONMOMENTUM
#endif
#if !defined(RT_DISABLE_RAD_PRESSURE)
#define RT_DISABLE_RAD_PRESSURE // we only want the local short-ranged photon momentum, since SF sims can easily get into the badly non-photon-conserving limit where LEBRON fluxes are less accurate
#endif
#endif
#if defined(COOLING) && !defined(COOL_GRACKLE) // if not using grackle modules, need to make sure appropriate cooling is enabled
#ifndef COOL_LOW_TEMPERATURES
#define COOL_LOW_TEMPERATURES // make sure low-temperature cooling is enabled!
#endif
#ifndef COOL_METAL_LINES_BY_SPECIES
#define COOL_METAL_LINES_BY_SPECIES // metal-based cooling enabled
#endif
#define OUTPUT_TEMPERATURE
#endif
#endif // SINGLE_STAR_SINK_DYNAMICS
#if (SINGLE_STAR_SINK_FORMATION & 1) || (SINGLE_STAR_SINK_FORMATION & 2048) // figure out flags needed for the chosen sink formation model [note these CAN be used even if single-star top-level flag is off, as additional SF/sink formation criteria for e.g. GALSF sims]
#if (SINGLE_STAR_SINK_FORMATION & 2048)
#define GALSF_SFR_VIRIAL_SF_CRITERION 2
#else
#define GALSF_SFR_VIRIAL_SF_CRITERION 1
#endif
#endif
#if (SINGLE_STAR_SINK_FORMATION & 16)
#ifndef SINGLE_STAR_TIMESTEPPING
#define SINGLE_STAR_TIMESTEPPING 0
#endif
#endif
#if (SINGLE_STAR_SINK_FORMATION & 32)
#define GALSF_SFR_TIDAL_HILL_CRITERION
#endif
#ifdef GRAVITY_ACCURATE_FEWBODY_INTEGRATION /* utility flag to enable a few different extra-conservative time-integration flags for gravity */
#if !defined(GRAVITY_HYBRID_OPENING_CRIT)
#define GRAVITY_HYBRID_OPENING_CRIT // use both Barnes-Hut + relative tree opening criterion
#endif
#if !defined(STOP_WHEN_BELOW_MINTIMESTEP)
#define STOP_WHEN_BELOW_MINTIMESTEP // stop when below min timestep to prevent bad timestepping
#endif
//#define RANDOMIZE_GRAVTREE /* move the top tree node around randomly so that treeforce errors are not correlated between one treebuild and another */
#define TIDAL_TIMESTEP_CRITERION // use tidal tensor timestep criterion
#endif
#ifdef HERMITE_INTEGRATION
#define COMPUTE_JERK_IN_GRAVTREE /* needs to be computed in order to do the Hermite integration */
#ifndef TIDAL_TIMESTEP_CRITERION
#define TIDAL_TIMESTEP_CRITERION // use tidal tensor timestep criterion -- otherwise won't effectively leverage the Hermite integrator timesteps
#endif
#endif
#ifdef RT_USE_TREECOL_FOR_NH
#if !defined(GRAVTREE_CALCULATE_GAS_MASS_IN_NODE)
#define GRAVTREE_CALCULATE_GAS_MASS_IN_NODE
#endif
#endif
#if (defined(SINGLE_STAR_FB_SNE) || defined(SINGLE_STAR_FB_WINDS)) && !defined(SINGLE_STAR_FB_SNE_N_EJECTA_QUADRANT)
#define SINGLE_STAR_FB_SNE_N_EJECTA_QUADRANT 2 // determines the maximum number of ejecta particles spawned per timestep, see below
#endif
#if defined(SINGLE_STAR_FB_SNE_N_EJECTA_QUADRANT)
#define SINGLE_STAR_FB_SNE_N_EJECTA (4*(SINGLE_STAR_FB_SNE_N_EJECTA_QUADRANT)*((SINGLE_STAR_FB_SNE_N_EJECTA_QUADRANT)+1)) // maximum number of ejecta cells spawned per timestep - follows from tiling rules for rays from RHD-direct-ray method
#endif
#ifdef ADAPTIVE_TREEFORCE_UPDATE // instead of going into the tree every timestep, only update gravity with a frequency set by this fraction of dynamical timescale (default for gas only)
#ifndef TIDAL_TIMESTEP_CRITERION
#define TIDAL_TIMESTEP_CRITERION // need this to estimate the dynamical time
#endif
#endif
#if (SINGLE_STAR_TIMESTEPPING > 0) /* if single-star timestepping is on, need to make sure the binary-identification flag is active */
#ifndef SINGLE_STAR_FIND_BINARIES
#define SINGLE_STAR_FIND_BINARIES
#endif
#endif
#ifdef MHD_CONSTRAINED_GRADIENT
/* make sure mid-point gradient calculation for cleaning terms is enabled */
#ifndef MHD_CONSTRAINED_GRADIENT_MIDPOINT
#define MHD_CONSTRAINED_GRADIENT_MIDPOINT
#endif
#endif
/* these are tolerances for the slope-limiters. we define them here, because the gradient constraint routine needs to
be sure to use the -same- values in both the gradients and reimann solver routines */
#if MHD_CONSTRAINED_GRADIENT
#if (MHD_CONSTRAINED_GRADIENT > 1)
#define MHD_CONSTRAINED_GRADIENT_FAC_MINMAX 7.5
#define MHD_CONSTRAINED_GRADIENT_FAC_MEDDEV 5.0
#define MHD_CONSTRAINED_GRADIENT_FAC_MED_PM 0.25
#define MHD_CONSTRAINED_GRADIENT_FAC_MAX_PM 0.25
#else
#define MHD_CONSTRAINED_GRADIENT_FAC_MINMAX 7.5
#define MHD_CONSTRAINED_GRADIENT_FAC_MEDDEV 1.5
#define MHD_CONSTRAINED_GRADIENT_FAC_MED_PM 0.2
#define MHD_CONSTRAINED_GRADIENT_FAC_MAX_PM 0.2
#endif
#else
#define MHD_CONSTRAINED_GRADIENT_FAC_MINMAX 2.0
#define MHD_CONSTRAINED_GRADIENT_FAC_MEDDEV 1.0
#define MHD_CONSTRAINED_GRADIENT_FAC_MED_PM 0.20
#define MHD_CONSTRAINED_GRADIENT_FAC_MAX_PM 0.125
#endif
/* force 'parent' or 'top-level' flags to be enabled for the appropriate methods, if we have enabled something using those methods */
/* ----- giant block of options for RHD modules ------ */
/* options for FIRE RT method */
#if defined(GALSF_FB_FIRE_RT_LONGRANGE)
#define RT_LEBRON // this flag requires lebron for rhd
#endif
#if defined(RT_LEBRON)
#define RT_USE_GRAVTREE // use gravity tree for flux propagation
#define RT_USE_GRAVTREE_SAVE_RAD_ENERGY
#if !defined(GALSF_FB_FIRE_RT_LONGRANGE)
#define RADTRANSFER // for cross-compatibility reasons, if the FIRE version is not on, need RADTRANSFER flag also enabled
#define RT_USE_GRAVTREE_SAVE_RAD_FLUX
#endif
#endif
/* check whether we want to use the implicit solver [only usable for very special cases, not recommended] */
#if defined(RT_DIFFUSION_IMPLICIT) && (defined(RT_OTVET) || defined(RT_FLUXLIMITEDDIFFUSION)) // only modules the implicit solver works with
#define RT_DIFFUSION_CG // use our implicit solver [will crash with any other modules, hence checking this before the others below]
#endif
/* options for FLD or OTVET or M1 or Ray/Rad_Intensity modules */
#if defined(RT_OTVET) || defined(RT_FLUXLIMITEDDIFFUSION) || defined(RT_M1) || defined(RT_LOCALRAYGRID)
#ifndef RADTRANSFER
#define RADTRANSFER // RADTRANSFER is ON, obviously
#endif
#define RT_SOURCE_INJECTION // need source injection enabled to define emissivity
#if !defined(RT_DIFFUSION_CG)
#define RT_SOLVER_EXPLICIT // default to explicit solutions (much more accurate/flexible)
#endif
#endif /* end of options for our general RHD methods */
/* OTVET-specific options [uses the gravity tree to calculate the Eddington tensor] */
#if defined(RT_OTVET)
#define RT_USE_GRAVTREE // use gravity tree for Eddington tensor
#ifndef RT_SEPARATELY_TRACK_LUMPOS
#define RT_SEPARATELY_TRACK_LUMPOS // and be sure to track luminosity locations
#endif
#endif /* end of otvet-specific options */
/* M1-specific options [make sure to add the flux moment */
#if defined(RT_M1)
#define RT_EVOLVE_FLUX // evolve flux moment [not just energy moment assumed by FLD/OTVET]
#endif
/* options for direct/exact Jiang et al. method for direct evolution on an intensity grid */
#if defined(RT_LOCALRAYGRID)
#define RT_EVOLVE_INTENSITIES // evolve the intensities explicitly
#define N_RT_INTENSITY_BINS (4*(RT_LOCALRAYGRID)*((RT_LOCALRAYGRID)+1)) // define number of directional bins, used throughout
#define RT_INTENSITY_BINS_DOMEGA (4.*M_PI/((double)N_RT_INTENSITY_BINS)) // normalization coefficient (for convenience defined here)
#endif
/* check if we are -explicitly- evolving the radiation energy density [0th moment], in which case we need to carry time-derivatives of the field */
#if defined(RT_SOLVER_EXPLICIT) && !defined(RT_EVOLVE_INTENSITIES) // only needed if we are -not- evolving intensities and -are- solving explicitly
#define RT_EVOLVE_ENERGY
#if !defined(RT_EVOLVE_FLUX) && !defined(RT_DISABLE_FLUXLIMITER) // evolving energy explicitly but not flux, flux-limiting is not disabled
#define RT_FLUXLIMITER // default to include flux-limiter under these conditions
#endif
#endif
/* enable radiation pressure forces unless they have been explicitly disabled */
#if defined(RADTRANSFER) && !defined(RT_DISABLE_RAD_PRESSURE) && !defined(RT_OPACITY_FROM_EXPLICIT_GRAINS)
#define RT_RAD_PRESSURE_FORCES
#endif
#ifdef RT_SOURCE_INJECTION
#if defined(GALSF) && !defined(RT_INJECT_PHOTONS_DISCRETELY)
#define RT_INJECT_PHOTONS_DISCRETELY // modules will not work correctly with differential timestepping with point sources without discrete injection
#endif
#if defined(RT_INJECT_PHOTONS_DISCRETELY) && defined(RT_RAD_PRESSURE_FORCES) && (defined(RT_ENABLE_R15_GRADIENTFIX) || defined(GALSF))
#define RT_INJECT_PHOTONS_DISCRETELY_ADD_MOMENTUM_FOR_LOCAL_EXTINCTION // adds correction for un-resolved extinction which cannot generate photon momentum with M1, FLD, OTVET, etc.
#endif
#endif
/* check if we need to explicitly calculate gradients of the radiation pressure tensor for the diffusive step */
#if (defined(RT_FLUXLIMITER) || defined(RT_RAD_PRESSURE_FORCES) || defined(RT_SOLVER_EXPLICIT)) && !defined(RT_COMPGRAD_EDDINGTON_TENSOR) //&& !defined(RT_EVOLVE_FLUX) && !defined(RT_EVOLVE_INTENSITIES))
#define RT_COMPGRAD_EDDINGTON_TENSOR
#endif
/* enable appropriate chemistry flags if we are using the photoionization modules */
#if defined(RT_CHEM_PHOTOION)
#if (RT_CHEM_PHOTOION > 1)
/* enables multi-frequency radiation transport for ionizing photons. Integration variable is the ionising intensity J_nu */
#define RT_CHEM_PHOTOION_HE
#define RT_PHOTOION_MULTIFREQUENCY // if using He-ionization, default to multi-frequency RT [otherwise doesn't make sense] //
#endif
#endif
/* enable appropriate flags for X-ray sub-modules */
#if defined(RT_XRAY)
#if (RT_XRAY == 1)
#define RT_SOFT_XRAY
#endif
#if (RT_XRAY == 2)
#define RT_HARD_XRAY
#endif
#if (RT_XRAY == 3)
#define RT_SOFT_XRAY
#define RT_HARD_XRAY
#endif
#endif
/* default to speed-of-light equal to actual speed-of-light, and stars as photo-ionizing sources */
#ifndef RT_SPEEDOFLIGHT_REDUCTION
#define RT_SPEEDOFLIGHT_REDUCTION (1.0)
#endif
#ifndef RT_SOURCES
#define RT_SOURCES 1+2+4+8+16+32 // default to allowing all types to act as sources //
#endif
/* cooling must be enabled for RT cooling to function */
#if defined(RT_COOLING_PHOTOHEATING_OLDFORMAT) && !defined(COOLING)
#define COOLING
#endif
#if !defined(RT_USE_GRAVTREE) && defined(RT_SELFGRAVITY_OFF) && !defined(SELFGRAVITY_OFF)
#define SELFGRAVITY_OFF // safely define SELFGRAVITY_OFF in this case, otherwise we act like there is gravity except in the final setting of accelerations
#endif
/* turn on outputs appropriately */
#ifdef RADTRANSFER
#if !defined(OUTPUT_EDDINGTON_TENSOR) && !defined(IO_SUPPRESS_OUTPUT_EDDINGTON_TENSOR)
#define OUTPUT_EDDINGTON_TENSOR
#endif
#endif
/* ----- end block of options for RHD modules ------ */
#if defined(GALSF) || defined(BLACK_HOLES) || defined(RADTRANSFER) || defined(OUTPUT_DENS_AROUND_STAR) || defined(CHIMES) || defined(RT_REPROCESS_INJECTED_PHOTONS)
#define DO_DENSITY_AROUND_STAR_PARTICLES
#if !defined(ALLOW_IMBALANCED_GASPARTICLELOAD)
#define ALLOW_IMBALANCED_GASPARTICLELOAD
#endif
#endif
#if defined(GALSF_SFR_VIRIAL_SF_CRITERION)
#if (GALSF_SFR_VIRIAL_SF_CRITERION >= 5)
#define GALSF_SFR_TIDAL_HILL_CRITERION
#endif
#if (GALSF_SFR_VIRIAL_SF_CRITERION >= 2)
#define GALSF_SFR_VIRIAL_CRITERION_TIMEAVERAGED
#endif
#endif
#if defined(BH_SWALLOWGAS)
#define BH_FOLLOW_ACCRETED_COM
#define BH_FOLLOW_ACCRETED_MOMENTUM
#if defined(SINGLE_STAR_SINK_DYNAMICS) || defined(BH_GRAVCAPTURE_GAS)
#define BH_FOLLOW_ACCRETED_ANGMOM 0 // follow accreted AM just from explicit 'swallow' operations
#else
#define BH_FOLLOW_ACCRETED_ANGMOM 1 // follow accreted AM from 'swallowed' BH particles, and from continuous/smooth properties [mdot] of kernel gas near BH
#endif
#endif
//#define ENERGY_ENTROPY_SWITCH_IS_ACTIVE
/* this is a ryu+jones type energy/entropy switch. it can help with some problems, but can also generate significant
errors in other types of problems. in general, even for pure hydro, this isn't recommended; use it for special problems if you know what you are doing. */
#ifdef MAGNETIC
/* recommended MHD switches -- only turn these off for de-bugging */
#define DIVBCLEANING_DEDNER /* hyperbolic/parabolic div-cleaing (Dedner 2002), with TP improvements */
/* MHD switches specific to SPH MHD */
#ifdef HYDRO_SPH
#define SPH_TP12_ARTIFICIAL_RESISTIVITY /* turns on magnetic dissipation ('artificial resistivity'): uses tricco switch =h*|gradB|/|B| */
#endif
#endif
#if defined(TURB_DIFF_ENERGY) || defined(TURB_DIFF_VELOCITY) || defined(TURB_DIFF_MASS) || defined(TURB_DIFF_METALS)
#define TURB_DIFFUSION /* top-level switch to calculate properties needed for scalar turbulent diffusion/mixing: must enable with any specific version */
#if defined(TURB_DIFF_VELOCITY) && !defined(VISCOSITY)
#define VISCOSITY
#endif
#if defined(TURB_DIFF_ENERGY) && !defined(CONDUCTION)
#define CONDUCTION
#endif
#endif
#if defined(RT_OPACITY_FROM_EXPLICIT_GRAINS) || defined(GALSF_ISMDUSTCHEM_MODEL) || defined(RT_INFRARED)
#define OUTPUT_DUST_TO_GAS_RATIO // helpful if these special modules are on to see this output and save it for use in analysis
#endif
#if defined(OUTPUT_POTENTIAL) && !defined(EVALPOTENTIAL)
#define EVALPOTENTIAL
#endif
#if defined(BH_REPOSITION_ON_POTMIN)
#if (BH_REPOSITION_ON_POTMIN < 0)
#undef BH_REPOSITION_ON_POTMIN // this is a key to un-define this variable if it is set, useful for some of the preset variable packages above //
#endif
#endif
#if defined(BLACK_HOLES) && (defined(BH_REPOSITION_ON_POTMIN) || defined(BH_SEED_FROM_FOF))
#ifndef EVALPOTENTIAL
#define EVALPOTENTIAL
#endif
#if !defined(BH_DYNFRICTION) && (BH_REPOSITION_ON_POTMIN == 2)
#define BH_DYNFRICTION 1 // use for local damping of anomalous velocities wrt background medium //
#endif
#endif
#ifdef EVALPOTENTIAL
#ifndef COMPUTE_POTENTIAL_ENERGY
#define COMPUTE_POTENTIAL_ENERGY
#endif
#endif
#if defined(COOL_MOLECFRAC)
#if (COOL_MOLECFRAC == 6) && !defined(COOL_MOLECFRAC_NONEQM)
#define COOL_MOLECFRAC_NONEQM // estimate molecular fractions for thermochemistry+cooling with explicitly-evolved non-equilibirum H2 formation+destruction with clumping and self-shielding (Hopkins et al arXiv:2203.00040)
#elif (COOL_MOLECFRAC == 5) && !defined(COOL_MOLECFRAC_LOCALEQM)
#define COOL_MOLECFRAC_LOCALEQM // estimate molecular fractions for thermochemistry+cooling from local equilibrium H2 formation+destruction with clumping and self-shielding (Hopkins et al arXiv:2203.00040)
#elif (COOL_MOLECFRAC == 4) && !defined(COOL_MOLECFRAC_KMT)
#define COOL_MOLECFRAC_KMT // estimate f_H2 from approximate large-scale expressions from Krumholz, McKee, & Tumlinson (2009ApJ...693..216K). use the simpler Kumholz, McKee, & Tumlinson 2009 sub-grid model for molecular fractions in equilibrium, which is a function modeling spherical clouds of internally uniform properties exposed to incident radiation. Depends on column density, metallicity, and incident FUV field
#elif (COOL_MOLECFRAC == 3) && !defined(COOL_MOLECFRAC_GD)
#define COOL_MOLECFRAC_GD // estimate f_H2 from approximate large-scale expressions from Gnedin & Draine (2014ApJ...795...37G). use the sub-grid final expression calibrated to ~60pc resolution simulations with equilibrium molecular chemistry and post-processing radiative transfer from Gnedin & Draine 2014 (Eqs. 5-7)
#elif (COOL_MOLECFRAC == 2) && !defined(COOL_MOLECFRAC_KG)
#define COOL_MOLECFRAC_KG // estimate f_H2 with Krumholz & Gnedin 2010 fitting function, assuming simple scalings of radiation field, clumping, and other factors with basic gas properties so function only of surface density and metallicity, truncated at low values (or else it gives non-sensical answers)
#elif (COOL_MOLECFRAC == 1) && !defined(COOL_MOLECFRAC_GC)
#define COOL_MOLECFRAC_GC // if none of the above is set, default to a wildly-oversimplified scaling set by fits to the temperature below which gas at a given density becomes molecular from cloud simulations in Glover+Clark 2012
#else
#define COOL_MOLECFRAC_GC // default if no value above set
#endif
#endif
#ifdef BOX_SHEARING
/* set default compile-time flags for the shearing-box (or shearing-sheet) boundaries */
/* shearing box boundaries: 1=r-z sheet (coordinates [0,1,2] = [r,z,phi]), 2=r-phi sheet [r,phi,z], 3=[r-phi-z] box */
#if (BOX_SHEARING==1)
#define BOX_SHEARING_PHI_COORDINATE 2
#else
#define BOX_SHEARING_PHI_COORDINATE 1
#endif
/* if the r-z or r-phi sheet is set, the code must be compiled in 2D mode */
#if (BOX_SHEARING==1) || (BOX_SHEARING==2)
#ifndef BOX_SPATIAL_DIMENSION
#define BOX_SPATIAL_DIMENSION 2
#endif
#endif
/* box must be periodic in this approximation */
#ifndef BOX_PERIODIC
#define BOX_PERIODIC
#endif
/* if not set, default to q=3/2 (q==-dlnOmega/dlnr, used for boundary and velocity corrections) */
#ifndef BOX_SHEARING_Q
#define BOX_SHEARING_Q (3.0/2.0)
#endif
/* set omega - usually we will default to always using time coordinates such that Omega = 1 at the box center */
#define BOX_SHEARING_OMEGA_BOX_CENTER 1.0
/* need analytic gravity on so we can add the appropriate source terms to the EOM */
#ifndef GRAVITY_ANALYTIC
#define GRAVITY_ANALYTIC
#endif
/* if self-gravity is on, we need to make sure the gravitational forces are not periodic. this is going to cause some errors at the x/y 'edges',
but for now at least, the periodic gravity routines (particularly the FFT's involved) require a regular periodic map, they cannot handle the
non-standard map that the shearing box represents. */
#ifndef GRAVITY_NOT_PERIODIC
#define GRAVITY_NOT_PERIODIC
#endif
#endif // BOX_SHEARING
#if defined(SPECIAL_POINT_MOTION)
#if !defined(BH_CALC_DISTANCES)
#define BH_CALC_DISTANCES /* make sure the distance tracking is actually enabled */
#endif
#if CHECK_IF_PREPROCESSOR_HAS_NUMERICAL_VALUE_(SPECIAL_POINT_MOTION)
#define SPECIAL_POINT_TYPE_FOR_NODE_DISTANCES (SPECIAL_POINT_MOTION) /* set the special particle type to be used for tracking */
#endif
#endif
#if defined(BH_CALC_DISTANCES) && !defined(SPECIAL_POINT_TYPE_FOR_NODE_DISTANCES)
#define SPECIAL_POINT_TYPE_FOR_NODE_DISTANCES (5) /* default to type = 5 for this module */
#endif
#if defined(GRAVITY_ANALYTIC)
#if CHECK_IF_PREPROCESSOR_HAS_NUMERICAL_VALUE_(GRAVITY_ANALYTIC)
#if (GRAVITY_ANALYTIC > 0)
#define GRAVITY_ANALYTIC_ANCHOR_TO_PARTICLE /* ok, analytic gravity is defined with a numerical value > 0, indicating we should use this flag */
#ifndef BH_CALC_DISTANCES
#define BH_CALC_DISTANCES
#endif
#endif
#endif
#endif
#if defined(EOS_SUBSTELLAR_ISM) || defined(COOL_MOLECFRAC_NONEQM)
#define EOS_GAMMA_VARIABLE
#endif
#ifdef EOS_PRECOMPUTE // cache EOS quantities - default to storing temperature and adiabatic index
#define EOS_CARRIES_TEMPERATURE
#define EOS_CARRIES_GAMMA
#endif
#if defined(EOS_GAMMA_VARIABLE)
#define GAMMA(i) (gamma_eos(i)) /*! use an actual function! */
#ifndef EOS_GENERAL
#define EOS_GENERAL /*! needs to be on for this to work */
#endif
#else
#define GAMMA(i) (EOS_GAMMA) /*! default to this being a universal constant */
#endif
#define GAMMA_DEFAULT (EOS_GAMMA)
#if defined(CONDUCTION) || defined(EOS_GENERAL)
#define DOGRAD_INTERNAL_ENERGY 1
#endif
#if defined(EOS_GENERAL)
#define DOGRAD_SOUNDSPEED 1
#endif
/*------- Things that are always recommended -------*/
#ifdef MPISENDRECV_SIZELIMIT
#undef MPI_Sendrecv
#define MPI_Sendrecv MPI_Sizelimited_Sendrecv
#endif
#ifdef MPISENDRECV_CHECKSUM
#undef MPI_Sendrecv
#define MPI_Sendrecv MPI_Check_Sendrecv
#endif
#include "tags.h"
#include <assert.h>
#ifdef MYSORT
#define MYSORT_DATAINDEX mysort_dataindex
#else // MYSORT
#define MYSORT_DATAINDEX qsort
#endif
#ifndef DISABLE_MEMORY_MANAGER // compiler specific data alignment hints: use only with memory manager as malloc'd memory is not sufficiently aligned
// (experimenting right now with removing this, as many compilers internal AVX optimizations appear to be doing marginally better, and can resolve crashes on some compilers)
#if defined(__xlC__) // XLC compiler
#define ALIGN(n) __attribute__((__aligned__(n)))
#elif defined(__GNUC__) // GNU compiler
#define ALIGN(n) __attribute__((__aligned__(n)))
#elif defined(__INTEL_COMPILER) // Intel Compiler
#define ALIGN(n) __declspec(align(n))
#endif
#endif
#ifndef ALIGN // Unknown Compiler or using default malloc
#define ALIGN(n)
#endif
#define ASSIGN_ADD(x,y,mode) (mode == 0 ? (x=y) : (x+=y))
#ifndef GALSF_GENERATIONS
#define GALSF_GENERATIONS 1 /*!< Number of star particles that may be created per gas particle */
#endif
#ifdef LONG_INTEGER_TIME
typedef long long integertime;
static MPI_Datatype MPI_TYPE_TIME = MPI_LONG_LONG;
#define TIMEBINS 60
#else
typedef int integertime;
static MPI_Datatype MPI_TYPE_TIME = MPI_INT;
#define TIMEBINS 29
#endif
#define TIMEBASE (((integertime) 1)<<TIMEBINS) /* The simulated timespan is mapped onto the integer interval [0,TIMESPAN], where TIMESPAN needs to be a power of 2. Note that (1<<28) corresponds to 2^29 */
#ifdef USE_TIMESTEP_DILATION_FOR_ZOOMS
#define TIMESTEP_DILATION_FACTOR(i,mode) (return_timestep_dilation_factor(i,mode))
#else
#define TIMESTEP_DILATION_FACTOR(i,mode) (1)
#endif
#define UNIT_INTEGERTIME_IN_PHYSICAL(i) ((All.Timebase_interval/All.cf_hubble_a) * TIMESTEP_DILATION_FACTOR(i,0))
#define GET_INTEGERTIME_FROM_TIMEBIN(bin) ((bin ? (((integertime) 1) << bin) : 0))
#define GET_PHYSICAL_TIMESTEP_FROM_TIMEBIN(bin, i) ((GET_INTEGERTIME_FROM_TIMEBIN(bin) * UNIT_INTEGERTIME_IN_PHYSICAL(i)))
#ifndef WAKEUP
#define GET_PARTICLE_INTEGERTIME(i) ((GET_INTEGERTIME_FROM_TIMEBIN(P[i].TimeBin)))
#else
#define GET_PARTICLE_INTEGERTIME(i) ((P[i].dt_step))
#endif
#define GET_PARTICLE_TIMESTEP_IN_PHYSICAL(i) ((GET_PARTICLE_INTEGERTIME(i) * UNIT_INTEGERTIME_IN_PHYSICAL(i)))
#ifdef GALSF_LIMIT_FBTIMESTEPS_FROM_BELOW
#define GET_PARTICLE_FEEDBACK_TIMESTEP_IN_PHYSICAL(i) DMAX(GET_PARTICLE_TIMESTEP_IN_PHYSICAL(i), All.Dt_Min_Between_FBCalc_Gyr/UNIT_TIME_IN_GYR)
#else
#define GET_PARTICLE_FEEDBACK_TIMESTEP_IN_PHYSICAL(i) GET_PARTICLE_TIMESTEP_IN_PHYSICAL(i)
#endif
#ifdef DILATION_FOR_STELLAR_KINEMATICS_ONLY
#undef GET_PARTICLE_FEEDBACK_TIMESTEP_IN_PHYSICAL
#define GET_PARTICLE_FEEDBACK_TIMESTEP_IN_PHYSICAL(i) (GET_PARTICLE_INTEGERTIME(i) * (All.Timebase_interval/All.cf_hubble_a)) /* this timestep does -not- involve dilation */
#endif
#ifdef AGS_HSML_CALCULATION_IS_ACTIVE
#define OUTPUT_SOFTENING /*! output softening to snapshots */
//#define AGS_OUTPUTZETA 1 /*! output correction zeta term to snapshots */
#endif
#ifdef NUCLEAR_NETWORK
#include "nuclear/nuclear_network.h"
#endif
#if defined(RADTRANSFER) || defined(RT_USE_GRAVTREE)
#define RT_BIN0 (-1)
#ifndef RT_CHEM_PHOTOION
#define RT_FREQ_BIN_H0 (RT_BIN0+0)
#else
#define RT_FREQ_BIN_H0 (RT_BIN0+1)
#endif
#ifndef RT_PHOTOION_MULTIFREQUENCY
#define RT_FREQ_BIN_He0 (RT_FREQ_BIN_H0+0)
#define RT_FREQ_BIN_He1 (RT_FREQ_BIN_He0+0)
#define RT_FREQ_BIN_He2 (RT_FREQ_BIN_He1+0)
#else
#define RT_FREQ_BIN_He0 (RT_FREQ_BIN_H0+1)
#define RT_FREQ_BIN_He1 (RT_FREQ_BIN_He0+1)
#define RT_FREQ_BIN_He2 (RT_FREQ_BIN_He1+1)
#endif
#ifdef RT_CHEM_PHOTOION
#define RT_BAND_IS_IONIZING(k) ((k==RT_FREQ_BIN_H0) || (k==RT_FREQ_BIN_He0) || (k==RT_FREQ_BIN_He1) || (k==RT_FREQ_BIN_He2))
#endif
#ifndef GALSF_FB_FIRE_RT_LONGRANGE
#define RT_FREQ_BIN_FIRE_UV (RT_FREQ_BIN_He2+0)
#define RT_FREQ_BIN_FIRE_OPT (RT_FREQ_BIN_FIRE_UV+0)
#define RT_FREQ_BIN_FIRE_IR (RT_FREQ_BIN_FIRE_OPT+0)
#else
#define RT_FREQ_BIN_FIRE_UV (RT_FREQ_BIN_He2+1)
#define RT_FREQ_BIN_FIRE_OPT (RT_FREQ_BIN_FIRE_UV+1)
#define RT_FREQ_BIN_FIRE_IR (RT_FREQ_BIN_FIRE_OPT+1)
#endif