Skip to content
Snippets Groups Projects
Commit a1f4b098 authored by Folkert Nobels's avatar Folkert Nobels
Browse files

Add SFR to the xpart of the gas particle for only Gadget 2 SPH as temporary position

parent 6cfefd19
No related branches found
No related tags found
1 merge request!705Star formation following Schaye08
...@@ -60,6 +60,9 @@ struct xpart { ...@@ -60,6 +60,9 @@ struct xpart {
/* Additional data used by the tracers */ /* Additional data used by the tracers */
struct tracers_xpart_data tracers_data; struct tracers_xpart_data tracers_data;
/* SFR label */
float SFR;
#ifdef WITH_LOGGER #ifdef WITH_LOGGER
/* Additional data for the particle logger */ /* Additional data for the particle logger */
struct logger_part_data logger_data; struct logger_part_data logger_data;
......
...@@ -515,7 +515,7 @@ void runner_do_star_formation(struct runner *r, struct cell *c, int timer) { ...@@ -515,7 +515,7 @@ void runner_do_star_formation(struct runner *r, struct cell *c, int timer) {
// const float rho = hydro_get_physical_density(p, cosmo); // const float rho = hydro_get_physical_density(p, cosmo);
if (star_formation_convert_to_star(e, starform, p, xp, constants, cosmo, if (star_formation_convert_to_star(e, starform, p, xp, constants, cosmo,
hydro_props, us, cooling, dt_star)) { hydro_props, us, cooling, dt_star, with_cosmology)) {
/* Convert your particle to a star */ /* Convert your particle to a star */
struct spart *sp = cell_convert_part_to_spart(e, c, p, xp); struct spart *sp = cell_convert_part_to_spart(e, c, p, xp);
......
...@@ -200,12 +200,12 @@ INLINE static int star_formation_potential_to_become_star( ...@@ -200,12 +200,12 @@ INLINE static int star_formation_potential_to_become_star(
*/ */
INLINE static int star_formation_convert_to_star( INLINE static int star_formation_convert_to_star(
const struct engine* e, const struct star_formation* starform, const struct engine* e, const struct star_formation* starform,
const struct part* restrict p, const struct xpart* restrict xp, const struct part* restrict p, struct xpart* restrict xp,
const struct phys_const* const phys_const, const struct cosmology* cosmo, const struct phys_const* const phys_const, const struct cosmology* cosmo,
const struct hydro_props* restrict hydro_props, const struct hydro_props* restrict hydro_props,
const struct unit_system* restrict us, const struct unit_system* restrict us,
const struct cooling_function_data* restrict cooling, const struct cooling_function_data* restrict cooling,
const double dt_star) { const double dt_star, const int with_cosmology) {
if (dt_star == 0.f) return 0; if (dt_star == 0.f) return 0;
...@@ -219,9 +219,14 @@ INLINE static int star_formation_convert_to_star( ...@@ -219,9 +219,14 @@ INLINE static int star_formation_convert_to_star(
starform->EOS_density_norm / phys_const->const_proton_mass, starform->EOS_density_norm / phys_const->const_proton_mass,
starform->polytropic_index); starform->polytropic_index);
/* Calculate the star formation rate */
const double SFRpergasmass = starform->SF_normalization *
pow(pressure, starform->SF_power_law);
xp->SFR = SFRpergasmass * p->mass;
/* Calculate the propability of forming a star */ /* Calculate the propability of forming a star */
const double prop = starform->SF_normalization * const double prop = SFRpergasmass * dt_star;
pow(pressure, starform->SF_power_law) * dt_star;
/* Calculate the seed */ /* Calculate the seed */
unsigned int seed = (p->id + e->ti_current) % 8191; unsigned int seed = (p->id + e->ti_current) % 8191;
...@@ -234,6 +239,15 @@ INLINE static int star_formation_convert_to_star( ...@@ -234,6 +239,15 @@ INLINE static int star_formation_convert_to_star(
/* Calculate if we form a star */ /* Calculate if we form a star */
return (prop > randomnumber); return (prop > randomnumber);
}
/* Check if it is the first time steps after star formation */
if (xp->SFR>0.f) {
if (with_cosmology) {
xp->SFR = - cosmo->a;
} else {
xp->SFR = - e->time;
}
} }
return 0; return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment