pub struct Sweep<L>(pub L);Expand description
Apply a local trial move to every body in the microstate.
The first field in the tuple struct determines what trial moves Sweep
attempts.
§Example
use hoomd_mc::{Sweep, Translate};
use hoomd_vector::Cartesian;
let d = 0.1;
let translate =
Translate::<Cartesian<2>>::with_maximum_distance(d.try_into()?);
let translate_sweep = Sweep(translate);Tuple Fields§
§0: LTrait Implementations§
Source§impl<'de, L> Deserialize<'de> for Sweep<L>where
L: Deserialize<'de>,
impl<'de, L> Deserialize<'de> for Sweep<L>where
L: Deserialize<'de>,
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
Source§impl<P, B, S, X, C, L, H, MA> Trial<Microstate<B, S, X, C>, H, MA> for Sweep<L>where
P: Copy,
B: Copy + Default + Transform<S> + Position<Position = P>,
S: Copy + Default + Position<Position = P>,
X: PointUpdate<P, SiteKey>,
L: LocalTrial<B>,
H: DeltaEnergyOne<B, S, X, C>,
C: Wrap<B> + Wrap<S> + GenerateGhosts<S>,
MA: Temperature,
impl<P, B, S, X, C, L, H, MA> Trial<Microstate<B, S, X, C>, H, MA> for Sweep<L>where
P: Copy,
B: Copy + Default + Transform<S> + Position<Position = P>,
S: Copy + Default + Position<Position = P>,
X: PointUpdate<P, SiteKey>,
L: LocalTrial<B>,
H: DeltaEnergyOne<B, S, X, C>,
C: Wrap<B> + Wrap<S> + GenerateGhosts<S>,
MA: Temperature,
Source§fn apply(
&mut self,
microstate: &mut Microstate<B, S, X, C>,
hamiltonian: &H,
macrostate: &MA,
) -> Self::Count
fn apply( &mut self, microstate: &mut Microstate<B, S, X, C>, hamiltonian: &H, macrostate: &MA, ) -> Self::Count
Apply a local trial move to each body in the microstate.
Each trial move is accepted when:
r < \exp\left(\frac{-\Delta H}{kT}\right)where r is a random value uniformly distributed in [0,1), $\Delta H$ is
the change in energy computed by the given hamiltonian and $kT$ is the
temperature given in macrostate.
§Example
use hoomd_interaction::Zero;
use hoomd_mc::{Sweep, Translate, Trial};
use hoomd_microstate::{Body, Microstate, property::Position};
use hoomd_simulation::macrostate::Isothermal;
use hoomd_vector::Cartesian;
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 hamiltonian = Zero;
let macrostate = Isothermal { temperature: 1.0 };
for _ in 0..1_000 {
translate_sweep.apply(&mut microstate, &hamiltonian, ¯ostate);
microstate.increment_step();
}Source§impl<P, B, S, X, C, L, H, MA> Tune<P, B, S, X, C, L, H, MA> for Sweep<L>where
P: Copy,
B: Copy + Default + Transform<S> + Position<Position = P>,
S: Copy + Default + Position<Position = P>,
X: PointUpdate<P, SiteKey>,
L: LocalTrial<B> + Adjust + Display,
H: DeltaEnergyOne<B, S, X, C>,
C: Wrap<B> + Wrap<S> + GenerateGhosts<S>,
MA: Temperature,
impl<P, B, S, X, C, L, H, MA> Tune<P, B, S, X, C, L, H, MA> for Sweep<L>where
P: Copy,
B: Copy + Default + Transform<S> + Position<Position = P>,
S: Copy + Default + Position<Position = P>,
X: PointUpdate<P, SiteKey>,
L: LocalTrial<B> + Adjust + Display,
H: DeltaEnergyOne<B, S, X, C>,
C: Wrap<B> + Wrap<S> + GenerateGhosts<S>,
MA: Temperature,
Source§fn tune(
&mut self,
microstate: &Microstate<B, S, X, C>,
hamiltonian: &H,
macrostate: &MA,
target_acceptance: OpenUnitIntervalNumber,
samples: usize,
steps: usize,
)
fn tune( &mut self, microstate: &Microstate<B, S, X, C>, hamiltonian: &H, macrostate: &MA, target_acceptance: OpenUnitIntervalNumber, samples: usize, steps: usize, )
Tune the trial move maximum size to achieve a given acceptance ratio.
Use tune_default unless you have a specific need to adjust the
tuning parameters.
§Example
use hoomd_geometry::shape::Rectangle;
use hoomd_interaction::{
MaximumInteractionRange, PairwiseCutoff, pairwise::HardSphere,
};
use hoomd_mc::{Sweep, Translate, Trial, Tune};
use hoomd_microstate::{
Body, Microstate, boundary::Periodic, property::Position,
};
use hoomd_simulation::macrostate::Isothermal;
use hoomd_vector::Cartesian;
let square = Rectangle::with_equal_edges(2.2.try_into()?);
let mut microstate = Microstate::builder()
.boundary(Periodic::new(1.0, square)?)
.try_build()?;
microstate.add_body(Body::point(Cartesian::from([-0.6, -0.6])))?;
microstate.add_body(Body::point(Cartesian::from([-0.6, 0.6])))?;
microstate.add_body(Body::point(Cartesian::from([0.6, -0.6])))?;
microstate.add_body(Body::point(Cartesian::from([0.6, 0.6])))?;
let d = 0.1;
let translate = Translate::with_maximum_distance(d.try_into()?);
let mut translate_sweep = Sweep(translate);
let hamiltonian = PairwiseCutoff(HardSphere { diameter: 1.0 });
let macrostate = Isothermal { temperature: 1.0 };
translate_sweep.tune_default(µstate, &hamiltonian, ¯ostate);
Source§fn tune_default(
&mut self,
microstate: &Microstate<B, S, X, C>,
hamiltonian: &H,
macrostate: &MA,
)
fn tune_default( &mut self, microstate: &Microstate<B, S, X, C>, hamiltonian: &H, macrostate: &MA, )
Tune the trial move maximum size with default parameters. Read more
impl<L> StructuralPartialEq for Sweep<L>
Auto Trait Implementations§
impl<L> Freeze for Sweep<L>where
L: Freeze,
impl<L> RefUnwindSafe for Sweep<L>where
L: RefUnwindSafe,
impl<L> Send for Sweep<L>where
L: Send,
impl<L> Sync for Sweep<L>where
L: Sync,
impl<L> Unpin for Sweep<L>where
L: Unpin,
impl<L> UnsafeUnpin for Sweep<L>where
L: UnsafeUnpin,
impl<L> UnwindSafe for Sweep<L>where
L: UnwindSafe,
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