deepmd.utils.spin
=================

.. py:module:: deepmd.utils.spin


Classes
-------

.. autoapisummary::

   deepmd.utils.spin.Spin


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

.. py:class:: Spin(use_spin: list[bool], virtual_scale: Union[list[float], float])

   
   Class for spin, mainly processes the spin type-related information.
   Atom types can be split into three kinds:
   1. Real types: real atom species, "Fe", "H", "O", etc.
   2. Spin types: atom species with spin, as virtual atoms in input, "Fe_spin", etc.
   3. Placeholder types: atom species without spin, as placeholders in input without contribution,
   also name "H_spin", "O_spin", etc.
   For any types in 2. or 3., the type index is `ntypes` plus index of its corresponding real type.


   :Parameters:

       **use_spin: list[bool]**
           A list of boolean values indicating whether to use atomic spin for each atom type.
           True for spin and False for not. List of bool values with shape of [ntypes].

       **virtual_scale: list[float], float**
           The scaling factor to determine the virtual distance
           between a virtual atom representing spin and its corresponding real atom
           for each atom type with spin. This factor is defined as the virtual distance
           divided by the magnitude of atomic spin for each atom type with spin.
           The virtual coordinate is defined as the real coordinate plus spin * virtual_scale.
           List of float values with shape of [ntypes] or [ntypes_spin] or one single float value for all types,
           only used when use_spin is True for each atom type.














   ..
       !! processed by numpydoc !!

   .. py:attribute:: ntypes_real


   .. py:attribute:: ntypes_spin


   .. py:attribute:: use_spin


   .. py:attribute:: spin_mask


   .. py:attribute:: ntypes_real_and_spin


   .. py:attribute:: ntypes_placeholder


   .. py:attribute:: ntypes_input


   .. py:attribute:: real_type


   .. py:attribute:: spin_type


   .. py:attribute:: real_and_spin_type


   .. py:attribute:: placeholder_type


   .. py:attribute:: spin_placeholder_type


   .. py:attribute:: input_type


   .. py:attribute:: virtual_scale


   .. py:attribute:: virtual_scale_mask


   .. py:attribute:: pair_exclude_types
      :value: []



   .. py:attribute:: atom_exclude_types_ps
      :value: []



   .. py:attribute:: atom_exclude_types_p
      :value: []



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

      
      Returns the number of real atom types.
















      ..
          !! processed by numpydoc !!


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

      
      Returns the number of atom types which contain spin.
















      ..
          !! processed by numpydoc !!


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

      
      Returns the number of real atom types and types which contain spin.
















      ..
          !! processed by numpydoc !!


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

      
      Returns the number of double real atom types for input placeholder.
















      ..
          !! processed by numpydoc !!


   .. py:method:: get_use_spin() -> list[bool]

      
      Returns the list of whether to use spin for each atom type.
















      ..
          !! processed by numpydoc !!


   .. py:method:: get_virtual_scale() -> numpy.ndarray

      
      Returns the list of magnitude of atomic spin for each atom type.
















      ..
          !! processed by numpydoc !!


   .. py:method:: init_pair_exclude_types_placeholder() -> None

      
      Initialize the pair-wise exclusion types for descriptor.
      The placeholder types for those without spin are excluded.
















      ..
          !! processed by numpydoc !!


   .. py:method:: init_atom_exclude_types_placeholder_spin() -> None

      
      Initialize the atom-wise exclusion types for fitting.
      Both the placeholder types and spin types are excluded.
















      ..
          !! processed by numpydoc !!


   .. py:method:: init_atom_exclude_types_placeholder() -> None

      
      Initialize the atom-wise exclusion types for fitting.
      The placeholder types for those without spin are excluded.
















      ..
          !! processed by numpydoc !!


   .. py:method:: get_pair_exclude_types(exclude_types=None) -> list[tuple[int, int]]

      
      Return the pair-wise exclusion types for descriptor.
      The placeholder types for those without spin are excluded.
















      ..
          !! processed by numpydoc !!


   .. py:method:: get_atom_exclude_types(exclude_types=None) -> list[int]

      
      Return the atom-wise exclusion types for fitting before out_def.
      Both the placeholder types and spin types are excluded.
















      ..
          !! processed by numpydoc !!


   .. py:method:: get_atom_exclude_types_placeholder(exclude_types=None) -> list[int]

      
      Return the atom-wise exclusion types for fitting after out_def.
      The placeholder types for those without spin are excluded.
















      ..
          !! processed by numpydoc !!


   .. py:method:: get_spin_mask()

      
      Return the spin mask of shape [ntypes],
      with spin types being 1, and non-spin types being 0.
















      ..
          !! processed by numpydoc !!


   .. py:method:: get_virtual_scale_mask()

      
      Return the virtual scale mask of shape [ntypes],
      with spin types being its virtual scale, and non-spin types being 0.
















      ..
          !! processed by numpydoc !!


   .. py:method:: serialize() -> dict


   .. py:method:: deserialize(data: dict) -> Spin
      :classmethod:



