pub struct ParallelSweep<L, K, B, S> { /* private fields */ }Expand description
In parallel, apply local trial moves to bodies in the microstate.
The generic type names are:
L: TheLocalTrialtype.K: TheCheckerboardtype.B: TheBody::propertiestype.S: TheSite::propertiestype.
§Example
use hoomd_mc::{HypercuboidCheckerboard, ParallelSweep, Translate};
use hoomd_microstate::property::Point;
use hoomd_vector::Cartesian;
let d = 0.1;
let translate =
Translate::<Cartesian<2>>::with_maximum_distance(d.try_into()?);
let translate_sweep = ParallelSweep::<
_,
HypercuboidCheckerboard<2>,
Point<Cartesian<2>>,
Point<Cartesian<2>>,
>::new(1.0.try_into()?, translate);Implementations§
Source§impl<L, K, B, S> ParallelSweep<L, K, B, S>where
K: Default,
impl<L, K, B, S> ParallelSweep<L, K, B, S>where
K: Default,
Sourcepub fn new(body_interaction_range: PositiveReal, local_trial: L) -> Self
pub fn new(body_interaction_range: PositiveReal, local_trial: L) -> Self
Construct a new ParallelSweep.
To avoid applying conflicting moves at the same time, you need to
provide the largest distance between any two interacting bodies:
body_interaction_range (measured between the body positions).
ParallelSweep cannot compute this value, nor can it validate
whether the provided value is correct.
The local_trial arguments determines what trial moves ParallelSweep
attempts.
§Example
use hoomd_mc::{HypercuboidCheckerboard, ParallelSweep, Translate};
use hoomd_microstate::property::Point;
use hoomd_vector::Cartesian;
let d = 0.1;
let translate =
Translate::<Cartesian<2>>::with_maximum_distance(d.try_into()?);
let translate_sweep = ParallelSweep::<
_,
HypercuboidCheckerboard<2>,
Point<Cartesian<2>>,
Point<Cartesian<2>>,
>::new(1.0.try_into()?, translate);Source§impl<L, K, B, S> ParallelSweep<L, K, B, S>
impl<L, K, B, S> ParallelSweep<L, K, B, S>
Sourcepub fn body_interaction_range(&self) -> &PositiveReal
pub fn body_interaction_range(&self) -> &PositiveReal
Get the body interaction range.
Sourcepub fn body_interaction_range_mut(&mut self) -> &mut PositiveReal
pub fn body_interaction_range_mut(&mut self) -> &mut PositiveReal
Get the body interaction range (mutable).
Sourcepub fn local_trial(&self) -> &L
pub fn local_trial(&self) -> &L
Get the local trial.
Sourcepub fn local_trial_mut(&mut self) -> &mut L
pub fn local_trial_mut(&mut self) -> &mut L
Get the local trial (mutable).
Trait Implementations§
Source§impl<L: Clone, K: Clone, B: Clone, S: Clone> Clone for ParallelSweep<L, K, B, S>
impl<L: Clone, K: Clone, B: Clone, S: Clone> Clone for ParallelSweep<L, K, B, S>
Source§fn clone(&self) -> ParallelSweep<L, K, B, S>
fn clone(&self) -> ParallelSweep<L, K, B, S>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'de, L, K, B, S> Deserialize<'de> for ParallelSweep<L, K, B, S>
impl<'de, L, K, B, S> Deserialize<'de> for ParallelSweep<L, K, B, S>
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<L: PartialEq, K: PartialEq, B: PartialEq, S: PartialEq> PartialEq for ParallelSweep<L, K, B, S>
impl<L: PartialEq, K: PartialEq, B: PartialEq, S: PartialEq> PartialEq for ParallelSweep<L, K, B, S>
Source§impl<L, K, B, S> Serialize for ParallelSweep<L, K, B, S>
impl<L, K, B, S> Serialize for ParallelSweep<L, K, B, S>
Source§impl<P, B, S, X, C, L, H, MA, K> Trial<Microstate<B, S, X, C>, H, MA> for ParallelSweep<L, K, B, S>where
P: Copy,
B: Copy + Default + Transform<S> + Position<Position = P> + Send + Sync,
S: Copy + Default + Position<Position = P> + Send + Sync,
X: PointUpdate<P, SiteKey> + Sync,
L: LocalTrial<B> + Sync,
H: DeltaEnergyOne<B, S, X, C> + Sync,
C: Wrap<B> + Wrap<S> + GenerateGhosts<S> + Cover<P, Checkerboard = K> + Sync,
MA: Temperature,
K: Checkerboard<P> + Sync,
impl<P, B, S, X, C, L, H, MA, K> Trial<Microstate<B, S, X, C>, H, MA> for ParallelSweep<L, K, B, S>where
P: Copy,
B: Copy + Default + Transform<S> + Position<Position = P> + Send + Sync,
S: Copy + Default + Position<Position = P> + Send + Sync,
X: PointUpdate<P, SiteKey> + Sync,
L: LocalTrial<B> + Sync,
H: DeltaEnergyOne<B, S, X, C> + Sync,
C: Wrap<B> + Wrap<S> + GenerateGhosts<S> + Cover<P, Checkerboard = K> + Sync,
MA: Temperature,
K: Checkerboard<P> + Sync,
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
In parallel, apply local trial moves to bodies 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.
ParallelSweep covers the simulation domain with a colored checkerboard
(given by the K type). For each color, apply applies trial moves
in parallel to bodies checkerboard spaces of that color (one trial move
per space). A move is invalid when the body center leaves the initial
checkerboard space. The return value counts only valid moves.
One invocation of apply continues to apply trial moves until it
has attempted at least as many trial moves as there are bodies in
the microstate. Therefore, one call to ParallelSweep::apply roughly
equivalent to one call to Sweep::apply. However, ParallelSweep
will always attempt more trial moves because it rounds up. To make
quantitative comparisons between the methods, normalize by the number of
attempted moves.
§Example
use hoomd_geometry::shape::Rectangle;
use hoomd_interaction::Zero;
use hoomd_mc::{ParallelSweep, Translate, Trial};
use hoomd_microstate::{
Body, Microstate, boundary::Closed, property::Position,
};
use hoomd_simulation::macrostate::Isothermal;
use hoomd_vector::Cartesian;
let square = Rectangle::with_equal_edges(10.0.try_into()?);
let mut microstate = Microstate::builder()
.boundary(Closed(square))
.bodies([Body::point(Cartesian::from([0.0, 0.0]))])
.try_build()?;
let d = 0.1;
let translate = Translate::with_maximum_distance(d.try_into()?);
let mut translate_sweep = ParallelSweep::new(1.0.try_into()?, translate);
let hamiltonian = Zero;
let macrostate = Isothermal { temperature: 1.0 };
translate_sweep.apply(&mut microstate, &hamiltonian, ¯ostate);
microstate.increment_step();Source§impl<P, B, S, X, C, L, H, MA, K> Tune<P, B, S, X, C, L, H, MA> for ParallelSweep<L, K, B, S>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, K> Tune<P, B, S, X, C, L, H, MA> for ParallelSweep<L, K, B, S>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::{ParallelSweep, 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(10.0.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 = ParallelSweep::new(1.0.try_into()?, translate);
let hamiltonian = PairwiseCutoff(HardSphere { diameter: 1.0 });
let macrostate = Isothermal { temperature: 1.0 };
translate_sweep.tune_default(µstate, &hamiltonian, ¯ostate);
translate_sweep.apply(&mut microstate, &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, )
impl<L, K, B, S> StructuralPartialEq for ParallelSweep<L, K, B, S>
Auto Trait Implementations§
impl<L, K, B, S> Freeze for ParallelSweep<L, K, B, S>
impl<L, K, B, S> RefUnwindSafe for ParallelSweep<L, K, B, S>
impl<L, K, B, S> Send for ParallelSweep<L, K, B, S>
impl<L, K, B, S> Sync for ParallelSweep<L, K, B, S>
impl<L, K, B, S> Unpin for ParallelSweep<L, K, B, S>
impl<L, K, B, S> UnwindSafe for ParallelSweep<L, K, B, S>
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