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: F3x3, origin: F3, pbc: Pbc3) -> Result<Self, BoxError>
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
Sourcepub fn new_cell(
h: F3x3,
origin: F3,
pbc: Pbc3,
cell_defined: bool,
) -> Result<Self, BoxError>
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.
Sourcepub fn is_cell_defined(&self) -> bool
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).
pub fn try_new(h: F3x3, origin: F3, pbc: Pbc3) -> Result<Self, BoxError>
Sourcepub fn cube(a: F, origin: F3, pbc: Pbc3) -> Result<Self, BoxError>
pub fn cube(a: F, origin: F3, pbc: Pbc3) -> Result<Self, BoxError>
Factory: cubic box with edge length a and origin O
Sourcepub fn ortho(lengths: F3, origin: F3, pbc: Pbc3) -> Result<Self, BoxError>
pub fn ortho(lengths: F3, origin: F3, pbc: Pbc3) -> Result<Self, BoxError>
Factory: ortho box with lengths (ax, ay, az) and origin O
Sourcepub fn free(points: FNx3View<'_>, padding: F) -> Result<Self, BoxError>
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.
Sourcepub fn origin_view(&self) -> F3View<'_>
pub fn origin_view(&self) -> F3View<'_>
View of the origin
Sourcepub fn pbc_view(&self) -> ArrayView1<'_, bool>
pub fn pbc_view(&self) -> ArrayView1<'_, bool>
View of the PBC flags
Sourcepub fn style(&self) -> &'static str
pub fn style(&self) -> &'static str
Geometry style label: "free" (no periodic axis), "orthogonal"
(diagonal H), or "triclinic".
Sourcepub fn nearest_plane_distance(&self) -> F3
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
pub fn kind(&self) -> &BoxKind
Sourcepub fn make_fractional(&self, r: F3View<'_>) -> F3
pub fn make_fractional(&self, r: F3View<'_>) -> F3
Convert Cartesian coordinates to fractional coordinates [0, 1)
Sourcepub fn make_fractional_fast(&self, r: F3View<'_>) -> F3
pub fn make_fractional_fast(&self, r: F3View<'_>) -> F3
Fractional coordinates with ortho fast-path
Sourcepub fn make_fractional_fast_arr(&self, r: F3View<'_>) -> [F; 3]
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.).
Sourcepub fn make_cartesian(&self, frac: F3View<'_>) -> F3
pub fn make_cartesian(&self, frac: F3View<'_>) -> F3
Convert fractional coordinates to Cartesian coordinates
Sourcepub fn shortest_vector(&self, r1: F3View<'_>, r2: F3View<'_>) -> F3
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).
Sourcepub fn shortest_vector_impl(&self, a: [F; 3], b: [F; 3]) -> [F; 3]
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.
Sourcepub fn calc_distance2(&self, a: F3View<'_>, b: F3View<'_>) -> F
pub fn calc_distance2(&self, a: F3View<'_>, b: F3View<'_>) -> F
Calculate squared distance using MIC.
Sourcepub fn to_frac(&self, xyz: FNx3View<'_>) -> FNx3
pub fn to_frac(&self, xyz: FNx3View<'_>) -> FNx3
Convert Cartesian points to fractional coordinates (N×3)
Sourcepub fn to_cart(&self, frac: FNx3View<'_>) -> FNx3
pub fn to_cart(&self, frac: FNx3View<'_>) -> FNx3
Convert fractional coordinates to Cartesian points (N×3)
Sourcepub fn isin(&self, xyz: FNx3View<'_>) -> Array1<bool>
pub fn isin(&self, xyz: FNx3View<'_>) -> Array1<bool>
Check if points lie within [0,1) in fractional space.
Sourcepub fn delta_out(
&self,
xyzu1: FNx3View<'_>,
xyzu2: FNx3View<'_>,
out: &mut FNx3,
minimum_image: bool,
)
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.
Sourcepub fn delta(
&self,
xyzu1: FNx3View<'_>,
xyzu2: FNx3View<'_>,
minimum_image: bool,
) -> FNx3
pub fn delta( &self, xyzu1: FNx3View<'_>, xyzu2: FNx3View<'_>, minimum_image: bool, ) -> FNx3
Batched displacement vectors row-wise (N×3)
Sourcepub fn wrap(&self, xyz: FNx3View<'_>) -> FNx3
pub fn wrap(&self, xyz: FNx3View<'_>) -> FNx3
Wrap Cartesian points into the unit cell according to PBC
pub fn get_corners(&self) -> FNx3
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SimBox
impl RefUnwindSafe for SimBox
impl Send for SimBox
impl Sync for SimBox
impl Unpin for SimBox
impl UnsafeUnpin for SimBox
impl UnwindSafe for SimBox
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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