pub trait ThermalizeMomentum<B, S> {
// Required method
fn thermalize_momentum_with_filter<F: Fn(&Tagged<Body<B, S>>) -> bool>(
&mut self,
temperature: f64,
should_thermalize_body: F,
);
// Provided method
fn thermalize_momentum(&mut self, temperature: f64) { ... }
}Expand description
Draw random momenta from a thermal distribution.
In the Maxwell–Boltzmann distribution, each component of the momentum $p_i$
is normally distributed with mean 0 and variance $ \sigma^2 = m k T$:
f(p_i) = \frac{1}{\sqrt{2 \pi m k T}} \exp{\left( -\frac{p_i^2}{2 m k T} \right)}where $f$ is probability, $m$ is mass, $k$ is the Boltzmann
constant, and $T$ is temperature.
The momenta generated by ThermalizeMomentum do not collectively sum to
zero. To zero the effective momentum of the system’s center of mass, use
ZeroCenterMomentum.
§Example
use hoomd_md::ThermalizeMomentum;
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]),
..Default::default()
},
Point::default(),
),
Body::single_site(
DynamicPoint {
position: Cartesian::from([-2.0, 3.0]),
..Default::default()
},
Point::default(),
),
])
.try_build()?;
microstate.thermalize_momentum(1.5);Required Methods§
Provided Methods§
Sourcefn thermalize_momentum(&mut self, temperature: f64)
fn thermalize_momentum(&mut self, temperature: f64)
Assign thermally distributed random momenta to all bodies in the microstate.
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.