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():

  1. If masses is provided, use those values (must map model name → scalar mass).

  2. Otherwise, attempt to read total_mass from the model’s metadata via get_model_metadata().

Parameters:
  • models (str or list of str, optional) – Which models to include in the total mass calculation. If "all" (default), all models in models are used. If a single model name is provided as a string, it will be treated as a list containing that model.

  • masses (dict of str, unyt_quantity, optional) – Optional mapping from model name to its total mass. If provided for a given model, this value overrides the total_mass from metadata.

Returns:

The total mass of the specified models, with units of mass.

Return type:

unyt_quantity

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.