High Performance Interface for H5MD Trajectories
Project description
ZnH5MD - High Performance Interface for H5MD Trajectories
ZnH5MD allows easy access to simulation results from H5MD trajectories.
Example
In the following example we investigate an H5MD dump from LAMMPS with 1000 atoms and 201 configurations:
import znh5md
traj = znh5md.DaskH5MD("file.h5", time_chunk_size=500, species_chunk_size=100)
print(traj.file.time_dependent_groups)
# ['box', 'force', 'image', 'position', 'species', 'velocity']
print(traj.force)
# DaskDataSet(value=dask.array<array, shape=(201, 1000, 3), ...)
print(traj.velocity.slice_by_species(species=1))
# DaskDataSet(value=dask.array<reshape, shape=(201, 500, 3), ...)
print(traj.position.value)
# dask.array<array, shape=(201, 1000, 3), dtype=float64, chunksize=(100, 500, 3), ...>
# You can iterate through the data
for item in traj.position.batch(size=27, axis=0):
for x in item.batch(size=17, axis=1):
print(x.value.compute())
ASE Atoms
You can use ZnH5MD to store ASE Atoms objects in the H5MD format.
ZnH5MD does not support all features of ASE Atoms objects. It s important to note that unsupported parts are silently ignored and no error is raised.
The ASEH5MD interface will not provide any time and step information.
import znh5md
import ase
atoms: list[ase.Atoms]
db = znh5md.io.DataWriter(filename="db.h5")
db.initialize_database_groups()
db.add(znh5md.io.AtomsReader(atoms))
data = znh5md.ASEH5MD("db.h5")
data.get_atoms_list() == atoms
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
znh5md-0.1.1.tar.gz
(12.1 kB
view hashes)
Built Distribution
znh5md-0.1.1-py3-none-any.whl
(13.1 kB
view hashes)