.. include:: ../../toolkit-substitutions

.. oe:namespace:: OEMolPotential



.. meta::
   :keywords: OETorAdaptor, TorAdaptor


.. _OEMolPotential_OETorAdaptor:

.. oe:class:: OETorAdaptor

   .. attention::

      |TWOLANGUAGE|

   .. oe:api::


      class OETorAdaptor : public OEMolAdaptor

   The :ref:`OETorAdaptor <OEMolPotential_OETorAdaptor>` class provides the ability to optimize torsion angles
   of a molecule while holding bond lengths and bond angles fixed. :ref:`OEMolFunc1 <OEMolPotential_OEMolFunc1>`
   derived classes typically require Cartesian coordinates for function evaluation. 
   :ref:`OETorAdaptor <OEMolPotential_OETorAdaptor>` transforms a set of torsions into Cartesian coordinates,
   passes the resultant coordinates to the internally stored :ref:`OEMolFunc1 <OEMolPotential_OEMolFunc1>`
   type function, and transforms the Cartesian gradients back into torsion gradients. Additional
   facilities are provided for excluding invariant molecule function interactions, controlling the 
   definition of a rotatable bond, and fixing atomic positions during coordinate transformation.

   .. _figure_OETorAdaptor_Hierarchy:

   .. figure:: ../images/OETorAdaptor.*
      :align:  center

   The following methods are publicly inherited from :ref:`OEAdaptor <OEOpt_OEAdaptor>`:
    * :oe:meth:`AdaptVar<OEOpt::OEAdaptor::AdaptVar>` 
    * :oe:meth:`GetVar<OEOpt::OEAdaptor::GetVar>`

   The following methods are publicly inherited from :ref:`OEFunc0 <OEOpt_OEFunc0>`:
    * :oe:meth:`operator()<OEOpt::OEFunc0::operator()>`         
    * :oe:meth:`GetFComponents<OEOpt::OEFunc0::GetFComponents>` 
    * :oe:meth:`NumVar<OEOpt::OEFunc0::NumVar>`

   The following methods are publicly inherited from :ref:`OEFunc1 <OEOpt_OEFunc1>`:
    * :oe:meth:`operator()<OEOpt::OEFunc1::operator()>`
   
   The following methods are publicly inherited from :ref:`OEMolFunc <OEMolPotential_OEMolFunc>`:
    * :oe:meth:`Clear<OEMolPotential::OEMolFunc::Clear>`   
    * :oe:meth:`ClearPredicates<OEMolPotential::OEMolFunc::ClearPredicates>`
    * :oe:meth:`GetInteractions<OEMolPotential::OEMolFunc::GetInteractions>`
    * :oe:meth:`Setup<OEMolPotential::OEMolFunc::Setup>`

   The following methods are publicly inherited from :ref:`OEMolAdaptor <OEMolPotential_OEMolAdaptor>`:
    * :oe:meth:`SetMolFunc<OEMolPotential::OEMolAdaptor::SetMolFunc>`

   The :ref:`OETorAdaptor <OEMolPotential_OETorAdaptor>` class defines the following public methods:
    * :oe:meth:`AdaptGrad<OEMolPotential::OETorAdaptor::AdaptGrad>`
    * :oe:meth:`Set<OEMolPotential::OETorAdaptor::Set>`

   .. oe:method:: Constructors

      .. oe:language:: c++ java csharp

         .. oe:api::

            OETorAdaptor(OEMolFunc1 &, bool own = false,
                         bool excludeInteract = true)

      .. oe:language:: python

         .. oe:api:: python

            OETorAdaptor(arg2: OEMolFunc1, own: bool = False,
                         excludeInteract: bool = True) -> OETorAdaptor

      Default and copy constructors.

      Constructs an :ref:`OETorAdaptor <OEMolPotential_OETorAdaptor>` instance. The molecule function used
      for function evaluation must be provided as the first argument to the constructor. The second 
      argument specifies whether the :ref:`OETorAdaptor <OEMolPotential_OETorAdaptor>` object takes ownership
      of the memory of the molecule function instance. By default the 
      :ref:`OETorAdaptor <OEMolPotential_OETorAdaptor>` instance does not take ownership of the molecule function,
      so the :ref:`OETorAdaptor <OEMolPotential_OETorAdaptor>` destructor does not delete the molecule function
      instance. If ownership of the molecule function is transferred to the 
      :ref:`OETorAdaptor <OEMolPotential_OETorAdaptor>` instance, the molecule function's delete operator will
      be called in the :ref:`OETorAdaptor <OEMolPotential_OETorAdaptor>` destructor. The third argument
      controls the inclusion of invariant molecule function interactions. By default, interactions 
      which remain constant during the torsion minimization are excluded from calculation (for 
      example  bond stretch interactions). If the third calling argument is ``false`` then all
      interactions will be computed during every function evaluation.


   .. oe:method:: operator=
      :language: c++

      .. oe:api::

         OETorAdaptor & operator=(const OETorAdaptor &)

      Assignment operator.

   

   .. oe:method:: AdaptGrad

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool AdaptGrad(double* torGrad, const double* grads) const

      .. oe:language:: python

         .. oe:api:: python

            AdaptGrad(torGrad: OEDoubleArray, grads: OEDoubleArray) -> bool

      Takes a set of Cartesian gradients of a conformer (second argument), and transforms them into 
      angular torsion gradients (first  argument). 

   .. oe:method:: Set

      .. oe:api::

         bool Set(const OESystem::OEUnaryPredicate<OEChem::OEAtomBase> &p,
                  unsigned int functype = OEFuncType::TorAdapt)
         bool Set(const OESystem::OEUnaryPredicate<OEChem::OEBondBase> &rot,
                  unsigned int functype = OEFuncType::TorAdapt)

      The first method assigns an atom predicate which is used to specify atoms which are to be held fixed in their starting positions during an optimization. The second method assigns a bond predicate which is used to determine which bonds of a molecule are to be rotated during an optimization. Both the :oe:meth:`Set<OEMolPotential::OETorAdaptor::Set>` methods must be called before the :oe:meth:`Setup<OEMolPotential::OEMolFunc::Setup>` for it to be effective.     
