gitlab is upgraded to version 13, please report any issues and enjoy

Commit dd2bff29 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Allow users to overwrite the birth density and birth temperature of stars in the EAGLE model.

parent e1ea61bb
......@@ -54,12 +54,16 @@ SPH:
# Parameters of the stars neighbour search
Stars:
resolution_eta: 1.2348 # (Optional) Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). Defaults to the SPH value.
h_tolerance: 1e-4 # (Optional) Relative accuracy of the Netwon-Raphson scheme for the smoothing lengths. Defaults to the SPH value.
max_ghost_iterations: 30 # (Optional) Maximal number of iterations allowed to converge towards the smoothing length. Defaults to the SPH value.
max_volume_change: 1.4 # (Optional) Maximal allowed change of kernel volume over one time-step. Defaults to the SPH value.
overwrite_birth_time: 0 # (Optional) Do we want to overwrite the birth time of the stars read from the ICs? (default: 0).
birth_time: -1 # (Optional) Initial birth times of *all* the stars to be used if we are overwriting them. (-1 means the stars remain inactive feedback-wise througout the run).
resolution_eta: 1.2348 # (Optional) Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). Defaults to the SPH value.
h_tolerance: 1e-4 # (Optional) Relative accuracy of the Netwon-Raphson scheme for the smoothing lengths. Defaults to the SPH value.
max_ghost_iterations: 30 # (Optional) Maximal number of iterations allowed to converge towards the smoothing length. Defaults to the SPH value.
max_volume_change: 1.4 # (Optional) Maximal allowed change of kernel volume over one time-step. Defaults to the SPH value.
overwrite_birth_time: 0 # (Optional) Do we want to overwrite the birth time of the stars read from the ICs? (default: 0).
birth_time: -1 # (Optional) Initial birth times of *all* the stars to be used if we are overwriting them. (-1 means the stars remain inactive feedback-wise througout the run).
overwrite_birth_density: 0 # (Optional) Do we want to overwrite the birth density of the stars read from the ICs? (default: 0).
birth_density: -1 # (Optional) Initial birth densities of *all* the stars to be used if we are overwriting them.
overwrite_birth_temperature: 0 # (Optional) Do we want to overwrite the birth temperature of the stars read from the ICs? (default: 0).
birth_temperature: -1 # (Optional) Initial birth temperatures of *all* the stars to be used if we are overwriting them.
# Parameters for the self-gravity scheme
Gravity:
......
......@@ -240,7 +240,7 @@ double eagle_feedback_energy_fraction(const struct spart* sp,
const double Z = chemistry_get_total_metal_mass_fraction_for_feedback(sp);
/* Physical density of the gas at the star's birth time */
const double rho_birth = sp->sf_data.birth_density;
const double rho_birth = sp->birth_density;
const double n_birth = rho_birth * props->rho_to_n_cgs;
/* Calculate f_E */
......
......@@ -458,11 +458,11 @@ INLINE static void star_formation_copy_properties(
sp->tracers_data = xp->tracers_data;
/* Store the birth density in the star particle */
sp->sf_data.birth_density = hydro_get_physical_density(p, cosmo);
sp->birth_density = hydro_get_physical_density(p, cosmo);
/* Store the birth temperature in the star particle */
sp->sf_data.birth_temperature = cooling_get_temperature(
phys_const, hydro_props, us, cosmo, cooling, p, xp);
sp->birth_temperature = cooling_get_temperature(phys_const, hydro_props, us,
cosmo, cooling, p, xp);
/* Flag that this particle has not done feedback yet */
sp->f_E = -1.f;
......
......@@ -71,21 +71,6 @@ __attribute__((always_inline)) INLINE static int star_formation_write_particles(
__attribute__((always_inline)) INLINE static int
star_formation_write_sparticles(const struct spart* sparts,
struct io_props* list) {
list[0] = io_make_output_field(
"BirthDensities", FLOAT, 1, UNIT_CONV_DENSITY, 0.f, sparts,
sf_data.birth_density,
"Physical densities at the time of birth of the gas particles that "
"turned into stars (note that "
"we store the physical density at the birth redshift, no conversion is "
"needed)");
list[1] =
io_make_output_field("BirthTemperatures", FLOAT, 1, UNIT_CONV_TEMPERATURE,
0.f, sparts, sf_data.birth_temperature,
"Temperatures at the time of birth of the gas "
"particles that turned into stars");
return 2;
return 0;
}
#endif /* SWIFT_STAR_FORMATION_EAGLE_IO_H */
......@@ -38,13 +38,6 @@ struct star_formation_xpart_data {
* @brief Star-formation-related properties stored in the star particle
* data.
*/
struct star_formation_spart_data {
/*! The physical birth density */
float birth_density;
/*! The birth temperature */
float birth_temperature;
};
struct star_formation_spart_data {};
#endif /* SWIFT_EAGLE_STAR_FORMATION_STRUCT_H */
......@@ -68,12 +68,16 @@ __attribute__((always_inline)) INLINE static void stars_first_init_spart(
const int with_cosmology, const double scale_factor, const double time) {
sp->time_bin = 0;
sp->sf_data.birth_density = 0.f;
sp->f_E = -1.f;
sp->count_since_last_enrichment = -1;
if (stars_properties->overwrite_birth_time)
sp->birth_time = stars_properties->spart_first_init_birth_time;
if (stars_properties->overwrite_birth_density)
sp->birth_density = stars_properties->spart_first_init_birth_density;
if (stars_properties->overwrite_birth_temperature)
sp->birth_temperature =
stars_properties->spart_first_init_birth_temperature;
if (with_cosmology)
sp->last_enrichment_time = scale_factor;
......
......@@ -35,7 +35,7 @@ INLINE static void stars_read_particles(struct spart *sparts,
int *num_fields) {
/* Say how much we want to read */
*num_fields = 7;
*num_fields = 9;
/* List what we want to read */
list[0] = io_make_input_field("Coordinates", DOUBLE, 3, COMPULSORY,
......@@ -52,6 +52,11 @@ INLINE static void stars_read_particles(struct spart *sparts,
sparts, mass_init);
list[6] = io_make_input_field("StellarFormationTime", FLOAT, 1, OPTIONAL,
UNIT_CONV_NO_UNITS, sparts, birth_time);
list[7] = io_make_input_field("BirthDensities", FLOAT, 1, OPTIONAL,
UNIT_CONV_DENSITY, sparts, birth_density);
list[8] =
io_make_input_field("BirthTemperatures", FLOAT, 1, OPTIONAL,
UNIT_CONV_TEMPERATURE, sparts, birth_temperature);
}
INLINE static void convert_spart_pos(const struct engine *e,
......@@ -115,7 +120,7 @@ INLINE static void stars_write_particles(const struct spart *sparts,
const int with_cosmology) {
/* Say how much we want to write */
*num_fields = 8;
*num_fields = 10;
/* List what we want to write */
list[0] = io_make_output_field_convert_spart(
......@@ -158,6 +163,19 @@ INLINE static void stars_write_particles(const struct spart *sparts,
"FeedbackEnergyFractions", FLOAT, 1, UNIT_CONV_NO_UNITS, 0.f, sparts, f_E,
"Fractions of the canonical feedback energy that was used for the stars' "
"SNII feedback events");
list[8] = io_make_output_field(
"BirthDensities", FLOAT, 1, UNIT_CONV_DENSITY, 0.f, sparts, birth_density,
"Physical densities at the time of birth of the gas particles that "
"turned into stars (note that "
"we store the physical density at the birth redshift, no conversion is "
"needed)");
list[9] =
io_make_output_field("BirthTemperatures", FLOAT, 1, UNIT_CONV_TEMPERATURE,
0.f, sparts, birth_temperature,
"Temperatures at the time of birth of the gas "
"particles that turned into stars");
}
/**
......@@ -206,15 +224,31 @@ INLINE static void stars_props_init(struct stars_props *sp,
else
sp->log_max_h_change = logf(powf(max_volume_change, hydro_dimension_inv));
/* Do we want to overwrite the stars' birth time? */
/* Do we want to overwrite the stars' birth properties? */
sp->overwrite_birth_time =
parser_get_opt_param_int(params, "Stars:overwrite_birth_time", 0);
sp->overwrite_birth_density =
parser_get_opt_param_int(params, "Stars:overwrite_birth_density", 0);
sp->overwrite_birth_temperature =
parser_get_opt_param_int(params, "Stars:overwrite_birth_temperature", 0);
/* Read birth time to set all stars in ICs */
if (sp->overwrite_birth_time) {
sp->spart_first_init_birth_time =
parser_get_param_float(params, "Stars:birth_time");
}
/* Read birth density to set all stars in ICs */
if (sp->overwrite_birth_density) {
sp->spart_first_init_birth_density =
parser_get_param_float(params, "Stars:birth_density");
}
/* Read birth temperature to set all stars in ICs */
if (sp->overwrite_birth_temperature) {
sp->spart_first_init_birth_temperature =
parser_get_param_float(params, "Stars:birth_temperature");
}
}
/**
......
......@@ -89,6 +89,12 @@ struct spart {
/*! Feedback energy fraction */
float f_E;
/*! The physical birth density */
float birth_density;
/*! The birth temperature */
float birth_temperature;
/*! Star formation struct */
struct star_formation_spart_data sf_data;
......@@ -165,8 +171,20 @@ struct stars_props {
/*! Are we overwriting the stars' birth time read from the ICs? */
int overwrite_birth_time;
/*! Are we overwriting the stars' birth density read from the ICs? */
int overwrite_birth_density;
/*! Are we overwriting the stars' birth temperature read from the ICs? */
int overwrite_birth_temperature;
/*! Value to set birth time of stars read from ICs */
float spart_first_init_birth_time;
/*! Value to set birth density of stars read from ICs */
float spart_first_init_birth_density;
/*! Value to set birth temperature of stars read from ICs */
float spart_first_init_birth_temperature;
};
#endif /* SWIFT_EAGLE_STAR_PART_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment