deepmd.pd.infer.deep_eval
=========================

.. py:module:: deepmd.pd.infer.deep_eval


Classes
-------

.. autoapisummary::

   deepmd.pd.infer.deep_eval.DeepEval


Module Contents
---------------

.. py:class:: DeepEval(model_file: str, output_def: deepmd.dpmodel.output_def.ModelOutputDef, *args: Any, auto_batch_size: Union[bool, int, deepmd.pd.utils.auto_batch_size.AutoBatchSize] = True, neighbor_list: Optional[ase.neighborlist.NewPrimitiveNeighborList] = None, head: Optional[Union[str, int]] = None, **kwargs: Any)

   Bases: :py:obj:`deepmd.infer.deep_eval.DeepEvalBackend`


   
   Paddle backend implementation of DeepEval.


   :Parameters:

       **model_file** : :obj:`Path`
           The name of the frozen model file.

       **output_def** : :obj:`ModelOutputDef`
           The output definition of the model.

       **\*args** : :class:`python:list`
           Positional arguments.

       **auto_batch_size** : :ref:`bool <python:bltin-boolean-values>` or :class:`python:int` or :obj:`AutomaticBatchSize`, default: :data:`python:False`
           If True, automatic batch size will be used. If int, it will be used
           as the initial batch size.

       **neighbor_list** : :obj:`ase.neighborlist.NewPrimitiveNeighborList`, :obj:`optional`
           The ASE neighbor list class to produce the neighbor list. If None, the
           neighbor list will be built natively in the model.

       **\*\*kwargs** : :class:`python:dict`
           Keyword arguments.














   ..
       !! processed by numpydoc !!

   .. py:attribute:: output_def


   .. py:attribute:: model_path


   .. py:attribute:: rcut


   .. py:attribute:: type_map


   .. py:attribute:: _has_spin


   .. py:method:: get_rcut() -> float

      
      Get the cutoff radius of this model.
















      ..
          !! processed by numpydoc !!


   .. py:method:: get_ntypes() -> int

      
      Get the number of atom types of this model.
















      ..
          !! processed by numpydoc !!


   .. py:method:: get_type_map() -> list[str]

      
      Get the type map (element name of the atom types) of this model.
















      ..
          !! processed by numpydoc !!


   .. py:method:: get_dim_fparam() -> int

      
      Get the number (dimension) of frame parameters of this DP.
















      ..
          !! processed by numpydoc !!


   .. py:method:: get_dim_aparam() -> int

      
      Get the number (dimension) of atomic parameters of this DP.
















      ..
          !! processed by numpydoc !!


   .. py:method:: get_intensive() -> bool


   .. py:property:: model_type
      :type: type[deepmd.infer.deep_eval.DeepEval]


      
      The the evaluator of the model type.
















      ..
          !! processed by numpydoc !!


   .. py:method:: get_sel_type() -> list[int]

      
      Get the selected atom types of this model.

      Only atoms with selected atom types have atomic contribution
      to the result of the model.
      If returning an empty list, all atom types are selected.















      ..
          !! processed by numpydoc !!


   .. py:method:: get_numb_dos() -> int

      
      Get the number of DOS.
















      ..
          !! processed by numpydoc !!


   .. py:method:: get_task_dim() -> int

      
      Get the output dimension.
















      ..
          !! processed by numpydoc !!


   .. py:method:: get_has_efield()

      
      Check if the model has efield.
















      ..
          !! processed by numpydoc !!


   .. py:method:: get_ntypes_spin()

      
      Get the number of spin atom types of this model. Only used in old implement.
















      ..
          !! processed by numpydoc !!


   .. py:method:: get_has_spin()

      
      Check if the model has spin atom types.
















      ..
          !! processed by numpydoc !!


   .. py:method:: eval(coords: numpy.ndarray, cells: Optional[numpy.ndarray], atom_types: numpy.ndarray, atomic: bool = False, fparam: Optional[numpy.ndarray] = None, aparam: Optional[numpy.ndarray] = None, **kwargs: Any) -> dict[str, numpy.ndarray]

      
      Evaluate the energy, force and virial by using this DP.


      :Parameters:

          **coords**
              The coordinates of atoms.
              The array should be of size nframes x natoms x 3

          **cells**
              The cell of the region.
              If None then non-PBC is assumed, otherwise using PBC.
              The array should be of size nframes x 9

          **atom_types**
              The atom types
              The list should contain natoms ints

          **atomic**
              Calculate the atomic energy and virial

          **fparam**
              The frame parameter.
              The array can be of size :
              - nframes x dim_fparam.
              - dim_fparam. Then all frames are assumed to be provided with the same fparam.

          **aparam**
              The atomic parameter
              The array can be of size :
              - nframes x natoms x dim_aparam.
              - natoms x dim_aparam. Then all frames are assumed to be provided with the same aparam.
              - dim_aparam. Then all frames and atoms are provided with the same aparam.

          **\*\*kwargs**
              Other parameters



      :Returns:

          **output_dict** : :class:`python:dict`
              The output of the evaluation. The keys are the names of the output
              variables, and the values are the corresponding output arrays.











      ..
          !! processed by numpydoc !!


   .. py:method:: _get_request_defs(atomic: bool) -> list[deepmd.dpmodel.output_def.OutputVariableDef]

      
      Get the requested output definitions.

      When atomic is True, all output_def are requested.
      When atomic is False, only energy (tensor), force, and virial
      are requested.

      :Parameters:

          **atomic** : :ref:`bool <python:bltin-boolean-values>`
              Whether to request the atomic output.



      :Returns:

          :class:`python:list`\[:obj:`OutputVariableDef`]
              The requested output definitions.











      ..
          !! processed by numpydoc !!


   .. py:method:: _eval_func(inner_func: Callable, numb_test: int, natoms: int) -> Callable

      
      Wrapper method with auto batch size.


      :Parameters:

          **inner_func** : :obj:`Callable <typing.Callable>`
              the method to be wrapped

          **numb_test** : :class:`python:int`
              number of tests

          **natoms** : :class:`python:int`
              number of atoms



      :Returns:

          :obj:`Callable <typing.Callable>`
              the wrapper











      ..
          !! processed by numpydoc !!


   .. py:method:: _get_natoms_and_nframes(coords: numpy.ndarray, atom_types: numpy.ndarray, mixed_type: bool = False) -> tuple[int, int]


   .. py:method:: _eval_model(coords: numpy.ndarray, cells: Optional[numpy.ndarray], atom_types: numpy.ndarray, fparam: Optional[numpy.ndarray], aparam: Optional[numpy.ndarray], request_defs: list[deepmd.dpmodel.output_def.OutputVariableDef])


   .. py:method:: _eval_model_spin(coords: numpy.ndarray, cells: Optional[numpy.ndarray], atom_types: numpy.ndarray, spins: numpy.ndarray, fparam: Optional[numpy.ndarray], aparam: Optional[numpy.ndarray], request_defs: list[deepmd.dpmodel.output_def.OutputVariableDef])
      :abstractmethod:



   .. py:method:: _get_output_shape(odef, nframes, natoms)


   .. py:method:: eval_typeebd() -> numpy.ndarray
      :abstractmethod:


      
      Evaluate output of type embedding network by using this model.





      :Returns:

          :obj:`np.ndarray <numpy.ndarray>`
              The output of type embedding network. The shape is [ntypes, o_size] or [ntypes + 1, o_size],
              where ntypes is the number of types, and o_size is the number of nodes
              in the output layer. If there are multiple type embedding networks,
              these outputs will be concatenated along the second axis.




      :Raises:

          :obj:`KeyError`
              If the model does not enable type embedding.



      .. seealso::

          
          :obj:`deepmd.pd.model.network.network.TypeEmbedNetConsistent`
              The type embedding network.
          
          



      ..
          !! processed by numpydoc !!


   .. py:method:: get_model_def_script() -> str

      
      Get model definition script.
















      ..
          !! processed by numpydoc !!


   .. py:method:: eval_descriptor(coords: numpy.ndarray, cells: Optional[numpy.ndarray], atom_types: numpy.ndarray, fparam: Optional[numpy.ndarray] = None, aparam: Optional[numpy.ndarray] = None, **kwargs: Any) -> numpy.ndarray

      
      Evaluate descriptors by using this DP.


      :Parameters:

          **coords**
              The coordinates of atoms.
              The array should be of size nframes x natoms x 3

          **cells**
              The cell of the region.
              If None then non-PBC is assumed, otherwise using PBC.
              The array should be of size nframes x 9

          **atom_types**
              The atom types
              The list should contain natoms ints

          **fparam**
              The frame parameter.
              The array can be of size :
              - nframes x dim_fparam.
              - dim_fparam. Then all frames are assumed to be provided with the same fparam.

          **aparam**
              The atomic parameter
              The array can be of size :
              - nframes x natoms x dim_aparam.
              - natoms x dim_aparam. Then all frames are assumed to be provided with the same aparam.
              - dim_aparam. Then all frames and atoms are provided with the same aparam.



      :Returns:

          :obj:`descriptor`
              Descriptors.











      ..
          !! processed by numpydoc !!


