pub struct Count {
pub accepted: u64,
pub rejected: u64,
}Expand description
Accepted and rejected trial moves.
A Trial reports the number moves it accepts and rejects via Count (or
some variation on Count). Count implements Add, AddAssign, and
convenience methods that compute often used properties, like the acceptance
rate.
§Example
Count the total number of trial moves performed over a number of sweeps:
use hoomd_interaction::Zero;
use hoomd_mc::{Count, Sweep, Translate, Trial};
use hoomd_microstate::{Body, Microstate, property::Position};
use hoomd_simulation::macrostate::Isothermal;
use hoomd_vector::Cartesian;
let macrostate = Isothermal { temperature: 1.0 };
let mut microstate = Microstate::new();
microstate.add_body(Body::point(Cartesian::from([0.0, 0.0])));
let d = 0.1;
let translate = Translate::with_maximum_distance(d.try_into()?);
let mut translate_sweep = Sweep(translate);
let mut count = Count::default();
for _ in 0..1_000 {
count += translate_sweep.apply(&mut microstate, &Zero, ¯ostate);
microstate.increment_step();
}
assert_eq!(count.total(), 1_000);Fields§
§accepted: u64The number of accepted moves.
rejected: u64The number of rejected moves.
Implementations§
Source§impl Count
impl Count
Sourcepub fn total(&self) -> u64
pub fn total(&self) -> u64
The total number of trial moves.
§Example
use hoomd_mc::Count;
let count = Count {
accepted: 2_000,
rejected: 8_000,
};
let total = count.total();
assert_eq!(total, 10_000);Sourcepub fn acceptance_ratio(&self) -> Option<f64>
pub fn acceptance_ratio(&self) -> Option<f64>
The fraction of moves that were accepted.
The acceptance ratio is the ratio of accepted moves to total moves.
acceptance_ratio returns Some(ratio) when the number of total moves is
nonzero and None when there are 0 moves.
§Example
use hoomd_mc::Count;
let count = Count {
accepted: 2_000,
rejected: 8_000,
};
let acceptance_ratio = count.acceptance_ratio();
assert_eq!(acceptance_ratio, Some(0.2));use hoomd_mc::Count;
let count = Count::default();
let acceptance_ratio = count.acceptance_ratio();
assert_eq!(acceptance_ratio, None);Trait Implementations§
Source§impl AddAssign for Count
impl AddAssign for Count
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moreSource§impl<'de> Deserialize<'de> for Count
impl<'de> Deserialize<'de> for Count
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>,
Deserialize this value from the given Serde deserializer. Read more
impl Copy for Count
impl StructuralPartialEq for Count
Auto Trait Implementations§
impl Freeze for Count
impl RefUnwindSafe for Count
impl Send for Count
impl Sync for Count
impl Unpin for Count
impl UnwindSafe for Count
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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