Commit fad25194 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Added Quick Lyman-alpha cooling and chemistry model

parent 3896d2bc
......@@ -1443,7 +1443,7 @@ AC_SUBST([NUMA_INCS])
# As an example for this, see the call to AC_ARG_WITH for cooling.
AC_ARG_WITH([subgrid],
[AS_HELP_STRING([--with-subgrid=<subgrid>],
[Master switch for subgrid methods. Inexperienced user should start from here @<:@none, GEAR, EAGLE default: none@:>@]
[Master switch for subgrid methods. Inexperienced user should start here. Options are: @<:@none, GEAR, QLA, EAGLE default: none@:>@]
)],
[with_subgrid="$withval"],
[with_subgrid=none]
......@@ -1478,6 +1478,18 @@ case "$with_subgrid" in
with_subgrid_task_order=none
enable_fof=no
;;
QLA)
with_subgrid_cooling=QLA
with_subgrid_chemistry=QLA
with_subgrid_tracers=none
with_subgrid_entropy_floor=QLA
with_subgrid_stars=none
with_subgrid_star_formation=QLA
with_subgrid_feedback=none
with_subgrid_black_holes=none
with_subgrid_task_order=default
enable_fof=no
;;
EAGLE)
with_subgrid_cooling=EAGLE
with_subgrid_chemistry=EAGLE
......@@ -1810,6 +1822,9 @@ case "$with_cooling" in
primordial_chemistry=${with_cooling:8}
AC_DEFINE_UNQUOTED([COOLING_GRACKLE_MODE], [$primordial_chemistry], [Grackle chemistry network])
;;
QLA)
AC_DEFINE([COOLING_QLA], [1], [Cooling following the Quick-Lyman-alpha model])
;;
EAGLE)
AC_DEFINE([COOLING_EAGLE], [1], [Cooling following the EAGLE model])
;;
......@@ -1845,6 +1860,9 @@ case "$with_chemistry" in
number_element=${with_chemistry:5}
AC_DEFINE_UNQUOTED([GEAR_CHEMISTRY_ELEMENT_COUNT], [$number_element], [Number of element to follow])
;;
QLA)
AC_DEFINE([CHEMISTRY_QLA], [1], [Chemistry taken from the Quick-Lyman-alpha model])
;;
EAGLE)
AC_DEFINE([CHEMISTRY_EAGLE], [1], [Chemistry taken from the EAGLE model])
;;
......@@ -2083,6 +2101,9 @@ case "$with_entropy_floor" in
none)
AC_DEFINE([ENTROPY_FLOOR_NONE], [1], [No entropy floor])
;;
QLA)
AC_DEFINE([ENTROPY_FLOOR_QLA], [1], [Quick Lyman-alpha entropy floor])
;;
EAGLE)
AC_DEFINE([ENTROPY_FLOOR_EAGLE], [1], [EAGLE entropy floor])
;;
......@@ -2140,6 +2161,9 @@ case "$with_star_formation" in
none)
AC_DEFINE([STAR_FORMATION_NONE], [1], [No star formation])
;;
QLA)
AC_DEFINE([STAR_FORMATION_QLA], [1], [Quick Lyman-alpha star formation model)])
;;
EAGLE)
AC_DEFINE([STAR_FORMATION_EAGLE], [1], [EAGLE star formation model (Schaye and Dalla Vecchia (2008))])
;;
......@@ -2180,6 +2204,9 @@ AC_SUBST([GIT_CMD])
DX_INIT_DOXYGEN(libswift,doc/Doxyfile,doc/)
AM_CONDITIONAL([HAVE_DOXYGEN], [test "$ac_cv_path_ac_pt_DX_DOXYGEN" != ""])
# Check if using QLA cooling
AM_CONDITIONAL([HAVEQLACOOLING], [test $with_cooling = "QLA"])
# Check if using EAGLE cooling
AM_CONDITIONAL([HAVEEAGLECOOLING], [test $with_cooling = "EAGLE"])
......
......@@ -59,6 +59,12 @@ include_HEADERS = space.h runner.h queue.h task.h lock.h cell.h part.h const.h \
black_holes.h black_holes_io.h black_holes_properties.h black_holes_struct.h \
feedback.h feedback_struct.h feedback_properties.h task_order.h
# source files for EAGLE cooling
QLA_COOLING_SOURCES =
if HAVEQLACOOLING
QLA_COOLING_SOURCES += cooling/QLA/cooling.c cooling/QLA/cooling_tables.c
endif
# source files for EAGLE cooling
EAGLE_COOLING_SOURCES =
if HAVEEAGLECOOLING
......@@ -102,6 +108,7 @@ AM_SOURCES = space.c runner_main.c runner_doiact_hydro.c runner_doiact_limiter.c
chemistry.c cosmology.c restart.c mesh_gravity.c velociraptor_interface.c \
outputlist.c velociraptor_dummy.c logger_io.c memuse.c mpiuse.c memuse_rnodes.c fof.c \
hashmap.c pressure_floor.c \
$(QLA_COOLING_SOURCES) \
$(EAGLE_COOLING_SOURCES) $(EAGLE_FEEDBACK_SOURCES) \
$(GRACKLE_COOLING_SOURCES) $(GEAR_FEEDBACK_SOURCES)
......@@ -222,6 +229,8 @@ nobase_noinst_HEADERS = align.h approx_math.h atomic.h barrier.h cycle.h error.h
cooling/grackle/cooling_io.h \
cooling/EAGLE/cooling.h cooling/EAGLE/cooling_struct.h cooling/EAGLE/cooling_tables.h \
cooling/EAGLE/cooling_io.h cooling/EAGLE/interpolate.h cooling/EAGLE/cooling_rates.h \
cooling/QLA/cooling.h cooling/QLA/cooling_struct.h cooling/QLA/cooling_tables.h \
cooling/QLA/cooling_io.h cooling/QLA/interpolate.h cooling/QLA/cooling_rates.h \
chemistry/none/chemistry.h \
chemistry/none/chemistry_io.h \
chemistry/none/chemistry_struct.h \
......@@ -234,6 +243,10 @@ nobase_noinst_HEADERS = align.h approx_math.h atomic.h barrier.h cycle.h error.h
chemistry/EAGLE/chemistry_io.h \
chemistry/EAGLE/chemistry_struct.h\
chemistry/EAGLE/chemistry_iact.h \
chemistry/QLA/chemistry.h \
chemistry/QLA/chemistry_io.h \
chemistry/QLA/chemistry_struct.h\
chemistry/QLA/chemistry_iact.h \
entropy_floor/none/entropy_floor.h \
entropy_floor/EAGLE/entropy_floor.h \
tracers/none/tracers.h tracers/none/tracers_struct.h \
......
......@@ -35,6 +35,9 @@
#elif defined(CHEMISTRY_GEAR)
#include "./chemistry/GEAR/chemistry.h"
#include "./chemistry/GEAR/chemistry_iact.h"
#elif defined(CHEMISTRY_QLA)
#include "./chemistry/QLA/chemistry.h"
#include "./chemistry/QLA/chemistry_iact.h"
#elif defined(CHEMISTRY_EAGLE)
#include "./chemistry/EAGLE/chemistry.h"
#include "./chemistry/EAGLE/chemistry_iact.h"
......
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2020 Matthieu Schaller (schaller@strw.leidenuniv.nl)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#ifndef SWIFT_CHEMISTRY_QLA_H
#define SWIFT_CHEMISTRY_QLA_H
/**
* @file src/chemistry/none/chemistry.h
* @brief Empty infrastructure for the cases without chemistry function
*/
/* Some standard headers. */
#include <float.h>
#include <math.h>
/* Local includes. */
#include "chemistry_struct.h"
#include "cosmology.h"
#include "error.h"
#include "hydro.h"
#include "parser.h"
#include "part.h"
#include "physical_constants.h"
#include "units.h"
/**
* @brief Return a string containing the name of a given #chemistry_element.
*/
__attribute__((always_inline)) INLINE static const char*
chemistry_get_element_name(enum chemistry_element elem) {
static const char* chemistry_element_names[chemistry_element_count] = {};
return chemistry_element_names[elem];
}
/**
* @brief Initialises the chemistry properties.
*
* Nothing to do here.
*
* @param parameter_file The parsed parameter file.
* @param us The current internal system of units.
* @param phys_const The physical constants in internal units.
* @param data The global chemistry information (to be filled).
*/
static INLINE void chemistry_init_backend(struct swift_params* parameter_file,
const struct unit_system* us,
const struct phys_const* phys_const,
struct chemistry_global_data* data) {}
/**
* @brief Prints the properties of the chemistry model to stdout.
*
* Nothing to do here.
*
* @brief The #chemistry_global_data containing information about the current
* model.
*/
static INLINE void chemistry_print_backend(
const struct chemistry_global_data* data) {
message("Chemistry function is 'Quick Lyman-alpha'.");
}
/**
* @brief Finishes the density calculation.
*
* Nothing to do here.
*
* @param p The particle to act upon
* @param cd The global chemistry information.
* @param cosmo The current cosmological model.
*/
__attribute__((always_inline)) INLINE static void chemistry_end_density(
struct part* restrict p, const struct chemistry_global_data* cd,
const struct cosmology* cosmo) {}
/**
* @brief Updates to the chemistry data after the hydro force loop.
*
* @param p The particle to act upon.
* @param cosmo The current cosmological model.
*/
__attribute__((always_inline)) INLINE static void chemistry_end_force(
struct part* restrict p, const struct cosmology* cosmo) {}
/**
* @brief Computes the chemistry-related time-step constraint.
*
* @param phys_const The physical constants in internal units.
* @param cosmo The current cosmological model.
* @param us The internal system of units.
* @param hydro_props The properties of the hydro scheme.
* @param cd The global properties of the chemistry scheme.
* @param p Pointer to the particle data.
*/
__attribute__((always_inline)) INLINE static float chemistry_timestep(
const struct phys_const* restrict phys_const,
const struct cosmology* restrict cosmo,
const struct unit_system* restrict us,
const struct hydro_props* hydro_props,
const struct chemistry_global_data* cd, const struct part* restrict p) {
return FLT_MAX;
}
/**
* @brief Sets all particle fields to sensible values when the #part has 0 ngbs.
*
* Nothing to do here.
*
* @param p The particle to act upon
* @param xp The extended particle data to act upon
* @param cd #chemistry_global_data containing chemistry informations.
* @param cosmo The current cosmological model.
*/
__attribute__((always_inline)) INLINE static void
chemistry_part_has_no_neighbours(struct part* restrict p,
struct xpart* restrict xp,
const struct chemistry_global_data* cd,
const struct cosmology* cosmo) {}
/**
* @brief Sets the chemistry properties of the (x-)particles to a valid start
* state.
*
* Nothing to do here.
*
* @param phys_const The physical constant in internal units.
* @param us The unit system.
* @param cosmo The current cosmological model.
* @param data The global chemistry information used for this run.
* @param p Pointer to the particle data.
* @param xp Pointer to the extended particle data.
*/
__attribute__((always_inline)) INLINE static void chemistry_first_init_part(
const struct phys_const* restrict phys_const,
const struct unit_system* restrict us,
const struct cosmology* restrict cosmo,
const struct chemistry_global_data* data, const struct part* restrict p,
struct xpart* restrict xp) {}
/**
* @brief Sets the chemistry properties of the (x-)particles to a valid start
* state.
*
* Nothing to do here.
*
* @param p Pointer to the particle data.
* @param data The global chemistry information.
*/
__attribute__((always_inline)) INLINE static void chemistry_init_part(
struct part* restrict p, const struct chemistry_global_data* data) {}
/**
* @brief Sets the chemistry properties of the sparticles to a valid start
* state.
*
* Nothing to do here.
*
* @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 sp Pointer to the sparticle data.
* @param xp Pointer to the extended particle data.
*/
__attribute__((always_inline)) INLINE static void chemistry_first_init_spart(
const struct chemistry_global_data* data, struct spart* restrict sp) {}
/**
* @brief Initialise the chemistry properties of a black hole with
* the chemistry properties of the gas it is born from.
*
* Nothing to do here.
*
* @param bp_data The black hole data to initialise.
* @param p_data The gas data to use.
* @param gas_mass The mass of the gas particle.
*/
__attribute__((always_inline)) INLINE static void chemistry_bpart_from_part(
struct chemistry_bpart_data* bp_data,
const struct chemistry_part_data* p_data, const double gas_mass) {}
/**
* @brief Add the chemistry data of a gas particle to a black hole.
*
* Nothing to do here.
*
* @param bp_data The black hole data to add to.
* @param p_data The gas data to use.
* @param gas_mass The mass of the gas particle.
*/
__attribute__((always_inline)) INLINE static void chemistry_add_part_to_bpart(
struct chemistry_bpart_data* bp_data,
const struct chemistry_part_data* p_data, const double gas_mass) {}
/**
* @brief Add the chemistry data of a black hole to another one.
*
* Nothing to do here.
*
* @param bp_data The black hole data to add to.
* @param swallowed_data The black hole data to use.
*/
__attribute__((always_inline)) INLINE static void chemistry_add_bpart_to_bpart(
struct chemistry_bpart_data* bp_data,
const struct chemistry_bpart_data* swallowed_data) {}
/**
* @brief Split the metal content of a particle into n pieces
*
* Nothing to do here.
*
* @param p The #part.
* @param n The number of pieces to split into.
*/
__attribute__((always_inline)) INLINE static void chemistry_split_part(
struct part* p, const double n) {}
/**
* @brief Returns the total metallicity (metal mass fraction) of the
* star particle to be used in feedback/enrichment related routines.
*
* No metallicity treatment here -> return 0.
*
* @param sp Pointer to the particle data.
*/
__attribute__((always_inline)) INLINE static float
chemistry_get_total_metal_mass_fraction_for_feedback(const struct spart* sp) {
return 0.f;
}
/**
* @brief Returns the abundance array (metal mass fractions) of the
* star particle to be used in feedback/enrichment related routines.
*
* No metallicity treatment here -> return NULL array.
*
* @param sp Pointer to the particle data.
*/
__attribute__((always_inline)) INLINE static float const*
chemistry_get_metal_mass_fraction_for_feedback(const struct spart* sp) {
return NULL;
}
/**
* @brief Returns the total metallicity (metal mass fraction) of the
* gas particle to be used in cooling related routines.
*
* No metallicity treatment here -> return 0.
*
* @param p Pointer to the particle data.
*/
__attribute__((always_inline)) INLINE static float
chemistry_get_total_metal_mass_fraction_for_cooling(const struct part* p) {
return 0.f;
}
/**
* @brief Returns the abundance array (metal mass fractions) of the
* gas particle to be used in cooling related routines.
*
* No metallicity treatment here -> return NULL array.
*
* @param p Pointer to the particle data.
*/
__attribute__((always_inline)) INLINE static float const*
chemistry_get_metal_mass_fraction_for_cooling(const struct part* p) {
return NULL;
}
/**
* @brief Returns the total metallicity (metal mass fraction) of the
* gas particle to be used in star formation related routines.
*
* No metallicity treatment here -> return 0.
*
* @param p Pointer to the particle data.
*/
__attribute__((always_inline)) INLINE static float
chemistry_get_total_metal_mass_fraction_for_star_formation(
const struct part* p) {
return 0.f;
}
/**
* @brief Returns the abundance array (metal mass fractions) of the
* gas particle to be used in star formation related routines.
*
* No metallicity treatment here -> return NULL array.
*
* @param p Pointer to the particle data.
*/
__attribute__((always_inline)) INLINE static float const*
chemistry_get_metal_mass_fraction_for_star_formation(const struct part* p) {
return NULL;
}
#endif /* SWIFT_CHEMISTRY_QLA_H */
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2020 Matthieu Schaller (schaller@strw.leidenuniv.nl)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#ifndef SWIFT_QLA_CHEMISTRY_IACT_H
#define SWIFT_QLA_CHEMISTRY_IACT_H
/**
* @file none/chemistry_iact.h
* @brief Density computation
*/
/**
* @brief do chemistry computation after the runner_iact_density (symmetric
* version)
*
* @param r2 Comoving square distance between the two particles.
* @param dx Comoving vector separating both particles (pi - pj).
* @param hi Comoving smoothing-length of particle i.
* @param hj Comoving smoothing-length of particle j.
* @param pi First particle.
* @param pj Second particle.
* @param a Current scale factor.
* @param H Current Hubble parameter.
*/
__attribute__((always_inline)) INLINE static void runner_iact_chemistry(
float r2, const float *dx, float hi, float hj, struct part *restrict pi,
struct part *restrict pj, float a, float H) {}
/**
* @brief do chemistry computation after the runner_iact_density (non symmetric
* version)
*
* @param r2 Comoving square distance between the two particles.
* @param dx Comoving vector separating both particles (pi - pj).
* @param hi Comoving smoothing-length of particle i.
* @param hj Comoving smoothing-length of particle j.
* @param pi First particle.
* @param pj Second particle (not updated).
* @param a Current scale factor.
* @param H Current Hubble parameter.
*/
__attribute__((always_inline)) INLINE static void runner_iact_nonsym_chemistry(
float r2, const float *dx, float hi, float hj, struct part *restrict pi,
const struct part *restrict pj, float a, float H) {}
#endif /* SWIFT_QLA_CHEMISTRY_IACT_H */
/*******************************************************************************
* This file is part of SWIFT.
* Coypright (c) 2020 Matthieu Schaller (schaller@strw.leidenuniv.nl)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#ifndef SWIFT_CHEMISTRY_IO_QLA_H
#define SWIFT_CHEMISTRY_IO_QLA_H
#include "io_properties.h"
/**
* @brief Specifies which particle fields to read from a dataset
*
* @param parts The particle array.
* @param list The list of i/o properties to read.
*
* @return Returns the number of fields to write.
*/
INLINE static int chemistry_read_particles(struct part* parts,
struct io_props* list) {
/* update list according to hydro_io */
/* Return the number of fields to read */
return 0;
}
/**
* @brief Specifies which particle fields to write to a dataset
*
* @param parts The particle array.
* @param list The list of i/o properties to write.
*
* @return Returns the number of fields to write.
*/
INLINE static int chemistry_write_particles(const struct part* parts,
struct io_props* list) {
/* update list according to hydro_io */
/* Return the number of fields to write */
return 0;
}
/**
* @brief Specifies which sparticle fields to write to a dataset
*
* @param sparts The sparticle array.
* @param list The list of i/o properties to write.
*
* @return Returns the number of fields to write.
*/
INLINE static int chemistry_write_sparticles(const struct spart* sparts,
struct io_props* list) {
/* update list according to hydro_io */
/* Return the number of fields to write */
return 0;
}
/**
* @brief Specifies which bparticle fields to write to a dataset
*
* @param bparts The bparticle array.
* @param list The list of i/o properties to write.
*
* @return Returns the number of fields to write.
*/
INLINE static int chemistry_write_bparticles(const struct bpart* bparts,
struct io_props* list) {
/* update list according to hydro_io */
/* Return the number of fields to write */
return 0;
}
#ifdef HAVE_HDF5
/**
* @brief Writes the current model of chemistry to the file
* @param h_grp The HDF5 group in which to write
*/
INLINE static void chemistry_write_flavour(hid_t h_grp) {
io_write_attribute_s(h_grp, "Chemistry Model", "Quick Lyman-alpha");
io_write_attribute_d(h_grp, "Chemistry element count", 0);
}
#endif
#endif /* SWIFT_CHEMISTRY_IO_QLA_H */
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2020 Matthieu Schaller (schaller@strw.leidenuniv.nl)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#ifndef SWIFT_CHEMISTRY_STRUCT_QLA_H
#define SWIFT_C