MP-Gadget  5.0.1.dev1-76bc7d4726-dirty
Classes | Enumerations | Functions
cooling_rates.h File Reference
#include "cooling.h"
#include "utils/paramset.h"
Include dependency graph for cooling_rates.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  cooling_params
 

Enumerations

enum  RecombType { Cen92 = 0 , Verner96 = 1 , Badnell06 = 2 }
 
enum  CoolingType { KWH92 = 0 , Enzo2Nyx = 1 , Sherwood =2 }
 
enum  CoolProcess { RECOMB , COLLIS , FREEFREE , HEAT }
 

Functions

void set_cooling_params (ParameterSet *ps)
 
void set_coolpar (struct cooling_params cp)
 
void init_cooling_rates (const char *TreeCoolFile, const char *MetalCoolFile, Cosmology *CP)
 
void InitMetalCooling (const char *MetalCoolFile)
 
double TableMetalCoolingRate (double redshift, double temp, double nHcgs)
 
double get_equilib_ne (double density, double ienergy, double helium, double *logt, const struct UVBG *uvbg, double ne_init)
 
double get_ne_by_nh (double density, double ienergy, double helium, const struct UVBG *uvbg, double ne_init)
 
double get_heatingcooling_rate (double density, double ienergy, double helium, double redshift, double metallicity, const struct UVBG *uvbg, double *ne_equilib)
 
double get_individual_cooling (enum CoolProcess process, double density, double ienergy, double helium, const struct UVBG *uvbg, double *ne_equilib)
 
double get_compton_cooling (double density, double ienergy, double helium, double redshift, double nebynh)
 
double get_neutral_fraction_phys_cgs (double density, double ienergy, double helium, const struct UVBG *uvbg, double *ne_init)
 
double get_helium_ion_phys_cgs (int ion, double density, double ienergy, double helium, const struct UVBG *uvbg, double ne_init)
 

Enumeration Type Documentation

◆ CoolingType

Enumerator
KWH92 
Enzo2Nyx 
Sherwood 

Definition at line 16 of file cooling_rates.h.

16  {
17  KWH92 = 0, //Cooling from KWH 92
18  Enzo2Nyx = 1, //Updated cooling rates from Avery Meiksin, used in Nyx and Enzo 2.
19  Sherwood =2 , //Same as KWH92, but with an improved large temperature correction factor.
20 };
@ Sherwood
Definition: cooling_rates.h:19
@ KWH92
Definition: cooling_rates.h:17
@ Enzo2Nyx
Definition: cooling_rates.h:18

◆ CoolProcess

Enumerator
RECOMB 
COLLIS 
FREEFREE 
HEAT 

Definition at line 94 of file cooling_rates.h.

94  {
95  RECOMB,
96  COLLIS,
97  FREEFREE,
98  HEAT
99 };
@ RECOMB
Definition: cooling_rates.h:95
@ HEAT
Definition: cooling_rates.h:98
@ COLLIS
Definition: cooling_rates.h:96
@ FREEFREE
Definition: cooling_rates.h:97

◆ RecombType

enum RecombType
Enumerator
Cen92 
Verner96 
Badnell06 

Definition at line 10 of file cooling_rates.h.

10  {
11  Cen92 = 0, // Recombination from Cen 92
12  Verner96 = 1, //Verner 96 recombination rates. Basically accurate, used by Sherwood and Nyx by default.
13  Badnell06 = 2, //Even more up to date rates from Badnell 2006, cloudy's current default.
14 };
@ Cen92
Definition: cooling_rates.h:11
@ Verner96
Definition: cooling_rates.h:12
@ Badnell06
Definition: cooling_rates.h:13

Function Documentation

◆ get_compton_cooling()

double get_compton_cooling ( double  density,
double  ienergy,
double  helium,
double  redshift,
double  nebynh 
)

Definition at line 1034 of file cooling_rates.c.

1035 {
1036  double nh = density * (1 - helium);
1037  double temp = get_temp_internal(nebynh, ienergy, helium);
1038  /*Compton cooling in erg/s cm^3*/
1039  double LambdaCmptn = -1*nebynh * cool_InverseCompton(temp, redshift) / nh;
1040  return LambdaCmptn * pow(1 - helium, 2) * density / PROTONMASS;
1041 }
static double cool_InverseCompton(double temp, double redshift)
static double get_temp_internal(double nebynh, double ienergy, double helium)
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
#define PROTONMASS
Definition: physconst.h:21

References cool_InverseCompton(), density(), get_temp_internal(), and PROTONMASS.

Here is the call graph for this function:

◆ get_equilib_ne()

double get_equilib_ne ( double  density,
double  ienergy,
double  helium,
double *  logt,
const struct UVBG uvbg,
double  ne_init 
)

Definition at line 683 of file cooling_rates.c.

684 {
685  /*Get hydrogen number density*/
686  double nh = density * (1-helium);
687  /* Avoid getting stuck in an alternate solution
688  * where there is never any heating in the presence of roundoff.*/
689  if(ne_init <= 0)
690  ne_init = 1.0;
691  return scipy_optimize_fixed_point(ne_init, nh, ienergy, helium, logt, uvbg);
692 }
static double scipy_optimize_fixed_point(double ne_init, double nh, double ienergy, double helium, double *logt, const struct UVBG *uvbg)

References density(), and scipy_optimize_fixed_point().

Referenced by get_heatingcooling_rate(), get_helium_ion_phys_cgs(), get_individual_cooling(), get_ne_by_nh(), get_neutral_fraction_phys_cgs(), get_temp(), and test_rate_network().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_heatingcooling_rate()

double get_heatingcooling_rate ( double  density,
double  ienergy,
double  helium,
double  redshift,
double  metallicity,
const struct UVBG uvbg,
double *  ne_equilib 
)

Definition at line 1104 of file cooling_rates.c.

1105 {
1106  double logt;
1107  double ne = get_equilib_ne(density, ienergy, helium, &logt, uvbg, *ne_equilib);
1108  double nh = density * (1 - helium);
1109  double nebynh = ne/nh;
1110  /*Faster than running the exp.*/
1111  double temp = get_temp_internal(nebynh, ienergy, helium);
1112  double photofac = self_shield_corr(nh, logt, uvbg->self_shield_dens);
1113 
1114  /*The helium number fraction*/
1115  double yy = helium / 4 / (1 - helium);
1116 
1117  double nH0 = nH0_internal(logt, ne, uvbg, photofac);
1118  double nHp = nHp_internal(nH0);
1119  struct he_ions He = nHe_internal(nh, logt, ne, uvbg, photofac);
1120  /*Put the abundances in units of nH to avoid underflows*/
1121  He.nHep*= yy/nh;
1122  He.nHe0*= yy/nh;
1123  He.nHepp*= yy/nh;
1124  /*Collisional ionization and excitation rate*/
1125  double LambdaCollis = nebynh * (get_interpolated_recomb(logt, cool_collisH0, cool_CollisionalH0) * nH0 +
1128  double LambdaRecomb = nebynh * (get_interpolated_recomb(logt, cool_recombHp, cool_RecombHp) * nHp +
1131  /*Free-free cooling rate*/
1132  double LambdaFF = 0;
1133 
1135 
1136  if(CoolingParams.cooling == Enzo2Nyx) {
1137  LambdaFF = nebynh * (cff * (nHp + He.nHep) + cool_FreeFree(temp, 2) * He.nHepp);
1138  } else {
1139  /*The factor of (zz=2)^2 has been pulled out, so if we use the Spitzer gaunt factor we don't need
1140  * to call the FreeFree function again.*/
1141  LambdaFF = nebynh * (cff * (nHp + He.nHep) + 4 * cff * He.nHepp);
1142  }
1143  /*Compton cooling in erg/s cm^3*/
1144  double LambdaCmptn = nebynh * cool_InverseCompton(temp, redshift) / nh;
1145  /*Total cooling rate per proton in erg/s cm^3*/
1146  double Lambda = LambdaCollis + LambdaRecomb + LambdaFF + LambdaCmptn;
1147 
1148  /*Total heating rate per proton in erg/s cm^3*/
1149  double Heat = (nH0 * uvbg->epsH0 + He.nHe0 * uvbg->epsHe0 + He.nHep * uvbg->epsHep)/nh;
1150 
1151  Heat *= cool_he_reion_factor(density, helium, redshift);
1152  /*Set external equilibrium electron density*/
1153  *ne_equilib = nebynh;
1154 
1155  /*Apply metal cooling. Does nothing if metal cooling is disabled*/
1156  double MetalCooling = metallicity * TableMetalCoolingRate(redshift, temp, nh);
1157 
1158  double LambdaNet = Heat - Lambda - MetalCooling;
1159 
1160  //message(1, "Heat = %g Lambda = %g MetalCool = %g LC = %g LR = %g LFF = %g LCmptn = %g, ne = %g, nH0 = %g, nHp = %g, nHe0 = %g, nHep = %g, nHepp = %g, nh=%g, temp=%g, ienergy=%g\n", Heat, Lambda, MetalCooling, LambdaCollis, LambdaRecomb, LambdaFF, LambdaCmptn, nebynh, nH0, nHp, nHe0, nHep, nHepp, nh, temp, ienergy);
1161 
1162  /* LambdaNet in erg cm^3 /s, Density in protons/cm^3, PROTONMASS in protons/g.
1163  * Convert to erg/s/g*/
1164  return LambdaNet * pow(1 - helium, 2) * density / PROTONMASS;
1165 }
static double cool_FreeFree(double temp, int zz)
static struct he_ions nHe_internal(double nh, double logt, double ne, const struct UVBG *uvbg, double photofac)
static double nHp_internal(double nH0)
static double * cool_recombHePP
static double * cool_freefree1
static double * cool_collisHe0
static double * cool_recombHp
double get_equilib_ne(double density, double ienergy, double helium, double *logt, const struct UVBG *uvbg, double ne_init)
static double cool_CollisionalHe0(double temp)
static double nH0_internal(double logt, double ne, const struct UVBG *uvbg, double photofac)
static double cool_FreeFree1(double temp)
static double cool_RecombHePP(double temp)
static double * cool_collisHeP
static double cool_CollisionalH0(double temp)
static double cool_RecombHeP(double temp)
static double * cool_collisH0
static double self_shield_corr(double nh, double logt, double ssdens)
static double cool_he_reion_factor(double nHcgs, double helium, double redshift)
static double cool_CollisionalHeP(double temp)
static double cool_RecombHp(double temp)
static double get_interpolated_recomb(double logt, double *rec_tab, double rec_func(double))
static struct cooling_params CoolingParams
Definition: cooling_rates.c:68
static double * cool_recombHeP
double TableMetalCoolingRate(double redshift, double temp, double nHcgs)
double epsHep
Definition: cooling.h:13
double epsH0
Definition: cooling.h:12
double self_shield_dens
Definition: cooling.h:15
double epsHe0
Definition: cooling.h:14
enum CoolingType cooling
Definition: cooling_rates.h:28
double nHe0
double nHep
double nHepp

References cool_collisH0, cool_collisHe0, cool_collisHeP, cool_CollisionalH0(), cool_CollisionalHe0(), cool_CollisionalHeP(), cool_FreeFree(), cool_freefree1, cool_FreeFree1(), cool_he_reion_factor(), cool_InverseCompton(), cool_recombHeP, cool_RecombHeP(), cool_recombHePP, cool_RecombHePP(), cool_recombHp, cool_RecombHp(), cooling_params::cooling, CoolingParams, density(), Enzo2Nyx, UVBG::epsH0, UVBG::epsHe0, UVBG::epsHep, get_equilib_ne(), get_interpolated_recomb(), get_temp_internal(), nH0_internal(), he_ions::nHe0, nHe_internal(), he_ions::nHep, he_ions::nHepp, nHp_internal(), PROTONMASS, self_shield_corr(), UVBG::self_shield_dens, and TableMetalCoolingRate().

Referenced by get_lambdanet(), GetCoolingTime(), and test_heatingcooling_rate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_helium_ion_phys_cgs()

double get_helium_ion_phys_cgs ( int  ion,
double  density,
double  ienergy,
double  helium,
const struct UVBG uvbg,
double  ne_init 
)

Definition at line 1202 of file cooling_rates.c.

1203 {
1204  double logt;
1205  double ne = get_equilib_ne(density, ienergy, helium, &logt, uvbg, ne_init);
1206  double yy = helium / 4 / (1 - helium);
1207  double nh = density * (1-helium);
1208  double photofac = self_shield_corr(nh, logt, uvbg->self_shield_dens);
1209  struct he_ions He = nHe_internal(nh, logt, ne, uvbg, photofac);
1210  if(ion == 0)
1211  return yy * He.nHe0 / nh;
1212  else if (ion == 1)
1213  return yy * He.nHep / nh;
1214  else
1215  return yy * He.nHepp / nh;
1216 }

References density(), get_equilib_ne(), he_ions::nHe0, nHe_internal(), he_ions::nHep, he_ions::nHepp, self_shield_corr(), and UVBG::self_shield_dens.

Referenced by GetHeliumIonFraction().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_individual_cooling()

double get_individual_cooling ( enum CoolProcess  process,
double  density,
double  ienergy,
double  helium,
const struct UVBG uvbg,
double *  ne_equilib 
)

Definition at line 1046 of file cooling_rates.c.

1047 {
1048  double logt;
1049  double ne = get_equilib_ne(density, ienergy, helium, &logt, uvbg, *ne_equilib);
1050  double nh = density * (1 - helium);
1051  double nebynh = ne/nh;
1052  /*Faster than running the exp.*/
1053  double temp = get_temp_internal(nebynh, ienergy, helium);
1054  double photofac = self_shield_corr(nh, logt, uvbg->self_shield_dens);
1055  double nH0 = nH0_internal(logt, ne, uvbg, photofac);
1056  double nHp = nHp_internal(nH0);
1057  /*The helium number fraction*/
1058  double yy = helium / 4 / (1 - helium);
1059  struct he_ions He = nHe_internal(nh, logt, ne, uvbg, photofac);
1060  /*Put the abundances in units of nH to avoid underflows*/
1061  He.nHep*= yy/nh;
1062  He.nHe0*= yy/nh;
1063  He.nHepp*= yy/nh;
1064 
1065  /*Compton cooling in erg/s cm^3*/
1066  double Lambda = 0;
1067 
1068  if(process == FREEFREE) {
1070  if(CoolingParams.cooling == Enzo2Nyx) {
1071  Lambda = -1*nebynh * (cff * (nHp + He.nHep) + cool_FreeFree(temp, 2) * He.nHepp);
1072  } else {
1073  /*The factor of (zz=2)^2 has been pulled out, so if we use the Spitzer gaunt factor we don't need
1074  * to call the FreeFree function again.*/
1075  Lambda = -1*nebynh * (cff * (nHp + He.nHep) + 4 * cff * He.nHepp);
1076  }
1077  } else if(process == HEAT) {
1078  /*Total heating rate per proton in erg/s cm^3*/
1079  Lambda = (nH0 * uvbg->epsH0 + He.nHe0 * uvbg->epsHe0 + He.nHep * uvbg->epsHep)/nh;
1080  }
1081  else if(process == RECOMB) {
1082  Lambda = -1*nebynh * (get_interpolated_recomb(logt, cool_recombHp, cool_RecombHp) * nHp +
1085  }
1086  else if(process == COLLIS) {
1087  Lambda = -1*nebynh * (get_interpolated_recomb(logt, cool_collisH0, cool_CollisionalH0) * nH0 +
1090  }
1091 
1092  return Lambda * pow(1 - helium, 2) * density / PROTONMASS;
1093 }

References COLLIS, cool_collisH0, cool_collisHe0, cool_collisHeP, cool_CollisionalH0(), cool_CollisionalHe0(), cool_CollisionalHeP(), cool_FreeFree(), cool_freefree1, cool_FreeFree1(), cool_recombHeP, cool_RecombHeP(), cool_recombHePP, cool_RecombHePP(), cool_recombHp, cool_RecombHp(), cooling_params::cooling, CoolingParams, density(), Enzo2Nyx, UVBG::epsH0, UVBG::epsHe0, UVBG::epsHep, FREEFREE, get_equilib_ne(), get_interpolated_recomb(), get_temp_internal(), HEAT, nH0_internal(), he_ions::nHe0, nHe_internal(), he_ions::nHep, he_ions::nHepp, nHp_internal(), PROTONMASS, RECOMB, self_shield_corr(), and UVBG::self_shield_dens.

Here is the call graph for this function:

◆ get_ne_by_nh()

double get_ne_by_nh ( double  density,
double  ienergy,
double  helium,
const struct UVBG uvbg,
double  ne_init 
)

Definition at line 696 of file cooling_rates.c.

697 {
698  double logt;
699  return get_equilib_ne(density, ienergy, helium, &logt, uvbg, ne_init)/(density*(1-helium));
700 }

References density(), and get_equilib_ne().

Here is the call graph for this function:

◆ get_neutral_fraction_phys_cgs()

double get_neutral_fraction_phys_cgs ( double  density,
double  ienergy,
double  helium,
const struct UVBG uvbg,
double *  ne_init 
)

Definition at line 1186 of file cooling_rates.c.

1187 {
1188  double logt;
1189  double ne = get_equilib_ne(density, ienergy, helium, &logt, uvbg, *ne_init);
1190  double nh = density * (1-helium);
1191  double photofac = self_shield_corr(nh, logt, uvbg->self_shield_dens);
1192  *ne_init = ne/nh;
1193  return nH0_internal(logt, ne, uvbg, photofac);
1194 }

References density(), get_equilib_ne(), nH0_internal(), self_shield_corr(), and UVBG::self_shield_dens.

Referenced by GetNeutralFraction(), and test_rate_network().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_cooling_rates()

void init_cooling_rates ( const char *  TreeCoolFile,
const char *  MetalCoolFile,
Cosmology CP 
)

Definition at line 970 of file cooling_rates.c.

971 {
973  CoolingParams.rho_crit_baryon = CP->OmegaBaryon * 3.0 * pow(CP->HubbleParam*HUBBLE,2.0) /(8.0*M_PI*GRAVITY);
974 
975  /* Initialize the interpolation for the self-shielding module as a function of redshift.
976  * A crash has been observed in GSL with a cspline interpolator. */
977  GrayOpac = gsl_interp_alloc(gsl_interp_linear,NGRAY);
978  gsl_interp_init(GrayOpac,GrayOpac_zz,GrayOpac_ydata, NGRAY);
979 
980  if(!TreeCoolFile || strnlen(TreeCoolFile,100) == 0) {
982  message(0, "No TreeCool file is provided. Cooling is broken. OK for DM only runs. \n");
983  }
984  else {
985  message(0, "Using uniform UVB from file %s\n", TreeCoolFile);
986  /* Load the TREECOOL into Gamma_HI->ydata, and initialise the interpolators*/
987  load_treecool(TreeCoolFile);
988  }
989 
990  /*Initialize the recombination tables*/
991  temp_tab = (double *) mymalloc("Recombination_tables", NRECOMBTAB * sizeof(double) * 14);
992 
1006 
1007  int i;
1008  for(i = 0 ; i < NRECOMBTAB; i++)
1009  {
1011  double tt = exp(temp_tab[i]);
1016  /* Note this includes dielectronic recombination*/
1025  cool_freefree1[i] = cool_FreeFree(tt, 1);
1026  }
1027 
1028  /*Initialize the metal cooling table*/
1029  InitMetalCooling(MetalCoolFile);
1030 }
double recomb_alphaHp(double temp)
#define NRECOMBTAB
Definition: cooling_rates.c:95
static double recomb_GammaeH0(double temp)
static void load_treecool(const char *TreeCoolFile)
static double * rec_GammaHe0
static gsl_interp * GrayOpac
Definition: cooling_rates.c:70
#define RECOMBTMIN
Definition: cooling_rates.c:97
static double recomb_GammaeHep(double temp)
static const double GrayOpac_ydata[NGRAY]
Definition: cooling_rates.c:75
static double * rec_GammaHep
static double * rec_alphaHp
Definition: cooling_rates.c:99
static const double GrayOpac_zz[NGRAY]
Definition: cooling_rates.c:76
static double recomb_alphaHepd(double temp)
#define NGRAY
Definition: cooling_rates.c:73
static double * rec_alphaHep
Definition: cooling_rates.c:99
#define RECOMBTMAX
Definition: cooling_rates.c:96
static double recomb_alphaHepp(double temp)
static double * rec_GammaH0
static double * temp_tab
Definition: cooling_rates.c:98
static double * rec_alphaHepp
Definition: cooling_rates.c:99
static double recomb_GammaeHe0(double temp)
void InitMetalCooling(const char *MetalCoolFile)
void message(int where, const char *fmt,...)
Definition: endrun.c:175
#define mymalloc(name, size)
Definition: mymalloc.h:15
#define HUBBLE
Definition: physconst.h:25
#define GRAVITY
Definition: physconst.h:5
static Cosmology * CP
Definition: power.c:27
double HubbleParam
Definition: cosmology.h:20
double OmegaCDM
Definition: cosmology.h:11
double OmegaBaryon
Definition: cosmology.h:19
double rho_crit_baryon
Definition: cooling_rates.h:57
static const double tt[NEXACT]

References cool_collisH0, cool_collisHe0, cool_collisHeP, cool_CollisionalH0(), cool_CollisionalHe0(), cool_CollisionalHeP(), cool_FreeFree(), cool_freefree1, cool_recombHeP, cool_RecombHeP(), cool_recombHePP, cool_RecombHePP(), cool_recombHp, cool_RecombHp(), CoolingParams, CP, cooling_params::fBar, GRAVITY, GrayOpac, GrayOpac_ydata, GrayOpac_zz, HUBBLE, Cosmology::HubbleParam, InitMetalCooling(), load_treecool(), message(), mymalloc, NGRAY, NRECOMBTAB, Cosmology::OmegaBaryon, Cosmology::OmegaCDM, cooling_params::PhotoIonizationOn, rec_alphaHep, rec_alphaHepp, rec_alphaHp, rec_GammaH0, rec_GammaHe0, rec_GammaHep, recomb_alphaHepd(), recomb_alphaHepp(), recomb_alphaHp(), recomb_GammaeH0(), recomb_GammaeHe0(), recomb_GammaeHep(), RECOMBTMAX, RECOMBTMIN, cooling_params::rho_crit_baryon, temp_tab, and tt.

Referenced by init_cooling(), test_heatingcooling_rate(), test_rate_network(), test_recomb_rates(), and test_uvbg_loader().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitMetalCooling()

void InitMetalCooling ( const char *  MetalCoolFile)

Definition at line 193 of file cooling_uvfluc.c.

194 {
195  /* now initialize the metal cooling table from cloudy; we got this file
196  * from vogelsberger's Arepo simulations; it is supposed to be
197  * cloudy + UVB - H and He; look so.
198  * the table contains only 1 Z_sun values. Need to be scaled to the
199  * metallicity.
200  *
201  * */
202  /* let's see if the Metal Cool File is magic NoMetal */
203  if(strlen(MetalCoolFile) == 0) {
204  MetalCool.CoolingNoMetal = 1;
205  return;
206  } else {
207  MetalCool.CoolingNoMetal = 0;
208  }
209 
210  int size;
211  //This is never used if MetalCoolFile == ""
212  double * tabbedmet = read_big_array(MetalCoolFile, "MetallicityInSolar_bins", &size);
213 
214  if(size != 1 || tabbedmet[0] != 0.0) {
215  endrun(123, "MetalCool file %s is wrongly tabulated\n", MetalCoolFile);
216  }
217  myfree(tabbedmet);
218 
219  MetalCool.Redshift_bins = read_big_array(MetalCoolFile, "Redshift_bins", &MetalCool.NRedshift_bins);
220  MetalCool.HydrogenNumberDensity_bins = read_big_array(MetalCoolFile, "HydrogenNumberDensity_bins", &MetalCool.NHydrogenNumberDensity_bins);
221  MetalCool.Temperature_bins = read_big_array(MetalCoolFile, "Temperature_bins", &MetalCool.NTemperature_bins);
222  MetalCool.Lmet_table = read_big_array(MetalCoolFile, "NetCoolingRate", &size);
223 
224  int64_t dims[] = {MetalCool.NRedshift_bins, MetalCool.NHydrogenNumberDensity_bins, MetalCool.NTemperature_bins};
225 
226  interp_init(&MetalCool.interp, 3, dims);
227  interp_init_dim(&MetalCool.interp, 0, MetalCool.Redshift_bins[0], MetalCool.Redshift_bins[MetalCool.NRedshift_bins - 1]);
228  interp_init_dim(&MetalCool.interp, 1, MetalCool.HydrogenNumberDensity_bins[0],
229  MetalCool.HydrogenNumberDensity_bins[MetalCool.NHydrogenNumberDensity_bins - 1]);
230  interp_init_dim(&MetalCool.interp, 2, MetalCool.Temperature_bins[0],
231  MetalCool.Temperature_bins[MetalCool.NTemperature_bins - 1]);
232 }
static double * read_big_array(const char *filename, const char *dataset, int *Nread)
struct @1 MetalCool
void endrun(int where, const char *fmt,...)
Definition: endrun.c:147
void interp_init(Interp *obj, int Ndim, int64_t *dims)
Definition: interp.c:9
void interp_init_dim(Interp *obj, int d, double Min, double Max)
Definition: interp.c:50
#define myfree(x)
Definition: mymalloc.h:19

References endrun(), interp_init(), interp_init_dim(), MetalCool, myfree, and read_big_array().

Referenced by init_cooling_rates().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_cooling_params()

void set_cooling_params ( ParameterSet ps)

Definition at line 942 of file cooling_rates.c.

943 {
944  int ThisTask;
945  MPI_Comm_rank(MPI_COMM_WORLD, &ThisTask);
946  if(ThisTask == 0) {
947  /*Cooling rate network parameters*/
948  CoolingParams.CMBTemperature = param_get_double(ps, "CMBTemperature");
949  CoolingParams.cooling = (enum CoolingType) param_get_enum(ps, "CoolingRates"); // Sherwood;
950  CoolingParams.recomb = (enum RecombType) param_get_enum(ps, "RecombRates"); // Verner96;
951  CoolingParams.SelfShieldingOn = param_get_int(ps, "SelfShieldingOn");
952  CoolingParams.PhotoIonizeFactor = param_get_double(ps, "PhotoIonizeFactor");
953  CoolingParams.PhotoIonizationOn = param_get_int(ps, "PhotoIonizationOn");
954  CoolingParams.MinGasTemp = param_get_double(ps, "MinGasTemp");
955  CoolingParams.UVRedshiftThreshold = param_get_double(ps, "UVRedshiftThreshold");
956  CoolingParams.HydrogenHeatAmp = log10(param_get_double(ps, "HydrogenHeatAmp"));
957 
958  /*Helium model parameters*/
959  CoolingParams.HeliumHeatOn = param_get_int(ps, "HeliumHeatOn");
960  CoolingParams.HeliumHeatThresh = param_get_double(ps, "HeliumHeatThresh");
961  CoolingParams.HeliumHeatAmp = param_get_double(ps, "HeliumHeatAmp");
962  CoolingParams.HeliumHeatExp = param_get_double(ps, "HeliumHeatExp");
963  }
964  MPI_Bcast(&CoolingParams, sizeof(struct cooling_params), MPI_BYTE, 0, MPI_COMM_WORLD);
965 }
CoolingType
Definition: cooling_rates.h:16
RecombType
Definition: cooling_rates.h:10
double param_get_double(ParameterSet *ps, const char *name)
Definition: paramset.c:336
int param_get_int(ParameterSet *ps, const char *name)
Definition: paramset.c:368
int param_get_enum(ParameterSet *ps, const char *name)
Definition: paramset.c:378
double HeliumHeatThresh
Definition: cooling_rates.h:54
double HeliumHeatAmp
Definition: cooling_rates.h:55
enum RecombType recomb
Definition: cooling_rates.h:26
double UVRedshiftThreshold
Definition: cooling_rates.h:47
double CMBTemperature
Definition: cooling_rates.h:41
double HeliumHeatExp
Definition: cooling_rates.h:56
double PhotoIonizeFactor
Definition: cooling_rates.h:38
double HydrogenHeatAmp
Definition: cooling_rates.h:50
int ThisTask
Definition: test_exchange.c:23

References cooling_params::CMBTemperature, cooling_params::cooling, CoolingParams, cooling_params::HeliumHeatAmp, cooling_params::HeliumHeatExp, cooling_params::HeliumHeatOn, cooling_params::HeliumHeatThresh, cooling_params::HydrogenHeatAmp, cooling_params::MinGasTemp, param_get_double(), param_get_enum(), param_get_int(), cooling_params::PhotoIonizationOn, cooling_params::PhotoIonizeFactor, cooling_params::recomb, cooling_params::SelfShieldingOn, ThisTask, and cooling_params::UVRedshiftThreshold.

Referenced by read_parameter_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_coolpar()

void set_coolpar ( struct cooling_params  cp)

Definition at line 936 of file cooling_rates.c.

937 {
938  CoolingParams = cp;
939 }

References CoolingParams.

Referenced by test_DoCooling(), test_heatingcooling_rate(), test_rate_network(), test_recomb_rates(), and test_uvbg_loader().

Here is the caller graph for this function:

◆ TableMetalCoolingRate()

double TableMetalCoolingRate ( double  redshift,
double  temp,
double  nHcgs 
)

Definition at line 235 of file cooling_uvfluc.c.

236 {
237  if(MetalCool.CoolingNoMetal)
238  return 0;
239 
240  double lognH = log10(nHcgs);
241  double logT = log10(temp);
242 
243  double x[] = {redshift, lognH, logT};
244  int status[3];
245  double rate = interp_eval(&MetalCool.interp, x, MetalCool.Lmet_table, status);
246  /* XXX: in case of very hot / very dense we just use whatever the table says at
247  * the limit. should be OK. */
248  return rate;
249 }
double interp_eval(Interp *obj, double *x, double *ydata, int *status)
Definition: interp.c:72

References interp_eval(), and MetalCool.

Referenced by get_heatingcooling_rate().

Here is the call graph for this function:
Here is the caller graph for this function: