pub struct MicrostateBuilder<B, S = B, X = AllPairs<SiteKey>, C = Open> { /* private fields */ }Expand description
Choose parameters when constructing a Microstate.
Use a MicrostateBuilder to choose the values of optional parameters when
constructing a Microstate. Some parameters, such as seed and step,
cannot be directly modified after building the Microstate.
§Example
use hoomd_microstate::{Body, Microstate};
use hoomd_vector::Cartesian;
let mut microstate = Microstate::builder()
.step(100_000)
.seed(0x1234abcd)
.bodies([
Body::point(Cartesian::from([1.0, 0.0])),
Body::point(Cartesian::from([-1.0, 2.0])),
])
.try_build()?;
assert_eq!(microstate.step(), 100_000);
assert_eq!(microstate.seed(), 0x1234abcd);
assert_eq!(microstate.bodies().len(), 2);Implementations§
Source§impl<B, S, X, C> MicrostateBuilder<B, S, X, C>
impl<B, S, X, C> MicrostateBuilder<B, S, X, C>
Sourcepub fn boundary<C2>(self, boundary: C2) -> MicrostateBuilder<B, S, X, C2>
pub fn boundary<C2>(self, boundary: C2) -> MicrostateBuilder<B, S, X, C2>
Choose the boundary conditions in the resulting Microstate.
§Example
use hoomd_geometry::shape::Rectangle;
use hoomd_microstate::{Microstate, boundary::Closed};
use hoomd_spatial::AllPairs;
use hoomd_vector::Cartesian;
let square = Closed(Rectangle::with_equal_edges(10.0.try_into()?));
let microstate = Microstate::<BodyProperties, SiteProperties>::builder()
.boundary(square)
.try_build()?;
assert_eq!(microstate.boundary().0.edge_lengths[0].get(), 10.0);Sourcepub fn spatial_data<X2>(
self,
spatial_data: X2,
) -> MicrostateBuilder<B, S, X2, C>
pub fn spatial_data<X2>( self, spatial_data: X2, ) -> MicrostateBuilder<B, S, X2, C>
Set the spatial data structure in the resulting Microstate.
§Example
use hoomd_microstate::{Microstate, SiteKey};
use hoomd_spatial::VecCell;
use hoomd_vector::Cartesian;
let cell_list = VecCell::builder()
.nominal_search_radius(2.5.try_into()?)
.build();
let microstate = Microstate::<BodyProperties, SiteProperties>::builder()
.spatial_data(cell_list)
.try_build()?;Sourcepub fn step(self, step: u64) -> Self
pub fn step(self, step: u64) -> Self
Choose the initial step in the resulting Microstate.
The default step is 0.
§Example
use hoomd_microstate::{Microstate, boundary::Open, property::Point};
use hoomd_vector::Cartesian;
let microstate = Microstate::<BodyProperties, SiteProperties>::builder()
.step(100_000)
.try_build()?;
assert_eq!(microstate.step(), 100_000);Sourcepub fn seed(self, seed: u32) -> Self
pub fn seed(self, seed: u32) -> Self
Choose the random number seed in the resulting Microstate.
The default seed is 0.
§Example
use hoomd_microstate::{Microstate, boundary::Open, property::Point};
use hoomd_vector::Cartesian;
let microstate = Microstate::<BodyProperties, SiteProperties>::builder()
.seed(0x1234abcd)
.try_build()?;
assert_eq!(microstate.seed(), 0x1234abcd);Sourcepub fn bodies<T>(self, bodies: T) -> Selfwhere
T: IntoIterator<Item = Body<B, S>>,
pub fn bodies<T>(self, bodies: T) -> Selfwhere
T: IntoIterator<Item = Body<B, S>>,
Add bodies to the resulting Microstate.
All bodies will be appended when this method is called multiple times.
§Example
use hoomd_microstate::{Body, Microstate};
use hoomd_vector::Cartesian;
let mut microstate = Microstate::builder()
.bodies([
Body::point(Cartesian::from([1.0, 0.0])),
Body::point(Cartesian::from([-1.0, 2.0])),
])
.try_build()?;
assert_eq!(microstate.bodies().len(), 2);Sourcepub fn try_build<P>(self) -> Result<Microstate<B, S, X, C>, Error>where
P: Copy,
B: Transform<S> + Position<Position = P>,
S: Position<Position = P> + Default,
C: Wrap<B> + Wrap<S> + GenerateGhosts<S>,
X: PointUpdate<P, SiteKey>,
pub fn try_build<P>(self) -> Result<Microstate<B, S, X, C>, Error>where
P: Copy,
B: Transform<S> + Position<Position = P>,
S: Position<Position = P> + Default,
C: Wrap<B> + Wrap<S> + GenerateGhosts<S>,
X: PointUpdate<P, SiteKey>,
Construct a Microstate with the chosen options.
§Errors
See Microstate::extend_bodies().
§Example
use hoomd_microstate::{Body, Microstate};
use hoomd_vector::Cartesian;
let mut microstate = Microstate::builder()
.step(100_000)
.seed(0x1234abcd)
.bodies([
Body::point(Cartesian::from([1.0, 0.0])),
Body::point(Cartesian::from([-1.0, 2.0])),
])
.try_build()?;
assert_eq!(microstate.step(), 100_000);
assert_eq!(microstate.seed(), 0x1234abcd);
assert_eq!(microstate.bodies().len(), 2);Trait Implementations§
Source§impl<B: Clone, S: Clone, X: Clone, C: Clone> Clone for MicrostateBuilder<B, S, X, C>
impl<B: Clone, S: Clone, X: Clone, C: Clone> Clone for MicrostateBuilder<B, S, X, C>
Source§fn clone(&self) -> MicrostateBuilder<B, S, X, C>
fn clone(&self) -> MicrostateBuilder<B, S, X, C>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'de, B, S, X, C> Deserialize<'de> for MicrostateBuilder<B, S, X, C>
impl<'de, B, S, X, C> Deserialize<'de> for MicrostateBuilder<B, S, X, C>
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<B: PartialEq, S: PartialEq, X: PartialEq, C: PartialEq> PartialEq for MicrostateBuilder<B, S, X, C>
impl<B: PartialEq, S: PartialEq, X: PartialEq, C: PartialEq> PartialEq for MicrostateBuilder<B, S, X, C>
Source§fn eq(&self, other: &MicrostateBuilder<B, S, X, C>) -> bool
fn eq(&self, other: &MicrostateBuilder<B, S, X, C>) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl<B, S, X, C> Serialize for MicrostateBuilder<B, S, X, C>
impl<B, S, X, C> Serialize for MicrostateBuilder<B, S, X, C>
impl<B, S, X, C> StructuralPartialEq for MicrostateBuilder<B, S, X, C>
Auto Trait Implementations§
impl<B, S, X, C> Freeze for MicrostateBuilder<B, S, X, C>
impl<B, S, X, C> RefUnwindSafe for MicrostateBuilder<B, S, X, C>
impl<B, S, X, C> Send for MicrostateBuilder<B, S, X, C>
impl<B, S, X, C> Sync for MicrostateBuilder<B, S, X, C>
impl<B, S, X, C> Unpin for MicrostateBuilder<B, S, X, C>
impl<B, S, X, C> UnsafeUnpin for MicrostateBuilder<B, S, X, C>where
X: UnsafeUnpin,
C: UnsafeUnpin,
impl<B, S, X, C> UnwindSafe for MicrostateBuilder<B, S, X, C>
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
Mutably borrows from an owned value. Read more
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>
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 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>
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