0
$\begingroup$

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

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.

$\endgroup$
1
$\begingroup$

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 *)
$\endgroup$
  • $\begingroup$ Does the trick, much faster than mine. $\endgroup$ – flinty May 25 '20 at 17:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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