Skip to main content

Crate minimage

Crate minimage 

Source
Expand description

Minimum-image convention for a periodic parallelepiped.

Cell holds the 3x3 lattice H and a dump-cell origin. Constructors accept a LAMMPS bound box plus tilts, a CON lattice or length-angle box, an ASE-style 3x3 cell, and a vesin box. Distances are the fractional wrap ds = wrap(Hinv (q - p)), then dr = H ds. That is the LAMMPS lamda / eOn / HOOMD engine convention. Orthorhombic boxes use d - L floor(d/L + 1/2) on every image. A restricted triclinic box uses the triangular lamda step. Cell::reduce_tilts is GROMACS correct_box; Cell::to_restricted is the LAMMPS general-to-restricted rotation. Cell::displacement_euclidean is Smith’s half-altitude test, then Babai’s rounding and the Sommer–Feder–Shalvi slicer on the Selling superbasis cached on the calling thread. Lagrange size reduction runs before that Delone step. dist2_many, dist2_pairs, wrap_many, and dist2_ortho_diffs batch the engine wrap. The orthorhombic SoA kernel is AVX when the CPU has it. Cell::fixed stores a position as 64-bit fixed-point fractions, and the wrap between two of them is exact integer arithmetic (Cell::dist2_fixed, dist2_many_fixed, dist2_pairs_fixed). Cell::dist2_shifted_indexed gathers a linked-cell bin’s index list into that shifted kernel. reduce_pairs turns a vesin image pair list into one minimum-image pair and drops the self image.

It is a LODE library. The Rust crate is the implementation. The C ABI (mi_*) is the hourglass waist, the same shape as linkcell and readcon-core. C++ is a RAII header over that ABI.

use minimage::Cell;

let sim = Cell::ortho(10.0, 10.0, 10.0)?;
let left = [0.2, 0.0, 0.0];
let right = [9.4, 0.0, 0.0];
assert!((sim.dist2(left, right) - 0.64).abs() < 1e-12);

Structs§

Cell
Periodic parallelepiped: columns of H, origin, and an ortho flag.
mi_cell
Periodic parallelepiped. Lattice vectors are a, b, c (same as vesin rows).

Enums§

Error
Why a cell or a distance call could not run.

Functions§

dist2_euclidean_many
Cell::dist2_euclidean from p to each row of qs, bit for bit. The superbasis is looked up once per call rather than once per pair.
dist2_euclidean_pairs
Cell::dist2_euclidean for paired rows, bit for bit, with one superbasis lookup per call.
dist2_euclidean_pairs_warm
Euclidean nearest-image squared distances for pairs that persist across frames.
dist2_many
Squared MIC distances from p to each packed candidate in qs.
dist2_many_fixed
Squared engine-wrap distances from fixed-point p to each fixed-point qs (Cell::fixed). Integer wrap, one product with H.
dist2_many_fixed32
Cell::dist2_fixed32 from p to each row of qs, bit for bit: sixteen rows per AVX-512 pass, eight per AVX2 pass.
dist2_ortho_diffs
Orthorhombic wrap of precomputed differences, one reciprocal per axis.
dist2_pairs
Squared MIC distances for packed pair lists ps and qs.
dist2_pairs_fixed
Squared engine-wrap distances for fixed-point pair lists.
dist2_pairs_fixed32
Cell::dist2_fixed32 for paired rows, bit for bit.
dump_bounds_to_h
Recover restricted-triclinic H (columns a, b, c) and origin from a LAMMPS dump bound box.
fixed32_many
Cell::fixed32 for packed positions.
fixed_many
Cell::fixed for packed positions: one AVX2 pass folds, floors, and takes the mantissa of t + 1 for four rows at once.
is_minkowski_reduced
True when the three columns of H satisfy the 3D Minkowski inequalities (Jaber; Nguyen–Stehlé).
mi_cell_from_ase⚠
Fill out from an ASE-style row-major 3x3 cell. origin may be NULL (then zero).
mi_cell_from_con⚠
Fill out from a CON 3x3 lattice (rows a, b, c).
mi_cell_from_con_box⚠
Fill out from CON lengths and angles in degrees.
mi_cell_from_lammps
Fill out from LAMMPS xlo xhi ylo yhi zlo zhi and tilts.
mi_cell_from_lammps_bounds
Fill out from dump bound spans, tilts, and bound lo.
mi_cell_from_vectors⚠
Fill out from lattice vectors a, b, c and an origin.
mi_cell_from_vesin⚠
Fill out from a vesin 3x3 box (rows a, b, c).
mi_displacement⚠
Minimum-image displacement from p to q into dr.
mi_displacement_euclidean⚠
Euclidean MIC: Smith half-altitude test, else the slicer on the Selling superbasis, into dr.
mi_dist2⚠
Squared minimum-image distance from p to q.
mi_dist2_euclidean_many⚠
Euclidean nearest-image squared distances from p to n packed candidates: mi_displacement_euclidean per pair, bit for bit, with one superbasis lookup per call and eight pairs per slicer pass.
mi_dist2_euclidean_pairs⚠
mi_dist2_euclidean_many for paired rows.
mi_dist2_euclidean_pairs_warm⚠
mi_dist2_euclidean_pairs for pairs that persist across frames. images is n rows of three int32_t: the cell-basis lattice shift of each pair’s image from the previous call, zeros to start, updated in place. A pair whose stored image still lies in the Voronoi cell skips the search; its distance equals the full search to rounding.
mi_dist2_fixed⚠
Squared engine-wrap distance between two fixed-point positions.
mi_dist2_fixed32⚠
Squared engine-wrap distance between two 32-bit fixed-point positions.
mi_dist2_many⚠
Squared MIC distances from p to n packed candidates in qs.
mi_dist2_many_fixed⚠
Squared engine-wrap distances from fixed-point p to n packed fixed-point candidates.
mi_dist2_many_fixed32⚠
Squared engine-wrap distances from 32-bit fixed-point p to n packed fixed-point candidates.
mi_dist2_ortho_diffs⚠
Orthorhombic wrap of precomputed differences (Highway kernel).
mi_dist2_pairs⚠
Squared MIC distances for n packed pairs (ps[k], qs[k]).
mi_dist2_pairs_fixed⚠
Squared engine-wrap distances for n packed fixed-point pairs.
mi_dist2_pairs_fixed32⚠
Squared engine-wrap distances for n packed 32-bit fixed-point pairs.
mi_dist2_shifted_many⚠
Squared distances from p to n points in qs, plus one lattice shift (sx, sy, sz) on every candidate. Rapaport’s bin pair.
mi_fixed32_many⚠
32-bit fixed-point fractional coordinates of n packed positions: three uint32_t per position, each the 64-bit fraction of mi_fixed_many rounded to its top 32 bits.
mi_fixed_many⚠
Fixed-point fractional coordinates of n packed positions: three uint64_t per position, each fraction as round(s * 2^52) * 2^12.
mi_last_error
Thread-local last-error string from this thread’s most recent mi_* failure.
mi_reduce_pairs⚠
Drop self images and collapse duplicate (i, j) rows.
mi_version
Library version string. Process-static, NUL-terminated. Do not free.
mi_wrap_many⚠
Engine wrap of n packed difference vectors into out.
minkowski_reduce
Unimodular Minkowski reduction. Same Cartesian lattice, new basis with |a| <= |b| <= |c|.
reduce_pairs
Drop self images and collapse duplicate (i, j) rows.
reduce_pairs_packed
Same reduction over a packed n * 2 C buffer.
wrap_many
Minimum-image wrap of packed difference vectors.