pub struct SimBox { /* private fields */ }Expand description
Simulation box: triclinic cell with origin and per-axis PBC mask
Implementations§
Source§impl SimBox
impl SimBox
Sourcepub fn new(
h: ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>,
origin: ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>,
pbc: [bool; 3],
) -> Result<SimBox, BoxError>
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
pub fn try_new( h: ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, origin: ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, pbc: [bool; 3], ) -> Result<SimBox, BoxError>
Sourcepub fn cube(
a: f64,
origin: ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>,
pbc: [bool; 3],
) -> Result<SimBox, BoxError>
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
Sourcepub fn ortho(
lengths: ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>,
origin: ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>,
pbc: [bool; 3],
) -> Result<SimBox, BoxError>
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
Sourcepub fn free(
points: ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>,
padding: f64,
) -> Result<SimBox, BoxError>
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.
Sourcepub fn inv_view(&self) -> ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>
pub fn inv_view(&self) -> ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>
View of the inverse cell matrix
Sourcepub fn tilts(&self) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>
pub fn tilts(&self) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>
Off-diagonal tilts [xy, xz, yz] of the cell matrix
Sourcepub fn nearest_plane_distance(
&self,
) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>
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
pub fn kind(&self) -> &BoxKind
Sourcepub fn lattice(
&self,
index: usize,
) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>
pub fn lattice( &self, index: usize, ) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>
Lattice vector by index (0,1,2) — columns of H
Sourcepub fn make_fractional(
&self,
r: ArrayBase<ViewRepr<&f64>, Dim<[usize; 1]>>,
) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>
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)
Sourcepub fn make_fractional_fast(
&self,
r: ArrayBase<ViewRepr<&f64>, Dim<[usize; 1]>>,
) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>
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
Sourcepub fn make_fractional_fast_arr(
&self,
r: ArrayBase<ViewRepr<&f64>, Dim<[usize; 1]>>,
) -> [f64; 3]
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.).
Sourcepub fn make_cartesian(
&self,
frac: ArrayBase<ViewRepr<&f64>, Dim<[usize; 1]>>,
) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>
pub fn make_cartesian( &self, frac: ArrayBase<ViewRepr<&f64>, Dim<[usize; 1]>>, ) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>
Convert fractional coordinates to Cartesian coordinates
Sourcepub fn shortest_vector(
&self,
r1: ArrayBase<ViewRepr<&f64>, Dim<[usize; 1]>>,
r2: ArrayBase<ViewRepr<&f64>, Dim<[usize; 1]>>,
) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>
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)
Sourcepub 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]>>
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
Sourcepub fn shortest_vector_fast_arr(
&self,
a: ArrayBase<ViewRepr<&f64>, Dim<[usize; 1]>>,
b: ArrayBase<ViewRepr<&f64>, Dim<[usize; 1]>>,
) -> [f64; 3]
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.
Sourcepub fn shortest_vector_raw(&self, a: [f64; 3], b: [f64; 3]) -> [f64; 3]
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>.
Sourcepub fn calc_distance2(
&self,
a: ArrayBase<ViewRepr<&f64>, Dim<[usize; 1]>>,
b: ArrayBase<ViewRepr<&f64>, Dim<[usize; 1]>>,
) -> f64
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.
Sourcepub fn to_frac(
&self,
xyz: ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>,
) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>
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)
Sourcepub fn to_cart(
&self,
frac: ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>,
) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>
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)
Sourcepub fn isin(
&self,
xyz: ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>,
) -> ArrayBase<OwnedRepr<bool>, Dim<[usize; 1]>>
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.
Sourcepub 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,
)
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.
Sourcepub 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]>>
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)
Sourcepub fn wrap(
&self,
xyz: ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>,
) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>
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