Skip to main content

SimBox

Struct SimBox 

Source
pub struct SimBox { /* private fields */ }
Expand description

Simulation box: triclinic cell with origin and per-axis PBC mask

Implementations§

Source§

impl SimBox

Source

pub fn new(h: F3x3, origin: F3, pbc: Pbc3) -> Result<Self, BoxError>

Construct from triclinic cell matrix H, origin O, and per-axis PBC flags

Source

pub fn new_cell( h: F3x3, origin: F3, pbc: Pbc3, cell_defined: bool, ) -> Result<Self, BoxError>

Construct a box, explicitly marking whether the cell is geometrically defined. Pass cell_defined = false for a “no-cell” box (undefined / zero-volume): supply the identity matrix so geometry ops degrade to no-ops, and volume / is_cell_defined reflect the undefined cell.

Source

pub fn is_cell_defined(&self) -> bool

Whether the cell is geometrically defined (false ⇒ a no-cell box of undefined / zero volume). Distinct from periodicity (is_free).

Source

pub fn try_new(h: F3x3, origin: F3, pbc: Pbc3) -> Result<Self, BoxError>

Source

pub fn cube(a: F, origin: F3, pbc: Pbc3) -> Result<Self, BoxError>

Factory: cubic box with edge length a and origin O

Source

pub fn ortho(lengths: F3, origin: F3, pbc: Pbc3) -> Result<Self, BoxError>

Factory: ortho box with lengths (ax, ay, az) and origin O

Source

pub fn free(points: FNx3View<'_>, padding: F) -> Result<Self, BoxError>

Create a non-periodic (free-boundary) box enclosing all points.

Computes the axis-aligned bounding box of points and adds padding on each side. The resulting box has pbc = [false, false, false].

padding should be >= the neighbor cutoff distance so that all particles sit well inside the box for correct cell assignment.

§Errors

Returns BoxError if padding is non-positive or the resulting box is degenerate.

§Panics

Panics if padding <= 0.

Source

pub fn h_view(&self) -> FNx3View<'_>

View of the cell matrix

Source

pub fn inv_view(&self) -> FNx3View<'_>

View of the inverse cell matrix

Source

pub fn origin_view(&self) -> F3View<'_>

View of the origin

Source

pub fn pbc_view(&self) -> ArrayView1<'_, bool>

View of the PBC flags

Source

pub fn pbc(&self) -> Pbc3

Per-axis PBC flags

Source

pub fn volume(&self) -> F

Cell volume (|det(H)|)

Source

pub fn is_free(&self) -> bool

true when the box is free (non-periodic on every axis).

Source

pub fn style(&self) -> &'static str

Geometry style label: "free" (no periodic axis), "orthogonal" (diagonal H), or "triclinic".

Source

pub fn tilts(&self) -> F3

Off-diagonal tilts [xy, xz, yz] of the cell matrix

Source

pub fn lengths(&self) -> F3

Lattice vector lengths

Source

pub fn nearest_plane_distance(&self) -> F3

Nearest plane distance (half the box size along each axis) For triclinic boxes, this is the perpendicular distance to each face

Source

pub fn kind(&self) -> &BoxKind

Source

pub fn lattice(&self, index: usize) -> F3

Lattice vector by index (0,1,2) — columns of H

Source

pub fn make_fractional(&self, r: F3View<'_>) -> F3

Convert Cartesian coordinates to fractional coordinates [0, 1)

Source

pub fn make_fractional_fast(&self, r: F3View<'_>) -> F3

Fractional coordinates with ortho fast-path

Source

pub fn make_fractional_fast_arr(&self, r: F3View<'_>) -> [F; 3]

Fractional coordinates returned as [F; 3] (zero-alloc hot path).

Equivalent to make_fractional_fast but avoids the Array1<F> heap allocation by returning a stack array. Use in tight inner loops (neighbor-list cell assignment, etc.).

Source

pub fn make_cartesian(&self, frac: F3View<'_>) -> F3

Convert fractional coordinates to Cartesian coordinates

Source

pub fn shortest_vector(&self, r1: F3View<'_>, r2: F3View<'_>) -> F3

Minimum image displacement vector from r1 to r2 (returns r2 − r1).

Ergonomic ndarray-flavoured API: takes views and returns an owned Array1<F>. Inside hot loops prefer shortest_vector_impl — it avoids the heap allocation for the output (~70% faster per call).

Source

pub fn shortest_vector_impl(&self, a: [F; 3], b: [F; 3]) -> [F; 3]

Zero-allocation MIC displacement from a to b (returns b − a).

Stack-array in / out; the canonical hot-loop entry point. Used by LinkCell, BruteForce, and AabbQuery inner loops.

Source

pub fn calc_distance2(&self, a: F3View<'_>, b: F3View<'_>) -> F

Calculate squared distance using MIC.

Source

pub fn to_frac(&self, xyz: FNx3View<'_>) -> FNx3

Convert Cartesian points to fractional coordinates (N×3)

Source

pub fn to_cart(&self, frac: FNx3View<'_>) -> FNx3

Convert fractional coordinates to Cartesian points (N×3)

Source

pub fn isin(&self, xyz: FNx3View<'_>) -> Array1<bool>

Check if points lie within [0,1) in fractional space.

Source

pub fn delta_out( &self, xyzu1: FNx3View<'_>, xyzu2: FNx3View<'_>, out: &mut FNx3, minimum_image: bool, )

Batched displacement vectors row-wise (N×3). Writes result into out to avoid allocation.

Source

pub fn delta( &self, xyzu1: FNx3View<'_>, xyzu2: FNx3View<'_>, minimum_image: bool, ) -> FNx3

Batched displacement vectors row-wise (N×3)

Source

pub fn wrap(&self, xyz: FNx3View<'_>) -> FNx3

Wrap Cartesian points into the unit cell according to PBC

Source

pub fn get_corners(&self) -> FNx3

Trait Implementations§

Source§

impl Clone for SimBox

Source§

fn clone(&self) -> SimBox

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 Debug for SimBox

Source§

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

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

impl Region for SimBox

Source§

fn bounds(&self) -> FNx3

Returns the axis-aligned bounding box of the region. Read more
Source§

fn contains(&self, points: &FNx3) -> Array1<bool>

Batched containment test for a set of 3D points. Read more
Source§

fn contains_point(&self, point: &[F; 3]) -> bool

Single-point containment test. Read more

Auto Trait Implementations§

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.