From 10c22805b55f78415f324907ee1f8ef64484f8e5 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Tue, 3 Jul 2018 18:19:51 +0200
Subject: [PATCH] Some general documentation and physical constants updates
 coming from the eagle-cooling-matthieu branch.

---
 doc/Doxyfile.in                    |  5 +++--
 src/align.h                        |  1 +
 src/chemistry/EAGLE/chemistry.h    |  7 +++++--
 src/chemistry/EAGLE/chemistry_io.h |  5 +++--
 src/cooling/EAGLE/cooling.h        |  5 ++++-
 src/cooling/EAGLE/cooling_io.h     |  2 +-
 src/cosmology.c                    |  2 +-
 src/physical_constants.c           | 10 ++++++++++
 src/physical_constants.h           |  6 ++++++
 src/physical_constants_cgs.h       |  9 +++++++++
 10 files changed, 43 insertions(+), 9 deletions(-)

diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in
index 5245c738e3..2b177a8a0d 100644
--- a/doc/Doxyfile.in
+++ b/doc/Doxyfile.in
@@ -766,8 +766,8 @@ INPUT		       += @top_srcdir@/src/stars/Default
 INPUT		       += @top_srcdir@/src/riemann
 INPUT		       += @top_srcdir@/src/potential/point_mass
 INPUT		       += @top_srcdir@/src/equation_of_state/ideal_gas
-INPUT		       += @top_srcdir@/src/cooling/none
-INPUT		       += @top_srcdir@/src/chemistry/none
+INPUT		       += @top_srcdir@/src/cooling/EAGLE
+INPUT		       += @top_srcdir@/src/chemistry/EAGLE
 
 # This tag can be used to specify the character encoding of the source files
 # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@@ -1993,6 +1993,7 @@ PREDEFINED             = "__attribute__(x)= "
 PREDEFINED             += HAVE_HDF5
 PREDEFINED             += WITH_MPI
 PREDEFINED             += WITH_VECTORIZATION
+PREDEFINED             += __GNUC__
 
 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
 # tag can be used to specify a list of macro names that should be expanded. The
diff --git a/src/align.h b/src/align.h
index 243557ee0b..6d329ae798 100644
--- a/src/align.h
+++ b/src/align.h
@@ -45,6 +45,7 @@
  *
  * Note that this turns into a no-op but gives information to the compiler.
  *
+ * @param type The type of the array.
  * @param array The array.
  * @param alignment The alignment in bytes of the array.
  */
diff --git a/src/chemistry/EAGLE/chemistry.h b/src/chemistry/EAGLE/chemistry.h
index 96a645806a..7f8a672669 100644
--- a/src/chemistry/EAGLE/chemistry.h
+++ b/src/chemistry/EAGLE/chemistry.h
@@ -98,9 +98,12 @@ chemistry_part_has_no_neighbours(struct part* restrict p,
  * @brief Sets the chemistry properties of the (x-)particles to a valid start
  * state.
  *
+ * @param phys_const The physical constants in internal units.
+ * @param us The internal system of units.
+ * @param cosmo The current cosmological model.
+ * @param data The global chemistry information.
  * @param p Pointer to the particle data.
  * @param xp Pointer to the extended particle data.
- * @param data The global chemistry information.
  */
 __attribute__((always_inline)) INLINE static void chemistry_first_init_part(
     const struct phys_const* restrict phys_const,
@@ -137,7 +140,7 @@ static INLINE void chemistry_init_backend(struct swift_params* parameter_file,
   for (int elem = 0; elem < chemistry_element_count; ++elem) {
     char buffer[50];
     sprintf(buffer, "EAGLEChemistry:InitAbundance_%s",
-            chemistry_get_element_name(elem));
+            chemistry_get_element_name((enum chemistry_element)elem));
 
     data->initial_metal_mass_fraction[elem] =
         parser_get_param_float(parameter_file, buffer);
diff --git a/src/chemistry/EAGLE/chemistry_io.h b/src/chemistry/EAGLE/chemistry_io.h
index f87807579c..a717318c1e 100644
--- a/src/chemistry/EAGLE/chemistry_io.h
+++ b/src/chemistry/EAGLE/chemistry_io.h
@@ -101,7 +101,7 @@ INLINE static int chemistry_write_particles(const struct part* parts,
 
 /**
  * @brief Writes the current model of SPH to the file
- * @param h_grpsph The HDF5 group in which to write
+ * @param h_grp The HDF5 group in which to write
  */
 INLINE static void chemistry_write_flavour(hid_t h_grp) {
 
@@ -109,7 +109,8 @@ INLINE static void chemistry_write_flavour(hid_t h_grp) {
   for (int elem = 0; elem < chemistry_element_count; ++elem) {
     char buffer[20];
     sprintf(buffer, "Element %d", elem);
-    io_write_attribute_s(h_grp, buffer, chemistry_get_element_name(elem));
+    io_write_attribute_s(h_grp, buffer, chemistry_get_element_name(
+                                            (enum chemistry_element)elem));
   }
 }
 #endif
diff --git a/src/cooling/EAGLE/cooling.h b/src/cooling/EAGLE/cooling.h
index f059d995c6..1c56572856 100644
--- a/src/cooling/EAGLE/cooling.h
+++ b/src/cooling/EAGLE/cooling.h
@@ -79,9 +79,12 @@ __attribute__((always_inline)) INLINE static float cooling_timestep(
  * @brief Sets the cooling properties of the (x-)particles to a valid start
  * state.
  *
+ * @param phys_const The physical constants in internal units.
+ * @param us The internal system of units.
+ * @param cosmo The current cosmological model.
+ * @param cooling The properties of the cooling function.
  * @param p Pointer to the particle data.
  * @param xp Pointer to the extended particle data.
- * @param cooling The properties of the cooling function.
  */
 __attribute__((always_inline)) INLINE static void cooling_first_init_part(
     const struct phys_const* restrict phys_const,
diff --git a/src/cooling/EAGLE/cooling_io.h b/src/cooling/EAGLE/cooling_io.h
index d6ed4f1228..f98539605d 100644
--- a/src/cooling/EAGLE/cooling_io.h
+++ b/src/cooling/EAGLE/cooling_io.h
@@ -41,7 +41,7 @@ __attribute__((always_inline)) INLINE static void cooling_write_flavour(
 /**
  * @brief Specifies which particle fields to write to a dataset
  *
- * @param parts The particle array.
+ * @param xparts The extended data particle array.
  * @param list The list of i/o properties to write.
  * @param cooling The #cooling_function_data
  *
diff --git a/src/cosmology.c b/src/cosmology.c
index dc612a0864..e0ea1e9cd3 100644
--- a/src/cosmology.c
+++ b/src/cosmology.c
@@ -614,7 +614,7 @@ double cosmology_get_therm_kick_factor(const struct cosmology *c,
  * @brief Compute the cosmic time (in internal units) between two points
  * on the integer time line.
  *
- * @brief c The current #cosmology.
+ * @param c The current #cosmology.
  * @param ti_start the (integer) time of the start.
  * @param ti_end the (integer) time of the end.
  */
diff --git a/src/physical_constants.c b/src/physical_constants.c
index 2c0ea6191b..097146a7a2 100644
--- a/src/physical_constants.c
+++ b/src/physical_constants.c
@@ -78,6 +78,11 @@ void phys_const_init(const struct unit_system *us, struct swift_params *params,
       const_thomson_cross_section_cgs /
       units_general_cgs_conversion_factor(us, dimension_thomson);
 
+  const float dimension_stefan[5] = {1, 0, -3, 0, -4};
+  internal_const->const_stefan_boltzmann =
+      const_stefan_boltzmann_cgs /
+      units_general_cgs_conversion_factor(us, dimension_stefan);
+
   const float dimension_ev[5] = {1, 2, -2, 0, 0};
   internal_const->const_electron_volt =
       const_electron_volt_cgs /
@@ -116,6 +121,11 @@ void phys_const_init(const struct unit_system *us, struct swift_params *params,
   internal_const->const_light_year =
       const_light_year_cgs /
       units_general_cgs_conversion_factor(us, dimension_length);
+
+  const float dimension_temperature[5] = {0, 0, 0, 0, 1};
+  internal_const->const_T_CMB_0 =
+      const_T_CMB_0_cgs /
+      units_general_cgs_conversion_factor(us, dimension_temperature);
 }
 
 /**
diff --git a/src/physical_constants.h b/src/physical_constants.h
index 606e7eeb58..16628bfd68 100644
--- a/src/physical_constants.h
+++ b/src/physical_constants.h
@@ -58,6 +58,9 @@ struct phys_const {
   /*! Thomson cross-section */
   double const_thomson_cross_section;
 
+  /*! Stefan-Boltzmann constant */
+  double const_stefan_boltzmann;
+
   /*! Charge of the electron  */
   double const_electron_charge;
 
@@ -87,6 +90,9 @@ struct phys_const {
 
   /*! Mass of the Earth */
   double const_earth_mass;
+
+  /*! Temperature of the CMB at present day */
+  double const_T_CMB_0;
 };
 
 void phys_const_init(const struct unit_system* us, struct swift_params* params,
diff --git a/src/physical_constants_cgs.h b/src/physical_constants_cgs.h
index 1d44dae491..f555d5df43 100644
--- a/src/physical_constants_cgs.h
+++ b/src/physical_constants_cgs.h
@@ -29,6 +29,9 @@
  * where all the constants are defined in the system of units specified
  * in the parameter file.
  *
+ * Of special interest if the value of G which is 0.03% different from the
+ * default value adopted by Gadget-2 (G = 6.672e-8).
+ *
  * All values are taken from C. Patrignani et al. (Particle Data Group), Chin.
  * Phys. C, 40, 100001 (2016) and 2017 update.
  * http://pdg.lbl.gov/2017/reviews/rpp2017-rev-phys-constants.pdf
@@ -56,6 +59,9 @@ const double const_avogadro_number_cgs = 6.022140857e23;
 /*! Thomson cross-section [cm^2] */
 const double const_thomson_cross_section_cgs = 6.6524587158e-25;
 
+/*! Stefan-Boltzmann constant [g s^-3 K^-4] */
+const double const_stefan_boltzmann_cgs = 5.670367e-5;
+
 /*! Elementary charge [A s^-1] */
 const double const_electron_charge_cgs = 1.6021766208e-19;
 
@@ -86,4 +92,7 @@ const double const_solar_mass_cgs = 1.98848e33;
 /*! Mass of the Earth [g] */
 const double const_earth_mass_cgs = 5.9724e27;
 
+/*! Temperature of the CMB at present day [K] */
+const double const_T_CMB_0_cgs = 2.72556;
+
 #endif /* SWIFT_PHYSICAL_CONSTANTS_CGS_H */
-- 
GitLab