Handling of different versions of the CODATA suggestions
Hi,
regarding the feature request here, I worked a bit on the unit handling of ase. What I did was the following
- Hard-code the CODATA standards from 1986-2014 for all basis units, ie., those that are required to defined all the other units in the module. This is done via dictionaries so far, which I think is convenient.
- Added a function to create a dictionary of all units based on the dictionary of the respective CODATA version. This
units
dictionary can then be used to update the module's scope. By doing so, all units can be used as before from the outside. - I set the default units to CODATA 2014.
- As suggested by Jens, I also added units labelled with the respective CODATA version as suffix. Hence we have for instance
Bohr_2014
andBohr_1986
. - Added a function
__update_units__()
which updates the units without the CODATA suffix in the module scope (e.g.ase.units.Bohr
) to the required CODATA version. This can be used to switch between CODATA versions dynamically, even though I have no experience how robust it actually is. - Added dictionaries
units_X
whereX
is the CODATA version. These dictionaries contain all units and can be used to update the local scope of a function only.
Any suggestions or comments on this are very welcome. If we agree to use this functionality, I will also adjust the ase.castep.io
to use these units.
Would also be great if someone cross-checked the hard -coded values. The references are given as comments.