Skip to main content

Sweep

Struct Sweep 

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

Trait Implementations§

Source§

impl<L: Clone> Clone for Sweep<L>

Source§

fn clone(&self) -> Sweep<L>

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> Debug for Sweep<L>

Source§

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

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

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

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<L: PartialEq> PartialEq for Sweep<L>

Source§

fn eq(&self, other: &Sweep<L>) -> 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> Serialize for Sweep<L>
where L: 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> 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

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, &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> 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, )

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

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

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

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

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