Skip to main content

MicrostateBuilder

Struct MicrostateBuilder 

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

Source

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);
Source

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()?;
Source

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);
Source

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);
Source

pub fn bodies<T>(self, bodies: T) -> Self
where 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);
Source

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>

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl<B: Debug, S: Debug, X: Debug, C: Debug> Debug for MicrostateBuilder<B, S, X, C>

Source§

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

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

impl<'de, B, S, X, C> Deserialize<'de> for MicrostateBuilder<B, S, X, C>
where B: Deserialize<'de>, S: Deserialize<'de>, X: Deserialize<'de>, C: 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<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

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<B, S, X, C> Serialize for MicrostateBuilder<B, S, X, C>
where B: Serialize, S: Serialize, X: Serialize, C: 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<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>
where X: Freeze, C: Freeze,

§

impl<B, S, X, C> RefUnwindSafe for MicrostateBuilder<B, S, X, C>

§

impl<B, S, X, C> Send for MicrostateBuilder<B, S, X, C>
where X: Send, C: Send, B: Send, S: Send,

§

impl<B, S, X, C> Sync for MicrostateBuilder<B, S, X, C>
where X: Sync, C: Sync, B: Sync, S: Sync,

§

impl<B, S, X, C> Unpin for MicrostateBuilder<B, S, X, C>
where X: Unpin, C: Unpin, B: Unpin, S: Unpin,

§

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

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