From 21f5b0c8e0957b7af311bcaa6f10cfbce9f60ade Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <schaller@strw.leidenuniv.nl>
Date: Sat, 12 Jan 2019 21:23:46 +0100
Subject: [PATCH] Small clarification about the Helium fraction in the EAGLE
 cooling code.

---
 src/cooling/EAGLE/cooling.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/cooling/EAGLE/cooling.c b/src/cooling/EAGLE/cooling.c
index a08a427440..3ca3eb5218 100644
--- a/src/cooling/EAGLE/cooling.c
+++ b/src/cooling/EAGLE/cooling.c
@@ -499,14 +499,13 @@ void cooling_cool_part(const struct phys_const *restrict phys_const,
   float abundance_ratio[chemistry_element_count + 2];
   abundance_ratio_to_solar(p, cooling, abundance_ratio);
 
-  /* Get the Hydrogen mass fraction */
+  /* Get the Hydrogen and Helium mass fractions */
   const float XH = p->chemistry_data.metal_mass_fraction[chemistry_element_H];
+  const float XHe = p->chemistry_data.metal_mass_fraction[chemistry_element_He];
 
   /* Get the Helium mass fraction. Note that this is He / (H + He), i.e. a
    * metal-free Helium mass fraction as per the Wiersma+08 definition */
-  const float HeFrac =
-      p->chemistry_data.metal_mass_fraction[chemistry_element_He] /
-      (XH + p->chemistry_data.metal_mass_fraction[chemistry_element_He]);
+  const float HeFrac = XHe / (XH + XHe);
 
   /* convert Hydrogen mass fraction into Hydrogen number density */
   const double n_H =
@@ -707,14 +706,13 @@ float cooling_get_temperature(
   const float u = hydro_get_physical_internal_energy(p, xp, cosmo);
   const double u_cgs = u * cooling->internal_energy_to_cgs;
 
-  /* Get the Hydrogen mass fraction */
+  /* Get the Hydrogen and Helium mass fractions */
   const float XH = p->chemistry_data.metal_mass_fraction[chemistry_element_H];
+  const float XHe = p->chemistry_data.metal_mass_fraction[chemistry_element_He];
 
   /* Get the Helium mass fraction. Note that this is He / (H + He), i.e. a
    * metal-free Helium mass fraction as per the Wiersma+08 definition */
-  const float HeFrac =
-      p->chemistry_data.metal_mass_fraction[chemistry_element_He] /
-      (XH + p->chemistry_data.metal_mass_fraction[chemistry_element_He]);
+  const float HeFrac = XHe / (XH + XHe);
 
   /* Convert Hydrogen mass fraction into Hydrogen number density */
   const float rho = hydro_get_physical_density(p, cosmo);
-- 
GitLab