usnistgov / REFPROP-issues

A repository solely used for reporting issues with NIST REFPROP
26 stars 13 forks source link

Thermodynamic tables for a mixture of hydrogen (54.19%), nitrogen (26.32%) and water (19.49%) #677

Closed JanAnker closed 1 month ago

JanAnker commented 2 months ago

#Description

Using refprop, we have been trying to generate thermodynamic tables for a mixture of hydrogen (54.19%), nitrogen (26.32%) and water (19.49%) for the following pressure and temperature ranges:

 p=[50Kpa:1000KPa],    T=[320K:360K]

Unfortunately, we have been encountering several issues. Which method would you suggest that we use to generate thermodynamic tables for this mixture? Will refprop be able to correctly account for the real-gas effect of our mixture or do we have to assume that there will be large approximations?

Would it be an approach to first generate a thermodynamic table for each individual species and simply create a table for the mixture by mass-averaging the tables for the individual species? One would thereby neglect the real-gas effects; we are aware that the error of doing so could be large (e.g., if the mixture is azeotropic).

Any advice on how to best proceed to generate thermodynamic tables for binary and tertiary mixtures would be highly appreciated.

### Steps to Reproduce

We see home holes in the tables. The saturation line only contains 6 of 100 points due to issues with convergence.

Expected behavior:

Convergence for all states

Actual behavior:

Not convergence for all states

Versions:

Refprop 10.0

Operating System and Version: LINUX

Access Method:

Own wrapper written in C++

nist-aharvey commented 2 months ago

Some partial comments: 1) It looks like your mixture is in a range where many (maybe most) of the points would be in a vapor-liquid equilibrium state, with a liquid phase that is mostly water in equilibrium with a gas phase. 2) For a 2-phase system, it would make no sense at all to do averaging of pure-component properties. That might not be totally unreasonable if everything was only in the vapor phase, but that's far from being the case here. 2a) Mass averaging is generally not a good approach -- if you are doing mixing in thermodynamics it is best to do everything in terms of moles, not mass. 3) Convergence of vapor-liquid equilibrium calculations is typically very difficult for water-gas mixtures. @ianhbell may have some thoughts about better ways to get converged calculations. 4) Here's a rather roundabout way that MIGHT help as a last resort. For your system, it would be reasonable to assume the liquid phase is pure water. So you just need to figure out the composition of the vapor phase, which is a dew-point calculation. So you can iteratively try different water mole fractions in the vapor (say, starting with the 0.1949 in your original mixture and getting smaller) until you get one that gives you a dew point at your tabulated point of interest. Then a material balance will tell you how much water is in the liquid phase. This assumes that the dew-point calculation converges, but those may have similar convergence problems to the vapor-liquid equilibrium calculations you are already doing. 4a) Dew-point calculations can fix T and look for the dew-point pressure, or fix P and look for the dew-point temperature. You could try both; it might be that one has better convergence behavior than the other. 4b) If this dew-point calculation establishes that a particular point is entirely in the vapor phase (because your original 0.1949 water mole fraction does not reach its dew point until lower T or higher P than your table point), then there might be a way to tell REFPROP to do a one-phase calculation at T and P and not look for phase equilibrium; again @ianhbell might know.

ianhbell commented 2 months ago

@nist-aharvey is right - such a mixture is VERY difficult to model. Not only that, given the extreme asymmetry between the molecules, the algorithms in libraries like REFPROP are VERY difficult to get to converge for such mixtures. You have picked close to a worst-case mixture I could dream up; replacing hydrogen with helium would be worse.

About the only help I can propose is to :

  1. Ensure that the saturation splines are enabled by calling SATSPLNdll.
  2. Extract the saturation curve with SPLNVALdll
  3. Manually check whether your state point is inside or outside the isopleth of the phase envelope
  4. Use the single-phase routines if outside (the ones that end in FLSH1)

Otherwise, you might need to do rootfinding (solving for the temperature, density pair) yourself. This is definitely possible, but not for the faint of heart. There are routines in boost (for C++) for rootfinding, but they too require some expertise. I am working on a solution for the rootfinding problem in general for mixtures of fixed composition which would be helpful for a case such as yours, but the code is not finalized yet. It is written in C++.