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: ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, origin: ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, pbc: [bool; 3], ) -> Result<SimBox, BoxError>

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

Source

pub fn try_new( h: ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, origin: ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, pbc: [bool; 3], ) -> Result<SimBox, BoxError>

Source

pub fn cube( a: f64, origin: ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, pbc: [bool; 3], ) -> Result<SimBox, BoxError>

Factory: cubic box with edge length a and origin O

Source

pub fn ortho( lengths: ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, origin: ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, pbc: [bool; 3], ) -> Result<SimBox, BoxError>

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

Source

pub fn free( points: ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>, padding: f64, ) -> Result<SimBox, 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) -> ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>

View of the cell matrix

Source

pub fn inv_view(&self) -> ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>

View of the inverse cell matrix

Source

pub fn origin_view(&self) -> ArrayBase<ViewRepr<&f64>, Dim<[usize; 1]>>

View of the origin

Source

pub fn pbc_view(&self) -> ArrayBase<ViewRepr<&bool>, Dim<[usize; 1]>>

View of the PBC flags

Source

pub fn pbc(&self) -> [bool; 3]

Per-axis PBC flags

Source

pub fn volume(&self) -> f64

Cell volume (|det(H)|)

Source

pub fn tilts(&self) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>

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

Source

pub fn lengths(&self) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>

Lattice vector lengths

Source

pub fn nearest_plane_distance( &self, ) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>

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, ) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>

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

Source

pub fn make_fractional( &self, r: ArrayBase<ViewRepr<&f64>, Dim<[usize; 1]>>, ) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>

Convert Cartesian coordinates to fractional coordinates [0, 1)

Source

pub fn make_fractional_fast( &self, r: ArrayBase<ViewRepr<&f64>, Dim<[usize; 1]>>, ) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>

Fractional coordinates with ortho fast-path

Source

pub fn make_fractional_fast_arr( &self, r: ArrayBase<ViewRepr<&f64>, Dim<[usize; 1]>>, ) -> [f64; 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: ArrayBase<ViewRepr<&f64>, Dim<[usize; 1]>>, ) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>

Convert fractional coordinates to Cartesian coordinates

Source

pub fn shortest_vector( &self, r1: ArrayBase<ViewRepr<&f64>, Dim<[usize; 1]>>, r2: ArrayBase<ViewRepr<&f64>, Dim<[usize; 1]>>, ) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>

Minimum image displacement vector from r1 to r2 (r2 - r1)

Source

pub fn shortest_vector_fast( &self, a: ArrayBase<ViewRepr<&f64>, Dim<[usize; 1]>>, b: ArrayBase<ViewRepr<&f64>, Dim<[usize; 1]>>, ) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>

Shortest vector with ortho fast-path

Source

pub fn shortest_vector_fast_arr( &self, a: ArrayBase<ViewRepr<&f64>, Dim<[usize; 1]>>, b: ArrayBase<ViewRepr<&f64>, Dim<[usize; 1]>>, ) -> [f64; 3]

Shortest vector returned as [F; 3] (zero-alloc hot path).

Equivalent to shortest_vector_fast but avoids the Array1<F> heap allocation by returning a stack array. Use inside neighbor-list pair loops where called O(N·k) times per build.

Source

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

Shortest vector from raw [F; 3] inputs, returning [F; 3].

Both inputs and output are stack arrays — no ArrayView indexing. Called from neighbor-list inner loops where positions are stored in a flat [F; 3] slab instead of an Array2<F>.

Source

pub fn calc_distance2( &self, a: ArrayBase<ViewRepr<&f64>, Dim<[usize; 1]>>, b: ArrayBase<ViewRepr<&f64>, Dim<[usize; 1]>>, ) -> f64

Calculate squared distance using MIC.

Source

pub fn to_frac( &self, xyz: ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>, ) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>

Convert Cartesian points to fractional coordinates (N×3)

Source

pub fn to_cart( &self, frac: ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>, ) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>

Convert fractional coordinates to Cartesian points (N×3)

Source

pub fn isin( &self, xyz: ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>, ) -> ArrayBase<OwnedRepr<bool>, Dim<[usize; 1]>>

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

Source

pub fn delta_out( &self, xyzu1: ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>, xyzu2: ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>, out: &mut ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, minimum_image: bool, )

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

Source

pub fn delta( &self, xyzu1: ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>, xyzu2: ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>, minimum_image: bool, ) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>

Batched displacement vectors row-wise (N×3)

Source

pub fn wrap( &self, xyz: ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>, ) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>

Wrap Cartesian points into the unit cell according to PBC

Source

pub fn get_corners(&self) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>

Trait Implementations§

Source§

impl Clone for SimBox

Source§

fn clone(&self) -> SimBox

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

Source§

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

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

impl Region for SimBox

Source§

fn bounds(&self) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>

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

fn contains( &self, points: &ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ) -> ArrayBase<OwnedRepr<bool>, Dim<[usize; 1]>>

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

fn contains_point(&self, point: &[f64; 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> 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.