Commit 4993881b authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Also update the EAGLE stars model with the new compulsory particle fields and function signatures.

parent 4c0689a3
......@@ -209,7 +209,8 @@ void runner_do_stars_ghost(struct runner *r, struct cell *c, int timer) {
/* Skip if h is already h_max and we don't have enough neighbours */
if ((sp->h >= stars_h_max) && (f < 0.f)) {
stars_reset_acceleration(sp);
stars_reset_feedback(sp);
/* Ok, we are done with this particle */
continue;
}
......@@ -260,7 +261,7 @@ void runner_do_stars_ghost(struct runner *r, struct cell *c, int timer) {
}
/* We now have a particle whose smoothing length has converged */
stars_reset_acceleration(sp);
stars_reset_feedback(sp);
/* Compute the stellar evolution */
stars_evolve_spart(sp, stars_properties, cosmo);
......
......@@ -100,6 +100,7 @@ __attribute__((always_inline)) INLINE static void stars_reset_predicted_values(
*/
__attribute__((always_inline)) INLINE static void stars_end_feedback(
struct spart* sp) {
sp->feedback.h_dt *= sp->h * hydro_dimension_inv;
}
......@@ -174,7 +175,7 @@ __attribute__((always_inline)) INLINE static void stars_evolve_spart(
*
* @param p The particle to act upon
*/
__attribute__((always_inline)) INLINE static void stars_reset_acceleration(
__attribute__((always_inline)) INLINE static void stars_reset_feedback(
struct spart* restrict p) {
/* Reset time derivative */
......@@ -186,4 +187,5 @@ __attribute__((always_inline)) INLINE static void stars_reset_acceleration(
p->num_ngb_force = 0;
#endif
}
#endif /* SWIFT_DEFAULT_STARS_H */
......@@ -61,6 +61,7 @@ struct spart {
timebin_t time_bin;
struct {
/* Number of neighbours. */
float wcount;
......@@ -69,18 +70,19 @@ struct spart {
} density;
/*! Tracer structure */
struct tracers_xpart_data tracers_data;
/*! Chemistry structure */
struct chemistry_part_data chemistry_data;
struct {
/* Change in smoothing length over time. */
float h_dt;
} feedback;
/*! Tracer structure */
struct tracers_xpart_data tracers_data;
/*! Chemistry structure */
struct chemistry_part_data chemistry_data;
#ifdef SWIFT_DEBUG_CHECKS
/* Time of the last drift */
......
......@@ -66,6 +66,25 @@ __attribute__((always_inline)) INLINE static void stars_init_spart(
sp->density.wcount_dh = 0.f;
}
/**
* @brief Predict additional particle fields forward in time when drifting
*
* @param p The particle
* @param dt_drift The drift time-step for positions.
*/
__attribute__((always_inline)) INLINE static void stars_predict_extra(
struct spart* restrict sp, float dt_drift) {
const float h_inv = 1.f / sp->h;
/* Predict smoothing length */
const float w1 = sp->feedback.h_dt * h_inv * dt_drift;
if (fabsf(w1) < 0.2f)
sp->h *= approx_expf(w1); /* 4th order expansion of exp(w) */
else
sp->h *= expf(w1);
}
/**
* @brief Sets the values to be predicted in the drifts to their values at a
* kick time
......@@ -82,8 +101,11 @@ __attribute__((always_inline)) INLINE static void stars_reset_predicted_values(
*
* @param sp The particle to act upon
*/
__attribute__((always_inline)) INLINE static void stars_end_force(
struct spart* sp) {}
__attribute__((always_inline)) INLINE static void stars_end_feedback(
struct spart* sp) {
sp->feedback.h_dt *= sp->h * hydro_dimension_inv;
}
/**
* @brief Kick the additional variables
......@@ -148,4 +170,25 @@ __attribute__((always_inline)) INLINE static void stars_evolve_spart(
struct spart* restrict sp, const struct stars_props* stars_properties,
const struct cosmology* cosmo) {}
/**
* @brief Reset acceleration fields of a particle
*
* This is the equivalent of hydro_reset_acceleration.
* We do not compute the acceleration on star, therefore no need to use it.
*
* @param p The particle to act upon
*/
__attribute__((always_inline)) INLINE static void stars_reset_feedback(
struct spart* restrict p) {
/* Reset time derivative */
p->feedback.h_dt = 0.f;
#ifdef DEBUG_INTERACTIONS_STARS
for (int i = 0; i < MAX_NUM_OF_NEIGHBOURS_STARS; ++i)
p->ids_ngbs_force[i] = -1;
p->num_ngb_force = 0;
#endif
}
#endif /* SWIFT_EAGLE_STARS_H */
......@@ -65,6 +65,7 @@ struct spart {
timebin_t time_bin;
struct {
/* Number of neighbours. */
float wcount;
......@@ -73,8 +74,16 @@ struct spart {
} density;
struct {
/* Change in smoothing length over time. */
float h_dt;
} feedback;
/*! Union for the birth time and birht scale factor */
union {
/*! Birth time */
float birth_time;
......
Supports Markdown
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