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

Define the dimensions of the lifetime tables as constants.

parent a3784cc5
No related branches found
No related tags found
1 merge request!787Eagle stellar evolution matthieu
......@@ -738,19 +738,6 @@ void compute_stellar_evolution(const struct feedback_props* feedback_props,
/* 0.5 * (sp->v[0] * sp->v[0] + sp->v[1] * sp->v[1] + sp->v[2] *
* sp->v[2]) * */
/* cosmo->a2_inv); */
/* /\* Compute the number of type II SNe that went off *\/ */
/* sp->feedback_data.to_distribute.num_SNe = */
/* compute_SNe(sp, feedback_props, age, dt); */
/* /\* Compute probability of heating neighbouring particles *\/ */
/* if (dt > 0 && sp->feedback_data.ngb_mass > 0) */
/* sp->feedback_data.to_distribute.heating_probability = */
/* feedback_props->total_energy_SNe * */
/* sp->feedback_data.to_distribute.num_SNe / */
/* (feedback_props->temp_to_u_factor *
* feedback_props->SNe_deltaT_desired * */
/* sp->feedback_data.ngb_mass); */
}
/**
......@@ -880,10 +867,6 @@ void feedback_props_init(struct feedback_props* fp,
us, UNIT_CONV_SPEED); // EAGLE parameter is 10 km/s
fp->ejecta_specific_thermal_energy = 0.5 * ejecta_velocity * ejecta_velocity;
/* Set number of elements found in yield tables */
fp->lifetimes.n_mass = 30;
fp->lifetimes.n_z = 6;
/* Initialise the IMF ------------------------------------------------- */
init_imf(fp);
......
......@@ -58,10 +58,6 @@ struct yield_table {
*/
struct lifetime_table {
/* number of elements, mass, and initial metallicity bins */
int n_mass;
int n_z;
/* table of masses */
double *mass;
......@@ -72,6 +68,9 @@ struct lifetime_table {
double **dyingtime;
};
/**
* @brief Properties of the EAGLE feedback model.
*/
struct feedback_props {
/* Kinetic energy of SN ejecta per unit mass (check name with Richard)*/
......
......@@ -278,8 +278,8 @@ inline static float dying_mass_msun(
const double *lifetime_Z = feedback_props->lifetimes.metallicity;
const double *lifetime_m = feedback_props->lifetimes.mass;
double **const dying_times = feedback_props->lifetimes.dyingtime;
const int n_Z = feedback_props->lifetimes.n_z;
const int n_m = feedback_props->lifetimes.n_mass;
const int n_Z = eagle_feedback_lifetime_N_metals;
const int n_m = eagle_feedback_lifetime_N_masses;
/* Early abort? */
if (age_Gyr <= 0.f) {
......@@ -410,8 +410,8 @@ inline static float lifetime_in_Gyr(
const double *lifetime_Z = feedback_props->lifetimes.metallicity;
const double *lifetime_m = feedback_props->lifetimes.mass;
double **const dying_times = feedback_props->lifetimes.dyingtime;
const int n_Z = feedback_props->lifetimes.n_z;
const int n_m = feedback_props->lifetimes.n_mass;
const int n_Z = eagle_feedback_lifetime_N_metals;
const int n_m = eagle_feedback_lifetime_N_masses;
/* Calculate index along the mass axis */
int m_index;
......
......@@ -51,6 +51,12 @@ static const float log10_min_metallicity = -20;
/*! Number of metallicity bins considered for the AGB yields */
#define eagle_feedback_AGB_N_metals 3
/*! Number od mass bins along the mass axis of the lifetime table */
#define eagle_feedback_lifetime_N_masses 30
/*! Number od mass bins along the metal axis of the lifetime table */
#define eagle_feedback_lifetime_N_metals 6
/**
* @brief returns index of element_name within array of element names
* (element_array)
......@@ -356,16 +362,16 @@ inline static void read_yield_tables(struct feedback_props *feedback_props) {
if (status < 0) error("error closing dataset");
/* allocate temporary array to read lifetimes */
double temp_lifetimes[feedback_props->lifetimes.n_z]
[feedback_props->lifetimes.n_mass];
double temp_lifetimes[eagle_feedback_lifetime_N_metals]
[eagle_feedback_lifetime_N_masses];
dataset = H5Dopen(file_id, "Lifetimes", H5P_DEFAULT);
H5Dread(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT,
temp_lifetimes);
H5Dclose(dataset);
for (int i = 0; i < feedback_props->lifetimes.n_z; i++) {
for (int j = 0; j < feedback_props->lifetimes.n_mass; j++) {
for (int i = 0; i < eagle_feedback_lifetime_N_metals; i++) {
for (int j = 0; j < eagle_feedback_lifetime_N_masses; j++) {
feedback_props->lifetimes.dyingtime[i][j] = log10(temp_lifetimes[i][j]);
}
}
......@@ -546,7 +552,7 @@ inline static void allocate_yield_tables(
if (swift_memalign("feedback-tables",
(void **)&feedback_props->lifetimes.mass,
SWIFT_STRUCT_ALIGNMENT,
feedback_props->lifetimes.n_mass * sizeof(double)) != 0) {
eagle_feedback_lifetime_N_masses * sizeof(double)) != 0) {
error("Failed to allocate lifetime mass array");
}
......@@ -554,16 +560,16 @@ inline static void allocate_yield_tables(
if (swift_memalign("feedback-tables",
(void **)&feedback_props->lifetimes.metallicity,
SWIFT_STRUCT_ALIGNMENT,
feedback_props->lifetimes.n_z * sizeof(double)) != 0) {
eagle_feedback_lifetime_N_metals * sizeof(double)) != 0) {
error("Failed to allocate lifetime metallicity array");
}
/* Allocate lifetimes array */
feedback_props->lifetimes.dyingtime =
(double **)malloc(feedback_props->lifetimes.n_z * sizeof(double *));
for (int i = 0; i < feedback_props->lifetimes.n_z; i++) {
(double **)malloc(eagle_feedback_lifetime_N_metals * sizeof(double *));
for (int i = 0; i < eagle_feedback_lifetime_N_metals; i++) {
feedback_props->lifetimes.dyingtime[i] =
(double *)malloc(feedback_props->lifetimes.n_mass * sizeof(double));
(double *)malloc(eagle_feedback_lifetime_N_masses * sizeof(double));
}
/* Allocate arrays to store names of elements tracked for SNIa, SNII, AGB */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment