yt-project / yt_astro_analysis

yt astrophysical analysis modules
Other
22 stars 21 forks source link

Finding Halos with Two Separate Particle Species Contributing to the Structure #210

Open Ecskrabacz10 opened 1 year ago

Ecskrabacz10 commented 1 year ago

This is not a bug, but it is a question of Rockstar's capabilities.

I am currently running some simulations with two forms of Dark Matter, decaying and stable. With these simulations, I am using yt_astro_analysis' capabilities with Rockstar to find halos. I was looking through the code for how Rockstar runs, and I found this section in the _setup_parameters function of RockstarHaloFinder in the rockstar.py file.

particle_mass = self.particle_mass
if particle_mass is None:
    pmass_min, pmass_max = dd.quantities.extrema(
        (ptype, self.mass_field), non_zero=True
    )
    particle_mass = pmass_min
elif isinstance(particle_mass, (tuple, list)) and len(particle_mass) == 2:
    particle_mass = tds.quan(*particle_mass)
elif not isinstance(particle_mass, unyt_quantity):
    particle_mass = tds.quan(particle_mass, "Msun / h")
particle_mass.convert_to_units("Msun / h")

Before this section of code, self.particle_mass = None and I have passed in the particle type all, which includes both the stable dark matter and decaying dark matter species. I want both species to contribute to the halos, but this code seems like all of the particles' masses will be set to the species that has the lower mass.

Is there a way for me to allow both species to have their pre-defined masses instead of being assigned by Rockstar? Is this possible to do already or should I make some code to allow for multiple species?

matthewturk commented 1 year ago

Is it possible to get nearer to what you want with a ParticleUnion? https://yt-project.org/doc/analyzing/filtering.html

brittonsmith commented 1 year ago

As I read the code, specifically rockstar_interface.pyx, we are still getting individual particle masses from the mass array. According to the docstring on the RockstarHaloFinder class, the particle_mass keyword is now only used to compute the mean interparticle spacing. This probably needs to be clarified somewhere in the documentation.

Ecskrabacz10 commented 1 year ago

That is wonderful to hear. For some more context, the two particle species have vastly different masses (one can end up being practically zero, while the other is constant at around 10^10 Msun). Would these different masses have a greater impact on the mean interparticle spacing? Would this possible impact on mean interparticle spacing directly affect how Rockstar finds halos?

Ecskrabacz10 commented 1 year ago

As for a separate issue, is there a place where I can edit the code in my yt-astro-analysis to account for only the first N particles in the simulation?

I am trying to run Rockstar with a time series, so I cannot perform ad = ds.all_data() for all the timesteps before sending the time series into Rockstar as that would overload the memory on the computer.

brittonsmith commented 1 year ago

That is wonderful to hear. For some more context, the two particle species have vastly different masses (one can end up being practically zero, while the other is constant at around 10^10 Msun). Would these different masses have a greater impact on the mean interparticle spacing? Would this possible impact on mean interparticle spacing directly affect how Rockstar finds halos?

I honestly cannot say. This question is specific to the Rockstar algorithm, which I don't understand all that well. The mean interparticle spacing informs the linking length used in the friend-of-friends step. That's about all I can contribute to the understanding here. I'm not sure if there is Rockstar mailing list. You might just have to experiment with doing it with and without the low-mass particles.

I am trying to run Rockstar with a time series, so I cannot perform ad = ds.all_data() for all the timesteps before sending the time series into Rockstar as that would overload the memory on the computer.

I'm not sure I understand why you would need to do this. It should not be necessary.