usnistgov / REFPROP-wrappers

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

Problem calculating compressibility factors for blends of natural gas and hydrogen #617

Open Nico574677 opened 1 month ago

Nico574677 commented 1 month ago

Hello,

I am using Refprop 10 and would like to calculate data for mixtures of Amarillo (natural gas) and hydrogen. I am using the ctREFPROP package for python.

I am interested in the compressibility factor Z, dynamic viscosity VIS, isochoric heat capacity CV, isobaric heat capacity CP and the gas constant R. How do I calculate these values for mixtures?

When I define the mixture and calculate the values like Z, VIS etc. using RP.REFPROP2dll, I get the same values as when I calculate the values only for Hydrogen.

My code looks like that: e.g. for the compressibility factor Z:

from ctREFPROP.ctREFPROP import REFPROPFunctionLibrary RP = REFPROPFunctionLibrary(os.environ['RPPREFIX']) RP.SETPATHdll(os.environ['RPPREFIX']) MOLAR_BASE_SI = RP.GETENUMdll(0, "MOLAR BASE SI").iEnum

z = RP.REFPROP2dll(hFld=fluids_mixture, hIn='TP', hOut='Z', iUnits=RP.GETENUMdll(iFlag=1,hEnum='SI WITH C')[0], iFlag=1, a=t, b=p, z=blend_mole_fracitons)[1][0]

fluids_mixture is a string: fluids_mixture = 'METHANENITROGENCO2ETHANEPROPANEISOBUTANBUTANEIPENTANEPENTANEHEXANEHYDROGEN' blend_mole_fracitons is an array: blend_mole_fraciton = [8.160516e-01, 2.815560e-02, 4.208400e-03, 4.075110e-02, 7.452000e-03, 9.333000e-04, 1.406700e-03, 2.889000e-04, 3.987000e-04, 3.537000e-04, 1.000000e-01] This is a blend with 10 % Hydrogen. t and p are values for the temperature and pressure of interest.

The command above leads to the same result as for pure hydrogen: z = RP.REFPROP2dll(hFld= 'hydrogen', hIn='TP', hOut='Z', iUnits=RP.GETENUMdll(iFlag=1,hEnum='SI WITH C')[0], iFlag=1, a=t, b=p, z= [1])[1][0]

Both commands lead to the same results.

Can you tell me how I can calculate the correct values for the blend?

Thanks in advance

ianhbell commented 1 month ago

Please provide the values of T and p and the output values, the value of ierr and herr. Also the SI_WITH_C is exposed on RP so you don't need to do the GETENUMdll call as that is done for you already

nist-aharvey commented 1 month ago

It might also be worth trying a simpler calculation with just a mixture of hydrogen and methane. The heavier components in the natural gas could (depending on pressure and temperature) put you close to (or inside) the 2-phase region, where calculations involving hydrogen can have serious difficulty converging. That would tell you whether the problem is in your usage (if it still happens with H2+CH4), or if it is a problem with convergence of the thermodynamic calculation (if it is triggered by the presence of heavier components).