pisces.models.stars.polytropes.PolytropicStarModel.generate_particles#
- PolytropicStarModel.generate_particles(filename: str | Path, num_particles: dict[str, int], overwrite: bool = False) ParticleDataset #
Convert this galaxy cluster model into a particle dataset.
This method creates a particle representation of the model by sampling positions, and interpolating model fields onto particles. The output is written to disk in the form of a
particles.base.ParticleDataset
.- Parameters:
filename (
str
orPath
) – Filesystem path where the output particle dataset should be saved. If the path already exists, it will be overwritten if overwrite=True.num_particles (
dict
ofstr
,int
) –The number of each type of particle to generate. The dictionary may contain any of the following keys:
['gas',]
and values should correspond to the number of particles to be generated of each species.If a species is provided but is not one of the allowed particle types, then an error will be raised.
overwrite (
bool
, optional) – Whether to overwrite an existing file at path. Default is False.
- Returns:
The newly created and populated particle dataset. For each particle type, the particle positions, velocities, and masses will be included along with any other relevant fields that were interpolated from the model.
- Return type:
ParticleDataset
Notes
The particle generation process follows two main steps:
Sampling: Radial positions are sampled from the species-specific mass profile (interpreted as a CDF), and converted into 3D Cartesian coordinates. This ensures that particles are distributed according to the model’s density. Masses are assigned to each particle species so that each species has equal masses across all particles.
Interpolation: Once the particle positions are established, the values of various model fields can be assigned to each particle via interpolation.