diff --git a/src/black_holes/EAGLE/black_holes_iact.h b/src/black_holes/EAGLE/black_holes_iact.h index e345330b4f4e55331b0cfe6c90f6f1555979f530..b0626bb6469bd626f9c4570bc113bc9af94a92eb 100644 --- a/src/black_holes/EAGLE/black_holes_iact.h +++ b/src/black_holes/EAGLE/black_holes_iact.h @@ -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 " */ diff --git a/src/tracers/EAGLE/tracers.h b/src/tracers/EAGLE/tracers.h index 3154a615d2f0e8b916d4e62932ba8b5fd69a49fd..33e8883c0d2952ea9f5b9c692e9b947bbf548a68 100644 --- a/src/tracers/EAGLE/tracers.h +++ b/src/tracers/EAGLE/tracers.h @@ -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 */ diff --git a/src/tracers/EAGLE/tracers_io.h b/src/tracers/EAGLE/tracers_io.h index 4ebd7d91f3d2d33de688a97927fe32044860e2e2..3c540132e95d0efd950d63e8e968ef34a15266f7 100644 --- a/src/tracers/EAGLE/tracers_io.h +++ b/src/tracers/EAGLE/tracers_io.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; } diff --git a/src/tracers/EAGLE/tracers_struct.h b/src/tracers/EAGLE/tracers_struct.h index 9d1e233130b9149f66263d6ce8e577ccbf69c845..7e5daf79a2d6e420c5e3e2a743ac71e6bed271a4 100644 --- a/src/tracers/EAGLE/tracers_struct.h +++ b/src/tracers/EAGLE/tracers_struct.h @@ -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; diff --git a/src/tracers/none/tracers.h b/src/tracers/none/tracers.h index 99bf395b92dbc5185c2aee1e26f41c38971797c7..fd5dea83873df7e4116858db098e75a7768bf081 100644 --- a/src/tracers/none/tracers.h +++ b/src/tracers/none/tracers.h @@ -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