Commit 017627d7 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Added basic EAGLE chemistry model. Metal fields exist and get written to snapshots.

parent 38824b44
......@@ -935,7 +935,7 @@ esac
# chemistry function
AC_ARG_WITH([chemistry],
[AS_HELP_STRING([--with-chemistry=<function>],
[chemistry function @<:@none, gear default: none@:>@]
[chemistry function @<:@none, gear, EAGLE default: none@:>@]
)],
[with_chemistry="$withval"],
[with_chemistry="none"]
......@@ -947,6 +947,9 @@ case "$with_chemistry" in
gear)
AC_DEFINE([CHEMISTRY_GEAR], [1], [Chemistry taken from the GEAR model])
;;
EAGLE)
AC_DEFINE([CHEMISTRY_EAGLE], [1], [Chemistry taken from the EAGLE model])
;;
*)
AC_MSG_ERROR([Unknown chemistry function: $with_chemistry])
;;
......
......@@ -125,7 +125,10 @@ nobase_noinst_HEADERS = align.h approx_math.h atomic.h barrier.h cycle.h error.h
chemistry/none/chemistry_struct.h \
chemistry/gear/chemistry.h \
chemistry/gear/chemistry_io.h \
chemistry/gear/chemistry_struct.h
chemistry/gear/chemistry_struct.h \
chemistry/EAGLE/chemistry.h \
chemistry/EAGLE/chemistry_io.h \
chemistry/EAGLE/chemistry_struct.h
# Sources and flags for regular library
......
......@@ -33,6 +33,8 @@
#include "./chemistry/none/chemistry.h"
#elif defined(CHEMISTRY_GEAR)
#include "./chemistry/gear/chemistry.h"
#elif defined(CHEMISTRY_EAGLE)
#include "./chemistry/EAGLE/chemistry.h"
#else
#error "Invalid choice of chemistry function."
#endif
......
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2016 Matthieu Schaller (matthieu.schaller@durham.ac.uk)
*
* 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_EAGLE_H
#define SWIFT_CHEMISTRY_EAGLE_H
/**
* @file src/chemistry/gear/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 "error.h"
#include "hydro.h"
#include "parser.h"
#include "part.h"
#include "physical_constants.h"
#include "units.h"
/**
* @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 xp Pointer to the extended particle data.
*/
__attribute__((always_inline)) INLINE static void chemistry_init_part(
const struct part* restrict p, struct xpart* restrict xp) {}
/**
* @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.
*/
static INLINE void chemistry_init_backend(
const struct swift_params* parameter_file, const struct unit_system* us,
const struct phys_const* phys_const) {}
/**
* @brief Prints the properties of the chemistry model to stdout.
*/
static INLINE void chemistry_print_backend() {
message("Chemistry model is 'EAGLE'.");
}
#endif /* SWIFT_CHEMISTRY_EAGLE_H */
/*******************************************************************************
* This file is part of SWIFT.
* Coypright (c) 2016 Matthieu Schaller (matthieu.schaller@durham.ac.uk)
*
* 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_EAGLE_H
#define SWIFT_CHEMISTRY_IO_EAGLE_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 read.
*/
int chemistry_read_particles(struct part* parts, struct io_props* list) {
/* Nothing 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.
*/
int chemistry_write_particles(const struct part* parts, struct io_props* list) {
/* List what we want to write */
list[0] = io_make_output_field("ElementAbundance", FLOAT, eagle_element_count,
UNIT_CONV_NO_UNITS, parts,
chemistry_data.metal_mass_fraction);
list[1] = io_make_output_field("SmoothedElementAbundance", FLOAT,
eagle_element_count, UNIT_CONV_NO_UNITS, parts,
chemistry_data.smoothed_metal_mass_fraction);
list[2] =
io_make_output_field("Metallicity", FLOAT, 1, UNIT_CONV_NO_UNITS, parts,
chemistry_data.metal_mass_fraction_total);
list[3] = io_make_output_field(
"SmoothedMetallicity", FLOAT, 1, UNIT_CONV_NO_UNITS, parts,
chemistry_data.smoothed_metal_mass_fraction_total);
list[4] = io_make_output_field("TotalMassFromSNIa", FLOAT, 1, UNIT_CONV_MASS,
parts, chemistry_data.mass_from_SNIa);
list[5] = io_make_output_field("MetalMassFracFromSNIa", FLOAT, 1,
UNIT_CONV_NO_UNITS, parts,
chemistry_data.metal_mass_fraction_from_SNIa);
list[6] = io_make_output_field("TotalMassFromAGB", FLOAT, 1, UNIT_CONV_MASS,
parts, chemistry_data.mass_from_AGB);
list[7] =
io_make_output_field("MetalMassFracFromAGB", FLOAT, 1, UNIT_CONV_NO_UNITS,
parts, chemistry_data.metal_mass_fraction_from_AGB);
list[8] = io_make_output_field("TotalMassFromSNII", FLOAT, 1, UNIT_CONV_MASS,
parts, chemistry_data.mass_from_SNII);
list[9] = io_make_output_field("MetalMassFracFromSNII", FLOAT, 1,
UNIT_CONV_NO_UNITS, parts,
chemistry_data.metal_mass_fraction_from_SNII);
list[10] =
io_make_output_field("IronMassFracFromSNIa", FLOAT, 1, UNIT_CONV_NO_UNITS,
parts, chemistry_data.iron_mass_fraction_from_SNIa);
list[11] = io_make_output_field(
"SmoothedIronMassFracFromSNIa", FLOAT, 1, UNIT_CONV_NO_UNITS, parts,
chemistry_data.smoothed_iron_mass_fraction_from_SNIa);
return 12;
}
/**
* @brief Writes the current model of SPH to the file
* @param h_grpsph The HDF5 group in which to write
*/
void chemistry_write_flavour(hid_t h_grpsph) {
io_write_attribute_s(h_grpsph, "Chemistry Model", "EAGLE");
}
#endif /* SWIFT_CHEMISTRY_IO_EAGLE_H */
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2016 Matthieu Schaller (matthieu.schaller@durham.ac.uk)
*
* 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_EAGLE_H
#define SWIFT_CHEMISTRY_STRUCT_EAGLE_H
/**
* @brief The individual elements traced in the EAGLE model.
*/
enum eagle_chemisty_element {
eagle_element_H = 0,
eagle_element_He,
eagle_element_C,
eagle_element_N,
eagle_element_O,
eagle_element_Ne,
eagle_element_Mg,
eagle_element_Si,
eagle_element_Fe,
eagle_element_count
};
/**
* @brief Chemical abundances traced in the EAGLE model.
*/
struct chemistry_part_data {
/*! Fraction of the particle mass in a given element */
float metal_mass_fraction[eagle_element_count];
/*! Fraction of the particle mass in *all* metals */
float metal_mass_fraction_total;
/*! Smoothed fraction of the particle mass in a given element */
float smoothed_metal_mass_fraction[eagle_element_count];
/*! Smoothed fraction of the particle mass in *all* metals */
float smoothed_metal_mass_fraction_total;
/*! Mass coming from SNIa */
float mass_from_SNIa;
/*! Fraction of total gas mass in metals coming from SNIa */
float metal_mass_fraction_from_SNIa;
/*! Mass coming from AGB */
float mass_from_AGB;
/*! Fraction of total gas mass in metals coming from AGB */
float metal_mass_fraction_from_AGB;
/*! Mass coming from SNII */
float mass_from_SNII;
/*! Fraction of total gas mass in metals coming from SNII */
float metal_mass_fraction_from_SNII;
/*! Fraction of total gas mass in Iron coming from SNIa */
float iron_mass_fraction_from_SNIa;
/*! Smoothed fraction of total gas mass in Iron coming from SNIa */
float smoothed_iron_mass_fraction_from_SNIa;
};
#endif /* SWIFT_CHEMISTRY_STRUCT_EAGLE_H */
......@@ -27,6 +27,8 @@
#include "./chemistry/none/chemistry_io.h"
#elif defined(CHEMISTRY_GEAR)
#include "./chemistry/gear/chemistry_io.h"
#elif defined(CHEMISTRY_EAGLE)
#include "./chemistry/EAGLE/chemistry_io.h"
#else
#error "Invalid choice of chemistry function."
#endif
......
......@@ -32,6 +32,8 @@
#include "./chemistry/none/chemistry_struct.h"
#elif defined(CHEMISTRY_GEAR)
#include "./chemistry/gear/chemistry_struct.h"
#elif defined(CHEMISTRY_EAGLE)
#include "./chemistry/EAGLE/chemistry_struct.h"
#else
#error "Invalid choice of chemistry function."
#endif
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment