Periodic

Struct Periodic 

Source
pub struct Periodic<T> { /* private fields */ }
Expand description

Describe a simulation space that repeats in one or more directions.

Periodic is a newtype that wraps a shape. Use it to set the boundary for a Microstate.

When bodies or sites exit the shape through one of the periodic sides of the shape, they are wrapped to the other side. Similarly, sites that are within the interaction range of one of the periodic sides appear as ghost sites just outside the opposite side. Depending on the shape type T, Periodic<T> might implement fully periodic boundaries or ones that are periodic in some directions and closed in others.

Periodic is implemented for the following shapes:

§Example

use hoomd_geometry::shape::Rectangle;
use hoomd_microstate::boundary::Periodic;

let periodic =
    Periodic::new(2.5, Rectangle::with_equal_edges(10.0.try_into()?))?;

Implementations§

Source§

impl<T> Periodic<T>

Source

pub fn new(maximum_interaction_range: f64, shape: T) -> Result<Self, Error>

Construct a new periodic boundary condition.

§Errors

Error::InteractionRangeTooLarge when maximum_interaction_range is larger than the maximum allowable interaction range by the shape.

§Example
use hoomd_geometry::shape::Rectangle;
use hoomd_microstate::boundary::Periodic;

let periodic =
    Periodic::new(2.5, Rectangle::with_equal_edges(10.0.try_into()?))?;
Source§

impl<T> Periodic<T>

Source

pub fn shape(&self) -> &T

Access the boundary’s shape.

§Example
use hoomd_geometry::shape::Rectangle;
use hoomd_microstate::boundary::Periodic;

let periodic =
    Periodic::new(2.5, Rectangle::with_equal_edges(10.0.try_into()?))?;

assert_eq!(periodic.shape().edge_lengths[0].get(), 10.0);
Source

pub fn maximum_interaction_range(&self) -> f64

Access the boundary’s maximum interaction range.

§Example
use hoomd_geometry::shape::Rectangle;
use hoomd_microstate::boundary::Periodic;

let periodic =
    Periodic::new(2.5, Rectangle::with_equal_edges(10.0.try_into()?))?;

assert_eq!(periodic.maximum_interaction_range(), 2.5);

Trait Implementations§

Source§

impl<B, X> AppendMicrostate<B, OrientedPoint<Cartesian<2>, Angle>, X, Periodic<Hypercuboid<2>>> for HoomdGsdFile

Source§

fn append_microstate( &mut self, microstate: &Microstate<B, OrientedPoint<Cartesian<2>, Angle>, X, Periodic<Hypercuboid<2>>>, ) -> Result<Frame<'_>, AppendError>

Append the contents of the microstate as a frame in a GSD file. Read more
Source§

impl<B, X> AppendMicrostate<B, OrientedPoint<Cartesian<3>, Versor>, X, Periodic<Hypercuboid<3>>> for HoomdGsdFile

Source§

fn append_microstate( &mut self, microstate: &Microstate<B, OrientedPoint<Cartesian<3>, Versor>, X, Periodic<Hypercuboid<3>>>, ) -> Result<Frame<'_>, AppendError>

Append the contents of the microstate as a frame in a GSD file. Read more
Source§

impl<B, X> AppendMicrostate<B, Point<Cartesian<2>>, X, Periodic<Hypercuboid<2>>> for HoomdGsdFile

Source§

fn append_microstate( &mut self, microstate: &Microstate<B, Point<Cartesian<2>>, X, Periodic<Hypercuboid<2>>>, ) -> Result<Frame<'_>, AppendError>

Append the contents of the microstate as a frame in a GSD file. Read more
Source§

impl<B, X> AppendMicrostate<B, Point<Cartesian<3>>, X, Periodic<Hypercuboid<3>>> for HoomdGsdFile

Source§

fn append_microstate( &mut self, microstate: &Microstate<B, Point<Cartesian<3>>, X, Periodic<Hypercuboid<3>>>, ) -> Result<Frame<'_>, AppendError>

Append the contents of the microstate as a frame in a GSD file. Read more
Source§

impl<T: Clone> Clone for Periodic<T>

Source§

fn clone(&self) -> Periodic<T>

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<T: Debug> Debug for Periodic<T>

Source§

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

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

impl<'de, T> Deserialize<'de> for Periodic<T>
where T: 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<T, V> Distribution<V> for Periodic<T>
where T: Distribution<V>,

Source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> V

Generate points uniformly distributed in the wrapped shape.

§Example
use rand::{SeedableRng, distr::Distribution, rngs::StdRng};

use hoomd_geometry::{IsPointInside, shape::Hypercuboid};
use hoomd_microstate::boundary::Periodic;

let cuboid = Hypercuboid {
    edge_lengths: [6.0.try_into()?, 8.0.try_into()?],
};
let periodic = Periodic::new(2.5, cuboid)?;
let mut rng = StdRng::seed_from_u64(1);

let point = periodic.sample(&mut rng);
assert!(periodic.shape().is_point_inside(&point));
§

fn sample_iter<R>(self, rng: R) -> Iter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
§

fn map<F, S>(self, func: F) -> Map<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Map sampled values to type S Read more
Source§

impl GenerateGhosts<OrientedHyperbolicPoint<3, Angle>> for Periodic<EightEight>

Source§

fn generate_ghosts( &self, site_properties: &OrientedHyperbolicPoint<3, Angle>, ) -> ArrayVec<OrientedHyperbolicPoint<3, Angle>, MAX_GHOSTS>

Place periodic images of sites near the edge of the periodic boundary

Source§

fn maximum_interaction_range(&self) -> f64

The largest interaction distance between sites. Read more
Source§

impl GenerateGhosts<OrientedHyperbolicPoint<3, Angle>> for Periodic<TwelveTwelve>

Source§

fn generate_ghosts( &self, site_properties: &OrientedHyperbolicPoint<3, Angle>, ) -> ArrayVec<OrientedHyperbolicPoint<3, Angle>, MAX_GHOSTS>

Place periodic images of sites near the edge of the periodic boundary.

Source§

fn maximum_interaction_range(&self) -> f64

The largest interaction distance between sites. Read more
Source§

impl GenerateGhosts<Point<Hyperbolic<3>>> for Periodic<EightEight>

Source§

fn generate_ghosts( &self, site_properties: &Point<Hyperbolic<3>>, ) -> ArrayVec<Point<Hyperbolic<3>>, MAX_GHOSTS>

Place periodic images of sites near the edge of the periodic boundary

Source§

fn maximum_interaction_range(&self) -> f64

The largest interaction distance between sites. Read more
Source§

impl GenerateGhosts<Point<Hyperbolic<3>>> for Periodic<TwelveTwelve>

Source§

fn generate_ghosts( &self, site_properties: &Point<Hyperbolic<3>>, ) -> ArrayVec<Point<Hyperbolic<3>>, MAX_GHOSTS>

Place periodic images of sites near the edges of the periodic boundary

Source§

fn maximum_interaction_range(&self) -> f64

The largest interaction distance between sites. Read more
Source§

impl<S> GenerateGhosts<S> for Periodic<Hypercuboid<2>>
where S: Position<Position = Cartesian<2>> + Copy + Default,

Source§

fn generate_ghosts(&self, site_properties: &S) -> ArrayVec<S, MAX_GHOSTS>

Place periodic images of sites near the edge of the periodic boundary.

For 2D cuboids, generate_ghosts places ghosts near the 4 edges and 4 vertices.

Source§

fn maximum_interaction_range(&self) -> f64

The largest interaction distance between sites. Read more
Source§

impl<S> GenerateGhosts<S> for Periodic<Hypercuboid<3>>
where S: Position<Position = Cartesian<3>> + Copy + Default,

Source§

fn generate_ghosts(&self, site_properties: &S) -> ArrayVec<S, MAX_GHOSTS>

Place periodic images of sites near the edge of the periodic boundary.

For 3D cuboids, generate_ghosts places ghosts near the 6 faces, 12 edges, and 8 vertices.

Source§

fn maximum_interaction_range(&self) -> f64

The largest interaction distance between sites. Read more
Source§

impl<P, T> MapPoint<P> for Periodic<T>
where T: MapPoint<P>,

Source§

fn map_point(&self, point: P, other: &Self) -> Result<P, Error>

Map points in from the wrapped shape into another periodic boundary.

§Errors

hoomd_geometry::Error::PointOutsideShape when point is outside self.shape().

§Example
use hoomd_geometry::{MapPoint, shape::Rectangle};
use hoomd_microstate::boundary::Periodic;
use hoomd_vector::Cartesian;

let periodic_a =
    Periodic::new(2.5, Rectangle::with_equal_edges(10.0.try_into()?))?;
let periodic_b =
    Periodic::new(2.5, Rectangle::with_equal_edges(20.0.try_into()?))?;

let mapped_point =
    periodic_a.map_point(Cartesian::from([-1.0, 1.0]), &periodic_b);

assert_eq!(mapped_point, Ok(Cartesian::from([-2.0, 2.0])));
assert_eq!(
    periodic_a.map_point(Cartesian::from([-100.0, 1.0]), &periodic_b),
    Err(hoomd_geometry::Error::PointOutsideShape)
);
Source§

impl<T: PartialEq> PartialEq for Periodic<T>

Source§

fn eq(&self, other: &Periodic<T>) -> 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<T> Scale for Periodic<T>

Source§

fn scale_length(&self, v: PositiveReal) -> Self

Scale the wrapped shape.

§Panics

When scaling the wrapped shape, scale_length will panic if the scaled maximum allowable interaction range is smaller than maximum_interaction_range.

§Examples
use hoomd_geometry::{Scale, shape::Rectangle};
use hoomd_microstate::boundary::Periodic;

let periodic =
    Periodic::new(2.5, Rectangle::with_equal_edges(10.0.try_into()?))?;

let scaled_periodic = periodic.scale_length(0.5.try_into()?);

assert_eq!(scaled_periodic.maximum_interaction_range(), 2.5);
assert_eq!(scaled_periodic.shape().edge_lengths[0].get(), 5.0);
use hoomd_geometry::{Scale, shape::Rectangle};
use hoomd_microstate::boundary::Periodic;

let periodic =
    Periodic::new(2.5, Rectangle::with_equal_edges(10.0.try_into()?))?;

let scaled_periodic = periodic.scale_length(0.2.try_into()?);
Source§

fn scale_volume(&self, v: PositiveReal) -> Self

Scale the wrapped shape.

§Panics

When scaling the wrapped shape, scale_length will panic if the scaled maximum allowable interaction range is smaller than maximum_interaction_range.

§Examples
use hoomd_geometry::{Scale, shape::Rectangle};
use hoomd_microstate::boundary::Periodic;

let periodic =
    Periodic::new(2.5, Rectangle::with_equal_edges(10.0.try_into()?))?;

let scaled_periodic = periodic.scale_volume(4.0.try_into()?);

assert_eq!(scaled_periodic.maximum_interaction_range(), 2.5);
assert_eq!(scaled_periodic.shape().edge_lengths[0].get(), 20.0);
use hoomd_geometry::{Scale, shape::Rectangle};
use hoomd_microstate::boundary::Periodic;

let periodic =
    Periodic::new(2.5, Rectangle::with_equal_edges(10.0.try_into()?))?;

let scaled_periodic = periodic.scale_volume(0.2.try_into()?);
Source§

impl<T> Serialize for Periodic<T>
where T: 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<T> Volume for Periodic<T>
where T: Volume,

Source§

fn volume(&self) -> f64

Volume of the wrapped shape.

§Examples
use hoomd_geometry::{Volume, shape::Rectangle};
use hoomd_microstate::boundary::Periodic;

let periodic =
    Periodic::new(2.5, Rectangle::with_equal_edges(10.0.try_into()?))?;

let volume = periodic.volume();

assert_eq!(volume, 100.0);
Source§

impl Wrap<OrientedHyperbolicPoint<3, Angle>> for Periodic<EightEight>

Source§

fn wrap( &self, properties: OrientedHyperbolicPoint<3, Angle>, ) -> Result<OrientedHyperbolicPoint<3, Angle>, Error>

Wrap the positions and orientations of oriented bodies in two-dimensional hyperbolic space under the {8,8} tiling.

Source§

impl Wrap<OrientedHyperbolicPoint<3, Angle>> for Periodic<TwelveTwelve>

Source§

fn wrap( &self, properties: OrientedHyperbolicPoint<3, Angle>, ) -> Result<OrientedHyperbolicPoint<3, Angle>, Error>

Wrap the positions and orientations of oriented bodies in hyperbolic space under the {12,12} tiling.

Source§

impl<const N: usize, P> Wrap<P> for Periodic<Hypercuboid<N>>
where P: Position<Position = Cartesian<N>>,

Source§

fn wrap(&self, properties: P) -> Result<P, Error>

Wrap any cartesian vector to the inside of the given cuboid.

§Example
use hoomd_geometry::shape::Rectangle;
use hoomd_microstate::{
    boundary::{Periodic, Wrap},
    property::Point,
};
use hoomd_vector::Cartesian;

let periodic =
    Periodic::new(2.5, Rectangle::with_equal_edges(10.0.try_into()?))?;
let point = Point::new(Cartesian::from([6.0, -15.0]));

let wrapped_point = periodic.wrap(point)?;
assert_eq!(wrapped_point.position, [-4.0, -5.0].into());
Source§

impl Wrap<Point<Hyperbolic<3>>> for Periodic<EightEight>

Source§

fn wrap( &self, properties: Point<Hyperbolic<3>>, ) -> Result<Point<Hyperbolic<3>>, Error>

Wrap a point in hyperbolic space to the inside of the {8,8} tile.

Note that the function fails to wrap points that are outside the octagon and further than EightEight::EDGE_LENGTH/2 from any of the vertices. In this case, the function returns Error::CannotWrapProperties

§Example
use approxim::assert_relative_eq;
use hoomd_geometry::shape::EightEight;
use hoomd_manifold::Hyperbolic;
use hoomd_microstate::{
    boundary::{Periodic, Wrap},
    property::Point,
};
use std::f64::consts::PI;

const EIGHTEIGHT: f64 = EightEight::EIGHTEIGHT;
let offset = PI / 8.0;
let boost = 2.0;
let point =
    Hyperbolic::<3>::from_polar_coordinates(boost, offset + PI / 4.0);
let point = Point::new(point);
let periodic = Periodic::new(0.5, EightEight {})?;

let wrapped_point = periodic.wrap(point)?;

let new_boost = 2.0
    * (EIGHTEIGHT.tanh()
        / (offset.cos() - offset.sin() * (1.0 - (2.0_f64).sqrt())))
    .atanh()
    - boost;
let ans = Hyperbolic::<3>::from_polar_coordinates(
    new_boost,
    6.0 * PI / 4.0 - offset,
);
assert_relative_eq!(
    ans.coordinates()[0],
    wrapped_point.position.coordinates()[0],
    epsilon = 1e-12
);
assert_relative_eq!(
    ans.coordinates()[1],
    wrapped_point.position.coordinates()[1],
    epsilon = 1e-12
);
assert_relative_eq!(
    ans.coordinates()[2],
    wrapped_point.position.coordinates()[2],
    epsilon = 1e-12
);
Source§

impl Wrap<Point<Hyperbolic<3>>> for Periodic<TwelveTwelve>

Source§

fn wrap( &self, properties: Point<Hyperbolic<3>>, ) -> Result<Point<Hyperbolic<3>>, Error>

Wrap a point in hyperbolic space to the inside of the {12,12} tile.

Note that the function fails to wrap points that are outside the dodecagon and further than TwelveTwelve::EDGE_LENGTH/2 from any of the vertices.

Source§

impl<T> StructuralPartialEq for Periodic<T>

Auto Trait Implementations§

§

impl<T> Freeze for Periodic<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Periodic<T>
where T: RefUnwindSafe,

§

impl<T> Send for Periodic<T>
where T: Send,

§

impl<T> Sync for Periodic<T>
where T: Sync,

§

impl<T> Unpin for Periodic<T>
where T: Unpin,

§

impl<T> UnwindSafe for Periodic<T>
where T: 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> 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,