Commit 43be4281 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Move the SF tracers struct into the same folder as the SF model. They always go together.

parent ffc8fd98
......@@ -1188,7 +1188,6 @@ with_subgrid_entropy_floor=none
with_subgrid_stars=none
with_subgrid_star_formation=none
with_subgrid_feedback=none
with_subgrid_sftracers=none
case "$with_subgrid" in
yes)
......@@ -1204,7 +1203,6 @@ case "$with_subgrid" in
with_subgrid_stars=GEAR
with_subgrid_star_formation=none
with_subgrid_feedback=thermal
with_subgrid_sftracers=none
;;
EAGLE)
with_subgrid_cooling=EAGLE
......@@ -1214,7 +1212,6 @@ case "$with_subgrid" in
with_subgrid_stars=EAGLE
with_subgrid_star_formation=EAGLE
with_subgrid_feedback=none
with_subgrid_sftracers=EAGLE
;;
*)
AC_MSG_ERROR([Unknown subgrid choice: $with_subgrid])
......@@ -1579,35 +1576,6 @@ case "$with_tracers" in
;;
esac
# Particle Star formation tracers
AC_ARG_WITH([sftracers],
[AS_HELP_STRING([--with-sftracers=<function>],
[star formation tracer function @<:@none, EAGLE default: none@:>@]
)],
[with_sftracers="$withval"],
[with_sftracers="none"]
)
if test "$with_subgrid" != "none"; then
if test "$with_sftracers" != "none"; then
AC_MSG_ERROR([Cannot provide with-subgrid and with-sftracers together])
else
with_sftracers="$with_subgrid_sftracers"
fi
fi
case "$with_sftracers" in
none)
AC_DEFINE([SFTRACERS_NONE], [1], [No star formation tracers function])
;;
EAGLE)
AC_DEFINE([SFTRACERS_EAGLE], [1], [Star Formation tracers taken from the EAGLE model])
;;
*)
AC_MSG_ERROR([Unknown star formation tracers choice: $with_tracers])
;;
esac
# Stellar model.
AC_ARG_WITH([stars],
[AS_HELP_STRING([--with-stars=<model>],
......@@ -1858,14 +1826,13 @@ AC_MSG_RESULT([
Make gravity glass : $gravity_glass_making
External potential : $with_potential
Entropy floor : $with_entropy_floor
Cooling function : $with_cooling
Chemistry : $with_chemistry
Tracers : $with_tracers
Star Formation Tracers : $with_sftracers
Stellar model : $with_stars
Star formation model : $with_star_formation
Feedback model : $with_feedback
Entropy floor : $with_entropy_floor
Cooling function : $with_cooling
Chemistry : $with_chemistry
Tracers : $with_tracers
Stellar model : $with_stars
Star formation model : $with_star_formation
Feedback model : $with_feedback
Individual timers : $enable_timers
Task debugging : $enable_task_debugging
......
......@@ -49,8 +49,8 @@ include_HEADERS = space.h runner.h queue.h task.h lock.h cell.h part.h const.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 space_getsid.h utilities.h \
mesh_gravity.h cbrt.h exp10.h velociraptor_interface.h swift_velociraptor_part.h outputlist.h \
logger_io.h tracers_io.h tracers.h tracers_struct.h sftracers_io.h sftracers.h \
sftracers_struct.h star_formation.h velociraptor_struct.h velociraptor_io.h
logger_io.h tracers_io.h tracers.h tracers_struct.h star_formation_io.h \
star_formation_struct.h star_formation.h velociraptor_struct.h velociraptor_io.h
# source files for EAGLE cooling
EAGLE_COOLING_SOURCES =
......@@ -141,7 +141,10 @@ nobase_noinst_HEADERS = align.h approx_math.h atomic.h barrier.h cycle.h error.h
potential/none/potential.h potential/point_mass/potential.h \
potential/isothermal/potential.h potential/disc_patch/potential.h \
potential/sine_wave/potential.h \
star_formation/none/star_formation.h star_formation/schaye08/star_formation.h \
star_formation/none/star_formation.h star_formation/none/star_formation_struct.h \
star_formation/none/star_formation_io.h \
star_formation/EAGLE/star_formation.h star_formation/EAGLE/star_formation_struct.h \
star_formation/EAGLE/star_formation_io.h \
cooling/none/cooling.h cooling/none/cooling_struct.h \
cooling/none/cooling_io.h \
cooling/Compton/cooling.h cooling/Compton/cooling_struct.h \
......@@ -171,9 +174,7 @@ nobase_noinst_HEADERS = align.h approx_math.h atomic.h barrier.h cycle.h error.h
tracers/none/tracers.h tracers/none/tracers_struct.h \
tracers/none/tracers_io.h \
tracers/EAGLE/tracers.h tracers/EAGLE/tracers_struct.h \
tracers/EAGLE/tracers_io.h \
sftracers/none/sftracers.h sftracers/none/sftracers_struct.h \
sftracers/none/sftracers_io.h
tracers/EAGLE/tracers_io.h
# Sources and flags for regular library
......
......@@ -34,7 +34,7 @@
#include "chemistry_struct.h"
#include "cooling_struct.h"
#include "logger.h"
#include "sftracers_struct.h"
#include "star_formation_struct.h"
#include "tracers_struct.h"
/* Extra particle data not needed during the SPH loops over neighbours. */
......@@ -62,7 +62,7 @@ struct xpart {
struct tracers_xpart_data tracers_data;
/* Additional data used by the tracers */
struct sftracers_xpart_data sftracers_data;
struct star_formation_xpart_data sf_data;
#ifdef WITH_LOGGER
/* Additional data for the particle logger */
......
......@@ -52,7 +52,7 @@
#include "kernel_hydro.h"
#include "part.h"
#include "part_type.h"
#include "sftracers_io.h"
#include "star_formation_io.h"
#include "stars_io.h"
#include "tracers_io.h"
#include "units.h"
......@@ -1069,7 +1069,6 @@ void prepare_file(struct engine* e, const char* baseName, long long N_total[6],
cooling_write_flavour(h_grp, e->cooling_func);
chemistry_write_flavour(h_grp);
tracers_write_flavour(h_grp);
sftracers_write_flavour(h_grp);
H5Gclose(h_grp);
/* Print the gravity parameters */
......@@ -1156,7 +1155,7 @@ void prepare_file(struct engine* e, const char* baseName, long long N_total[6],
}
num_fields += tracers_write_particles(parts, xparts, list + num_fields,
with_cosmology);
num_fields += sftracers_write_particles(
num_fields += star_formation_write_particles(
parts, xparts, list + num_fields, with_cosmology);
if (with_stf) {
num_fields +=
......@@ -1479,7 +1478,7 @@ void write_output_parallel(struct engine* e, const char* baseName,
}
num_fields += tracers_write_particles(
parts, xparts, list + num_fields, with_cosmology);
num_fields += sftracers_write_particles(
num_fields += star_formation_write_particles(
parts, xparts, list + num_fields, with_cosmology);
} else {
......@@ -1515,7 +1514,7 @@ void write_output_parallel(struct engine* e, const char* baseName,
}
num_fields += tracers_write_particles(
parts_written, xparts_written, list + num_fields, with_cosmology);
num_fields += sftracers_write_particles(
num_fields += star_formation_write_particles(
parts_written, xparts_written, list + num_fields, with_cosmology);
}
} break;
......
......@@ -52,7 +52,7 @@
#include "kernel_hydro.h"
#include "part.h"
#include "part_type.h"
#include "sftracers_io.h"
#include "star_formation_io.h"
#include "stars_io.h"
#include "tracers_io.h"
#include "units.h"
......@@ -931,7 +931,6 @@ void write_output_serial(struct engine* e, const char* baseName,
cooling_write_flavour(h_grp, e->cooling_func);
chemistry_write_flavour(h_grp);
tracers_write_flavour(h_grp);
sftracers_write_flavour(h_grp);
H5Gclose(h_grp);
/* Print the gravity parameters */
......@@ -1124,7 +1123,7 @@ void write_output_serial(struct engine* e, const char* baseName,
}
num_fields += tracers_write_particles(
parts, xparts, list + num_fields, with_cosmology);
num_fields += sftracers_write_particles(
num_fields += star_formation_write_particles(
parts, xparts, list + num_fields, with_cosmology);
} else {
......@@ -1161,9 +1160,9 @@ void write_output_serial(struct engine* e, const char* baseName,
num_fields +=
tracers_write_particles(parts_written, xparts_written,
list + num_fields, with_cosmology);
num_fields +=
sftracers_write_particles(parts_written, xparts_written,
list + num_fields, with_cosmology);
num_fields += star_formation_write_particles(
parts_written, xparts_written, list + num_fields,
with_cosmology);
}
} break;
......
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2019 Folkert Nobels (nobels@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_SFTRACERS_H
#define SWIFT_SFTRACERS_H
/**
* @file src/sftracers.h
* @brief Branches between the different particle data star formation tracers
*/
/* Config parameters. */
#include "../config.h"
/* Import the right cooling definition */
#if defined(SFTRACERS_NONE)
#include "./sftracers/none/sftracers.h"
#elif defined(SFTRACERS_EAGLE)
#include "./sftracers/EAGLE/sftracers.h"
#else
#error "Invalid choice of star formation tracers."
#endif
#endif /* SWIFT_SFTRACERS_H */
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2018 Folkert Nobels (nobels@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_SFTRACERS_EAGLE_H
#define SWIFT_SFTRACERS_EAGLE_H
/* Config parameters. */
#include "../config.h"
/* Local includes */
#include "cooling.h"
#include "part.h"
#include "sftracers_struct.h"
/**
* @brief Update the particle tracers just after it has been initialised at the
* start of a step.
*
* Nothing to do here in the EAGLE model.
*
* @param us The internal system of units.
* @param phys_const The physical constants in internal units.
* @param cosmo The current cosmological model.
* @param hydro_props the hydro_props struct
* @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 (containing the tracers
* struct).
*/
static INLINE void sftracers_after_init(
const struct part *p, struct xpart *xp, const struct unit_system *us,
const struct phys_const *phys_const, const int with_cosmology,
const struct cosmology *cosmo, const struct hydro_props *hydro_props,
const struct cooling_function_data *cooling, const double time) {}
/**
* @brief Update the particle tracers just after it has been drifted.
*
* Nothing to do here in the EAGLE model.
*
* @param us The internal system of units.
* @param phys_const The physical constants in internal units.
* @param cosmo The current cosmological model.
* @param hydro_props the hydro_props struct
* @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 (containing the tracers
* struct).
*/
static INLINE void sftracers_after_drift(
const struct part *p, struct xpart *xp, const struct unit_system *us,
const struct phys_const *phys_const, const int with_cosmology,
const struct cosmology *cosmo, const struct hydro_props *hydro_props,
const struct cooling_function_data *cooling, const double time) {}
/**
* @brief Update the particle tracers just after its time-step has been
* computed.
*
* Nothing to do here in the EAGLE model.
*
* @param us The internal system of units.
* @param phys_const The physical constants in internal units.
* @param cosmo The current cosmological model.
* @param hydro_props the hydro_props struct
* @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 (containing the tracers
* struct).
*/
static INLINE void sftracers_after_timestep(
const struct part *p, struct xpart *xp, const struct unit_system *us,
const struct phys_const *phys_const, const int with_cosmology,
const struct cosmology *cosmo, const struct hydro_props *hydro_props,
const struct cooling_function_data *cooling, const double time) {}
/**
* @brief Update the particle tracers just after its time-step has been
* computed.
*
* Nothing to do here in the EAGLE model.
*
* @param us The internal system of units.
* @param phys_const The physical constants in internal units.
* @param cosmo The current cosmological model.
* @param hydro_props the hydro_props struct
* @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 (containing the tracers
* struct).
*/
static INLINE void sftracers_first_init_xpart(
const struct part *p, struct xpart *xp, const struct unit_system *us,
const struct phys_const *phys_const, const struct cosmology *cosmo,
const struct hydro_props *hydro_props,
const struct cooling_function_data *cooling) {}
#endif /* SWIFT_SFTRACERS_EAGLE_H */
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2018 Folkert Nobels (nobels@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_SFTRACERS_NONE_H
#define SWIFT_SFTRACERS_NONE_H
/* Config parameters. */
#include "../config.h"
/* Local includes */
#include "cooling.h"
#include "part.h"
#include "sftracers_struct.h"
/**
* @brief Update the particle tracers just after it has been initialised at the
* start of a step.
*
* Nothing to do here in the EAGLE model.
*
* @param us The internal system of units.
* @param phys_const The physical constants in internal units.
* @param cosmo The current cosmological model.
* @param hydro_props the hydro_props struct
* @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 (containing the tracers
* struct).
*/
static INLINE void sftracers_after_init(
const struct part *p, struct xpart *xp, const struct unit_system *us,
const struct phys_const *phys_const, const int with_cosmology,
const struct cosmology *cosmo, const struct hydro_props *hydro_props,
const struct cooling_function_data *cooling, const double time) {}
/**
* @brief Update the particle tracers just after it has been drifted.
*
* Nothing to do here in the EAGLE model.
*
* @param us The internal system of units.
* @param phys_const The physical constants in internal units.
* @param cosmo The current cosmological model.
* @param hydro_props the hydro_props struct
* @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 (containing the tracers
* struct).
*/
static INLINE void sftracers_after_drift(
const struct part *p, struct xpart *xp, const struct unit_system *us,
const struct phys_const *phys_const, const int with_cosmology,
const struct cosmology *cosmo, const struct hydro_props *hydro_props,
const struct cooling_function_data *cooling, const double time) {}
/**
* @brief Update the particle tracers just after its time-step has been
* computed.
*
* Nothing to do here in the EAGLE model.
*
* @param us The internal system of units.
* @param phys_const The physical constants in internal units.
* @param cosmo The current cosmological model.
* @param hydro_props the hydro_props struct
* @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 (containing the tracers
* struct).
*/
static INLINE void sftracers_after_timestep(
const struct part *p, struct xpart *xp, const struct unit_system *us,
const struct phys_const *phys_const, const int with_cosmology,
const struct cosmology *cosmo, const struct hydro_props *hydro_props,
const struct cooling_function_data *cooling, const double time) {}
/**
* @brief Update the particle tracers just after its time-step has been
* computed.
*
* Nothing to do here in the EAGLE model.
*
* @param us The internal system of units.
* @param phys_const The physical constants in internal units.
* @param cosmo The current cosmological model.
* @param hydro_props the hydro_props struct
* @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 (containing the tracers
* struct).
*/
static INLINE void sftracers_first_init_xpart(
const struct part *p, struct xpart *xp, const struct unit_system *us,
const struct phys_const *phys_const, const struct cosmology *cosmo,
const struct hydro_props *hydro_props,
const struct cooling_function_data *cooling) {}
#endif /* SWIFT_SFTRACERS_NONE_H */
......@@ -51,7 +51,7 @@
#include "kernel_hydro.h"
#include "part.h"
#include "part_type.h"
#include "sftracers_io.h"
#include "star_formation_io.h"
#include "stars_io.h"
#include "tracers_io.h"
#include "units.h"
......@@ -783,7 +783,6 @@ void write_output_single(struct engine* e, const char* baseName,
cooling_write_flavour(h_grp, e->cooling_func);
chemistry_write_flavour(h_grp);
tracers_write_flavour(h_grp);
sftracers_write_flavour(h_grp);
H5Gclose(h_grp);
/* Print the gravity parameters */
......@@ -927,7 +926,7 @@ void write_output_single(struct engine* e, const char* baseName,
}
num_fields += tracers_write_particles(
parts, xparts, list + num_fields, with_cosmology);
num_fields += sftracers_write_particles(
num_fields += star_formation_write_particles(
parts, xparts, list + num_fields, with_cosmology);
} else {
......@@ -963,7 +962,7 @@ void write_output_single(struct engine* e, const char* baseName,
}
num_fields += tracers_write_particles(
parts_written, xparts_written, list + num_fields, with_cosmology);
num_fields += sftracers_write_particles(
num_fields += star_formation_write_particles(
parts_written, xparts_written, list + num_fields, with_cosmology);
}
} break;
......
......@@ -251,8 +251,8 @@ INLINE static int star_formation_convert_to_star(
}
/* Store the SFR */
xp->sftracers_data.SFR = SFRpergasmass * p->mass;
xp->sftracers_data.sSFR = SFRpergasmass;
xp->sf_data.SFR = SFRpergasmass * p->mass;
xp->sf_data.sSFR = SFRpergasmass;
/* Calculate the propability of forming a star */
const double prop = SFRpergasmass * dt_star;
......@@ -270,13 +270,13 @@ INLINE static int star_formation_convert_to_star(
}
/* Check if it is the first time steps after star formation */
if (xp->sftracers_data.SFR > 0.f) {
if (xp->sf_data.SFR > 0.f) {
if (with_cosmology) {
xp->sftracers_data.SFR = -cosmo->a;
xp->sftracers_data.sSFR = 0.f;
xp->sf_data.SFR = -cosmo->a;
xp->sf_data.sSFR = 0.f;
} else {
xp->sftracers_data.SFR = -e->time;
xp->sftracers_data.sSFR = 0.f;
xp->sf_data.SFR = -e->time;
xp->sf_data.sSFR = 0.f;
}
}
......
......@@ -16,30 +16,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#ifndef SWIFT_SFTRACERS_EAGLE_IO_H
#define SWIFT_SFTRACERS_EAGLE_IO_H
#ifndef SWIFT_STAR_FORMATION_EAGLE_IO_H
#define SWIFT_STAR_FORMATION_EAGLE_IO_H
/* Config parameters. */
#include "../config.h"
/* Local includes */
#include "io_properties.h"
#include "tracers.h"
#ifdef HAVE_HDF5
/**
* @brief Writes the current model of tracers to the file.
*
* @param h_grp The HDF5 group in which to write
* @param tracers The #tracers_function_data
*/
__attribute__((always_inline)) INLINE static void sftracers_write_flavour(
hid_t h_grp) {
io_write_attribute_s(h_grp, "Star formation tracers", "EAGLE");
}
#endif
/**
* @brief Specifies which particle fields to write to a dataset
......@@ -50,17 +34,17 @@ __attribute__((always_inline)) INLINE static void sftracers_write_flavour(
*
* @return Returns the number of fields to write.
*/
__attribute__((always_inline)) INLINE static int sftracers_write_particles(
__attribute__((always_inline)) INLINE static int star_formation_write_particles(
const struct part* parts, const struct xpart* xparts, struct io_props* list,
const int with_cosmology) {
list[0] = io_make_output_field("SFR", FLOAT, 1, UNIT_CONV_SFR, xparts,
sftracers_data.SFR);
list[0] =
io_make_output_field("SFR", FLOAT, 1, UNIT_CONV_SFR, xparts, sf_data.SFR);
list[1] = io_make_output_field("sSFR", FLOAT, 1, UNIT_CONV_SSFR, xparts,
sftracers_data.sSFR);
sf_data.sSFR);
return 2;
}
#endif /* SWIFT_SFTRACERS_EAGLE_IO_H */
#endif /* SWIFT_STAR_FORMATION_EAGLE_IO_H */
......@@ -16,13 +16,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#ifndef SWIFT_SFTRACERS_STRUCT_EAGLE_H
#define SWIFT_SFTRACERS_STRUCT_EAGLE_H
#ifndef SWIFT_EAGLE_STAR_FORMATION_STRUCT_H
#define SWIFT_EAGLE_STAR_FORMATION_STRUCT_H
/**
* @brief Properties of the tracers stored in the extended particle data.
*/
struct sftracers_xpart_data {
struct star_formation_xpart_data {
/*! Star formation rate */
float SFR;
......@@ -30,4 +31,4 @@ struct sftracers_xpart_data {
float sSFR;
};
#endif /* SWIFT_SFTRACERS_STRUCT_EAGLE_H */
#endif /* SWIFT_EAGLE_STAR_FORMATION_STRUCT_H */
......@@ -16,30 +16,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*