# Find a temperature from enthalpy

I would like to find a temperature by knowing the enthalpy, is this possible? This is what i've tried so far:

V1 = 150;
V2 = 4;
T1 = 15 + 273;

Enthalpy

h[T_] := QuantityMagnitude[
ThermodynamicData["Air",
"Enthalpy", {"Temperature" -> Quantity[T, "Kelvins"]}]]

h1 = h[T1]

sol = Solve[h1 + V1^2/2 == h2 + V2^2/2]

{{h2 -> 425466.}}

FindRoot[h[T2] == h2 /. sol, {T2, 300}]

During evaluation of ThermodynamicData::quant: T2 is not a real number.

During evaluation of FindRoot::jsing: Encountered a singular Jacobian at the point {T2} = {300.}. Try perturbing the initial point(s).

{T2 -> 300.}

• Are you trying to do something like solve the Clapeyron equation? – J. M.'s ennui May 25 '20 at 15:15
• I am trying to find the temperature of air after it has went through a diffuser. – Sam May 25 '20 at 15:28
• In the definition of h, restrict the arguments of h to numeric values, i.e., h[T_?NumericQ] := ... – Bob Hanlon May 25 '20 at 16:02
• Thanks a lot for the help Bob! – Sam May 25 '20 at 16:05

## 2 Answers

Mathematica is missing enthalpy data below 60K. Also evaluating the ThermodynamicData inside the Solve is slow. Try this:

enthalpy[t_?NumericQ] :=
QuantityMagnitude[
QuantityMagnitude[
ThermodynamicData["Air",
"Enthalpy", {"Temperature" -> Quantity[t, "Kelvins"]}]]]
h2 = With[{V1 = 150, V2 = 4, T1 = 15 + 273},
x /. Last@
NMinimize[{((enthalpy[T1] + V1^2/2) - (x + V2^2/2))^2, x > 60}, x,
MaxIterations -> 5]]
NMinimize[{(enthalpy[t] - h2)^2 , t > 60}, t, MaxIterations -> 5]


It's still a bit slow, and will be even slower with more iterations, but I get 299.173K.

I would explicitly state the reference pressure (assuming 1 Bar). Here is an alternative way:

Clear[h]
h[t_?NumericQ] :=
QuantityMagnitude@
ThermodynamicData["Air",
"Enthalpy", {"Pressure" -> Quantity[1, "Bars"],
"Temperature" -> Quantity[t, "Kelvins"]}]
V1 = 150;
V2 = 4;
T1 = 15 + 273;
h1 = h[T1];
sol = First@Solve[h1 + V1^2/2 == h2 + V2^2/2, h2];
t /. FindRoot[h[t] == h2 /. sol, {t, 273}]
(* 299.173 *)

• Does the trick, much faster than mine. – flinty May 25 '20 at 17:24