Thanks Ray. I'm looking through the MixtureFugacityTP class, and I notice that is some coding that uses the gibbs energy of the equation of state to determine the saturation pressure from a given temperature. It seems like maybe this class was going in that direction as some point?
The original algorithm in the ThermoPhase::setState_HPorUV takes in the P and H and first sets the density of the state using setPressure. Then it tries to find a temperature that generates the same enthalpy as the input value, H. And then sets this to be the temperature. This seems to work fairly fine. But it does struggle when even getting anywhere close to the two-phase dome(from the example the density starts of oscillate between vapor and gas even before getting to the saturation point).
I was thinking about making the following tweak by having the MixtureFugacityTP class override the setState_HPorUV() to use the following approach:
1.) Take Pressure from the input argument.
2.) Compute the saturation temperature at the given pressure.
3.) Using the pressure and saturation temperature, query the cubic eos to get the liquid and vapor enthalpies.
4.) Compare the input enthalpy to see if it lies between the liquid an vapor values, if so the system is two-phase.
5.) If the system is two-phase, then set the temperature to the saturation temperature.
6.) Use the liquid/vapor enthalpies to determine quality and then use that quality to estimate the density.
7.) Store the density of the mixture.
8.) If the enthalpy is outside of the bounds, then go back to the standard temperature iteration algorithm that was originally implemented.
Does this seem like a fundamentally unsound approach?