Skip to content
Snippets Groups Projects
Commit 4e3e41be authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Merge branch 'gear_feedback_updates' into 'master'

Gear feedback updates

See merge request !2128
parents 793d05e2 fad10f5c
No related branches found
No related tags found
1 merge request!2128Gear feedback updates
...@@ -636,6 +636,21 @@ int stellar_evolution_get_element_index(const struct stellar_model* sm, ...@@ -636,6 +636,21 @@ int stellar_evolution_get_element_index(const struct stellar_model* sm,
return -1; return -1;
} }
/**
* @brief Get the solar abundance of the element .
*
* @param sm The #stellar_model.
* @param element_name The element name.
*/
float stellar_evolution_get_solar_abundance(const struct stellar_model* sm,
const char* element_name) {
int element_index = stellar_evolution_get_element_index(sm, element_name);
float solar_abundance = sm->solar_abundances[element_index];
return solar_abundance;
}
/** /**
* @brief Read the name of all the elements present in the tables. * @brief Read the name of all the elements present in the tables.
* *
...@@ -689,6 +704,46 @@ void stellar_evolution_read_elements(struct stellar_model* sm, ...@@ -689,6 +704,46 @@ void stellar_evolution_read_elements(struct stellar_model* sm,
} }
} }
/**
* @brief Read the solar abundances.
*
* @param parameter_file The parsed parameter file.
* @param data The properties to initialise.
*/
void stellar_evolution_read_solar_abundances(struct stellar_model* sm,
struct swift_params* params) {
#if defined(HAVE_HDF5)
/* Get the yields table */
char filename[DESCRIPTION_BUFFER_SIZE];
parser_get_param_string(params, "GEARFeedback:yields_table", filename);
/* Open file. */
hid_t file_id = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT);
if (file_id < 0) error("unable to open file %s.\n", filename);
/* Open group. */
hid_t group_id = H5Gopen(file_id, "Data", H5P_DEFAULT);
if (group_id < 0) error("unable to open group Data.\n");
/* Read the data */
io_read_array_attribute(group_id, "SolarMassAbundances", FLOAT,
sm->solar_abundances, GEAR_CHEMISTRY_ELEMENT_COUNT);
/* Close group */
hid_t status = H5Gclose(group_id);
if (status < 0) error("error closing group.");
/* Close file */
status = H5Fclose(file_id);
if (status < 0) error("error closing file.");
#else
message("Cannot read the solar abundances without HDF5");
#endif
}
/** /**
* @brief Initialize the global properties of the stellar evolution scheme. * @brief Initialize the global properties of the stellar evolution scheme.
* *
...@@ -707,6 +762,9 @@ void stellar_evolution_props_init(struct stellar_model* sm, ...@@ -707,6 +762,9 @@ void stellar_evolution_props_init(struct stellar_model* sm,
/* Read the list of elements */ /* Read the list of elements */
stellar_evolution_read_elements(sm, params); stellar_evolution_read_elements(sm, params);
/* Read the solar abundances */
stellar_evolution_read_solar_abundances(sm, params);
/* Use the discrete yields approach? */ /* Use the discrete yields approach? */
sm->discrete_yields = sm->discrete_yields =
parser_get_param_int(params, "GEARFeedback:discrete_yields"); parser_get_param_int(params, "GEARFeedback:discrete_yields");
......
...@@ -62,9 +62,12 @@ const char* stellar_evolution_get_element_name(const struct stellar_model* sm, ...@@ -62,9 +62,12 @@ const char* stellar_evolution_get_element_name(const struct stellar_model* sm,
int i); int i);
int stellar_evolution_get_element_index(const struct stellar_model* sm, int stellar_evolution_get_element_index(const struct stellar_model* sm,
const char* element_name); const char* element_name);
float stellar_evolution_get_solar_abundance(const struct stellar_model* sm,
const char* element_name);
void stellar_evolution_read_elements(struct stellar_model* sm, void stellar_evolution_read_elements(struct stellar_model* sm,
struct swift_params* params); struct swift_params* params);
void stellar_evolution_read_solar_abundances(struct stellar_model* sm,
struct swift_params* params);
void stellar_evolution_props_init(struct stellar_model* sm, void stellar_evolution_props_init(struct stellar_model* sm,
const struct phys_const* phys_const, const struct phys_const* phys_const,
const struct unit_system* us, const struct unit_system* us,
...@@ -79,5 +82,4 @@ void stellar_evolution_clean(struct stellar_model* sm); ...@@ -79,5 +82,4 @@ void stellar_evolution_clean(struct stellar_model* sm);
float stellar_evolution_compute_initial_mass( float stellar_evolution_compute_initial_mass(
const struct spart* restrict sp, const struct stellar_model* sm, const struct spart* restrict sp, const struct stellar_model* sm,
const struct phys_const* phys_consts); const struct phys_const* phys_consts);
#endif // SWIFT_STELLAR_EVOLUTION_GEAR_H #endif // SWIFT_STELLAR_EVOLUTION_GEAR_H
...@@ -191,6 +191,9 @@ struct stellar_model { ...@@ -191,6 +191,9 @@ struct stellar_model {
/*! Name of the different elements */ /*! Name of the different elements */
char elements_name[GEAR_CHEMISTRY_ELEMENT_COUNT * GEAR_LABELS_SIZE]; char elements_name[GEAR_CHEMISTRY_ELEMENT_COUNT * GEAR_LABELS_SIZE];
/* Solar mass abundances read from the chemistry table */
float solar_abundances[GEAR_CHEMISTRY_ELEMENT_COUNT];
/*! The initial mass function */ /*! The initial mass function */
struct initial_mass_function imf; struct initial_mass_function imf;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment