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

Make the seed external and explicit in the runner

parent 0aa907f8
No related branches found
No related tags found
1 merge request!705Star formation following Schaye08
......@@ -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,9 +493,10 @@ 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.
......
......@@ -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) {
......@@ -358,6 +362,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};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment