diff --git a/src/runner.c b/src/runner.c index ee22bce4115ed7c616ae015936187ad4da980f85..a45475320e4cde5f30047c4bc316744917e25e20 100644 --- a/src/runner.c +++ b/src/runner.c @@ -470,6 +470,7 @@ void runner_do_star_formation(struct runner *r, struct cell *c, int timer) { const int count = c->hydro.count; struct part *restrict parts = c->hydro.parts; struct xpart *restrict xparts = c->hydro.xparts; + unsigned int testseed; TIMER_TIC; @@ -492,23 +493,11 @@ void runner_do_star_formation(struct runner *r, struct cell *c, int timer) { if (part_is_active(p, e)) { //const float rho = hydro_get_physical_density(p, cosmo); - + // THIS IS A VERY WEAK SEED, WE NEED TO IMPROVE THIS + testseed = p->id + timer; if (starformation_potential_to_become_star(starform, p, xp, constants, cosmo) ) { - starformation_convert_to_gas(starform, p, xp, cosmo); + starformation_convert_to_gas(starform, p, xp, cosmo, testseed); } - // MATTHIEU: Temporary star-formation law - // Do not use this at home. - /*if (rho > 1.7e7 && e->step > 2) { - message("Removing particle id=%lld rho=%e", p->id, rho); - - struct spart *sp = cell_convert_part_to_spart(e, c, p, xp); - - // Did we run out of fresh particles? - if (sp == NULL) continue; - - // Set everything to a valid state - stars_init_spart(sp); - }*/ } } } diff --git a/src/starformation/schaye08/starformation.h b/src/starformation/schaye08/starformation.h index 0e6d5d029a91bfc5dd7e2629223271ab4d3a4408..48d0b43f7c6e812ea7e340ebdb45cb4457662cb0 100644 --- a/src/starformation/schaye08/starformation.h +++ b/src/starformation/schaye08/starformation.h @@ -80,6 +80,9 @@ struct star_formation { /*! Critical density to form stars */ double den_crit; + /*! Maximum critical density to form stars */ + double den_crit_max; + /*! Scaling metallicity */ double Z0; @@ -164,10 +167,11 @@ INLINE static int starformation_potential_to_become_star( * */ INLINE static void starformation_convert_to_gas( const struct star_formation* starform, const struct part* restrict p, - const struct xpart* restrict xp, const struct cosmology* cosmo + const struct xpart* restrict xp, const struct cosmology* cosmo, + unsigned int seed ){ /* Set a dummy seed for testing */ - unsigned int globalseed = 42; + //unsigned int globalseed = 42; /* Get the pressure */ const double pressure = hydro_get_physical_pressure(p, cosmo); @@ -177,7 +181,7 @@ INLINE static void starformation_convert_to_gas( starform->SF_power_law) * p->time_bin; /* Generate a random number between 0 and 1. */ - const double randomnumber = rand_r(&globalseed)*starform->inv_RAND_MAX; + const double randomnumber = rand_r(&seed)*starform->inv_RAND_MAX; /* Calculate if we form a star */ if (prop > randomnumber) { @@ -322,6 +326,11 @@ INLINE static void starformation_init_backend( /* Read the power law of the critical density scaling */ starform->n_Z0 = parser_get_opt_param_double( parameter_file, "SchayeSF:MetDep_SFthresh_Slope", powerlawZ_default); + + /* Read the maximum allowed density for star formation */ + starform->den_crit_max = parser_get_opt_param_double( + parameter_file, "SchayeSF:thresh_max_norm_HpCM3",norm_ncrit_no04_default); + } /* Conversion of number density from cgs */ static const float dimension_numb_den[5] = {0, -3, 0, 0, 0};