usnistgov / REFPROP-wrappers

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

REFPROP Convergence problem - High temp, high water content combustion products #320

Closed aquasweep closed 4 years ago

aquasweep commented 4 years ago

REFPROP does not seem to converge property calculations (such as enthalpy or entropy given pressure and temperature) in high-temperature, single phase ranges. This happens with relatively high water content but counter intuitively it works in lower temperature ranges closer to saturation Error message indicates two phase iteration problem. This seems very odd since the convergence problem only occurs when temperature is an input. Inverse calculation such as temperature from pressure and enthalpy works fine. Example: Combustion products with relatively high water content Composition: D$8:= Nitrogen;Argon;CO2;SO2;Water|.7;.0083;.0973;0;.1944 Function: REFPROP("H",D$8,"PT","e",14.69,2700) Result #[TPFL2 error 226] 2-phase iteration did not converge. Refprop convergence.xlsx

ianhbell commented 4 years ago

Have you tried to enable the saturation splines? In some but not all cases that improves convergence of challenging mixtures, including those containing water.

aquasweep commented 4 years ago

Hi Ian No I have not tried satspln yet…. I will investigate now, thank you. I would be very surprised if this issue (and an associated common “fix”) didn’t surface yet as this is a most common natural gas/air combustion product, close to stoichiometric condition. I assume that this is similar to the Humid Air issues (and why COOLPROP is much more robust with high water content mixtures) Peter

ianhbell commented 4 years ago

Mixture flash calculations are very challenging, there is just no getting around that. The approach used in CoolProp for humid air is much simpler, so therefore is much more reliable.

Are your inputs definitely gaseous? If so, you can try to specify the phase, which can sometimes help.

aquasweep commented 4 years ago

Hi Ian As I mentioned, this is a very common natural gas combustion problem where the oxidizer is ambient (humid) air and the combustion is at or close to stoichiometric conditions The adiabatic flame temperature is over 3000 F (at atmospheric pressure) so I am pretty sure that the combustion product mixture is in gaseous phase – very far from saturation I have also tried to search for the SATSPLN in the VBA . This is the only spot I found in the VBA but removing the comment apostrophe did not solve the problem

        'The line below sets a flag to call SATSPLN to use splines for the saturation states of the mixture.  This then allows the calculation of the
        'true critical point, maximum temperature, and maximum pressure at saturation (for the composition in z).  This call can be slow (0.1 to 2 seconds per call)
        'and is best used in a separate xls file for a dedicated mixture.  The spline routine is called when the fluids are/or compositions change.
        'If the spline calculations are desired, it is best to leave this flag always on when calling the REFPROP routine.
           'iFlag = 1
ianhbell commented 4 years ago

Can you use an environment like Python or MATLAB? Much easier to interface with the DLL and do more complicated operations like selectively enabling saturation splines.

I tried your example in Python (below), and cannot reproduce the behavior you see. A warning message that I see indicates that the temperature is above the maximum temperature of the model, though a value is returned.

from ctREFPROP.ctREFPROP import REFPROPFunctionLibrary

root = 'D:/Program Files (x86)/REFPROPalpha'

RP = REFPROPFunctionLibrary(root)
RP.SETPATHdll(root)

components = 'Nitrogen;Argon;CO2;SO2;Water'
composition = [0.7,0.0083,0.0973,0,0.1944]

for iFlag in 0,1:
    r = RP.REFPROPdll(components, "PT", "H", RP.ENGLISH, 0, iFlag, 14.69, 2700, composition)
    print(r.Output[0], r.herr)

yielding

1084.1893891366271 [TPFLSH warning -1] One or more inputs are out of range; Temperature above upper limit: T = 1755.37 K, Tmax = 1606.94 K.
1084.1893891366271 [TPFLSH warning -1] One or more inputs are out of range; Temperature above upper limit: T = 1755.37 K, Tmax = 1606.94 K.
EricLemmon commented 4 years ago

I've transferred your issue to the Refprop-wrappers github site.

EricLemmon commented 4 years ago

Can you send Ian or me a personal email (ian.bell@nist.gov or eric.lemmon@nist.gov)? This seems to be fixed, I just tried it here with the code below. We'll send you the current beta version for you to try.

  i=iGetEnum(0,'english')
  hfl='Nitrogen;Argon;CO2;SO2;Water|.7;.0083;.0973;0;.1944'
  call REFPROP(hfl,'  ',' ',i,0,0,2700d0,14.69d0,z,
 &      Ou,u,iU,x,y,x3,q,ierr,herr)
  call REFPROP(' ','PT','H',i,0,1,2700d0,14.69d0,z,
 &      Ou,u,iU,x,y,x3,q,ierr,herr)
aquasweep commented 4 years ago

Version 10.0.0.78 resolved the issue... thank you