Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
0a5b9afd
Commit
0a5b9afd
authored
6 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Prevent rounding errors when computing stellar ages in the EAGLE feedback model.
parent
9037c0a0
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/feedback/EAGLE/feedback.c
+17
-12
17 additions, 12 deletions
src/feedback/EAGLE/feedback.c
with
17 additions
and
12 deletions
src/feedback/EAGLE/feedback.c
+
17
−
12
View file @
0a5b9afd
...
...
@@ -114,7 +114,7 @@ double eagle_feedback_energy_fraction(const struct spart* sp,
/* Calculate f_E */
const
double
Z_term
=
pow
(
max
(
Z_smooth
,
1e-6
)
/
Z_0
,
n_Z
);
const
double
n_term
=
pow
(
max
(
n_birth
,
1e-6
)
/
n_0
,
-
n_n
);
const
double
n_term
=
pow
(
n_birth
/
n_0
,
-
n_n
);
const
double
denonimator
=
1
.
+
Z_term
*
n_term
;
return
f_E_min
+
(
f_E_max
-
f_E_min
)
/
denonimator
;
...
...
@@ -181,6 +181,11 @@ INLINE static void compute_SNII_feedback(
delta_u
=
f_E
*
E_SNe
*
N_SNe
/
ngb_gas_mass
;
}
#ifdef SWIFT_DEBUG_CHECKS
if
(
f_E
<
feedback_props
->
f_E_min
||
f_E
>
feedback_props
->
f_E_max
)
error
(
"f_E is not in the valid range! f_E=%f sp->id=%lld"
,
f_E
,
sp
->
id
);
#endif
/* Store all of this in the star for delivery onto the gas */
sp
->
f_E
=
f_E
;
sp
->
feedback_data
.
to_distribute
.
SNII_heating_probability
=
prob
;
...
...
@@ -309,12 +314,17 @@ INLINE static void determine_bin_yield_SNII(
INLINE
static
void
evolve_SNIa
(
const
float
log10_min_mass
,
const
float
log10_max_mass
,
const
struct
feedback_props
*
props
,
struct
spart
*
sp
,
float
star_age_Gyr
,
float
dt_Gyr
)
{
struct
spart
*
sp
,
double
star_age_Gyr
,
double
dt_Gyr
)
{
/* Check if we're outside the mass range for SNIa */
if
(
log10_min_mass
>=
props
->
log10_SNIa_max_mass_msun
)
return
;
#ifdef SWIFT_DEBUG_CHECKS
if
(
dt_Gyr
<
0
.)
error
(
"Negative time-step length!"
);
if
(
star_age_Gyr
<
0
.)
error
(
"Negative age!"
);
#endif
/* If the max mass is outside the mass range update it to be the maximum
* and use updated values for the star's age and timestep in this function */
if
(
log10_max_mass
>
props
->
log10_SNIa_max_mass_msun
)
{
...
...
@@ -323,15 +333,10 @@ INLINE static void evolve_SNIa(const float log10_min_mass,
const
float
max_mass
=
exp10f
(
props
->
log10_SNIa_max_mass_msun
);
const
float
lifetime_Gyr
=
lifetime_in_Gyr
(
max_mass
,
Z
,
props
);
dt_Gyr
=
star_age_Gyr
+
dt_Gyr
-
lifetime_Gyr
;
dt_Gyr
=
max
(
star_age_Gyr
+
dt_Gyr
-
lifetime_Gyr
,
0
.)
;
star_age_Gyr
=
lifetime_Gyr
;
}
#ifdef SWIFT_DEBUG_CHECKS
if
(
dt_Gyr
<
0
.)
error
(
"Negative time-step length!"
);
if
(
star_age_Gyr
<
0
.)
error
(
"Negative age!"
);
#endif
/* Compute the number of SNIa */
const
float
num_SNIa
=
eagle_feedback_number_of_SNIa
(
sp
,
star_age_Gyr
,
star_age_Gyr
+
dt_Gyr
,
props
);
...
...
@@ -704,9 +709,9 @@ void compute_stellar_evolution(const struct feedback_props* feedback_props,
/* Convert dt and stellar age from internal units to Gyr. */
const
double
Gyr_in_cgs
=
1e9
*
365
.
*
24
.
*
3600
.;
const
double
time_to_cgs
=
units_cgs_conversion_factor
(
us
,
UNIT_CONV_TIME
);
const
float
conversion_factor
=
time_to_cgs
/
Gyr_in_cgs
;
const
float
dt_Gyr
=
dt
*
conversion_factor
;
const
float
star_age_Gyr
=
age
*
conversion_factor
;
const
double
conversion_factor
=
time_to_cgs
/
Gyr_in_cgs
;
const
double
dt_Gyr
=
dt
*
conversion_factor
;
const
double
star_age_Gyr
=
age
*
conversion_factor
;
/* Get the metallicity */
const
float
Z
=
sp
->
chemistry_data
.
metal_mass_fraction_total
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment