Skip to main content

RegionRestraint

Struct RegionRestraint 

Source
pub struct RegionRestraint<R: Region>(pub R);
Expand description

Wraps a Region as a soft-penalty AtomRestraint with quadratic exterior penalty:

penalty(x) = scale2 * max(0, signed_distance(x))²

Gradient uses the analytic chain rule 2 * scale2 * max(0, d) * ∂d/∂x, where ∂d/∂x comes from Region::signed_distance_grad.

§Example

use molpack::region::{InsideSphereRegion, RegionExt};
use molpack::{RegionRestraint, AtomRestraint};

let shell = InsideSphereRegion::new([0.0; 3], 10.0)
    .and(InsideSphereRegion::new([0.0; 3], 5.0).not());
let restraint = RegionRestraint(shell);
// At x=(7,0,0) the shell is satisfied → f == 0
assert_eq!(restraint.f(&[7.0, 0.0, 0.0], 1.0, 1.0), 0.0);
// At x=(15,0,0) we are outside the outer sphere → f > 0
assert!(restraint.f(&[15.0, 0.0, 0.0], 1.0, 1.0) > 0.0);

Tuple Fields§

§0: R

Trait Implementations§

Source§

impl<R: Region + 'static> AtomRestraint for RegionRestraint<R>

Source§

fn f(&self, x: &[F; 3], _scale: F, scale2: F) -> F

Source§

fn fg(&self, x: &[F; 3], scale: F, scale2: F, g: &mut [F; 3]) -> F

Source§

fn is_parallel_safe(&self) -> bool

Source§

fn name(&self) -> &'static str

Source§

fn periodic_box(&self) -> Option<([F; 3], [F; 3], [bool; 3])>

Declare that this restraint defines a periodic box for the pair-kernel minimum-image wrap. Return Some((min, max, periodic)) where periodic[k] == true marks axis k as wrapping. Default None means this restraint does not imply PBC.
Source§

impl<R: Clone + Region> Clone for RegionRestraint<R>

Source§

fn clone(&self) -> RegionRestraint<R>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<R: Copy + Region> Copy for RegionRestraint<R>

Source§

impl<R: Debug + Region> Debug for RegionRestraint<R>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<R> Freeze for RegionRestraint<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for RegionRestraint<R>
where R: RefUnwindSafe,

§

impl<R> Send for RegionRestraint<R>

§

impl<R> Sync for RegionRestraint<R>

§

impl<R> Unpin for RegionRestraint<R>
where R: Unpin,

§

impl<R> UnsafeUnpin for RegionRestraint<R>
where R: UnsafeUnpin,

§

impl<R> UnwindSafe for RegionRestraint<R>
where R: 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V