Commit 55c84bb5 authored by lhausamm's avatar lhausamm

Update cooling and chemistry functions

parent 2fb0f958
...@@ -57,10 +57,10 @@ chemistry_get_element_name(enum chemistry_element elem) { ...@@ -57,10 +57,10 @@ chemistry_get_element_name(enum chemistry_element elem) {
* the various smooth metallicity tasks * the various smooth metallicity tasks
* *
* @param p The particle to act upon * @param p The particle to act upon
* @param cd #chemistry_data containing chemistry informations. * @param cd #chemistry_global_data containing chemistry informations.
*/ */
__attribute__((always_inline)) INLINE static void chemistry_init_part( __attribute__((always_inline)) INLINE static void chemistry_init_part(
struct part* restrict p, const struct chemistry_data* cd) {} struct part* restrict p, const struct chemistry_global_data* cd) {}
/** /**
* @brief Finishes the smooth metal calculation. * @brief Finishes the smooth metal calculation.
...@@ -71,11 +71,11 @@ __attribute__((always_inline)) INLINE static void chemistry_init_part( ...@@ -71,11 +71,11 @@ __attribute__((always_inline)) INLINE static void chemistry_init_part(
* This function requires the #hydro_end_density to have been called. * This function requires the #hydro_end_density to have been called.
* *
* @param p The particle to act upon. * @param p The particle to act upon.
* @param cd #chemistry_data containing chemistry informations. * @param cd #chemistry_global_data containing chemistry informations.
* @param cosmo The current cosmological model. * @param cosmo The current cosmological model.
*/ */
__attribute__((always_inline)) INLINE static void chemistry_end_density( __attribute__((always_inline)) INLINE static void chemistry_end_density(
struct part* restrict p, const struct chemistry_data* cd, struct part* restrict p, const struct chemistry_global_data* cd,
const struct cosmology* cosmo) {} const struct cosmology* cosmo) {}
/** /**
...@@ -87,8 +87,11 @@ __attribute__((always_inline)) INLINE static void chemistry_end_density( ...@@ -87,8 +87,11 @@ __attribute__((always_inline)) INLINE static void chemistry_end_density(
* @param data The global chemistry information. * @param data The global chemistry information.
*/ */
__attribute__((always_inline)) INLINE static void chemistry_first_init_part( __attribute__((always_inline)) INLINE static void chemistry_first_init_part(
struct part* restrict p, struct xpart* restrict xp, const struct phys_const* restrict phys_const,
const struct chemistry_data* data) { const struct unit_system* restrict us,
const struct cosmology* restrict cosmo,
const struct chemistry_global_data* data,
struct part* restrict p, struct xpart* restrict xp) {
p->chemistry_data.metal_mass_fraction_total = p->chemistry_data.metal_mass_fraction_total =
data->initial_metal_mass_fraction_total; data->initial_metal_mass_fraction_total;
...@@ -107,7 +110,7 @@ __attribute__((always_inline)) INLINE static void chemistry_first_init_part( ...@@ -107,7 +110,7 @@ __attribute__((always_inline)) INLINE static void chemistry_first_init_part(
*/ */
static INLINE void chemistry_init_backend( static INLINE void chemistry_init_backend(
const struct swift_params* parameter_file, const struct unit_system* us, const struct swift_params* parameter_file, const struct unit_system* us,
const struct phys_const* phys_const, struct chemistry_data* data) { const struct phys_const* phys_const, struct chemistry_global_data* data) {
/* Read the total metallicity */ /* Read the total metallicity */
data->initial_metal_mass_fraction_total = data->initial_metal_mass_fraction_total =
...@@ -133,9 +136,9 @@ static INLINE void chemistry_init_backend( ...@@ -133,9 +136,9 @@ static INLINE void chemistry_init_backend(
/** /**
* @brief Prints the properties of the chemistry model to stdout. * @brief Prints the properties of the chemistry model to stdout.
* *
* @brief The #chemistry_data containing information about the current model. * @brief The #chemistry_global_data containing information about the current model.
*/ */
static INLINE void chemistry_print_backend(const struct chemistry_data* data) { static INLINE void chemistry_print_backend(const struct chemistry_global_data* data) {
message("Chemistry model is 'EAGLE' tracking %d elements.", message("Chemistry model is 'EAGLE' tracking %d elements.",
chemistry_element_count); chemistry_element_count);
......
...@@ -38,7 +38,7 @@ enum chemistry_element { ...@@ -38,7 +38,7 @@ enum chemistry_element {
/** /**
* @brief Global chemical abundance information in the EAGLE model. * @brief Global chemical abundance information in the EAGLE model.
*/ */
struct chemistry_data { struct chemistry_global_data {
/*! Fraction of the particle mass in given elements at the start of the run */ /*! Fraction of the particle mass in given elements at the start of the run */
float initial_metal_mass_fraction[chemistry_element_count]; float initial_metal_mass_fraction[chemistry_element_count];
......
...@@ -61,14 +61,14 @@ chemistry_get_element_name(enum chemistry_element elem) { ...@@ -61,14 +61,14 @@ chemistry_get_element_name(enum chemistry_element elem) {
*/ */
static INLINE void chemistry_init_backend( static INLINE void chemistry_init_backend(
const struct swift_params* parameter_file, const struct unit_system* us, const struct swift_params* parameter_file, const struct unit_system* us,
const struct phys_const* phys_const, struct chemistry_data* data) {} const struct phys_const* phys_const, struct chemistry_global_data* data) {}
/** /**
* @brief Prints the properties of the chemistry model to stdout. * @brief Prints the properties of the chemistry model to stdout.
* *
* @brief The #chemistry_data containing information about the current model. * @brief The #chemistry_global_data containing information about the current model.
*/ */
static INLINE void chemistry_print_backend(const struct chemistry_data* data) { static INLINE void chemistry_print_backend(const struct chemistry_global_data* data) {
message("Chemistry function is 'No chemistry'."); message("Chemistry function is 'No chemistry'.");
} }
...@@ -81,7 +81,7 @@ static INLINE void chemistry_print_backend(const struct chemistry_data* data) { ...@@ -81,7 +81,7 @@ static INLINE void chemistry_print_backend(const struct chemistry_data* data) {
* @param cosmo The current cosmological model. * @param cosmo The current cosmological model.
*/ */
__attribute__((always_inline)) INLINE static void chemistry_end_density( __attribute__((always_inline)) INLINE static void chemistry_end_density(
struct part* restrict p, const struct chemistry_data* cd, struct part* restrict p, const struct chemistry_global_data* cd,
const struct cosmology* cosmo) {} const struct cosmology* cosmo) {}
/** /**
...@@ -95,8 +95,11 @@ __attribute__((always_inline)) INLINE static void chemistry_end_density( ...@@ -95,8 +95,11 @@ __attribute__((always_inline)) INLINE static void chemistry_end_density(
* @param data The global chemistry information used for this run. * @param data The global chemistry information used for this run.
*/ */
__attribute__((always_inline)) INLINE static void chemistry_first_init_part( __attribute__((always_inline)) INLINE static void chemistry_first_init_part(
const struct part* restrict p, struct xpart* restrict xp, const struct phys_const* restrict phys_const,
const struct chemistry_data* data) {} const struct unit_system* restrict us,
const struct cosmology* restrict cosmo,
const struct chemistry_global_data* data,
const struct part* restrict p, struct xpart* restrict xp) {}
/** /**
* @brief Sets the chemistry properties of the (x-)particles to a valid start * @brief Sets the chemistry properties of the (x-)particles to a valid start
...@@ -108,6 +111,6 @@ __attribute__((always_inline)) INLINE static void chemistry_first_init_part( ...@@ -108,6 +111,6 @@ __attribute__((always_inline)) INLINE static void chemistry_first_init_part(
* @param data The global chemistry information. * @param data The global chemistry information.
*/ */
__attribute__((always_inline)) INLINE static void chemistry_init_part( __attribute__((always_inline)) INLINE static void chemistry_init_part(
struct part* restrict p, const struct chemistry_data* data) {} struct part* restrict p, const struct chemistry_global_data* data) {}
#endif /* SWIFT_CHEMISTRY_NONE_H */ #endif /* SWIFT_CHEMISTRY_NONE_H */
...@@ -34,7 +34,7 @@ enum chemistry_element { chemistry_element_count = 0 }; ...@@ -34,7 +34,7 @@ enum chemistry_element { chemistry_element_count = 0 };
* *
* Nothing here. * Nothing here.
*/ */
struct chemistry_data {}; struct chemistry_global_data {};
/** /**
* @brief Chemistry properties carried by the #part. * @brief Chemistry properties carried by the #part.
......
...@@ -84,8 +84,11 @@ __attribute__((always_inline)) INLINE static float cooling_timestep( ...@@ -84,8 +84,11 @@ __attribute__((always_inline)) INLINE static float cooling_timestep(
* @param cooling The properties of the cooling function. * @param cooling The properties of the cooling function.
*/ */
__attribute__((always_inline)) INLINE static void cooling_first_init_part( __attribute__((always_inline)) INLINE static void cooling_first_init_part(
const struct part* restrict p, struct xpart* restrict xp, const struct phys_const* restrict phys_const,
const struct cooling_function_data* cooling) {} const struct unit_system* restrict us,
const struct cosmology* restrict cosmo,
const struct cooling_function_data* restrict cooling,
const struct part* restrict p, struct xpart* restrict xp) {}
/** /**
* @brief Returns the total radiated energy by this particle. * @brief Returns the total radiated energy by this particle.
......
...@@ -80,7 +80,7 @@ __attribute__((always_inline)) INLINE static void cooling_cool_part( ...@@ -80,7 +80,7 @@ __attribute__((always_inline)) INLINE static void cooling_cool_part(
float cooling_du_dt = -cooling->cooling_rate; float cooling_du_dt = -cooling->cooling_rate;
/* Integrate cooling equation to enforce energy floor */ /* Integrate cooling equation to enforce energy floor */
if (u_old + hydro_du_dt * dt < u_floor) { if (u_old + hydro_du_dt * dt < u_floor) {
cooling_du_dt = 0.f; cooling_du_dt = 0.f;
} else if (u_old + (hydro_du_dt + cooling_du_dt) * dt < u_floor) { } else if (u_old + (hydro_du_dt + cooling_du_dt) * dt < u_floor) {
cooling_du_dt = (u_old + dt * hydro_du_dt - u_floor) / dt; cooling_du_dt = (u_old + dt * hydro_du_dt - u_floor) / dt;
...@@ -130,8 +130,11 @@ __attribute__((always_inline)) INLINE static float cooling_timestep( ...@@ -130,8 +130,11 @@ __attribute__((always_inline)) INLINE static float cooling_timestep(
* @param cooling The properties of the cooling function. * @param cooling The properties of the cooling function.
*/ */
__attribute__((always_inline)) INLINE static void cooling_first_init_part( __attribute__((always_inline)) INLINE static void cooling_first_init_part(
const struct part* restrict p, struct xpart* restrict xp, const struct phys_const* restrict phys_const,
const struct cooling_function_data* cooling) { const struct unit_system* restrict us,
const struct cosmology* restrict cosmo,
const struct cooling_function_data* restrict cooling,
const struct part* restrict p, struct xpart* restrict xp) {
xp->cooling_data.radiated_energy = 0.f; xp->cooling_data.radiated_energy = 0.f;
} }
......
...@@ -143,8 +143,11 @@ __attribute__((always_inline)) INLINE static float cooling_timestep( ...@@ -143,8 +143,11 @@ __attribute__((always_inline)) INLINE static float cooling_timestep(
* @param cooling The properties of the cooling function. * @param cooling The properties of the cooling function.
*/ */
__attribute__((always_inline)) INLINE static void cooling_first_init_part( __attribute__((always_inline)) INLINE static void cooling_first_init_part(
const struct part* restrict p, struct xpart* restrict xp, const struct phys_const* restrict phys_const,
const struct cooling_function_data* cooling) { const struct unit_system* restrict us,
const struct cosmology* restrict cosmo,
const struct cooling_function_data* restrict cooling,
const struct part* restrict p, struct xpart* restrict xp) {
xp->cooling_data.radiated_energy = 0.f; xp->cooling_data.radiated_energy = 0.f;
} }
......
...@@ -90,8 +90,11 @@ __attribute__((always_inline)) INLINE static float cooling_timestep( ...@@ -90,8 +90,11 @@ __attribute__((always_inline)) INLINE static float cooling_timestep(
* @param cooling The properties of the cooling function. * @param cooling The properties of the cooling function.
*/ */
__attribute__((always_inline)) INLINE static void cooling_first_init_part( __attribute__((always_inline)) INLINE static void cooling_first_init_part(
const struct part* restrict p, struct xpart* restrict xp, const struct phys_const* restrict phys_const,
const struct cooling_function_data* cooling) {} const struct unit_system* restrict us,
const struct cosmology* restrict cosmo,
const struct cooling_function_data* data,
const struct part* restrict p, struct xpart* restrict xp) {}
/** /**
* @brief Returns the total radiated energy by this particle. * @brief Returns the total radiated energy by this particle.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment