10
$\begingroup$

I'm trying to define a variable with the value of the thermal constant $V_T$. The value of the thermal constant is given in Volts as $V_T = \frac{k T}{q}$, where $k$ is the Boltzmann constant and $q$ is the charge on an electron.

Why am I getting different results from the following two inputs:

k = Quantity["BoltzmannConstant"];
q = Quantity["ElementaryCharge"];
T = UnitConvert[Quantity[25, "DegreesCelsius"], "Kelvin"];
Subscript[v, t] = UnitConvert[(k T)/q, "Volts"]

Which is returning the expected value of Quantity[0.0256926, "Volts"].

k = Quantity["BoltzmannConstant"];
q = Quantity["ElementaryCharge"];
T = Quantity[25, "DegreesCelsius"];
Subscript[v, t] = UnitConvert[(k T)/q, "Volts"]

Which is returning the unexpected value of Quantity[0.590610, "Volts"].

The only difference between the two is that in the first one I convert the from Celsius to Kelvin; however, the inherent physical value is not changing. So when I convert to Volts, shouldn't I get the same result from both inputs?

$\endgroup$
15
  • $\begingroup$ @march I might not be understanding what you are saying correctly, but it seems that Mathematica does know the difference between an absolute and non-absolute unit, because when I do UnitConvert[Quantity[25, "DegreesCelsius"], "Kelvin"] I get 298.15 K. If it wasn't able to differentiate between absolute and non-absolute wouldn't I just get 25 K? $\endgroup$ Jan 28, 2019 at 18:07
  • $\begingroup$ Hmm. I take back my comment! When I run your code on my own copy of Mathematica, I get the same result for both. Try quitting the kernel and trying again. If it still give you the wrong answer, then perhaps this is a bug. What version are you using? $\endgroup$
    – march
    Jan 28, 2019 at 18:10
  • $\begingroup$ @march I just tried again and I'm still getting the different answers. I even tried restarting my computer and nothing changed. I'm on Mathematica 11.3. I will submit a support ticket and see what they say. Thanks for testing it. $\endgroup$ Jan 28, 2019 at 18:21
  • 3
    $\begingroup$ Never use Celsius when doing physics, it only leads to trouble. Physical units cannot deal with offsets, and the conversion between temperature units is a kludge: the system has to guess somehow whether you mean an absolute temperature (take offset into account) or a temperature difference (don't take offset into account). $\endgroup$
    – Roman
    Jan 28, 2019 at 19:33
  • 1
    $\begingroup$ I would also check this out: reference.wolfram.com/language/tutorial/TemperatureUnits.html $\endgroup$
    – chuy
    Jan 28, 2019 at 21:25

2 Answers 2

1
$\begingroup$

Correct Temperature Conversion Code

k = Quantity["BoltzmannConstant"];
q = Quantity["ElementaryCharge"];
T1 = UnitConvert[Quantity[25, "DegreesCelsius"], "Kelvins"];
Subscript[v, t] = UnitConvert[k T1/q, "SI"]

(*Quantity[2.56926, "Centivolts"]*)
$\endgroup$
9
  • 3
    $\begingroup$ Can you say exactly how the OP is using UnitConvert incorrectly? $\endgroup$
    – Jason B.
    Jan 29, 2019 at 14:43
  • $\begingroup$ @JasonB. I showed how to use correctly. And how to use incorrectly showed OP. He did not specify in which unit system the conversion is performed. See tutorials: UnitConvert[quantity, targetunit] attempts to convert the specified quantity to the specified targetunit. A targetunit specification can also be one of the following unit systems: "SIBase", "SI", "Imperial", or "Metric". When using heterogeneous units, it is necessary to specify the unit system. $\endgroup$ Jan 29, 2019 at 15:08
  • 2
    $\begingroup$ You showed that both you and OP are using documented syntax for UnitConvert, and you claim that yours is correct while his is incorrect. So where on the documentation page for UnitConvert does it say that you must use a unit system rather than a target unit when using heterogeneous units? $\endgroup$
    – Jason B.
    Jan 29, 2019 at 17:06
  • $\begingroup$ See Scope UnitConvert[{Quantity[3., "Feet"], Quantity[8., "Inches"], Quantity[3., "Pounds"], Quantity[8., "Ounces"]}, "SI"] $\endgroup$ Jan 29, 2019 at 17:32
  • 2
    $\begingroup$ There is something weird going on, because 2.15 mV is the incorrect value. The correct value is 25.7 mV. So both your methods agree with eachother, but they return the wrong value. Also, according to the link you posted, the default for the second parameter on UnitConvert is SIBase, so I wouldn't expect it to make a difference whether it is implied through the defaults or explicitly added. $\endgroup$ Jan 31, 2019 at 16:19
1
$\begingroup$

I contacted support and they said they were "able to reproduce the issue." It seems like this is unintended behavior and will be fixed.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.