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

Use the correct constant for the abundance array size in the EAGLE cooling.

parent 8e1b90a1
...@@ -207,7 +207,7 @@ INLINE static double bisection_iter( ...@@ -207,7 +207,7 @@ INLINE static double bisection_iter(
const float d_He, const double Lambda_He_reion_cgs, const float d_He, const double Lambda_He_reion_cgs,
const double ratefact_cgs, const double ratefact_cgs,
const struct cooling_function_data *restrict cooling, 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) { const double dt_cgs, const long long ID) {
/* Bracketing */ /* Bracketing */
...@@ -419,7 +419,7 @@ void cooling_cool_part(const struct phys_const *phys_const, ...@@ -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 * Note that we need to add S and Ca that are in the tables but not tracked
* by the particles themselves. * by the particles themselves.
* The order is [H, He, C, N, O, Ne, Mg, Si, S, Ca, Fe] */ * 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); abundance_ratio_to_solar(p, cooling, abundance_ratio);
/* Get the Hydrogen and Helium mass fractions */ /* Get the Hydrogen and Helium mass fractions */
......
...@@ -43,16 +43,13 @@ ...@@ -43,16 +43,13 @@
* We also re-order the elements such that they match the order of the * 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]. * 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 p Pointer to #part struct.
* @param cooling #cooling_function_data struct. * @param cooling #cooling_function_data struct.
* @param ratio_solar (return) Array of ratios to solar abundances. * @param ratio_solar (return) Array of ratios to solar abundances.
*/ */
__attribute__((always_inline)) INLINE void abundance_ratio_to_solar( __attribute__((always_inline)) INLINE void abundance_ratio_to_solar(
const struct part *p, const struct cooling_function_data *cooling, 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] = ratio_solar[0] =
p->chemistry_data.smoothed_metal_mass_fraction[chemistry_element_H] * p->chemistry_data.smoothed_metal_mass_fraction[chemistry_element_H] *
...@@ -313,7 +310,7 @@ __attribute__((always_inline)) INLINE double eagle_Compton_cooling_rate( ...@@ -313,7 +310,7 @@ __attribute__((always_inline)) INLINE double eagle_Compton_cooling_rate(
*/ */
INLINE static double eagle_metal_cooling_rate( INLINE static double eagle_metal_cooling_rate(
const double log10_u_cgs, const double redshift, const double n_H_cgs, 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 float d_n_H, const int He_index, const float d_He,
const struct cooling_function_data *cooling, double *element_lambda) { const struct cooling_function_data *cooling, double *element_lambda) {
...@@ -537,7 +534,7 @@ INLINE static double eagle_metal_cooling_rate( ...@@ -537,7 +534,7 @@ INLINE static double eagle_metal_cooling_rate(
*/ */
INLINE static double eagle_cooling_rate( INLINE static double eagle_cooling_rate(
const double log10_u_cgs, const double redshift, const double n_H_cgs, 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 int n_H_index, const float d_n_H, const int He_index,
const float d_He, const struct cooling_function_data *cooling) { const float d_He, const struct cooling_function_data *cooling) {
......
...@@ -213,10 +213,6 @@ void read_cooling_header(const char *fname, ...@@ -213,10 +213,6 @@ void read_cooling_header(const char *fname,
if (N_SolarAbundances != eagle_cooling_N_abundances) if (N_SolarAbundances != eagle_cooling_N_abundances)
error("Invalid solar abundances array length."); 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); dataset = H5Dopen(tempfile_id, "/Header/Number_of_metals", H5P_DEFAULT);
status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
&N_Elements); &N_Elements);
......
...@@ -214,7 +214,7 @@ __attribute__((always_inline)) INLINE double eagle_convert_u_to_temp( ...@@ -214,7 +214,7 @@ __attribute__((always_inline)) INLINE double eagle_convert_u_to_temp(
*/ */
INLINE static double eagle_metal_cooling_rate( INLINE static double eagle_metal_cooling_rate(
double log10_u_cgs, double redshift, double n_H_cgs, 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, float d_n_H, int He_index, float d_He,
const struct cooling_function_data *restrict cooling, double *dlambda_du, const struct cooling_function_data *restrict cooling, double *dlambda_du,
double *element_lambda) { double *element_lambda) {
...@@ -569,7 +569,7 @@ INLINE static double eagle_metal_cooling_rate( ...@@ -569,7 +569,7 @@ INLINE static double eagle_metal_cooling_rate(
*/ */
INLINE static double eagle_cooling_rate( INLINE static double eagle_cooling_rate(
double log_u_cgs, double redshift, double n_H_cgs, 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, float d_n_H, int He_index, float d_He,
const struct cooling_function_data *restrict cooling, const struct cooling_function_data *restrict cooling,
double *dLambdaNet_du) { double *dLambdaNet_du) {
...@@ -609,7 +609,7 @@ INLINE static double eagle_metal_cooling_rate( ...@@ -609,7 +609,7 @@ INLINE static double eagle_metal_cooling_rate(
const struct cosmology *restrict cosmo, const struct cosmology *restrict cosmo,
const struct cooling_function_data *restrict cooling, const struct cooling_function_data *restrict cooling,
const struct phys_const *restrict phys_const, 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) { float dt, int *bisection_flag) {
double logu, logu_old; double logu, logu_old;
......
Supports Markdown
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