Rotate

Struct Rotate 

Source
pub struct Rotate<O> { /* private fields */ }
Expand description

Change the orientation of a body by a small amount.

Rotate proposes local trial moves that rotate the orientation of a body by a small amount. The maximum_rotation parameter sets the largest possible rotation.

When proposing trial moves for Angle, maximum_rotation is measured in radians and the rotation is uniformly chosen between -maximum_rotation and maximum_rotation.

When proposing trial moves for Versor, maximum_rotation is measured in radians and the width of a Gaussian distribution centered on 0.

The generic type names are:

  • O: The type of the orientation to rotate.

§Example

use hoomd_mc::Rotate;
use hoomd_vector::Angle;

let a = 0.1;
let rotate = Rotate::<Angle>::with_maximum_rotation(a.try_into()?);

Implementations§

Source§

impl<P> Rotate<P>

Source

pub fn with_maximum_rotation(maximum_rotation: PositiveReal) -> Self

Construct a Rotate move with the given maximum rotation.

§Example
use hoomd_mc::Rotate;
use hoomd_vector::Angle;

let a = 0.1;
let rotate = Rotate::<Angle>::with_maximum_rotation(a.try_into()?);
Source

pub fn maximum_rotation(&self) -> &PositiveReal

Get the maximum rotation.

Source

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

Get the maximum rotation.

Trait Implementations§

Source§

impl Adjust for Rotate<Angle>

Source§

fn adjust(&mut self, factor: PositiveReal)

Change the maximum trial move size by the given scale factor.

Source§

impl Adjust for Rotate<Versor>

Source§

fn adjust(&mut self, factor: PositiveReal)

Change the maximum trial move size by the given scale factor.

Source§

impl<O: Clone> Clone for Rotate<O>

Source§

fn clone(&self) -> Rotate<O>

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<O: Debug> Debug for Rotate<O>

Source§

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

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

impl<'de, O> Deserialize<'de> for Rotate<O>

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<P> Display for Rotate<P>

Source§

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

Format a Rotate as {maximum_rotation}.

Source§

impl<B> LocalTrial<B> for Rotate<Angle>
where B: Orientation<Rotation = Angle>,

Source§

fn propose<R: Rng>(&self, rng: &mut R, body_properties: B) -> B

Perturb a body’s orientation by a random amount.

§Example
use hoomd_mc::{LocalTrial, Rotate};
use hoomd_microstate::property::OrientedPoint;
use hoomd_vector::{Angle, Cartesian};
use rand::{Rng, SeedableRng, rngs::StdRng};

let mut rng = StdRng::seed_from_u64(1);
let body_properties = OrientedPoint {
    position: Cartesian::from([0.0, 0.0]),
    orientation: Angle::from(0.0),
};
let rotate = Rotate::with_maximum_rotation(0.1.try_into()?);

let new_body_properties = rotate.propose(&mut rng, body_properties);
assert!(new_body_properties.orientation.theta.abs() < 0.1);
Source§

impl<B> LocalTrial<B> for Rotate<Versor>
where B: Orientation<Rotation = Versor>,

Source§

fn propose<R: Rng>(&self, rng: &mut R, body_properties: B) -> B

Perturb a body’s orientation by a random amount.

In three dimensions, we design this perturbation as a versor whose distribution is centered on the existing orientation and whose distribution is narrow. To do so, we sample from a 3-dimensional Normal distribution in the tangent space of SO(3), lift to the manifold, then rotate to center on the current orientation. The result is a small displacement from a quaternion input, with fast decay in the tails that make large displacements unlikely. This is desirable for Monte Carlo, as large moves are very likely to be rejected. This sampling obeys detailed balance.

§Example
use hoomd_mc::{LocalTrial, Rotate};
use hoomd_microstate::property::OrientedPoint;
use hoomd_vector::{Cartesian, Versor};
use rand::{Rng, SeedableRng, rngs::StdRng};

let mut rng = StdRng::seed_from_u64(1);
let initial_orientation = Versor::default();
let body_properties = OrientedPoint {
    position: Cartesian::from([0.0, 0.0, 0.0]),
    orientation: initial_orientation,
};
let rotate = Rotate::with_maximum_rotation(0.1.try_into()?);

let new_body_properties = rotate.propose(&mut rng, body_properties);
assert!(new_body_properties.orientation != initial_orientation);
Source§

impl<O: PartialEq> PartialEq for Rotate<O>

Source§

fn eq(&self, other: &Rotate<O>) -> 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<O> Serialize for Rotate<O>

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<O> StructuralPartialEq for Rotate<O>

Auto Trait Implementations§

§

impl<O> Freeze for Rotate<O>

§

impl<O> RefUnwindSafe for Rotate<O>
where O: RefUnwindSafe,

§

impl<O> Send for Rotate<O>
where O: Send,

§

impl<O> Sync for Rotate<O>
where O: Sync,

§

impl<O> Unpin for Rotate<O>
where O: Unpin,

§

impl<O> UnwindSafe for Rotate<O>
where O: 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
§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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>,