Skip to main content

ThermalizeMomentum

Trait ThermalizeMomentum 

Source
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§

Source

fn thermalize_momentum_with_filter<F: Fn(&Tagged<Body<B, S>>) -> bool>( &mut self, temperature: f64, should_thermalize_body: F, )

Assign thermally distributed random momenta to selected bodies in the microstate.

Provided Methods§

Source

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.

Implementations on Foreign Types§

Source§

impl<const N: usize, B, S, X, C> ThermalizeMomentum<B, S> for Microstate<B, S, X, C>
where B: Position<Position = Cartesian<N>> + Momentum<Momentum = Cartesian<N>> + Mass + Transform<S> + Clone, S: Position<Position = Cartesian<N>> + Default, X: PointUpdate<Cartesian<N>, SiteKey>, C: Wrap<B> + Wrap<S> + GenerateGhosts<S>,

Source§

fn thermalize_momentum_with_filter<F: Fn(&Tagged<Body<B, S>>) -> bool>( &mut self, temperature: f64, should_thermalize_body: F, )

Implementors§