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
...@@ -49,6 +49,7 @@ Gravity: ...@@ -49,6 +49,7 @@ Gravity:
# Parameters for the hydrodynamics scheme # Parameters for the hydrodynamics scheme
SPH: SPH:
resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). 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. CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
minimal_temperature: 100 # (internal units) minimal_temperature: 100 # (internal units)
......
...@@ -47,6 +47,7 @@ Gravity: ...@@ -47,6 +47,7 @@ Gravity:
# Parameters for the hydrodynamics scheme # Parameters for the hydrodynamics scheme
SPH: SPH:
resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). 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. CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
minimal_temperature: 100 # (internal units) minimal_temperature: 100 # (internal units)
......
...@@ -54,6 +54,7 @@ Gravity: ...@@ -54,6 +54,7 @@ Gravity:
# Parameters for the hydrodynamics scheme # Parameters for the hydrodynamics scheme
SPH: SPH:
resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). 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. CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
minimal_temperature: 100 # (internal units) minimal_temperature: 100 # (internal units)
......
...@@ -49,6 +49,7 @@ Gravity: ...@@ -49,6 +49,7 @@ Gravity:
# Parameters for the hydrodynamics scheme # Parameters for the hydrodynamics scheme
SPH: SPH:
resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). 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. CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
minimal_temperature: 100 # (internal units) minimal_temperature: 100 # (internal units)
......
...@@ -58,6 +58,7 @@ Gravity: ...@@ -58,6 +58,7 @@ Gravity:
# Parameters for the hydrodynamics scheme # Parameters for the hydrodynamics scheme
SPH: SPH:
resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). 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. CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
minimal_temperature: 100 # (internal units) minimal_temperature: 100 # (internal units)
......
...@@ -11,13 +11,13 @@ Gravity: ...@@ -11,13 +11,13 @@ Gravity:
mesh_side_length: 32 # Number of cells along each axis for the periodic gravity mesh. mesh_side_length: 32 # Number of cells along each axis for the periodic gravity mesh.
eta: 0.025 # Constant dimensionless multiplier for time integration. eta: 0.025 # Constant dimensionless multiplier for time integration.
theta: 0.7 # Opening angle (Multipole acceptance criterion). theta: 0.7 # Opening angle (Multipole acceptance criterion).
comoving_softening: 0.01 # Comoving 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). 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.) # Parameters governing the time integration (Set dt_min and dt_max to the same value for a fixed time-step run.)
TimeIntegration: TimeIntegration:
time_begin: 0. # The starting time of the simulation (in internal units). 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_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). dt_max: 1e-2 # The maximal time-step size of the simulation (in internal units).
...@@ -35,20 +35,17 @@ Statistics: ...@@ -35,20 +35,17 @@ Statistics:
# Parameters related to the initial conditions # Parameters related to the initial conditions
InitialConditions: 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? periodic: 0 # Are we running with periodic ICs?
# Parameters for the hydrodynamics scheme # Parameters for the hydrodynamics scheme
SPH: SPH:
resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). 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. 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_min_ratio: 0.1 # Minimal smoothing in units of softening.
h_max: 10. # (Optional) Maximal allowed smoothing length in internal units. Defaults to FLT_MAX if unspecified. h_max: 10.
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.
# Standard EAGLE cooling options
EAGLECooling: EAGLECooling:
dir_name: ./coolingtables/ # Location of the Wiersma+08 cooling tables dir_name: ./coolingtables/ # Location of the Wiersma+08 cooling tables
H_reion_z: 11.5 # Redshift of Hydrogen re-ionization H_reion_z: 11.5 # Redshift of Hydrogen re-ionization
......
...@@ -46,6 +46,7 @@ Gravity: ...@@ -46,6 +46,7 @@ Gravity:
# Parameters of the hydro scheme # Parameters of the hydro scheme
SPH: SPH:
resolution_eta: 1.2348 # "48 Ngb" with the cubic spline kernel resolution_eta: 1.2348 # "48 Ngb" with the cubic spline kernel
h_min_ratio: 0.1
CFL_condition: 0.1 CFL_condition: 0.1
initial_temperature: 1200. # (1 + z_ini)^2 * 2.72K initial_temperature: 1200. # (1 + z_ini)^2 * 2.72K
minimal_temperature: 100. minimal_temperature: 100.
......
...@@ -47,6 +47,7 @@ Gravity: ...@@ -47,6 +47,7 @@ Gravity:
SPH: SPH:
resolution_eta: 1.2348 # "48 Ngb" with the cubic spline kernel resolution_eta: 1.2348 # "48 Ngb" with the cubic spline kernel
CFL_condition: 0.1 CFL_condition: 0.1
h_min_ratio: 0.1
initial_temperature: 1200. # (1 + z_ini)^2 * 2.72K initial_temperature: 1200. # (1 + z_ini)^2 * 2.72K
minimal_temperature: 100. minimal_temperature: 100.
......
...@@ -30,6 +30,7 @@ Gravity: ...@@ -30,6 +30,7 @@ Gravity:
# Parameters of the hydro scheme # Parameters of the hydro scheme
SPH: SPH:
resolution_eta: 1.2348 # "48 Ngb" with the cubic spline kernel resolution_eta: 1.2348 # "48 Ngb" with the cubic spline kernel
h_min_ratio: 0.1
CFL_condition: 0.1 CFL_condition: 0.1
initial_temperature: 7075. # (1 + z_ini)^2 * 2.72K initial_temperature: 7075. # (1 + z_ini)^2 * 2.72K
minimal_temperature: 100. minimal_temperature: 100.
......
...@@ -30,6 +30,7 @@ Gravity: ...@@ -30,6 +30,7 @@ Gravity:
# Parameters of the hydro scheme # Parameters of the hydro scheme
SPH: SPH:
resolution_eta: 1.2348 # "48 Ngb" with the cubic spline kernel resolution_eta: 1.2348 # "48 Ngb" with the cubic spline kernel
h_min_ratio: 0.1
CFL_condition: 0.1 CFL_condition: 0.1
initial_temperature: 7075. # (1 + z_ini)^2 * 2.72K initial_temperature: 7075. # (1 + z_ini)^2 * 2.72K
minimal_temperature: 100. minimal_temperature: 100.
......
...@@ -30,6 +30,7 @@ Gravity: ...@@ -30,6 +30,7 @@ Gravity:
# Parameters of the hydro scheme # Parameters of the hydro scheme
SPH: SPH:
resolution_eta: 1.2348 # "48 Ngb" with the cubic spline kernel resolution_eta: 1.2348 # "48 Ngb" with the cubic spline kernel
h_min_ratio: 0.1
CFL_condition: 0.1 CFL_condition: 0.1
initial_temperature: 7075. # (1 + z_ini)^2 * 2.72K initial_temperature: 7075. # (1 + z_ini)^2 * 2.72K
minimal_temperature: 100. minimal_temperature: 100.
......
...@@ -35,6 +35,7 @@ Statistics: ...@@ -35,6 +35,7 @@ Statistics:
SPH: SPH:
resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation 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. CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
h_min_ratio: 0.1
# Parameters related to the initial conditions # Parameters related to the initial conditions
InitialConditions: InitialConditions:
......
...@@ -28,6 +28,7 @@ SPH: ...@@ -28,6 +28,7 @@ SPH:
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration. 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_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_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_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. 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. 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) { ...@@ -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 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 int with_cosmology = (e->policy & engine_policy_cosmology);
const float hydro_h_max = e->hydro_properties->h_max; 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_old_part = c->hydro.ti_old_part;
const integertime_t ti_current = e->ti_current; const integertime_t ti_current = e->ti_current;
struct part *const parts = c->hydro.parts; struct part *const parts = c->hydro.parts;
...@@ -3776,6 +3777,7 @@ void cell_drift_part(struct cell *c, const struct engine *e, int force) { ...@@ -3776,6 +3777,7 @@ void cell_drift_part(struct cell *c, const struct engine *e, int force) {
/* Limit h to within the allowed range */ /* Limit h to within the allowed range */
p->h = min(p->h, hydro_h_max); p->h = min(p->h, hydro_h_max);
p->h = max(p->h, hydro_h_min);
/* Compute (square of) motion since last cell construction */ /* Compute (square of) motion since last cell construction */
const float dx2 = xp->x_diff[0] * xp->x_diff[0] + 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, ...@@ -2792,7 +2792,12 @@ void engine_init_particles(struct engine *e, int flag_entropy_ICs,
/* Update the softening lengths */ /* Update the softening lengths */
if (e->policy & engine_policy_self_gravity) 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 */ /* Start by setting the particles in a good state */
if (e->nodeID == 0) message("Setting particles to a valid state..."); if (e->nodeID == 0) message("Setting particles to a valid state...");
...@@ -3085,7 +3090,12 @@ void engine_step(struct engine *e) { ...@@ -3085,7 +3090,12 @@ void engine_step(struct engine *e) {
/* Update the softening lengths */ /* Update the softening lengths */
if (e->policy & engine_policy_self_gravity) 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 */ /* Trigger a tree-rebuild if we passed the frequency threshold */
if ((e->policy & engine_policy_self_gravity) && if ((e->policy & engine_policy_self_gravity) &&
...@@ -4088,7 +4098,7 @@ void engine_init(struct engine *e, struct space *s, struct swift_params *params, ...@@ -4088,7 +4098,7 @@ void engine_init(struct engine *e, struct space *s, struct swift_params *params,
int policy, int verbose, struct repartition *reparttype, int policy, int verbose, struct repartition *reparttype,
const struct unit_system *internal_units, const struct unit_system *internal_units,
const struct phys_const *physical_constants, 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, const struct entropy_floor_properties *entropy_floor,
struct gravity_props *gravity, const struct stars_props *stars, struct gravity_props *gravity, const struct stars_props *stars,
struct pm_mesh *mesh, struct pm_mesh *mesh,
......
...@@ -343,7 +343,7 @@ struct engine { ...@@ -343,7 +343,7 @@ struct engine {
struct cosmology *cosmology; struct cosmology *cosmology;
/* Properties of the hydro scheme */ /* Properties of the hydro scheme */
const struct hydro_props *hydro_properties; struct hydro_props *hydro_properties;
/* Properties of the entropy floor */ /* Properties of the entropy floor */
const struct entropy_floor_properties *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, ...@@ -419,7 +419,7 @@ void engine_init(struct engine *e, struct space *s, struct swift_params *params,
int policy, int verbose, struct repartition *reparttype, int policy, int verbose, struct repartition *reparttype,
const struct unit_system *internal_units, const struct unit_system *internal_units,
const struct phys_const *physical_constants, 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, const struct entropy_floor_properties *entropy_floor,
struct gravity_props *gravity, const struct stars_props *stars, struct gravity_props *gravity, const struct stars_props *stars,
struct pm_mesh *mesh, struct pm_mesh *mesh,
......
...@@ -40,7 +40,7 @@ __attribute__((always_inline)) INLINE static float gravity_get_mass( ...@@ -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 gp The particle of interest
* @param grav_props The global gravity properties. * @param grav_props The global gravity properties.
......
...@@ -39,7 +39,7 @@ __attribute__((always_inline)) INLINE static float gravity_get_mass( ...@@ -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 gp The particle of interest
* @param grav_props The global gravity properties. * @param grav_props The global gravity properties.
......
...@@ -99,10 +99,11 @@ void gravity_props_init(struct gravity_props *p, struct swift_params *params, ...@@ -99,10 +99,11 @@ void gravity_props_init(struct gravity_props *p, struct swift_params *params,
} }
/* Set the softening to the current time */ /* 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 */ /* Current softening lengths */
double softening; double softening;
......
...@@ -73,7 +73,7 @@ struct gravity_props { ...@@ -73,7 +73,7 @@ struct gravity_props {
/*! Maxium physical softening */ /*! Maxium physical softening */
double epsilon_max_physical; double epsilon_max_physical;
/*! Current sftening length */ /*! Current softening length */
float epsilon_cur; float epsilon_cur;
/*! Square of current softening length */ /*! Square of current softening length */
...@@ -90,7 +90,8 @@ void gravity_props_print(const struct gravity_props *p); ...@@ -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, void gravity_props_init(struct gravity_props *p, struct swift_params *params,
const struct cosmology *cosmo, int with_cosmology, const struct cosmology *cosmo, int with_cosmology,
int periodic); 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) #if defined(HAVE_HDF5)
void gravity_props_print_snapshot(hid_t h_grpsph, void gravity_props_print_snapshot(hid_t h_grpsph,
......
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