Skip to content
Snippets Groups Projects
Commit a61064c2 authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Merge branch 'particle_splitting' into 'master'

Particle splitting "a la EAGLE"

See merge request !984
parents 8dafa3fb 0ac7431e
Branches
Tags
1 merge request!984Particle splitting "a la EAGLE"
Showing
with 210 additions and 70 deletions
......@@ -373,6 +373,15 @@ prevent the smoothing length from going below this value in dense
environments. This will lead to smoothing over more particles than specified
by :math:`\eta`.
The optional parameter ``particle_splitting`` (Default: 0) activates the
splitting of overly massive particles into 2. By switching this on, the code
will loop over all the particles at every tree rebuild and split the particles
with a mass above a fixed threshold into two copies that are slightly shifted
(by a randomly orientated vector of norm :math:`0.2h`). Their masses and other
relevant particle-carried quantities are then halved. The mass threshold for
splitting is set by the parameter ``particle_splitting_mass_threshold`` which is
specified using the internal unit system.
The final set of parameters in this section determine the initial and minimum
temperatures of the particles.
......@@ -399,14 +408,17 @@ The full section to start a typical cosmological run would be:
.. code:: YAML
SPH:
resolution_eta: 1.2
CFL_condition: 0.1
h_tolerance: 1e-4
h_min_ratio: 0.1
initial_temperature: 273
minimal_temperature: 100
H_mass_fraction: 0.755
H_ionization_temperature: 1e4
resolution_eta: 1.2
CFL_condition: 0.1
h_tolerance: 1e-4
h_min_ratio: 0.1
h_max: 1. # U_L
initial_temperature: 273 # U_T
minimal_temperature: 100 # U_T
H_mass_fraction: 0.755
H_ionization_temperature: 1e4 # U_T
particle_splitting: 1
particle_splitting_mass_threshold: 5e-3 # U_M
.. _Parameters_Stars:
......
......@@ -48,12 +48,14 @@ Gravity:
# Parameters for the hydrodynamics scheme
SPH:
resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel).
h_min_ratio: 0.1 # Minimal smoothing in units of softening.
h_max: 0.5 # Maximal softening in co-moving internal units.
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
minimal_temperature: 100.0 # (internal units)
initial_temperature: 268.7
resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel).
h_min_ratio: 0.1 # Minimal smoothing in units of softening.
h_max: 0.5 # Maximal softening in co-moving internal units.
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
minimal_temperature: 100.0 # (internal units)
initial_temperature: 268.7 # (internal units)
particle_splitting: 1 # Particle splitting is ON
particle_splitting_mass_threshold: 7e-4 # (internal units, i.e. 7e6 Msun ~ 4x initial gas particle mass)
# Parameters of the stars neighbour search
Stars:
......
......@@ -48,12 +48,14 @@ Gravity:
# Parameters for the hydrodynamics scheme
SPH:
resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel).
h_min_ratio: 0.1 # Minimal smoothing in units of softening.
h_max: 0.5 # Maximal softening in co-moving internal units.
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
minimal_temperature: 100.0 # (internal units)
initial_temperature: 268.7
resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel).
h_min_ratio: 0.1 # Minimal smoothing in units of softening.
h_max: 0.5 # Maximal softening in co-moving internal units.
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
minimal_temperature: 100.0 # (internal units)
initial_temperature: 268.7 # (internal units)
particle_splitting: 1 # Particle splitting is ON
particle_splitting_mass_threshold: 7e-4 # (internal units, i.e. 7e6 Msun ~ 4x initial gas particle mass)
# Parameters of the stars neighbour search
Stars:
......
......@@ -48,12 +48,14 @@ Gravity:
# Parameters for the hydrodynamics scheme
SPH:
resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel).
h_min_ratio: 0.1 # Minimal smoothing in units of softening.
h_max: 0.5 # Maximal softening in co-moving internal units.
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
minimal_temperature: 100.0 # (internal units)
initial_temperature: 268.7
resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel).
h_min_ratio: 0.1 # Minimal smoothing in units of softening.
h_max: 0.5 # Maximal softening in co-moving internal units.
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
minimal_temperature: 100.0 # (internal units)
initial_temperature: 268.7 # (internal units)
particle_splitting: 1 # Particle splitting is ON
particle_splitting_mass_threshold: 7e-4 # (internal units, i.e. 7e6 Msun ~ 4x initial gas particle mass)
# Parameters of the stars neighbour search
Stars:
......
......@@ -11,6 +11,9 @@ the following changes have been made:
been changed to 1.79 ckpc. This follows the recommendations of
Ludlow et al. 2019. Old values were 0.7 pkpc and 2.69 ckpc for
all the particle species.
- SPH particles with a mass larger than 7*10^6 Msun (~4x the initial
gas particle mass) are now split into 2 equal mass particles
within the smoothing length of the original particle.
- The metallicity-dependent density threshold for star formation
uses the smoothed metallicities and not the raw metallicities
any more.
......
......@@ -54,11 +54,13 @@ Gravity:
# Parameters for the hydrodynamics scheme
SPH:
resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel).
h_min_ratio: 0.1 # Minimal smoothing in units of softening.
h_max: 0.5 # Maximal softening in co-moving internal units.
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
minimal_temperature: 100 # (internal units)
resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel).
h_min_ratio: 0.1 # Minimal smoothing in units of softening.
h_max: 0.5 # Maximal softening in co-moving internal units.
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
minimal_temperature: 100 # (internal units)
particle_splitting: 1
particle_splitting_mass_threshold: 7e-4 # Internal units (i.e. 7e6 Msun ~ 4 times the initial gas mass)
# Parameters of the stars neighbour search
Stars:
......
......@@ -62,11 +62,13 @@ Gravity:
# Parameters for the hydrodynamics scheme
SPH:
resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel).
h_min_ratio: 0.1 # Minimal smoothing in units of softening.
h_max: 0.5 # Maximal softening in co-moving internal units.
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
minimal_temperature: 100 # (internal units)
resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel).
h_min_ratio: 0.1 # Minimal smoothing in units of softening.
h_max: 0.5 # Maximal softening in co-moving internal units.
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
minimal_temperature: 100 # (internal units)
particle_splitting: 1
particle_splitting_mass_threshold: 7e-4 # Internal units (i.e. 7e6 Msun ~ 4 times the initial gas mass)
# Parameters of the stars neighbour search
Stars:
......
......@@ -53,11 +53,13 @@ Gravity:
# Parameters for the hydrodynamics scheme
SPH:
resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel).
h_min_ratio: 0.1 # Minimal smoothing in units of softening.
h_max: 0.5 # Maximal softening in co-moving internal units.
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
minimal_temperature: 100 # (internal units)
resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel).
h_min_ratio: 0.1 # Minimal smoothing in units of softening.
h_max: 0.5 # Maximal softening in co-moving internal units.
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
minimal_temperature: 100 # (internal units)
particle_splitting: 1
particle_splitting_mass_threshold: 7e-4 # Internal units (i.e. 7e6 Msun ~ 4 times the initial gas mass)
# Parameters of the stars neighbour search
Stars:
......
......@@ -63,11 +63,13 @@ Gravity:
# Parameters for the hydrodynamics scheme
SPH:
resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel).
h_min_ratio: 0.1 # Minimal smoothing in units of softening.
h_max: 0.5 # Maximal softening in co-moving internal units.
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
minimal_temperature: 100 # (internal units)
resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel).
h_min_ratio: 0.1 # Minimal smoothing in units of softening.
h_max: 0.5 # Maximal softening in co-moving internal units.
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
minimal_temperature: 100 # (internal units)
particle_splitting: 1
particle_splitting_mass_threshold: 7e-4 # Internal units (i.e. 7e6 Msun ~ 4 times the initial gas mass)
# Parameters of the stars neighbour search
Stars:
......
......@@ -28,26 +28,28 @@ Cosmology:
# Parameters for the hydrodynamics scheme
SPH:
resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel).
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
use_mass_weighted_num_ngb: 0 # (Optional) Are we using the mass-weighted definition of the number of neighbours?
h_tolerance: 1e-4 # (Optional) Relative accuracy of the Netwon-Raphson scheme for the smoothing lengths.
h_max: 10. # (Optional) Maximal allowed smoothing length in internal units. Defaults to FLT_MAX if unspecified.
h_min_ratio: 0. # (Optional) Minimal allowed smoothing length in units of the softening. Defaults to 0 if unspecified.
max_volume_change: 1.4 # (Optional) Maximal allowed change of kernel volume over one time-step.
max_ghost_iterations: 30 # (Optional) Maximal number of iterations allowed to converge towards the smoothing length.
initial_temperature: 0 # (Optional) Initial temperature (in internal units) to set the gas particles at start-up. Value is ignored if set to 0.
minimal_temperature: 0 # (Optional) Minimal temperature (in internal units) allowed for the gas particles. Value is ignored if set to 0.
H_mass_fraction: 0.755 # (Optional) Hydrogen mass fraction used for initial conversion from temp to internal energy. Default value is derived from the physical constants.
H_ionization_temperature: 1e4 # (Optional) Temperature of the transition from neutral to ionized Hydrogen for primoridal gas.
viscosity_alpha: 0.8 # (Optional) Override for the initial value of the artificial viscosity. In schemes that have a fixed AV, this remains as alpha throughout the run.
viscosity_alpha_max: 2.0 # (Optional) Maximal value for the artificial viscosity in schemes that allow alpha to vary.
viscosity_alpha_min: 0.1 # (Optional) Minimal value for the artificial viscosity in schemes that allow alpha to vary.
viscosity_length: 0.1 # (Optional) Decay length for the artificial viscosity in schemes that allow alpha to vary.
diffusion_alpha: 0.0 # (Optional) Override the initial value for the thermal diffusion coefficient in schemes with thermal diffusion.
diffusion_beta: 0.01 # (Optional) Override the decay/rise rate tuning parameter for the thermal diffusion.
diffusion_alpha_max: 1.0 # (Optional) Override the maximal thermal diffusion coefficient that is allowed for a given particle.
diffusion_alpha_min: 0.0 # (Optional) Override the minimal thermal diffusion coefficient that is allowed for a given particle.
resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel).
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
use_mass_weighted_num_ngb: 0 # (Optional) Are we using the mass-weighted definition of the number of neighbours?
h_tolerance: 1e-4 # (Optional) Relative accuracy of the Netwon-Raphson scheme for the smoothing lengths.
h_max: 10. # (Optional) Maximal allowed smoothing length in internal units. Defaults to FLT_MAX if unspecified.
h_min_ratio: 0. # (Optional) Minimal allowed smoothing length in units of the softening. Defaults to 0 if unspecified.
max_volume_change: 1.4 # (Optional) Maximal allowed change of kernel volume over one time-step.
max_ghost_iterations: 30 # (Optional) Maximal number of iterations allowed to converge towards the smoothing length.
particle_splitting: 1 # (Optional) Are we splitting particles that are too massive (default: 0)
particle_splitting_mass_threshold: 7e-4 # (Optional) Mass threshold for particle splitting (in internal units)
initial_temperature: 0 # (Optional) Initial temperature (in internal units) to set the gas particles at start-up. Value is ignored if set to 0.
minimal_temperature: 0 # (Optional) Minimal temperature (in internal units) allowed for the gas particles. Value is ignored if set to 0.
H_mass_fraction: 0.755 # (Optional) Hydrogen mass fraction used for initial conversion from temp to internal energy. Default value is derived from the physical constants.
H_ionization_temperature: 1e4 # (Optional) Temperature of the transition from neutral to ionized Hydrogen for primoridal gas.
viscosity_alpha: 0.8 # (Optional) Override for the initial value of the artificial viscosity. In schemes that have a fixed AV, this remains as alpha throughout the run.
viscosity_alpha_max: 2.0 # (Optional) Maximal value for the artificial viscosity in schemes that allow alpha to vary.
viscosity_alpha_min: 0.1 # (Optional) Minimal value for the artificial viscosity in schemes that allow alpha to vary.
viscosity_length: 0.1 # (Optional) Decay length for the artificial viscosity in schemes that allow alpha to vary.
diffusion_alpha: 0.0 # (Optional) Override the initial value for the thermal diffusion coefficient in schemes with thermal diffusion.
diffusion_beta: 0.01 # (Optional) Override the decay/rise rate tuning parameter for the thermal diffusion.
diffusion_alpha_max: 1.0 # (Optional) Override the maximal thermal diffusion coefficient that is allowed for a given particle.
diffusion_alpha_min: 0.0 # (Optional) Override the minimal thermal diffusion coefficient that is allowed for a given particle.
# Parameters of the stars neighbour search
Stars:
......
......@@ -76,7 +76,7 @@ AM_SOURCES = space.c runner_main.c runner_doiact_hydro.c runner_doiact_limiter.c
runner_doiact_stars.c runner_doiact_black_holes.c runner_ghost.c runner_recv.c \
runner_sort.c runner_drift.c runner_black_holes.c runner_time_integration.c \
runner_doiact_hydro_vec.c runner_others.c\
queue.c task.c cell.c engine.c engine_maketasks.c \
queue.c task.c cell.c engine.c engine_maketasks.c engine_split_particles.c \
engine_marktasks.c engine_drift.c engine_unskip.c engine_collect_end_of_step.c \
engine_redistribute.c engine_fof.c serial_io.c timers.c debug.c scheduler.c \
proxy.c parallel_io.c units.c common_io.c single_io.c multipole.c version.c map.c \
......
......@@ -403,6 +403,21 @@ __attribute__((always_inline)) INLINE static void chemistry_add_bpart_to_bpart(
bp_data->iron_mass_from_SNIa += swallowed_data->iron_mass_from_SNIa;
}
/**
* @brief Split the metal content of a particle into n pieces
*
* We only need to split the fields that are not fractions.
*
* @param p The #part.
* @param n The number of pieces to split into.
*/
__attribute__((always_inline)) INLINE static void chemistry_split_part(
struct part* p, const double n) {
p->chemistry_data.mass_from_SNIa /= n;
p->chemistry_data.mass_from_SNII /= n;
p->chemistry_data.mass_from_AGB /= n;
}
/**
* @brief Returns the total metallicity (metal mass fraction) of the
* star particle to be used in feedback/enrichment related routines.
......
......@@ -229,7 +229,9 @@ __attribute__((always_inline)) INLINE static void chemistry_first_init_spart(
*/
__attribute__((always_inline)) INLINE static void chemistry_bpart_from_part(
struct chemistry_bpart_data* bp_data,
const struct chemistry_part_data* p_data, const double gas_mass) {}
const struct chemistry_part_data* p_data, const double gas_mass) {
error("Loic: to be implemented");
}
/**
* @brief Add the chemistry data of a gas particle to a black hole.
......@@ -242,7 +244,9 @@ __attribute__((always_inline)) INLINE static void chemistry_bpart_from_part(
*/
__attribute__((always_inline)) INLINE static void chemistry_add_part_to_bpart(
struct chemistry_bpart_data* bp_data,
const struct chemistry_part_data* p_data, const double gas_mass) {}
const struct chemistry_part_data* p_data, const double gas_mass) {
error("Loic: to be implemented");
}
/**
* @brief Add the chemistry data of a black hole to another one.
......@@ -254,6 +258,19 @@ __attribute__((always_inline)) INLINE static void chemistry_add_part_to_bpart(
*/
__attribute__((always_inline)) INLINE static void chemistry_add_bpart_to_bpart(
struct chemistry_bpart_data* bp_data,
const struct chemistry_bpart_data* swallowed_data) {}
const struct chemistry_bpart_data* swallowed_data) {
error("Loic: to be implemented");
}
/**
* @brief Split the metal content of a particle into n pieces
*
* @param p The #part.
* @param n The number of pieces to split into.
*/
__attribute__((always_inline)) INLINE static void chemistry_split_part(
struct part* p, const double n) {
error("Loic: to be implemented");
}
#endif /* SWIFT_CHEMISTRY_GEAR_H */
......@@ -214,6 +214,17 @@ __attribute__((always_inline)) INLINE static void chemistry_add_bpart_to_bpart(
struct chemistry_bpart_data* bp_data,
const struct chemistry_bpart_data* swallowed_data) {}
/**
* @brief Split the metal content of a particle into n pieces
*
* Nothing to do here.
*
* @param p The #part.
* @param n The number of pieces to split into.
*/
__attribute__((always_inline)) INLINE static void chemistry_split_part(
struct part* p, const double n) {}
/**
* @brief Returns the total metallicity (metal mass fraction) of the
* star particle to be used in feedback/enrichment related routines.
......
......@@ -308,6 +308,19 @@ __attribute__((always_inline)) INLINE static float cooling_get_radiated_energy(
return xp->cooling_data.radiated_energy;
}
/**
* @brief Split the coolong content of a particle into n pieces
*
* @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) {
xp->cooling_data.radiated_energy /= n;
}
/**
* @brief Initialises the cooling properties.
*
......
......@@ -642,6 +642,18 @@ __attribute__((always_inline)) INLINE float cooling_get_radiated_energy(
return xp->cooling_data.radiated_energy;
}
/**
* @brief Split the coolong content of a particle into n pieces
*
* @param p The #part.
* @param xp The #xpart.
* @param n The number of pieces to split into.
*/
void cooling_split_part(struct part *p, struct xpart *xp, double n) {
xp->cooling_data.radiated_energy /= n;
}
/**
* @brief Inject a fixed amount of energy to each particle in the simulation
* to mimic Hydrogen reionization.
......
......@@ -71,6 +71,8 @@ float cooling_get_temperature(
float cooling_get_radiated_energy(const struct xpart *restrict xp);
void cooling_split_part(struct part *p, struct xpart *xp, double n);
void cooling_Hydrogen_reionization(const struct cooling_function_data *cooling,
const struct cosmology *cosmo,
struct space *s);
......
......@@ -226,6 +226,19 @@ __attribute__((always_inline)) INLINE static float cooling_get_radiated_energy(
return xp->cooling_data.radiated_energy;
}
/**
* @brief Split the coolong content of a particle into n pieces
*
* @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) {
xp->cooling_data.radiated_energy /= n;
}
/**
* @brief Initialises the cooling function properties from the parameter file
*
......
......@@ -302,6 +302,19 @@ __attribute__((always_inline)) INLINE static float cooling_get_radiated_energy(
return xp->cooling_data.radiated_energy;
}
/**
* @brief Split the coolong content of a particle into n pieces
*
* @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) {
xp->cooling_data.radiated_energy /= n;
}
/**
* @brief Initialises the cooling properties.
*
......
......@@ -763,6 +763,19 @@ __attribute__((always_inline)) INLINE static float cooling_timestep(
return FLT_MAX;
}
/**
* @brief Split the coolong content of a particle into n pieces
*
* @param p The #part.
* @param xp The #xpart.
* @param n The number of pieces to split into.
*/
INLINE static void cooling_split_part(struct part* p, struct xpart* xp,
double n) {
error("Loic: to be implemented");
}
/**
* @brief Initialises the cooling unit system.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment