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() 'Ang' >>> units.GetEnergyUnit() 'eV'
The length and energy units can be changed with the SetLengthUnit() and SetEnergyUnit() methods:
>>> units.SetLengthUnit('Bohr') >>> units.SetEnergyUnit('Hartree')
>>> 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.
'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') 27.211395655517311 >>> Convert(20, 'Ang', 'nm') 1.9999999999999998 >>> t = 1e-15 * Second() >>> t 0.098226935315503194