From c9713695d6b62f2a3944c424a8930e68bafc0e77 Mon Sep 17 00:00:00 2001 From: Folkert Nobels <nobels@strw.leidenuniv.nl> Date: Thu, 13 Dec 2018 17:12:47 +0100 Subject: [PATCH] Add the EOS to the star formation --- examples/parameter_example.yml | 3 +++ src/runner.c | 1 + src/starformation/schaye08/starformation.h | 25 +++++++++++++++++++--- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/examples/parameter_example.yml b/examples/parameter_example.yml index 03b2b1ac52..efbd105bde 100644 --- a/examples/parameter_example.yml +++ b/examples/parameter_example.yml @@ -302,6 +302,9 @@ SchayeSF: MetDep_SFthresh_Slope: -0.64 # (optional) Scaling of the critical density with the metallicity (not used for Schaye2004=0) thresh_MaxPhysDensOn: 0 # (optional) Default is 0. thresh_MaxOverDens_HpCM3: 1e5 # (optional) Density at which the SF law changes + EOS_Jeans_GammaEffective: 1.33333 # (optional) The polytropic index + EOS_Jeans_PressureNorm: 1e3 # (optional) No idea how this works + EOS_JEANS_den0: .1 # (optional) No idea what the value is. # Structure finding options (requires velociraptor) StructureFinding: diff --git a/src/runner.c b/src/runner.c index baa2399091..7006cc0aad 100644 --- a/src/runner.c +++ b/src/runner.c @@ -496,6 +496,7 @@ void runner_do_star_formation(struct runner *r, struct cell *c, int timer) { // 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) ) { + message("Found particle that can form star!"); starformation_convert_to_gas(starform, p, xp, cosmo, testseed); } // MATTHIEU: Temporary star-formation law diff --git a/src/starformation/schaye08/starformation.h b/src/starformation/schaye08/starformation.h index 38cad65122..63f5692231 100644 --- a/src/starformation/schaye08/starformation.h +++ b/src/starformation/schaye08/starformation.h @@ -96,6 +96,14 @@ struct star_formation { /*! Metallicity dependent critical density from Schaye (2004) */ int schaye04; + /*! Polytropic index */ + double polytropic_index; + + /*! EOS pressure norm */ + double EOS_pressure_norm; + + /*! EOS density norm */ + double EOS_den0; }; /* @@ -136,7 +144,7 @@ INLINE static int starformation_potential_to_become_star( /* Check if it exceeded the maximum density */ if (p->rho > starform->den_crit_max) { /* double tempp = cooling_get_temperature() */ - tempp = 1e4; + tempp = 5e3; /* Check the last criteria, if the temperature is satisfied */ if (tempp < starform->T_crit) { return 1; @@ -151,7 +159,7 @@ INLINE static int starformation_potential_to_become_star( double den_crit_current = starform->den_crit * pow(Z/starform->Z0, starform->n_Z0); if (p->rho > den_crit_current) { /* double tempp = cooling_get_temperature() */ - tempp = 1e4; + tempp = 5e3; /* Check the last criteria, if the temperature is satisfied */ if (tempp < starform->T_crit) { return 1; @@ -184,7 +192,8 @@ INLINE static void starformation_convert_to_gas( ){ /* Get the pressure */ - const double pressure = hydro_get_physical_pressure(p, cosmo); + const double pressure = starform->EOS_pressure_norm + * pow(p->rho/starform->EOS_den0, starform->polytropic_index); /* Calculate the propability of forming a star */ const double prop = starform->SF_normalization * pow(pressure, @@ -195,6 +204,7 @@ INLINE static void starformation_convert_to_gas( /* Calculate if we form a star */ if (prop > randomnumber) { + /* How to implement the convert_part_to_spart */ message("Create a STAR!!"); } } @@ -387,6 +397,15 @@ INLINE static void starformation_init_backend( /* !!!DONT FORGET TO DO THE CORRECT UNIT CONVERSION!!!*/ starform->den_crit_star = starform->den_crit / pow(starform->Z0, starform->n_Z0) * conversion_numb_density; + + /* Load the equation of state for this model */ + starform->polytropic_index = parser_get_param_double( + parameter_file, "SchayeSF:EOS_Jeans_GammaEffective"); + starform->EOS_pressure_norm = parser_get_param_double( + parameter_file, "SchayeSF:EOS_Jeans_PressureNorm"); + starform->EOS_den0 = parser_get_param_double( + parameter_file, "SchayeSF:EOS_JEANS_den0"); + } /* @brief Prints the used parameters of the star formation law -- GitLab