Skip to main content

ApproximateShapeOverlap

Struct ApproximateShapeOverlap 

Source
pub struct ApproximateShapeOverlap<E, A, B = A> {
    pub shape_i: A,
    pub shape_j: B,
    pub isotropic: E,
    pub resolution: PositiveReal,
}
Expand description

Apply an isotropic potential evaluated at the approximate signed overlap distance.

Use ApproximateShapeOverlap combined with OverlapPenalty and QuickInsert to quickly insert new bodies into the microstate or QuickCompress to quickly compress the system to a target density. In both cases, ApproximateShapeOverlap will allow partial overlaps that can be resolved by later trial moves.

ApproximateShapeOverlap approximates the distance r that shape j must be moved to remove any overlaps. If the shapes are already separate, r is 0. Then it returns isotropic.energy(-r). resolution sets the steps between r values.

The overlap distance is approximate and expensive to evaluate. Do not use this potential for equilibration or sampling. It is suitable only for use during a brief initialization phase when QuickInsert is adding bodies or QuickCompress is compressing the system.

§Example

use hoomd_geometry::{Convex, shape::ConvexPolygon};
use hoomd_interaction::{
    pairwise::ApproximateShapeOverlap, univariate::OverlapPenalty,
};

let approximate_shape_overlap = ApproximateShapeOverlap::new(
    Convex(ConvexPolygon::regular(6)),
    OverlapPenalty::default(),
    0.01.try_into()?,
);

Fields§

§shape_i: A

The site i’s shape.

§shape_j: B

The site j’s shape.

§isotropic: E

Potential to apply as a function of the signed distance between shapes.

§resolution: PositiveReal

Resolve the separation distance in multiples of this resolution.

Implementations§

Source§

impl<E, G> ApproximateShapeOverlap<E, G>

Source

pub fn new(shape: G, isotropic: E, resolution: PositiveReal) -> Self
where G: Clone,

Construct a new approximate shape overlap potential.

new() sets both shape_i and shape_j to shape. Use struct initialization syntax when you need to set these separately.

§Example
use hoomd_geometry::{Convex, shape::ConvexPolygon};
use hoomd_interaction::{
    pairwise::ApproximateShapeOverlap, univariate::OverlapPenalty,
};

let approximate_shape_overlap = ApproximateShapeOverlap::new(
    Convex(ConvexPolygon::regular(6)),
    OverlapPenalty::default(),
    0.01.try_into()?,
);

Trait Implementations§

Source§

impl<E, A, B, V, R> AnisotropicEnergy<V, R> for ApproximateShapeOverlap<E, A, B>
where E: UnivariateEnergy, V: InnerProduct, R: Rotation + Rotate<V>, A: IntersectsAt<B, V, R>,

Source§

fn energy(&self, r_ij: &V, o_ij: &R) -> f64

Evaluate the energy contribution from a pair of sites.

use hoomd_geometry::{Convex, shape::ConvexPolygon};
use hoomd_interaction::{
    SitePairEnergy,
    pairwise::{Anisotropic, ApproximateShapeOverlap},
    univariate::OverlapPenalty,
};
use hoomd_microstate::property::OrientedPoint;
use hoomd_vector::{Angle, Cartesian};

let approximate_shape_overlap = Anisotropic {
    interaction: ApproximateShapeOverlap::new(
        Convex(ConvexPolygon::regular(6)),
        OverlapPenalty::default(),
        0.01.try_into()?,
    ),
    r_cut: 1.0,
};

let a = OrientedPoint {
    position: Cartesian::from([0.0, 0.0]),
    orientation: Angle::default(),
};
let b = OrientedPoint {
    position: Cartesian::from([0.6, 0.0]),
    orientation: Angle::default(),
};

let energy = approximate_shape_overlap.site_pair_energy(&a, &b);
assert!(energy >= 100.0);

let c = OrientedPoint {
    position: Cartesian::from([0.9, 0.0]),
    orientation: Angle::default(),
};

let energy = approximate_shape_overlap.site_pair_energy(&a, &c);
assert!(energy >= 0.0);
assert!(energy < f64::INFINITY);

let d = OrientedPoint {
    position: Cartesian::from([1.0, 0.0]),
    orientation: Angle::default(),
};

let energy = approximate_shape_overlap.site_pair_energy(&a, &d);
assert_eq!(energy, 0.0);
Source§

impl<E: Clone, A: Clone, B: Clone> Clone for ApproximateShapeOverlap<E, A, B>

Source§

fn clone(&self) -> ApproximateShapeOverlap<E, A, B>

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<E: Debug, A: Debug, B: Debug> Debug for ApproximateShapeOverlap<E, A, B>

Source§

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

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

impl<'de, E, A, B> Deserialize<'de> for ApproximateShapeOverlap<E, A, B>
where E: Deserialize<'de>, A: Deserialize<'de>, B: 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<E: PartialEq, A: PartialEq, B: PartialEq> PartialEq for ApproximateShapeOverlap<E, A, B>

Source§

fn eq(&self, other: &ApproximateShapeOverlap<E, A, B>) -> 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<E, A, B> Serialize for ApproximateShapeOverlap<E, A, B>
where E: Serialize, A: Serialize, B: 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<E, A, B> StructuralPartialEq for ApproximateShapeOverlap<E, A, B>

Auto Trait Implementations§

§

impl<E, A, B> Freeze for ApproximateShapeOverlap<E, A, B>
where A: Freeze, B: Freeze, E: Freeze,

§

impl<E, A, B> RefUnwindSafe for ApproximateShapeOverlap<E, A, B>

§

impl<E, A, B> Send for ApproximateShapeOverlap<E, A, B>
where A: Send, B: Send, E: Send,

§

impl<E, A, B> Sync for ApproximateShapeOverlap<E, A, B>
where A: Sync, B: Sync, E: Sync,

§

impl<E, A, B> Unpin for ApproximateShapeOverlap<E, A, B>
where A: Unpin, B: Unpin, E: Unpin,

§

impl<E, A, B> UnsafeUnpin for ApproximateShapeOverlap<E, A, B>

§

impl<E, A, B> UnwindSafe for ApproximateShapeOverlap<E, A, B>
where A: UnwindSafe, B: UnwindSafe, E: 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>,