Skip to main content

ZeroCenterAngularMomentum

Trait ZeroCenterAngularMomentum 

Source
pub trait ZeroCenterAngularMomentum<B, S> {
    // Required method
    fn zero_center_angular_momentum_with_filter<F: Fn(&Tagged<Body<B, S>>) -> bool>(
        &mut self,
        should_zero_body: F,
    );

    // Provided method
    fn zero_center_angular_momentum(&mut self) { ... }
}
Expand description

Remove angular motion about the system’s center of mass.

ZeroCenterAngularMomentum adjusts the translational momentum of every body in order to zero out the total angular momentum of the system about the center of mass (ignoring periodic boundary conditions).

§2D

In 2D, ZeroCenterAngularMomentum applies:

\vec{p}_{i,\mathrm{new}} = \vec{p}_{i,\mathrm{old}} - \left( [-r_{ci}^{y}, r_{ci}^{x}] \right) \frac{L_c}{I_c} m_i

where $i$ is the index of each body in a system, $L_c$ is the angular momentum about the center of mass, $I_c$ is the moment of inertia about the center of mass, and $\vec{r}_{ci}$ is the position of body i relative to the center of mass.

§3D

In 3D, ZeroCenterAngularMomentum applies:

\vec{p}_{i,\mathrm{new}} = \vec{p}_{i,\mathrm{old}} - \left( \vec{\omega}_c \times \vec{r}_{ci} \right) m_i

where $i$ is the index of each body in a system, $\vec{\omega}_c$ is angular velocity about the center of mass, and $\vec{r}_{ci}$ is the position of body i relative to the center of mass.

$\vec{\omega}_c$ is obtained by solving the following linear system:

\mathbf{I}_c \vec{\omega}_c = \vec{L}_c

where $\mathbf{I}_c$ is the moment of inertia about the center of mass, and $\vec{L}_c$ is the angular momentum about the center of mass.

§Example

use hoomd_md::ZeroCenterAngularMomentum;
use hoomd_microstate::{
    Body, Microstate,
    property::{DynamicPoint, Point},
};
use hoomd_vector::Cartesian;

let mut microstate = Microstate::builder()
    .bodies([
        Body::single_site(
            DynamicPoint {
                position: Cartesian::from([1.0, 2.0]),
                momentum: Cartesian::from([-2.0, 4.0]),
                ..Default::default()
            },
            Point::default(),
        ),
        Body::single_site(
            DynamicPoint {
                position: Cartesian::from([-2.0, 3.0]),
                momentum: Cartesian::from([3.0, -6.0]),
                ..Default::default()
            },
            Point::default(),
        ),
    ])
    .try_build()?;

microstate.zero_center_angular_momentum();

Required Methods§

Source

fn zero_center_angular_momentum_with_filter<F: Fn(&Tagged<Body<B, S>>) -> bool>( &mut self, should_zero_body: F, )

Adjust each selected body’s translational momentum in order to zero the system’s overall angular momentum about the center of mass..

Provided Methods§

Source

fn zero_center_angular_momentum(&mut self)

Adjust each body’s angular translational momentum in order to zero the system’s overall angular momentum about the center of mass.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<R, S, X, C> ZeroCenterAngularMomentum<DynamicOrientedPoint<Cartesian<2>, R>, S> for Microstate<DynamicOrientedPoint<Cartesian<2>, R>, S, X, C>

Source§

fn zero_center_angular_momentum_with_filter<F: Fn(&Tagged<Body<DynamicOrientedPoint<Cartesian<2>, R>, S>>) -> bool>( &mut self, should_zero_body: F, )

Source§

impl<R, S, X, C> ZeroCenterAngularMomentum<DynamicOrientedPoint<Cartesian<3>, R>, S> for Microstate<DynamicOrientedPoint<Cartesian<3>, R>, S, X, C>

Source§

fn zero_center_angular_momentum_with_filter<F: Fn(&Tagged<Body<DynamicOrientedPoint<Cartesian<3>, R>, S>>) -> bool>( &mut self, should_zero_body: F, )

Source§

impl<S, X, C> ZeroCenterAngularMomentum<DynamicPoint<Cartesian<2>>, S> for Microstate<DynamicPoint<Cartesian<2>>, S, X, C>

Source§

fn zero_center_angular_momentum_with_filter<F: Fn(&Tagged<Body<DynamicPoint<Cartesian<2>>, S>>) -> bool>( &mut self, should_zero_body: F, )

Source§

impl<S, X, C> ZeroCenterAngularMomentum<DynamicPoint<Cartesian<3>>, S> for Microstate<DynamicPoint<Cartesian<3>>, S, X, C>

Source§

fn zero_center_angular_momentum_with_filter<F: Fn(&Tagged<Body<DynamicPoint<Cartesian<3>>, S>>) -> bool>( &mut self, should_zero_body: F, )

Implementors§