Skip to main content

RotationalKineticEnergy

Trait RotationalKineticEnergy 

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

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

Compute the rotational kinetic energy of bodies in a microstate.

RotationalKineticEnergy is implemented for Microstate. Call microstate.rotational_kinetic_energy to compute the total rotational 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 rotational_kinetic_energy_with_filter.

§2D

In 2D, each body has only 0 or 1 rotational degree of freedom. Set $L = 0$ to deactivate rotations for a body. The total number of degrees of freedom is then:

\mathrm{degrees\_of\_freedom} = \sum_{i \in \mathrm{selection}} \left| L_i \ne 0 \right|

where $\left| \right|$ is the Iverson bracket.

The kinetic energy is

K = \sum_{i \in \mathrm{selection}} \frac{L_i^2}{2I}

(ignoring terms where the moment of inertia is zero).

§3D

In 3D, there are 0 to 3 degrees of freedom per body. Set $I_{xx}=0$, $I_{yy}=0$, and/or $I_{zz}=0$ to deactivate rotations one or more axes. The total number of degrees of freedom is then:

\mathrm{degrees\_of\_freedom} = \sum_{i \in \mathrm{selection}} \left| I_{xx,i} \ne 0 \right| + \left| I_{yy,i} \ne 0 \right| + \left| I_{zz,i} \ne 0 \right|

The kinetic energy is

K = \sum_{i \in \mathrm{selection}}\frac{L_{x,i}(t)^2}{2I_{xx,i}} + \frac{L_{y,i}(t)^2}{2I_{yy,i}} + \frac{L_{z,i}(t)^2}{2I_{zz,i}}

(ignoring terms where the moment of inertia is zero).

§Example

use hoomd_md::RotationalKineticEnergy;
use hoomd_microstate::{
    Body, Microstate,
    property::{DynamicOrientedPoint, Point},
};
use hoomd_vector::{Angle, Cartesian};

let microstate: Microstate<
    DynamicOrientedPoint<Cartesian<2>, Angle>,
    _,
    _,
    _,
> = Microstate::builder()
    .bodies([
        Body::single_site(
            DynamicOrientedPoint {
                moment_of_inertia: 0.0,
                ..Default::default()
            },
            Point::default(),
        ),
        Body::single_site(
            DynamicOrientedPoint {
                moment_of_inertia: 2.0,
                angular_momentum: 8.0,
                ..Default::default()
            },
            Point::default(),
        ),
        Body::single_site(
            DynamicOrientedPoint {
                moment_of_inertia: 4.0,
                angular_momentum: 3.0,
                ..Default::default()
            },
            Point::default(),
        ),
    ])
    .try_build()?;

let (rotational_kinetic_energy, rotational_degrees_of_freedom) =
    microstate.rotational_kinetic_energy();

Required Methods§

Source

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

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

Provided Methods§

Source

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

Compute the total rotational 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<P, S, X, C> RotationalKineticEnergy<DynamicOrientedPoint<P, Angle>, S> for Microstate<DynamicOrientedPoint<P, Angle>, S, X, C>
where P: Wedge + Outer,

Source§

fn rotational_kinetic_energy_with_filter<F: Fn(&Tagged<Body<DynamicOrientedPoint<P, Angle>, S>>) -> bool>( &self, should_sum_body: F, ) -> (f64, usize)

Source§

impl<P, S, X, C> RotationalKineticEnergy<DynamicOrientedPoint<P, Versor>, S> for Microstate<DynamicOrientedPoint<P, Versor>, S, X, C>
where P: Wedge + Outer,

Source§

fn rotational_kinetic_energy_with_filter<F: Fn(&Tagged<Body<DynamicOrientedPoint<P, Versor>, S>>) -> bool>( &self, should_sum_body: F, ) -> (f64, usize)

Implementors§