Commit 81c05683 authored by Matthieu Schaller's avatar Matthieu Schaller

Merge branch 'improved_grackle' into 'master'

Add support for Grackle 3.0.

See merge request !499
parents 0cb47d49 e7f6698b
......@@ -962,7 +962,7 @@ esac
# Cooling function
AC_ARG_WITH([cooling],
[AS_HELP_STRING([--with-cooling=<function>],
[cooling function @<:@none, const-du, const-lambda, grackle default: none@:>@]
[cooling function @<:@none, const-du, const-lambda, EAGLE, grackle, grackle1, grackle2, grackle3 default: none@:>@]
)],
[with_cooling="$withval"],
[with_cooling="none"]
......@@ -979,6 +979,19 @@ case "$with_cooling" in
;;
grackle)
AC_DEFINE([COOLING_GRACKLE], [1], [Cooling via the grackle library])
AC_DEFINE([COOLING_GRACKLE_MODE], [0], [Grackle chemistry network, mode 0])
;;
grackle1)
AC_DEFINE([COOLING_GRACKLE], [1], [Cooling via the grackle library])
AC_DEFINE([COOLING_GRACKLE_MODE], [1], [Grackle chemistry network, mode 1])
;;
grackle2)
AC_DEFINE([COOLING_GRACKLE], [1], [Cooling via the grackle library])
AC_DEFINE([COOLING_GRACKLE_MODE], [2], [Grackle chemistry network, mode 2])
;;
grackle3)
AC_DEFINE([COOLING_GRACKLE], [1], [Cooling via the grackle library])
AC_DEFINE([COOLING_GRACKLE_MODE], [3], [Grackle chemistry network, mode 3])
;;
EAGLE)
AC_DEFINE([COOLING_EAGLE], [1], [Cooling following the EAGLE model])
......
......@@ -42,10 +42,16 @@ LambdaCooling:
# Cooling with Grackle 2.0
GrackleCooling:
GrackleCloudyTable: ../CloudyData_UVB=HM2012.h5 # Name of the Cloudy Table (available on the grackle bitbucket repository)
UVbackground: 0 # Enable or not the UV background
GrackleRedshift: 0 # Redshift to use (-1 means time based redshift)
GrackleHSShieldingDensityThreshold: 1.1708e-26 # self shielding threshold in internal system of units
CloudyTable: CloudyData_UVB=HM2012.h5 # Name of the Cloudy Table (available on the grackle bitbucket repository)
WithUVbackground: 0 # Enable or not the UV background
Redshift: 0 # Redshift to use (-1 means time based redshift)
WithMetalCooling: 1 # Enable or not the metal cooling
ProvideVolumetricHeatingRates: 0 # User provide volumetric heating rates
ProvideSpecificHeatingRates: 0 # User provide specific heating rates
SelfShieldingMethod: 0 # Grackle (<= 3) or Gear self shielding method
OutputMode: 1 # Write in output corresponding primordial chemistry mode
MaxSteps: 1000
ConvergenceLimit: 1e-2
EAGLEChemistry:
InitMetallicity: 0.
......@@ -60,3 +66,6 @@ EAGLEChemistry:
InitAbundance_Iron: 0.000
CalciumOverSilicon: 0.0941736
SulphurOverSilicon: 0.6054160
GearChemistry:
InitialMetallicity: 0.01295
......@@ -124,7 +124,7 @@ int main(int argc, char *argv[]) {
/* Structs used by the engine. Declare now to make sure these are always in
* scope. */
struct chemistry_data chemistry;
struct chemistry_global_data chemistry;
struct cooling_function_data cooling_func;
struct cosmology cosmo;
struct external_potential potential;
......
......@@ -179,12 +179,18 @@ LambdaCooling:
hydrogen_mass_abundance: 0.75 # Hydrogen mass abundance (dimensionless)
cooling_tstep_mult: 1.0 # Dimensionless pre-factor for the time-step condition
# Cooling with Grackle 2.0
# Cooling with Grackle 3.0
GrackleCooling:
GrackleCloudyTable: CloudyData_UVB=HM2012.h5 # Name of the Cloudy Table (available on the grackle bitbucket repository)
UVbackground: 1 # Enable or not the UV background
GrackleRedshift: 0 # Redshift to use (-1 means time based redshift)
GrackleHSShieldingDensityThreshold: 1.1708e-26 # self shielding threshold in internal system of units
CloudyTable: CloudyData_UVB=HM2012.h5 # Name of the Cloudy Table (available on the grackle bitbucket repository)
WithUVbackground: 1 # Enable or not the UV background
Redshift: 0 # Redshift to use (-1 means time based redshift)
WithMetalCooling: 1 # Enable or not the metal cooling
ProvideVolumetricHeatingRates: 0 # (optional) User provide volumetric heating rates
ProvideSpecificHeatingRates: 0 # (optional) User provide specific heating rates
SelfShieldingMethod: 0 # (optional) Grackle (<= 3) or Gear self shielding method
OutputMode: 0 # (optional) Write in output corresponding primordial chemistry mode
MaxSteps: 10000 # (optional) Max number of step when computing the initial composition
ConvergenceLimit: 1e-2 # (optional) Convergence threshold (relative) for initial composition
# Parameters related to chemistry models -----------------------------------------------
......
......@@ -43,8 +43,8 @@ include_HEADERS = space.h runner.h queue.h task.h lock.h cell.h part.h const.h \
engine.h swift.h serial_io.h timers.h debug.h scheduler.h proxy.h parallel_io.h \
common_io.h single_io.h multipole.h map.h tools.h partition.h clocks.h parser.h \
physical_constants.h physical_constants_cgs.h potential.h version.h \
hydro_properties.h riemann.h threadpool.h cooling.h cooling_struct.h sourceterms.h \
sourceterms_struct.h statistics.h memswap.h cache.h runner_doiact_vec.h profiler.h \
hydro_properties.h riemann.h threadpool.h cooling_io.h cooling.h cooling_struct.h \
sourceterms.h sourceterms_struct.h statistics.h memswap.h cache.h runner_doiact_vec.h profiler.h \
dump.h logger.h active.h timeline.h xmf.h gravity_properties.h gravity_derivatives.h \
gravity_softened_derivatives.h vector_power.h collectgroup.h hydro_space.h sort_part.h \
chemistry.h chemistry_io.h chemistry_struct.h cosmology.h restart.h
......@@ -118,10 +118,15 @@ nobase_noinst_HEADERS = align.h approx_math.h atomic.h barrier.h cycle.h error.h
potential/isothermal/potential.h potential/disc_patch/potential.h \
potential/sine_wave/potential.h \
cooling/none/cooling.h cooling/none/cooling_struct.h \
cooling/none/cooling_io.h \
cooling/const_du/cooling.h cooling/const_du/cooling_struct.h \
cooling/const_du/cooling_io.h \
cooling/const_lambda/cooling.h cooling/const_lambda/cooling_struct.h \
cooling/const_lambda/cooling_io.h \
cooling/grackle/cooling.h cooling/grackle/cooling_struct.h \
cooling/grackle/cooling_io.h \
cooling/EAGLE/cooling.h cooling/EAGLE/cooling_struct.h \
cooling/EAGLE/cooling_io.h \
chemistry/none/chemistry.h \
chemistry/none/chemistry_io.h \
chemistry/none/chemistry_struct.h \
......
......@@ -36,7 +36,7 @@
void chemistry_init(const struct swift_params* parameter_file,
const struct unit_system* us,
const struct phys_const* phys_const,
struct chemistry_data* data) {
struct chemistry_global_data* data) {
chemistry_init_backend(parameter_file, us, phys_const, data);
}
......@@ -46,9 +46,10 @@ void chemistry_init(const struct swift_params* parameter_file,
*
* Calls chemistry_print_backend for the chosen chemistry model.
*
* @brief The #chemistry_data containing information about the current model.
* @brief The #chemistry_global_data containing information about the current
* model.
*/
void chemistry_print(const struct chemistry_data* data) {
void chemistry_print(const struct chemistry_global_data* data) {
chemistry_print_backend(data);
}
......@@ -58,10 +59,10 @@ void chemistry_print(const struct chemistry_data* data) {
* @param chemistry the struct
* @param stream the file stream
*/
void chemistry_struct_dump(const struct chemistry_data* chemistry,
void chemistry_struct_dump(const struct chemistry_global_data* chemistry,
FILE* stream) {
restart_write_blocks((void*)chemistry, sizeof(struct chemistry_data), 1,
stream, "chemistry", "chemistry function");
restart_write_blocks((void*)chemistry, sizeof(struct chemistry_global_data),
1, stream, "chemistry", "chemistry function");
}
/**
......@@ -71,8 +72,8 @@ void chemistry_struct_dump(const struct chemistry_data* chemistry,
* @param chemistry the struct
* @param stream the file stream
*/
void chemistry_struct_restore(const struct chemistry_data* chemistry,
void chemistry_struct_restore(const struct chemistry_global_data* chemistry,
FILE* stream) {
restart_read_blocks((void*)chemistry, sizeof(struct chemistry_data), 1,
restart_read_blocks((void*)chemistry, sizeof(struct chemistry_global_data), 1,
stream, NULL, "chemistry function");
}
......@@ -46,14 +46,14 @@
void chemistry_init(const struct swift_params* parameter_file,
const struct unit_system* us,
const struct phys_const* phys_const,
struct chemistry_data* data);
struct chemistry_global_data* data);
void chemistry_print(const struct chemistry_data* data);
void chemistry_print(const struct chemistry_global_data* data);
/* Dump/restore. */
void chemistry_struct_dump(const struct chemistry_data* chemistry,
void chemistry_struct_dump(const struct chemistry_global_data* chemistry,
FILE* stream);
void chemistry_struct_restore(const struct chemistry_data* chemistry,
void chemistry_struct_restore(const struct chemistry_global_data* chemistry,
FILE* stream);
#endif /* SWIFT_CHEMISTRY_H */
......@@ -57,10 +57,10 @@ chemistry_get_element_name(enum chemistry_element elem) {
* the various smooth metallicity tasks
*
* @param p The particle to act upon
* @param cd #chemistry_data containing chemistry informations.
* @param cd #chemistry_global_data containing chemistry informations.
*/
__attribute__((always_inline)) INLINE static void chemistry_init_part(
struct part* restrict p, const struct chemistry_data* cd) {}
struct part* restrict p, const struct chemistry_global_data* cd) {}
/**
* @brief Finishes the smooth metal calculation.
......@@ -71,11 +71,11 @@ __attribute__((always_inline)) INLINE static void chemistry_init_part(
* This function requires the #hydro_end_density to have been called.
*
* @param p The particle to act upon.
* @param cd #chemistry_data containing chemistry informations.
* @param cd #chemistry_global_data containing chemistry informations.
* @param cosmo The current cosmological model.
*/
__attribute__((always_inline)) INLINE static void chemistry_end_density(
struct part* restrict p, const struct chemistry_data* cd,
struct part* restrict p, const struct chemistry_global_data* cd,
const struct cosmology* cosmo) {}
/**
......@@ -87,8 +87,11 @@ __attribute__((always_inline)) INLINE static void chemistry_end_density(
* @param data The global chemistry information.
*/
__attribute__((always_inline)) INLINE static void chemistry_first_init_part(
struct part* restrict p, struct xpart* restrict xp,
const struct chemistry_data* data) {
const struct phys_const* restrict phys_const,
const struct unit_system* restrict us,
const struct cosmology* restrict cosmo,
const struct chemistry_global_data* data, struct part* restrict p,
struct xpart* restrict xp) {
p->chemistry_data.metal_mass_fraction_total =
data->initial_metal_mass_fraction_total;
......@@ -107,7 +110,7 @@ __attribute__((always_inline)) INLINE static void chemistry_first_init_part(
*/
static INLINE void chemistry_init_backend(
const struct swift_params* parameter_file, const struct unit_system* us,
const struct phys_const* phys_const, struct chemistry_data* data) {
const struct phys_const* phys_const, struct chemistry_global_data* data) {
/* Read the total metallicity */
data->initial_metal_mass_fraction_total =
......@@ -133,9 +136,11 @@ static INLINE void chemistry_init_backend(
/**
* @brief Prints the properties of the chemistry model to stdout.
*
* @brief The #chemistry_data containing information about the current model.
* @brief The #chemistry_global_data containing information about the current
* model.
*/
static INLINE void chemistry_print_backend(const struct chemistry_data* data) {
static INLINE void chemistry_print_backend(
const struct chemistry_global_data* data) {
message("Chemistry model is 'EAGLE' tracking %d elements.",
chemistry_element_count);
......
......@@ -38,7 +38,7 @@ enum chemistry_element {
/**
* @brief Global chemical abundance information in the EAGLE model.
*/
struct chemistry_data {
struct chemistry_global_data {
/*! Fraction of the particle mass in given elements at the start of the run */
float initial_metal_mass_fraction[chemistry_element_count];
......
......@@ -29,6 +29,7 @@
#include <math.h>
/* Local includes. */
#include "chemistry_io.h"
#include "chemistry_struct.h"
#include "error.h"
#include "hydro.h"
......@@ -38,16 +39,16 @@
#include "units.h"
/**
* @brief Return a string containing the name of a given #chemistry_element.
* @brief Compute the metal mass fraction
*
* @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 const char*
chemistry_get_element_name(enum chemistry_element elem) {
static const char* chemistry_element_names[chemistry_element_count] = {
"Oxygen", "Magnesium", "Sulfur", "Iron", "Zinc",
"Strontium", "Yttrium", "Barium", "Europium"};
return chemistry_element_names[elem];
__attribute__((always_inline)) INLINE static float
chemistry_metal_mass_fraction(const struct part* restrict p,
const struct xpart* restrict xp) {
return p->chemistry_data.Z;
}
/**
......@@ -62,16 +63,10 @@ chemistry_get_element_name(enum chemistry_element elem) {
*/
static INLINE void chemistry_init_backend(
const struct swift_params* parameter_file, const struct unit_system* us,
const struct phys_const* phys_const, struct chemistry_data* data) {}
const struct phys_const* phys_const, struct chemistry_global_data* data) {
/**
* @brief Prints the properties of the chemistry model to stdout.
*
* @brief The #chemistry_data containing information about the current model.
*/
static INLINE void chemistry_print_backend(const struct chemistry_data* data) {
message("Chemistry function is 'Gear'.");
/* read parameters */
chemistry_read_parameters(parameter_file, us, phys_const, data);
}
/**
......@@ -81,10 +76,10 @@ static INLINE void chemistry_print_backend(const struct chemistry_data* data) {
* the various smooth metallicity tasks
*
* @param p The particle to act upon
* @param cd #chemistry_data containing chemistry informations.
* @param cd #chemistry_global_data containing chemistry informations.
*/
__attribute__((always_inline)) INLINE static void chemistry_init_part(
struct part* restrict p, const struct chemistry_data* cd) {
struct part* restrict p, const struct chemistry_global_data* cd) {
struct chemistry_part_data* cpd = &p->chemistry_data;
......@@ -102,11 +97,11 @@ __attribute__((always_inline)) INLINE static void chemistry_init_part(
* This function requires the #hydro_end_density to have been called.
*
* @param p The particle to act upon.
* @param cd #chemistry_data containing chemistry informations.
* @param cd #chemistry_global_data containing chemistry informations.
* @param cosmo The current cosmological model.
*/
__attribute__((always_inline)) INLINE static void chemistry_end_density(
struct part* restrict p, const struct chemistry_data* cd,
struct part* restrict p, const struct chemistry_global_data* cd,
const struct cosmology* cosmo) {
/* Some smoothing length multiples. */
......@@ -138,8 +133,13 @@ __attribute__((always_inline)) INLINE static void chemistry_end_density(
* @param data The global chemistry information.
*/
__attribute__((always_inline)) INLINE static void chemistry_first_init_part(
struct part* restrict p, struct xpart* restrict xp,
const struct chemistry_data* data) {
const struct phys_const* restrict phys_const,
const struct unit_system* restrict us,
const struct cosmology* restrict cosmo,
const struct chemistry_global_data* data, struct part* restrict p,
struct xpart* restrict xp) {
p->chemistry_data.Z = data->initial_metallicity;
chemistry_init_part(p, data);
}
......
......@@ -19,9 +19,38 @@
#ifndef SWIFT_CHEMISTRY_IO_GEAR_H
#define SWIFT_CHEMISTRY_IO_GEAR_H
#include "chemistry.h"
#include "chemistry_struct.h"
#include "error.h"
#include "io_properties.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] = {
"Oxygen", "Magnesium", "Sulfur", "Iron", "Zinc",
"Strontium", "Yttrium", "Barium", "Europium"};
return chemistry_element_names[elem];
}
/**
* @brief Prints the properties of the chemistry model to stdout.
*
* @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 'Gear'.");
}
/**
* @brief Specifies which particle fields to read from a dataset
......@@ -31,13 +60,25 @@
*
* @return Returns the number of fields to read.
*/
int chemistry_read_particles(struct part* parts, struct io_props* list) {
__attribute__((always_inline)) INLINE static int chemistry_read_particles(
struct part* parts, struct io_props* list) {
/* List what we want to read */
list[0] = io_make_input_field(
"ElementAbundance", FLOAT, chemistry_element_count, OPTIONAL,
UNIT_CONV_NO_UNITS, parts, chemistry_data.metal_mass_fraction);
return 1;
list[1] = io_make_input_field("Z", FLOAT, 1, OPTIONAL, UNIT_CONV_NO_UNITS,
parts, chemistry_data.Z);
return 2;
}
__attribute__((always_inline)) INLINE static void chemistry_read_parameters(
const struct swift_params* parameter_file, const struct unit_system* us,
const struct phys_const* phys_const, struct chemistry_global_data* data) {
data->initial_metallicity = parser_get_opt_param_float(
parameter_file, "GearChemistry:InitialMetallicity", -1);
}
/**
......@@ -48,18 +89,21 @@ int chemistry_read_particles(struct part* parts, struct io_props* list) {
*
* @return Returns the number of fields to write.
*/
int chemistry_write_particles(const struct part* parts, struct io_props* list) {
__attribute__((always_inline)) INLINE static int chemistry_write_particles(
const struct part* parts, struct io_props* list) {
/* List what we want to write */
list[0] = io_make_output_field(
"SmoothedElementAbundance", FLOAT, chemistry_element_count,
UNIT_CONV_NO_UNITS, parts, chemistry_data.smoothed_metal_mass_fraction);
list[1] = io_make_output_field("Z", FLOAT, 1, UNIT_CONV_NO_UNITS, parts,
chemistry_data.Z);
list[1] = io_make_output_field("ElementAbundance", FLOAT,
list[2] = io_make_output_field("ElementAbundance", FLOAT,
chemistry_element_count, UNIT_CONV_NO_UNITS,
parts, chemistry_data.metal_mass_fraction);
return 2;
return 3;
}
#ifdef HAVE_HDF5
......@@ -68,7 +112,8 @@ int chemistry_write_particles(const struct part* parts, struct io_props* list) {
* @brief Writes the current model of SPH to the file
* @param h_grp The HDF5 group in which to write
*/
void chemistry_write_flavour(hid_t h_grp) {
__attribute__((always_inline)) INLINE static void chemistry_write_flavour(
hid_t h_grp) {
io_write_attribute_s(h_grp, "Chemistry Model", "GEAR");
for (enum chemistry_element i = chemistry_element_O;
......
......@@ -38,7 +38,11 @@ enum chemistry_element {
/**
* @brief Global chemical abundance information.
*/
struct chemistry_data {};
struct chemistry_global_data {
/* Initial metallicity Z */
float initial_metallicity;
};
/**
* @brief Properties of the chemistry function.
......@@ -50,6 +54,8 @@ struct chemistry_part_data {
/*! Smoothed fraction of the particle mass in a given element */
float smoothed_metal_mass_fraction[chemistry_element_count];
float Z;
};
#endif /* SWIFT_CHEMISTRY_STRUCT_GEAR_H */
......@@ -61,14 +61,16 @@ chemistry_get_element_name(enum chemistry_element elem) {
*/
static INLINE void chemistry_init_backend(
const struct swift_params* parameter_file, const struct unit_system* us,
const struct phys_const* phys_const, struct chemistry_data* data) {}
const struct phys_const* phys_const, struct chemistry_global_data* data) {}
/**
* @brief Prints the properties of the chemistry model to stdout.
*
* @brief The #chemistry_data containing information about the current model.
* @brief The #chemistry_global_data containing information about the current
* model.
*/
static INLINE void chemistry_print_backend(const struct chemistry_data* data) {
static INLINE void chemistry_print_backend(
const struct chemistry_global_data* data) {
message("Chemistry function is 'No chemistry'.");
}
......@@ -81,7 +83,7 @@ static INLINE void chemistry_print_backend(const struct chemistry_data* data) {
* @param cosmo The current cosmological model.
*/
__attribute__((always_inline)) INLINE static void chemistry_end_density(
struct part* restrict p, const struct chemistry_data* cd,
struct part* restrict p, const struct chemistry_global_data* cd,
const struct cosmology* cosmo) {}
/**
......@@ -90,13 +92,19 @@ __attribute__((always_inline)) INLINE static void chemistry_end_density(
*
* 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.
* @param data The global chemistry information used for this run.
*/
__attribute__((always_inline)) INLINE static void chemistry_first_init_part(
const struct part* restrict p, struct xpart* restrict xp,
const struct chemistry_data* data) {}
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
......@@ -108,6 +116,6 @@ __attribute__((always_inline)) INLINE static void chemistry_first_init_part(
* @param data The global chemistry information.
*/
__attribute__((always_inline)) INLINE static void chemistry_init_part(
struct part* restrict p, const struct chemistry_data* data) {}
struct part* restrict p, const struct chemistry_global_data* data) {}
#endif /* SWIFT_CHEMISTRY_NONE_H */
......@@ -34,7 +34,7 @@ enum chemistry_element { chemistry_element_count = 0 };
*
* Nothing here.
*/
struct chemistry_data {};
struct chemistry_global_data {};
/**
* @brief Chemistry properties carried by the #part.
......
......@@ -20,10 +20,13 @@
#define SWIFT_COOLING_EAGLE_H
/**
* @file src/cooling/none/cooling.h
* @brief Empty infrastructure for the cases without cooling function
* @file src/cooling/EAGLE/cooling.h
* @brief EAGLE cooling function
*/
/* Config parameters. */
#include "../config.h"
/* Some standard headers. */
#include <float.h>
#include <math.h>
......@@ -31,25 +34,11 @@
/* Local includes. */
#include "error.h"
#include "hydro.h"
#include "io_properties.h"
#include "parser.h"
#include "part.h"
#include "physical_constants.h"
#include "units.h"
#ifdef HAVE_HDF5
/**
* @brief Writes the current model of SPH to the file
* @param h_grpsph The HDF5 group in which to write
*/
__attribute__((always_inline)) INLINE static void cooling_write_flavour(
hid_t h_grpsph) {
io_write_attribute_s(h_grpsph, "Cooling Model", "EAGLE");
}
#endif
/**
* @brief Apply the cooling function to a particle.
*
......@@ -95,8 +84,11 @@ __attribute__((always_inline)) INLINE static float cooling_timestep(
* @param cooling The properties of the cooling function.
*/
__attribute__((always_inline)) INLINE static void cooling_first_init_part(
const struct part* restrict p, struct xpart* restrict xp,
const struct cooling_function_data* cooling) {}
const struct phys_const* restrict phys_const,
const struct unit_system* restrict us,
const struct cosmology* restrict cosmo,
const struct cooling_function_data* restrict cooling,
const struct part* restrict p, struct xpart* restrict xp) {}
/**
* @brief Returns the total radiated energy by this particle.
......
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2017 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_COOLING_EAGLE_IO_H
#define SWIFT_COOLING_EAGLE_IO_H
/* Config parameters. */
#include "../config.h"
/* Local includes */
#include "io_properties.h"
#ifdef HAVE_HDF5
/**
* @brief Writes the current model of SPH to the file
* @param h_grpsph The HDF5 group in which to write
*/
__attribute__((always_inline)) INLINE static void cooling_write_flavour(
hid_t h_grpsph) {
io_write_attribute_s(h_grpsph, "Cooling Model", "EAGLE");
}
#endif
/**
* @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.
* @param cooling The #cooling_function_data
*
* @return Returns the number of fields to write.
*/
__attribute__((always_inline)) INLINE static int cooling_write_particles(
const struct xpart* xparts, struct io_props* list,
const struct cooling_function_data* cooling) {
return 0;
}
#endif /* SWIFT_COOLING_EAGLE_IO_H */
......@@ -30,33 +30,21 @@
* realistic functions.
*/
/* Config parameters. */
#include "../config.h"
/* Some standard headers. */
#include <math.h>
/* Local includes. */
#include "const.h"
#include "cooling_struct.h"
#include "error.h"
#include "hydro.h"
#include "io_properties.h"
#include "parser.h"
#include "part.h"
#include "physical_constants.h"
#include "units.h"
#ifdef HAVE_HDF5
/**
* @brief Writes the current model of SPH to the file
* @param h_grpsph The HDF5 group in which to write
*/
__attribute__((always_inline)) INLINE static void cooling_write_flavour(
hid_t h_grpsph) {
io_write_attribute_s(h_grpsph, "Cooling Model", "Constant du/dt");
}
#endif
/**
* @brief Apply the cooling function to a particle.
*
......@@ -141,8 +129,11 @@ __attribute__((always_inline)) INLINE static float cooling_timestep(
* @param cooling The properties of the cooling function.
*/
__attribute__((always_inline)) INLINE static void cooling_first_init_part(
const struct part* restrict p, struct xpart* restrict xp,
const struct cooling_function_data* cooling) {
const struct phys_const* restrict phys_const,
const struct unit_system* restrict us,
const struct cosmology* restrict cosmo,
const struct cooling_function_data* restrict cooling,
const struct part* restrict p, struct xpart* restrict xp) {
xp->cooling_data.radiated_energy = 0.f;
}
......
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2016 Matthieu Schaller (matthieu.schaller@durham.ac.uk)
* Richard Bower (r.g.bower@durham.ac.uk)
* Stefan Arridge (stefan.arridge@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