Skip to content

Commit

Permalink
Upgrade to FOF to treat some types differently
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthieuSchaller committed Dec 1, 2023
1 parent 25063f6 commit 47b3c40
Show file tree
Hide file tree
Showing 47 changed files with 2,360 additions and 443 deletions.
48 changes: 32 additions & 16 deletions doc/RTD/source/FriendsOfFriends/algorithm_description.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,19 @@ friends (its *friends-of-friends*). This creates networks of linked particles
which are called *groups*. The size (or length) of
a group is the number of particles in that group. If a particle does not
find any other particle within ``l`` then it forms its own group of
size 1. For a given distribution of particles the resulting list of
groups is unique and unambiguously defined.
size 1. **For a given distribution of particles the resulting list of
groups is unique and unambiguously defined.**

In our implementation, we use three separate categories influencing their
behaviour in the FOF code:
* ``linkable`` particles which behave as described above.
* ``attachable`` particles which can `only` form a link with the `nearest` ``linkable`` particle they find.
* And the others which are ignored entirely.

The category of each particle type is specified at run time in the parameter
file. The classic scenario for the two categories is to run FOF on the dark
matter particles (i.e. they are `linkable`) and then attach the gas, stars and
black holes to their nearest DM (i.e. the baryons are `attachable`).

Small groups are typically discarded, the final catalogue only contains
objects with a length above a minimal threshold, typically of the
Expand All @@ -36,20 +47,25 @@ domain decomposition and tree structure that is created for the other
parts of the code. The tree can be easily used to find neighbours of
particles within the linking length.

Depending on the application, the choice of linking length and
minimal group size can vary. For cosmological applications, bound
structures (dark matter haloes) are traditionally identified using a
linking length expressed as :math:`0.2` of the mean inter-particle
separation :math:`d` in the simulation which is given by :math:`d =
\sqrt[3]{\frac{V}{N}}`, where :math:`N` is the number of particles in
the simulation and :math:`V` is the simulation (co-moving)
volume. Usually only dark matter particles are considered for the
number :math:`N`. Other particle types are linked but do not
participate in the calculation of the linking length. Experience shows
that this produces groups that are similar to the commonly adopted
(but much more complex) definition of virialised haloes. A minimal
group length of :math:`32` is often adopted in order to get a robust
catalogue of haloes and compute a good halo mass function.
Depending on the application, the choice of linking length and minimal group
size can vary. For cosmological applications, bound structures (dark matter
haloes) are traditionally identified using a linking length expressed as
:math:`0.2` of the mean inter-particle separation :math:`d` in the simulation
which is given by :math:`d = \sqrt[3]{\frac{V}{N}}`, where :math:`N` is the
number of particles in the simulation and :math:`V` is the simulation
(co-moving) volume. Experience shows that this produces groups that are similar
to the commonly adopted (but much more complex) definition of virialised
haloes. A minimal group length of :math:`32` is often adopted in order to get a
robust catalogue of haloes and compute a good halo mass function. Usually only
dark matter particles are considered for the number :math:`N`. In practice, the
mean inter-particle separation is evaluated based on the cosmology adopted in
the simulation. We use: :math:`d=\sqrt[3]{\frac{m_{\rm DM}}{\Omega_{\rm cdm}
\rho_{\rm crit}}}` for simulations with baryonic particles and
:math:`d=\sqrt[3]{\frac{m_{\rm DM}}{(\Omega_{\rm cdm} + \Omega_{\rm b})
\rho_{\rm crit}}}` for DMO simulations. In both cases, :math:`m_{\rm DM}` is the
mean mass of the DM particles. Using this definition (rather than basing in on
:math:`N`) makes the code robust to zoom-in scenarios where the entire volume is
not filled with particles.

For non-cosmological applications of the FOF algorithm, the choice of
the linking length is more difficult and left to the user. The choice
Expand Down
5 changes: 3 additions & 2 deletions doc/RTD/source/FriendsOfFriends/on_the_fly_fof.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ The main purpose of the on-the-fly FOF is to identify haloes during a
cosmological simulation in order to seed some of them with black holes
based on physical considerations.

**In this mode, no group catalogue is written to the disk. The resulting list
of haloes is only used internally by SWIFT.**
.. warning::
In this mode, no group catalogue is written to the disk. The resulting list
of haloes is only used internally by SWIFT.

Note that a catalogue can nevertheless be written after every seeding call by
setting the optional parameter ``dump_catalogue_when_seeding``.
Expand Down
10 changes: 9 additions & 1 deletion doc/RTD/source/FriendsOfFriends/parameter_description.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ absolute value using the parameter ``absolute_linking_length``. This is
expressed in internal units. This value will be ignored (and the ratio of
the mean inter-particle separation will be used) when set to ``-1``.

The categories of particles are specified using the ``linking_types`` and
``attaching_types`` arrays. They are of the length of the number of particle
types in SWIFT (currently 7) and specify for each type using ``1`` or ``0``
whether or not the given particle type is in this category. Types not present
in either category are ignored entirely.

The second important parameter is the minimal size of groups to retain in
the catalogues. This is given in terms of number of particles (of all types)
via the parameter ``min_group_size``. When analysing simulations, to
Expand Down Expand Up @@ -98,10 +104,12 @@ A full FOF section of the YAML parameter file looks like:
time_first: 0.2 # Time of first FoF black hole seeding calls.
delta_time: 1.005 # Time between consecutive FoF black hole seeding calls.
min_group_size: 256 # The minimum no. of particles required for a group.
linking_types: [0, 1, 0, 0, 0, 0, 0] # Which particle types to consider for linking (here only DM)
attaching_types: [1, 0, 0, 0, 1, 1, 0] # Which particle types to consider for attaching (here gas, stars, and BHs)
linking_length_ratio: 0.2 # Linking length in units of the main inter-particle separation.
seed_black_holes_enabled: 0 # Do not seed black holes when running FOF
black_hole_seed_halo_mass_Msun: 1.5e10 # Minimal halo mass in which to seed a black hole (in solar masses).
dump_catalogue_when_seeding: 0 # (Optional) Write a FOF catalogue when seeding black holes. Defaults to 0 if unspecified.
absolute_linking_length: -1. # (Optional) Absolute linking length (in internal units).
group_id_default: 2147483647 # (Optional) Sets the group ID of particles in groups below the minimum size.
group_id_offset: 1 # (Optional) Sets the offset of group ID labelling. Defaults to 1 if unspecified.
seed_black_holes_enabled: 0 # Do not seed black holes when running FOF
21 changes: 14 additions & 7 deletions doc/RTD/source/FriendsOfFriends/stand_alone_fof.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ compiled by configuring the code with the option
``--enable-stand-alone-fof``. The ``fof`` and ``fof_mpi`` executables
will then be generated alongside the regular SWIFT ones.

The executable takes a parameter file as an argument. It will then
read the snapshot specified in the parameter file and extract all
the dark matter particles by default. FOF is then run on these
particles and a catalogue of groups is written to disk. Additional
particle types can be read and processed by the stand-alone FOF
code by adding any of the following runtime parameters to the
command line:
The executable takes a parameter file as an argument. It will then read the
snapshot specified in the parameter file (specified as an initial condition
file) and extract all the dark matter particles by default. FOF is then run on
these particles and a catalogue of groups is written to disk. Additional
particle types can be read and processed by the stand-alone FOF code by adding
any of the following runtime parameters to the command line:

* ``--hydro``: Read and process the gas particles,
* ``--stars``: Read and process the star particles,
* ``--black-holes``: Read and process the black hole particles,
* ``--sinks``: Read and process the sink particles,
* ``--cosmology``: Consider cosmological terms.

Running with cosmology is necessary when using a linking length based
Expand All @@ -34,3 +34,10 @@ internal units). The FOF code will also write a snapshot with an
additional field for each particle. This contains the ``GroupID`` of
each particle and can be used to find all the particles in a given
halo and to link them to the information stored in the catalogue.

.. warning::

Note that since not all particle properties are read in stand-alone
mode, not all particle properties will be written to the snapshot generated
by the stand-alone FOF.

2 changes: 2 additions & 0 deletions examples/EAGLE_ICs/EAGLE_100/eagle_100.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ FOF:
black_hole_seed_halo_mass_Msun: 1.0e10 # Minimal halo mass in which to seed a black hole (in solar masses).
scale_factor_first: 0.05 # Scale-factor of first FoF black hole seeding calls.
delta_time: 1.00751 # Scale-factor ratio between consecutive FoF black hole seeding calls.
linking_types: [0, 1, 0, 0, 0, 0, 0] # Use DM as the primary FOF linking type
attaching_types: [1, 0, 0, 0, 1, 1, 0] # Use gas, stars and black holes as FOF attachable types

Scheduler:
max_top_level_cells: 64
Expand Down
2 changes: 2 additions & 0 deletions examples/EAGLE_ICs/EAGLE_12/eagle_12.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ FOF:
black_hole_seed_halo_mass_Msun: 1.0e10 # Minimal halo mass in which to seed a black hole (in solar masses).
scale_factor_first: 0.05 # Scale-factor of first FoF black hole seeding calls.
delta_time: 1.00751 # Scale-factor ratio between consecutive FoF black hole seeding calls.
linking_types: [0, 1, 0, 0, 0, 0, 0] # Use DM as the primary FOF linking type
attaching_types: [1, 0, 0, 0, 1, 1, 0] # Use gas, stars and black holes as FOF attachable types

Scheduler:
max_top_level_cells: 8
Expand Down
2 changes: 2 additions & 0 deletions examples/EAGLE_ICs/EAGLE_25/eagle_25.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ FOF:
black_hole_seed_halo_mass_Msun: 1.0e10 # Minimal halo mass in which to seed a black hole (in solar masses).
scale_factor_first: 0.05 # Scale-factor of first FoF black hole seeding calls.
delta_time: 1.00751 # Scale-factor ratio between consecutive FoF black hole seeding calls.
linking_types: [0, 1, 0, 0, 0, 0, 0] # Use DM as the primary FOF linking type
attaching_types: [1, 0, 0, 0, 1, 1, 0] # Use gas, stars and black holes as FOF attachable types

Scheduler:
max_top_level_cells: 16
Expand Down
2 changes: 2 additions & 0 deletions examples/EAGLE_ICs/EAGLE_25_low_res/eagle_25.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ FOF:
black_hole_seed_halo_mass_Msun: 1.0e10 # Minimal halo mass in which to seed a black hole (in solar masses).
scale_factor_first: 0.05 # Scale-factor of first FoF black hole seeding calls.
delta_time: 1.00751 # Scale-factor ratio between consecutive FoF black hole seeding calls.
linking_types: [0, 1, 0, 0, 0, 0, 0] # Use DM as the primary FOF linking type
attaching_types: [1, 0, 0, 0, 1, 1, 0] # Use gas, stars and black holes as FOF attachable types

Scheduler:
max_top_level_cells: 16
Expand Down
2 changes: 2 additions & 0 deletions examples/EAGLE_ICs/EAGLE_50/eagle_50.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ FOF:
black_hole_seed_halo_mass_Msun: 1.0e10 # Minimal halo mass in which to seed a black hole (in solar masses).
scale_factor_first: 0.05 # Scale-factor of first FoF black hole seeding calls.
delta_time: 1.00751 # Scale-factor ratio between consecutive FoF black hole seeding calls.
linking_types: [0, 1, 0, 0, 0, 0, 0] # Use DM as the primary FOF linking type
attaching_types: [1, 0, 0, 0, 1, 1, 0] # Use gas, stars and black holes as FOF attachable types

Scheduler:
max_top_level_cells: 32
Expand Down
2 changes: 2 additions & 0 deletions examples/EAGLE_ICs/EAGLE_50_low_res/eagle_50.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ FOF:
black_hole_seed_halo_mass_Msun: 1.0e10 # Minimal halo mass in which to seed a black hole (in solar masses).
scale_factor_first: 0.05 # Scale-factor of first FoF black hole seeding calls.
delta_time: 1.00751 # Scale-factor ratio between consecutive FoF black hole seeding calls.
linking_types: [0, 1, 0, 0, 0, 0, 0] # Use DM as the primary FOF linking type
attaching_types: [1, 0, 0, 0, 1, 1, 0] # Use gas, stars and black holes as FOF attachable types

Scheduler:
max_top_level_cells: 16
Expand Down
2 changes: 2 additions & 0 deletions examples/EAGLE_ICs/EAGLE_6/eagle_6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ FOF:
black_hole_seed_halo_mass_Msun: 1.0e10 # Minimal halo mass in which to seed a black hole (in solar masses).
scale_factor_first: 0.05 # Scale-factor of first FoF black hole seeding calls.
delta_time: 1.00751 # Scale-factor ratio between consecutive FoF black hole seeding calls.
linking_types: [0, 1, 0, 0, 0, 0, 0] # Use DM as the primary FOF linking type
attaching_types: [1, 0, 0, 0, 1, 1, 0] # Use gas, stars and black holes as FOF attachable types

Scheduler:
max_top_level_cells: 8
Expand Down
2 changes: 2 additions & 0 deletions examples/EAGLE_low_z/EAGLE_12/eagle_12.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ FOF:
black_hole_seed_halo_mass_Msun: 1.5e10 # Minimal halo mass in which to seed a black hole (in solar masses).
scale_factor_first: 0.91 # Scale-factor of first FoF black hole seeding calls.
delta_time: 1.005 # Scale-factor ratio between consecutive FoF black hole seeding calls.
linking_types: [0, 1, 0, 0, 0, 0, 0] # Use DM as the primary FOF linking type
attaching_types: [1, 0, 0, 0, 1, 1, 0] # Use gas, stars and black holes as FOF attachable types

# Parameters related to the initial conditions
InitialConditions:
Expand Down
2 changes: 2 additions & 0 deletions examples/EAGLE_low_z/EAGLE_25/eagle_25.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ FOF:
black_hole_seed_halo_mass_Msun: 1.5e10 # Minimal halo mass in which to seed a black hole (in solar masses).
scale_factor_first: 0.91 # Scale-factor of first FoF black hole seeding calls.
delta_time: 1.005 # Scale-factor ratio between consecutive FoF black hole seeding calls.
linking_types: [0, 1, 0, 0, 0, 0, 0] # Use DM as the primary FOF linking type
attaching_types: [1, 0, 0, 0, 1, 1, 0] # Use gas, stars and black holes as FOF attachable types

# Parameters related to the initial conditions
InitialConditions:
Expand Down
2 changes: 2 additions & 0 deletions examples/EAGLE_low_z/EAGLE_50/eagle_50.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ FOF:
black_hole_seed_halo_mass_Msun: 1.5e10 # Minimal halo mass in which to seed a black hole (in solar masses).
scale_factor_first: 0.91 # Scale-factor of first FoF black hole seeding calls.
delta_time: 1.005 # Scale-factor ratio between consecutive FoF black hole seeding calls.
linking_types: [0, 1, 0, 0, 0, 0, 0] # Use DM as the primary FOF linking type
attaching_types: [1, 0, 0, 0, 1, 1, 0] # Use gas, stars and black holes as FOF attachable types

# Parameters related to the initial conditions
InitialConditions:
Expand Down
Loading

0 comments on commit 47b3c40

Please sign in to comment.