:py:mod:`IMLCV.implementations.CV`
==================================

.. py:module:: IMLCV.implementations.CV


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

Classes
~~~~~~~

.. autoapisummary::

   IMLCV.implementations.CV.RealNVP
   IMLCV.implementations.CV.DistraxRealNVP
   IMLCV.implementations.CV.MetricUMAP
   IMLCV.implementations.CV.hyperTorus



Functions
~~~~~~~~~

.. autoapisummary::

   IMLCV.implementations.CV.Volume
   IMLCV.implementations.CV.distance_descriptor
   IMLCV.implementations.CV.dihedral
   IMLCV.implementations.CV.sb_descriptor
   IMLCV.implementations.CV.NoneCV
   IMLCV.implementations.CV.rotate_2d
   IMLCV.implementations.CV.project_distances
   IMLCV.implementations.CV.scale_cv_trans
   IMLCV.implementations.CV.trunc_svd
   IMLCV.implementations.CV.get_sinkhorn_divergence
   IMLCV.implementations.CV.un_atomize



.. py:function:: Volume(sp: IMLCV.base.CV.SystemParams, _)


.. py:function:: distance_descriptor()


.. py:function:: dihedral(numbers: list[int] | Array)

   from https://stackoverflow.com/questions/20305272/dihedral-torsion-
   angle-from-four-points-in-cartesian- coordinates-in-python.

   :param numbers: list with index of 4 atoms that form dihedral


.. py:function:: sb_descriptor(r_cut, n_max: int, l_max: int, references: SystemParams | None = None, references_nl: NeighbourList | None = None, reduce=True, reshape=False)


.. py:function:: NoneCV() -> IMLCV.base.CV.CollectiveVariable


.. py:function:: rotate_2d(alpha)


.. py:function:: project_distances(a)


.. py:function:: scale_cv_trans(array: IMLCV.base.CV.CV)

   axis 0 is batch axis


.. py:function:: trunc_svd(m: IMLCV.base.CV.CV) -> tuple[IMLCV.base.CV.CV, IMLCV.base.CV.CvTrans]


.. py:function:: get_sinkhorn_divergence(nli: NeighbourList | None, pi: Array | None, sort='rematch', alpha_rematch=0.1)


.. py:function:: un_atomize(x: IMLCV.base.CV.CV, nl, _)


.. py:class:: RealNVP

   Bases: :py:obj:`IMLCV.base.CV.CvFunNn`

   use in combination with swaplink

   .. py:attribute:: _
      :type: dataclasses.KW_ONLY

      

   .. py:attribute:: features
      :type: int

      

   .. py:attribute:: cv_input
      :type: IMLCV.base.CV.CvFunInput

      

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

      Initializes a Module lazily (similar to a lazy ``__init__``).

      ``setup`` is called once lazily on a module instance when a module
      is bound, immediately before any other methods like ``__call__`` are
      invoked, or before a ``setup``-defined attribute on `self` is accessed.

      This can happen in three cases:

        1. Immediately when invoking :meth:`apply`, :meth:`init` or
           :meth:`init_and_output`.

        2. Once the module is given a name by being assigned to an attribute of
           another module inside the other module's ``setup`` method
           (see :meth:`__setattr__`)::

             class MyModule(nn.Module):
               def setup(self):
                 submodule = Conv(...)

                 # Accessing `submodule` attributes does not yet work here.

                 # The following line invokes `self.__setattr__`, which gives
                 # `submodule` the name "conv1".
                 self.conv1 = submodule

                 # Accessing `submodule` attributes or methods is now safe and
                 # either causes setup() to be called once.

        3. Once a module is constructed inside a method wrapped with
           :meth:`compact`, immediately before another method is called or
           ``setup`` defined attribute is accessed.


   .. py:method:: forward(x: IMLCV.base.CV.CV, nl: NeighbourList | None, conditioners: list[CV] | None = None)


   .. py:method:: backward(z: IMLCV.base.CV.CV, nl: NeighbourList | None, conditioners: list[CV] | None = None)



.. py:class:: DistraxRealNVP

   Bases: :py:obj:`IMLCV.base.CV.CvFunDistrax`

   creates bijective CV function based on a distrax flow. The seup function should initialize the bijector

   class RealNVP(CvFunDistrax):
       _: dataclasses.KW_ONLY
       latent_dim: int

       def setup(self):
           self.s = Dense(features=self.latent_dim)
           self.t = Dense(features=self.latent_dim)

           # Alternating binary mask.
           self.bijector = distrax.as_bijector(
               tfp.bijectors.RealNVP(
                   fraction_masked=0.5,
                   shift_and_log_scale_fn=self.shift_and_scale,
               )
           )

       def shift_and_scale(self, x0, input_depth, **condition_kwargs):
           return self.s(x0), self.t(x0)

   .. py:attribute:: _
      :type: dataclasses.KW_ONLY

      

   .. py:attribute:: latent_dim
      :type: int

      

   .. py:method:: setup()

      Creates the flow model.


   .. py:method:: shift_and_scale(x0, input_depth, **condition_kwargs)



.. py:class:: MetricUMAP(periodicities, bounding_box=None)

   Bases: :py:obj:`IMLCV.base.CV.CvMetric`

   class to keep track of topology of given CV. Identifies the periodicitie of CVs and maps to unit square with correct peridicities


.. py:class:: hyperTorus(n)

   Bases: :py:obj:`IMLCV.base.CV.CvMetric`

   class to keep track of topology of given CV. Identifies the periodicitie of CVs and maps to unit square with correct peridicities


