From a72aaa2e4d4d53b83c4198cdfd460726c34e47ee Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <schaller@strw.leidenuniv.nl> Date: Thu, 8 Aug 2019 22:01:02 +0200 Subject: [PATCH] Use the correct constant for the abundance array size in the EAGLE cooling. --- src/cooling/EAGLE/cooling.c | 4 ++-- src/cooling/EAGLE/cooling_rates.h | 9 +++------ src/cooling/EAGLE/cooling_tables.c | 4 ---- src/cooling/EAGLE/newton_cooling.c | 6 +++--- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/cooling/EAGLE/cooling.c b/src/cooling/EAGLE/cooling.c index 3fda0c8004..674631ae52 100644 --- a/src/cooling/EAGLE/cooling.c +++ b/src/cooling/EAGLE/cooling.c @@ -207,7 +207,7 @@ INLINE static double bisection_iter( const float d_He, const double Lambda_He_reion_cgs, const double ratefact_cgs, const struct cooling_function_data *restrict cooling, - const float abundance_ratio[chemistry_element_count + 2], + const float abundance_ratio[eagle_cooling_N_abundances], const double dt_cgs, const long long ID) { /* Bracketing */ @@ -419,7 +419,7 @@ void cooling_cool_part(const struct phys_const *phys_const, * Note that we need to add S and Ca that are in the tables but not tracked * by the particles themselves. * The order is [H, He, C, N, O, Ne, Mg, Si, S, Ca, Fe] */ - float abundance_ratio[chemistry_element_count + 2]; + float abundance_ratio[eagle_cooling_N_abundances]; abundance_ratio_to_solar(p, cooling, abundance_ratio); /* Get the Hydrogen and Helium mass fractions */ diff --git a/src/cooling/EAGLE/cooling_rates.h b/src/cooling/EAGLE/cooling_rates.h index 6707a9a9d7..bf908c3a7c 100644 --- a/src/cooling/EAGLE/cooling_rates.h +++ b/src/cooling/EAGLE/cooling_rates.h @@ -43,16 +43,13 @@ * We also re-order the elements such that they match the order of the * tables. This is [H, He, C, N, O, Ne, Mg, Si, S, Ca, Fe]. * - * The solar abundances table (from the cooling struct) is arranged as - * [H, He, C, N, O, Ne, Mg, Si, S, Ca, Fe]. - * * @param p Pointer to #part struct. * @param cooling #cooling_function_data struct. * @param ratio_solar (return) Array of ratios to solar abundances. */ __attribute__((always_inline)) INLINE void abundance_ratio_to_solar( const struct part *p, const struct cooling_function_data *cooling, - float ratio_solar[chemistry_element_count + 2]) { + float ratio_solar[eagle_cooling_N_abundances]) { ratio_solar[0] = p->chemistry_data.smoothed_metal_mass_fraction[chemistry_element_H] * @@ -313,7 +310,7 @@ __attribute__((always_inline)) INLINE double eagle_Compton_cooling_rate( */ INLINE static double eagle_metal_cooling_rate( const double log10_u_cgs, const double redshift, const double n_H_cgs, - const float solar_ratio[chemistry_element_count + 2], const int n_H_index, + const float solar_ratio[eagle_cooling_N_abundances], const int n_H_index, const float d_n_H, const int He_index, const float d_He, const struct cooling_function_data *cooling, double *element_lambda) { @@ -537,7 +534,7 @@ INLINE static double eagle_metal_cooling_rate( */ INLINE static double eagle_cooling_rate( const double log10_u_cgs, const double redshift, const double n_H_cgs, - const float abundance_ratio[chemistry_element_count + 2], + const float abundance_ratio[eagle_cooling_N_abundances], const int n_H_index, const float d_n_H, const int He_index, const float d_He, const struct cooling_function_data *cooling) { diff --git a/src/cooling/EAGLE/cooling_tables.c b/src/cooling/EAGLE/cooling_tables.c index cddc8d50e0..4261e9ac0a 100644 --- a/src/cooling/EAGLE/cooling_tables.c +++ b/src/cooling/EAGLE/cooling_tables.c @@ -213,10 +213,6 @@ void read_cooling_header(const char *fname, if (N_SolarAbundances != eagle_cooling_N_abundances) error("Invalid solar abundances array length."); - /* Check value */ - if (N_SolarAbundances != chemistry_element_count + 2) - error("Number of abundances not compatible with the chemistry model."); - dataset = H5Dopen(tempfile_id, "/Header/Number_of_metals", H5P_DEFAULT); status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &N_Elements); diff --git a/src/cooling/EAGLE/newton_cooling.c b/src/cooling/EAGLE/newton_cooling.c index c68a776144..e86ebb7a2f 100644 --- a/src/cooling/EAGLE/newton_cooling.c +++ b/src/cooling/EAGLE/newton_cooling.c @@ -214,7 +214,7 @@ __attribute__((always_inline)) INLINE double eagle_convert_u_to_temp( */ INLINE static double eagle_metal_cooling_rate( double log10_u_cgs, double redshift, double n_H_cgs, - const float solar_ratio[chemistry_element_count + 2], int n_H_index, + const float solar_ratio[eagle_cooling_N_abundances], int n_H_index, float d_n_H, int He_index, float d_He, const struct cooling_function_data *restrict cooling, double *dlambda_du, double *element_lambda) { @@ -569,7 +569,7 @@ INLINE static double eagle_metal_cooling_rate( */ INLINE static double eagle_cooling_rate( double log_u_cgs, double redshift, double n_H_cgs, - const float abundance_ratio[chemistry_element_count + 2], int n_H_index, + const float abundance_ratio[eagle_cooling_N_abundances], int n_H_index, float d_n_H, int He_index, float d_He, const struct cooling_function_data *restrict cooling, double *dLambdaNet_du) { @@ -609,7 +609,7 @@ INLINE static double eagle_metal_cooling_rate( const struct cosmology *restrict cosmo, const struct cooling_function_data *restrict cooling, const struct phys_const *restrict phys_const, - const float abundance_ratio[chemistry_element_count + 2], + const float abundance_ratio[eagle_cooling_N_abundances], float dt, int *bisection_flag) { double logu, logu_old; -- GitLab