Expand description
Traits that describe body and/or site properties a a selection types that implement them.
See the crate-level documentation for an overview of how body and site
properties interact with Microstate and model methods.
§Provided types
The structs provided in property may be used as Body and/or
Site properties.
Point represents a position in space:
use hoomd_microstate::property::Point;
use hoomd_vector::Cartesian;
let point = Point::new(Cartesian::from([1.0, -3.0]));OrientedPoint contains both the position and orientation of an extended body:
use hoomd_microstate::property::OrientedPoint;
use hoomd_vector::{Angle, Cartesian};
let point = OrientedPoint {
position: Cartesian::from([1.0, -3.0]),
orientation: Angle::from(1.2),
};§Custom property types
When none of the provided types meets your needs, you can define a custom type.
You must implement Position for your type and may implement other
property traits as needed by your model.
For example, this Custom type implements Position, Orientation,
and has a custom field. The full site properties type is available when
hoomd-rs computes interactions on sites, so you can use the custom fields
in your own custom interaction potentials.
use hoomd_microstate::property::{Orientation, Position};
use hoomd_vector::{Cartesian, Versor};
#[derive(Position, Orientation)]
struct Custom {
position: Cartesian<3>,
orientation: Versor,
custom: f64,
}§Transformations
Implement Transform to take sites from the body frame to the system frame.
Typically, this involves transforming position and orientation while leaving
all other fields unchanged. The three most common implementations of Transform
follow. All these examples are in 3D. To convert to 2D, replace Cartesian<3>
with Cartesian<2> and Versor with Angle.
Non-oriented bodies and sites (i.e. point particles or non-rotating rigid bodies):
use hoomd_microstate::{
Transform,
property::{Point, Position},
};
use hoomd_vector::Cartesian;
#[derive(Position)]
struct Custom {
position: Cartesian<3>,
custom: f64,
}
impl Transform<Custom> for Point<Cartesian<3>> {
fn transform(&self, site_properties: &Custom) -> Custom {
Custom {
position: self.position + site_properties.position,
..*site_properties
}
}
}Oriented bodies and non-oriented sites (i.e. rotating rigid bodies with isotropic site-site interactions):
use hoomd_microstate::{
Transform,
property::{OrientedPoint, Position},
};
use hoomd_vector::{Cartesian, Rotate, Rotation, Versor};
#[derive(Position)]
struct Custom {
position: Cartesian<3>,
custom: f64,
}
impl Transform<Custom> for OrientedPoint<Cartesian<3>, Versor> {
fn transform(&self, site_properties: &Custom) -> Custom {
Custom {
position: self.position
+ self.orientation.rotate(&site_properties.position),
..*site_properties
}
}
}Oriented bodies and oriented sites (i.e. rotating rigid bodies with anisotropic site-site interactions):
use hoomd_microstate::{
Transform,
property::{Orientation, OrientedPoint, Position},
};
use hoomd_vector::{Cartesian, Rotate, Rotation, Versor};
#[derive(Position, Orientation)]
struct Custom {
position: Cartesian<3>,
orientation: Versor,
custom: f64,
}
impl Transform<Custom> for OrientedPoint<Cartesian<3>, Versor> {
fn transform(&self, site_properties: &Custom) -> Custom {
Custom {
position: self.position
+ self.orientation.rotate(&site_properties.position),
orientation: self
.orientation
.combine(&site_properties.orientation),
..*site_properties
}
}
}Structs§
- Oriented
Hyperbolic Point - The position and orientation of an extended body in hyperbolic space.
- Oriented
Point - The position and orientation of an extended body.
- Point
- A position in space and nothing more.
Traits§
- Orientation
- Rotate sites and bodies.
- Position
- Locate sites and bodies.
Derive Macros§
- Orientation
- Automatically implement the
hoomd_microstate::property::Orientationtrait. - Position
- Automatically implement the
hoomd_microstate::property::Positiontrait.