SWIFTSIM / HBTplus

HBTplus halo finder adapted for the FLAMINGO and COLIBRE simulations
0 stars 0 forks source link

New masking step to remove duplicate particles #35

Closed VictorForouhar closed 1 month ago

VictorForouhar commented 2 months ago

In HBT, particles that are unbound from their original subhalo are passed to the source subhalo of its parent. As the original subhalo also retains the particle, this leads to the same particle being across more than one source. This is not a problem if subhalos are in the same FOF, but if they are found in different hosts, we may find duplicate bound particles.

Fix #26 solved the case for particles that are found across FOF groups, but another special case leads to some duplications. This is when the troublesome particle is not part of a FOF group, since we are not applying the FOF exclusivity criteria to them.

To solve the issue, we believe we should update the sources of subhaloes (i.e. Particles vector) after saving the bound properties. By applying a masking step, we can assign particles to a single source subgroup, typically the deepest one in the hierarchy (unless the source subhalo has been truncated).

To prevent the accidental removal of the 10 most bound tracer particles (important for tracers and boundness criteria) we first apply the masking on the 10 most bound tracers from top to bottom, and then on the remaining particles from bottom to top.

VictorForouhar commented 2 months ago

Related to #29

VictorForouhar commented 2 months ago

I have tested on the first snapshot in COLIBRE where there are substructures. Results seem sensible.

Example 1: all particles are bound to their respective subhaloes, so no cross-contamination of the source has happened.

Inside MaskTopBottom  looking at subhalo entry 47 with TrackID 47 (central)
Inside MaskTopBottom  looking at subhalo entry 48 with TrackID 48 (satellite)
TrackID = 48 (satellite) will mask out 0 particles out of its original Nsource (Nbound) 42 (42)
TrackID = 47 (central) will mask out 0 particles out of its original Nsource (Nbound) 113 (88)

Example 2: two particles of a satellite were unbound from it, and are bound to the central. The masking removes these two particles from the source of the central.

Inside MaskTopBottom looking at subhalo entry 68 with TrackID 68 (central)
Inside MaskTopBottom looking at subhalo entry 50 with TrackID 50 (satellite)
TrackID = 50 (satellite)  will mask out 0 particles out of its original Nsource (Nbound) 64 (62)
TrackID = 68 (central) will mask out 2 particles out of its original Nsource (Nbound) 514 (488)
VictorForouhar commented 1 month ago

The latest commit was tested in COLIBRE and FLAMINGO L1000N1800 box, which ran without crashing and resulted in no duplicate particles.

VictorForouhar commented 1 month ago

Something that still needs to be done is to get the saving of the Src files done correctly. An initial test results in a crash when doing a restart.