.. oe:namespace:: OEChem

.. meta::
   :keywords: OECalcPMI

.. oe:function:: OECalcPMI

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

      .. oe:api::

         bool OECalcPMI(double* pmi, OEMolBase& mol)
         bool OECalcPMI(double* pmi, const OEMolBase& mol)
         bool OECalcPMI(double* pmi, const OEConfBase& mol)
         bool OECalcPMI(double* pmi, const OEMCMolBase& mol)

   .. oe:language:: python

      .. oe:api:: python

         OECalcPMI(pmi: OEDoubleArray, mol: Union[OEGraphMol,OEQMol]) -> bool
         OECalcPMI(pmi: OEDoubleArray, mol: OEConfBase) -> bool
         OECalcPMI(pmi: OEDoubleArray, mol: OEMol) -> bool

   Calculates the PMI (principal moment of inertia) of the given molecule. Units of the PMI calculated are
   :math:`\text{amu} \times A^2`, where amu stands for Atomic Mass Unit and :math:`A` for Angstrom. If calling the OEMCMolBase overload,
   the PMI calculated corresponds to the active conformer.
   
   Returns true if calculation is successful, false otherwise. The function returns false if the values for the PMI
   are all 0, or if the molecule is not centered before calling the overloads with a const molecule argument.

   If using any of the constant molecule overloads of this function, you must center the molecule before calling the
   overload, otherwise the function will return an incorrect or invalid value.
   See the function :oe:func:`OEChem::OECenter` for how to center a molecule.

   *pmi*
      This pointer is populated by the PMI of the given molecule in each dimension, X, Y, and Z. 
  
   *mol*
      This is the molecule for which the PMI is calculated. It must have a set radius and set mass for the calculation
      to be valid. 

   .. warning::

      These functions only work correctly with a molecule that has been centered using the function
      :oe:func:`OEChem::OECenter`. If the molecule has not been centered, the function will return false.

   .. seealso::

      * :oe:func:`OEChem::OEGetRadiusOfGyration` function to calculate radius of gyration.

   The following code snippet demonstrates how to calculate the PMI and radius of gyration for a molecule.

.. oe:source:: CalcPMI.cpp
   :language: c++
   :noindent:
   :frag:     SNIPPET-CALC-PMI

.. oe:source:: CalcPMI.py
   :language: python
   :noindent:
   :frag:     SNIPPET-CALC-PMI

.. oe:source:: CalcPMI.java
   :language: java
   :noindent:
   :frag:     SNIPPET-CALC-PMI

.. oe:source:: CalcPMI.cs
   :language: csharp
   :noindent:
   :frag:     SNIPPET-CALC-PMI
