This likely is something basic that I am missing, but I am having trouble using and plotting ThermodynamicData in Mathematica. My attempts normally end up with: "Throw::nocatch: Uncaught Throw[$Failed,InvalidUnit] returned to top level."

This is the result from:

    temps = Table[t, {t, 1, 60}];
densities = ThermodynamicData["Water", "Density", {"Temperature" -> Quantity[temps, "DegreesCelsius"]}]

I get the same result with the cut/paste examples from the Mathematica ThermodynamicData built in function explanations. For example, when I try the following from the samples, I get the same result:

temps = Quantity[Table[t, {t, 1, 60}], "DegreesCelsius"];

densities = ThermodynamicData["Water", "Density", {"Temperature" -> temps}];
ListLinePlot[Transpose[{temps, densities}], AxesLabel -> Automatic]
  • results in "Throw::nocatch: Uncaught Throw[$Failed,InvalidUnit] returned to top level.".

I would expect the samples to work nicely.


This works, but not nicely in a function:

DensityFluid[temp_] := 
ThermodynamicData["Water", "Density", {"Temperature" -> Quantity[temp, "DegreesCelsius"]}]

Plot[DensityFluid[T], {T, 10., 65.}]

The issue with the above is the inordinate amount of time required to pull the detailed data instead of minimal point for a clean plot.

Best would be a way to pull data to the computer, then draw the Press/Temp lines when needed. CoolProp may be the solution here.

Any ideas would be greatly appreciated.


  • 1
    $\begingroup$ Let me first welcome you to Mathematica.SE. Your question is a good one, but you should consider to make it clear from the start that you are aware that single temperatures work as expected and what you are really interested in is finding a faster way to compute this for a list of temperatures. $\endgroup$
    – halirutan
    Jun 13 '18 at 11:18
  • $\begingroup$ Good point. I am actually interesting in following changing P and T through fluid cycling. Simple gases and single phase, so this is basically a look up function (assuming they have NIST tables as such). Yet the fact that the sample in their function explanation doesn't work on my system and the long time and internet dependence, it is proving a problem. $\endgroup$
    – Chris B
    Jun 14 '18 at 11:23

Your Answer

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

Browse other questions tagged or ask your own question.