Commit beaf5c3a authored by Loic Hausammann's avatar Loic Hausammann
Browse files

Format

parent 41436dcb
...@@ -746,8 +746,8 @@ void cooling_cool_part(const struct phys_const* restrict phys_const, ...@@ -746,8 +746,8 @@ void cooling_cool_part(const struct phys_const* restrict phys_const,
const float u_old = hydro_get_physical_internal_energy(p, xp, cosmo); const float u_old = hydro_get_physical_internal_energy(p, xp, cosmo);
/* Energy after the adiabatic cooling */ /* Energy after the adiabatic cooling */
float u_ad_before = u_old + float u_ad_before =
dt_therm * hydro_get_physical_internal_energy_dt(p, cosmo); u_old + dt_therm * hydro_get_physical_internal_energy_dt(p, cosmo);
/* We now need to check that we are not going to go below any of the limits */ /* We now need to check that we are not going to go below any of the limits */
const double u_minimal = hydro_props->minimal_internal_energy; const double u_minimal = hydro_props->minimal_internal_energy;
...@@ -770,7 +770,8 @@ void cooling_cool_part(const struct phys_const* restrict phys_const, ...@@ -770,7 +770,8 @@ void cooling_cool_part(const struct phys_const* restrict phys_const,
/* Calculate the cooling rate */ /* Calculate the cooling rate */
float cool_du_dt = (u_new - u_ad_before) / dt_therm; float cool_du_dt = (u_new - u_ad_before) / dt_therm;
/* Check that the energy stays above the limits if the time step increase by 2 */ /* Check that the energy stays above the limits if the time step increase by 2
*/
/* Hydro */ /* Hydro */
double u_ad = u_new + hydro_du_dt * dt_therm; double u_ad = u_new + hydro_du_dt * dt_therm;
if (u_ad < u_minimal) { if (u_ad < u_minimal) {
...@@ -787,11 +788,11 @@ void cooling_cool_part(const struct phys_const* restrict phys_const, ...@@ -787,11 +788,11 @@ void cooling_cool_part(const struct phys_const* restrict phys_const,
cool_du_dt = (u_new - u_old) / dt_therm; cool_du_dt = (u_new - u_old) / dt_therm;
/* Update the internal energy time derivative */ /* Update the internal energy time derivative */
hydro_set_physical_internal_energy_dt(p, cosmo, cool_du_dt /* + hydro_du_dt */); hydro_set_physical_internal_energy_dt(p, cosmo,
cool_du_dt /* + hydro_du_dt */);
/* Store the radiated energy */ /* Store the radiated energy */
xp->cooling_data.radiated_energy -= xp->cooling_data.radiated_energy -= hydro_get_mass(p) * cool_du_dt * dt_therm;
hydro_get_mass(p) * cool_du_dt * dt_therm;
} }
/** /**
......
...@@ -81,7 +81,8 @@ void initial_mass_function_print(const struct initial_mass_function *imf) { ...@@ -81,7 +81,8 @@ void initial_mass_function_print(const struct initial_mass_function *imf) {
* @param step_size The distance between two points. * @param step_size The distance between two points.
*/ */
void initial_mass_function_integrate(const struct initial_mass_function *imf, void initial_mass_function_integrate(const struct initial_mass_function *imf,
float *data, size_t count, float log_mass_min, float step_size) { float *data, size_t count,
float log_mass_min, float step_size) {
/* Index in the data */ /* Index in the data */
size_t j = 1; size_t j = 1;
...@@ -107,7 +108,8 @@ void initial_mass_function_integrate(const struct initial_mass_function *imf, ...@@ -107,7 +108,8 @@ void initial_mass_function_integrate(const struct initial_mass_function *imf,
} }
/* Integrate the data */ /* Integrate the data */
while ((m < imf->mass_limits[i + 1] || i == imf->n_parts - 1) && j < count) { while ((m < imf->mass_limits[i + 1] || i == imf->n_parts - 1) &&
j < count) {
/* Compute the masses */ /* Compute the masses */
const float log_m1 = log_mass_min + (j - 1) * step_size; const float log_m1 = log_mass_min + (j - 1) * step_size;
...@@ -126,9 +128,7 @@ void initial_mass_function_integrate(const struct initial_mass_function *imf, ...@@ -126,9 +128,7 @@ void initial_mass_function_integrate(const struct initial_mass_function *imf,
} }
/* Compute the integral */ /* Compute the integral */
tmp[j] = tmp[j] = tmp[j - 1] + 0.5 * (imf_1 * data[j - 1] + imf_2 * data[j]) * dm;
tmp[j - 1] +
0.5 * (imf_1 * data[j - 1] + imf_2 * data[j]) * dm;
/* Update j and m */ /* Update j and m */
j += 1; j += 1;
......
...@@ -27,7 +27,8 @@ float initial_mass_function_get_exponent( ...@@ -27,7 +27,8 @@ float initial_mass_function_get_exponent(
void initial_mass_function_print(const struct initial_mass_function *imf); void initial_mass_function_print(const struct initial_mass_function *imf);
void initial_mass_function_integrate(const struct initial_mass_function *imf, void initial_mass_function_integrate(const struct initial_mass_function *imf,
float *data, size_t count, float log_mass_min, float step_size); float *data, size_t count,
float log_mass_min, float step_size);
float initial_mass_function_get_coefficient( float initial_mass_function_get_coefficient(
const struct initial_mass_function *imf, float mass_min, float mass_max); const struct initial_mass_function *imf, float mass_min, float mass_max);
float initial_mass_function_get_integral_xi( float initial_mass_function_get_integral_xi(
......
...@@ -161,7 +161,7 @@ __attribute__((always_inline)) static INLINE float interpolate_1d( ...@@ -161,7 +161,7 @@ __attribute__((always_inline)) static INLINE float interpolate_1d(
case boundary_condition_zero_const: case boundary_condition_zero_const:
return 0; return 0;
case boundary_condition_const: case boundary_condition_const:
return interp->data[0]; return interp->data[0];
default: default:
error("Interpolation type not implemented"); error("Interpolation type not implemented");
} }
......
...@@ -197,7 +197,6 @@ __attribute__((always_inline)) INLINE static void lifetime_init( ...@@ -197,7 +197,6 @@ __attribute__((always_inline)) INLINE static void lifetime_init(
/* Change units from yr into Myr */ /* Change units from yr into Myr */
const int dim = 3; const int dim = 3;
lt->constant[dim - 1] -= 6; lt->constant[dim - 1] -= 6;
} }
/** /**
......
...@@ -94,8 +94,10 @@ int stellar_evolution_compute_integer_number_supernovae( ...@@ -94,8 +94,10 @@ int stellar_evolution_compute_integer_number_supernovae(
* (solMass) * (solMass)
* @param m_end_step Mass of a star ending its life at the end of the step * @param m_end_step Mass of a star ending its life at the end of the step
* (solMass) * (solMass)
* @param number_snia_f (Floating) Number of SNIa produced by the stellar particle. * @param number_snia_f (Floating) Number of SNIa produced by the stellar
* @param number_snii_f (Floating) Number of SNII produced by the stellar particle. * particle.
* @param number_snii_f (Floating) Number of SNII produced by the stellar
* particle.
* *
*/ */
void stellar_evolution_compute_continuous_feedback_properties( void stellar_evolution_compute_continuous_feedback_properties(
...@@ -107,15 +109,16 @@ void stellar_evolution_compute_continuous_feedback_properties( ...@@ -107,15 +109,16 @@ void stellar_evolution_compute_continuous_feedback_properties(
/* Compute the mass ejected */ /* Compute the mass ejected */
/* SNIa */ /* SNIa */
const float mass_snia = const float mass_snia =
supernovae_ia_get_ejected_mass_processed(&sm->snia) * number_snia_f; supernovae_ia_get_ejected_mass_processed(&sm->snia) * number_snia_f;
/* SNII */ /* SNII */
const float mass_frac_snii = supernovae_ii_get_ejected_mass_fraction_processed_from_integral( const float mass_frac_snii =
supernovae_ii_get_ejected_mass_fraction_processed_from_integral(
&sm->snii, log_m_end_step, log_m_beg_step); &sm->snii, log_m_end_step, log_m_beg_step);
/* Sum the contributions from SNIa and SNII */ /* Sum the contributions from SNIa and SNII */
sp->feedback_data.mass_ejected = mass_frac_snii * sp->sf_data.birth_mass sp->feedback_data.mass_ejected = mass_frac_snii * sp->sf_data.birth_mass +
+ mass_snia * phys_const->const_solar_mass; mass_snia * phys_const->const_solar_mass;
if (sp->mass <= sp->feedback_data.mass_ejected) { if (sp->mass <= sp->feedback_data.mass_ejected) {
error("Stars cannot have negative mass. (%g <= %g). Initial mass = %g", error("Stars cannot have negative mass. (%g <= %g). Initial mass = %g",
...@@ -132,21 +135,22 @@ void stellar_evolution_compute_continuous_feedback_properties( ...@@ -132,21 +135,22 @@ void stellar_evolution_compute_continuous_feedback_properties(
/* Compute the SNII yields */ /* Compute the SNII yields */
float snii_yields[GEAR_CHEMISTRY_ELEMENT_COUNT]; float snii_yields[GEAR_CHEMISTRY_ELEMENT_COUNT];
supernovae_ii_get_yields_from_integral(&sm->snii, log_m_end_step, log_m_beg_step, supernovae_ii_get_yields_from_integral(&sm->snii, log_m_end_step,
snii_yields); log_m_beg_step, snii_yields);
/* Compute the mass fraction of non processed elements */ /* Compute the mass fraction of non processed elements */
const float non_processed = supernovae_ii_get_ejected_mass_fraction_non_processed_from_integral( const float non_processed =
&sm->snii, log_m_end_step, log_m_beg_step); supernovae_ii_get_ejected_mass_fraction_non_processed_from_integral(
&sm->snii, log_m_end_step, log_m_beg_step);
/* Set the yields */ /* Set the yields */
for (int i = 0; i < GEAR_CHEMISTRY_ELEMENT_COUNT; i++) { for (int i = 0; i < GEAR_CHEMISTRY_ELEMENT_COUNT; i++) {
/* Compute the mass fraction of metals */ /* Compute the mass fraction of metals */
sp->feedback_data.metal_mass_ejected[i] = sp->feedback_data.metal_mass_ejected[i] =
/* Supernovae II yields */ /* Supernovae II yields */
snii_yields[i] + snii_yields[i] +
/* Gas contained in stars initial metallicity */ /* Gas contained in stars initial metallicity */
chemistry_get_metal_mass_fraction_for_feedback(sp)[i] * non_processed; chemistry_get_metal_mass_fraction_for_feedback(sp)[i] * non_processed;
/* Convert it to total mass */ /* Convert it to total mass */
sp->feedback_data.metal_mass_ejected[i] *= sp->sf_data.birth_mass; sp->feedback_data.metal_mass_ejected[i] *= sp->sf_data.birth_mass;
...@@ -155,8 +159,7 @@ void stellar_evolution_compute_continuous_feedback_properties( ...@@ -155,8 +159,7 @@ void stellar_evolution_compute_continuous_feedback_properties(
/* Add the Supernovae Ia */ /* Add the Supernovae Ia */
sp->feedback_data.metal_mass_ejected[i] += sp->feedback_data.metal_mass_ejected[i] +=
snia_yields[i] * number_snia_f * phys_const->const_solar_mass; snia_yields[i] * number_snia_f * phys_const->const_solar_mass;
} }
} }
...@@ -186,19 +189,21 @@ void stellar_evolution_compute_discrete_feedback_properties( ...@@ -186,19 +189,21 @@ void stellar_evolution_compute_discrete_feedback_properties(
const float m_init, const int number_snia, const int number_snii) { const float m_init, const int number_snia, const int number_snii) {
/* Compute the average mass */ /* Compute the average mass */
const float m_avg = initial_mass_function_get_integral_imf(&sm->imf, m_end_step, m_beg_step) / const float m_avg =
initial_mass_function_get_integral_xi(&sm->imf, m_end_step, m_beg_step); initial_mass_function_get_integral_imf(&sm->imf, m_end_step, m_beg_step) /
initial_mass_function_get_integral_xi(&sm->imf, m_end_step, m_beg_step);
const float log_m_avg = log10(m_avg); const float log_m_avg = log10(m_avg);
/* Compute the mass ejected */ /* Compute the mass ejected */
/* SNIa */ /* SNIa */
const float mass_snia = const float mass_snia =
supernovae_ia_get_ejected_mass_processed(&sm->snia) * number_snia; supernovae_ia_get_ejected_mass_processed(&sm->snia) * number_snia;
/* SNII */ /* SNII */
const float mass_snii = const float mass_snii =
supernovae_ii_get_ejected_mass_fraction_processed_from_raw( supernovae_ii_get_ejected_mass_fraction_processed_from_raw(&sm->snii,
&sm->snii, log_m_avg) * m_avg * number_snii; log_m_avg) *
m_avg * number_snii;
sp->feedback_data.mass_ejected = mass_snia + mass_snii; sp->feedback_data.mass_ejected = mass_snia + mass_snii;
...@@ -222,24 +227,23 @@ void stellar_evolution_compute_discrete_feedback_properties( ...@@ -222,24 +227,23 @@ void stellar_evolution_compute_discrete_feedback_properties(
/* Compute the mass fraction of non processed elements */ /* Compute the mass fraction of non processed elements */
const float non_processed = const float non_processed =
supernovae_ii_get_ejected_mass_fraction_non_processed_from_raw( supernovae_ii_get_ejected_mass_fraction_non_processed_from_raw(&sm->snii,
&sm->snii, log_m_avg); log_m_avg);
/* Set the yields */ /* Set the yields */
for (int i = 0; i < GEAR_CHEMISTRY_ELEMENT_COUNT; i++) { for (int i = 0; i < GEAR_CHEMISTRY_ELEMENT_COUNT; i++) {
/* Compute the mass fraction of metals */ /* Compute the mass fraction of metals */
sp->feedback_data.metal_mass_ejected[i] = sp->feedback_data.metal_mass_ejected[i] =
/* Supernovae II yields */ /* Supernovae II yields */
snii_yields[i] + snii_yields[i] +
/* Gas contained in stars initial metallicity */ /* Gas contained in stars initial metallicity */
chemistry_get_metal_mass_fraction_for_feedback(sp)[i] * non_processed; chemistry_get_metal_mass_fraction_for_feedback(sp)[i] * non_processed;
/* Convert it to total mass */ /* Convert it to total mass */
sp->feedback_data.metal_mass_ejected[i] *= m_avg * number_snii; sp->feedback_data.metal_mass_ejected[i] *= m_avg * number_snii;
/* Supernovae Ia yields */ /* Supernovae Ia yields */
sp->feedback_data.metal_mass_ejected[i] += sp->feedback_data.metal_mass_ejected[i] += snia_yields[i] * number_snia;
snia_yields[i] * number_snia;
/* Convert everything in code units */ /* Convert everything in code units */
sp->feedback_data.metal_mass_ejected[i] *= phys_const->const_solar_mass; sp->feedback_data.metal_mass_ejected[i] *= phys_const->const_solar_mass;
...@@ -306,12 +310,18 @@ void stellar_evolution_evolve_spart( ...@@ -306,12 +310,18 @@ void stellar_evolution_evolve_spart(
const float m_init = sp->sf_data.birth_mass / phys_const->const_solar_mass; const float m_init = sp->sf_data.birth_mass / phys_const->const_solar_mass;
/* Compute number of SNIa */ /* Compute number of SNIa */
const float number_snia_f = can_produce_snia ? const float number_snia_f = can_produce_snia
supernovae_ia_get_number_per_unit_mass(&sm->snia, m_end_step, m_beg_step) * m_init : 0; ? supernovae_ia_get_number_per_unit_mass(
&sm->snia, m_end_step, m_beg_step) *
m_init
: 0;
/* Compute number of SNII */ /* Compute number of SNII */
const float number_snii_f = can_produce_snii ? const float number_snii_f = can_produce_snii
supernovae_ii_get_number_per_unit_mass(&sm->snii, m_end_step, m_beg_step) * m_init : 0; ? supernovae_ii_get_number_per_unit_mass(
&sm->snii, m_end_step, m_beg_step) *
m_init
: 0;
/* Does this star produce a supernovae? */ /* Does this star produce a supernovae? */
if (number_snia_f == 0 && number_snii_f == 0) return; if (number_snia_f == 0 && number_snii_f == 0) return;
...@@ -320,11 +330,11 @@ void stellar_evolution_evolve_spart( ...@@ -320,11 +330,11 @@ void stellar_evolution_evolve_spart(
if (sm->discrete_yields) { if (sm->discrete_yields) {
/* Get the integer number of supernovae */ /* Get the integer number of supernovae */
const int number_snia = stellar_evolution_compute_integer_number_supernovae( const int number_snia = stellar_evolution_compute_integer_number_supernovae(
sp, number_snia_f, ti_begin, random_number_stellar_feedback_1); sp, number_snia_f, ti_begin, random_number_stellar_feedback_1);
/* Get the integer number of supernovae */ /* Get the integer number of supernovae */
const int number_snii = stellar_evolution_compute_integer_number_supernovae( const int number_snii = stellar_evolution_compute_integer_number_supernovae(
sp, number_snii_f, ti_begin, random_number_stellar_feedback_2); sp, number_snii_f, ti_begin, random_number_stellar_feedback_2);
/* Do we have a supernovae? */ /* Do we have a supernovae? */
if (number_snia == 0 && number_snii == 0) return; if (number_snia == 0 && number_snii == 0) return;
......
...@@ -121,20 +121,23 @@ struct supernovae_ii { ...@@ -121,20 +121,23 @@ struct supernovae_ii {
/*! Total mass fraction ejected. */ /*! Total mass fraction ejected. */
struct interpolation_1d ejected_mass_processed; struct interpolation_1d ejected_mass_processed;
/*! Mass fraction ejected and not processed (=> with the star metallicity). */ /*! Mass fraction ejected and not processed (=> with the star metallicity).
*/
struct interpolation_1d ejected_mass_non_processed; struct interpolation_1d ejected_mass_non_processed;
} raw; } raw;
/*! Yields integrated */ /*! Yields integrated */
struct { struct {
/*! Integrated (over the IMF) mass fraction of metals ejected by a supernovae /*! Integrated (over the IMF) mass fraction of metals ejected by a
* supernovae
*/ */
struct interpolation_1d yields[GEAR_CHEMISTRY_ELEMENT_COUNT]; struct interpolation_1d yields[GEAR_CHEMISTRY_ELEMENT_COUNT];
/*! Total mass fraction ejected (integrated over the IMF) */ /*! Total mass fraction ejected (integrated over the IMF) */
struct interpolation_1d ejected_mass_processed; struct interpolation_1d ejected_mass_processed;
/*! Mass fraction ejected and not processed (=> with the star metallicity) */ /*! Mass fraction ejected and not processed (=> with the star metallicity)
*/
struct interpolation_1d ejected_mass_non_processed; struct interpolation_1d ejected_mass_non_processed;
} integrated; } integrated;
......
...@@ -123,8 +123,8 @@ float supernovae_ia_get_companion_fraction(const struct supernovae_ia *snia, ...@@ -123,8 +123,8 @@ float supernovae_ia_get_companion_fraction(const struct supernovae_ia *snia,
* *
* @return The number of supernovae Ia per unit of mass. * @return The number of supernovae Ia per unit of mass.
*/ */
float supernovae_ia_get_number_per_unit_mass(const struct supernovae_ia *snia, float m1, float supernovae_ia_get_number_per_unit_mass(const struct supernovae_ia *snia,
float m2) { float m1, float m2) {
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
if (m1 > m2) error("Mass 1 larger than mass 2 %g > %g.", m1, m2); if (m1 > m2) error("Mass 1 larger than mass 2 %g > %g.", m1, m2);
...@@ -222,7 +222,7 @@ void supernovae_ia_init_companion(struct supernovae_ia *snia) { ...@@ -222,7 +222,7 @@ void supernovae_ia_init_companion(struct supernovae_ia *snia) {
/* Get the exponent for the integral */ /* Get the exponent for the integral */
const float exp = snia->companion_exponent; const float exp = snia->companion_exponent;
for (int i = 0; i < GEAR_NUMBER_TYPE_OF_COMPANION; i++) { for (int i = 0; i < GEAR_NUMBER_TYPE_OF_COMPANION; i++) {
/* Compute the integral */ /* Compute the integral */
...@@ -231,7 +231,7 @@ void supernovae_ia_init_companion(struct supernovae_ia *snia) { ...@@ -231,7 +231,7 @@ void supernovae_ia_init_companion(struct supernovae_ia *snia) {
integral /= exp + 1.; integral /= exp + 1.;
/* Update the coefficient for a normalization to 1 of the IMF */ /* Update the coefficient for a normalization to 1 of the IMF */
snia->companion[i].coef /= exp * integral; snia->companion[i].coef /= exp * integral;
} }
} }
......
...@@ -32,8 +32,8 @@ float supernovae_ia_get_ejected_mass_processed( ...@@ -32,8 +32,8 @@ float supernovae_ia_get_ejected_mass_processed(
float supernovae_ia_get_companion_fraction(const struct supernovae_ia *snia, float supernovae_ia_get_companion_fraction(const struct supernovae_ia *snia,
float m1, float m2, float m1, float m2,
int companion_type); int companion_type);
float supernovae_ia_get_number_per_unit_mass(const struct supernovae_ia *snia, float m1, float supernovae_ia_get_number_per_unit_mass(const struct supernovae_ia *snia,
float m2); float m1, float m2);
void supernovae_ia_read_yields(struct supernovae_ia *snia, void supernovae_ia_read_yields(struct supernovae_ia *snia,
struct swift_params *params, struct swift_params *params,
......
...@@ -68,8 +68,8 @@ int supernovae_ii_can_explode(const struct supernovae_ii *snii, float m_low, ...@@ -68,8 +68,8 @@ int supernovae_ii_can_explode(const struct supernovae_ii *snii, float m_low,
* *
* @return The number of supernovae II per unit of mass. * @return The number of supernovae II per unit of mass.
*/ */
float supernovae_ii_get_number_per_unit_mass(const struct supernovae_ii *snii, float m1, float supernovae_ii_get_number_per_unit_mass(const struct supernovae_ii *snii,
float m2) { float m1, float m2) {
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
if (m1 > m2) error("Mass 1 larger than mass 2 %g > %g.", m1, m2); if (m1 > m2) error("Mass 1 larger than mass 2 %g > %g.", m1, m2);
#endif #endif
...@@ -96,8 +96,9 @@ float supernovae_ii_get_number_per_unit_mass(const struct supernovae_ii *snii, f ...@@ -96,8 +96,9 @@ float supernovae_ii_get_number_per_unit_mass(const struct supernovae_ii *snii, f
* @param m2 The upper mass in log. * @param m2 The upper mass in log.
* @param yields The elements ejected (needs to be allocated). * @param yields The elements ejected (needs to be allocated).
*/ */
void supernovae_ii_get_yields_from_integral(const struct supernovae_ii *snii, float log_m1, void supernovae_ii_get_yields_from_integral(const struct supernovae_ii *snii,
float log_m2, float *yields) { float log_m1, float log_m2,
float *yields) {
for (int i = 0; i < GEAR_CHEMISTRY_ELEMENT_COUNT; i++) { for (int i = 0; i < GEAR_CHEMISTRY_ELEMENT_COUNT; i++) {
float yields_1 = interpolate_1d(&snii->integrated.yields[i], log_m1); float yields_1 = interpolate_1d(&snii->integrated.yields[i], log_m1);
...@@ -114,8 +115,8 @@ void supernovae_ii_get_yields_from_integral(const struct supernovae_ii *snii, fl ...@@ -114,8 +115,8 @@ void supernovae_ii_get_yields_from_integral(const struct supernovae_ii *snii, fl
* @param log_m The mass in log. * @param log_m The mass in log.
* @param yields The elements ejected (needs to be allocated). * @param yields The elements ejected (needs to be allocated).
*/ */
void supernovae_ii_get_yields_from_raw(const struct supernovae_ii *snii, float log_m, void supernovae_ii_get_yields_from_raw(const struct supernovae_ii *snii,
float *yields) { float log_m, float *yields) {
for (int i = 0; i < GEAR_CHEMISTRY_ELEMENT_COUNT; i++) { for (int i = 0; i < GEAR_CHEMISTRY_ELEMENT_COUNT; i++) {
yields[i] = interpolate_1d(&snii->raw.yields[i], log_m); yields[i] = interpolate_1d(&snii->raw.yields[i], log_m);
...@@ -131,16 +132,17 @@ void supernovae_ii_get_yields_from_raw(const struct supernovae_ii *snii, float l ...@@ -131,16 +132,17 @@ void supernovae_ii_get_yields_from_raw(const struct supernovae_ii *snii, float l
* *
* @return mass_ejected_processed The mass of non processsed elements. * @return mass_ejected_processed The mass of non processsed elements.
*/ */
float supernovae_ii_get_ejected_mass_fraction_non_processed_from_integral(const struct supernovae_ii *snii, float supernovae_ii_get_ejected_mass_fraction_non_processed_from_integral(
float log_m1, float log_m2) { const struct supernovae_ii *snii, float log_m1, float log_m2) {
float mass_ejected_1 = interpolate_1d(&snii->integrated.ejected_mass_non_processed, log_m1); float mass_ejected_1 =
float mass_ejected_2 = interpolate_1d(&snii->integrated.ejected_mass_non_processed, log_m2); interpolate_1d(&snii->integrated.ejected_mass_non_processed, log_m1);
float mass_ejected_2 =
interpolate_1d(&snii->integrated.ejected_mass_non_processed, log_m2);
return mass_ejected_2 - mass_ejected_1; return mass_ejected_2 - mass_ejected_1;
}; };
/** /**
* @brief Get the ejected mass (non processed) per mass unit. * @brief Get the ejected mass (non processed) per mass unit.
* *
...@@ -149,8 +151,8 @@ float supernovae_ii_get_ejected_mass_fraction_non_processed_from_integral(const ...@@ -149,8 +151,8 @@ float supernovae_ii_get_ejected_mass_fraction_non_processed_from_integral(const
* *
* @return The mass of non processsed elements. * @return The mass of non processsed elements.
*/ */
float supernovae_ii_get_ejected_mass_fraction_non_processed_from_raw(const struct supernovae_ii *snii, float supernovae_ii_get_ejected_mass_fraction_non_processed_from_raw(
float log_m) { const struct supernovae_ii *snii, float log_m) {
return interpolate_1d(&snii->raw.ejected_mass_non_processed, log_m); return interpolate_1d(&snii->raw.ejected_mass_non_processed, log_m);
}; };
...@@ -175,7 +177,6 @@ float supernovae_ii_get_ejected_mass_fraction_processed_from_integral( ...@@ -175,7 +177,6 @@ float supernovae_ii_get_ejected_mass_fraction_processed_from_integral(
return mass_ejected_2 - mass_ejected_1; return mass_ejected_2 - mass_ejected_1;
}; };
/** /**
* @brief Get the ejected mass (processed) per mass. * @brief Get the ejected mass (processed) per mass.
* *
...@@ -201,13 +202,14 @@ float supernovae_ii_get_ejected_mass_fraction_processed_from_raw( ...@@ -201,13 +202,14 @@ float supernovae_ii_get_ejected_mass_fraction_processed_from_raw(
* @param group_id The HDF5 group id where to read from. * @param group_id The HDF5 group id where to read from.
* @param hdf5_dataset_name The dataset name to read. * @param hdf5_dataset_name The dataset name to read.
* @param previous_count Number of element in the previous array read. * @param previous_count Number of element in the previous array read.
* @param interpolation_size Number of element to keep in the interpolation data. * @param interpolation_size Number of element to keep in the interpolation
* data.
*/ */
void supernovae_ii_read_yields_array( void supernovae_ii_read_yields_array(
struct supernovae_ii *snii, struct interpolation_1d *interp_raw, struct supernovae_ii *snii, struct interpolation_1d *interp_raw,
struct interpolation_1d *interp_int, struct interpolation_1d *interp_int, const struct phys_const *phys_const,
const struct phys_const *phys_const, const struct stellar_model *sm, const struct stellar_model *sm, hid_t group_id,
hid_t group_id, const char *hdf5_dataset_name, hsize_t *previous_count, const char *hdf5_dataset_name, hsize_t *previous_count,
int interpolation_size) { int interpolation_size) {
/* Now let's get the number of elements */ /* Now let's get the number of elements */
...@@ -247,16 +249,16 @@ void supernovae_ii_read_yields_array( ...@@ -247,16 +249,16 @@ void supernovae_ii_read_yields_array(
/* Initialize the raw interpolation */ /* Initialize the raw interpolation */
interpolate_1d_init(interp_raw, log10(snii->mass_min), log10(snii->mass_max),