Skip to main content

TranslationalKineticEnergy

Trait TranslationalKineticEnergy 

Source
pub trait TranslationalKineticEnergy<B, S> {
    // Required method
    fn translational_kinetic_energy_with_filter<F: Fn(&Tagged<Body<B, S>>) -> bool>(
        &self,
        should_sum_body: F,
    ) -> (f64, usize);

    // Provided method
    fn translational_kinetic_energy(&self) -> (f64, usize) { ... }
}
Expand description

Compute the translational kinetic energy of bodies in a microstate.

TranslationalKineticEnergy is implemented for Microstate. Call microstate.translational_kinetic_energy to compute the total translational kinetic energy (and degrees of freedom) of all bodies in the microstate. Energy can be calculated for a subset of bodies using the companion method translational_kinetic_energy_with_filter.

Sum the per-body kinetic energies:

K = \sum_{i \in \mathrm{selection}} \frac{\vec{p}_i \cdot \vec{p}_i}{2m_i}

Count the degrees of freedom of each selected body:

\mathrm{degrees\_of\_freedom} = \sum_{i \in \mathrm{selection}} D

where D is the dimensionality of momentum vector space.

§Example

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

let microstate = Microstate::builder()
    .bodies([
        Body::single_site(
            DynamicPoint {
                mass: 2.0,
                momentum: Cartesian::<2>::from([2.0, 0.0]),
                ..Default::default()
            },
            Point::default(),
        ),
        Body::single_site(
            DynamicPoint {
                mass: 4.0,
                momentum: Cartesian::<2>::from([1.0, 1.0]),
                ..Default::default()
            },
            Point::default(),
        ),
        Body::single_site(
            DynamicPoint {
                mass: 3.0,
                momentum: Cartesian::<2>::from([-4.0, -2.0]),
                ..Default::default()
            },
            Point::default(),
        ),
    ])
    .try_build()?;
let (translational_kinetic_energy, translational_degrees_of_freedom) =
    microstate.translational_kinetic_energy();

Required Methods§

Source

fn translational_kinetic_energy_with_filter<F: Fn(&Tagged<Body<B, S>>) -> bool>( &self, should_sum_body: F, ) -> (f64, usize)

Compute the total translational kinetic energy and degrees of freedom over selected bodies in the microstate.

Provided Methods§

Source

fn translational_kinetic_energy(&self) -> (f64, usize)

Compute the total translational kinetic energy and degrees of freedom over 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<V, B, S, X, C> TranslationalKineticEnergy<B, S> for Microstate<B, S, X, C>
where V: InnerProduct, B: Momentum<Momentum = V> + Mass,

Source§

fn translational_kinetic_energy_with_filter<F: Fn(&Tagged<Body<B, S>>) -> bool>( &self, should_sum_body: F, ) -> (f64, usize)

Implementors§