/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2016 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 .
*
******************************************************************************/
#ifndef SWIFT_COOLING_NONE_H
#define SWIFT_COOLING_NONE_H
/**
* @file src/cooling/none/cooling.h
* @brief Empty infrastructure for the cases without cooling function
*/
#include
/* Some standard headers. */
#include
#include
/* Local includes. */
#include "cooling_properties.h"
#include "cosmology.h"
#include "entropy_floor.h"
#include "hydro.h"
#include "hydro_properties.h"
#include "part.h"
/**
* @brief Common operations performed on the cooling function at a
* given time-step or redshift.
*
* @param cosmo The current cosmological model.
* @param cooling The #cooling_function_data used in the run.
* @param pressure_floor Properties of the pressure floor.
* @param s The #space containing all the particles.
* @param time The current system time
*/
INLINE static void cooling_update(
const struct phys_const* phys_const, const struct cosmology* cosmo,
const struct pressure_floor_props* pressure_floor,
struct cooling_function_data* cooling, struct space* s, const double time) {
// Add content if required.
}
/**
* @brief Apply the cooling function to a particle.
*
* We do nothing.
*
* @param phys_const The physical constants in internal units.
* @param us The internal system of units.
* @param cosmo The current cosmological model.
* @param hydro_props The properties of the hydro scheme.
* @param hydro_properties the hydro_props struct
* @param floor_props Properties of the entropy floor.
* @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.
* @param dt_therm The time-step operator used for thermal quantities.
* @param time The current time (since the Big Bang or start of the run) in
* internal units.
*/
__attribute__((always_inline)) INLINE static void cooling_cool_part(
const struct phys_const* phys_const, const struct unit_system* us,
const struct cosmology* cosmo, const struct hydro_props* hydro_props,
const struct entropy_floor_properties* floor_props,
const struct pressure_floor_props* pressure_floor,
const struct cooling_function_data* cooling, struct part* p,
struct xpart* xp, const float dt, const float dt_therm, const double time) {
}
/**
* @brief Computes the cooling time-step.
*
* We return FLT_MAX so as to impose no limit on the time-step.
*
* @param cooling The #cooling_function_data used in the run.
* @param phys_const The physical constants in internal units.
* @param cosmo The current cosmological model.
* @param hydro_props The properties of the hydro scheme.
* @param us The internal system of units.
* @param p Pointer to the particle data.
* @param xp Pointer to the extended data of the particle.
*/
__attribute__((always_inline)) INLINE static float cooling_timestep(
const struct cooling_function_data* restrict cooling,
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 part* restrict p,
const struct xpart* restrict xp) {
return FLT_MAX;
}
/**
* @brief Sets the cooling 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 hydro_props The properties of the hydro scheme.
* @param cosmo The current cosmological model.
* @param data The properties of the cooling function.
* @param p Pointer to the particle data.
* @param xp Pointer to the extended particle data.
*/
__attribute__((always_inline)) INLINE static void cooling_first_init_part(
const struct phys_const* restrict phys_const,
const struct unit_system* restrict us,
const struct hydro_props* hydro_props,
const struct cosmology* restrict cosmo,
const struct cooling_function_data* data, const struct part* restrict p,
struct xpart* restrict xp) {}
/**
* @brief Perform additional init on the cooling properties of the
* (x-)particles that requires the density to be known.
*
* Nothing to do here.
*
* @param phys_const The physical constant in internal units.
* @param us The unit system.
* @param hydro_props The properties of the hydro scheme.
* @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.
*/
__attribute__((always_inline)) INLINE static void cooling_post_init_part(
const struct phys_const* restrict phys_const,
const struct unit_system* restrict us,
const struct hydro_props* hydro_props,
const struct cosmology* restrict cosmo,
const struct cooling_function_data* cooling, const struct part* restrict p,
struct xpart* restrict xp) {}
/**
* @brief Compute the temperature of a #part based on the cooling function.
*
* @param phys_const #phys_const data structure.
* @param hydro_props The properties of the hydro scheme.
* @param us The internal system of units.
* @param cosmo #cosmology data structure.
* @param cooling #cooling_function_data struct.
* @param p #part data.
* @param xp Pointer to the #xpart data.
*/
INLINE static float cooling_get_temperature(
const struct phys_const* restrict phys_const,
const struct hydro_props* restrict hydro_props,
const struct unit_system* restrict us,
const struct cosmology* restrict cosmo,
const struct cooling_function_data* restrict cooling,
const struct part* restrict p, const struct xpart* restrict xp) {
/* Physical constants */
const double m_H = phys_const->const_proton_mass;
const double k_B = phys_const->const_boltzmann_k;
/* Gas properties */
const double T_transition = hydro_props->hydrogen_ionization_temperature;
const double mu_neutral = hydro_props->mu_neutral;
const double mu_ionised = hydro_props->mu_ionised;
/* Particle temperature */
const double u = hydro_get_physical_internal_energy(p, xp, cosmo);
/* Temperature over mean molecular weight */
const double T_over_mu = hydro_gamma_minus_one * u * m_H / k_B;
/* Are we above or below the HII -> HI transition? */
if (T_over_mu > (T_transition + 1.) / mu_ionised)
return T_over_mu * mu_ionised;
else if (T_over_mu < (T_transition - 1.) / mu_neutral)
return T_over_mu * mu_neutral;
else
return T_transition;
}
/**
* @brief Compute the electron pressure of a #part based on the cooling
* function.
*
* Does not exist in this model. We return 0.
*
* @param phys_const #phys_const data structure.
* @param hydro_props The properties of the hydro scheme.
* @param us The internal system of units.
* @param cosmo #cosmology data structure.
* @param cooling #cooling_function_data struct.
* @param p #part data.
* @param xp Pointer to the #xpart data.
*/
INLINE static double cooling_get_electron_pressure(
const struct phys_const* phys_const, const struct hydro_props* hydro_props,
const struct unit_system* us, const struct cosmology* cosmo,
const struct cooling_function_data* cooling, const struct part* p,
const struct xpart* xp) {
return 0.;
}
/**
* @brief Compute the y-Compton contribution of a #part based on the cooling
* function.
*
* Does not exist in this model. We return 0.
*
* @param phys_const #phys_const data structure.
* @param hydro_props The properties of the hydro scheme.
* @param us The internal system of units.
* @param cosmo #cosmology data structure.
* @param cooling #cooling_function_data struct.
* @param p #part data.
* @param xp Pointer to the #xpart data.
*/
INLINE static double cooling_get_ycompton(
const struct phys_const* phys_const, const struct hydro_props* hydro_props,
const struct unit_system* us, const struct cosmology* cosmo,
const struct cooling_function_data* cooling, const struct part* p,
const struct xpart* xp) {
return 0.f;
}
/**
* @param Returns the subgrid temperature of a particle.
*
* This model has no subgrid quantity. We return -1.
*
* @param p The particle.
* @param xp The extended particle data.
*/
INLINE static float cooling_get_subgrid_temperature(const struct part* p,
const struct xpart* xp) {
return -1.f;
}
/**
* @param Returns the subgrid density of a particle.
*
* This model has no subgrid quantity. We return -1.
*
* @param p The particle.
* @param xp The extended particle data.
*/
INLINE static float cooling_get_subgrid_density(const struct part* p,
const struct xpart* xp) {
return -1.f;
}
/**
* @brief Returns the total radiated energy by this particle.
*
* No cooling, so return 0.
*
* @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 Record the time when cooling was switched off for a particle.
*
* In none model, this function does nothing.
*
* @param p #part data.
* @param xp Pointer to the #xpart data.
* @param time The time when the cooling was switched off.
*/
INLINE static void cooling_set_part_time_cooling_off(struct part* p,
struct xpart* xp,
const double time) {}
/**
* @brief Split the coolong content of a particle into n pieces
*
* Nothing to do here.
*
* @param p The #part.
* @param xp The #xpart.
* @param n The number of pieces to split into.
*/
static INLINE void cooling_split_part(struct part* p, struct xpart* xp,
double n) {}
/**
* @brief Initialises the cooling 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 hydro_props The properties of the hydro scheme.
* @param cooling The cooling properties to initialize
*/
static INLINE void cooling_init_backend(struct swift_params* parameter_file,
const struct unit_system* us,
const struct phys_const* phys_const,
const struct hydro_props* hydro_props,
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 'No cooling'.");
}
/**
* @brief Clean-up the memory allocated for the cooling routines
*
* @param cooling the cooling data structure.
*/
static INLINE void cooling_clean(struct cooling_function_data* cooling) {}
/**
* @brief Write a cooling struct to the given FILE as a stream of bytes.
*
* Empty structure so nothing to do here.
*
* @param cooling the struct
* @param stream the file stream
*/
static INLINE void cooling_struct_dump(
const struct cooling_function_data* cooling, FILE* stream) {}
/**
* @brief Restore a hydro_props struct from the given FILE as a stream of
* bytes.
*
* Empty structure so nothing to do here.
*
* @param cooling the struct
* @param stream the file stream
* @param cosmo #cosmology structure
*/
static INLINE void cooling_struct_restore(struct cooling_function_data* cooling,
FILE* stream,
const struct cosmology* cosmo) {}
#endif /* SWIFT_COOLING_NONE_H */