usnistgov / REFPROP-wrappers

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

Refrigerant:air mixtures not supported / validated #209

Closed ajrj2 closed 5 years ago

ajrj2 commented 5 years ago

Description

I recently purchased REFPROP 10 to calculate the speeds of sound of a few air:refrigerant mixtures, including air and R32, for example. Unfortunately, it seems that the fluids in these mixtures are too dissimilar and there is not enough confidence in the interaction parameters to produce accurate results. Or, at least, this is my interpretation of the error messages received:

  1. When using the python wrapper CoolProp, I receive the error message 'ValueError: Could not load these fluids: R32|N2'. This occurs when I attempt to calculate the speed of sound of an air (or N2 in this case):R32 mixture. There is no error when initialising the mixture. Relatedly, I can successfully calculate the speed of sound of a pure R32 gas, as well as a binary mixture of two refrigerants. So I expect this is an issue with the specific mixtures I am investigating, rather than the code base or my code itself.

  2. When investigating in the REFPROP desktop application instead, the same N2:R32 mixture cannot be made and the following error message is generated:

'Mixture data have not been fitted for one or more binary pairs in the specified mixture; the mixture is outside the range of the model and calculations will not be made.'

Interestingly, when I try generating this mixture for a second time after closing this error message, I can calculate speed of sound estimates, albeit understanding that the model that produces these estimates is not validated.

My application does not require super high accuracy; +/- 1% speed of sound is fine over the operating range, which is ~ up to 15% refrigerant concentration by volume in air, and from ~ 240 to ~320 K, at or slightly below ambient pressures.

Ultimately, my question is: is there a way to make REFPROP via the python wrapper work for this use case? While accepting, and having an understanding of, the degree of potential inaccuracy in the model.

Thanks,

Adam

Versions

REFPROP Version: 10** [REFPROP version you are using]
Operating System and Version: Windows 10
Access Method: Python (and the desktop application)

Additional Information

None.

ianhbell commented 5 years ago

Hi Adam,

This is a tricky one.... NIST's databases do not contain any experimental data for this mixture (see https://trc.nist.gov/thermolit/main/home.html#property/syssel:2:info;difluoromethane:info;nitrogen:form/props:1:0:0), so we have no way of even validating our most common estimation schemes. I think 1% in speed of sound is unlikely to be within our capabilities.

This mixture is very asymmetric, so you should expect lots of "weird" mixture thermodynamics to rear their heads (open phase envelopes, etc.). If you are near atmospheric pressure, in the gas phase, it might not be a TERRIBLE thing to use one of the standard mixing rules (Lorentz-Berthelot or linear mixing), but you need to be aware of the caveats that come along with this approach.

It is possible to adjust mixture models at runtime through the python interface, but this is a fairly advanced topic. I can provide more info on this topic if it interests you. A simpler approach might be to set the parameters for REFPROP through CoolProp, that's only a couple of lines of code.

ajrj2 commented 5 years ago

Hi Ian,

Thank you for the quick response. I think that this is what I expected, but appreciate it coming from someone more knowledgeable in the field.

I've managed to implement the simple mixture models in python using CoolProp as you suggested, and am content progressing those for now. It's convenient that the conditions I'm interested in are typically gas phase at or below ambient pressures.

Hopefully this is the issue closed for now.

Adam

ianhbell commented 5 years ago

Sounds good to me, go ahead and close the issue then.

But be warned - I still remain very skeptical of any values coming from this approach.

ajrj2 commented 5 years ago

Actually, I've not managed to successfully implement the simple mixing rules with an R32:N2 mixture. I have done so successfully with CoolProp and the HEOS backend, but I cannot get it to work when trying to access REFPROP instead.

Please see the attached notebook for details. In this notebook, I'm following a very similar example to here:

When I try to create output speed of sound, I get a ValueError, stating; 'Initialize failed for backend: "REFPROP",...,Could not load these fluids: N2|R32'.

I can circumvent this by setting the configuration variable 'REFPROP_IGNORE_ERROR_ESTIMATED_INTERACTION_PARAMETERS' to True, but I think this actually bypasses the option to use user-estimated interaction parameters in the first place?

What were the couple of lines of code you were suggesting?

Regards,

Adam Rerigerant_mixture_issues.zip

ianhbell commented 5 years ago

Hmm.. this is is sort of a bug in CoolProp, but readily fixed. In the development version of CoolProp, this option was added:

CP.set_config_int(CP.REFPROP_ERROR_THRESHOLD, 1000) # This is a bad idea in general

to control what is considered an error. But it looks like I overlooked fluid loading (threshold is hardcoded at zero), so I'll need to make that change inside CoolProp. In the meantime, you could also take this approach: https://github.com/ianhbell/binfit/blob/master/binary_fitter.py#L147-L155 with the new direct Python interface of REFPROP.

ajrj2 commented 5 years ago

Okay, thanks again. I've moved over to the new python interface, and can spit out the numbers I'm interested (whether not they are sensible -TBD). Fingers crossed that this is it for the meantime!

Adam