diff --git a/examples/main.c b/examples/main.c index 7d4667c02d0ed98f0df106922884849c47b5b489..17f2234145094c388dc619e15f18af81eaad0912 100644 --- a/examples/main.c +++ b/examples/main.c @@ -864,9 +864,9 @@ int main(int argc, char *argv[]) { if (myrank == 0) cooling_print(&cooling_func); /* Initialise the star formation law and its properties */ - if (with_star_formation) - starformation_init(params, &prog_const, &us, &starform); - if (myrank ==0) starformation_print(&starform); + if (with_star_formation) + starformation_init(params, &prog_const, &us, &starform); + if (myrank == 0) starformation_print(&starform); /* Initialise the chemistry */ bzero(&chemistry, sizeof(struct chemistry_global_data)); diff --git a/src/engine.c b/src/engine.c index 922cbb6a1b7219de92891e9ae0a1ee333a2a3465..a5cbfd33110ce80f5b8345f9ec4c344816c7de61 100644 --- a/src/engine.c +++ b/src/engine.c @@ -83,6 +83,7 @@ #include "serial_io.h" #include "single_io.h" #include "sort_part.h" +#include "starformation.h" #include "stars_io.h" #include "statistics.h" #include "timers.h" @@ -90,7 +91,6 @@ #include "units.h" #include "velociraptor_interface.h" #include "version.h" -#include "starformation.h" /* Particle cache size. */ #define CACHE_SIZE 512 @@ -5322,8 +5322,8 @@ void engine_struct_restore(struct engine *e, FILE *stream) { cooling_struct_restore(cooling_func, stream, e->cosmology); e->cooling_func = cooling_func; - struct star_formation *star_formation = (struct star_formation *)malloc(sizeof( - struct star_formation)); + struct star_formation *star_formation = + (struct star_formation *)malloc(sizeof(struct star_formation)); starformation_struct_restore(star_formation, stream); e->star_formation = star_formation; diff --git a/src/part.h b/src/part.h index 744bf6edf1e6fda3ff64e6f9f3e666d5d51b5c84..033fd4f6aed7a1fe9f1365971908887050be6c38 100644 --- a/src/part.h +++ b/src/part.h @@ -95,7 +95,7 @@ #include "./stars/EAGLE/stars_part.h" #elif defined(STARS_GEAR) #include "./stars/GEAR/stars_part.h" -#else +#else #error "Invalid choice of star particle" #endif diff --git a/src/physical_constants.c b/src/physical_constants.c index 5996712238188116cc6ba32217f9807be7c71969..10ac9fd7ce8895b2b8d9d4dbfac87c470c0534d3 100644 --- a/src/physical_constants.c +++ b/src/physical_constants.c @@ -138,13 +138,13 @@ void phys_const_init(const struct unit_system *us, struct swift_params *params, units_general_cgs_conversion_factor(us, dimension_reduced_hubble); const float dimension_ks[5] = {1, -2, -1, 0, 0}; /* [g cm^-2 s^-1] */ - internal_const->const_kennicutt_schmidt_units = - const_kennicutt_schmidt_units_cgs / + internal_const->const_kennicutt_schmidt_units = + const_kennicutt_schmidt_units_cgs / units_general_cgs_conversion_factor(us, dimension_ks); - + const float dimension_M_per_pc2[5] = {1, -2, 0, 0, 0}; - internal_const->const_solar_mass_per_parsec2 = - const_solar_mass_per_squared_parsec / + internal_const->const_solar_mass_per_parsec2 = + const_solar_mass_per_squared_parsec / units_general_cgs_conversion_factor(us, dimension_M_per_pc2); } diff --git a/src/runner.c b/src/runner.c index 8fc328190c943aa55bcc10b824a0cef4052aa780..63960b41700a34a1b1afeab0c338d6845e6f3287 100644 --- a/src/runner.c +++ b/src/runner.c @@ -60,12 +60,12 @@ #include "sort_part.h" #include "space.h" #include "space_getsid.h" +#include "starformation.h" #include "stars.h" #include "task.h" #include "timers.h" #include "timestep.h" #include "tracers.h" -#include "starformation.h" #define TASK_LOOP_DENSITY 0 #define TASK_LOOP_GRADIENT 1 @@ -496,10 +496,12 @@ 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); - if (star_formation_convert_to_star(e, starform, p, xp, constants, cosmo, hydro_props, us, cooling) ) { - star_formation_copy_properties(e, c, p, xp, starform, constants, cosmo, with_cosmology); - //struct spart *sp = cell_conert_part_to_spart(c, p, ...); + // const float rho = hydro_get_physical_density(p, cosmo); + if (star_formation_convert_to_star(e, starform, p, xp, constants, cosmo, + hydro_props, us, cooling)) { + star_formation_copy_properties(e, c, p, xp, starform, constants, + cosmo, with_cosmology); + // struct spart *sp = cell_conert_part_to_spart(c, p, ...); } } } diff --git a/src/starformation.c b/src/starformation.c index c9dd394beb3061c42a15a35b33c55cc4e9222c45..b1c023c4242c16d8af70393bacfb98706e7af76c 100644 --- a/src/starformation.c +++ b/src/starformation.c @@ -21,31 +21,31 @@ #include "../config.h" /* This object's header. */ -#include "starformation.h" -#include "restart.h" #include "part.h" +#include "restart.h" +#include "starformation.h" #include "units.h" /** - * @brief Initialises the star formation law properties in the internal + * @brief Initialises the star formation law properties in the internal * unit system. * * @param parameter_file The parsed parameter file * @param phys_const Physical constants in internal units - * @param us the current internal system of units + * @param us the current internal system of units * @param s the #space we run in. - * @param starform the properties of the star formation law + * @param starform the properties of the star formation law */ void starformation_init(struct swift_params* parameter_file, - const struct phys_const* phys_const, - const struct unit_system* us, - struct star_formation* starform) { + const struct phys_const* phys_const, + const struct unit_system* us, + struct star_formation* starform) { starformation_init_backend(parameter_file, phys_const, us, starform); } /** - * @brief Print the properties of the star fromation law + * @brief Print the properties of the star fromation law * * @param starform the star formation properties. */ @@ -62,7 +62,7 @@ void starformation_print(const struct star_formation* starform) { * @param stream the file stream */ void starformation_struct_dump(const struct star_formation* starform, - FILE* stream) { + FILE* stream) { restart_write_blocks((void*)starform, sizeof(struct star_formation), 1, stream, "starformation", "star formation"); } @@ -75,7 +75,7 @@ void starformation_struct_dump(const struct star_formation* starform, * @param streeam the file stream */ void starformation_struct_restore(const struct star_formation* starform, - FILE* stream) { - restart_read_blocks((void*)starform, sizeof(struct star_formation), 1, - stream, NULL, "star formation"); + FILE* stream) { + restart_read_blocks((void*)starform, sizeof(struct star_formation), 1, stream, + NULL, "star formation"); } diff --git a/src/starformation.h b/src/starformation.h index a785135a3051c0d75ed772b29fc7cd1ee3c243f1..43cc39f8aba4c5e0d9d27120c552fc6bbacebd3e 100644 --- a/src/starformation.h +++ b/src/starformation.h @@ -1,6 +1,6 @@ /******************************************************************************* * This file is part of SWIFT. - * Copyright (c) 2018 Folkert Nobels (nobels@strw.leidenuniv.nl) + * Copyright (c) 2018 Folkert Nobels (nobels@strw.leidenuniv.nl) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published @@ -21,7 +21,7 @@ /** * @file src/starformation.h - * @brief Branches between the different star formation recipies. + * @brief Branches between the different star formation recipies. */ /* Config parameters. */ @@ -46,9 +46,9 @@ void starformation_print(const struct star_formation* starform); /* Dump store */ void starformation_struct_dump(const struct star_formation* starform, - FILE* stream); + FILE* stream); void starformation_struct_restore(const struct star_formation* starform, - FILE* stream); + FILE* stream); #endif /* SWIFT_STARFORMATION_H */ diff --git a/src/starformation/none/starformation.h b/src/starformation/none/starformation.h index 715480ac23d9cff532910bc5fb134a4b2a26c21a..52f645e83c7ccfa34eef425dd8f6184e47474e5c 100644 --- a/src/starformation/none/starformation.h +++ b/src/starformation/none/starformation.h @@ -24,14 +24,14 @@ #include <stdlib.h> /* Local includes */ +#include "cell.h" #include "cosmology.h" -#include "physical_constants.h" +#include "equation_of_state.h" +#include "error.h" +#include "parser.h" #include "part.h" +#include "physical_constants.h" #include "units.h" -#include "parser.h" -#include "equation_of_state.h" -#include "error.h" -#include "cell.h" /* Starformation struct */ struct star_formation {}; @@ -50,13 +50,13 @@ struct star_formation {}; INLINE static int star_formation_convert_to_star( const struct star_formation* starform, struct part* restrict p, const struct xpart* restrict xp, const struct phys_const* const phys_const, - const struct cosmology* cosmo){ + const struct cosmology* cosmo) { return 0; } /* - * @brief Calculate if the gas particle is converted + * @brief Calculate if the gas particle is converted * * @param starform the star formation struct * @param p the gas particles with their properties @@ -65,12 +65,12 @@ INLINE static int star_formation_convert_to_star( * * */ INLINE static void star_formation_copy_properties( - struct engine *e, struct cell *c, struct part* p, - struct xpart* xp, const struct star_formation* starform, - const struct phys_const* const phys_const, const struct cosmology* cosmo) {} + struct engine* e, struct cell* c, struct part* p, struct xpart* xp, + const struct star_formation* starform, + const struct phys_const* const phys_const, const struct cosmology* cosmo) {} -/* - * @brief initialization of the star formation law +/* + * @brief initialization of the star formation law * * @param parameter_file The parsed parameter file * @param phys_const Physical constants in internal units @@ -79,19 +79,17 @@ INLINE static void star_formation_copy_properties( * * */ INLINE static void starformation_init_backend( - struct swift_params* parameter_file, const struct phys_const* phys_const, - const struct unit_system* us, const struct star_formation* starform) {} + struct swift_params* parameter_file, const struct phys_const* phys_const, + const struct unit_system* us, const struct star_formation* starform) {} -/* @brief Prints the used parameters of the star formation law +/* @brief Prints the used parameters of the star formation law * * @param starform the star formation law properties. * */ INLINE static void starformation_print_backend( - const struct star_formation* starform){ + const struct star_formation* starform) { message("Star formation law is 'No Star Formation'"); - } - #endif /* SWIFT_NO_STARFORMATION_H */ diff --git a/src/starformation/schaye08/starformation.h b/src/starformation/schaye08/starformation.h index d94ec4c7e56ab63a4869c78e6c0607d840d87bca..56a78d32ff860ccb97456f769f29aa01bf7022a5 100644 --- a/src/starformation/schaye08/starformation.h +++ b/src/starformation/schaye08/starformation.h @@ -24,22 +24,22 @@ #include <stdlib.h> /* Local includes */ +#include "adiabatic_index.h" +#include "cell.h" +#include "cooling.h" #include "cosmology.h" -#include "physical_constants.h" -#include "units.h" #include "engine.h" -#include "parser.h" #include "equation_of_state.h" -#include "part.h" #include "hydro.h" -#include "cooling.h" -#include "adiabatic_index.h" -#include "cell.h" +#include "parser.h" +#include "part.h" +#include "physical_constants.h" #include "stars.h" +#include "units.h" /* Starformation struct */ struct star_formation { - + /*! Normalization of the KS star formation law */ double KS_normalization; @@ -127,25 +127,25 @@ struct star_formation { INLINE static int star_formation_potential_to_become_star( const struct star_formation* starform, const struct part* restrict p, const struct xpart* restrict xp, const struct phys_const* const phys_const, - const struct cosmology* cosmo, const struct hydro_props *restrict hydro_props, - const struct unit_system *restrict us, - const struct cooling_function_data *restrict cooling){ + const struct cosmology* cosmo, + const struct hydro_props* restrict hydro_props, + const struct unit_system* restrict us, + const struct cooling_function_data* restrict cooling) { - /* Read the critical overdensity factor and the critical density of + /* Read the critical overdensity factor and the critical density of * the universe to determine the critical density to form stars*/ - const double rho_crit = cosmo->critical_density*starform->min_over_den; - + const double rho_crit = cosmo->critical_density * starform->min_over_den; + /* double tempp = cooling_get_temperature() */ double tempp; - /* Deside whether we should form stars or not, * first we deterime if we have the correct over density * if that is true we calculate if either the maximum density - * threshold is reached or if the metallicity dependent - * threshold is reached, after this we calculate if the + * threshold is reached or if the metallicity dependent + * threshold is reached, after this we calculate if the * temperature is appropriate */ - if (p->rho > rho_crit ) { + if (p->rho > rho_crit) { /* In this case there are actually multiple possibilities * because we also need to check if the physical density exceeded * the appropriate limit */ @@ -153,22 +153,25 @@ INLINE static int star_formation_potential_to_become_star( /* Check if it exceeded the maximum density */ if (p->rho > starform->den_crit_max) { /* double tempp = cooling_get_temperature() */ - tempp = cooling_get_temperature(phys_const, hydro_props, us, cosmo, cooling, p, xp); + tempp = cooling_get_temperature(phys_const, hydro_props, us, cosmo, + cooling, p, xp); /* Check the last criteria, if the temperature is satisfied */ if (tempp < starform->T_crit) { return 1; } else { return 0; } - /* If the maximum density is not exceeded check if the redshift dependent - * one is exceeded */ + /* If the maximum density is not exceeded check if the redshift dependent + * one is exceeded */ } else { /* NEED TO USE A PROPER WAY OF FINDING Z */ double Z = 0.002; - double den_crit_current = starform->den_crit * pow(Z*starform->Z0_inv, starform->n_Z0); + double den_crit_current = + starform->den_crit * pow(Z * starform->Z0_inv, starform->n_Z0); if (p->rho > den_crit_current) { /* double tempp = cooling_get_temperature() */ - tempp = cooling_get_temperature(phys_const, hydro_props, us, cosmo, cooling, p, xp); + tempp = cooling_get_temperature(phys_const, hydro_props, us, cosmo, + cooling, p, xp); /* Check the last criteria, if the temperature is satisfied */ if (tempp < starform->T_crit) { return 1; @@ -186,7 +189,7 @@ INLINE static int star_formation_potential_to_become_star( /* * @brief Calculates if the gas particle gets converted - * + * * @param the #engine * @param starform the star formation law properties to use. * @param p the gas particles. @@ -198,26 +201,29 @@ INLINE static int star_formation_potential_to_become_star( * @param cooling The cooling data struct. */ INLINE static int star_formation_convert_to_star( - struct engine *e, const struct star_formation* starform, const struct part* restrict p, - const struct xpart* restrict xp, const struct phys_const* const phys_const, - const struct cosmology* cosmo, const struct hydro_props *restrict hydro_props, - const struct unit_system *restrict us, - const struct cooling_function_data *restrict cooling) { + struct engine* e, const struct star_formation* starform, + const struct part* restrict p, const struct xpart* restrict xp, + const struct phys_const* const phys_const, const struct cosmology* cosmo, + const struct hydro_props* restrict hydro_props, + const struct unit_system* restrict us, + const struct cooling_function_data* restrict cooling) { - if (star_formation_potential_to_become_star(starform, p, xp, phys_const, cosmo, hydro_props, us, cooling)){ + if (star_formation_potential_to_become_star( + starform, p, xp, phys_const, cosmo, hydro_props, us, cooling)) { /* Get the pressure */ - const double pressure = starform->EOS_pressure_norm - * pow(p->rho/starform->EOS_density_norm, starform->polytropic_index); - - /* Calculate the propability of forming a star */ - const double prop = starform->SF_normalization * pow(pressure, - starform->SF_power_law) * p->time_bin; + const double pressure = + starform->EOS_pressure_norm * + pow(p->rho / starform->EOS_density_norm, starform->polytropic_index); + + /* Calculate the propability of forming a star */ + const double prop = starform->SF_normalization * + pow(pressure, starform->SF_power_law) * p->time_bin; /* Calculate the seed */ unsigned int seed = (p->id + e->ti_current) % 8191; - + /* Generate a random number between 0 and 1. */ - const double randomnumber = rand_r(&seed)*starform->inv_RAND_MAX; + const double randomnumber = rand_r(&seed) * starform->inv_RAND_MAX; /* Calculate if we form a star */ if (prop > randomnumber) { @@ -245,14 +251,14 @@ INLINE static int star_formation_convert_to_star( * @param with_cosmology if we run with cosmology. */ INLINE static void star_formation_copy_properties( - struct engine *e, struct cell *c, struct part* p, - struct xpart* xp, const struct star_formation* starform, + struct engine* e, struct cell* c, struct part* p, struct xpart* xp, + const struct star_formation* starform, const struct phys_const* const phys_const, const struct cosmology* cosmo, int with_cosmology) { - + /* 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); + /* Store the current mass */ sp->mass = p->mass; @@ -278,11 +284,10 @@ INLINE static void star_formation_copy_properties( sp->new_star_flag = 1; message("A star has been formed!"); - } -/* - * @brief initialization of the star formation law +/* + * @brief initialization of the star formation law * * @param parameter_file The parsed parameter file * @param phys_const Physical constants in internal units @@ -291,11 +296,11 @@ INLINE static void star_formation_copy_properties( * * */ INLINE static void starformation_init_backend( - struct swift_params* parameter_file, const struct phys_const* phys_const, - const struct unit_system* us, struct star_formation* starform) { + struct swift_params* parameter_file, const struct phys_const* phys_const, + const struct unit_system* us, struct star_formation* starform) { - /* Get the appropriate constant to calculate the - * star formation constant */ + /* Get the appropriate constant to calculate the + * star formation constant */ const double KS_const = phys_const->const_kennicutt_schmidt_units; /* Get the Gravitational constant */ @@ -303,138 +308,147 @@ INLINE static void starformation_init_backend( /* Get the surface density unit M_\odot / pc^2 */ const double M_per_pc2 = phys_const->const_solar_mass_per_parsec2; - + /* Calculate inverse of RAND_MAX for the random numbers */ starform->inv_RAND_MAX = 1.f / RAND_MAX; /* Conversion of number density from cgs */ static const float dimension_numb_den[5] = {0, -3, 0, 0, 0}; - const double conversion_numb_density = 1.f/ - units_general_cgs_conversion_factor(us, dimension_numb_den); + const double conversion_numb_density = + 1.f / units_general_cgs_conversion_factor(us, dimension_numb_den); /* Quantities that have to do with the Normal Kennicutt- * Schmidt law will be read in this part of the code*/ /* Read the critical density contrast from the parameter file*/ - starform->min_over_den = parser_get_param_double(parameter_file, - "SchayeSF:thresh_MinOverDens"); + starform->min_over_den = + parser_get_param_double(parameter_file, "SchayeSF:thresh_MinOverDens"); /* Read the critical temperature from the parameter file */ - starform->T_crit = parser_get_param_double(parameter_file, - "SchayeSF:thresh_temp"); + starform->T_crit = + parser_get_param_double(parameter_file, "SchayeSF:thresh_temp"); /* Read the gas fraction from the file */ - starform->fgas = parser_get_param_double(parameter_file, - "SchayeSF:fg"); + starform->fgas = parser_get_param_double(parameter_file, "SchayeSF:fg"); /* Read the normalization of the KS law in KS law units */ const double normalization_MSUNpYRpKPC2 = parser_get_param_double( - parameter_file, "SchayeSF:SchmidtLawCoeff_MSUNpYRpKPC2"); + parameter_file, "SchayeSF:SchmidtLawCoeff_MSUNpYRpKPC2"); /* Read the Kennicutt-Schmidt power law exponent */ - starform->KS_power_law = parser_get_param_double( - parameter_file, "SchayeSF:SchmidtLawExponent"); + starform->KS_power_law = + parser_get_param_double(parameter_file, "SchayeSF:SchmidtLawExponent"); /* Calculate the power law of the star formation */ - starform->SF_power_law = (starform->KS_power_law - 1.f)/2.f; - + starform->SF_power_law = (starform->KS_power_law - 1.f) / 2.f; + /* Give the Kennicutt-Schmidt law the same units as internal units */ starform->KS_normalization = normalization_MSUNpYRpKPC2 * KS_const; - + /* Calculate the starformation prefactor with most terms */ - starform->SF_normalization = starform->KS_normalization * pow(M_per_pc2, -starform->KS_power_law) * - pow( hydro_gamma * starform->fgas / G_newton, starform->SF_power_law); + starform->SF_normalization = + starform->KS_normalization * pow(M_per_pc2, -starform->KS_power_law) * + pow(hydro_gamma * starform->fgas / G_newton, starform->SF_power_law); /* Read the high density Kennicutt-Schmidt power law exponent */ starform->KS_high_den_power_law = parser_get_param_double( - parameter_file, "SchayeSF:SchmidtLawHighDensExponent"); - + parameter_file, "SchayeSF:SchmidtLawHighDensExponent"); + /* Read the high density criteria for the KS law in number density per cm^3 */ const double KS_high_den_thresh_HpCM3 = parser_get_param_double( - parameter_file, "SchayeSF:SchmidtLawHighDens_thresh_HpCM3"); + parameter_file, "SchayeSF:SchmidtLawHighDens_thresh_HpCM3"); /* Transform the KS high density criteria to simulation units */ - starform->KS_high_den_thresh = KS_high_den_thresh_HpCM3 * conversion_numb_density; + starform->KS_high_den_thresh = + KS_high_den_thresh_HpCM3 * conversion_numb_density; /* Calculate the SF high density power law */ - starform->SF_high_den_power_law = (starform->KS_high_den_power_law - 1.f)/2.f; + starform->SF_high_den_power_law = + (starform->KS_high_den_power_law - 1.f) / 2.f; /* Load the equation of state for this model */ starform->polytropic_index = parser_get_param_double( - parameter_file, "SchayeSF:EOS_Jeans_GammaEffective"); + parameter_file, "SchayeSF:EOS_Jeans_GammaEffective"); starform->EOS_temperature_norm = parser_get_param_double( - parameter_file, "SchayeSF:EOS_Jeans_TemperatureNorm_K"); - starform->EOS_density_norm = parser_get_param_double( - parameter_file, "SchayeSF:EOS_JEANS_DensityNorm_HpCM3") * conversion_numb_density; + parameter_file, "SchayeSF:EOS_Jeans_TemperatureNorm_K"); + starform->EOS_density_norm = + parser_get_param_double(parameter_file, + "SchayeSF:EOS_JEANS_DensityNorm_HpCM3") * + conversion_numb_density; /* Calculate the EOS pressure normalization */ - starform->EOS_pressure_norm = starform->EOS_density_norm * starform->EOS_temperature_norm - * phys_const->const_boltzmann_k; + starform->EOS_pressure_norm = starform->EOS_density_norm * + starform->EOS_temperature_norm * + phys_const->const_boltzmann_k; - const double EOS_high_den_pressure = starform->EOS_pressure_norm * pow( - starform->KS_high_den_thresh / starform->EOS_density_norm, starform->polytropic_index); + const double EOS_high_den_pressure = + starform->EOS_pressure_norm * + pow(starform->KS_high_den_thresh / starform->EOS_density_norm, + starform->polytropic_index); /* Calculate the KS high density normalization */ - starform->KS_high_den_normalization = starform->KS_normalization * pow( M_per_pc2, - starform->KS_high_den_power_law - starform->KS_power_law) * pow( hydro_gamma * - starform->fgas / G_newton * EOS_high_den_pressure, (starform->KS_power_law - - starform->KS_high_den_power_law)/2.f); + starform->KS_high_den_normalization = + starform->KS_normalization * + pow(M_per_pc2, starform->KS_high_den_power_law - starform->KS_power_law) * + pow(hydro_gamma * starform->fgas / G_newton * EOS_high_den_pressure, + (starform->KS_power_law - starform->KS_high_den_power_law) / 2.f); /* Calculate the SF high density normalization */ - starform->SF_high_den_normalization = starform->KS_high_den_normalization - * pow(M_per_pc2, -starform->KS_high_den_power_law) * pow( hydro_gamma - * starform->fgas / G_newton, starform->SF_high_den_power_law); + starform->SF_high_den_normalization = + starform->KS_high_den_normalization * + pow(M_per_pc2, -starform->KS_high_den_power_law) * + pow(hydro_gamma * starform->fgas / G_newton, + starform->SF_high_den_power_law); /* Use the Schaye (2004) metallicity dependent critical density * to form stars. */ - /* Read the normalization of the metallicity dependent critical + /* Read the normalization of the metallicity dependent critical * density*/ - starform->den_crit = parser_get_param_double( - parameter_file, "SchayeSF:thresh_norm_HpCM3") * - conversion_numb_density; + starform->den_crit = + parser_get_param_double(parameter_file, "SchayeSF:thresh_norm_HpCM3") * + conversion_numb_density; /* Read the scale metallicity Z0 */ - starform->Z0 = parser_get_param_double( - parameter_file, "SchayeSF:MetDep_Z0"); + starform->Z0 = parser_get_param_double(parameter_file, "SchayeSF:MetDep_Z0"); /* Read the power law of the critical density scaling */ - starform->n_Z0 = parser_get_param_double( - parameter_file, "SchayeSF:MetDep_SFthresh_Slope"); + starform->n_Z0 = + parser_get_param_double(parameter_file, "SchayeSF:MetDep_SFthresh_Slope"); /* Read the maximum allowed density for star formation */ - starform->den_crit_max = parser_get_param_double( - parameter_file, "SchayeSF:thresh_max_norm_HpCM3"); + starform->den_crit_max = + parser_get_param_double(parameter_file, "SchayeSF:thresh_max_norm_HpCM3"); /* Claculate 1 over the metallicity */ - starform->Z0_inv = 1/starform->Z0; + starform->Z0_inv = 1 / starform->Z0; /* Calculate the prefactor that is always common */ /* !!!DONT FORGET TO DO THE CORRECT UNIT CONVERSION!!!*/ - starform->den_crit_star = starform->den_crit / pow(starform->Z0, - starform->n_Z0) * conversion_numb_density; - - + starform->den_crit_star = starform->den_crit / + pow(starform->Z0, starform->n_Z0) * + conversion_numb_density; } -/* @brief Prints the used parameters of the star formation law +/* @brief Prints the used parameters of the star formation law * * @param starform the star formation law properties. * */ INLINE static void starformation_print_backend( - const struct star_formation* starform){ - - message("Star formation law is Schaye and Dalla Vecchia (2008)" - " with properties, normalization = %e, slope of the Kennicutt" - "-Schmidt law = %e, gas fraction = %e, critical " - "density = %e and critical temperature = %e", starform->KS_normalization, - starform->KS_power_law, starform->fgas, starform->den_crit, - starform->T_crit); - message("Density threshold to form stars is given by Schaye " - "(2004), the normalization of the star formation law is given by" - " %e, with metallicity slope of %e, and metallicity normalization" - "of %e", starform->den_crit_star, starform->n_Z0, starform->Z0); - + const struct star_formation* starform) { + + message( + "Star formation law is Schaye and Dalla Vecchia (2008)" + " with properties, normalization = %e, slope of the Kennicutt" + "-Schmidt law = %e, gas fraction = %e, critical " + "density = %e and critical temperature = %e", + starform->KS_normalization, starform->KS_power_law, starform->fgas, + starform->den_crit, starform->T_crit); + message( + "Density threshold to form stars is given by Schaye " + "(2004), the normalization of the star formation law is given by" + " %e, with metallicity slope of %e, and metallicity normalization" + "of %e", + starform->den_crit_star, starform->n_Z0, starform->Z0); } - #endif /* SWIFT_SCHAYE_STARFORMATION_H */ diff --git a/src/stars.h b/src/stars.h index f1cd965c95c708bcdbb5068e32abd339a670034d..fc7ee74d3a2cae91ee209c4008eee4d5dd0f375e 100644 --- a/src/stars.h +++ b/src/stars.h @@ -30,10 +30,10 @@ #include "./stars/EAGLE/stars.h" #include "./stars/EAGLE/stars_iact.h" #elif defined(STARS_GEAR) -#include "./stars/GEAR/stars.h" +#include "./stars/GEAR/stars.h" #include "./stars/GEAR/stars_iact.h" -#else -#error "Invalid choice of star model" +#else +#error "Invalid choice of star model" #endif #endif diff --git a/src/stars/EAGLE/stars_part.h b/src/stars/EAGLE/stars_part.h index e7c92850f3f1457c073c405cfac3865c893b213e..03b5d89866777eb668b3ff1411d538072703c956 100644 --- a/src/stars/EAGLE/stars_part.h +++ b/src/stars/EAGLE/stars_part.h @@ -24,7 +24,7 @@ #include <stdlib.h> /* Read chemistry */ -#include "chemistry_struct.h" +#include "chemistry_struct.h" #include "tracers_struct.h" /** @@ -57,7 +57,7 @@ struct spart { /*! Initial star mass */ float mass_init; - + /*! Union for the birth time and birht scale factor */ union { /*! Birth time */ @@ -71,10 +71,10 @@ struct spart { float birth_density; /*! New star flag */ - int new_star_flag; + int new_star_flag; /*! Tracer structure */ - struct tracers_xpart_data tracers_data; + struct tracers_xpart_data tracers_data; /* Particle cutoff radius. */ float h; diff --git a/src/stars_io.h b/src/stars_io.h index 3f6610522fc6a20582e0b34dc824833c73d4b59e..c2a095c47c8d491fe6cf97d22c367d1e9d4a7fd6 100644 --- a/src/stars_io.h +++ b/src/stars_io.h @@ -19,8 +19,8 @@ #ifndef SWIFT_STARS_IO_H #define SWIFT_STARS_IO_H -#include "./const.h" #include "../config.h" +#include "./const.h" /* Load the correct star type */ #if defined(STARS_NONE) @@ -29,7 +29,7 @@ #include "./stars/EAGLE/stars_io.h" #elif defined(STARS_GEAR) #include "./stars/GEAR/stars_io.h" -#else +#else #error "Invalid choice of star model" #endif diff --git a/src/swift.h b/src/swift.h index 3a362fe9cea7c78e52307c405607c65b75654374..e819ee97ef490ef898d8a7ae3e11c322f2e4c4f8 100644 --- a/src/swift.h +++ b/src/swift.h @@ -66,6 +66,7 @@ #include "serial_io.h" #include "single_io.h" #include "space.h" +#include "starformation.h" #include "stars.h" #include "stars_io.h" #include "task.h" @@ -76,6 +77,5 @@ #include "units.h" #include "velociraptor_interface.h" #include "version.h" -#include "starformation.h" #endif /* SWIFT_SWIFT_H */