Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
beaf5c3a
Commit
beaf5c3a
authored
Apr 02, 2020
by
Loic Hausammann
Browse files
Format
parent
41436dcb
Changes
14
Hide whitespace changes
Inline
Side-by-side
src/cooling/grackle/cooling.c
View file @
beaf5c3a
...
...
@@ -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
);
/* Energy after the adiabatic cooling */
float
u_ad_before
=
u_old
+
dt_therm
*
hydro_get_physical_internal_energy_dt
(
p
,
cosmo
);
float
u_ad_before
=
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 */
const
double
u_minimal
=
hydro_props
->
minimal_internal_energy
;
...
...
@@ -770,7 +770,8 @@ void cooling_cool_part(const struct phys_const* restrict phys_const,
/* Calculate the cooling rate */
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 */
double
u_ad
=
u_new
+
hydro_du_dt
*
dt_therm
;
if
(
u_ad
<
u_minimal
)
{
...
...
@@ -787,11 +788,11 @@ void cooling_cool_part(const struct phys_const* restrict phys_const,
cool_du_dt
=
(
u_new
-
u_old
)
/
dt_therm
;
/* 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 */
xp
->
cooling_data
.
radiated_energy
-=
hydro_get_mass
(
p
)
*
cool_du_dt
*
dt_therm
;
xp
->
cooling_data
.
radiated_energy
-=
hydro_get_mass
(
p
)
*
cool_du_dt
*
dt_therm
;
}
/**
...
...
src/feedback/GEAR/initial_mass_function.c
View file @
beaf5c3a
...
...
@@ -81,7 +81,8 @@ void initial_mass_function_print(const struct initial_mass_function *imf) {
* @param step_size The distance between two points.
*/
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 */
size_t
j
=
1
;
...
...
@@ -107,7 +108,8 @@ void initial_mass_function_integrate(const struct initial_mass_function *imf,
}
/* 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 */
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,
}
/* Compute the integral */
tmp
[
j
]
=
tmp
[
j
-
1
]
+
0
.
5
*
(
imf_1
*
data
[
j
-
1
]
+
imf_2
*
data
[
j
])
*
dm
;
tmp
[
j
]
=
tmp
[
j
-
1
]
+
0
.
5
*
(
imf_1
*
data
[
j
-
1
]
+
imf_2
*
data
[
j
])
*
dm
;
/* Update j and m */
j
+=
1
;
...
...
src/feedback/GEAR/initial_mass_function.h
View file @
beaf5c3a
...
...
@@ -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_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
(
const
struct
initial_mass_function
*
imf
,
float
mass_min
,
float
mass_max
);
float
initial_mass_function_get_integral_xi
(
...
...
src/feedback/GEAR/interpolation.h
View file @
beaf5c3a
...
...
@@ -161,7 +161,7 @@ __attribute__((always_inline)) static INLINE float interpolate_1d(
case
boundary_condition_zero_const
:
return
0
;
case
boundary_condition_const
:
return
interp
->
data
[
0
];
return
interp
->
data
[
0
];
default:
error
(
"Interpolation type not implemented"
);
}
...
...
src/feedback/GEAR/lifetime.h
View file @
beaf5c3a
...
...
@@ -197,7 +197,6 @@ __attribute__((always_inline)) INLINE static void lifetime_init(
/* Change units from yr into Myr */
const
int
dim
=
3
;
lt
->
constant
[
dim
-
1
]
-=
6
;
}
/**
...
...
src/feedback/GEAR/stellar_evolution.c
View file @
beaf5c3a
...
...
@@ -94,8 +94,10 @@ int stellar_evolution_compute_integer_number_supernovae(
* (solMass)
* @param m_end_step Mass of a star ending its life at the end of the step
* (solMass)
* @param number_snia_f (Floating) Number of SNIa produced by the stellar particle.
* @param number_snii_f (Floating) Number of SNII produced by the stellar particle.
* @param number_snia_f (Floating) Number of SNIa produced by the stellar
* particle.
* @param number_snii_f (Floating) Number of SNII produced by the stellar
* particle.
*
*/
void
stellar_evolution_compute_continuous_feedback_properties
(
...
...
@@ -107,15 +109,16 @@ void stellar_evolution_compute_continuous_feedback_properties(
/* Compute the mass ejected */
/* 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 */
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
);
/* Sum the contributions from SNIa and SNII */
sp
->
feedback_data
.
mass_ejected
=
mass_frac_snii
*
sp
->
sf_data
.
birth_mass
+
mass_snia
*
phys_const
->
const_solar_mass
;
sp
->
feedback_data
.
mass_ejected
=
mass_frac_snii
*
sp
->
sf_data
.
birth_mass
+
mass_snia
*
phys_const
->
const_solar_mass
;
if
(
sp
->
mass
<=
sp
->
feedback_data
.
mass_ejected
)
{
error
(
"Stars cannot have negative mass. (%g <= %g). Initial mass = %g"
,
...
...
@@ -132,21 +135,22 @@ void stellar_evolution_compute_continuous_feedback_properties(
/* Compute the SNII yields */
float
snii_yields
[
GEAR_CHEMISTRY_ELEMENT_COUNT
];
supernovae_ii_get_yields_from_integral
(
&
sm
->
snii
,
log_m_end_step
,
log_m_beg_step
,
snii_yields
);
supernovae_ii_get_yields_from_integral
(
&
sm
->
snii
,
log_m_end_step
,
log_m_beg_step
,
snii_yields
);
/* Compute the mass fraction of non processed elements */
const
float
non_processed
=
supernovae_ii_get_ejected_mass_fraction_non_processed_from_integral
(
&
sm
->
snii
,
log_m_end_step
,
log_m_beg_step
);
const
float
non_processed
=
supernovae_ii_get_ejected_mass_fraction_non_processed_from_integral
(
&
sm
->
snii
,
log_m_end_step
,
log_m_beg_step
);
/* Set the yields */
for
(
int
i
=
0
;
i
<
GEAR_CHEMISTRY_ELEMENT_COUNT
;
i
++
)
{
/* Compute the mass fraction of metals */
sp
->
feedback_data
.
metal_mass_ejected
[
i
]
=
/* Supernovae II yields */
snii_yields
[
i
]
+
/* Gas contained in stars initial metallicity */
chemistry_get_metal_mass_fraction_for_feedback
(
sp
)[
i
]
*
non_processed
;
/* Supernovae II yields */
snii_yields
[
i
]
+
/* Gas contained in stars initial metallicity */
chemistry_get_metal_mass_fraction_for_feedback
(
sp
)[
i
]
*
non_processed
;
/* Convert it to total mass */
sp
->
feedback_data
.
metal_mass_ejected
[
i
]
*=
sp
->
sf_data
.
birth_mass
;
...
...
@@ -155,8 +159,7 @@ void stellar_evolution_compute_continuous_feedback_properties(
/* Add the Supernovae Ia */
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(
const
float
m_init
,
const
int
number_snia
,
const
int
number_snii
)
{
/* Compute the average mass */
const
float
m_avg
=
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
m_avg
=
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
);
/* Compute the mass ejected */
/* 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 */
const
float
mass_snii
=
supernovae_ii_get_ejected_mass_fraction_processed_from_raw
(
&
sm
->
snii
,
log_m_avg
)
*
m_avg
*
number_snii
;
supernovae_ii_get_ejected_mass_fraction_processed_from_raw
(
&
sm
->
snii
,
log_m_avg
)
*
m_avg
*
number_snii
;
sp
->
feedback_data
.
mass_ejected
=
mass_snia
+
mass_snii
;
...
...
@@ -222,24 +227,23 @@ void stellar_evolution_compute_discrete_feedback_properties(
/* Compute the mass fraction of non processed elements */
const
float
non_processed
=
supernovae_ii_get_ejected_mass_fraction_non_processed_from_raw
(
&
sm
->
snii
,
log_m_avg
);
supernovae_ii_get_ejected_mass_fraction_non_processed_from_raw
(
&
sm
->
snii
,
log_m_avg
);
/* Set the yields */
for
(
int
i
=
0
;
i
<
GEAR_CHEMISTRY_ELEMENT_COUNT
;
i
++
)
{
/* Compute the mass fraction of metals */
sp
->
feedback_data
.
metal_mass_ejected
[
i
]
=
/* Supernovae II yields */
snii_yields
[
i
]
+
/* Gas contained in stars initial metallicity */
chemistry_get_metal_mass_fraction_for_feedback
(
sp
)[
i
]
*
non_processed
;
/* Supernovae II yields */
snii_yields
[
i
]
+
/* Gas contained in stars initial metallicity */
chemistry_get_metal_mass_fraction_for_feedback
(
sp
)[
i
]
*
non_processed
;
/* Convert it to total mass */
sp
->
feedback_data
.
metal_mass_ejected
[
i
]
*=
m_avg
*
number_snii
;
/* Supernovae Ia yields */
sp
->
feedback_data
.
metal_mass_ejected
[
i
]
+=
snia_yields
[
i
]
*
number_snia
;
sp
->
feedback_data
.
metal_mass_ejected
[
i
]
+=
snia_yields
[
i
]
*
number_snia
;
/* Convert everything in code units */
sp
->
feedback_data
.
metal_mass_ejected
[
i
]
*=
phys_const
->
const_solar_mass
;
...
...
@@ -306,12 +310,18 @@ void stellar_evolution_evolve_spart(
const
float
m_init
=
sp
->
sf_data
.
birth_mass
/
phys_const
->
const_solar_mass
;
/* Compute number of 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
;
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
;
/* Compute number of 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
;
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
;
/* Does this star produce a supernovae? */
if
(
number_snia_f
==
0
&&
number_snii_f
==
0
)
return
;
...
...
@@ -320,11 +330,11 @@ void stellar_evolution_evolve_spart(
if
(
sm
->
discrete_yields
)
{
/* Get the integer number of 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 */
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? */
if
(
number_snia
==
0
&&
number_snii
==
0
)
return
;
...
...
src/feedback/GEAR/stellar_evolution_struct.h
View file @
beaf5c3a
...
...
@@ -121,20 +121,23 @@ struct supernovae_ii {
/*! Total mass fraction ejected. */
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
;
}
raw
;
/*! Yields integrated */
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
];
/*! Total mass fraction ejected (integrated over the IMF) */
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
;
}
integrated
;
...
...
src/feedback/GEAR/supernovae_ia.c
View file @
beaf5c3a
...
...
@@ -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.
*/
float
supernovae_ia_get_number_per_unit_mass
(
const
struct
supernovae_ia
*
snia
,
float
m1
,
float
m2
)
{
float
supernovae_ia_get_number_per_unit_mass
(
const
struct
supernovae_ia
*
snia
,
float
m1
,
float
m2
)
{
#ifdef SWIFT_DEBUG_CHECKS
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) {
/* Get the exponent for the integral */
const
float
exp
=
snia
->
companion_exponent
;
for
(
int
i
=
0
;
i
<
GEAR_NUMBER_TYPE_OF_COMPANION
;
i
++
)
{
/* Compute the integral */
...
...
@@ -231,7 +231,7 @@ void supernovae_ia_init_companion(struct supernovae_ia *snia) {
integral
/=
exp
+
1
.;
/* Update the coefficient for a normalization to 1 of the IMF */
snia
->
companion
[
i
].
coef
/=
exp
*
integral
;
snia
->
companion
[
i
].
coef
/=
exp
*
integral
;
}
}
...
...
src/feedback/GEAR/supernovae_ia.h
View file @
beaf5c3a
...
...
@@ -32,8 +32,8 @@ float supernovae_ia_get_ejected_mass_processed(
float
supernovae_ia_get_companion_fraction
(
const
struct
supernovae_ia
*
snia
,
float
m1
,
float
m2
,
int
companion_type
);
float
supernovae_ia_get_number_per_unit_mass
(
const
struct
supernovae_ia
*
snia
,
float
m1
,
float
m2
);
float
supernovae_ia_get_number_per_unit_mass
(
const
struct
supernovae_ia
*
snia
,
float
m1
,
float
m2
);
void
supernovae_ia_read_yields
(
struct
supernovae_ia
*
snia
,
struct
swift_params
*
params
,
...
...
src/feedback/GEAR/supernovae_ii.c
View file @
beaf5c3a
...
...
@@ -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.
*/
float
supernovae_ii_get_number_per_unit_mass
(
const
struct
supernovae_ii
*
snii
,
float
m1
,
float
m2
)
{
float
supernovae_ii_get_number_per_unit_mass
(
const
struct
supernovae_ii
*
snii
,
float
m1
,
float
m2
)
{
#ifdef SWIFT_DEBUG_CHECKS
if
(
m1
>
m2
)
error
(
"Mass 1 larger than mass 2 %g > %g."
,
m1
,
m2
);
#endif
...
...
@@ -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 yields The elements ejected (needs to be allocated).
*/
void
supernovae_ii_get_yields_from_integral
(
const
struct
supernovae_ii
*
snii
,
float
log_m1
,
float
log_m2
,
float
*
yields
)
{
void
supernovae_ii_get_yields_from_integral
(
const
struct
supernovae_ii
*
snii
,
float
log_m1
,
float
log_m2
,
float
*
yields
)
{
for
(
int
i
=
0
;
i
<
GEAR_CHEMISTRY_ELEMENT_COUNT
;
i
++
)
{
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
* @param log_m The mass in log.
* @param yields The elements ejected (needs to be allocated).
*/
void
supernovae_ii_get_yields_from_raw
(
const
struct
supernovae_ii
*
snii
,
float
log_m
,
float
*
yields
)
{
void
supernovae_ii_get_yields_from_raw
(
const
struct
supernovae_ii
*
snii
,
float
log_m
,
float
*
yields
)
{
for
(
int
i
=
0
;
i
<
GEAR_CHEMISTRY_ELEMENT_COUNT
;
i
++
)
{
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
*
* @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
log_m1
,
float
log_m2
)
{
float
supernovae_ii_get_ejected_mass_fraction_non_processed_from_integral
(
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_2
=
interpolate_1d
(
&
snii
->
integrated
.
ejected_mass_non_processed
,
log_m2
);
float
mass_ejected_1
=
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
;
};
/**
* @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
*
* @return The mass of non processsed elements.
*/
float
supernovae_ii_get_ejected_mass_fraction_non_processed_from_raw
(
const
struct
supernovae_ii
*
snii
,
float
log_m
)
{
float
supernovae_ii_get_ejected_mass_fraction_non_processed_from_raw
(
const
struct
supernovae_ii
*
snii
,
float
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(
return
mass_ejected_2
-
mass_ejected_1
;
};
/**
* @brief Get the ejected mass (processed) per mass.
*
...
...
@@ -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 hdf5_dataset_name The dataset name to 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
(
struct
supernovae_ii
*
snii
,
struct
interpolation_1d
*
interp_raw
,
struct
interpolation_1d
*
interp_int
,
const
struct
phys_const
*
phys_const
,
const
struct
stellar_model
*
sm
,
hid_t
group_id
,
const
char
*
hdf5_dataset_name
,
hsize_t
*
previous_count
,
struct
interpolation_1d
*
interp_int
,
const
struct
phys_const
*
phys_const
,
const
struct
stellar_model
*
sm
,
hid_t
group_id
,
const
char
*
hdf5_dataset_name
,
hsize_t
*
previous_count
,
int
interpolation_size
)
{
/* Now let's get the number of elements */
...
...
@@ -247,16 +249,16 @@ void supernovae_ii_read_yields_array(
/* Initialize the raw interpolation */
interpolate_1d_init
(
interp_raw
,
log10
(
snii
->
mass_min
),
log10
(
snii
->
mass_max
),
interpolation_size
,
log_mass_min
,
step_size
,
count
,
data
,
boundary_condition_zero
);
boundary_condition_zero
);
initial_mass_function_integrate
(
&
sm
->
imf
,
data
,
count
,
log_mass_min
,
step_size
);
initial_mass_function_integrate
(
&
sm
->
imf
,
data
,
count
,
log_mass_min
,
step_size
);
// TODO: decrease count in order to keep the same distance between points
/* Initialize the integrated interpolation */
interpolate_1d_init
(
interp_int
,
log10
(
snii
->
mass_min
),
log10
(
snii
->
mass_max
),
interpolation_size
,
log_mass_min
,
step_size
,
count
,
data
,
boundary_condition_const
);
boundary_condition_const
);
/* Cleanup the memory */
free
(
data
);
...
...
@@ -293,23 +295,21 @@ void supernovae_ii_read_yields(struct supernovae_ii *snii,
const
char
*
name
=
stellar_evolution_get_element_name
(
sm
,
i
);
/* Read the array */
supernovae_ii_read_yields_array
(
snii
,
&
snii
->
raw
.
yields
[
i
],
&
snii
->
integrated
.
yields
[
i
],
phys_const
,
sm
,
group_id
,
name
,
&
previous_count
,
interpolation_size
);
supernovae_ii_read_yields_array
(
snii
,
&
snii
->
raw
.
yields
[
i
],
&
snii
->
integrated
.
yields
[
i
],
phys_const
,
sm
,
group_id
,
name
,
&
previous_count
,
interpolation_size
);
}
/* Read the mass ejected */
supernovae_ii_read_yields_array
(
snii
,
&
snii
->
raw
.
ejected_mass_processed
,
&
snii
->
integrated
.
ejected_mass_processed
,
phys_const
,
sm
,
group_id
,
"Ej"
,
&
previous_count
,
interpolation_size
);
supernovae_ii_read_yields_array
(
snii
,
&
snii
->
raw
.
ejected_mass_processed
,
&
snii
->
integrated
.
ejected_mass_processed
,
phys_const
,
sm
,
group_id
,
"Ej"
,
&
previous_count
,
interpolation_size
);
/* Read the mass ejected of non processed gas */
supernovae_ii_read_yields_array
(
snii
,
&
snii
->
raw
.
ejected_mass_non_processed
,
&
snii
->
integrated
.
ejected_mass_non_processed
,
phys_const
,
sm
,
group_id
,
"Ejnp"
,
&
snii
->
integrated
.
ejected_mass_non_processed
,
phys_const
,
sm
,
group_id
,
"Ejnp"
,
&
previous_count
,
interpolation_size
);
/* Cleanup everything */
...
...
@@ -414,8 +414,9 @@ void supernovae_ii_dump(const struct supernovae_ii *snii, FILE *stream,
strcat
(
name
,
"_int"
);
/* Write the array */
restart_write_blocks
((
void
*
)
snii
->
integrated
.
yields
[
i
].
data
,
sizeof
(
float
),
snii
->
integrated
.
yields
[
i
].
N
,
stream
,
name
,
name
);
restart_write_blocks
((
void
*
)
snii
->
integrated
.
yields
[
i
].
data
,
sizeof
(
float
),
snii
->
integrated
.
yields
[
i
].
N
,
stream
,
name
,
name
);
}
/* Raw yields */
...
...
@@ -427,9 +428,8 @@ void supernovae_ii_dump(const struct supernovae_ii *snii, FILE *stream,
/* Write the array */
restart_write_blocks
((
void
*
)
snii
->
raw
.
yields
[
i
].
data
,
sizeof
(
float
),
snii
->
raw
.
yields
[
i
].
N
,
stream
,
name
,
name
);
snii
->
raw
.
yields
[
i
].
N
,
stream
,
name
,
name
);
}
}
/*! Dump the processed mass (integrated). */
...
...
@@ -443,25 +443,25 @@ void supernovae_ii_dump(const struct supernovae_ii *snii, FILE *stream,
/*! Dump the processed mass (raw). */
if
(
snii
->
raw
.
ejected_mass_processed
.
data
!=
NULL
)
{
restart_write_blocks
((
void
*
)
snii
->
raw
.
ejected_mass_processed
.
data
,
sizeof
(
float
),
snii
->
raw
.
ejected_mass_processed
.
N
,
stream
,
"processed_mass_raw"
,
"processed_mass_raw"
);
sizeof
(
float
),
snii
->
raw
.
ejected_mass_processed
.
N
,
stream
,
"processed_mass_raw"
,
"processed_mass_raw"
);
}
/*! Dump the non processed mass (integrated). */
if
(
snii
->
integrated
.
ejected_mass_non_processed
.
data
!=
NULL
)
{
restart_write_blocks
((
void
*
)
snii
->
integrated
.
ejected_mass_non_processed
.
data
,
sizeof
(
float
),
snii
->
integrated
.
ejected_mass_non_processed
.
N
,
stream
,
"non_processed_mass_int"
,
"non_processed_mass_int"
);
restart_write_blocks
(
(
void
*
)
snii
->
integrated
.
ejected_mass_non_processed
.
data
,
sizeof
(
float
),
snii
->
integrated
.
ejected_mass_non_processed
.
N
,
stream
,
"non_processed_mass_int"
,
"non_processed_mass_int"
);
}
/*! Dump the non processed mass (raw). */
if
(
snii
->
raw
.
ejected_mass_non_processed
.
data
!=
NULL
)
{
restart_write_blocks
((
void
*
)
snii
->
raw
.
ejected_mass_non_processed
.
data
,
sizeof
(
float
),
snii
->
raw
.
ejected_mass_non_processed
.
N
,
stream
,
"non_processed_mass_raw"
,
"non_processed_mass_raw"
);
sizeof
(
float
),
snii
->
raw
.
ejected_mass_non_processed
.
N
,
stream
,
"non_processed_mass_raw"
,
"non_processed_mass_raw"
);
}
}
/**
...
...
@@ -490,14 +490,15 @@ void supernovae_ii_restore(struct supernovae_ii *snii, FILE *stream,
/* Allocate the memory */
snii
->
integrated
.
yields
[
i
].
data
=
(
float
*
)
malloc
(
sizeof
(
float
)
*
snii
->
integrated
.
yields
[
i
].
N
);
(
float
*
)
malloc
(
sizeof
(
float
)
*
snii
->
integrated
.
yields
[
i
].
N
);
if
(
snii
->
integrated
.
yields
[
i
].
data
==
NULL
)
{
error
(
"Failed to allocate memory for the yields"
);
error
(
"Failed to allocate memory for the yields"
);
}
/* Read the data */
restart_read_blocks
((
void
*
)
snii
->
integrated
.
yields
[
i
].
data
,
sizeof
(
float
),
snii
->
integrated
.
yields
[
i
].
N
,
stream
,
NULL
,
name
);
/* Read the data */
restart_read_blocks
((
void
*
)
snii
->
integrated
.
yields
[
i
].
data
,
sizeof
(
float
),
snii
->
integrated
.
yields
[
i
].
N
,
stream
,
NULL
,
name
);
}
/* Raw yields */
...
...
@@ -509,25 +510,24 @@ void supernovae_ii_restore(struct supernovae_ii *snii, FILE *stream,
/* Allocate the memory */
snii
->
raw
.
yields
[
i
].
data
=
(
float
*
)
malloc
(
sizeof
(
float
)
*
snii
->
raw
.
yields
[
i
].
N
);
(
float
*
)
malloc
(
sizeof
(
float
)
*
snii
->
raw
.
yields
[
i
].
N
);
if
(
snii
->
raw
.
yields
[
i
].
data
==
NULL
)
{
error
(
"Failed to allocate memory for the yields"
);
error
(
"Failed to allocate memory for the yields"
);
}
/* Read the data */
/* Read the data */
restart_read_blocks
((
void
*
)
snii
->
raw
.
yields
[
i
].
data
,
sizeof
(
float
),
snii
->
raw
.
yields
[
i
].
N
,
stream
,
NULL
,
name
);
snii
->
raw
.
yields
[
i
].
N
,
stream
,
NULL
,
name
);
}
}
/* Restore the processed mass (integrated) */
if
(
snii
->
integrated
.
ejected_mass_processed
.
data
!=
NULL
)
{
snii
->
integrated
.
ejected_mass_processed
.
data
=
(
float
*
)
malloc
(
sizeof
(
float
)
*
snii
->
integrated
.
ejected_mass_processed
.
N
);
if
(
snii
->
integrated
.
ejected_mass_processed
.
data
==
NULL
)
{
error
(
"Failed to allocate memory for the yields"
);
}
if
(
snii
->
integrated
.
ejected_mass_processed
.
data
==
NULL
)
{
error
(
"Failed to allocate memory for the yields"
);
}
restart_read_blocks
((
void
*
)
snii
->
integrated
.
ejected_mass_processed
.
data
,
sizeof
(
float
),
...
...
@@ -537,44 +537,43 @@ void supernovae_ii_restore(struct supernovae_ii *snii, FILE *stream,
/* Restore the processed mass (raw) */
if
(
snii
->
raw
.
ejected_mass_processed
.
data
!=
NULL
)
{
snii
->
raw
.
ejected_mass_processed
.
data
=
(
float
*
)
malloc
(
sizeof
(
float
)
*
snii
->
raw
.
ejected_mass_processed
.
N
);
if
(
snii
->
raw
.
ejected_mass_processed
.
data
==
NULL
)
{
error
(
"Failed to allocate memory for the yields"
);
}
snii
->
raw
.
ejected_mass_processed
.
data
=
(
float
*
)
malloc
(
sizeof
(
float
)
*
snii
->
raw
.
ejected_mass_processed
.
N
);
if
(
snii
->
raw
.
ejected_mass_processed
.
data
==
NULL
)
{
error
(
"Failed to allocate memory for the yields"
);
}