usnistgov / REFPROP-wrappers

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

Convergence of calculation of internal energy(pressure, density) case hydrogen #575

Closed ELBAAMRANI closed 5 months ago

ELBAAMRANI commented 10 months ago

If you have an issue to report, please continue and fill out the applicable sections below. The details provided will help to resolve this issue as quickly as possible.

Prerequisites

NOTE: Be aware that all issues are publicly accessible and viewable. Thus please do not post any code or other content that is protected intellectual property or under copyright.

Before posting an issue, please:

You can also use markdown to format your issue: GitHub guide on Markdown. If you have code snippets, please use a code block to ensure that the formatting remains legible in the web interface. For instance, surround your code in triple backticks:

print('Hello world!')

Description

I have a problem of Convergence of calculation of internal energy(pressure, density) case hydrogen. I use Refprop under Excel '=@Energy($B$1;"PD";"Molar SI";$B$7;Q14) P = 700 MPa: pressure D = [37 to 15] liquid density kg/m3

Steps to Reproduce

  1. [First Step]
  2. [Second Step]
  3. [and so on...]

Expected behavior: [What you expect to happen]

Actual behavior: [What actually happens]

Versions

REFPROP Version: [REFPROP version 10]
Operating System and Version: [Windows 11 are running REFPROP on]
Access Method: [How you are accessing REFPROP (Excel)

Additional Information

I had the same problem using Refrop 9.1 Hydrogen InternalEnergy

Many Thanks

ianhbell commented 10 months ago

I am struggling to reproduce your problem. Please give me a single output that is failing, with units. Right now you are mixing density units as far as I can make out

ELBAAMRANI commented 10 months ago

I appreciate your quick response. I whant to calculate liquid density in function of pressure and density for the Hydrogen fluid. I use under Excel this call : @.***($B$1;"PD";"Molar SI";$B$7;Q14) B7 = pressure = 700 MPa Q14 = liquid density = @LiquidDensity($B$1;"Tliq";"Molar SI";Q12;0) For Tliq = Q12 = 23.8225 K ==> Q14 = liquid density = 32.965041 ==> Internal Energy = 32817.702 ==> OK And for Tliq = 24.42 K ==> Q14 = liquid density = 32.515925 ==> Internal Energy NOK [Une image contenant texte, capture d’écran, ligne, Police Description générée automatiquement] And the same problem for Tliq = 24 to critical temperature = 33.145 K

ianhbell commented 10 months ago

Please provide units for all quantities. You'll want to respond in the web client to attach images

ELBAAMRANI commented 10 months ago

OK Pressure : MPa Temperature Tliq : K Liquid density : kg/m3 Internal Energy = KJ/kg Thanks

ianhbell commented 10 months ago

The density units I don't think are kg/m^3. I think they are mol/dm^3, no?

ELBAAMRANI commented 10 months ago

Oups, I'll check But any way, I call the functions assuming that the unit is respected My main input is the temperature (K) and the pressure (MPa) , the rest I suppose use the right units

ELBAAMRANI commented 10 months ago

I can send you the Excel file I use if you want.

ianhbell commented 10 months ago

I see the problem: your input is at too high a temperature for 700 MPa:

import os
import numpy as np 
import ctREFPROP.ctREFPROP as ct
os.environ['RPPREFIX'] = os.getenv('HOME')+'/REFPROP10'

root = os.getenv('RPPREFIX')
RP = ct.REFPROPFunctionLibrary(root)
RP.SETPATHdll(root)
print(f'version: {RP.RPVersion()}')

z = [1]

r1 = RP.REFPROPdll('HYDROGEN','TQ','D',RP.MOLAR_BASE_SI,0,0,23.8225,0,z)
print(r1.Output[0], r1.herr)
r1 = RP.REFPROPdll('HYDROGEN','PD','E',RP.MOLAR_BASE_SI,0,0,700e6,r1.Output[0],z)
print(r1.Output[0], r1.herr)

r1 = RP.REFPROPdll('HYDROGEN','TQ','D',RP.MOLAR_BASE_SI,0,0,24.42,0,z)
print(r1.Output[0], r1.herr)
r1 = RP.REFPROPdll('HYDROGEN','PD','E',RP.MOLAR_BASE_SI,0,0,700e6,r1.Output[0],z)
print(r1.Output[0], r1.herr)

yielding

version: 10.0
32965.04080455675 
32817.70218567939 [PDFLSH warning -1] One or more inputs are out of range; Temperature above upper limit: T = 1468.73 K, Tmax = 1000.00 K.
32533.65518846334 
33688.3616820967 [PDFLSH error 1] One or more inputs are out of range; Temperature above 1.5x(upper limit): T = 1504.52 K, Tmax = 1000.00 K.

The first one yields just a VERY high temperature that is already outside the temperature range, but not quite 1.5Tmax, so that is a warning only. The next one yields a temperature outside 1.5Tmax, which is an error

ELBAAMRANI commented 10 months ago

What I dont inderestand is that all inputs temperatures are between Tmin = 14.5 K and the critical temperature = 33.145 K

ianhbell commented 10 months ago

But not when you go to 700 MPa

ELBAAMRANI commented 10 months ago

Because I want to calculate the maximun internal Energy. That is why I use the maximum of pressure which is less than the pressure limit (2000000 kPa)

ianhbell commented 10 months ago

But you are outside the range of validity of the EOS, so you can't do it

ELBAAMRANI commented 10 months ago

Yes, In this case I try to extrapol But this introduce no consistency in the other calculations

ianhbell commented 10 months ago

I don't think there is anything else I can offer; you are doing something that is not supported in REFPROP

ELBAAMRANI commented 10 months ago

I Tank you for your help.