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§
Provided Methods§
Sourcefn zero_center_momentum(&mut self)
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.