diff --git a/configure.ac b/configure.ac index e7b7cb3c171946ac202a34e7625ffc8dab2fce7d..3256c0ff55e452fb689a4d3cae052623d01923b3 100644 --- a/configure.ac +++ b/configure.ac @@ -927,6 +927,9 @@ case "$with_cooling" in grackle) AC_DEFINE([COOLING_GRACKLE], [1], [Cooling via the grackle library]) ;; + EAGLE) + AC_DEFINE([COOLING_EAGLE], [1], [Cooling following the EAGLE model]) + ;; *) AC_MSG_ERROR([Unknown cooling function: $with_cooling]) ;; diff --git a/src/Makefile.am b/src/Makefile.am index 5107f35a17c26d21a3b875a09b2def292528fd12..690c5a0589e7cbd71ec40c2dd2bcdd53d848bd4b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -66,7 +66,7 @@ AM_SOURCES = space.c runner.c queue.c task.c cell.c engine.c \ nobase_noinst_HEADERS = align.h approx_math.h atomic.h barrier.h cycle.h error.h inline.h kernel_hydro.h kernel_gravity.h \ kernel_long_gravity.h vector.h cache.h runner_doiact.h runner_doiact_vec.h runner_doiact_grav.h runner_doiact_fft.h \ runner_doiact_nosort.h units.h intrinsics.h minmax.h kick.h timestep.h drift.h adiabatic_index.h io_properties.h \ - dimension.h equation_of_state.h part_type.h periodic.h \ + dimension.h equation_of_state.h part_type.h periodic.h memswap.h dump.h logger.h \ gravity.h gravity_io.h gravity_cache.h \ gravity/Default/gravity.h gravity/Default/gravity_iact.h gravity/Default/gravity_io.h \ gravity/Default/gravity_debug.h gravity/Default/gravity_part.h \ @@ -119,7 +119,7 @@ nobase_noinst_HEADERS = align.h approx_math.h atomic.h barrier.h cycle.h error.h cooling/const_du/cooling.h cooling/const_du/cooling_struct.h \ cooling/const_lambda/cooling.h cooling/const_lambda/cooling_struct.h \ cooling/grackle/cooling.h cooling/grackle/cooling_struct.h \ - memswap.h dump.h logger.h \ + cooling/EAGLE/cooling.h cooling/EAGLE/cooling_struct.h \ chemistry/none/chemistry.h \ chemistry/none/chemistry_io.h \ chemistry/none/chemistry_struct.h \ diff --git a/src/cooling.h b/src/cooling.h index 3d50658b9b2cf03cadb6138315b3936d3c4ea4ad..ff15d95d39f857b04ed08db43b488d5f4d8ed31f 100644 --- a/src/cooling.h +++ b/src/cooling.h @@ -36,6 +36,8 @@ #include "./cooling/const_lambda/cooling.h" #elif defined(COOLING_GRACKLE) #include "./cooling/grackle/cooling.h" +#elif defined(COOLING_EAGLE) +#include "./cooling/EAGLE/cooling.h" #else #error "Invalid choice of cooling function." #endif diff --git a/src/cooling/EAGLE/cooling.h b/src/cooling/EAGLE/cooling.h new file mode 100644 index 0000000000000000000000000000000000000000..aca68ec39b677333a0e8a2b65604f2c12c96678f --- /dev/null +++ b/src/cooling/EAGLE/cooling.h @@ -0,0 +1,129 @@ +/******************************************************************************* + * 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_H +#define SWIFT_COOLING_EAGLE_H + +/** + * @file src/cooling/none/cooling.h + * @brief Empty infrastructure for the cases without cooling function + */ + +/* Some standard headers. */ +#include <float.h> +#include <math.h> + +/* 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" + +/** + * @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"); +} + +/** + * @brief Apply the cooling function to a particle. + * + * @param phys_const The physical constants in internal units. + * @param us The internal system of units. + * @param cooling The #cooling_function_data used in the run. + * @param p Pointer to the particle data. + * @param xp Pointer to the extended particle data. + * @param dt The time-step of this particle. + */ +__attribute__((always_inline)) INLINE static void cooling_cool_part( + const struct phys_const* restrict phys_const, + const struct unit_system* restrict us, + const struct cooling_function_data* restrict cooling, + struct part* restrict p, struct xpart* restrict xp, float dt) {} + +/** + * @brief Computes the cooling time-step. + * + * @param cooling The #cooling_function_data used in the run. + * @param phys_const The physical constants in internal units. + * @param us The internal system of units. + * @param p Pointer to the particle data. + */ +__attribute__((always_inline)) INLINE static float cooling_timestep( + const struct cooling_function_data* restrict cooling, + const struct phys_const* restrict phys_const, + const struct unit_system* restrict us, const struct part* restrict p) { + + return FLT_MAX; +} + +/** + * @brief Sets the cooling properties of the (x-)particles to a valid start + * state. + * + * @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 part* restrict p, struct xpart* restrict xp, + const struct cooling_function_data* cooling) {} + +/** + * @brief Returns the total radiated energy by this particle. + * + * @param xp The extended particle data + */ +__attribute__((always_inline)) INLINE static float cooling_get_radiated_energy( + const struct xpart* restrict xp) { + + return 0.f; +} + +/** + * @brief Initialises the cooling properties. + * + * @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 cooling The cooling properties to initialize + */ +static INLINE void cooling_init_backend( + const struct swift_params* parameter_file, const struct unit_system* us, + const struct phys_const* phys_const, + struct cooling_function_data* cooling) {} + +/** + * @brief Prints the properties of the cooling model to stdout. + * + * @param cooling The properties of the cooling function. + */ +static INLINE void cooling_print_backend( + const struct cooling_function_data* cooling) { + + message("Cooling function is 'EAGLE'."); +} + +#endif /* SWIFT_COOLING_EAGLE_H */ diff --git a/src/cooling/EAGLE/cooling_struct.h b/src/cooling/EAGLE/cooling_struct.h new file mode 100644 index 0000000000000000000000000000000000000000..24c8b2088bf5b54134fde7a4a76ab3d2ae61c6ba --- /dev/null +++ b/src/cooling/EAGLE/cooling_struct.h @@ -0,0 +1,32 @@ +/******************************************************************************* + * 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_COOLING_STRUCT_EAGLE_H +#define SWIFT_COOLING_STRUCT_EAGLE_H + +/** + * @brief Properties of the cooling function. + */ +struct cooling_function_data {}; + +/** + * @brief Properties of the cooling stored in the extended particle data. + */ +struct cooling_xpart_data {}; + +#endif /* SWIFT_COOLING_STRUCT_EAGLE_H */ diff --git a/src/cooling_struct.h b/src/cooling_struct.h index c766e10b299e58e2e517f7a70b057a93bb5e0530..9c187d596e714fddaf60ae61323624569196ba70 100644 --- a/src/cooling_struct.h +++ b/src/cooling_struct.h @@ -36,6 +36,8 @@ #include "./cooling/const_lambda/cooling_struct.h" #elif defined(COOLING_GRACKLE) #include "./cooling/grackle/cooling_struct.h" +#elif defined(COOLING_EAGLE) +#include "./cooling/EAGLE/cooling_struct.h" #else #error "Invalid choice of cooling function." #endif