Coverage for local_installation/dynasor/units.py: 100%
9 statements
« prev ^ index » next coverage.py v7.3.2, created at 2024-12-21 12:02 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2024-12-21 12:02 +0000
1"""
2Module containing convenient unit conversion factors, including
4* ``radians_per_fs_to_THz``
5* ``radians_per_fs_to_meV``
6* ``radians_per_fs_to_invcm``
7* ``THz_to_meV``
8* ``THz_to_invcm``
9* ``meV_to_invcm``
10* ``Dalton_to_dmu`` dmu is Dynasor Mass Unit
13Here, for example, ``radians_per_fs_to_invcm`` can be used to convert an angular frequency in units
14of radians/fs to a frequency in 1/cm, as demonstrated by the code snippet below.
16.. highlight:: python
17.. code-block:: python
19 # converting the angular frequencies (omega) in a Sample object to frequencies in inverse cm
20 from dynasor.units import radians_per_fs_to_invcm
21 frequencies_invcm = sample.omega * radians_per_fs_to_invcm
23 # converting frequencies from inverse cm to meV
24 from dynasor.units import meV_to_invcm
25 frequencies_meV = frequencies_invcm / meV_to_invcm
27"""
28from math import pi
29from ase.units import _c, invcm, fs
31# Frequencies
32meV_to_invcm = 1 / invcm / 1e3
33THz_to_invcm = 1e12 / _c / 1e2
34THz_to_meV = 1e13 * invcm / _c
36# Angular frequencies
37radians_per_fs_to_THz = 1000 / 2 / pi
38radians_per_fs_to_meV = radians_per_fs_to_THz * THz_to_meV
39radians_per_fs_to_invcm = radians_per_fs_to_THz * THz_to_invcm
41# Mass
42Dalton_to_dmu = 1/fs**2