Commit 768937bf authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Merge branch 'master' into removing_particles

parents c22e4447 f241e5ea
.. Command line options
Matthieu Schaller, 21st October 2018
Command line options
====================
......@@ -20,7 +20,6 @@ and keep on your desk.
running_example
runtime_options
configuration_options
parameter_file
what_about_mpi
running_on_large_systems
special_modes
......@@ -28,3 +28,9 @@ scheme it includes a Monaghan AV scheme and a Balsara switch.
.. code-block:: bash
./configure --with-hydro="pressure-energy"
Both of the above schemes use a very simple, fixed artificial viscosity, only
the ``SPH:viscosity_alpha`` parameter has any effect for this scheme. This will
change the strength of the artificial viscosity throughout the simulation, and
has a default of 0.8.
......@@ -10,11 +10,17 @@ Minimal (Density-Energy) SPH
:caption: Contents:
This scheme is a textbook implementation of Density-Energy SPH, and can be used
as a pedagogical example. It also implements a Monaghan AV scheme, like the
GADGET-2 scheme. It uses very similar equations, but differs in implementation
details; namely it tracks the internal energy \(u\) as the thermodynamic
variable, rather than entropy \(A\). To use the minimal scheme, use
as a pedagogical example. It also implements a Monaghan AV scheme with a
Balsara switch, like the GADGET-2 scheme. It uses very similar equations, but
differs in implementation details; namely it tracks the internal energy \(u\)
as the thermodynamic variable, rather than entropy \(A\). To use the minimal
scheme, use
.. code-block:: bash
./configure --with-hydro="minimal"
As it uses a very simple, fixed artificial viscosity, only the
``SPH:viscosity_alpha`` parameter has any effect for this scheme. This will
change the strength of the artificial viscosity throughout the simulation,
and has a default of 0.8.
......@@ -15,3 +15,8 @@ a Monaghan artificial viscosity scheme and Balsara switch.
To use this hydro scheme, you need no extra configuration options -- it is the
default!
As it uses a very simple, fixed artificial viscosity, only the
``SPH:viscosity_alpha`` parameter has any effect for this scheme. This will
change the strength of the artificial viscosity throughout the simulation,
and has a default of 0.8.
......@@ -176,7 +176,9 @@ as peculiar velocities divided by ``sqrt(a)``. This can be undone by swicthing
on the parameter ``InitialConditions:cleanup_velocity_factors`` in the
:ref:`Parameter_File_label`.
.. _ICs_units_label:
Optional Components
-------------------
......
.. Parameter Files
Matthieu Schaller, 21st October 2018
Parameter Files
===============
File format and basic information
---------------------------------
The parameter file uses a format similar to the `YAML format
<https://en.wikipedia.org/wiki/YAML>`_ 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:
.. code:: YAML
ICs: santa_barbara.hdf5
dt_max: 1.5
shift: [2., 4., 5.]
Comments can be inserted anywhere and start with a hash:
.. code:: YAML
# Descrption 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:
.. code:: YAML
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:
.. code:: YAML
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 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``.
Internal Unit System
--------------------
This 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 :ref:`ICs_units_label`) 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. :math:`cm`, :math:`g`, :math:`cm/s`, :math:`A` and :math:`K`). Recall
that there are no h-factors in any of SWIFT's quantities; we, for instance,
use :math:`cm` and not :math:`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:
.. code:: YAML
# 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 humourous `FFF unit
system <https://en.wikipedia.org/wiki/FFF_system>`_ one would use
.. code:: YAML
# 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 [#f1]_.
Cosmology
---------
When running a cosmological simulation, this section set the values of the
cosmological model. The epanded :math:`\Lambda\rm{CDM}` parameters governing the
background evolution of the Univese need to be specified here. These are:
* The reduced Hubble constant: :math:`h`: ``h``,
* The matter density parameter :math:`\Omega_m`: ``Omega_m``,
* The cosmological constant density parameter :math:`\Omega_\Lambda`: ``Omega_lambda``,
* The baryon density parameter :math:`\Omega_b`: ``Omega_b``,
* The radiation density parameter :math:`\Omega_r`: ``Omega_r``.
The last parameter can be omitted and will default to :math:`\Omega_r = 0`.
This section als 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 :math:`w(a)`. We use the evolution law :math:`w(a) =
w_0 + w_a (1 - a)`. The two parameters in the YAML file are:
* The :math:`z=0` dark energy equation of state parameter :math:`w_0`: ``w_0``
* The dark energy equation of state evolutio parameter :math:`w_a`: ``w_a``
If unspecified these parameters default to the default
:math:`\Lambda\rm{CDM}` values of :math:`w_0 = -1` and :math:`w_a = 0`.
For a Planck+13 cosmological model (ignoring radiation density as is
commonly done) and running from :math:`z=127` to :math:`z=0`, one would hence
use the following parameters:
.. code:: YAML
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.0455
Omega_r: 0. # (Optional)
w_0: -1.0 # (Optional)
w_a: 0. # (Optional)
When running a non-cosmological simulation (i.e. without the ``-c`` runtime
flag) this section of the YAML file is entirely ignored.
Gravity
-------
SPH
---
Time Integration
----------------
Physical Constants
------------------
For some idealised test it can be useful to overwrite the value of
some physical constants. In particular the value of the gravitational
constant. SWIFT offers an optional parameter to overwrite the value of
that constant.
.. code:: YAML
PhysicalConstants:
G: 1
Note that this set :math:`G` to the specified value in the internal system
of units. Setting a value of `1` when using the system of units (10^10 Msun,
Mpc, km/s) will mean that :math:`G_N=1` in these units [#f2]_ instead of the
normal value :math:`G_N=43.00927`.
This option is only used for specific tests and debugging. This entire
section of the YAML file can typically be left out.
Snapshots
---------
Some additional specific options for the snapshot outputs are described in the
following pages:
.. toctree::
:maxdepth: 1
output_selection
Statistics
----------
Restarts
--------
Scheduler
---------
Domain Decomposition
--------------------
.. [#f1] The thorough reader (or overly keen SWIFT tester) would find that the speed of light is :math:`c=1.8026\times10^{12}\,\rm{fur}\,\rm{ftn}^{-1}`, Newton's contant becomes :math:`G_N=4.896735\times10^{-4}~\rm{fur}^3\,\rm{fir}^{-1}\,\rm{ftn}^{-2}` and Planck's constant turns into :math:`h=4.851453\times 10^{-34}~\rm{fur}^2\,\rm{fir}\,\rm{ftn}^{-1}`.
.. [#f2] which would translate into a constant :math:`G_N=1.5517771\times10^{-9}~cm^{3}\,g^{-1}\,s^{-2}` if expressed in the CGS system.
.. Parameter File
Loic Hausammann, 1 june 2018
.. _Parameter_File_label:
Parameter File
==============
To run SWIFT, you will need to provide a ``yaml`` parameter file. An example is
given in ``examples/parameter_file.yml`` which should contain all possible
parameters. Each section in this file corresponds to a different option in
SWIFT and are not always required depending on the configuration options and
the run time parameters.
.. _Output_list_label:
Output List
~~~~~~~~~~~
In the sections ``Snapshots`` and ``Statistics``, you can specify the options ``output_list_on`` and ``output_list`` which receive an int and a filename.
The ``output_list_on`` enable or not the output list and ``output_list`` is the filename containing the output times.
With the file header, you can choose between writing redshifts, scale factors or times.
In the sections ``Snapshots`` and ``Statistics``, you can specify the
options ``output_list_on`` and ``output_list`` which receive an int
and a filename. The ``output_list_on`` enable or not the output list
and ``output_list`` is the filename containing the output times. With
the file header, you can choose between writing redshifts, scale
factors or times.
Example of file containing with times (in internal units)::
......@@ -42,6 +36,8 @@ Example of file with redshift::
10
5
.. _Output_selection_label:
Output Selection
~~~~~~~~~~~~~~~~
......
......@@ -15,6 +15,8 @@ difference is the parameter file that will need to be adapted for SWIFT.
:maxdepth: 2
GettingStarted/index
CommandLineOptions/index
ParameterFiles/index
InitialConditions/index
HydroSchemes/index
Cooling/index
......
This example is a galaxy extracted from the example "ZoomIn". It allows
to test SWIFT on a smaller problem. See the README in "ZoomIn" for more
information.
MD5 check-sum of the ICS:
ae2af84d88f30011b6a8af3f37d140cf dwarf_galaxy.hdf5
\ No newline at end of file
# Define the system of units to use internally.
InternalUnitSystem:
UnitMass_in_cgs: 1.98848e43 # 10^10 M_sun in grams
UnitLength_in_cgs: 3.08567758e21 # kpc in centimeters
UnitVelocity_in_cgs: 1e5 # km/s in centimeters per second
UnitCurrent_in_cgs: 1 # Amperes
UnitTemp_in_cgs: 1 # Kelvin
# Structure finding options
StructureFinding:
config_file_name: stf_input.cfg # Name of the STF config file.
basename: ./stf # Common part of the name of output files.
output_time_format: 0 # Specifies the frequency format of structure finding. 0 for simulation steps (delta_step) and 1 for simulation time intervals (delta_time).
scale_factor_first: 0.92 # Scale-factor of the first snaphot (cosmological run)
time_first: 0.01 # Time of the first structure finding output (in internal units).
delta_step: 1000 # Time difference between consecutive structure finding outputs (in internal units) in simulation steps.
delta_time: 1.10 # Time difference between consecutive structure finding outputs (in internal units) in simulation time intervals.
# Cosmological parameters
Cosmology:
h: 0.673 # Reduced Hubble constant
a_begin: 0.9873046739 # Initial scale-factor of the simulation
a_end: 1.0 # Final scale factor of the simulation
Omega_m: 0.315 # Matter density parameter
Omega_lambda: 0.685 # Dark-energy density parameter
Omega_b: 0.0486 # Baryon density parameter
Scheduler:
max_top_level_cells: 8
cell_split_size: 400 # (Optional) Maximal number of particles per cell (this is the default value).
# Parameters governing the time integration
TimeIntegration:
time_begin: 0. # The starting time of the simulation (in internal units).
time_end: 1. # The end time of the simulation (in internal units).
dt_min: 1e-10 # The minimal time-step size of the simulation (in internal units).
dt_max: 1e-3 # The maximal time-step size of the simulation (in internal units).
# Parameters governing the snapshots
Snapshots:
basename: dwarf_galaxy # Common part of the name of output files
time_first: 0. # Time of the first output (non-cosmological run) (in internal units)
delta_time: 0.02 # Time difference between consecutive outputs (in internal units)
compression: 1
# Parameters governing the conserved quantities statistics
Statistics:
scale_factor_first: 0.987345 # Scale-factor of the first stat dump (cosmological run)
time_first: 0.01 # Time of the first stat dump (non-cosmological run) (in internal units)
delta_time: 1.05 # Time between statistics output
# Parameters for the self-gravity scheme
Gravity:
eta: 0.025 # Constant dimensionless multiplier for time integration.
theta: 0.7 # Opening angle (Multipole acceptance criterion)
comoving_softening: 0.05 # Comoving softening length (in internal units).
max_physical_softening: 0.01 # Physical softening length (in internal units).
mesh_side_length: 16
# 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.
minimal_temperature: 100 # (internal units)
# Parameters related to the initial conditions
InitialConditions:
file_name: ./dwarf_galaxy.hdf5 # The file to read
cleanup_h_factors: 1 # Remove the h-factors inherited from Gadget
cleanup_velocity_factors: 1 # Remove the sqrt(a) factor in the velocities inherited from Gadget
#!/bin/bash
wget https://obswww.unige.ch/~lhausamm/swift/IC/DwarfGalaxy/dwarf_galaxy.hdf5
#!/bin/bash
# Generate the initial conditions if they are not present.
if [ ! -e dwarf_galaxy.hdf5 ]
then
echo "Fetching initial conditions for the dwarf galaxy example..."
./getIC.sh
fi
../swift -b -G -s -S -t 8 dwarf_galaxy.yml 2>&1 | tee output.log
Initial conditions for a zoom in cosmological simulation of dwarf
galaxies. These have been generated by MUSIC and ran up to z=0 with
GEAR (see Revaz and Jablonka 2018 for more details on the simulation).
The cosmology is taken from Planck 2015.
The initial conditions have been cleaned to contain only the required
fields. The ICs have been created for Gadget and the positions and box
size are hence expressed in h-full units (e.g. box size of 32 / h Mpc).
Similarly, the peculiar velocitites contain an extra sqrt(a) factor.
We will use SWIFT to cancel the h- and a-factors from the ICs. Gas
particles will be generated at startup.
MD5 check-sum of the ICS:
9aafe154438478ed435e88664c1c5dba zoom_in.hdf5
#!/bin/bash
wget https://obswww.unige.ch/~lhausamm/swift/IC/ZoomIn/zoom_in.hdf5
#!/bin/bash
# Generate the initial conditions if they are not present.
if [ ! -e zoom_in.hdf5 ]
then
echo "Fetching initial conditions for the zoom in example..."
./getIC.sh
fi
../swift -b -c -G -s -S -t 8 zoom_in.yml 2>&1 | tee output.log
# Define the system of units to use internally.
InternalUnitSystem:
UnitMass_in_cgs: 1.98848e43 # 10^10 M_sun in grams
UnitLength_in_cgs: 3.08567758e21 # kpc in centimeters
UnitVelocity_in_cgs: 1e5 # km/s in centimeters per second
UnitCurrent_in_cgs: 1 # Amperes
UnitTemp_in_cgs: 1 # Kelvin
# Cosmological parameters
Cosmology:
h: 0.673 # Reduced Hubble constant
a_begin: 0.9873046739 # Initial scale-factor of the simulation
a_end: 1.0 # Final scale factor of the simulation
Omega_m: 0.315 # Matter density parameter
Omega_lambda: 0.685 # Dark-energy density parameter
Omega_b: 0.0486 # Baryon density parameter
Scheduler:
max_top_level_cells: 8
# Parameters governing the time integration
TimeIntegration:
time_begin: 0. # The starting time of the simulation (in internal units).
time_end: 1e-2 # The end time of the simulation (in internal units).
dt_min: 1e-10 # The minimal time-step size of the simulation (in internal units).
dt_max: 1e-3 # The maximal time-step size of the simulation (in internal units).
# Parameters governing the snapshots
Snapshots:
basename: zoom_in # Common part of the name of output files
scale_factor_first: 0.987345 # Scale-factor of the first snaphot (cosmological run)
time_first: 0.01 # Time of the first output (non-cosmological run) (in internal units)
delta_time: 1.01 # Time difference between consecutive outputs (in internal units)
compression: 1
# Parameters governing the conserved quantities statistics
Statistics:
scale_factor_first: 0.987345 # Scale-factor of the first stat dump (cosmological run)
time_first: 0.01 # Time of the first stat dump (non-cosmological run) (in internal units)
delta_time: 1.05 # Time between statistics output
# Parameters for the self-gravity scheme
Gravity:
eta: 0.025 # Constant dimensionless multiplier for time integration.
theta: 0.7 # Opening angle (Multipole acceptance criterion)
comoving_softening: 0.05 # Comoving softening length (in internal units).
max_physical_softening: 0.01 # Physical softening length (in internal units).
mesh_side_length: 16
# 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.
minimal_temperature: 100 # (internal units)
# Parameters related to the initial conditions
InitialConditions:
file_name: ./zoom_in.hdf5 # The file to read
cleanup_h_factors: 1 # Remove the h-factors inherited from Gadget
cleanup_velocity_factors: 1 # Remove the sqrt(a) factor in the velocities inherited from Gadget
......@@ -34,6 +34,10 @@ SPH:
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
# Parameters for the self-gravity scheme
Gravity:
......@@ -133,9 +137,9 @@ DomainDecomposition:
# new decomposition, or number of steps (>1) between decompositions
minfrac: 0.9 # (Optional) Fractional of all particles that should be updated in previous step when
# using CPU time trigger
usemetis 0 # Use serial METIS when ParMETIS is also available.
adaptive 1 # Use adaptive repartition when ParMETIS is available, otherwise simple refinement.
itr 100 # When adaptive defines the ratio of inter node communication time to data redistribution time, in the range 0.00001 to 10000000.0.
usemetis: 0 # Use serial METIS when ParMETIS is also available.
adaptive: 1 # Use adaptive repartition when ParMETIS is available, otherwise simple refinement.
itr: 100 # When adaptive defines the ratio of inter node communication time to data redistribution time, in the range 0.00001 to 10000000.0.
# Lower values give less data movement during redistributions, at the cost of global balance which may require more communication.
# Parameters related to the equation of state ------------------------------------------
......
#!/usr/bin/python
"""
Usage:
./plot_task_level.py task_level.txt
Description:
Plot the number of tasks for each depth level and each type of task.
"""
import pandas as pd
import matplotlib.pyplot as plt
import sys
# get filename
filename = sys.argv[-1]
# Column names
names = ["type", "subtype", "depth", "count"]
# read file
data = pd.read_csv(filename, sep=' ', comment="#", names=names)
# generate color map
cmap = plt.get_cmap("hsv")
N = data["depth"].max() + 5
# plot data
for i in range(data["depth"].max()):
ind = data["depth"] == i
label = "depth = %i" % i
c = cmap(i / N)
plt.plot(data["type"][ind] + "_" + data["subtype"][ind],
data["count"][ind], ".", label=label,
color=c)
# modify figure parameters and show it
plt.gca().set_yscale("log")
plt.xticks(rotation=45)
plt.ylabel("Number of Tasks")
plt.gcf().subplots_adjust(bottom=0.15)
plt.legend()
plt.show()
......@@ -157,11 +157,11 @@ for task in SUBTYPES:
# For fiddling with colours...
if args.verbose:
print