ParallelSweep

Struct ParallelSweep 

Source
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:

§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,

Source

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>

Source

pub fn body_interaction_range(&self) -> &PositiveReal

Get the body interaction range.

Source

pub fn body_interaction_range_mut(&mut self) -> &mut PositiveReal

Get the body interaction range (mutable).

Source

pub fn local_trial(&self) -> &L

Get the local trial.

Source

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>

Source§

fn clone(&self) -> ParallelSweep<L, K, B, S>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<L: Debug, K: Debug, B: Debug, S: Debug> Debug for ParallelSweep<L, K, B, S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, L, K, B, S> Deserialize<'de> for ParallelSweep<L, K, B, S>
where L: Deserialize<'de>, K: Deserialize<'de>, B: Default, S: Default,

Source§

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<L: PartialEq, K: PartialEq, B: PartialEq, S: PartialEq> PartialEq for ParallelSweep<L, K, B, S>

Source§

fn eq(&self, other: &ParallelSweep<L, K, B, S>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<L, K, B, S> Serialize for ParallelSweep<L, K, B, S>
where L: Serialize, K: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
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,

Source§

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, &macrostate);
microstate.increment_step();
Source§

type Count = Count

Represent the number of accepted and rejected individual trial moves. Read more
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,

Source§

fn tune( &mut self, microstate: &Microstate<B, S, X, C>, hamiltonian: &H, macrostate: &MA, target_acceptance: OpenUnitIntervalNumber, samples: usize, steps: usize, )

👎Deprecated since 1.1.0: use tune_with_options

Tune the trial move maximum size to achieve a given acceptance ratio.

Use tune_with_options and TuneOptions: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, TuneOptions};
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_with_options(
    &microstate,
    &hamiltonian,
    &macrostate,
    &TuneOptions::default(),
);

translate_sweep.apply(&mut microstate, &hamiltonian, &macrostate);
Source§

fn tune_with_options( &mut self, microstate: &Microstate<B, S, X, C>, hamiltonian: &H, macrostate: &MA, options: &TuneOptions, )

Tune the trial move maximum size to achieve a given acceptance ratio. Read more
Source§

fn tune_default( &mut self, microstate: &Microstate<B, S, X, C>, hamiltonian: &H, macrostate: &MA, )

👎Deprecated since 1.1.0: use tune_with_options(..., &TuneOptions::default())
Tune the trial move maximum size with default parameters. Read more
Source§

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>
where L: Freeze, K: Freeze,

§

impl<L, K, B, S> RefUnwindSafe for ParallelSweep<L, K, B, S>

§

impl<L, K, B, S> Send for ParallelSweep<L, K, B, S>
where L: Send, K: Send, B: Send, S: Send,

§

impl<L, K, B, S> Sync for ParallelSweep<L, K, B, S>
where L: Sync, K: Sync, B: Sync, S: Sync,

§

impl<L, K, B, S> Unpin for ParallelSweep<L, K, B, S>
where L: Unpin, K: Unpin, B: Unpin, S: Unpin,

§

impl<L, K, B, S> UnwindSafe for ParallelSweep<L, K, B, S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,