Commit 453b1ef9 authored by Matthieu Schaller's avatar Matthieu Schaller

In the EAGLE model, store the amount of energy received by AGN feedback events...

In the EAGLE model, store the amount of energy received by AGN feedback events into the particles' tracers
parent 698fda58
......@@ -372,7 +372,7 @@ runner_iact_nonsym_bh_gas_feedback(const float r2, const float *dx,
/* Are we lucky? */
if (rand < prob) {
/* Compute new energy of this particle */
/* Compute new energy per unit mass of this particle */
const double u_init = hydro_get_physical_internal_energy(pj, xpj, cosmo);
const float delta_u = bi->to_distribute.AGN_delta_u;
const double u_new = u_init + delta_u;
......@@ -383,8 +383,10 @@ runner_iact_nonsym_bh_gas_feedback(const float r2, const float *dx,
/* Impose maximal viscosity */
hydro_diffusive_feedback_reset(pj);
/* Mark this particle has having been heated by AGN feedback */
tracers_after_black_holes_feedback(xpj, with_cosmology, cosmo->a, time);
/* Store the feedback energy */
const double delta_energy = delta_u * hydro_get_mass(pj);
tracers_after_black_holes_feedback(xpj, with_cosmology, cosmo->a, time,
delta_energy);
/* message( */
/* "We did some AGN heating! id %llu BH id %llu probability " */
......
......@@ -134,6 +134,7 @@ static INLINE void tracers_first_init_xpart(
xp->tracers_data.maximum_temperature_time = -1.f;
xp->tracers_data.hit_by_SNII_feedback = 0;
xp->tracers_data.hit_by_AGN_feedback = 0;
xp->tracers_data.AGN_feedback_energy = 0.f;
}
/**
......@@ -152,25 +153,31 @@ static INLINE void tracers_after_feedback(struct xpart *xp) {
* event.
*
* @param xp The extended particle data.
* @param with_cosmology Are we running with cosmology?
* @param scale_factor The current scale-factor (if running with cosmo)
* @param time The current time (if running without cosmo)
* @param Amount of energy injected in the feedback event (internal physical
* units)
*/
static INLINE void tracers_after_black_holes_feedback(struct xpart *xp,
const int with_cosmology,
const float scale_factor,
const double time) {
static INLINE void tracers_after_black_holes_feedback(
struct xpart *xp, const int with_cosmology, const float scale_factor,
const double time, const double delta_energy) {
xp->tracers_data.hit_by_AGN_feedback = 1;
xp->tracers_data.AGN_feedback_energy += delta_energy;
}
/**
* @brief Split the tracer content of a particle into n pieces
*
* Nothing to do here.
*
* @param p The #part.
* @param xp The #xpart.
* @param n The number of pieces to split into.
*/
__attribute__((always_inline)) INLINE static void tracers_split_part(
struct part *p, struct xpart *xp, const double n) {}
struct part *p, struct xpart *xp, const double n) {
xp->tracers_data.AGN_feedback_energy /= n;
}
#endif /* SWIFT_TRACERS_EAGLE_H */
......@@ -85,7 +85,13 @@ __attribute__((always_inline)) INLINE static int tracers_write_particles(
"Flags the particles that have been directly hit by "
"an AGN feedback event at some point in the past.");
return 4;
list[4] = io_make_output_field("EnergiesReceivedFromAGNFeedback", FLOAT, 1,
UNIT_CONV_ENERGY, 0.f, xparts,
tracers_data.AGN_feedback_energy,
"Total amount of thermal energy from AGN "
"feedback events received by the particles.");
return 5;
}
__attribute__((always_inline)) INLINE static int tracers_write_sparticles(
......@@ -126,6 +132,12 @@ __attribute__((always_inline)) INLINE static int tracers_write_sparticles(
"an AGN feedback event at some point in the past "
"when the particle was still a gas particle.");
list[4] = io_make_output_field(
"EnergiesReceivedFromAGNFeedback", FLOAT, 1, UNIT_CONV_ENERGY, 0.f,
sparts, tracers_data.AGN_feedback_energy,
"Total amount of thermal energy from AGN feedback events received by the "
"particles when the particle was still a gas particle.");
return 4;
}
......
......@@ -37,6 +37,10 @@ struct tracers_xpart_data {
float maximum_temperature_time;
};
/*! Total amount of AGN feedback energy received by this particle
* (physical units) */
float AGN_feedback_energy;
/*! Has this particle been hit by SNII feedback? */
char hit_by_SNII_feedback;
......
......@@ -124,8 +124,15 @@ static INLINE void tracers_after_feedback(struct xpart *xp) {}
* Nothing to do here.
*
* @param xp The extended particle data.
* @param with_cosmology Are we running with cosmology?
* @param scale_factor The current scale-factor (if running with cosmo)
* @param time The current time (if running without cosmo)
* @param Amount of energy injected in the feedback event (internal physical
* units)
*/
static INLINE void tracers_after_black_holes_feedback(struct xpart *xp) {}
static INLINE void tracers_after_black_holes_feedback(
struct xpart *xp, const int with_cosmology, const float scale_factor,
const double time, const double delta_energy) {}
/**
* @brief Split the tracer content of a particle into n pieces
......
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