MP-Gadget  5.0.1.dev1-76bc7d4726-dirty
cooling.h
Go to the documentation of this file.
1 #ifndef _COOLING_H_
2 #define _COOLING_H_
3 
4 #include "cosmology.h"
5 
6 /* Ultra-violet background structure.
7  * Can be changed on a particle-by-particle basis*/
8 struct UVBG {
9  double gJH0;
10  double gJHep;
11  double gJHe0;
12  double epsH0;
13  double epsHep;
14  double epsHe0;
16  double zreion;
17 };
18 
19 /*Global unit system for the cooling module*/
21 {
22  /*Flag to enable or disable all cooling.*/
23  int CoolingOn;
24  /*Factor to convert internal density to cgs. By default should be UnitDensity_in_cgs * h^2 */
25  double density_in_phys_cgs; //All.UnitDensity_in_cgs * All.CP.HubbleParam * All.CP.HubbleParam
26  /*Factor to convert internal internal energy to cgs. By default should be UnitEnergy_in_cgs / UnitMass_in_cgs */
27  double uu_in_cgs; //All.UnitEnergy_in_cgs / All.UnitMass_in_cgs
28  /*Factor to convert time to s. By default should be UnitTime_in_s / h */
29  double tt_in_s; //All.UnitTime_in_s / All.CP.HubbleParam
30  /* Baryonic critial density in g cm^-3 at z=0 */
32 };
33 
34 /*Initialise the cooling module.*/
35 void init_cooling(const char * TreeCoolFile, const char * MetalCoolFile, char * reion_hist_file, struct cooling_units cu, Cosmology * CP);
36 
37 /*Reads and initialises the tables for a spatially varying redshift of reionization*/
38 void init_uvf_table(const char * UVFluctuationFile, const int UVFlucLen, const double BoxSize, const double UnitLength_in_cm);
39 
40 /* Get the cooling time for a particle from the internal energy and density, specifying a UVB appropriately.
41  * Sets ne_guess to the equilibrium electron density.*/
42 double GetCoolingTime(double redshift, double u_old, double rho, struct UVBG * uvbg, double *ne_guess, double Z);
43 
44 /*Get the new internal energy per unit mass. ne_guess is set to the new internal equilibrium electron density*/
45 double DoCooling(double redshift, double u_old, double rho, double dt, struct UVBG * uvbg, double *ne_guess, double Z, double MinEgySpec, int isHeIIIionized);
46 
47 /*Interpolates the ultra-violet background tables to the desired redshift and returns a cooling rate table*/
48 struct UVBG get_global_UVBG(double redshift);
49 
50 /* Change the ultra-violet background table according to a pre-computed table of UV fluctuations.
51  * This zeros the UVBG if this particular particle has not reionized yet*/
52 struct UVBG get_local_UVBG(double redshift, const struct UVBG * const GlobalUVBG, const double * const Pos, const double * const PosOffset);
53 
54 /*Get the equilibrium temperature at given internal energy.
55  density is total gas density in protons/cm^3
56  Internal energy is in J/kg == 10^-10 ergs/g.
57  helium is a mass fraction*/
58 double get_temp(double density, double ienergy, double helium, const struct UVBG * uvbg, double * ne_init);
59 
60 /*Gets the neutral fraction from density and internal energy in internal units.
61  u_old is in internal units. rho is in internal physical density units and is converted to
62  physical protons/cm^3 inside the function. */
63 double GetNeutralFraction(double u_old, double rho, const struct UVBG * uvbg, double ne);
64 
65 /*Gets the helium ionic fractions from density and internal energy in internal units.
66  u_old is in internal units. rho is in internal physical density units and is converted to
67  physical protons/cm^3 inside the function. */
68 double GetHeliumIonFraction(int ion, double u_old, double rho, const struct UVBG * uvbg, double ne_init);
69 
70 #endif
double GetNeutralFraction(double u_old, double rho, const struct UVBG *uvbg, double ne)
Definition: cooling.c:181
void init_cooling(const char *TreeCoolFile, const char *MetalCoolFile, char *reion_hist_file, struct cooling_units cu, Cosmology *CP)
Definition: cooling.c:36
double GetCoolingTime(double redshift, double u_old, double rho, struct UVBG *uvbg, double *ne_guess, double Z)
Definition: cooling.c:157
void init_uvf_table(const char *UVFluctuationFile, const int UVFlucLen, const double BoxSize, const double UnitLength_in_cm)
double get_temp(double density, double ienergy, double helium, const struct UVBG *uvbg, double *ne_init)
struct UVBG get_local_UVBG(double redshift, const struct UVBG *const GlobalUVBG, const double *const Pos, const double *const PosOffset)
struct UVBG get_global_UVBG(double redshift)
double DoCooling(double redshift, double u_old, double rho, double dt, struct UVBG *uvbg, double *ne_guess, double Z, double MinEgySpec, int isHeIIIionized)
Definition: cooling.c:71
double GetHeliumIonFraction(int ion, double u_old, double rho, const struct UVBG *uvbg, double ne_init)
Definition: cooling.c:192
void density(const ActiveParticles *act, int update_hsml, int DoEgyDensity, int BlackHoleOn, double MinEgySpec, const DriftKickTimes times, Cosmology *CP, struct sph_pred_data *SPH_predicted, MyFloat *GradRho, const ForceTree *const tree)
Definition: density.c:203
static Cosmology * CP
Definition: power.c:27
static double UnitLength_in_cm
Definition: power.c:26
Definition: cooling.h:8
double epsHep
Definition: cooling.h:13
double epsH0
Definition: cooling.h:12
double gJHep
Definition: cooling.h:10
double gJHe0
Definition: cooling.h:11
double gJH0
Definition: cooling.h:9
double self_shield_dens
Definition: cooling.h:15
double epsHe0
Definition: cooling.h:14
double zreion
Definition: cooling.h:16
double rho_crit_baryon
Definition: cooling.h:31
int CoolingOn
Definition: cooling.h:23
double density_in_phys_cgs
Definition: cooling.h:25
double tt_in_s
Definition: cooling.h:29
double uu_in_cgs
Definition: cooling.h:27