Commit bd6d2ffc authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

More standardized API for the COLIBRE and EAGLE cooling flavours

parent b934599d
......@@ -540,7 +540,7 @@ __attribute__((always_inline)) INLINE static void black_holes_prepare_feedback(
const double rho_sub = compute_subgrid_property(
cooling, constants, floor_props, cosmo, gas_rho_phys, logZZsol, XH,
gas_P_phys, log10_gas_T, log10_T_EOS_max, /*HII_region=*/0,
abundance_ratio, 0.f, colibre_compute_subgrid_density);
abundance_ratio, 0.f, cooling_compute_subgrid_density);
/* Record what we used */
bp->rho_subgrid_gas = rho_sub;
......
......@@ -763,7 +763,7 @@ float cooling_get_particle_subgrid_HI_fraction(
cooling, phys_const, floor_props, cosmo, rho_phys, logZZsol, XH, P_phys,
log10_T, log10_T_EOS_max, HII_region, abundance_ratio,
log10(u_phys * cooling->internal_energy_to_cgs),
colibre_compute_subgrid_HI_fraction);
cooling_compute_subgrid_HI_fraction);
}
/**
......@@ -824,7 +824,7 @@ float cooling_get_particle_subgrid_HII_fraction(
cooling, phys_const, floor_props, cosmo, rho_phys, logZZsol, XH, P_phys,
log10_T, log10_T_EOS_max, HII_region, abundance_ratio,
log10(u_phys * cooling->internal_energy_to_cgs),
colibre_compute_subgrid_HII_fraction);
cooling_compute_subgrid_HII_fraction);
}
/**
......@@ -885,7 +885,7 @@ float cooling_get_particle_subgrid_H2_fraction(
cooling, phys_const, floor_props, cosmo, rho_phys, logZZsol, XH, P_phys,
log10_T, log10_T_EOS_max, HII_region, abundance_ratio,
log10(u_phys * cooling->internal_energy_to_cgs),
colibre_compute_subgrid_H2_fraction);
cooling_compute_subgrid_H2_fraction);
}
/**
......@@ -945,7 +945,7 @@ float cooling_get_particle_subgrid_temperature(
cooling, phys_const, floor_props, cosmo, rho_phys, logZZsol, XH, P_phys,
log10_T, log10_T_EOS_max, HII_region, abundance_ratio,
log10(u_phys * cooling->internal_energy_to_cgs),
colibre_compute_subgrid_temperature);
cooling_compute_subgrid_temperature);
}
/**
......@@ -1006,7 +1006,7 @@ float cooling_get_particle_subgrid_density(
return compute_subgrid_property(
cooling, phys_const, floor_props, cosmo, rho_phys, logZZsol, XH, P_phys,
log10_T, log10_T_EOS_max, HII_region, abundance_ratio, log10(u_0_cgs),
colibre_compute_subgrid_density);
cooling_compute_subgrid_density);
}
/**
......@@ -1063,12 +1063,12 @@ void cooling_set_particle_subgrid_properties(
p->cooling_data.subgrid_temp = compute_subgrid_property(
cooling, phys_const, floor_props, cosmo, rho_phys, logZZsol, XH, P_phys,
log10_T, log10_T_EOS_max, HII_region, abundance_ratio, log10(u_cgs),
colibre_compute_subgrid_temperature);
cooling_compute_subgrid_temperature);
p->cooling_data.subgrid_dens = compute_subgrid_property(
cooling, phys_const, floor_props, cosmo, rho_phys, logZZsol, XH, P_phys,
log10_T, log10_T_EOS_max, HII_region, abundance_ratio, log10(u_cgs),
colibre_compute_subgrid_density);
cooling_compute_subgrid_density);
}
/**
......
......@@ -132,7 +132,7 @@ double compute_subgrid_property(
const float XH, const float P_phys, const float log10_T,
const float log10_T_EOS_max, const int HII_region,
const float abundance_ratio[colibre_cooling_N_elementtypes],
const double log_u_cgs, const enum colibre_subgrid_properties isub);
const double log_u_cgs, const enum cooling_subgrid_properties isub);
float cooling_get_radiated_energy(const struct xpart *xp);
......
......@@ -217,4 +217,15 @@ struct cooling_xpart_data {
float radiated_energy;
};
/**
* @brief Subgrid properties to calculate
*/
enum cooling_subgrid_properties {
cooling_compute_subgrid_density,
cooling_compute_subgrid_temperature,
cooling_compute_subgrid_HI_fraction,
cooling_compute_subgrid_HII_fraction,
cooling_compute_subgrid_H2_fraction
};
#endif /* SWIFT_COOLING_STRUCT_COLIBRE_H */
......@@ -185,7 +185,7 @@ double compute_subgrid_property(
const float XH, const float P_phys, const float log10_T,
const float log10_T_EOS_max, const int HII_region,
const float abundance_ratio[colibre_cooling_N_elementtypes],
const double log_u_cgs, const enum colibre_subgrid_properties isub) {
const double log_u_cgs, const enum cooling_subgrid_properties isub) {
if (HII_region)
error("HII regions are not implemented in the EAGLE-XL flavour");
......@@ -199,9 +199,9 @@ double compute_subgrid_property(
/* Start by computing the subgrid property as if it were not subgrid */
if (isub == colibre_compute_subgrid_density) {
if (isub == cooling_compute_subgrid_density) {
standard_return = rho_phys;
} else if (isub == colibre_compute_subgrid_temperature) {
} else if (isub == cooling_compute_subgrid_temperature) {
standard_return = exp10(log10_T);
} else {
......@@ -221,7 +221,7 @@ double compute_subgrid_property(
get_index_1d(cooling->Temp, colibre_cooling_N_temperature, log10_T, &item,
&dtem);
if (isub == colibre_compute_subgrid_HI_fraction) {
if (isub == cooling_compute_subgrid_HI_fraction) {
const float nHI_over_nH =
interpolation4d_plus_summation(cooling->table.logHfracs_all, /* */
......@@ -236,7 +236,7 @@ double compute_subgrid_property(
standard_return = nHI_over_nH;
} else if (isub == colibre_compute_subgrid_HII_fraction) {
} else if (isub == cooling_compute_subgrid_HII_fraction) {
const float nHII_over_nH =
interpolation4d_plus_summation(cooling->table.logHfracs_all, /* */
......@@ -251,7 +251,7 @@ double compute_subgrid_property(
standard_return = nHII_over_nH;
} else if (isub == colibre_compute_subgrid_H2_fraction) {
} else if (isub == cooling_compute_subgrid_H2_fraction) {
const float mH2_over_mH =
interpolation4d_plus_summation(cooling->table.logHfracs_all, /* */
......@@ -356,7 +356,7 @@ double compute_subgrid_property(
* bin */
if (log10_P_cgs > log10_Peq_max_cgs) {
if (isub == colibre_compute_subgrid_density) {
if (isub == cooling_compute_subgrid_density) {
const double rho_cgs =
exp10(cooling->nH[colibre_cooling_N_density - 1]) *
......@@ -364,7 +364,7 @@ double compute_subgrid_property(
return rho_cgs * cooling->density_from_cgs;
} else if (isub == colibre_compute_subgrid_temperature) {
} else if (isub == cooling_compute_subgrid_temperature) {
const float log10_T_at_Peq = interpolation_3d_no_z(
cooling->table.logTeq, ired, imet, colibre_cooling_N_density - 1,
......@@ -373,7 +373,7 @@ double compute_subgrid_property(
return exp10(log10_T_at_Peq);
} else if (isub == colibre_compute_subgrid_HI_fraction) {
} else if (isub == cooling_compute_subgrid_HI_fraction) {
const float log10_HI_over_nH = interpolation_4d_no_z_no_w(
cooling->table.logHfracs_Teq, /* */
......@@ -386,7 +386,7 @@ double compute_subgrid_property(
return exp10(log10_HI_over_nH);
} else if (isub == colibre_compute_subgrid_HII_fraction) {
} else if (isub == cooling_compute_subgrid_HII_fraction) {
const float log10_HII_over_nH = interpolation_4d_no_z_no_w(
cooling->table.logHfracs_Teq, /* */
......@@ -399,7 +399,7 @@ double compute_subgrid_property(
return exp10(log10_HII_over_nH);
} else if (isub == colibre_compute_subgrid_H2_fraction) {
} else if (isub == cooling_compute_subgrid_H2_fraction) {
const float log10_H2_over_nH = interpolation_4d_no_z_no_w(
cooling->table.logHfracs_Teq, /* */
......@@ -475,7 +475,7 @@ double compute_subgrid_property(
* equilibrium temperature function Teq(density,
* metallicity/abundances, redshift) for equal pressure */
if (isub == colibre_compute_subgrid_density) {
if (isub == cooling_compute_subgrid_density) {
const double rho_cgs =
exp10(log10_n_at_Peq) * cooling->proton_mass_cgs / XH;
return rho_cgs * cooling->density_from_cgs;
......@@ -499,7 +499,7 @@ double compute_subgrid_property(
colibre_cooling_N_metallicity, /* */
colibre_cooling_N_density);
if (isub == colibre_compute_subgrid_temperature) {
if (isub == cooling_compute_subgrid_temperature) {
return exp10(log10_T_at_Peq);
} else {
......@@ -510,7 +510,7 @@ double compute_subgrid_property(
get_index_1d(cooling->Temp, colibre_cooling_N_temperature,
log10_T_at_Peq, &item_eq, &dtem_eq);
if (isub == colibre_compute_subgrid_HI_fraction) {
if (isub == cooling_compute_subgrid_HI_fraction) {
const float nHI_over_nH_eq = interpolation4d_plus_summation(
cooling->table.logHfracs_all, /* */
......@@ -525,7 +525,7 @@ double compute_subgrid_property(
return nHI_over_nH_eq;
} else if (isub == colibre_compute_subgrid_HII_fraction) {
} else if (isub == cooling_compute_subgrid_HII_fraction) {
const float nHII_over_nH_eq = interpolation4d_plus_summation(
cooling->table.logHfracs_all, /* */
......@@ -540,7 +540,7 @@ double compute_subgrid_property(
return nHII_over_nH_eq;
} else if (isub == colibre_compute_subgrid_H2_fraction) {
} else if (isub == cooling_compute_subgrid_H2_fraction) {
const float mH2_over_mH_eq = interpolation4d_plus_summation(
cooling->table.logHfracs_all, /* */
......
......@@ -55,17 +55,6 @@
/*! Number of different elements in the tables */
#define colibre_cooling_N_elementtypes 12
/**
* @brief Subgrid properties to calculate
*/
enum colibre_subgrid_properties {
colibre_compute_subgrid_density,
colibre_compute_subgrid_temperature,
colibre_compute_subgrid_HI_fraction,
colibre_compute_subgrid_HII_fraction,
colibre_compute_subgrid_H2_fraction
};
/**
* @brief Elements present in the tables
*/
......
......@@ -585,7 +585,8 @@ __attribute__((always_inline)) INLINE void cooling_first_init_part(
float cooling_get_temperature_from_gas(
const struct phys_const *phys_const, const struct cosmology *cosmo,
const struct cooling_function_data *cooling, const float rho_phys,
const float XH, const float logZZsol, const float u_phys) {
const float XH, const float logZZsol, const float u_phys,
const int HII_region) {
error("Do not call this function");
return -1.f;
......@@ -659,6 +660,20 @@ float cooling_get_temperature(
return exp10(log_10_T);
}
double compute_subgrid_property(
const struct cooling_function_data *cooling,
const struct phys_const *phys_const,
const struct entropy_floor_properties *floor_props,
const struct cosmology *cosmo, const float rho_phys, const float logZZsol,
const float XH, const float P_phys, const float log10_T,
const float log10_T_EOS_max, const int HII_region,
const float *abundance_ratio, const double log_u_cgs,
const enum cooling_subgrid_properties isub) {
error("Do not call this function");
return -1.f;
}
/**
* @brief Compute the physical subgrid density of the gas.
*
......
......@@ -66,7 +66,8 @@ void cooling_first_init_part(
float cooling_get_temperature_from_gas(
const struct phys_const *phys_const, const struct cosmology *cosmo,
const struct cooling_function_data *cooling, const float rho_phys,
const float XH, const float logZZsol, const float u_phys);
const float XH, const float logZZsol, const float u_phys,
const int HII_region);
float cooling_get_temperature(
const struct phys_const *restrict phys_const,
......@@ -76,13 +77,15 @@ float cooling_get_temperature(
const struct cooling_function_data *restrict cooling,
const struct part *restrict p, const struct xpart *restrict xp);
double compute_subgrid_density(
double compute_subgrid_property(
const struct cooling_function_data *cooling,
const struct phys_const *phys_const,
const struct entropy_floor_properties *floor_props,
const struct cosmology *cosmo, const float rho_phys, const float logZZsol,
const float XH, const float P_phys, const float log10_T,
const float log10_T_EOS_max);
const float log10_T_EOS_max, const int HII_region,
const float *abundance_ratio, const double log_u_cgs,
const enum cooling_subgrid_properties isub);
float cooling_get_radiated_energy(const struct xpart *restrict xp);
......@@ -102,4 +105,7 @@ void cooling_print_backend(const struct cooling_function_data *cooling);
void cooling_clean(struct cooling_function_data *data);
/*! Stub defined to let the BH model compile */
#define colibre_cooling_N_elementtypes 1
#endif /* SWIFT_COOLING_EAGLE_H */
......@@ -145,4 +145,15 @@ struct cooling_xpart_data {
float radiated_energy;
};
/**
* @brief Subgrid properties to calculate
*/
enum cooling_subgrid_properties {
cooling_compute_subgrid_density,
cooling_compute_subgrid_temperature,
cooling_compute_subgrid_HI_fraction,
cooling_compute_subgrid_HII_fraction,
cooling_compute_subgrid_H2_fraction
};
#endif /* SWIFT_COOLING_STRUCT_EAGLE_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment