.. _DeePMDCompFormat:

deepmd/npy format
=================

Aliases
-------

``deepmd/comp``, ``deepmd/npy``

Implementation: :class:`DeePMDCompFormat <dpdata.plugins.deepmd.DeePMDCompFormat>`

Overview
--------


DeePMD-kit NumPy dataset directory.

`DeePMD-kit <https://github.com/deepmodeling/deepmd-kit>`_ is a deep
learning package for training interatomic potentials. Commonly called
``deepmd/npy``, this layout keeps type metadata as raw files and splits
frame arrays among ``set.000``, ``set.001``, ... directories containing
``.npy`` files. It is the standard efficient on-disk format for DeePMD-kit
training data.
















Quick examples
--------------

The examples use the preferred alias ``deepmd/npy``; any alias listed above is equivalent.

.. code-block:: python

   import dpdata
   
   # Geometry-only data
   system = dpdata.System("input_file", fmt="deepmd/npy")
   
   # Data with energies and forces
   labeled_system = dpdata.LabeledSystem("input_file", fmt="deepmd/npy")
   
   # Multiple compositions or calculation directories
   systems = dpdata.MultiSystems.from_file("input_directory", fmt="deepmd/npy")
   
   # Write geometry-only data
   system.to("deepmd/npy", "output_path")
   
   # Write multiple systems
   systems.to("deepmd/npy", "output_path")

Conversions
-----------

.. _DeePMDCompFormat_from_system:

Convert from this format to System
``````````````````````````````````

.. py:function:: dpdata.System(file_name, type_map=None, fmt: Literal['deepmd/comp'] = None, **kwargs) -> dpdata.system.System
   :noindex:
.. py:function:: dpdata.System(file_name, type_map=None, fmt: Literal['deepmd/npy'] = None, **kwargs) -> dpdata.system.System
   :noindex:
.. py:function:: dpdata.System.from_deepmd_comp(file_name, type_map=None, **kwargs) -> dpdata.system.System
   :noindex:
.. py:function:: dpdata.System.from_deepmd_npy(file_name, type_map=None, **kwargs) -> dpdata.system.System
   :noindex:

   
Load an unlabeled DeePMD NumPy dataset.


:Parameters:

    **file_name** : str or os.PathLike
        DeePMD NumPy dataset directory.

    **type_map** : list[str], optional
        Element names or requested type ordering used while loading.

    **\*\*kwargs** : dict
        Additional format arguments accepted for API compatibility.



:Returns:

    System
        converted system















.. _DeePMDCompFormat_to_system:

Convert from System to this format
``````````````````````````````````

.. py:function:: dpdata.System.to(fmt: Literal['deepmd/comp'], file_name, set_size=5000, prec=<class 'numpy.float64'>, **kwargs)
   :noindex:
.. py:function:: dpdata.System.to(fmt: Literal['deepmd/npy'], file_name, set_size=5000, prec=<class 'numpy.float64'>, **kwargs)
   :noindex:
.. py:function:: dpdata.System.to_deepmd_comp(file_name, set_size=5000, prec=<class 'numpy.float64'>, **kwargs)
   :noindex:
.. py:function:: dpdata.System.to_deepmd_npy(file_name, set_size=5000, prec=<class 'numpy.float64'>, **kwargs)
   :noindex:

   
Dump the system in deepmd compressed format (numpy binary) to `folder`.

The frames are firstly split to sets, then dumped to seperated subfolders named as `folder/set.000`, `folder/set.001`, ....

Each set contains `set_size` frames.
The last set may have less frames than `set_size`.

:Parameters:

    **file_name** : str
        The output folder

    **set_size** : int
        The size of each set.

    **prec** : {numpy.float32, numpy.float64}
        The floating point precision of the compressed data

    **\*\*kwargs** : dict
        other parameters


















.. _DeePMDCompFormat_to_labeled_system:

Convert from LabeledSystem to this format
`````````````````````````````````````````

.. py:function:: dpdata.LabeledSystem.to(fmt: Literal['deepmd/comp'], file_name, set_size=5000, prec=<class 'numpy.float64'>, **kwargs)
   :noindex:
.. py:function:: dpdata.LabeledSystem.to(fmt: Literal['deepmd/npy'], file_name, set_size=5000, prec=<class 'numpy.float64'>, **kwargs)
   :noindex:
.. py:function:: dpdata.LabeledSystem.to_deepmd_comp(file_name, set_size=5000, prec=<class 'numpy.float64'>, **kwargs)
   :noindex:
.. py:function:: dpdata.LabeledSystem.to_deepmd_npy(file_name, set_size=5000, prec=<class 'numpy.float64'>, **kwargs)
   :noindex:

   
Dump the system in deepmd compressed format (numpy binary) to `folder`.

The frames are firstly split to sets, then dumped to seperated subfolders named as `folder/set.000`, `folder/set.001`, ....

Each set contains `set_size` frames.
The last set may have less frames than `set_size`.

:Parameters:

    **file_name** : str
        The output folder

    **set_size** : int
        The size of each set.

    **prec** : {numpy.float32, numpy.float64}
        The floating point precision of the compressed data

    **\*\*kwargs** : dict
        other parameters


















.. _DeePMDCompFormat_from_labeled_system:

Convert from this format to LabeledSystem
`````````````````````````````````````````

.. py:function:: dpdata.LabeledSystem(file_name, type_map=None, fmt: Literal['deepmd/comp'] = None, **kwargs) -> dpdata.system.LabeledSystem
   :noindex:
.. py:function:: dpdata.LabeledSystem(file_name, type_map=None, fmt: Literal['deepmd/npy'] = None, **kwargs) -> dpdata.system.LabeledSystem
   :noindex:
.. py:function:: dpdata.LabeledSystem.from_deepmd_comp(file_name, type_map=None, **kwargs) -> dpdata.system.LabeledSystem
   :noindex:
.. py:function:: dpdata.LabeledSystem.from_deepmd_npy(file_name, type_map=None, **kwargs) -> dpdata.system.LabeledSystem
   :noindex:

   
Load a labeled DeePMD NumPy dataset.


:Parameters:

    **file_name** : str or os.PathLike
        DeePMD NumPy dataset directory.

    **type_map** : list[str], optional
        Element names or requested type ordering used while loading.

    **\*\*kwargs** : dict
        Additional format arguments accepted for API compatibility.



:Returns:

    LabeledSystem
        converted system















.. _DeePMDCompFormat_from_multi_systems:

Convert from this format to MultiSystems
````````````````````````````````````````

.. py:function:: dpdata.MultiSystems.from_deepmd_comp(directory, **kwargs) -> dpdata.system.MultiSystems
   :noindex:
.. py:function:: dpdata.MultiSystems.from_deepmd_npy(directory, **kwargs) -> dpdata.system.MultiSystems
   :noindex:

   
Convert this format to :class:`MultiSystems`.


:Parameters:

    **directory** : str
        directory of systems



:Returns:

    MultiSystems
        converted system















.. _DeePMDCompFormat_to_multi_systems:

Convert from MultiSystems to this format
````````````````````````````````````````

.. py:function:: dpdata.MultiSystems.to(fmt: Literal['deepmd/comp'], directory, **kwargs) -> dpdata.system.MultiSystems
   :noindex:
.. py:function:: dpdata.MultiSystems.to(fmt: Literal['deepmd/npy'], directory, **kwargs) -> dpdata.system.MultiSystems
   :noindex:
.. py:function:: dpdata.MultiSystems.to_deepmd_comp(directory, **kwargs) -> dpdata.system.MultiSystems
   :noindex:
.. py:function:: dpdata.MultiSystems.to_deepmd_npy(directory, **kwargs) -> dpdata.system.MultiSystems
   :noindex:

   
Convert :class:`MultiSystems` to this format.


:Parameters:

    **directory** : str
        directory to save systems



:Returns:

    MultiSystems
        this system













