Closed KayvanA closed 1 year ago
First you need to calculate the saturation densities with a function like SATT, then once you have them, you would call the low-level function that matches for each phase. For instance TRNPRPdll
for transport properties (https://refprop-docs.readthedocs.io/en/latest/DLL/legacy.html#f/_/TRNPRPdll), STNdll
for surface tension (https://refprop-docs.readthedocs.io/en/latest/DLL/legacy.html#f/_/STNdll), and THERMdll
(https://refprop-docs.readthedocs.io/en/latest/DLL/legacy.html#f/_/THERMdll) for most of the others.
Thanks for your reply, Ian.
I have been studying the Refprop documentation and I think I might have a few options. Which of the following methods is faster?
Method I) Use SATTdll to calculate density. Later use Would I be able to use (TRNPRPdll, STNdll, THERMdll) the other properties? Also, are these functions (TRNPRPdll, STNdll, THERMdll) for single phase only? Or can I use them to calculate these properties at the saturated liquid (x=0) and saturated vapor (x=1) points as well?
Method II) Make a single call to ALLPROPSdll to get all the desired properties in an array?
Method III) Call ABFLSHdll for (Tsat, Rho, H, Cp), Call STNddll for (sigma), Call TRNPdll for (mu, k). Still not sure if this method could be applied for both single-phasae and also saturated liquid (x=0) and saturated vapor (x=1) points.
Method IV) Call REFPROPdll for (Tsat, Rho, H, Cp), Call STNddll for (sigma), Call TRNPdll for (mu, k). Still not sure if this method could be applied for both single-phasae and also saturated liquid (x=0) and saturated vapor (x=1) points.
Method I) should be fastest because no string comparisons are being done (profile it yourself!) You are right, as the docs state, TRNPRPdll
and THERMdll
only calculates properly for single-phase inputs. In this context, saturated liquid states are considered to be single-phase properties but there are some subtleties that need to be considered for saturation properties.
Thanks, Ian. I saw that I can calculate (h and cp) via THERMdll. What function do you recommend to get saturation temperature as a function of pressure at (x=0) and (x=1)?
SATPdll
Thanks! Looks like that one is for saturated vapor temperature as a function of pressure. Is there a function for saturated liquid temperature as well?
For a pure they are the same. Please read the docs for this function: https://refprop-docs.readthedocs.io/en/latest/DLL/legacy.html in particular the kph
argument
Oops, my bad. I was looking at the description for TSATPdll instead of SATPdll.
I apologize!
Looks like SATPdll would also provide the saturated liquid and saturated densities, in Dl and Dv, respectively. That would help, because I would not have to call SATTdll to get the densities later.
However, the output density would be in mol/L . I would need the molar mass to eventually convert it to SI density (kg/m3).
I think you would recommend using WMOLdll to get the molar mass, am I correct?
Yes
Thank you for your help.
I have written a short code to test my Refprop calls for SATT and WMOL. It works for R32 as the refrigerant. However, when I use R410A it gives erroneous results.
I am calculating the saturated pressure of the liquid at 20C=293.15K :
I also noticed that WMOL is giving the correct molar mass value for R32, but it is erroneous for R410A.
Do you mind taking a look and let me know if I have made any mistakes? I will paste my code in the next comment.
subroutine test_call()
implicit none
integer, parameter :: ncmax=20,ipropmax=200
double precision dummy1(ncmax),dummy2(ncmax),dummy3(ncmax)
double precision x,y,xcalc,z(ncmax),Output(ipropmax)
double precision xx(ncmax), yy(ncmax)
double precision P,T,x1,x2,x3,h,hf1,hf2,hg,Tf,hf,error_Tf,Pf
double precision Dl, Dv
double precision T_calc_liquid, T_calc_vapor
double precision P_calc_liquid, P_calc_vapor
double precision P_kPa , wmm , WMOL
double precision rho_sat_l_1, rho_sat_v_1
double precision rho_sat_l_2, rho_sat_v_2
double precision error_P
integer iUnit,iMass,ierr,iFlag,iOut, kph , herr_length
character*255 hOut,herr,Refrigerant
herr_length = 255
Refrigerant='R410A'
!Refrigerant='R32'
iMass=1
call GETENUM(0,'MASS BASE SI',iUnit,ierr,herr)
! Set the Refrigerant in REFPROP
call REFPROP (Refrigerant,' ',' ',iUnit,iMass,0,0d0,0d0,z,Output,hout,iOut,dummy1,dummy2,dummy3,x,ierr,herr)
! Calculate the molar weight
wmm = WMOL(z) ! g/mol
!wmm = 72.58_8 ! Molecular weight of R410A
T = 20.0_8 + 273.15_8 ! Convert from Celsius to Kelvin
kph = 1
call SATT (T,z,kph,P_kPa,Dl,Dv,xx,yy,ierr,herr)
!Check SATT result against REFPROP1 result
x = 0_8
call REFPROP1('TQ','P',iUnit,iMass,T,x,z,P_calc_liquid,xcalc,ierr,herr)
error_P = P_calc_liquid - P_kPa * 1000_8
end subroutine
My guess is that I am not setting up the Refrigerant correctly in Refprop. Probably I should make another call to set up the refrigerant before calling SATT. Currently, I am setting the Refrigerant up via a call to Refprop:
call REFPROP (Refrigerant,' ',' ',iUnit,iMass,0,0d0,0d0,z,Output,hout,iOut,dummy1,dummy2,dummy3,x,ierr,here)
Is it possible that I would need an initial guess for pressure when I call SATT? The current result that I get is very close to the correct value, so the Newton-Raphson method should be able to converge to the correct value without the need for initial value.
Do you want R410A as a pseudo-pure fluid or as a predefined mixture? The approach differs just slightly depending on the answer.
If predefined mixture, you need to obtain the composition from SETMIXTUREdll (or elsewhere). If pure, z should be 1.0
For some reason I cannot connect to Internet on my laptop so I’m writing this from my phone:
I added the below line to my code after my call to GETNUM:
Call SETMIXTURE(Refrigerant, z, ierr)
I had to make sure the number of arguments match the subroutine in the SAT_SUB.for . The definition in Refprop pdf documentation is wrong: It has 1 too many arguments: h_MixNme_length
The code compiles fine now. SETMIXTURE gives ~0.698 and ~0.302 for the composition. However, I still get an erroneous result:
SATT returns 1447603 Pa REFPROP returns 1468571 Pa
Therefore, there is a 20967 Pa discrepancy between the two.
I also tried using ‘R410A.MIX’ instead of ‘R410A’ , but still got the same error.
Also, I tried using SETFLUIDS(Refrigerant, ierr) instead of SETMIXTURE but the results were way off.
What can I do to get the same value from both REFPROP and SATT calls?
Thanks, Kayvan
On Mon, Oct 24, 2022 at 4:44 PM Ian Bell @.***> wrote:
If predefined mixture, you need to obtain the composition from SETMIXTUREdll (or elsewhere). If pure, z should be 1.0
— Reply to this email directly, view it on GitHub https://github.com/usnistgov/REFPROP-issues/issues/551#issuecomment-1289015898, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD6LGHQKAVTEHIJG4M3PWSTWE2DSLANCNFSM6AAAAAARJDQNJ4 . You are receiving this because you authored the thread.Message ID: @.***>
-- All the best,
I did it in Python, same result with all three methods:
import os
import ctREFPROP.ctREFPROP as ct
root = os.getenv('RPPREFIX')
RP = ct.REFPROPFunctionLibrary(root)
RP.SETPATHdll(root)
m = RP.SETMIXTUREdll('R410A.MIX')
print(m.z)
print(RP.SATTdll(20.0 +273.15, m.z, 1).P)
print(RP.REFPROP1dll('TQ', 'P', RP.MOLAR_BASE_SI, 0, 20.0 +273.15, 0, m.z).c)
print(RP.REFPROPdll('','TQ', 'P', RP.MOLAR_BASE_SI, 0,0, 20.0 +273.15, 0, m.z).Output[0])
yields
array('d', [0.697614699375863, 0.302385300624138, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
1447.6042687400204
1447605.7807184535
1447605.7807184535
That is really weird. The original REFPROP codes are in Fortran, so if anything they should be most compatible with the code in Fortran.
I see that you also have used SETPATH, GETENV in your Python code. I do not have those calls in my Fortran code. Could those be the source of the error in my code?
Is there a chance you could show my code to Eric Lemmon? The code that I gave you was a modification of a short code I had received from him. Is there a chance either you or him could write a short code in Fortran that gives the same values for the two calls?
Thank you, Kayvan
On Mon, Oct 24, 2022 at 6:18 PM Ian Bell @.***> wrote:
I did it in Python, same result with all three methods:
import osimport ctREFPROP.ctREFPROP as ctroot = os.getenv('RPPREFIX')RP = ct.REFPROPFunctionLibrary(root)RP.SETPATHdll(root) m = RP.SETMIXTUREdll('R410A.MIX')print(m.z) print(RP.SATTdll(20.0 +273.15, m.z, 1).P)print(RP.REFPROP1dll('TQ', 'P', RP.MOLAR_BASE_SI, 0, 20.0 +273.15, 0, m.z).c)print(RP.REFPROPdll('','TQ', 'P', RP.MOLAR_BASE_SI, 0,0, 20.0 +273.15, 0, m.z).Output[0])
yields
array('d', [0.697614699375863, 0.302385300624138, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]) 1447.6042687400204 1447605.7807184535 1447605.7807184535
— Reply to this email directly, view it on GitHub https://github.com/usnistgov/REFPROP-issues/issues/551#issuecomment-1289155297, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD6LGHTNW6XOL46Z2KD3SRTWE2OVRANCNFSM6AAAAAARJDQNJ4 . You are receiving this because you authored the thread.Message ID: @.***>
-- All the best,
SETPATH
is for setting the path to fluid fluids, you have that in your code.
getenv
is for reading the environment variables, you don't need that either.
Try to reproduce exactly my example in FORTRAN
When I looked into your Python code, I noticed you used ‘MOLAR BASE SI’.
So I tried ‘MOLAR BASE SI’ instead of ‘MASS BASE SI’ and it worked. The saturated pressure values now match.
I also changed iMass to 0 instead of 1. Also, the code shows iUnit=20
My conclusion is that I cannot call SATT with ‘MASS BASE SI’. Do you know why that was causing the error? Should I use ‘ MOLAR BASE SI’ for all low level functions?
Thanks, Kayvan
On Mon, Oct 24, 2022 at 6:41 PM Ian Bell @.***> wrote:
SETPATH is for setting the path to fluid fluids, you have that in your code.
getenv is for reading the environment variables, you don't need that either.
Try to reproduce exactly my example in FORTRAN
— Reply to this email directly, view it on GitHub https://github.com/usnistgov/REFPROP-issues/issues/551#issuecomment-1289188005, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD6LGHXIUKDDBD2YSI2RP43WE2RKTANCNFSM6AAAAAARJDQNJ4 . You are receiving this because you authored the thread.Message ID: @.***>
-- All the best,
Make sure you check your error codes when calling getenum.
SATT does not use units. Docs: https://refprop-docs.readthedocs.io/en/latest/DLL/legacy.html#f/_/SATTdll
But also, this might be a bug if the results are different.
Also, in your example above you set the composition to [0.8, 0.8], which is probably not what you wanted.
The error code for GETENUM is ierr=0 for both cases (Molar base SI with iMass=0) and (Mass base SI with iMass=1). So GETENUM does not seem to reveal an error in the case of Mass Base SI.
May I ask where in my code you noticed that I am setting composition to [0.8 0.8]? I cannot find that. BTW, Shouldn’t those fractions add up to 1? These add up to 1.6.
The composition that I get in the variable z is (I’m rounding to 3 digits here) [0.698 0.302], regardless of using(Molar base SI with iMass=0) or (Mass base SI with iMass=1).
So the composition does not seem to be erroneous in the case of (Mass base SI with iMass=1) either.
Thanks, Kayvan
On Tue, Oct 25, 2022 at 2:08 AM Ian Bell @.***> wrote:
Make sure you check your error codes when calling getenum.
SATT does not use units. Docs: https://refprop-docs.readthedocs.io/en/latest/DLL/legacy.html#f/_/SATTdll
But also, this might be a bug if the results are different.
Also, in your example above you set the composition to [0.8, 0.8], which is probably not what you wanted.
— Reply to this email directly, view it on GitHub https://github.com/usnistgov/REFPROP-issues/issues/551#issuecomment-1289720930, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD6LGHSZRTEFX76ZZX2OHG3WE4FVDANCNFSM6AAAAAARJDQNJ4 . You are receiving this because you authored the thread.Message ID: @.***>
-- All the best,
Nevermind, you used x for quality (better to use Q)
Same result for me with MASS_BASE_SI
in my code
Ok…thanks.
For single phase regime, what low level/fast function would you recommend to get the density as a function of temperature and pressure?
I would have to use this density to get the other properties later in the functions that you mentioned: TRNPRP, THERM, STN.
Thanks, Kayvan
On Tue, Oct 25, 2022 at 2:28 AM Ian Bell @.***> wrote:
Nevermind, you used x for quality (better to use Q)
— Reply to this email directly, view it on GitHub https://github.com/usnistgov/REFPROP-issues/issues/551#issuecomment-1289735885, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD6LGHQ47VXB5AHLJ2P3ARDWE4IBRANCNFSM6AAAAAARJDQNJ4 . You are receiving this because you authored the thread.Message ID: @.***>
-- All the best,
TPRHO. Please read the docs.
Ok, thanks.
On Tue, Oct 25, 2022 at 2:38 AM Ian Bell @.***> wrote:
TPRHO. Please read the docs.
— Reply to this email directly, view it on GitHub https://github.com/usnistgov/REFPROP-issues/issues/551#issuecomment-1289753899, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD6LGHQQV3JLTEB5JPFQ66DWE4JHDANCNFSM6AAAAAARJDQNJ4 . You are receiving this because you authored the thread.Message ID: @.***>
-- All the best,
Hi, I am developing a Microchannel condenser solver, and I need to update the below properties every few elements. For superheated vapor and subcooled liquid, I would need the single phase properties. However, when I have two-phase flow, I will need saturated liquid and saturated vapor properties to calculate the heat transfer coefficient and pressure drops. Speed is the main thing that I am looking for, because the solution will be iterative and I have nested loops and many elements at a time.
I searched in Refprop 10.0a Documentation (attached for reference) and saw REPROP2dll would provide me with the properties; however, the document mentions that since string comparisons are time expensive in Fortran, this function would not be as fast as a dedicated function for the specific property.
In the document, I found the function TRNPRPdll function, which would provide viscosity (mu) and thermal conductivity (k). However, even that one is for single phase and it would not provide these properties for saturated liquid and saturated vapor.
Do you mind providing me the individual dedicated function names that would provide me with each of the 7 properties above for single-phase and the saturated liquid and saturated vapor? I would not need Refprop to calculate these properties in the middle of the dome (e.g. at x=0.2). I realize such calculations would be more complex and hence more time expensive. I only need those properties at saturated liquid and saturated vapor points at a given pressure, mainly for R32 and R410A for now. My code is also written in Fortran.
Thank you for your help in advance. Kayvan