Skip to main content

ZeroCenterMomentum

Trait ZeroCenterMomentum 

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

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

Remove translational motion from the system’s center of mass.

ZeroCenterMomentum subtracts the average momentum from every body’s momentum:

\vec{p}_{i,\mathrm{new}} = \vec{p}_{i,\mathrm{old}} - \langle \vec{p}_\mathrm{old} \rangle

§Example

use hoomd_md::ZeroCenterMomentum;
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_momentum();

Required Methods§

Source

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

Subtract the average momentum from each selected body’s momentum.

Provided Methods§

Source

fn zero_center_momentum(&mut self)

Subtract the average momentum from each body’s momentum.

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<const N: usize, B, S, X, C> ZeroCenterMomentum<B, S> for Microstate<B, S, X, C>
where B: Position<Position = Cartesian<N>> + Momentum<Momentum = Cartesian<N>> + Transform<S> + Clone, S: Position<Position = Cartesian<N>> + Default, X: PointUpdate<Cartesian<N>, SiteKey>, C: Wrap<B> + Wrap<S> + GenerateGhosts<S>,

Source§

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

Implementors§