DanWBR / dwsim

DWSIM is a Steady-State and Dynamic Sequential Modular Chemical Process Simulator for Windows, Linux and macOS.
https://dwsim.org
GNU General Public License v3.0
287 stars 92 forks source link

Phase envelope and hydrate curve not working with PR #416

Closed mohamedmovahed closed 1 year ago

mohamedmovahed commented 1 year ago

Phase envelope worked in the previous version (8.3.2). Sample file based on Phase Envelope and Hydrate Curve_Simple Hydrocarbon Mixture.zip a simple hydrocarbon mixture is attached.

DanWBR commented 1 year ago

@mohamedmovahed your case didn't work in v8.3.2 either... it is not handling water in the mixture - it got broken somewhere in the middle

mohamedmovahed commented 1 year ago

Thanks Daniel. Phase envelope doesn't appear to return sensible results on dry basis either. I have removed water from the simple mixture and you can see the results in the attached sample file. Hydrate dissociation curve is a different matter, as it is function of water content when mixture is undersaturated with water Simple HC Mixture Dry Basis Phase Envelope & wet basis hydrate curve_PR78.zip . Once water is included in the mixture, DWSIM does not converge on either hydrate curve or phase envelope.

DanWBR commented 1 year ago

@mohamedmovahed I'll have to work on this as soon as possible.

mohamedmovahed commented 1 year ago

Phase envelope still does not seem to work with any PR EoS variation, but works with SRK. See attached. The problem is that if phase envelope does not converge, then any flash with PR may not be reliable. Simple Dry HC Mixture Phase Envelope with PR.zip

DanWBR commented 1 year ago

Phase envelope still does not seem to work with any PR EoS variation, but works with SRK. See attached. The problem is that if phase envelope does not converge, then any flash with PR may not be reliable. Simple Dry HC Mixture Phase Envelope with PR.zip

@mohamedmovahed the problem, in this case, is in the critical point calculation. I'll take a look.

I'm sorry but your conclusion about the flash with PR is not correct. doing a single flash calculation is much simpler than building an entire phase envelope. there are many different procedures to build a phase envelope - I chose to calculate the critical point using a separate procedure and then use it as the endpoint for the dew and bubble curves. If you check your case with PR, you'll see that the curves were calculated correctly - they just didn't know where to stop:

Captura de Tela 2023-02-03 às 08 24 19
mohamedmovahed commented 1 year ago

Thanks very much Daniel for the clarification. I am somewhat familiar with theoretical basis for both density-based and volume-based phase envelope construction methods. I got the attached output, which probably if I reduced the pressure scale, I would get the same plot as yourself. However, as you can see in the plot in the attached file, the critical point is so off the mark that I assumed there is a convergence issue with K value or density calculations at very low vapour fraction (bubble point curve) or very low liquid fraction (dew point curve), and hence the comment regarding stability of flash calculations with PR. Output.zip

DanWBR commented 1 year ago

@mohamedmovahed yes the CP is very off. The weird thing is that if you reduce the propane amount just a little bit it is able to calculate the correct CP.

The CP calculation is totally different from flash calculations... it is very prone to round-off errors, though I can put some fail-safe checks to avoid the issues we are discussing here. Here's the reference paper if you're interested: https://aiche.onlinelibrary.wiley.com/doi/abs/10.1002/aic.690260510

And here is my implementation: https://github.com/DanWBR/dwsim/blob/windows/DWSIM.Thermodynamics/PropertyPackages/Models/TrueCriticalPoint.vb#L31

DanWBR commented 1 year ago

Critical Point calculation added for PR78 and fixed for PR/SRK in https://github.com/DanWBR/dwsim/commit/b7dd0742368ab9dbdda345dad1c6876644178097

mohamedmovahed commented 1 year ago

Hi Daniel, Still struggling with phase envelope. It just doesn't run. See attached. I have used a simplified composition. Phase envelope_FPSO Simplified Export Gas.zip

DanWBR commented 1 year ago

@mohamedmovahed you have some customization options to play with:

Captura de Tela 2023-03-19 às 16 19 42