57 get_lambdanet(
double rho,
double u,
double redshift,
double Z,
struct UVBG * uvbg,
double * ne_guess,
int isHeIIIionized)
71 double DoCooling(
double redshift,
double u_old,
double rho,
double dt,
struct UVBG * uvbg,
double *ne_guess,
double Z,
double MinEgySpec,
int isHeIIIionized)
76 double u_lower, u_upper;
83 if(u_old < MinEgySpec)
91 LambdaNet =
get_lambdanet(rho, u, redshift, Z, uvbg, ne_guess, isHeIIIionized);
94 if(u - u_old - LambdaNet * dt < 0)
100 }
while(u_upper - u_old -
get_lambdanet(rho, u_upper, redshift, Z, uvbg, ne_guess, isHeIIIionized) * dt < 0);
108 if(u_upper <= MinEgySpec) {
111 }
while(u_lower - u_old -
get_lambdanet(rho, u_lower, redshift, Z, uvbg, ne_guess, isHeIIIionized) * dt > 0);
116 u = 0.5 * (u_lower + u_upper);
119 if(u_upper <= MinEgySpec) {
124 LambdaNet =
get_lambdanet(rho, u, redshift, Z, uvbg, ne_guess, isHeIIIionized);
126 if(u - u_old - LambdaNet * dt > 0)
135 du = u_upper - u_lower;
142 while(fabs(du / u) > 1.0e-6 && iter <
MAXITER);
146 endrun(10,
"failed to converge in DoCooling()\n");
157 double GetCoolingTime(
double redshift,
double u_old,
double rho,
struct UVBG * uvbg,
double *ne_guess,
double Z)
171 double coolingtime = u_old / (- LambdaNet);
void init_cooling(const char *TreeCoolFile, const char *MetalCoolFile, char *reion_hist_file, struct cooling_units cu, Cosmology *CP)
double GetCoolingTime(double redshift, double u_old, double rho, struct UVBG *uvbg, double *ne_guess, double Z)
static double get_lambdanet(double rho, double u, double redshift, double Z, struct UVBG *uvbg, double *ne_guess, int isHeIIIionized)
static struct cooling_units coolunits
double DoCooling(double redshift, double u_old, double rho, double dt, struct UVBG *uvbg, double *ne_guess, double Z, double MinEgySpec, int isHeIIIionized)
double GetHeliumIonFraction(int ion, double u_old, double rho, const struct UVBG *uvbg, double ne_init)
double GetNeutralFraction(double u_old, double rho, const struct UVBG *uvbg, double ne_init)
double get_long_mean_free_path_heating(double redshift)
void init_qso_lightup(char *reion_hist_file)
double get_helium_ion_phys_cgs(int ion, 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_neutral_fraction_phys_cgs(double density, double ienergy, double helium, const struct UVBG *uvbg, double *ne_init)
void init_cooling_rates(const char *TreeCoolFile, const char *MetalCoolFile, Cosmology *CP)
void message(int where, const char *fmt,...)
void endrun(int where, const char *fmt,...)
#define HYDROGEN_MASSFRAC
double density_in_phys_cgs