EnergyUnits

The unit for energy used varies wildly between field. Even within one field there is often more then one unit used. Quanty allows to use any unit one likes and makes it easy to transform between units of energy. The variable EnergyUnits contains a table with the values of different units, and a string describing the energy unit. The units are expressed in the value .units which can be changed by the field .Set. The standard setting is eV.

Besides the option to change between Joule, electron Volt, Rydberg or many other obscure units one can express the unit for temperature and magnetic field to the unit of energy. This allows for clean scripting without the need of Bolzman's constants and $\mu$ Bohrs in the appropriate units.

Basics

Conversion between units is implemented in the constant EnergyUnits. For example the Rydberg energy in units of electron volts can be found in the constant:

Example.Quanty
print(EnergyUnits.Ryd.value)

which returns:

13.605693009454

The unit of this number is obtained from:

Example.Quanty
print(EnergyUnits.Ryd.units)

which returns:

eV

A definition of the Rydberg can be found in the description:

Example.Quanty
print(EnergyUnits.Ryd.description)

which returns:

Rydberg, binding energy of a clasical electron to a point potential of 1 unit of electrical charge in units of electron Volt

All units implemented

A list of all implemented energy units can be obtained by printing all elements in the global table EnergyUnits:

Example.Quanty
for constant,var in pairs(EnergyUnits) do 
  io.write(string.format("EnergyUnits.%s\n",constant)) 
  io.write(string.format("  %17.10E [%s]\n",var.value,var.units)) 
  io.write(string.format("   %s\n",var.description)) 
end

which returns:

Energy transferred (or work done) to an object when a force of one newton acts on that object in the direction of its motion through a distance of one meter in units of electron Volt 
EnergyUnits.perfs 
   4.1356676623E+00 [eV] 
   10^15 h in units of electron Volt 
EnergyUnits.Hartree 
   2.7211386019E+01 [eV] 
   Hartree energy (2 Rydberg) in units of electron Volt 
EnergyUnits.Tesla 
   5.7883818011E-05 [eV] 
   muB Bohr magneton in units of electron Volt 
EnergyUnits.Kelvin 
   8.6173303372E-05 [eV] 
   kB Boltzmann constant in units of electron Volt 
EnergyUnits.eV 
   1.0000000000E+00 [eV] 
   The amount of energy gained (or lost) by the charge of a single electron moved across an electric potential difference of one volt in units of electron Volt 
EnergyUnits.T 
   5.7883818011E-05 [eV] 
   muB Bohr magneton in units of electron Volt 
EnergyUnits.TeraHz 
   4.1356676623E-03 [eV] 
   10^12 h in units of electron Volt 
EnergyUnits.pernm 
   1.2398419740E+03 [eV] 
   10^9 h c in units of electron Volt 
EnergyUnits.fs^-1 
   4.1356676623E+00 [eV] 
   10^15 h in units of electron Volt 
EnergyUnits.THz 
   4.1356676623E-03 [eV] 
   10^12 h in units of electron Volt 
EnergyUnits.Rydberg 
   1.3605693009E+01 [eV] 
   Rydberg, binding energy of a clasical electron to a point potential of 1 unit of electrical charge in units of electron Volt 
EnergyUnits.K 
   8.6173303372E-05 [eV] 
   kB Boltzmann constant in units of electron Volt 
EnergyUnits.J 
   6.2415091259E+18 [eV] 
   Energy transferred (or work done) to an object when a force of one newton acts on that object in the direction of its motion through a distance of one meter in units of electron Volt 
EnergyUnits.cm^-1 
   1.2398419740E-04 [eV] 
   100 h c in units of electron Volt 
EnergyUnits.percm 
   1.2398419740E-04 [eV] 
   100 h c in units of electron Volt 
EnergyUnits.nm^-1 
   1.2398419740E+03 [eV] 
   10^9 h c in units of electron Volt 
EnergyUnits.electron Volt 
   1.0000000000E+00 [eV] 
   The amount of energy gained (or lost) by the charge of a single electron moved across an electric potential difference of one volt in units of electron Volt 
EnergyUnits.Ryd 
   1.3605693009E+01 [eV] 
   Rydberg, binding energy of a clasical electron to a point potential of 1 unit of electrical charge in units of electron Volt

Change of unit used for the values

Without further settings the unit of all energy units in electron volt (eV). This is not a must and can be changed. By setting the variable EnergyUnits.Set one can change the standard unit. If one wants to have Joules as the unit of energy one can do:

Example.Quanty
EnergyUnits.Set="Joule" 
 
for constant,var in pairs(EnergyUnits) do 
  io.write(string.format("EnergyUnits.%s\n",constant)) 
  io.write(string.format("  %17.10E [%s]\n",var.value,var.units)) 
  io.write(string.format("   %s\n",var.description)) 
end

which sets the energy unit to Joule. The script furthermore returns all energy units implemented, but now in Joule

EnergyUnits.nm^-1 
   1.9864458242E-16 [J] 
   10^9 h c in units of Joule 
EnergyUnits.T 
   9.2740099940E-24 [J] 
   muB Bohr magneton in units of Joule 
EnergyUnits.eV 
   1.6021766208E-19 [J] 
   The amount of energy gained (or lost) by the charge of a single electron moved across an electric potential difference of one volt in units of Joule 
EnergyUnits.cm^-1 
   1.9864458242E-23 [J] 
   100 h c in units of Joule 
EnergyUnits.pernm 
   1.9864458242E-16 [J] 
   10^9 h c in units of Joule 
EnergyUnits.Ryd 
   2.1798723250E-18 [J] 
   Rydberg, binding energy of a clasical electron to a point potential of 1 unit of electrical charge in units of Joule 
EnergyUnits.K 
   1.3806485200E-23 [J] 
   kB Boltzmann constant in units of Joule 
EnergyUnits.THz 
   6.6260700400E-22 [J] 
   10^12 h in units of Joule 
EnergyUnits.Tesla 
   9.2740099940E-24 [J] 
   muB Bohr magneton in units of Joule 
EnergyUnits.J 
   1.0000000000E+00 [J] 
   Energy transferred (or work done) to an object when a force of one newton acts on that object in the direction of its motion through a distance of one meter in units of Joule 
EnergyUnits.fs^-1 
   6.6260700400E-19 [J] 
   10^15 h in units of Joule 
EnergyUnits.electron Volt 
   1.6021766208E-19 [J] 
   The amount of energy gained (or lost) by the charge of a single electron moved across an electric potential difference of one volt in units of Joule 
EnergyUnits.Hartree 
   4.3597446499E-18 [J] 
   Hartree energy (2 Rydberg) in units of Joule 
EnergyUnits.percm 
   1.9864458242E-23 [J] 
   100 h c in units of Joule 
EnergyUnits.TeraHz 
   6.6260700400E-22 [J] 
   10^12 h in units of Joule 
EnergyUnits.Rydberg 
   2.1798723250E-18 [J] 
   Rydberg, binding energy of a clasical electron to a point potential of 1 unit of electrical charge in units of Joule 
EnergyUnits.Joule 
   1.0000000000E+00 [J] 
   Energy transferred (or work done) to an object when a force of one newton acts on that object in the direction of its motion through a distance of one meter in units of Joule 
EnergyUnits.perfs 
   6.6260700400E-19 [J] 
   10^15 h in units of Joule 
EnergyUnits.Kelvin 
   1.3806485200E-23 [J] 
   kB Boltzmann constant in units of Joule 
EnergyUnits.Ha 
   4.3597446499E-18 [J] 
   Hartree energy (2 Rydberg) in units of Joule

Conversion table

A table converting all units into each other can be obtained by printing the table EnergyUnits

Example.Quanty
print(EnergyUnits)

which returns

Conversion table between energy units 
      Joule             Rydberg           Hartree           electron Volt     Kelvin            Tesla             pernm             percm             TeraHz            perfs 
      J                 Ryd               Ha                eV                K                 T                 nm^-1             cm^-1             THz               fs^-1 
J     1.00000000000E+00 4.58742463287E+17 2.29371231643E+17 6.24150912588E+18 7.24297303415E+22 1.07828221087E+23 5.03411665111E+15 5.03411665111E+22 1.50919020470E+21 1.50919020470E+18 
Ryd   2.17987232495E-18 1.00000000000E+00 5.00000000000E-01 1.36056930095E+01 1.57887564675E+05 2.35051754997E+05 1.09737315683E-02 1.09737315683E+05 3.28984196031E+03 3.28984196031E+00 
Ha    4.35974464991E-18 2.00000000000E+00 1.00000000000E+00 2.72113860189E+01 3.15775129351E+05 4.70103509995E+05 2.19474631367E-02 2.19474631367E+05 6.57968392062E+03 6.57968392062E+00 
eV    1.60217662080E-19 7.34986449647E-02 3.67493224823E-02 1.00000000000E+00 1.16045220604E+04 1.72759854889E+04 8.06554400480E-04 8.06554400480E+03 2.41798926230E+02 2.41798926230E-01 
K     1.38064852000E-23 6.33362102998E-06 3.16681051499E-06 8.61733033722E-05 1.00000000000E+00 1.48872873859E+00 6.95034570387E-08 6.95034570387E-01 2.08366122251E-02 2.08366122251E-05 
T     9.27400999400E-24 4.25438218920E-06 2.12719109460E-06 5.78838180111E-05 6.71714043050E-01 1.00000000000E+00 4.66864481334E-08 4.66864481334E-01 1.39962450412E-02 1.39962450412E-05 
nm^-1 1.98644582417E-16 9.11267050567E+01 4.55633525283E+01 1.23984197396E+03 1.43877735383E+07 2.14194919507E+07 1.00000000000E+00 1.00000000000E+07 2.99792458000E+05 2.99792458000E+02 
cm^-1 1.98644582417E-23 9.11267050567E-06 4.55633525283E-06 1.23984197396E-04 1.43877735383E+00 2.14194919507E+00 1.00000000000E-07 1.00000000000E+00 2.99792458000E-02 2.99792458000E-05 
THz   6.62607004000E-22 3.03965969206E-04 1.51982984603E-04 4.13566766234E-03 4.79924466221E+01 7.14477345214E+01 3.33564095198E-06 3.33564095198E+01 1.00000000000E+00 1.00000000000E-03 
fs^-1 6.62607004000E-19 3.03965969206E-01 1.51982984603E-01 4.13566766234E+00 4.79924466221E+04 7.14477345214E+04 3.33564095198E-03 3.33564095198E+04 1.00000000000E+03 1.00000000000E+00

Sub pages

Print/export