Skip to main content

Body

Struct Body 

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

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

Source

pub fn point(position: V) -> Self
where 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<B, S> Clone for Body<B, S>
where B: Clone, S: Clone,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<B: Debug, S: Debug> Debug for Body<B, S>

Source§

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

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

impl<B: Default, S: Default> Default for Body<B, S>

Source§

fn default() -> Body<B, S>

Returns the “default value” for a type. Read more
Source§

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

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<B: PartialEq, S: PartialEq> PartialEq for Body<B, S>

Source§

fn eq(&self, other: &Body<B, S>) -> 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> Serialize for Body<B, S>
where B: Serialize, S: 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> 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>

§

impl<B, S> Send for Body<B, S>
where B: Send, S: Send,

§

impl<B, S> Sync for Body<B, S>
where B: Sync, S: Sync,

§

impl<B, S> Unpin for Body<B, S>
where B: Unpin, S: Unpin,

§

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