Add unit of electron-volts that is specifically a temperature
See original GitHub issueThe electron-volt (eV) is an extremely common unit of temperature in plasma physics. Units of eV, keV, and so on are often used as a measure of the thermal energy per particle. A quantity with units of eV can be converted to temperature by dividing by the Boltzmann constant, kB.
Despite my honest opinion about this usage (see https://github.com/PlasmaPy/PlasmaPy/issues/131 for my grumblings), many in the plasma physics community would benefit from a unit of electron-volts that is specifically a temperature (perhaps called eV_temp). Including this unit would also allow us to clean up a lot of code within PlasmaPy.
The ways to currently do this are:
>>> kT = 1.4 * units.eV
>>> kT.to(units.K, equivalencies=units.temperature_energy())
<Quantity 11604.522060401008 K>
and
>>> units.set_enabled_equivalencies(units.temperature_energy())
>>> kT.to(units.K)
<Quantity 11604.522060401008 K>
The proposed usage would allow usage like:
>>> kT = 1.0 * units.eV_temp
>>> kT.to(units.K)
<Quantity 11604.522060401008 K>
One of the biggest benefits is that we would not need to explicitly do a conversion step before we put a quantity with these units into a formula. This would also greatly reduce the ambiguity for when units of eV are used as temperature.
However, units of eV can also correspond to mass, momentum, distance, and time as well as energy. This ambiguity is part of the reason why I generally recommend against using units of eV in general (along with having silent factors of kB, c, c2, etc.). If we decide to have units of eV_temp, then we might want to consider units of eV_mass and eV_momentum as well.
Thank you!
-Nick
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:5 (5 by maintainers)

Top Related StackOverflow Question
It may be possible to repurpose some trickery I used for the functional units, which define their own
equivalencies. This can solve one direction very easily:For the other direction, we’d either need to adjust
UnitBaseto start checking forequivalencieson itself, oreV_tempshould subclass the base unit and add a new method. Just as a proof of concept:So, this is not difficult in itself, but needs thought of how best to implement it.
What is the package that specializes in Xray astronomy and use astropy? Maybe such a
def_unitcan live there?