idaes-pse
idaes-pse copied to clipboard
Investigate behavior of IAPWS external functions at low enthalpies
As part of #848, it was discovered that the behavior of the IAPWS external function calls showed different behavior at low enthalpies on Linux and Windows.
The state conditions were: F: 100, P: 101325, h: 4000.
Under these conditions, the fluid is pure liquid, hence the vapor phase enthalpy is undefined. When this is retrieved from the external function call, Windows and Linux were providing different values four unsolved (and uninitialized) models; it was suggested that this value was a garbage value being returned by whatever was in memory at the time.
This is important as things like the reporting functionality retrieve the enthalpy values for each phase regardless of whether that phase is present or not, hence the need to have some standard, reasonable value for these.
In the external function, I know if a phase exists or not. In practice these things where a phase doesn't exist get multiplied by 0 in calculating the mixed phase properties. still it would be good to return a reasonable number. Ho do you feel about returning 1000 where a phase doesn't exist and a property is undefined? It would be nice to return NaN or something, but that would cause trouble solving the problem (depending on which form you use).
@eslickj I was thinking about what the return myself, and my first thought was NaN
as well (followed by recognizing the same issue you did). I think we want a value which is numerically safe but also clearly a placeholder; give than the value gets multiplied by zero in the actual model I think we should be able to get away with almost any value.
Some ideas I had:
- 1000, as good as anything
- 0, makes it clear it is a placeholder, but might have some unexpected issues with singularities
- -1000, not sure if the -ve sign makes it any clearer that this is placeholder, and might also have some unforeseen side effects.
Oh yeah and a lot of times -1000 is a totally valid enthalpy. Negative should be fine for a lot of things. Temperature and pressure shouldn't be an issue (vapor and liquid are the same). Probably is fine.
The external function and the IAPWS have been reworked several times sine this issue. I'm going to close this, but we can open a new issue if this comes up again.
Generally now the mixed phase properties are the most commonly used, and you'd want to avoid calling for specific phase properties if it can be avoided.
What happens now if you ask for properties of a phase that doesn't exist is this:
The pressure-temperature space is divided into quadrants by the critical temperature and pressure. In the supercritical quadrant the property functions for vapor and liquid return the same result which is properties for the supercritical fluid. In the quadrant where there can only be vapor the properties for vapor are returned even for liquid property functions. In the quadrant where there can only be liquid the liquid properties are returned even for vapor property functions. In the quadrant where vapor and liquid can exist, we solver for the density root of the phase even if it doesn't exist. This gives you a sort of fictitious property that extends nicely from where the phase disappears. This gives you a little buffer along the saturation curve and makes things easier to deal with for the solver.
If you use single phase properties, it's probably a good idea to have a post-solve check that the phase actually exists.