-
Matthieu Schaller authored
This reverts commit 6f6c3499.
Matthieu Schaller authoredThis reverts commit 6f6c3499.
File format and basic information
The parameter file uses a format similar to the YAML format but reduced to only the elements required for the SWIFT parameters. Options are given by a name followed by a column and the value of the parameter:
ICs: santa_barbara.hdf5
dt_max: 1.5
shift: [2., 4., 5.]
Comments can be inserted anywhere and start with a hash:
# Description of the physics
viscosity_alpha: 2.0
dt_max: 1.5 # seconds
A typical SWIFT parameter file is split into multiple sections that may or may not be present depending on the different configuration options. The sections start with a label and can contain any number of parameters:
Cosmology: # Planck13
Omega_m: 0.307
Omega_lambda: 0.693
Omega_b: 0.0455
h: 0.6777
a_begin: 0.0078125 # z = 127
The options can be integer values, floating point numbers, characters or strings. If SWIFT expects a number and string is given, an error will be raised. The code can also read an array of values:
shift: [2., 4., 5.]
Some options in the parameter file are optional and when not provided, SWIFT will run with the default value. However, if a compulsory parameter is missing an error will be raised at start-up.
Finally, SWIFT outputs two YAML files at the start of a run. The first one
used_parameters.yml
contains all the parameters that were used for this run,
including all the optional parameters left unspecified with their default
values. This file can be used to start an exact copy of the run. The second
file, unused_parameters.yml
contains all the values that were not read from
the parameter file. This can be used to simplify the parameter file or check
that nothing important was ignored (for instance because the code is not
configured to use some options).
The rest of this page describes all the SWIFT parameters, split by
section. A list of all the possible parameters is kept in the file
examples/parameter_examples.yml
.
Meta Data
The MetaData
section contains basic information about the simulation. It
currently only contains one parameter: run_name
. This is a string of
characters describing the simulation. It is written to the snapshots' headers.
Internal Unit System
The InternalUnitSystem
section describes the units used internally by the
code. This is the system of units in which all the equations are solved. All
physical constants are converted to this system and if the ICs use a different
system (see the snapshots' :ref:`ICs_units_label` section of the documentation)
the particle quantities will be converted when read in.
The system of units is described using the value of the 5 basic units of any system with respect to the CGS system. Instead of using a unit of time we use a unit of velocity as this is more intuitive. Users hence need to provide:
- a unit of length:
UnitLength_in_cgs
, - a unit of mass:
UnitMass_in_cgs
, - a unit of velocity
UnitVelocity_in_cgs
, - a unit of electric current
UnitCurrent_in_cgs
, - a unit of temperature
UnitTemp_in_cgs
.
All these need to be expressed with respect to their cgs counter-part (i.e. cm, g, cm/s, A and K). Recall that there are no h-factors in any of SWIFT's quantities; we, for instance, use cm and not cm/h.
For instance to use the commonly adopted system of 10^10 Msun as a unit for mass, mega-parsec as a unit of length and km/s as a unit of speed, we would use:
# Common unit system for cosmo sims
InternalUnitSystem:
UnitMass_in_cgs: 1.98848e43 # 10^10 M_sun in grams
UnitLength_in_cgs: 3.08567758e24 # 1 Mpc in centimeters
UnitVelocity_in_cgs: 1e5 # 1 km/s in centimeters per second
UnitCurrent_in_cgs: 1 # 1 Ampere
UnitTemp_in_cgs: 1 # 1 Kelvin
Note that there are currently no variables in any of the SWIFT physics schemes that make use of the unit of electric current. There is also no incentive to use anything else than Kelvin but that makes the whole system consistent with any possible unit system.
If one is interested in using the more humorous FFF unit system one would use
# FFF unit system
InternalUnitSystem:
UnitMass_in_cgs: 40823.3133 # 1 Firkin (fir) in grams
UnitLength_in_cgs: 20116.8 # 1 Furlong (fur) in cm
UnitVelocity_in_cgs: 0.01663095 # 1 Furlong (fur) per Fortnight (ftn) in cm/s
UnitCurrent_in_cgs: 1 # 1 Ampere
UnitTemp_in_cgs: 1 # 1 Kelvin
The value of the physical constants in this system is left as an exercise for the reader [1].
Cosmology
When running a cosmological simulation, the section Cosmology
sets the values of the
cosmological model. The expanded \Lambda\rm{CDM} parameters governing the
background evolution of the Universe need to be specified here. These are:
- The reduced Hubble constant: h:
h
, - The matter density parameter \Omega_m:
Omega_m
, - The cosmological constant density parameter \Omega_\Lambda:
Omega_lambda
, - The baryon density parameter \Omega_b:
Omega_b
, - The radiation density parameter \Omega_r:
Omega_r
.
The last parameter can be omitted and will default to \Omega_r = 0. Note that SWIFT will verify on start-up that the matter content of the initial conditions matches the cosmology specified in this section.
This section also specifies the start and end of the simulation expressed in terms of scale-factors. The two parameters are:
- Initial scale-factor:
a_begin
, - Final scale-factor:
a_end
.
Two additional optional parameters can be used to change the equation of state of dark energy w(a). We use the evolution law w(a) = w_0 + w_a (1 - a). The two parameters in the YAML file are:
- The z=0 dark energy equation of state parameter w_0:
w_0
- The dark energy equation of state evolution parameter w_a:
w_a
If unspecified these parameters default to the default \Lambda\rm{CDM} values of w_0 = -1 and w_a = 0.
For a Planck+13 cosmological model (ignoring radiation density as is commonly done) and running from z=127 to z=0, one would hence use the following parameters:
Cosmology:
a_begin: 0.0078125 # z = 127
a_end: 1.0 # z = 0
h: 0.6777
Omega_m: 0.307
Omega_lambda: 0.693
Omega_b: 0.0482519
Omega_r: 0. # (Optional)
w_0: -1.0 # (Optional)
w_a: 0. # (Optional)
When running a non-cosmological simulation (i.e. without the -c
run-time
flag) this section of the YAML file is entirely ignored.
Gravity
The behaviour of the self-gravity solver can be modified by the parameters
provided in the Gravity
section. The theory document puts these parameters into the
context of the equations being solved. We give a brief overview here.
- The Plummer-equivalent co-moving softening length used for all dark matter particles \epsilon_{\rm com,DM}:
comoving_DM_softening
, - The Plummer-equivalent co-moving softening length used for all baryon particles (gas, stars, BHs) \epsilon_{\rm com,bar}:
comoving_baryon_softening
, - The Plummer-equivalent maximal physical softening length used for all dark matter particles \epsilon_{\rm max,DM}:
max_physical_DM_softening
, - The Plummer-equivalent maximal physical softening length used for all baryon particles (gas, stars, BHs) \epsilon_{\rm max,bar}:
max_physical_baryon_softening
,
At any redshift z, the Plummer-equivalent softening length used by the code will be \epsilon=\min(\epsilon_{max}, \frac{\epsilon_{com}}{z+1}). The same calculation is performed independently for the dark matter and baryon particles. All the softening quantities are expressed in internal units. Calculations that only involve DM or baryons can leave the unused quantities out of the parameter file. For non-cosmological runs, only the physical softening lengths need to be supplied.
In case of zoom simulations, the softening of the additional, more massive, background
particles is specified via the parameter
softening_ratio_background
. Since these particles will typically have
different masses to degrade the resolution away from the zoom region, the
particles won't have a single softening value. Instead, we specify the
fraction of the mean inter-particle separation to use. The code will then
derive the softening length of each particle assuming the mean density of
the Universe. That is \epsilon_{\rm background} =
f\sqrt[3]{\frac{m}{\Omega_m\rho_{\rm crit}}}, where f is the
user-defined value (typically of order 0.05).
The accuracy of the gravity calculation is governed by the following two parameters:
- The opening angle (multipole acceptance criterion) used in the FMM \theta:
theta
, - The time-step size pre-factor \eta:
eta
,
The time-step of a given particle is given by \Delta t = \sqrt{2\eta\epsilon_i/|\overrightarrow{a}_i|}, where \overrightarrow{a}_i is the particle's acceleration and \epsilon_i its (spline) softening length. Power et al. (2003) recommend using \eta=0.025.
The last tree-related parameter is
- The tree rebuild frequency:
rebuild_frequency
.
The tree rebuild frequency is an optional parameter defaulting to 0.01. It is used to trigger the re-construction of the tree every time a fraction of the particles have been integrated (kicked) forward in time.
Simulations using periodic boundary conditions use additional parameters for the Particle-Mesh part of the calculation. The last five are optional:
- The number cells along each axis of the mesh N:
mesh_side_length
, - The mesh smoothing scale in units of the mesh cell-size a_{\rm
smooth}:
a_smooth
(default:1.25
), - The scale above which the short-range forces are assumed to be 0 (in units of
the mesh cell-size multiplied by a_{\rm smooth}) r_{\rm
cut,max}:
r_cut_max
(default:4.5
), - The scale below which the short-range forces are assumed to be exactly Newtonian (in units of
the mesh cell-size multiplied by a_{\rm smooth}) r_{\rm
cut,min}:
r_cut_min
(default:0.1
), - Whether or not to dither the particles randomly at each tree rebuild:
dithering
(default:1
), - The magnitude of each component of the dithering vector to use in units of the
top-level cell sizes:
dithering_ratio
(default:1.0
).
For most runs, the default values can be used. Only the number of cells along each axis needs to be specified. The mesh dithering is only used for simulations using periodic boundary conditions and in the absence of an external potential. At each tree rebuild time, all the particles are moved by a random vector (the same for all particles) and the periodic BCs are then applied. This reduces the correlation of erros across time. The remaining three values are best described in the context of the full set of equations in the theory documents.
As a summary, here are the values used for the EAGLE 100^3~{\rm Mpc}^3 simulation:
# Parameters for the self-gravity scheme for the EAGLE-100 box
Gravity:
eta: 0.025
theta: 0.6
mesh_side_length: 512
comoving_DM_softening: 0.0026994 # 0.7 proper kpc at z=2.8.
max_physical_DM_softening: 0.0007 # 0.7 proper kpc
comoving_baryon_softening: 0.0026994 # 0.7 proper kpc at z=2.8.
max_physical_baryon_softening: 0.0007 # 0.7 proper kpc
rebuild_frequency: 0.01 # Default optional value
a_smooth: 1.25 # Default optional value
r_cut_max: 4.5 # Default optional value
r_cut_min: 0.1 # Default optional value
dithering: 1 # Default optional value
dithering_ratio: 1.0 # Default optional value
SPH
The SPH
section is used to set parameters that describe the SPH
calculations. There are some scheme-specific values that are detailed in the
:ref:`hydro` section. The common parameters are detailed below.
In all cases, users have to specify two values:
- The smoothing length in terms of mean inter-particle separation:
resolution_eta
- The CFL condition that enters the time-step calculation:
CFL_condition
These quantities are dimensionless. The first, resolution_eta
, specifies
how smooth the simulation should be, and is used here instead of the number
of neighbours to smooth over as this also takes into account non-uniform
particle distributions. A value of 1.2348 gives approximately 48 neighbours
in 3D with the cubic spline kernel. More information on the choices behind
these parameters can be found in
Dehnen & Aly 2012.
The second quantity, the CFL condition, specifies how accurate the time integration should be and enters as a pre-factor into the hydrodynamics time-step calculation. This factor should be strictly bounded by 0 and 1, and typically takes a value of 0.1 for SPH calculations.
The next set of parameters deal with the calculation of the smoothing lengths directly and are all optional:
- Whether to use or not the mass-weighted definition of the SPH number of
neighbours:
use_mass_weighted_num_ngb
(Default: 0) - The (relative) tolerance to converge smoothing lengths within:
h_tolerance
(Default: 1e-4) - The maximal smoothing length in internal units:
h_max
(Default: FLT_MAX) - The minimal allowed smoothing length in terms of the gravitational
softening:
h_min_ratio
(Default: 0.0, i.e. no minimum) - The maximal (relative) allowed change in volume over one time-step:
max_volume_change
(Default: 1.4) - The maximal number of iterations allowed to converge the smoothing
lengths:
max_ghost_iterations
(Default: 30)
These parameters all set the accuracy of the smoothing lengths in various ways. The first one specified what definition of the local number density of particles to use. By default, we use
n_i = \sum_j W(\|\mathbf{r}_i - \mathbf{r}_j\|, h_i)
but switching on the use_mass_weighted_num_ngb
flag changes the
defintion to:
n_i = \frac{\rho_i}{m_i}
where the density has been computed in the traditional SPH way (i.e. \rho_i = \sum_j m_j W(\|\mathbf{r}_i - \mathbf{r}_j\|, h_i)). Note that in the case where all the particles in the simulation have the same mass, the two definitions lead to the same number density value.
We dot not recommend using this alternative neighbour number definition in production runs. It is mainly provided for backward compatibility with earlier simulations.
The second one, the relative tolerance for the smoothing length, specifies
the convergence criteria for the smoothing length when using the
Newton-Raphson scheme. This works with the maximal number of iterations,
max_ghost_iterations
(so called because the smoothing length calculation
occurs in the ghost task), to ensure that the values of the smoothing lengths
are consistent with the local number density. We solve:
(\eta \gamma)^{n_D} = n_i
with \gamma the ratio of smoothing length to kernel support (this
is fixed for a given kernel shape), n_D the number of spatial
dimensions, \eta the value of resolution_eta
, and n_i
the local number density. We adapt the value of the smoothing length,
h, to be consistent with the number density.
The maximal smoothing length, by default, is set to FLT_MAX
, and if set
prevents the smoothing length from going beyond h_max
(in internal units)
during the run, irrespective of the above equation. The minimal smoothing
length is set in terms of the gravitational softening, h_min_ratio
, to
prevent the smoothing length from going below this value in dense
environments. This will lead to smoothing over more particles than specified
by \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 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.
- The initial temperature of all particles:
initial_temperature
(Default: InternalEnergy from the initial conditions) - The minimal temperature of any particle:
minimal_temperature
(Default: 0) - The mass fraction of hydrogen used to set the initial temperature:
H_mass_fraction
(Default: 0.755) - The ionization temperature (from neutral to ionized) for primordial gas,
again used in this conversion:
H_ionization_temperature
(Default: 1e4)
These parameters, if not present, are set to the default values. The initial temperature is used, along with the hydrogen mass fraction and ionization temperature, to set the initial internal energy per unit mass (or entropy per unit mass) of the particles.
Throughout the run, if the temperature of a particle drops below
minimal_temperature
, the particle has energy added to it such that it
remains at that temperature. The run is not terminated prematurely. The
temperatures specified in this section are in internal units.
The full section to start a typical cosmological run would be:
SPH:
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
Stars
The Stars
section is used to set parameters that describe the Stars
calculations when doing feedback or enrichment. Note that if stars only act
gravitationally (i.e. SWIFT is run without --feedback
) no parameters
in this section are used.
The first four parameters are related to the neighbour search:
- The (relative) tolerance to converge smoothing lengths within:
h_tolerance
(Default: same as SPH scheme) - The maximal smoothing length in internal units:
h_max
(Default: same as SPH scheme) - The minimal allowed smoothing length in terms of the gravitational
softening:
h_min_ratio
(Default: same as SPH scheme) - The maximal (relative) allowed change in volume over one time-step:
max_volume_change
(Default: same as SPH scheme)
These four parameters are optional and will default to their SPH equivalent if left unspecified. That is the value specified by the user in that section or the default SPH value if left unspecified there as well.