Open miloknowles opened 1 week ago
In my experience, the Peng Robinson equation of state is mostly meant for gaseous solutions. The MixtureFugacityTP class is the one responsible for deciding phase information. Unfortunately, I believe that class is incomplete and mostly the gas information is what it uses.
I think a better handling of the detection of the saturation temperature is what would be needed. The Gibbs balance between the liquid and vapor phases would allow for a better selection of the vapor or liquid solution. One thing is that I don't think any two-phase solutions are permitted currently.
@wandadars is correct - in its current form, Cantera is not set up for two-phase Solutions (outside of pure substances). Peng-Robinson et al are currently implemented to capture real gas behavior only. There are, however, some known glitches with the cubic solver, see #1699 or #1157, so logic improvements would be welcome. Beyond, all phases are implemented in C++ only; Python only serves as a more user-friendly interface, and does not provide access to all internal functions.
PS: apart from that, it does appear that some exception handling would be beneficial to indicate when the state can no longer be represented correctly.
Problem description
When creating a
Solution
for methanol using aPeng-Robinson
equation of state, the incorrect density (off by orders of magnitude) is returned at temperatures and pressure where we'd expect methanol to be in a liquid phase. For example, at a TP of(300, 101325)
, I see a density of~1.3 kg/m3
, whereas liquid methanol would be around~780 kg/m3
.Digging into the C++ code, it appears that there is some logic to "force" a certain solution to the cubic equation of state when multiple are found. However, I don't see any Python interface for doing that. In general, it's unclear whether a solution using the Peng-Robinson equation of state will reliable detect whether a fluid is in the liquid or vapor phase, and there doesn't seem to be a way to "help" the solver find the right density. If you can point me in the right direction, I'd be happy to work on a PR that addresses this issue.
Steps to reproduce
Using the following YAML file:
I load a
Solution
using Python:Printout:
Behavior
As you can see, the density is very low (indicating a gas) even at temperatures below the boiling point of methanol. Expected values are shown as comments to the right of each line. I haven't debugged the C++ code to confirm this, but I suspect that there are multiple roots of the cubic polynomial, and the one corresponding to a gas phase is being returned.
System information
Cantera
3.0.0, installed withpoetry
Attachments
Additional context