pisces.particles.gadget.GadgetLikeParticleDataset.build_particle_dataset#
- classmethod GadgetLikeParticleDataset.build_particle_dataset(path: str | Path, number_of_particles: Sequence, box_size: unyt_quantity, *, ntypes: int = 6, unit_system: UnitSystem = None, overwrite: bool = False, fields: dict = None) GadgetLikeParticleDataset[source]#
Create a new Gadget-like particle dataset on disk.
This public factory method initializes a new HDF5 file containing the header, particle groups, and required fields in the Gadget/AREPO format. It is the main entry point for generating initial condition files or empty snapshot skeletons.
- Parameters:
path (
strorpathlib.Path) – Destination path for the new HDF5 file. If the file already exists andoverwriteis False, aFileExistsErroris raised.number_of_particles (
sequenceofint) – The number of particles of each type to include in the particle dataset. This should be a sequence (e.g., list or tuple) of lengthntypes, each element of which is a non-negative integer. If a particle type has zero particles, its group will not be created.box_size (
unyt.unyt_quantity) – The physical size of the simulation box. Must carry length units.ntypes (
int, default6) – Number of particle types to include. Gadget-like codes use six by default (0=gas, 1=DM, 2=disk, 3=bulge, 4=stars, 5=BH).unit_system (
unyt.UnitSystem, optional) – Unit system for tagging dataset attributes. If not provided, the class default is used.overwrite (
bool, defaultFalse) – If True, overwrite any existing file atpath. If False, raiseFileExistsErrorif the file exists.fields (
dict, optional) – Extra particle fields to populate. Keys must be of the form"PartTypeX.FieldName"where X is the particle type index. Values must beunyt.array.unyt_arrayornumpy.ndarraywith the correct leading dimension.
- Returns:
A dataset object representing the newly created HDF5 file.
- Return type:
- Raises:
FileExistsError – If the target file exists and
overwriteis False.ValueError – If the number of particles does not match
ntypesor if a field shape is inconsistent with its particle group.TypeError – If
unit_systemis not aunyt.UnitSysteminstance.
Notes
This overload describes the base API. Subclasses may add further keyword arguments for physics-specific fields (e.g. MHD, cooling).
At minimum, each populated particle type will include the required datasets:
Coordinates,Velocities,ParticleIDs, andMasses. Gas cells (PartType0) also includeDensityandInternalEnergy.