# Finding Temperature as function of pressure and entropy in Mathematica

While Mathematica's ThermodynamicData[] is very useful, is there a method in Mathematica to find Temperature as a function of Pressure and Entropy? ThermodynamicData[] allows only functions of P and T.

• I am not a Physics major, but I am curious, before computers came along (say 100 years ago), how did people find temperature as a function of Pressure and Entropy? Is there no formula for this? – Nasser Mar 7 at 13:38
• You can use Legendre transformations for this purpose – user740332 Mar 7 at 16:09
• What do you mean by "ThermodynamicData[] allows only functions of P and T"? Code like ThermodynamicData["Water", "Temperature", {"Entropy" -> Quantity[30, "Joules"/("Kelvins" "Kilograms")], "Pressure" -> Quantity[100, "kPa"]}] just works as expected. – xzczd Mar 8 at 2:10

You could create your own interpolation function from a table of ThermodynamicData. The following creates an interpolation function, $$Tfun=Tfun(P,S)$$:

pst = Table[{{10^i,
QuantityMagnitude@
ThermodynamicData["Water",
"Entropy", {"Temperature" -> Quantity[j, "DegreesCelsius"],
"Pressure" -> Quantity[10^i, "Bar"]}]}, j}, {i, -2, 3,
0.2}, {j, 50, 800, 50}];
Tfun = Interpolation[Flatten[pst, 1]];
Plot[Tfun[p, 5000] + 273.15, {p, 0.1, 1000}] Another approach to get what you seek is based on @Carl Woll's answer 198506.

Clear[TfunFRB]
TfunFRB[p_, s_] := Module[{f},
f[t_?NumericQ] :=
QuantityMagnitude@
ThermodynamicData["Water",
"Entropy", {"Pressure" -> Quantity[p, "Bars"],
"Temperature" -> Quantity[t, "DegreesCelsius"]}];
t /. Quiet@FindRoot[f[t] == s, {t, 50, 800}, Method -> "Brent"]]


Here is an example:

TfunFRB[1, 7500]
(* 126.347 *)


This compares favorably to what can be found with online calculators such as can be found here • Thank you both. The function will be very useful. I am guilty of seeking a quick answer. It's been two decades since Uni and whilst I know I need to review, time is the issue. - thanks for the explanation and links. – Chris B Mar 8 at 20:35

Look for an text of introduction into Thermodynamic potential. There is the concept of natural variables. There are $$S$$, $$p$$, $$T$$, $$N$$ and $$V$$. There are the so names intensive parameters $$p$$, $$T$$ and $$V$$. This are considered somewhat more fundamental by the designers of Mathematica.

The example finishing section of the documentation page for ThermodynamicData about the Joule-Thompson Coefficient. This concepts allow to transfor the depence on $$p$$, $$T$$ in some of the other natural variables. These partial derivatives are replace by the Maxwell relations or Euler relations or other thermodynamic relations depending on the given problem.

The tasks are then to transform all that into a sole dependence on $$p$$, $$T$$ if it is needed to work with Mathematica ThermodynamicData. The thermodynamics themself garanty at moderate equilibrium conditions that the rewrite into a dependence on $$p$$, $$T$$ is for sure or approximately possible to engineering or technical needs.

This question for example: find a temperature from enthalpy. Another one get temperature given pressure and enthalpy. As the wikipedia page shows it is always a matter of the reduction the author make what information is easily accessable and what not.

There are introductory overview available on the internet: Or this chapter relating pressure volume amount and temperature the ideal gas law with some example of importance and a teaching style and exercises. from entropy. Mind that entropy is usually important if there are states to compare or mass exchanges entropy and work. Make sure that You identify which of these

"IsenthalpicJouleThomsonCoefficient" temperature change due to pressure at constant enthalpy

"IsentropicExpansionCoefficient" heat capacity ratio

"IsobaricHeatCapacity" heat capacity at constant pressure

"IsochoricHeatCapacity" heat capacity at constant volume

"IsothermalBulkModulus" bulk modulus at constant temperature

"IsothermalCompressibility" volume change at constant temperature

"IsothermalExpansionCoefficient" expansion due to temperature at constant pressure

"IsothermalThrottlingCoefficient" isothermal throttling coefficient

apply and use the appropriate formulas. The documenation page for ThermodynamicData show the Mollier diagrams $$T(S)$$ temperature and $$p(S)$$pressure agains entropy. Have a look at the Mathematica demonstrations for some examples: TemperatureEntropyDiagramForWater. There are over 4 pages of demonstrations for entropy.

It is a fundamental and elementary knowledge that the four intensive parameters and natural variable are interchangeable and that selecting functions in $$p, T$$ is in general sufficient for all situation in thermodynamics. There situation were more information is needed than these. This information has to be added to the modellation but the internals remain valid. Most such influences add up. It is always important to consider the signs right and make equations for equilibria preferentially.

Thermodynamics considers states and changes and is successful in describin both. Such a general question requires a general answer and much to much open. It is usual in thermodynamics to consider change along pathes of states curves were only one intensive parameter or natural variable is changed and the others are kept fixed. The built-in ThermodynamicData offers data that is sufficient to describe all the possible pathes and modellation ansatzes. It is highly capable. Despite that there is always a choice made and approximations may be unavoidable that might not be wished.

Therefore for a proper scientific work with Mathematica a critics of the data offered be ThermodynamicData is needed. This seems the appropiate first page to visit for such purposes: ThermodynamicData Source Information. So this is to cite:

Wolfram|Alpha curated data, 2020.

Lemmon, E.W., Huber, M.L., McLinden, M.O. NIST Standard Reference Database 23: Reference Fluid Thermodynamic and Transport Properties-REFPROP, Version 9.1, National Institute of Standards and Technology, Standard Reference Data Program, Gaithersburg, 2013

and Wolfram Inc. gives You an address where to complain, message the Wolfram Research ThermodynamicData team.

• (-1) Once again, I can't find a single line answering OP's question in this long answer. – xzczd Mar 8 at 1:42