Commit 5559a4be authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Initialise the radiative loss counter to 0 on start-up.

parent ccdc8b06
......@@ -95,8 +95,8 @@
//#define EXTERNAL_POTENTIAL_DISK_PATCH
/* Cooling properties */
//#define COOLING_NONE
#define COOLING_CONST_DU
#define COOLING_NONE
//#define COOLING_CONST_DU
//#define COOLING_CONST_LAMBDA
//#define COOLING_GRACKLE
......
......@@ -53,6 +53,7 @@
* @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(
......@@ -103,7 +104,27 @@ __attribute__((always_inline)) INLINE static float cooling_timestep(
}
/**
* @brief Initialises the cooling properties.
* @brief Sets the cooling properties of the (x-)particles to a valid start
* state.
*
* In this case, we set the total radiated energy to 0. Note that the particle
* structure is just passed in for cases where information needs to be read
* from there.
*
* @param p Pointer to the particle data.
* @param xp Pointer to the extended particle data.
*/
__attribute__((always_inline)) INLINE static void cooling_init_part(
const struct part* restrict p, struct xpart* restrict xp) {
xp->cooling_data.radiated_energy = 0.f;
}
/**
* @brief Initialises the cooling function properties from the parameter file
*
* In this example, we just read in the values from the YAML file without
* doing any conversions or multiplying any constants in.
*
* @param parameter_file The parsed parameter file.
* @param us The current internal system of units.
......
......@@ -51,6 +51,11 @@ struct cooling_function_data {
* This is used to carry properties such as the total amount of
* energy radiated away.
*/
struct cooling_xpart_data {};
struct cooling_xpart_data {
/*! Amount of energy radiated away by this particle since the start of the run
*/
float radiated_energy;
};
#endif /* SWIFT_COOLING_STRUCT_CONST_DU_H */
......@@ -138,6 +138,19 @@ __attribute__((always_inline)) INLINE static float cooling_timestep(
return u / du_dt;
}
/**
* @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.
*/
__attribute__((always_inline)) INLINE static void cooling_init_part(
const struct part* restrict p, struct xpart* restrict xp) {
xp->cooling_data.radiated_energy = 0.f;
}
/**
* @brief Initialises the cooling properties.
*
......
......@@ -48,9 +48,14 @@ struct cooling_function_data {
float cooling_tstep_mult;
};
/**
* @brief Properties of the cooling stored in the particle data
* @brief Properties of the cooling stored in the particle data.
*/
struct cooling_xpart_data {};
struct cooling_xpart_data {
/*! Amount of energy radiated away by this particle since the start of the run */
float radiated_energy;
};
#endif /* SWIFT_COOLING_STRUCT_CONST_LAMBDA_H */
......@@ -71,6 +71,18 @@ __attribute__((always_inline)) INLINE static float cooling_timestep(
return FLT_MAX;
}
/**
* @brief Sets the cooling 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 cooling_init_part(
const struct part* restrict p, struct xpart* restrict xp) {}
/**
* @brief Initialises the cooling properties.
*
......
......@@ -42,6 +42,7 @@
/* Local headers. */
#include "atomic.h"
#include "const.h"
#include "cooling.h"
#include "engine.h"
#include "error.h"
#include "gravity.h"
......@@ -1471,6 +1472,23 @@ void space_init_parts(struct space *s) {
}
}
/**
* @brief Initialises all the extra particle data
*
* Calls cooling_init_xpart() on all the particles
*/
void space_init_xparts(struct space *s) {
const size_t nr_parts = s->nr_parts;
struct part *restrict p = s->parts;
struct xpart *restrict xp = s->xparts;
for (size_t i = 0; i < nr_parts; ++i) {
cooling_init_part(&p[i], &xp[i]);
}
}
/**
* @brief Initialises all the g-particles by setting them into a valid state
*
......@@ -1630,6 +1648,7 @@ void space_init(struct space *s, const struct swift_params *params,
/* Set the particles in a state where they are ready for a run */
space_init_parts(s);
space_init_xparts(s);
space_init_gparts(s);
/* Init the space lock. */
......
Markdown is supported
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