deepmd/hdf5/mixed format#
Aliases#
deepmd/hdf5/mixed
Implementation: DeePMDHDF5MixedFormat
Overview#
Mixed type HDF5 format for DeePMD-kit.
DeePMD-kit is a deep learning package for training interatomic potentials.
Mixed type data stores frames with the same atom count in one dataset even when their formulas differ. The placeholder type.raw contains only the mixed token type, while set.*/real_atom_types.npy stores the real atom type layout for each frame. Loading reconstructs regular Systems by splitting frames with different real_atom_types rows.
The HDF5 layout mirrors deepmd/npy/mixed inside HDF5 groups. For dpdata.MultiSystems, each top-level mixed group is keyed by the number of atoms after optional padding, such as "4" or "8". A string path may include "#group/path" to read or write mixed data under a nested HDF5 group.
Examples
Dump a dpdata.MultiSystems object to a mixed HDF5 file:
>>> systems.to_deepmd_hdf5_mixed("mixed.hdf5")
Dump with atom-count padding:
>>> systems.to_deepmd_hdf5_mixed("mixed.hdf5", atom_numb_pad=8)
Load a mixed HDF5 file into dpdata.MultiSystems:
>>> dpdata.MultiSystems().from_deepmd_hdf5_mixed("mixed.hdf5")
Quick examples#
The examples use the preferred alias deepmd/hdf5/mixed; any alias listed above is equivalent.
import dpdata
# Multiple compositions or calculation directories
systems = dpdata.MultiSystems.from_file("input_directory", fmt="deepmd/hdf5/mixed")
# Load or construct the system to write
system = dpdata.System("input_file")
# Write geometry-only data
system.to("deepmd/hdf5/mixed", "output_path")
# Write multiple systems
systems.to("deepmd/hdf5/mixed", "output_path")
Conversions#
Convert from System to this format#
- dpdata.System.to(fmt: Literal['deepmd/hdf5/mixed'], file_name, set_size: 'int' = 2000, prec=<class 'numpy.float64'>, comp_prec=None, **kwargs)
- dpdata.System.to_deepmd_hdf5_mixed(file_name, set_size: 'int' = 2000, prec=<class 'numpy.float64'>, comp_prec=None, **kwargs)
Dump a System data dict in mixed HDF5 format.
- Parameters:
- file_namestr or h5py.Group or h5py.File
HDF5 file, HDF5 group, or string in
"file.hdf5#group"form. Strings open the target file in write mode. HDF5 objects are written in place.- set_sizeint, default=2000
Maximum number of frames per
set.*group.- precnumpy.dtype, default=numpy.float64
Floating point precision for dumped frame data. Kept for consistency with
deepmd/npy/mixed.- comp_precnumpy.dtype, optional
Explicit floating point precision. When provided, this overrides
prec.- **kwargsdict
Additional keyword arguments accepted for format API compatibility.
- Raises:
- TypeError
If
file_nameis not a string, HDF5 group, or HDF5 file.
Convert from LabeledSystem to this format#
- dpdata.LabeledSystem.to(fmt: Literal['deepmd/hdf5/mixed'], file_name, set_size: 'int' = 2000, prec=<class 'numpy.float64'>, comp_prec=None, **kwargs)
- dpdata.LabeledSystem.to_deepmd_hdf5_mixed(file_name, set_size: 'int' = 2000, prec=<class 'numpy.float64'>, comp_prec=None, **kwargs)
Dump a System data dict in mixed HDF5 format.
- Parameters:
- file_namestr or h5py.Group or h5py.File
HDF5 file, HDF5 group, or string in
"file.hdf5#group"form. Strings open the target file in write mode. HDF5 objects are written in place.- set_sizeint, default=2000
Maximum number of frames per
set.*group.- precnumpy.dtype, default=numpy.float64
Floating point precision for dumped frame data. Kept for consistency with
deepmd/npy/mixed.- comp_precnumpy.dtype, optional
Explicit floating point precision. When provided, this overrides
prec.- **kwargsdict
Additional keyword arguments accepted for format API compatibility.
- Raises:
- TypeError
If
file_nameis not a string, HDF5 group, or HDF5 file.
Convert from this format to MultiSystems#
- dpdata.MultiSystems.from_deepmd_hdf5_mixed(directory, **kwargs) dpdata.system.MultiSystems
Generate mixed HDF5 groups for MultiSystems loading.
- Parameters:
- directorystr or h5py.Group or h5py.File
HDF5 file, HDF5 group, or string in
"file.hdf5#group"form. The selected object may be either one mixed system group or a container of mixed groups.- **kwargsdict
Additional keyword arguments accepted for format API compatibility.
- Returns:
- MultiSystems
converted system
- Raises:
- TypeError
If
directoryis not a string, HDF5 group, or HDF5 file.
Convert from MultiSystems to this format#
- dpdata.MultiSystems.to(fmt: Literal['deepmd/hdf5/mixed'], directory, **kwargs) dpdata.system.MultiSystems
- dpdata.MultiSystems.to_deepmd_hdf5_mixed(directory, **kwargs) dpdata.system.MultiSystems
Generate HDF5 groups for MultiSystems mixed dumping.
- Parameters:
- directorystr or h5py.Group or h5py.File
HDF5 file, HDF5 group, or string in
"file.hdf5#group"form. Strings open the target file in write mode.- **kwargsdict
Additional keyword arguments accepted for format API compatibility.
- Returns:
- MultiSystems
this system
- Raises:
- TypeError
If
directoryis not a string, HDF5 group, or HDF5 file.