pub struct Body<B, S = B> {
pub properties: B,
pub sites: Vec<S>,
}Expand description
A collection of interaction sites that can be placed in a Microstate.
The Body properties have a generic type that includes all the body’s
degrees of freedom and any other fields needed to implement the user’s
model. Bodies interact indirectly via one or more sites. The sites vector
stores the properties of the body’s sites in the body frame. The body field
properties stores the body’s degrees of freedom (such as position and
orientation) in the system frame. Transform describes how a given body
transforms its sites from the body frame to the system frame.
In typical cases, such as those implemented in hoomd-rs, Body describes
a rigid collection of sites that transform together. However, creative
implementations of Transform could achieve other behaviors.
Use the properties defined in property to construct bodies that meet
the needs of your model.
§Examples
Construct body with a single interaction site at one point:
use hoomd_microstate::Body;
use hoomd_vector::Cartesian;
let body = Body::point(Cartesian::from([-3.0, 5.0]));Construct an oriented body:
use hoomd_microstate::{Body, property::OrientedPoint};
use hoomd_vector::{Angle, Cartesian};
let body_properties = OrientedPoint {
position: Cartesian::from([1.0, -3.0]),
orientation: Angle::from(1.2),
};
let site_properties = OrientedPoint {
position: Cartesian::<2>::default(),
orientation: Angle::default(),
};
let body = Body {
properties: body_properties,
sites: vec![site_properties],
};Construct a rigid body with several point sites:
use hoomd_microstate::{
Body,
property::{OrientedPoint, Point},
};
use hoomd_vector::{Angle, Cartesian};
let body_properties = OrientedPoint {
position: Cartesian::from([1.0, -3.0]),
orientation: Angle::from(1.2),
};
let body = Body {
properties: body_properties,
sites: vec![
Point::new(Cartesian::from([0.0, -1.0])),
Point::new(Cartesian::from([0.0, 0.0])),
Point::new(Cartesian::from([0.0, 1.0])),
],
};§Custom body and site properties
The property module documentation shows you how to define custom body
and site property types.
Fields§
§properties: BThe body’s degrees of freedom.
sites: Vec<S>Interaction sites in the body’s frame of reference.
Implementations§
Source§impl<V> Body<Point<V>, Point<V>>
impl<V> Body<Point<V>, Point<V>>
Sourcepub fn point(position: V) -> Selfwhere
V: Default,
pub fn point(position: V) -> Selfwhere
V: Default,
Construct a point particle.
A point particle is a Body with a single interaction site at the body’s
origin. The body and site property types are identical and have only a
position field. Use point particles for simulations of monodisperse hard
spheres, identical particles with pairwise interactions, or any time you
need a Microstate that consists only of point particles.
§Example
use hoomd_microstate::Body;
use hoomd_vector::Cartesian;
let body = Body::point(Cartesian::from([-3.0, 5.0]));
assert_eq!(body.properties.position, [-3.0, 5.0].into());
assert_eq!(body.sites.len(), 1);
assert_eq!(body.sites[0].position, [0.0, 0.0].into());Trait Implementations§
Source§impl<'de, B, S> Deserialize<'de> for Body<B, S>where
B: Deserialize<'de>,
S: Deserialize<'de>,
impl<'de, B, S> Deserialize<'de> for Body<B, S>where
B: Deserialize<'de>,
S: Deserialize<'de>,
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>,
impl<B, S> StructuralPartialEq for Body<B, S>
Auto Trait Implementations§
impl<B, S> Freeze for Body<B, S>where
B: Freeze,
impl<B, S> RefUnwindSafe for Body<B, S>where
B: RefUnwindSafe,
S: RefUnwindSafe,
impl<B, S> Send for Body<B, S>
impl<B, S> Sync for Body<B, S>
impl<B, S> Unpin for Body<B, S>
impl<B, S> UnsafeUnpin for Body<B, S>where
B: UnsafeUnpin,
impl<B, S> UnwindSafe for Body<B, S>where
B: UnwindSafe,
S: 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