usnistgov / REFPROP-wrappers

Wrappers around NIST REFPROP for languages such as Python, MATLAB, etc.
193 stars 127 forks source link

[PHFLSH error 224] dew point calculation did not converge within 2-phase iteration: SATTP error: Density roots equal #515

Closed Francesco983 closed 1 year ago

Francesco983 commented 1 year ago

Hi everyone, I have a problem with REFPROP in Matlab. I modeled a methane liquefaction plant using a mixed refrigerant (composition in the code line), this error is shown during the simulation:

[PHFLSH error 224] dew point calculation did not converge within 2-phase iteration: SATTP error: Density roots equal

refering to:

[T_11c, X_11c] = refpropm('TQ','P',P_11c,'H',h_11c, 'nitrogen', 'methane', 'ethane', 'propane', [0.0521 0.1402 0.1405 0.6672])

where P_11c (P_11c = 1.113 bar) is fixed and h_11c is updated at each iteration. Initially, the simulation goes, but when the enthalpy is equal to 134.18 kJ/kg, this error appears. In the penultimate iteration, the enthalpy is equal to 187.12 kJ/kg and the simulation goes. Using these values for P (P_11c = 1.113 bar) and H (h_11c = 134.18 kJ/kg) on REFPROP, the required values are given, then what can be the problem in Matlab?

This is my first time creating an issue on GitHub, I hope I followed the rules and was clear. Thanks to whoever will answer, Francesco

REFPROP Version: [REFPROP version 9.1]
Operating System and Version: [Windows 10]
Access Method: [MATLAB R2021b]

ianhbell commented 1 year ago

The refpropm interface is no longer supported. You need to upgrade to the Python interface version for MATLAB.

Then, you can call the SATSPLNdll function to force the isopleth of the phase envelope to be built. That helps for a lot of cases like this.

Francesco983 commented 1 year ago

@ianhbell Thanks for the reply. How does the SATSPLNdll function fit in this case? Here's the code line below [T_11c, X_11c] = refpropm('TQ','P',P_11c,'H',h_11c, 'nitrogen', 'methane', 'ethane', 'propane', [0.0521 0.1402 0.1405 0.6672])

ianhbell commented 1 year ago

First step: convert to the python interface

Francesco983 commented 1 year ago

Already done

ianhbell commented 1 year ago

Please show me your code that you are running with the Python interface.

Francesco983 commented 1 year ago

I connected Python to Matlab and installed ctREFPROP as suggested in this issue https://github.com/usnistgov/REFPROP-wrappers/blob/master/wrappers/MATLAB/README.md then I check the practical example, but it doesn't run, becauce also I don't understand that I didn't understand how it is implemented via python coding.

ianhbell commented 1 year ago

We don't really support version 9.1 anymore, the version 10 has a lot of new features and a new more friendly programming interface. The examples are all for version 10.0, using the new functions.

ianhbell commented 1 year ago

In version 10.0, both of your calculations work:

import os
os.environ['RPPREFIX'] = os.getenv('HOME')+'/REFPROP10'

import ctREFPROP.ctREFPROP as ct
root = os.getenv('RPPREFIX')
RP = ct.REFPROPFunctionLibrary(root)
RP.SETPATHdll(root)
print('version:', RP.RPVersion())

imass = 0
z = [0.0521, 0.1402, 0.1405, 0.6672]
P = 1.113e5

for h in [187.12e3, 134.18e3]:
    r1 = RP.REFPROPdll('NITROGEN;METHANE;ETHANE;PROPANE','PH','T',RP.MASS_BASE_SI,imass,0,P,h,z)
    print(r1.Output[0:1], r1.ierr)

yields

version: 10.0
array('d', [208.60055889815573]) 0
array('d', [200.99859910490193]) 0
Francesco983 commented 1 year ago

So, I need to switch to version 10, is there an accademic version for students at a discounted price? Anyway, thank you so much!🙏

ianhbell commented 1 year ago

No, I am afraid there isn't an academic version