pisces.extensions.simulation.core.initial_conditions.InitialConditions.compute_total_mass#
- InitialConditions.compute_total_mass(models: str | list[str] = 'all', masses: dict[str, unyt_quantity] | None = None) unyt_quantity [source]#
Compute the total mass of one or more models in the initial conditions.
Mass values are determined in the same order as in
compute_center_of_mass()
:If
masses
is provided, use those values (must map model name → scalar mass).Otherwise, attempt to read
total_mass
from the model’s metadata viaget_model_metadata()
.
- Parameters:
models (
str
orlist
ofstr
, optional) – Which models to include in the total mass calculation. If"all"
(default), all models inmodels
are used. If a single model name is provided as a string, it will be treated as a list containing that model.masses (
dict
ofstr
,unyt_quantity
, optional) – Optional mapping from model name to its total mass. If provided for a given model, this value overrides thetotal_mass
from metadata.
- Returns:
The total mass of the specified models, with units of mass.
- Return type:
- Raises:
KeyError – If any specified model name is not found in the initial conditions.
ValueError – If a required mass is missing from both
masses
and the model metadata.