Bug introduced in 9 and partially persists through 10.2 or later
The specific bug described in the original question is fixed ("Kelvin"
is correctly recognized as "Kelvins"
now) but as shown in the answer by Willinski there is more involved problem with misinterpretation of "K"
as "KelvinsDifference"
in some cases. Please see this discussion for more information on the temperature difference units in Mathematica.
I'm trying to use Mathematica units more often, but I've run into the following problem:
(*Define some unitful constants*)
q = UnitConvert[Quantity["elementary charge"]];
k = UnitConvert[Quantity["Boltzmann Constant"]];
T = Quantity[300, "Kelvin"];
V = Quantity[5, "Volt"];
(*Do a simple calculation*)
UnitConvert[(q V)/(k T)]
The above code outputs
Quantity[193.409, ("Kelvins")/("KelvinsDifference")]
which really should just be 193.409, since the units cancel, but Mathematica insists on a distinction between absolute temperature and temperature differences. I understand that such a distinction is useful in conversions, but the above is quite a nuisance.
Is there a way to prevent this? I'd rather not have to put in QuantityMagnitude
calls every time I need to cancel some Kelvins
.
Thanks!
Kelvin
used to be interpreted by Wolfram Alpha asKelvinDifference
, whereasKelvins
was recognized by Mathematica as a built-in unit and directly interpreted asKelvin
. Since a few months,Kelvin
is interpreted asKelvins
, so the error appears to have gone away. (Of course, the unit of the Boltzmann constant is stilll incorrect, see Xerxes' answer.) $\endgroup$"Kelvin"
as"Kelvins"
, it still incorrectly interprets"K"
as"KelvinsDifference"
inQuantity[1, "J/(mol*K)"]
while inQuantity[300, "K"]
it correctly interprets"K"
as"Kelvins"
(the example is from the answer by Willinski). So the bug is only partially fixed. $\endgroup$