Each Python session has units stored in a units object. The units for length, energy and mass default to Å, eV and atomic mass units.

>>> from ASE.Units import units
>>> units.GetLengthUnit()
>>> units.GetEnergyUnit()

The length and energy units can be changed with the SetLengthUnit() and SetEnergyUnit() methods:

>>> units.SetLengthUnit('Bohr')
>>> units.SetEnergyUnit('Hartree')

or equivalently:

>>> units.SetUnits('Bohr', 'Hartree')

A calculator (or some other object that needs to know about units) can ask the units object for its units (with GetLengthUnit() and GetEnergyUnit()). After the first call to GetLengthUnit() or GetEnergyUnit(), the corresponding Set-method will be disabled. This behavior ensures that each python session will use one and only one set of units.

The only link between two Python sessions (with possibly different units) is through a file. Therefore, a portable file should always contain the units.

The units are identified by strings like 'Ang' and 'eV'. The identifiers are taken directly from the Scientific.Physics.PhysicalQuantities module of Scientific Python. Useful length units are:

'Ang', 'Bohr' and 'nm',

and for energy:

'eV', 'Hartree', 'kJ/mol/Nav' and 'kcal/mol/Nav'.

The ASE.Units module has two convenience functions: Convert(value, unit, newunit) and Second(). Examples:

>>> from ASE.Units import Convert, Second
>>> Convert(1, 'Hartree', 'eV')
>>> Convert(20, 'Ang', 'nm')
>>> t = 1e-15 * Second()
>>> t