.. _DeePMDMixedFormat:

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

Aliases
-------

``deepmd/npy/mixed``

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

Overview
--------


Mixed-type NumPy dataset for DeePMD-kit.

`DeePMD-kit <https://github.com/deepmodeling/deepmd-kit>`_ is a deep
learning package for training interatomic potentials. Unlike regular
``deepmd/npy``, this layout can combine frames that have the same atom
count but different formulas. Per-frame real atom types keep each
composition recoverable for models that use type embeddings. Optional
atom-count padding can reduce the number of output groups when a
:class:`dpdata.MultiSystems` contains many system sizes.














.. rubric:: Examples

Dump a MultiSystems into a mixed type numpy directory:

>>> import dpdata
>>> dpdata.MultiSystems(*systems).to_deepmd_npy_mixed("mixed_dir")

Dump with ``atom_numb_pad`` to reduce the number of subdirectories.
Systems are padded with virtual atoms (type -1) so that atom counts are
rounded up to the nearest multiple of the given number:

>>> dpdata.MultiSystems(*systems).to_deepmd_npy_mixed("mixed_dir", atom_numb_pad=8)

Load a mixed type data into a MultiSystems:

>>> import dpdata
>>> dpdata.MultiSystems().load_systems_from_file("mixed_dir", fmt="deepmd/npy/mixed")


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

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

.. code-block:: python

   import dpdata
   
   # Multiple compositions or calculation directories
   systems = dpdata.MultiSystems.from_file("input_directory", fmt="deepmd/npy/mixed")
   
   # Load or construct the system to write
   system = dpdata.System("input_file")
   
   # Write geometry-only data
   system.to("deepmd/npy/mixed", "output_path")
   
   # Write multiple systems
   systems.to("deepmd/npy/mixed", "output_path")

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

.. _DeePMDMixedFormat_to_system:

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

.. py:function:: dpdata.System.to(fmt: Literal['deepmd/npy/mixed'], file_name, set_size: 'int' = 2000, prec=<class 'numpy.float64'>, **kwargs)
   :noindex:
.. py:function:: dpdata.System.to_deepmd_npy_mixed(file_name, set_size: 'int' = 2000, prec=<class 'numpy.float64'>, **kwargs)
   :noindex:

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

The frames were already split to different systems, so these frames can be dumped to one single subfolders
    named as `folder/set.000`, containing less than `set_size` frames.

:Parameters:

    **file_name** : str
        The output folder

    **set_size** : int, default=2000
        set size

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

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


















.. _DeePMDMixedFormat_to_labeled_system:

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

.. py:function:: dpdata.LabeledSystem.to(fmt: Literal['deepmd/npy/mixed'], file_name, set_size: 'int' = 2000, prec=<class 'numpy.float64'>, **kwargs)
   :noindex:
.. py:function:: dpdata.LabeledSystem.to_deepmd_npy_mixed(file_name, set_size: 'int' = 2000, prec=<class 'numpy.float64'>, **kwargs)
   :noindex:

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

The frames were already split to different systems, so these frames can be dumped to one single subfolders
    named as `folder/set.000`, containing less than `set_size` frames.

:Parameters:

    **file_name** : str
        The output folder

    **set_size** : int, default=2000
        set size

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

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


















.. _DeePMDMixedFormat_from_multi_systems:

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

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

   
Find mixed-type DeePMD NumPy systems below a directory.


:Parameters:

    **directory** : str or os.PathLike
        Root directory containing one or more mixed datasets.

    **\*\*kwargs** : dict
        Additional format arguments forwarded when each dataset is read.



:Returns:

    MultiSystems
        converted system















.. _DeePMDMixedFormat_to_multi_systems:

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

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

   
Convert :class:`MultiSystems` to this format.


:Parameters:

    **directory** : str
        directory to save systems



:Returns:

    MultiSystems
        this system













