pisces.extensions.simulation.core.initial_conditions.InitialConditions2DCartesian.compute_center_of_mass_velocity#
- InitialConditions2DCartesian.compute_center_of_mass_velocity(models: str | list[str] = 'all', masses: dict[str, unyt_quantity] | None = None)#
Compute the mass-weighted center-of-mass (COM) velocity for one or more models in the initial conditions.
The COM velocity is:
\[\mathbf{V}_{\mathrm{COM}} = \frac{\sum_i m_i \mathbf{v}_i}{\sum_i m_i}\]where
m_iis the total mass of modeliandv_iis its velocity vector.- Mass values are obtained in the following order:
If
massesis provided, use those values (must map model name → scalar mass).Otherwise, attempt to read
total_massfrom the model’s metadata.
- Parameters:
models (
strorlistofstr, optional) – Which models to include in the COM velocity calculation. If"all", all models inmodelsare used. If a single model name is given, it will be treated as a list of one.masses (
dictofstr,unyt_quantity, optional) – Optional mapping from model name to its total mass. Overridestotal_massin metadata if provided.
- Returns:
The COM velocity vector with shape
(ndim,)and units of velocity.- 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.