diff --git a/src/feedback/EAGLE/feedback.c b/src/feedback/EAGLE/feedback.c index c280d6cd829d819bede91bf17df0b8861ad9fbbc..e576eab17357ca5834a05cb14b89e98236a809df 100644 --- a/src/feedback/EAGLE/feedback.c +++ b/src/feedback/EAGLE/feedback.c @@ -717,6 +717,14 @@ void compute_stellar_evolution(const struct feedback_props* feedback_props, /* Properties collected in the stellar density loop. */ const float ngb_gas_mass = sp->feedback_data.to_collect.ngb_mass; + + /* Check if there are neighbours, otherwise exit */ + if (ngb_gas_mass == 0.f) { + feedback_reset_feedback(sp, feedback_props); + return; + } + + /* Update the enrichment weights */ const float enrichment_weight_inv = sp->feedback_data.to_collect.enrichment_weight_inv; @@ -727,8 +735,7 @@ void compute_stellar_evolution(const struct feedback_props* feedback_props, feedback_reset_feedback(sp, feedback_props); /* Update the weights used for distribution */ - const float enrichment_weight = - (enrichment_weight_inv != 0.f) ? 1.f / enrichment_weight_inv : 0.f; + const float enrichment_weight = 1.f / enrichment_weight_inv; sp->feedback_data.to_distribute.enrichment_weight = enrichment_weight; /* Compute properties of the stochastic SNII feedback model. */ diff --git a/src/feedback/EAGLE/feedback_iact.h b/src/feedback/EAGLE/feedback_iact.h index 2576e0f05947d0c33230b3140885b0a4fbcaa58e..c9e84a0b8be52f48c264baf146447f9036fec799 100644 --- a/src/feedback/EAGLE/feedback_iact.h +++ b/src/feedback/EAGLE/feedback_iact.h @@ -249,7 +249,11 @@ runner_iact_nonsym_feedback_apply(const float r2, const float *dx, const double injected_energy = si->feedback_data.to_distribute.energy * Omega_frac; - /* Apply energy conservation to recover the new thermal energy of the gas */ + /* Apply energy conservation to recover the new thermal energy of the gas + * Note: in some specific cases the new_thermal_energy could be lower + * than the current_thermal_energy, this is mainly the case if the change + * in mass is relatively small and the velocity vectors between both the + * gas particle and the star particle have a small angle. */ const double new_thermal_energy = current_kinetic_energy_gas + current_thermal_energy + injected_energy - new_kinetic_energy_gas; @@ -257,11 +261,6 @@ runner_iact_nonsym_feedback_apply(const float r2, const float *dx, /* Convert this to a specific thermal energy */ const double u_new_enrich = new_thermal_energy * new_mass_inv; -#ifdef SWIFT_DEBUG_CHECKS - if (new_thermal_energy < 0.99 * current_thermal_energy) - error("Enrichment is cooling the gas"); -#endif - /* Do the energy injection. */ hydro_set_physical_internal_energy(pj, xpj, cosmo, u_new_enrich); hydro_set_drifted_physical_internal_energy(pj, cosmo, u_new_enrich);