pub struct MartynaTuckermanTobiasKlein { /* private fields */ }Expand description
Nosé-Hoover thermostat.
MartynaTuckermanTobiasKlein adds a new degree of freedom ($\eta$)
to a molecular dynamics simulation in such a way that the existing
degrees of freedom sample a constant temperature ensemble. Each
MartynaTuckermanTobiasKlein instance stores $\eta$ and its momentum,
$\xi$, internally.
The extended Hamiltonian $H$ is:
H = K + U
+ N kT \eta
+ \frac{1}{2} N kT \tau^2\xi^2Where $K$ is the kinetic energy of the system, $U$ is the potential
energy of the system, $N$ is the number of degrees of freedom, and $kT$
is the temperature.
Following the Trotter decomposition of Liouvillian,
MartynaTuckermanTobiasKlein integrates $\eta$ and $\xi$ forward
by half time step $\frac{\delta t}{2}$ via the following procedure:
\begin{align*}
G_\mathrm{old} &= \frac{1}{\tau^2} \left( \frac{2 K}{N kT} - 1 \right) \\
\xi \left\{ t+\frac{\delta t} {4} \right\} &= \xi \{ t \} + G_\mathrm{old}\frac{\delta t}{4} \\
\alpha &= \exp\left[ -\xi \left\{ t+\frac{\delta t} {4} \right\} \frac{dt}{2} \right] \\
K_{new} &= K \alpha^2 \\
\eta \left\{ t+\frac{\delta t} {2} \right\} &= \eta \{ t \} + \xi \left\{ t+\frac{\delta t} {4} \right\} \frac{\delta t}{2} \\
G_\mathrm{new} &= \frac{1}{\tau^2} \left( \frac{2 K_\mathrm{new} }{kT} - 1 \right) \\
\xi \left\{ t+\frac{\delta t} {2} \right\} &= \xi \left\{ t+\frac{\delta t} {4} \right\} + G_\mathrm{new} \frac{\delta t}{4}
\end{align*}§Warning
MartynaTuckermanTobiasKlein fails to sample the correct distribution when there are
strong harmonic interactions in the system. In such situations, use
Bussi or NoséHooverChain instead.
§References
§Example
use hoomd_md::thermostat::MartynaTuckermanTobiasKlein;
let thermostat = MartynaTuckermanTobiasKlein::zero(0.5.try_into()?);Implementations§
Source§impl MartynaTuckermanTobiasKlein
impl MartynaTuckermanTobiasKlein
Sourcepub fn zero(tau: PositiveReal) -> Self
pub fn zero(tau: PositiveReal) -> Self
Construct a new MartynaTuckermanTobiasKlein thermostat with the given time constant,
$\xi = 0$, and $\eta = 0$ .
This initial condition is likely to be very far from equilibrium which
will result in wild kinetic energy oscillations for the first hundred to
thousand time steps. Use thermalized to choose the initial position
and momentum from a thermal distribution.
§Example
use hoomd_md::thermostat::MartynaTuckermanTobiasKlein;
let thermostat = MartynaTuckermanTobiasKlein::zero(0.5.try_into()?);Sourcepub fn thermalized<M, R: Rng + ?Sized>(
rng: &mut R,
tau: PositiveReal,
macrostate: &M,
degrees_of_freedom: usize,
) -> Selfwhere
M: Temperature,
pub fn thermalized<M, R: Rng + ?Sized>(
rng: &mut R,
tau: PositiveReal,
macrostate: &M,
degrees_of_freedom: usize,
) -> Selfwhere
M: Temperature,
Construct a new MartynaTuckermanTobiasKlein thermostat with a random $\xi$
drawn from a thermal distribution.
§Panics
This method will panic when degrees_of_freedom is 0.
§Example
use hoomd_md::{
TranslationalKineticEnergy, thermostat::MartynaTuckermanTobiasKlein,
};
use hoomd_microstate::{
Body, Microstate,
property::{DynamicPoint, Point},
};
use hoomd_simulation::macrostate::Isothermal;
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()?;
let macrostate = Isothermal { temperature: 1.5 };
let mut rng = microstate.counter().make_rng();
let translational_thermostat = MartynaTuckermanTobiasKlein::thermalized(
&mut rng,
0.5.try_into()?,
¯ostate,
microstate.translational_kinetic_energy().1,
);
microstate.increment_substep();Sourcepub fn energy(&self) -> f64
pub fn energy(&self) -> f64
The total energy of the thermostat.
§Example
use hoomd_md::thermostat::MartynaTuckermanTobiasKlein;
let thermostat = MartynaTuckermanTobiasKlein::zero(0.5.try_into()?);
let energy = thermostat.energy();Trait Implementations§
Source§impl Clone for MartynaTuckermanTobiasKlein
impl Clone for MartynaTuckermanTobiasKlein
Source§fn clone(&self) -> MartynaTuckermanTobiasKlein
fn clone(&self) -> MartynaTuckermanTobiasKlein
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MartynaTuckermanTobiasKlein
impl Debug for MartynaTuckermanTobiasKlein
Source§impl<'de> Deserialize<'de> for MartynaTuckermanTobiasKlein
impl<'de> Deserialize<'de> for MartynaTuckermanTobiasKlein
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<M> Thermostat<M> for MartynaTuckermanTobiasKleinwhere
M: Temperature,
impl<M> Thermostat<M> for MartynaTuckermanTobiasKleinwhere
M: Temperature,
impl StructuralPartialEq for MartynaTuckermanTobiasKlein
Auto Trait Implementations§
impl Freeze for MartynaTuckermanTobiasKlein
impl RefUnwindSafe for MartynaTuckermanTobiasKlein
impl Send for MartynaTuckermanTobiasKlein
impl Sync for MartynaTuckermanTobiasKlein
impl Unpin for MartynaTuckermanTobiasKlein
impl UnsafeUnpin for MartynaTuckermanTobiasKlein
impl UnwindSafe for MartynaTuckermanTobiasKlein
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more