minimage
Minimum-image convention for a periodic parallelepiped.
linkcell walks k-nearest neighbours. vesin builds cutoff pair lists.
Both need the same wrap: fold through H, pick one image, never the
self image. This crate is that wrap. Cell holds the 3x3 lattice and
a dump-cell origin. Constructors accept LAMMPS bounds plus xy, xz, yz tilts, a CON lattice or length-angle box, an ASE-style 3x3 cell,
and a vesin box. PartialCell handles slabs, wires, and open systems
where only some axes are periodic.
It is a LODE library. The Rust crate is the implementation. The C ABI
(minimage_*) is the hourglass waist, the same shape as
linkcell and
readcon-core. C++ is a
header-only wrapper over that ABI.
Docs (orgmode first, HTML export): lode-org.github.io/minimage. Org catalog: lode-org.github.io. Rust API docs: docs.rs/minimage.
Install
Rust:
cargo add minimage
C and C++ consumers take the staticlib (--features capi, on by
default) plus include/minimage.h or include/minimage.hpp. Meson,
CMake, and pkg-config all install that archive, the shared library, and
those headers.
The function prefix spells out the crate name (minimage_*) so it
cannot collide with mimalloc's mi_* ABI. The non-default
capi-compat-names feature adds deprecated thin aliases for the old
mi_* function names while consumers migrate; those aliases can still
collide with mimalloc.
pip install minimage
Python 3.10 or newer. Each release has one abi3 wheel per platform, for Linux x86_64 and aarch64 (manylinux_2_28), macOS arm64 and Windows x86_64, which covers every CPython from 3.10 on. Elsewhere pip builds the sdist, which needs a Rust toolchain.
import minimage
cell = minimage.Cell.ortho(10.0, 10.0, 10.0)
assert abs(cell.dist2([0.2, 0.0, 0.0], [9.4, 0.0, 0.0]) - 0.64) < 1e-12
Meson
meson setup build
meson compile -C build
meson install -C build
As a wrap, Meson exposes minimage_dep:
[wrap-git]
url = https://github.com/lode-org/minimage.git
revision = v0.2.3
depth = 1
[provide]
minimage = minimage_dep
minimage_dep = dependency('minimage', fallback: ['minimage', 'minimage_dep'])
CMake
cmake -B build -DCMAKE_INSTALL_PREFIX=$PREFIX
cmake --build build
cmake --install build
find_package(minimage 0.2 REQUIRED)
target_link_libraries(app PRIVATE minimage::minimage)
pkg-config
pkg-config --cflags --libs minimage
Rust
use minimage::{dist2_many, reduce_pairs, Cell, Error, PartialCell};
fn main() -> Result<(), Error> {
let sim = Cell::ortho(10.0, 10.0, 10.0)?;
let sheared = Cell::from_lammps_bounds(
15.0, 8.660254037844386, 10.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.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);
// Hex-prism body diagonal: Euclidean MIC finds a shorter image than the engine wrap.
let q_diag = sheared.cartesian([0.49, 0.49, 0.49]);
let euc = sheared.displacement_euclidean([0.0; 3], q_diag);
assert!(euc.iter().map(|x| x * x).sum::<f64>() < sheared.dist2([0.0; 3], q_diag));
let qs = [[9.4, 0.0, 0.0], [1.0, 0.0, 0.0]];
let mut out = [0.0; 2];
dist2_many(&sim, left, &qs, &mut out)?;
let slab = PartialCell::from_ase(
[[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 0.0]],
[true, true, false],
)?;
assert!((slab.displacement_euclidean([0.5, 0.5, 0.0], [9.5, 0.5, 20.0])[2] - 20.0).abs() < 1e-12);
let pairs = [[0, 1], [0, 0], [0, 1]];
let mut kept = Vec::new();
reduce_pairs(&pairs, &mut kept)?;
assert_eq!(kept, vec![[0, 1]]);
Ok(())
}
C ABI (minimage_*)
All exported C ABI functions use the minimage_ prefix, including
minimage_cell_from_lammps_bounds, minimage_displacement,
minimage_displacement_euclidean, minimage_dist2, minimage_dist2_many,
minimage_dist2_pairs, minimage_wrap_many, minimage_pbc_cell_from_ase,
minimage_displacement_euclidean_pbc, minimage_filter_shifted,
minimage_ring_centroid, and minimage_reduce_pairs.
#include "minimage.h"
#include <stdio.h>
mi_cell cell;
if (minimage_cell_from_lammps_bounds(
15.0, 8.660254037844386, 10.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, &cell) != 0) {
fprintf(stderr, "%s\n", minimage_last_error());
}
const double p[3] = {0.0, 0.0, 0.0};
const double q[3] = {
0.49 * (cell.ax + cell.bx + cell.cx),
0.49 * (cell.ay + cell.by + cell.cy),
0.49 * (cell.az + cell.bz + cell.cz),
};
double dr[3] = {0.0};
if (minimage_displacement_euclidean(&cell, p, q, dr) != 0) {
fprintf(stderr, "%s\n", minimage_last_error());
}
Conventions and error behaviour
- Units and storage: coordinates, lattice vectors, and origins share
one caller-chosen length unit; squared distances and cutoffs use that
unit squared;
from_con_box/minimage_cell_from_con_boxtake angles in degrees.Cell::from_vectorsandCell::hstorea, b, cas the columns ofH(r = H s + origin), whilefrom_ase,from_con,from_vesin, andPartialCell::from_asetake row-major[a, b, c]. - Displacements and triclinic cells:
displacement(p, q)returnswrap(q - p). Orthorhombic boxes wrap each axis into[-L/2, L/2), keeping-L/2and mapping+L/2to-L/2. Restricted triclinic boxes (aalong x,bin the xy plane) use the upper-triangularlamdawrap matching LAMMPS, HOOMD, OpenMM, and GROMACS;reduce_tiltsapplies GROMACScorrect_box,to_restrictedrotates general cells into that frame, anddisplacement_euclidean(minimage_displacement_euclidean) checks Smith's half-altitude bound and falls back to the Selling superbasis slicer for exact Voronoi nearest images. - Errors: Rust returns
Result<_, Error>(BadBox,BufferSize,Empty). C ABI functions return0on success and1on failure and record a thread-local message inminimage_last_error()(cleared on the next success on that thread;minimage_version()leaves it untouched). C++ throwsminimage::Error, and Python raisesValueError,TypeError, orBufferError.
Batch kernels select AVX-512, AVX2, AVX, NEON, or scalar at run time.
MINIMAGE_SIMD overrides that choice. simd_path() returns the name.
License
MIT. See LICENSE.
Metadata
Release files for minimage 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| minimage-0.2.3.tar.gz | 197.6 kB | With provenance | Details for minimage-0.2.3.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| minimage-0.2.3-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details for minimage-0.2.3-cp310-abi3-win_amd64.whl |
| minimage-0.2.3-cp310-abi3-manylinux_2_28_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.28+ x86-64 | Details for minimage-0.2.3-cp310-abi3-manylinux_2_28_x86_64.whl |
| minimage-0.2.3-cp310-abi3-manylinux_2_28_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.28+ ARM64 | Details for minimage-0.2.3-cp310-abi3-manylinux_2_28_aarch64.whl |
| minimage-0.2.3-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details for minimage-0.2.3-cp310-abi3-macosx_11_0_arm64.whl |
Total release size: 1.6 MB
Release files / minimage-0.2.3.tar.gz
| Download URL | minimage-0.2.3.tar.gz |
|---|---|
| Size | 197.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9f908e0fa00231a81976630018a349cfd203de4f4657af355e4acce55baf24cf
|
|
BLAKE2b-256 checksum How to use checksums |
4b67cd77bd7b0933782049917757ab506bb35ad610c41e66bac7f1561fa6f1a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.
Transparency logRelease files / minimage-0.2.3-cp310-abi3-win_amd64.whl
| Download URL | minimage-0.2.3-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 320.7 kB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
a36a8b9b7080b6e4bf17ec39a6b6703a5ff4cf6872e0d9f4b83dd1f3c4d984bf
|
|
BLAKE2b-256 checksum How to use checksums |
159a23892f7ae7caacbc6db2b6dee0f41e37c8b3329aaf51e046983323c600f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.
Transparency logRelease files / minimage-0.2.3-cp310-abi3-manylinux_2_28_x86_64.whl
| Download URL | minimage-0.2.3-cp310-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 410.2 kB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
41bf6226d937f3fef50059c7e6cb00f644880570f8752cf3247a613aaf443ec5
|
|
BLAKE2b-256 checksum How to use checksums |
3e43e72285f99ba9b206c3f018fa06e77d2939d4fd6aa9a0655ba70445b0bed6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.
Transparency logRelease files / minimage-0.2.3-cp310-abi3-manylinux_2_28_aarch64.whl
| Download URL | minimage-0.2.3-cp310-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 363.1 kB |
| Tags | CPython 3.10 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
0d2941ca70750c95818c640c38d0767c8d27ba16b80c7b06327bb51e1546e8bc
|
|
BLAKE2b-256 checksum How to use checksums |
ac1114f89630b36143a63d1d02697a8ddc253a8f1cdfeba2b2d8ebf68e82330a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.
Transparency logRelease files / minimage-0.2.3-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | minimage-0.2.3-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 340.5 kB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
47a39d384a39b7f0b7663b752e7bab783b1ebc3b98ab5322fb6f9e8866d3554b
|
|
BLAKE2b-256 checksum How to use checksums |
de053114da5fff1e42e71c9a51f2a84cf046aeef2cf548c4e99971161fdaf17d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.
Transparency logSecurity for minimage 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 5 files in this release have been uploaded with provenance metadata.
Attestation for minimage-0.2.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.