pisces.extensions.simulation.core.initial_conditions.InitialConditions3DCartesian.compute_total_mass#
- InitialConditions3DCartesian.compute_total_mass(models: str | list[str] = 'all', masses: dict[str, unyt_quantity] | None = None) unyt_quantity#
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
massesis provided, use those values (must map model name → scalar mass).Otherwise, attempt to read
total_massfrom the model’s metadata viaget_model_metadata().
- Parameters:
models (
strorlistofstr, optional) – Which models to include in the total mass calculation. If"all"(default), all models inmodelsare used. If a single model name is provided as a string, it will be treated as a list containing that model.masses (
dictofstr,unyt_quantity, optional) – Optional mapping from model name to its total mass. If provided for a given model, this value overrides thetotal_massfrom 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
massesand the model metadata.