Skip to content
Snippets Groups Projects
Commit 9d95c26c authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Implement an optional minimal smoothing length based on the softening of the particle

parent 97f3111f
No related branches found
No related tags found
No related merge requests found
Showing
with 44 additions and 21 deletions
......@@ -49,6 +49,7 @@ 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.
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
minimal_temperature: 100 # (internal units)
......
......@@ -47,6 +47,7 @@ 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.
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
minimal_temperature: 100 # (internal units)
......
......@@ -54,6 +54,7 @@ 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.
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
minimal_temperature: 100 # (internal units)
......
......@@ -49,6 +49,7 @@ 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.
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
minimal_temperature: 100 # (internal units)
......
......@@ -58,6 +58,7 @@ 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.
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
minimal_temperature: 100 # (internal units)
......
......@@ -11,13 +11,13 @@ Gravity:
mesh_side_length: 32 # Number of cells along each axis for the periodic gravity mesh.
eta: 0.025 # Constant dimensionless multiplier for time integration.
theta: 0.7 # Opening angle (Multipole acceptance criterion).
comoving_softening: 0.01 # Comoving softening length (in internal units).
max_physical_softening: 0.01 # Physical softening length (in internal units).
comoving_softening: 0.01 # Comoving softening length (in internal units).
max_physical_softening: 0.01 # Physical softening length (in internal units).
# Parameters governing the time integration (Set dt_min and dt_max to the same value for a fixed time-step run.)
TimeIntegration:
time_begin: 0. # The starting time of the simulation (in internal units).
time_end: 0.1 # The end time of the simulation (in internal units).
time_end: 0.1 # The end time of the simulation (in internal units).
dt_min: 1e-9 # The minimal time-step size of the simulation (in internal units).
dt_max: 1e-2 # The maximal time-step size of the simulation (in internal units).
......@@ -35,20 +35,17 @@ Statistics:
# Parameters related to the initial conditions
InitialConditions:
file_name: fid.hdf5 # The file to read
file_name: fid.hdf5 # The file to read
periodic: 0 # Are we running with periodic ICs?
# 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.
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.
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.
minimal_temperature: 100 # (Optional) Minimal temperature (in internal units) allowed for the gas particles. Value is ignored if set to 0.
H_ionization_temperature: 1e4 # (Optional) Temperature of the transition from neutral to ionized Hydrogen for primoridal gas.
h_min_ratio: 0.1 # Minimal smoothing in units of softening.
h_max: 10.
# Standard EAGLE cooling options
EAGLECooling:
dir_name: ./coolingtables/ # Location of the Wiersma+08 cooling tables
H_reion_z: 11.5 # Redshift of Hydrogen re-ionization
......
......@@ -46,6 +46,7 @@ Gravity:
# Parameters of the hydro scheme
SPH:
resolution_eta: 1.2348 # "48 Ngb" with the cubic spline kernel
h_min_ratio: 0.1
CFL_condition: 0.1
initial_temperature: 1200. # (1 + z_ini)^2 * 2.72K
minimal_temperature: 100.
......
......@@ -47,6 +47,7 @@ Gravity:
SPH:
resolution_eta: 1.2348 # "48 Ngb" with the cubic spline kernel
CFL_condition: 0.1
h_min_ratio: 0.1
initial_temperature: 1200. # (1 + z_ini)^2 * 2.72K
minimal_temperature: 100.
......
......@@ -30,6 +30,7 @@ Gravity:
# Parameters of the hydro scheme
SPH:
resolution_eta: 1.2348 # "48 Ngb" with the cubic spline kernel
h_min_ratio: 0.1
CFL_condition: 0.1
initial_temperature: 7075. # (1 + z_ini)^2 * 2.72K
minimal_temperature: 100.
......
......@@ -30,6 +30,7 @@ Gravity:
# Parameters of the hydro scheme
SPH:
resolution_eta: 1.2348 # "48 Ngb" with the cubic spline kernel
h_min_ratio: 0.1
CFL_condition: 0.1
initial_temperature: 7075. # (1 + z_ini)^2 * 2.72K
minimal_temperature: 100.
......
......@@ -30,6 +30,7 @@ Gravity:
# Parameters of the hydro scheme
SPH:
resolution_eta: 1.2348 # "48 Ngb" with the cubic spline kernel
h_min_ratio: 0.1
CFL_condition: 0.1
initial_temperature: 7075. # (1 + z_ini)^2 * 2.72K
minimal_temperature: 100.
......
......@@ -35,6 +35,7 @@ Statistics:
SPH:
resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
h_min_ratio: 0.1
# Parameters related to the initial conditions
InitialConditions:
......
......@@ -28,6 +28,7 @@ SPH:
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
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.
......
......@@ -3642,6 +3642,7 @@ void cell_drift_part(struct cell *c, const struct engine *e, int force) {
const double dim[3] = {e->s->dim[0], e->s->dim[1], e->s->dim[2]};
const int with_cosmology = (e->policy & engine_policy_cosmology);
const float hydro_h_max = e->hydro_properties->h_max;
const float hydro_h_min = e->hydro_properties->h_min;
const integertime_t ti_old_part = c->hydro.ti_old_part;
const integertime_t ti_current = e->ti_current;
struct part *const parts = c->hydro.parts;
......@@ -3776,6 +3777,7 @@ void cell_drift_part(struct cell *c, const struct engine *e, int force) {
/* Limit h to within the allowed range */
p->h = min(p->h, hydro_h_max);
p->h = max(p->h, hydro_h_min);
/* Compute (square of) motion since last cell construction */
const float dx2 = xp->x_diff[0] * xp->x_diff[0] +
......
......@@ -2792,7 +2792,12 @@ void engine_init_particles(struct engine *e, int flag_entropy_ICs,
/* Update the softening lengths */
if (e->policy & engine_policy_self_gravity)
gravity_update(e->gravity_properties, e->cosmology);
gravity_props_update(e->gravity_properties, e->cosmology);
/* Udpate the hydro properties */
if (e->policy & engine_policy_hydro)
hydro_props_update(e->hydro_properties, e->gravity_properties,
e->cosmology);
/* Start by setting the particles in a good state */
if (e->nodeID == 0) message("Setting particles to a valid state...");
......@@ -3085,7 +3090,12 @@ void engine_step(struct engine *e) {
/* Update the softening lengths */
if (e->policy & engine_policy_self_gravity)
gravity_update(e->gravity_properties, e->cosmology);
gravity_props_update(e->gravity_properties, e->cosmology);
/* Udpate the hydro properties */
if (e->policy & engine_policy_hydro)
hydro_props_update(e->hydro_properties, e->gravity_properties,
e->cosmology);
/* Trigger a tree-rebuild if we passed the frequency threshold */
if ((e->policy & engine_policy_self_gravity) &&
......@@ -4088,7 +4098,7 @@ void engine_init(struct engine *e, struct space *s, struct swift_params *params,
int policy, int verbose, struct repartition *reparttype,
const struct unit_system *internal_units,
const struct phys_const *physical_constants,
struct cosmology *cosmo, const struct hydro_props *hydro,
struct cosmology *cosmo, struct hydro_props *hydro,
const struct entropy_floor_properties *entropy_floor,
struct gravity_props *gravity, const struct stars_props *stars,
struct pm_mesh *mesh,
......
......@@ -343,7 +343,7 @@ struct engine {
struct cosmology *cosmology;
/* Properties of the hydro scheme */
const struct hydro_props *hydro_properties;
struct hydro_props *hydro_properties;
/* Properties of the entropy floor */
const struct entropy_floor_properties *entropy_floor;
......@@ -419,7 +419,7 @@ void engine_init(struct engine *e, struct space *s, struct swift_params *params,
int policy, int verbose, struct repartition *reparttype,
const struct unit_system *internal_units,
const struct phys_const *physical_constants,
struct cosmology *cosmo, const struct hydro_props *hydro,
struct cosmology *cosmo, struct hydro_props *hydro,
const struct entropy_floor_properties *entropy_floor,
struct gravity_props *gravity, const struct stars_props *stars,
struct pm_mesh *mesh,
......
......@@ -40,7 +40,7 @@ __attribute__((always_inline)) INLINE static float gravity_get_mass(
}
/**
* @brief Returns the softening of a particle
* @brief Returns the current co-moving softening of a particle
*
* @param gp The particle of interest
* @param grav_props The global gravity properties.
......
......@@ -39,7 +39,7 @@ __attribute__((always_inline)) INLINE static float gravity_get_mass(
}
/**
* @brief Returns the softening of a particle
* @brief Returns the current co-moving softening of a particle
*
* @param gp The particle of interest
* @param grav_props The global gravity properties.
......
......@@ -99,10 +99,11 @@ void gravity_props_init(struct gravity_props *p, struct swift_params *params,
}
/* Set the softening to the current time */
gravity_update(p, cosmo);
gravity_props_update(p, cosmo);
}
void gravity_update(struct gravity_props *p, const struct cosmology *cosmo) {
void gravity_props_update(struct gravity_props *p,
const struct cosmology *cosmo) {
/* Current softening lengths */
double softening;
......
......@@ -73,7 +73,7 @@ struct gravity_props {
/*! Maxium physical softening */
double epsilon_max_physical;
/*! Current sftening length */
/*! Current softening length */
float epsilon_cur;
/*! Square of current softening length */
......@@ -90,7 +90,8 @@ void gravity_props_print(const struct gravity_props *p);
void gravity_props_init(struct gravity_props *p, struct swift_params *params,
const struct cosmology *cosmo, int with_cosmology,
int periodic);
void gravity_update(struct gravity_props *p, const struct cosmology *cosmo);
void gravity_props_update(struct gravity_props *p,
const struct cosmology *cosmo);
#if defined(HAVE_HDF5)
void gravity_props_print_snapshot(hid_t h_grpsph,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment