PyFrag
Public Member Functions | Static Public Attributes | List of all members
qmworks.plams.tools.utils.Units Class Reference
Inheritance diagram for qmworks.plams.tools.utils.Units:
Inheritance graph
[legend]
Collaboration diagram for qmworks.plams.tools.utils.Units:
Collaboration graph
[legend]

Public Member Functions

def __init__ (self)
 
def conversion_ratio (cls, inp, out)
 
def convert (cls, value, inp, out)
 

Static Public Attributes

dictionary constants = {}
 
list dicts = []
 
dictionary distance = {}
 
dictionary energy = {}
 
dictionary angle = {}
 
dictionary dipole = {}
 

Detailed Description

Singleton class for units converter.

All values are based on `2014 CODATA recommended values <http://physics.nist.gov/cuu/Constants>`_.

The following constants and units are supported:
    *   constants:

        -   ``speed_of_light`` (also ``c``)
        -   ``elementary_charge`` (also ``e`` and ``electron_charge``)
        -   ``avogadro_constant`` (also ``NA``)
        -   ``bohr_radius``

    *   distance:

        -   ``Angstrom``, ``angstrom``, ``A``
        -   ``bohr``, ``a0``, ``au``
        -   ``nm``
        -   ``pm``

    *   angle:

        -    ``degree``, ``deg``,
        -    ``radian``, ``rad``,
        -    ``grad``
        -    ``circle``

    *   energy:

        -   ``au``, ``hartree``, ``Hartree``
        -   ``ev``, ``eV``
        -   ``kcal/mol``
        -   ``kJ/mol``
        -   ``cm^-1``

    *   dipole moment:

        -   ``au``
        -   ``Cm``
        -   ``D``, ``Debye``, ``debye``

Example::

    >>> print(Units.constants['speed_of_light'])
    299792458
    >>> print(Units.constants['e'])
    1.6021766208e-19
    >>> print(Units.convert(123, 'angstrom', 'bohr'))
    232.436313431
    >>> print(Units.convert(23.32, 'kJ/mol', 'kcal/mol'))
    5.57361376673
    >>> print(Units.conversion_ratio('kcal/mol', 'kJ/mol'))
    4.184

Member Function Documentation

◆ conversion_ratio()

def qmworks.plams.tools.utils.Units.conversion_ratio (   cls,
  inp,
  out 
)
Return conversion ratio from unit *inp* to *out*.
Here is the caller graph for this function:

◆ convert()

def qmworks.plams.tools.utils.Units.convert (   cls,
  value,
  inp,
  out 
)
Convert *value* from unit *inp* to *out*. *value* has to be either a single number or a container (list, tuple etc.) containing only numbers. In this case container of the same type and length is returned.
Here is the call graph for this function:

The documentation for this class was generated from the following file: