narupatools.physics.rigidbody

Methods for dealing with systems of particles, such as center of mass.

Methods here are not specific with units - as long as arguments are provided in consistent units, then the calculated result will be correct.

Functions

angular_velocity

Calculate the angular velocity of a set of particles.

center_of_mass

Calculate the center of mass \(R\) of a collection of particles.

center_of_mass_acceleration

Calculate the acceleration of the center of mass of a collection of particles.

center_of_mass_velocity

Calculate the velocity of the center of mass of a collection of particles.

distribute_angular_velocity

Calculate the velocities that correspond to an angular velocity about an origin.

kinetic_energy

Calculate the total kinetic energy of a set of particles.

moment_of_inertia_tensor

Calculate the moment of inertia tensor of a set of particles.

orbital_angular_momentum

Calculate the orbital angular momentum of a set of particles about an origin.

spin_angular_momentum

Calculate the spin angular momentum of a set of particles.

narupatools.physics.rigidbody.angular_velocity(*, masses: numpy.ndarray[Any, numpy.dtype[numpy.float64]], positions: numpy.ndarray[Any, numpy.dtype[numpy.float64]], velocities: numpy.ndarray[Any, numpy.dtype[numpy.float64]])numpy.ndarray[Any, numpy.dtype[numpy.float64]]

Calculate the angular velocity of a set of particles.

This is peformed by calculating the angular momentum about the center of mass, and inverting the inertia tensor to obtain \(\omega\):

\[\omega = I^{-1} L\]
Parameters
  • masses – List of masses \(m_i\) of each particle.

  • positions – List of positions \(R_i\) of each particle.

  • velocities – List of velocities \(V_i\) of each particle.

Returns

Angular velocity \(\omega\) in units of radians / [time].

narupatools.physics.rigidbody.center_of_mass(*, masses: Union[numpy.ndarray[Any, numpy.dtype[numpy.float64]], Sequence[float]], positions: Union[numpy.ndarray[Any, numpy.dtype[numpy.float64]], Sequence[numpy.ndarray[Any, numpy.dtype[numpy.float64]]], Sequence[Sequence[float]]])numpy.ndarray[Any, numpy.dtype[numpy.float64]]

Calculate the center of mass \(R\) of a collection of particles.

This is defined as the mass weighted average position:

\[R = \frac{\sum_i m_i r_i}{\sum_i m_i}\]
Parameters
  • masses – List of masses \(m_i\) of each particle.

  • positions – List of positions \(r_i\) of each particle.

Raises

ValueError – Masses and position arrays are different lengths.

Returns

Center of mass of the particles, in the same units as positions was provided in.

narupatools.physics.rigidbody.center_of_mass_acceleration(*, masses: Union[numpy.ndarray[Any, numpy.dtype[numpy.float64]], Sequence[float]], accelerations: Union[numpy.ndarray[Any, numpy.dtype[numpy.float64]], Sequence[numpy.ndarray[Any, numpy.dtype[numpy.float64]]], Sequence[Sequence[float]]])numpy.ndarray[Any, numpy.dtype[numpy.float64]]

Calculate the acceleration of the center of mass of a collection of particles.

This is defined as the mass weighted average acceleration:

\[A_R = \frac{\sum_i m_i a_i}{\sum_i a_i}\]
Parameters
  • masses – List of masses \(m_i\) of each particle.

  • accelerations – List of accelerations \(a_i\) of each particle.

Returns

Acceleration of the center of mass of the particles, in units of [distance] / [time] ** 2.

narupatools.physics.rigidbody.center_of_mass_velocity(*, masses: Union[numpy.ndarray[Any, numpy.dtype[numpy.float64]], Sequence[float]], velocities: Union[numpy.ndarray[Any, numpy.dtype[numpy.float64]], Sequence[numpy.ndarray[Any, numpy.dtype[numpy.float64]]], Sequence[Sequence[float]]])numpy.ndarray[Any, numpy.dtype[numpy.float64]]

Calculate the velocity of the center of mass of a collection of particles.

This is defined as the mass weighted average velocity:

\[V_R = \frac{\sum_i m_i v_i}{\sum_i v_i}\]
Parameters
  • masses – List of masses \(m_i\) of each particle.

  • velocities – List of velocities \(v_i\) of each particle.

Returns

Velocity of the center of mass of the particles, in units of [distance] / [time].

narupatools.physics.rigidbody.distribute_angular_velocity(*, masses: Optional[Union[numpy.ndarray[Any, numpy.dtype[numpy.float64]], Sequence[float]]] = None, positions: Union[numpy.ndarray[Any, numpy.dtype[numpy.float64]], Sequence[numpy.ndarray[Any, numpy.dtype[numpy.float64]]], Sequence[Sequence[float]]], angular_velocity: Union[numpy.ndarray[Any, numpy.dtype[numpy.float64]], Sequence[float]], origin: Optional[Union[numpy.ndarray[Any, numpy.dtype[numpy.float64]], Sequence[float]]] = None)numpy.ndarray[Any, numpy.dtype[numpy.float64]]

Calculate the velocities that correspond to an angular velocity about an origin.

This is defined by:

\[v_i = \omega \times (r_i - c)\]

The origin \(c\) defaults to the center of mass of the particles.

Parameters
  • masses – List of masses \(m_i\) of each particle.

  • positions – List of positions \(R_i\) of each particle.

  • angular_velocity – Angular velocity \(\omega\) to assign to the system.

  • origin – Origin \(c\) to calculate velocity about.

Raises

ValueError – Neither an origin or masses are provided.

Returns

Velocities \(V_i\) in units of [distance] / [time].

narupatools.physics.rigidbody.kinetic_energy(*, masses: Union[numpy.ndarray[Any, numpy.dtype[numpy.float64]], Sequence[float]], velocities: Union[numpy.ndarray[Any, numpy.dtype[numpy.float64]], Sequence[numpy.ndarray[Any, numpy.dtype[numpy.float64]]], Sequence[Sequence[float]]])float

Calculate the total kinetic energy of a set of particles.

This is given by:

\[K = \frac{1}{2} \sum_i m_i v_i^2\]
Parameters
  • masses – List of masses \(m_i\) of each particle.

  • velocities – List of velocities \(v_i\) of each particle.

Returns

Kinetic energy \(K\) in units of [distance] / [time].

narupatools.physics.rigidbody.moment_of_inertia_tensor(*, masses: numpy.ndarray[Any, numpy.dtype[numpy.float64]], positions: numpy.ndarray[Any, numpy.dtype[numpy.float64]], origin: Optional[Union[numpy.ndarray[Any, numpy.dtype[numpy.float64]], Sequence[float]]] = None)numpy.ndarray[Any, numpy.dtype[numpy.float64]]

Calculate the moment of inertia tensor of a set of particles.

This matrix fulfills the identity:

\[I v = \sum_i m_i r_i \times (v \times r_i)\]

for all vectors \(v\). Here, \(r_i\) is the position of the i-th particle relative to the center of mass.

By default, the origin is taken to be the center of mass.

Parameters
  • masses – List of masses \(m_i\) of each particle.

  • positions – List of positions \(R_i\) of each particle.

  • origin – Optional origin to calculate the moment of inertia around. Defaults to the center of mass.

Returns

Moment of inertia tensor \(I\) with respect to the center of mass, in units of [mass] * [distance] squared

narupatools.physics.rigidbody.orbital_angular_momentum(*, masses: numpy.ndarray[Any, numpy.dtype[numpy.float64]], positions: numpy.ndarray[Any, numpy.dtype[numpy.float64]], velocities: numpy.ndarray[Any, numpy.dtype[numpy.float64]], origin: Optional[Union[numpy.ndarray[Any, numpy.dtype[numpy.float64]], Sequence[float]]] = None)numpy.ndarray[Any, numpy.dtype[numpy.float64]]

Calculate the orbital angular momentum of a set of particles about an origin.

This is defined as:

\[L = M (R - c) \times V\]

where \(M\), \(R\) and \(V\) are the total mass, center of mass and the velocity of the center of mass respectively.

The origin defaults to the origin (0, 0, 0).

Parameters
  • masses – List of masses \(m_i\) of each particle.

  • positions – List of positions \(R_i\) of each particle.

  • velocities – List of velocities \(V_i\) of each particle.

  • origin – Origin about where to calculate the orbital angular momentum.

Returns

Orbital angular momentum \(L\) in units of [mass] * [distance] squared / [time].

narupatools.physics.rigidbody.spin_angular_momentum(*, masses: numpy.ndarray[Any, numpy.dtype[numpy.float64]], positions: numpy.ndarray[Any, numpy.dtype[numpy.float64]], velocities: numpy.ndarray[Any, numpy.dtype[numpy.float64]])numpy.ndarray[Any, numpy.dtype[numpy.float64]]

Calculate the spin angular momentum of a set of particles.

This is defined as:

\[L = \sum_i m_i r_i \times v_i\]

where \(r_i\) and \(v_i\) are the particles’ position and velocity relative to the center of mass.

Parameters
  • masses – List of masses \(m_i\) of each particle.

  • positions – List of positions \(R_i\) of each particle.

  • velocities – List of velocities \(V_i\) of each particle.

Returns

Spin angular momentum \(L\) in units of [mass] * [distance] squared / [time].