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>
impl<P> Rotate<P>
Sourcepub fn with_maximum_rotation(maximum_rotation: PositiveReal) -> Self
pub fn with_maximum_rotation(maximum_rotation: PositiveReal) -> Self
Sourcepub fn maximum_rotation(&self) -> &PositiveReal
pub fn maximum_rotation(&self) -> &PositiveReal
Get the maximum rotation.
Sourcepub fn maximum_rotation_mut(&mut self) -> &mut PositiveReal
pub fn maximum_rotation_mut(&mut self) -> &mut PositiveReal
Get the maximum rotation.
Trait Implementations§
Source§impl Adjust for Rotate<Angle>
impl Adjust for Rotate<Angle>
Source§fn adjust(&mut self, factor: PositiveReal)
fn adjust(&mut self, factor: PositiveReal)
Change the maximum trial move size by the given scale factor.
Source§impl Adjust for Rotate<Versor>
impl Adjust for Rotate<Versor>
Source§fn adjust(&mut self, factor: PositiveReal)
fn adjust(&mut self, factor: PositiveReal)
Change the maximum trial move size by the given scale factor.
Source§impl<'de, O> Deserialize<'de> for Rotate<O>
impl<'de, O> Deserialize<'de> for Rotate<O>
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<B> LocalTrial<B> for Rotate<Angle>where
B: Orientation<Rotation = Angle>,
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
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>,
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
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);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> 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