Atom-level analysis toolkit for molecular dynamics trajectories
Project description
atomkit
Atom-level analysis toolkit for molecular dynamics trajectories.
Install
pip install atomkit
# or
uv pip install atomkit
Features
SpatialGrid
4D CSR-indexed spatial grid (space + time) for fast region queries on LAMMPS trajectories. Stores as HDF5 with zstd compression and lazy loading (mmap).
CLI:
# Convert LAMMPS trajectory to HDF5 (all timesteps)
atomkit convert simulation.lammpstrj output.h5
# Options
atomkit convert simulation.lammpstrj -c 4.0 # cell size 4Å
atomkit convert simulation.lammpstrj -t 0:100 # timesteps 0-99
atomkit convert simulation.lammpstrj -t 0:1000:10 # every 10th timestep
atomkit convert simulation.lammpstrj -t 0,50,100 # specific timesteps
# Inspect file
atomkit info output.h5
Python:
from atomkit import SpatialGrid, Region
# Create from LAMMPS file (loads all timesteps by default)
grid = SpatialGrid.from_lammps('simulation.lammpstrj', cell_size=4.0)
grid.save('data.h5')
# Query with 4D regions (returns read-only numpy arrays)
with SpatialGrid.load('data.h5') as grid:
# Region bounds: (min, max) tuple, single value, or omit for unbounded
# Single timestep (t=100 means timestep VALUE 100)
data = grid.query(Region(t=100))
# Spatial box, all timesteps
data = grid.query(Region(x=(0, 50), y=(0, 50), z=(0, 50)))
# Full 4D query
data = grid.query(Region(x=(0, 50), y=(0, 50), z=(0, 50), t=(0, 1000)))
# Slice at a point (all cells containing x=25)
data = grid.query(Region(x=25.0, t=100))
# Everything
data = grid.query() # or Region()
# Access fields
data['coords'] # (N, 3) atom positions
data['stress'] # (N,) stress values
data['_timestep'] # (N,) which timestep each atom belongs to
data['_source_idx'] # (N,) original file indices
# Per-timestep analysis
for t in np.unique(data['_timestep']):
mask = data['_timestep'] == t
print(f"t={t}: mean stress = {data['stress'][mask].mean()}")
# Fast approximate count (no field reads)
n_approx = grid.count(Region(x=(0, 50), y=(0, 50), z=(0, 50)))
# Exact vs cell-level query
data = grid.query(region) # default, exact bounds
data = grid.query(region, cell_level=True) # faster, includes full boundary cells
# Add fields later
grid.add_field('velocity', vel_array)
Region
4D axis-aligned bounding box for space-time queries:
from atomkit import Region
# Flexible bounds specification:
Region(x=(0, 10), y=(0, 10), z=(0, 10)) # Spatial box, all timesteps
Region(t=100) # Single timestep, all space
Region(x=5.0) # YZ plane at x=5 (slice query)
Region() # Everything (unbounded)
# Region operations
region = Region(x=(0, 100), y=(0, 100), z=(0, 100), t=(0, 1000))
region.volume() # Spatial volume
region.subdivide(nx=10, ny=10, nz=10) # Split into sub-regions
region.with_time(500) # Same space, different time
region.expand(padding=5.0) # Grow bounds
Grid dimensions:
grid.n_timesteps- number of timestepsgrid.n_atoms- atoms per timestepgrid.grid_shape- (nx, ny, nz) spatial cellsgrid.timestep_values- actual timestep values from trajectory
Future Extensions
Marching Cubes / Void Visualization
For visualizing empty space (cracks, voids, delamination) and computing volumes:
# Potential future API
verts, faces = grid.void_mesh(Region(t=100), threshold=0.5)
volume = grid.void_volume(Region(t=100), threshold=0.5)
Grid Alignment
For snapping user-selected regions to grid cell boundaries:
# Potential future API
aligned = AlignedRegion.snap(region, grid, mode='enclosing')
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file atomkit-0.1.1.tar.gz.
File metadata
- Download URL: atomkit-0.1.1.tar.gz
- Upload date:
- Size: 41.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae50c94cdf499522852fbe3b0c716acb611eeaba75f9636e8570f134070839a5
|
|
| MD5 |
236a2c369471b2b4dbb2f47d4df1ff58
|
|
| BLAKE2b-256 |
b22e8ca26c6ee86a774901e9afca47c38fc4ad8ed34d2b89565a1009241294c1
|
File details
Details for the file atomkit-0.1.1-py3-none-any.whl.
File metadata
- Download URL: atomkit-0.1.1-py3-none-any.whl
- Upload date:
- Size: 30.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43625d19dd39c277db04362eec292239d9c0324b7fe04b464605ef3e88c7a243
|
|
| MD5 |
8a0906f4962d14d57246cbb56c5855a5
|
|
| BLAKE2b-256 |
eb4987df53988580ba88536896c066e579f14123751b4847786892dd461413fa
|