While at University of Wisconsin-Madison, I got started on a Type that called Refprop dll.
- Define interfaces for the subroutines in the dll.
- Create handles to the subroutines in the dll.
Not all of the subroutines in Refprop were implemented, and only preliminary testing was done. In fact, all this process should be done not under a type, but as a kernell routine, so the properties are available for other types.
Below is the code. Please consider it as under development.
I hope that this helps.
! TRNSYS Type 75: Calling REFPROP
! ----------------------------------------------------------------------------------------------------------------------
!
! This component calls the program REFPROP
!
! Inputs
! ----------------------------------------------------------------------------------------------------------------------
! Nb | Variable | Description | Input Units | Internal Units
! ---|---------------|----------------------------------------------------------------|----------------|----------------
! 1 ! property1-i | Value of first property at point i | - | -
! 2 ! property2-i | Value of second property at point i | - | -
!
!
! Parameters
! ----------------------------------------------------------------------------------------------------------------------
! Nb | Variable | Description | Param. Units | Internal Units
! ---|---------------|----------------------------------------------------------------|----------------|----------------
! 1 | mode | Not Implemented yet | - | -
! 2 | lu_refprop | Logical unit number for Refprop.dll | - | -!
! 3 | lu_fluid | Logical unit number for file with fluid properties | - | -!
! 4 | n_points | Number of points at which to calculate properties | - | -
! 5 ! property1-i | First property | - | -
! 6 ! property2-i | Second property | - | -
!
! Outputs
! ----------------------------------------------------------------------------------------------------------------------
! Nb | Variable | Description | Output Units | Internal Units
! ---|---------------|----------------------------------------------------------------|----------------|----------------
! 1 ! wwm | Molecular weight | - | -
! 2 ! ttrp | Triple point temperature | - | -
! 3 ! tnbpt | Molecular weight | - | -
! 4 ! tc | Critical temperature | - | -
! 5 ! pc | Critical pressure | - | -
! 6 ! Dc | Critical density | - | -
!6+1 ! Temperature-i | Temperature at point i | - | -
!6+2 ! Pressure-i | Pressure at point i | - | -
!6+3 ! Enthalpy-i | Enthalpy at point i | - | -
!6+4 ! Entropy-i | Entropy at point i | - | -
!6+5 ! Quality-i | Quality at point i | - | -
!6+6 ! SpecVolume-i | Specific volume at point i | - | -
!6+7 ! IntEnergy-i | Internal energy at point i | - | -
!6+8 ! Density-i | Density at point i | - | -
!6+9 ! cp-i | Specific heat at constant volume at point i | - | -
!6+10! cv-i | Specific heat at constant pressure at point i | - | -
!6+11! mu | Dynamic viscosity | - | -
!6+12! k | Thermoconductivity | - | -
!
!
! SubPrograms
! ----------------------------------------------------------------------------------------------------------------------
!
! None
!
! Required external librairies
! ----------------------------------------------------------------------------------------------------------------------
!
! refprop.dll
!
!
! Revision history
! ---------------------------------------------------------------------------------------------------------------------
!
! This type was originally written by Diego A. Arias at the Solar Energy Laboratory, University of Wisconsin-Madison,
! in August 2006, for TRNSYS 16.
!
! Modifications:
!
! 2006-08-
!
!
! Use of the Storage array
! ----------------------------------------------------------------------------------------------------------------------
! Stored array contains the values of the input signals during the previous time step
! stored((i-1) + 1 ) = icount(i)
! stored((i-1) + 2 ) = itime(i)
!
! ----------------------------------------------------------------------------------------------------------------------
subroutine type75(time,xin,out,t,dtdt,par,info,iCntrl,*)
!dec$attributes dllexport :: type75
use TrnsysConstants
use TrnsysFunctions
use KERNEL32
implicit none
! --- External routine declarations -----------------------------------------------------------------------------------
! These routines are found in the file refprop.dll
interface
subroutine SETUPdll(i,hf,hfmix,hrf,ierr,herr)
!DEC$ ATTRIBUTES DLLIMPORT :: SETUPdll
parameter (ncmax=20) !max number of components in mixture
integer i, ierr
character*255 hf(ncmax),hfmix
character hrf*3, herr*255
end subroutine SETUPdll
end interface
pointer(lpfnfunc,SETUPdll)
interface
subroutine SETREFdll(hrf,ixflag,x0,h0,s0,t0,p0,ierr,herr)
!DEC$ ATTRIBUTES DLLIMPORT :: SETUPdll
parameter (ncmax=20) !max number of components in mixture
integer ixflag, ierr
character*255 hf(ncmax),hfmix
character*3 hrf
character*255 herr
double precision x0(ncmax)
double precision h0,s0,t0,p0
end subroutine SETREFdll
end interface
POINTER(lpSETREF,SETREFdll)
interface
subroutine INFOdll (icomp,wmm,ttrp,tnbpt,tc,pc,Dc,Zc,acf,dip,Rgas)
!DEC$ ATTRIBUTES DLLIMPORT :: INFOdll
integer icomp
double precision wmm,ttrp,tnbpt,tc,pc,Dc,Zc,acf,dip,Rgas
end subroutine INFOdll
end interface
pointer(lpINFO,INFOdll)
interface
subroutine SATTdll (t,x,kph,p,rhol,rhov,xl,xv,ierr,herr)
!DEC$ ATTRIBUTES DLLIMPORT :: SATTdll
parameter (ncmax=20) !max number of components in mixture
double precision t,x, p, rhol, rhov, xl(ncmax), xv(ncmax)
integer kph, ierr
character*255 herr
end subroutine SATTdll
end interface
pointer(lpSATT,SATTdll)
interface
subroutine TPFLSHdll (t,p,x,D,Dl,Dv,xl,xv,q,e,h,s,cv,cp,w,ierr,herr)
!DEC$ ATTRIBUTES DLLIMPORT :: TPFLSHdll
parameter (ncmax=20) !max number of components in mixture
integer ierr
double precision t,p,x(ncmax),D,Dl,Dv,xl(ncmax),xv(ncmax),q,e,h,s,cv,cp,w
character*255 herr
end subroutine TPFLSHdll
end interface
pointer(lpTPFLSH,TPFLSHdll)
interface
subroutine TDFLSHdll (t,D,x,p,Dl,Dv,xl,xv,q,e,h,s,cv,cp,w,ierr,herr)
!DEC$ ATTRIBUTES DLLIMPORT :: TDFLSHdll
parameter (ncmax=20) !max number of components in mixture
integer ierr
double precision t,p,x(ncmax),D,Dl,Dv,xl(ncmax),xv(ncmax),q,e,h,s,cv,cp,w
character*255 herr
end subroutine TDFLSHdll
end interface
pointer(lpTDFLSH,TDFLSHdll)
interface
subroutine PDFLSHdll (p,D,x,t,Dl,Dv,xl,xv,q,e,h,s,cv,cp,w,ierr,herr)
!DEC$ ATTRIBUTES DLLIMPORT :: PDFLSHdll
parameter (ncmax=20) !max number of components in mixture
integer ierr
double precision t,p,x(ncmax),D,Dl,Dv,xl(ncmax),xv(ncmax),q,e,h,s,cv,cp,w
character*255 herr
end subroutine PDFLSHdll
end interface
pointer(lpPDFLSH,PDFLSHdll)
interface
subroutine PHFLSHdll (p,h,x,t,D,Dl,Dv,xl,xv,q,e,s,cv,cp,w,ierr,herr)
!DEC$ ATTRIBUTES DLLIMPORT :: PHFLSHdll
parameter (ncmax=20) !max number of components in mixture
integer ierr
double precision t,p,x(ncmax),D,Dl,Dv,xl(ncmax),xv(ncmax),q,e,h,s,cv,cp,w
character*255 herr
end subroutine PHFLSHdll
end interface
pointer(lpPHFLSH,PHFLSHdll)
interface
subroutine PSFLSHdll (p,s,x,t,D,Dl,Dv,xl,xv,q,e,h,cv,cp,w,ierr,herr)
!DEC$ ATTRIBUTES DLLIMPORT :: PSFLSHdll
parameter (ncmax=20) !max number of components in mixture
integer ierr
double precision t,p,x(ncmax),D,Dl,Dv,xl(ncmax),xv(ncmax),q,e,h,s,cv,cp,w
character*255 herr
end subroutine PSFLSHdll
end interface
pointer(lpPSFLSH,PSFLSHdll)
interface
subroutine PEFLSHdll (p,e,x,t,D,Dl,Dv,xl,xv,q,h,s,cv,cp,w,ierr,herr)
!DEC$ ATTRIBUTES DLLIMPORT :: PEFLSHdll
parameter (ncmax=20) !max number of components in mixture
integer ierr
double precision t,p,x(ncmax),D,Dl,Dv,xl(ncmax),xv(ncmax),q,e,h,s,cv,cp,w
character*255 herr
end subroutine PEFLSHdll
end interface
pointer(lpPEFLSH,PEFLSHdll)
interface
subroutine THFLSHdll (t,h,x,kr,p,D,Dl,Dv,xl,xv,q,e,s,cv,cp,w,ierr,herr)
!DEC$ ATTRIBUTES DLLIMPORT :: THFLSHdll
parameter (ncmax=20) !max number of components in mixture
integer ierr, kr
double precision t,p,x(ncmax),D,Dl,Dv,xl(ncmax),xv(ncmax),q,e,h,s,cv,cp,w
character*255 herr
end subroutine THFLSHdll
end interface
pointer(lpTHFLSH,THFLSHdll)
interface
subroutine TSFLSHdll (t,s,x,kr,p,D,Dl,Dv,xl,xv,q,e,h,cv,cp,w,ierr,herr)
!DEC$ ATTRIBUTES DLLIMPORT :: TSFLSHdll
parameter (ncmax=20) !max number of components in mixture
integer ierr, kr
double precision t,p,x(ncmax),D,Dl,Dv,xl(ncmax),xv(ncmax),q,e,h,s,cv,cp,w
character*255 herr
end subroutine TSFLSHdll
end interface
pointer(lpTSFLSH,TSFLSHdll)
interface
subroutine TEFLSHdll (t,e,x,kr,p,D,Dl,Dv,xl,xv,q,h,s,cv,cp,w,ierr,herr)
!DEC$ ATTRIBUTES DLLIMPORT :: TEFLSHdll
parameter (ncmax=20) !max number of components in mixture
integer ierr, kr
double precision t,p,x(ncmax),D,Dl,Dv,xl(ncmax),xv(ncmax),q,e,h,s,cv,cp,w
character*255 herr
end subroutine TEFLSHdll
end interface
pointer(lpTEFLSH,TEFLSHdll)
interface
subroutine DHFLSHdll (D,h,x,t,p,Dl,Dv,xl,xv,q,e,s,cv,cp,w,ierr,herr)
!DEC$ ATTRIBUTES DLLIMPORT :: DHFLSHdll
parameter (ncmax=20) !max number of components in mixture
integer ierr
double precision t,p,x(ncmax),D,Dl,Dv,xl(ncmax),xv(ncmax),q,e,h,s,cv,cp,w
character*255 herr
end subroutine DHFLSHdll
end interface
pointer(lpDHFLSH,DHFLSHdll)
interface
subroutine DSFLSHdll (D,s,x,t,p,Dl,Dv,xl,xv,q,e,h,cv,cp,w,ierr,herr)
!DEC$ ATTRIBUTES DLLIMPORT :: DSFLSHdll
parameter (ncmax=20) !max number of components in mixture
integer ierr
double precision t,p,x(ncmax),D,Dl,Dv,xl(ncmax),xv(ncmax),q,e,h,s,cv,cp,w
character*255 herr
end subroutine DSFLSHdll
end interface
pointer(lpDSFLSH,DSFLSHdll)
interface
subroutine DEFLSHdll (D,e,x,t,p,Dl,Dv,xl,xv,q,h,s,cv,cp,w,ierr,herr)
!DEC$ ATTRIBUTES DLLIMPORT :: DEFLSHdll
parameter (ncmax=20) !max number of components in mixture
integer ierr
double precision t,p,x(ncmax),D,Dl,Dv,xl(ncmax),xv(ncmax),q,e,h,s,cv,cp,w
character*255 herr
end subroutine DEFLSHdll
end interface
pointer(lpDEFLSH,DEFLSHdll)
interface
subroutine TQFLSHdll (t,q,x,kq,p,D,Dl,Dv,xl,xv,e,h,s,cv,cp,w,ierr,herr)
!DEC$ ATTRIBUTES DLLIMPORT :: TQFLSHdll
parameter (ncmax=20) !max number of components in mixture
integer ierr, kq
double precision t,p,x(ncmax),D,Dl,Dv,xl(ncmax),xv(ncmax),q,e,h,s,cv,cp,w
character*255 herr
end subroutine TQFLSHdll
end interface
pointer(lpTQFLSH,TQFLSHdll)
interface
subroutine PQFLSHdll (p,q,x,kq,t,D,Dl,Dv,xl,xv,e,h,s,cv,cp,w,ierr,herr)
!DEC$ ATTRIBUTES DLLIMPORT :: PQFLSHdll
parameter (ncmax=20) !max number of components in mixture
integer ierr, kq
double precision t,p,x(ncmax),D,Dl,Dv,xl(ncmax),xv(ncmax),q,e,h,s,cv,cp,w
character*255 herr
end subroutine PQFLSHdll
end interface
pointer(lpPQFLSH,PQFLSHdll)
interface
subroutine HSFLSHdll (h,s,x,t,p,D,Dl,Dv,xl,xv,q,e,cv,cp,w,ierr,herr)
!DEC$ ATTRIBUTES DLLIMPORT :: HSFLSHdll
parameter (ncmax=20) !max number of components in mixture
integer ierr
double precision t,p,x(ncmax),D,Dl,Dv,xl(ncmax),xv(ncmax),q,e,h,s,cv,cp,w
character*255 herr
end subroutine HSFLSHdll
end interface
pointer(lpHSFLSH,HSFLSHdll)
interface
subroutine TRNPRPdll (t,rho,x,eta,tcx,ierr,herr)
!DEC$ ATTRIBUTES DLLIMPORT :: TRNPRPdll
parameter (ncmax=20) !max number of components in mixture
double precision t,rho,x(ncmax),eta,tcx
integer ierr
character*255 herr
end subroutine TRNPRPdll
end interface
pointer(lpTRNPRP,TRNPRPdll)
! --- TRNSYS declarations ----------------------------------------------------------------------------------------------
integer, parameter :: NImax=100, NP =4, ND=0, ncmax = 20, NSmax = 200
integer, parameter :: nmaxpoints = 20
real(8), intent(in) :: time, xin, par, t
real(8), intent(inout) :: dtdt
real(8), intent(out) :: out
integer, intent(inout) :: info, iCntrl
dimension xin(NImax), par(NP), OUT(nMaxOutputs), info(15)
! --- Local variables --------------------------------------------------------------------------------------------------
! --- Parameters:
integer :: mode
integer :: n_points
! Intermediate variables
integer NI, NO, NS
integer iUnit
integer icomp, kr, kq
integer hLib,i, ierr, ist
integer prop1(nmaxpoints), prop2(nmaxpoints), propCase(nmaxpoints)
character*255 hf(ncmax),hfmix, herr
character*3 hrf
character (len=maxFileWidth) :: refpropFile
character (len=maxFileWidth) :: message
logical :: openedLibrary = .false.
logical :: closedLibrary = .false.
double precision wmm !Molecular weight
double precision ttrp !Triple point temperature
double precision tnbpt !Normal boiling point temperature
double precision tc !Critical temperature
double precision pc !Critical pressure
double precision Dc !Critical density
double precision Zc !Critical compressibility factor
double precision acf !Critical accectric factor
double precision dip !Dipole moment
double precision Rgas !Gas constant
double precision t1 !Temperature
double precision p !Pressure
double precision x(ncmax) !
double precision D !Density
double precision Dl !Liquid density
double precision Dv !Liquid density
double precision xl(ncmax)
double precision xv(ncmax)
double precision q !Quality
double precision e !Internal energy
double precision h !Enthalpy
double precision s !Entropy
double precision cv !Specific heat
double precision cp !Specific heat
double precision w !
double precision mu !Dynamic viscosity
double precision kt !Thermal conductivity
double precision stored(NSmax)
! Read parameters
mode = jfix(par(1) + 0.1)
n_points = jfix(par(2) + 0.1)
do i=1,n_points
prop1(i) = jfix(par((i-1)*2 + 1 + 2) + 0.1)
prop2(i) = jfix(par((i-1)*2 + 2 + 2) + 0.1)
enddo
!-----------------------------------------------------------------------------------------------------------------------
! --- Initial call to detect the TRNSYS version for which this Type is written -----------------------------------------
if (info(7) .eq. -2) then
info(12) = 16 ! This component is a TRNSYS 16 Type
return 1
endif
!-----------------------------------------------------------------------------------------------------------------------
! --- Very last call in simulation -------------------------------------------------------------------------------------
if (info(8).eq.-1) then
iSt = FreeLibrary(hLib)
return 1 !
endif
!-----------------------------------------------------------------------------------------------------------------------
! --- Extra call after convergence at a time step - The type should not modify its outputs here ------------------------
if (info(13) .gt. 0) then
return 1
endif
!-----------------------------------------------------------------------------------------------------------------------
! --- Initialization call (not a simulation call) ----------------------------------------------------------------------
if (info(7) .eq. -1) then
iUnit = info(1)
NI = n_points*2
NO = n_points*12 + 6
NS = n_points + 7
info(6) = NO ! Set outputs number
info(9) = 1 ! This type's outputs depend upon the passage of time
info(10) = 0
call typeck(1,info,NI,NP,ND) ! Check the number of inputs/parameters/derivatives
call setStorageSize(NS,info) !Set number of storage spots
return 1
endif
!-----------------------------------------------------------------------------------------------------------------------
! --- First time step - No iterations ----------------------------------------------------------------------------------
if ( time .lt. (getSimulationStartTime()+getSimulationTimeStep()/2.0) ) then
!Check values of parameters
if (mode /= 1) call typeck(-4,info,0,1,0)
if (n_points < 1) call typeck(-4,info,0,2,0)
do i=1,n_points
if ((prop1(i) < 1).or.(prop1(i)>7)) call typeck(-4,info,0,((i-1)*2+3),0)
if ((prop2(i) < 1).or.(prop2(i)>7)) call typeck(-4,info,0,((i-1)*2+4),0)
if (prop1(i) == prop2(i)) call typeck(-4,info,0,((i-1)*2+3),0)
enddo
!Decide the case for calculation of properties
do i=1,n_points
if (((prop1(i)==1).and.(prop2(i)==2)).or.((prop1(i)==2).and.(prop2(i)==1))) then
propCase(i) = 1 !TP
endif
if (((prop1(i)==1).and.(prop2(i)==3)).or.((prop1(i)==3).and.(prop2(i)==1))) then
propCase(i) = 2 !TH
endif
if (((prop1(i)==1).and.(prop2(i)==4)).or.((prop1(i)==4).and.(prop2(i)==1))) then
propCase(i) = 3 !TS
endif
if (((prop1(i)==1).and.(prop2(i)==5)).or.((prop1(i)==5).and.(prop2(i)==1))) then
propCase(i) = 4 !TQ
endif
if (((prop1(i)==1).and.(prop2(i)==6)).or.((prop1(i)==6).and.(prop2(i)==1))) then
propCase(i) = 5 !TD
!DAA### - THE FUNCTION USES DENSITY BUT INPUT SHOULD BE SPECIFIC VOLUME!!!
endif
if (((prop1(i)==1).and.(prop2(i)==7)).or.((prop1(i)==7).and.(prop2(i)==1))) then
propCase(i) = 6 !TE
endif
if (((prop1(i)==2).and.(prop2(i)==3)).or.((prop1(i)==3).and.(prop2(i)==2))) then
propCase(i) = 7 !PH
endif
if (((prop1(i)==2).and.(prop2(i)==4)).or.((prop1(i)==4).and.(prop2(i)==2))) then
propCase(i) = 8 !PS
endif
if (((prop1(i)==2).and.(prop2(i)==5)).or.((prop1(i)==5).and.(prop2(i)==2))) then
propCase(i) = 9 !PQ
endif
if (((prop1(i)==2).and.(prop2(i)==6)).or.((prop1(i)==6).and.(prop2(i)==2))) then
propCase(i) = 10 !PD
!DAA### - THE FUNCTION USES DENSITY BUT INPUT SHOULD BE SPECIFIC VOLUME!!!
endif
if (((prop1(i)==2).and.(prop2(i)==7)).or.((prop1(i)==7).and.(prop2(i)==2))) then
propCase(i) = 11 !PE
endif
if (((prop1(i)==3).and.(prop2(i)==4)).or.((prop1(i)==4).and.(prop2(i)==3))) then
propCase(i) = 12 !HS
endif
if (((prop1(i)==3).and.(prop2(i)==5)).or.((prop1(i)==5).and.(prop2(i)==3))) then
propCase(i) = 13 !HQ-NOT IMPLEMENTED DAA###
endif
if (((prop1(i)==3).and.(prop2(i)==6)).or.((prop1(i)==6).and.(prop2(i)==3))) then
propCase(i) = 14 !HD
!DAA### - THE FUNCTION USES DENSITY BUT INPUT SHOULD BE SPECIFIC VOLUME!!!
endif
if (((prop1(i)==3).and.(prop2(i)==7)).or.((prop1(i)==7).and.(prop2(i)==3))) then
propCase(i) = 15 !HE-NOT IMPLEMENTED DAA###
endif
if (((prop1(i)==4).and.(prop2(i)==5)).or.((prop1(i)==5).and.(prop2(i)==4))) then
propCase(i) = 16 !SQ-NOT IMPLEMENTED DAA###
endif
if (((prop1(i)==4).and.(prop2(i)==6)).or.((prop1(i)==6).and.(prop2(i)==4))) then
propCase(i) = 17 !DS
!DAA### - THE FUNCTION USES DENSITY BUT INPUT SHOULD BE SPECIFIC VOLUME!!!
endif
if (((prop1(i)==4).and.(prop2(i)==7)).or.((prop1(i)==7).and.(prop2(i)==4))) then
propCase(i) = 18 !SE-NOT IMPLEMENTED DAA###
endif
if (((prop1(i)==5).and.(prop2(i)==6)).or.((prop1(i)==6).and.(prop2(i)==5))) then
propCase(i) = 19 !QD-NOT IMPLEMENTED DAA###
endif
if (((prop1(i)==5).and.(prop2(i)==7)).or.((prop1(i)==7).and.(prop2(i)==5))) then
propCase(i) = 20 !QE-NOT IMPLEMENTED DAA###
endif
if (((prop1(i)==6).and.(prop2(i)==7)).or.((prop1(i)==7).and.(prop2(i)==6))) then
propCase(i) = 21 !DE-NOT IMPLEMENTED DAA###
endif
enddo
! Find the location of the REFPROP.DLL from the first label
refpropFile =getlabel(INFO(1),1)
!Create handle to REFPROP.dll and internal functions
if (.not.(openedLibrary)) then
openedLibrary = .true.
! Create a handle to the refprop.dll
hLib = LoadLibrary(TRIM(refpropFile))
! Find addressses to the internal functions
lpfnfunc = GetProcAddress(hLib,"SETUPdll")
lpINFO = GetProcAddress(hLib,"INFOdll")
lpTPFLSH = GetProcAddress(hLib,"TPFLSHdll")
lpTHFLSH = GetProcAddress(hLib,"THFLSHdll")
lpTSFLSH = GetProcAddress(hLib,"TSFLSHdll")
lpTQFLSH = GetProcAddress(hLib,"TQFLSHdll")
lpTDFLSH = GetProcAddress(hLib,"TDFLSHdll")
lpTEFLSH = GetProcAddress(hLib,"TEFLSHdll")
lpPHFLSH = GetProcAddress(hLib,"PHFLSHdll")
lpPSFLSH = GetProcAddress(hLib,"PSFLSHdll")
lpPQFLSH = GetProcAddress(hLib,"PQFLSHdll")
lpPDFLSH = GetProcAddress(hLib,"PDFLSHdll")
lpPEFLSH = GetProcAddress(hLib,"PEFLSHdll")
lpHSFLSH = GetProcAddress(hLib,"HSFLSHdll")
! lpHQFLSH = GetProcAddress(hLib,"HQFLSHdll") !DAA### NOT IMPLEMENTED
lpDHFLSH = GetProcAddress(hLib,"DHFLSHdll")
! lpHEFLSH = GetProcAddress(hLib,"HEFLSHdll") !DAA### NOT IMPLEMENTED
lpDSFLSH = GetProcAddress(hLib,"DSFLSHdll")
! lpSEFLSH = GetProcAddress(hLib,"SEFLSHdll") !DAA### NOT IMPLEMENTED
! lpQDFLSH = GetProcAddress(hLib,"QDFLSHdll") !DAA### NOT IMPLEMENTED
! lpQEFLSH = GetProcAddress(hLib,"QEFLSHdll") !DAA### NOT IMPLEMENTED
! lpDEFLSH = GetProcAddress(hLib,"DEFLSHdll") !DAA### NOT IMPLEMENTED
lpTRNPRP = GetProcAddress(hLib,"TRNPRPdll")
endif
! Units are K, kPa, mol/dm^3, mole fraction, J/mol, J/mol-K, m/s
! uPa-s, W/m-K, N/m
! Find the location of file with the fluid properties from the second label
hf(1) = getlabel(INFO(1),2)
!Initialize REFPROP
i=1
hrf='DEF' ! default reference state as specified in fluid file
CALL SETUPdll(i,hf,hfmix,hrf,ierr,herr)
! Get basic information about the substance
CALL INFOdll (icomp,wmm,ttrp,tnbpt,tc,pc,Dc,Zc,acf,dip,Rgas)
!Set storage variables
stored(1) = wmm
stored(2) = ttrp
stored(3) = tnbpt
stored(4) = tc
stored(5) = pc
stored(6) = Dc
stored(7) = Rgas
do i=1,n_points
stored(7+i) = propCase(i)
enddo
call setStorageVars(stored,NS,info)
endif
! --- Iterative Call ---------------------------------------------------------------------------------------------------
if ( iUnit /= info(1)) then
call getStorageVars(stored,NS,info)
wmm = stored(1)
ttrp = stored(2)
tnbpt = stored(3)
tc = stored(4)
pc = stored(5)
Dc = stored(6)
Rgas = stored(7)
do i=1,n_points
propCase(i) = stored(7+i)
enddo
! Find the location of file with the fluid properties from the second label
hf(1) = getlabel(INFO(1),2)
!Initialize REFPROP
i=1
hrf='DEF' ! default reference state as specified in fluid file
CALL SETUPdll(i,hf,hfmix,hrf,ierr,herr)
endif
do i=1, n_points
select case ( propCase(i))
case(1) !TP
if (prop1(i) == 1) then
t1 = xin( (i-1)*2 + 1)
p = xin( (i-1)*2 + 2)
else
t1 = xin( (i-1)*2 + 2)
p = xin( (i-1)*2 + 1)
endif
call TPFLSHdll (t1,p,x,D,Dl,Dv,xl,xv,q,e,h,s,cv,cp,w,ierr,herr)
case(2) !TH
if (prop1(i) == 1) then
t1 = xin( (i-1)*2 + 1)
h = xin( (i-1)*2 + 2)
else
t1 = xin( (i-1)*2 + 2)
h = xin( (i-1)*2 + 1)
endif
call THFLSHdll (t1,h,x,kr,p,D,Dl,Dv,xl,xv,q,e,s,cv,cp,w,ierr,herr)
case(3) !TS
if (prop1(i) == 1) then
t1 = xin( (i-1)*2 + 1)
s = xin( (i-1)*2 + 2)
else
t1 = xin( (i-1)*2 + 2)
s = xin( (i-1)*2 + 1)
endif
call TSFLSHdll (t1,s,x,kr,p,D,Dl,Dv,xl,xv,q,e,h,cv,cp,w,ierr,herr)
case(4) !TQ
if (prop1(i) == 1) then
t1 = xin( (i-1)*2 + 1)
q = xin( (i-1)*2 + 2)
else
t1 = xin( (i-1)*2 + 2)
q = xin( (i-1)*2 + 1)
endif
call TQFLSHdll (t1,q,x,kq,p,D,Dl,Dv,xl,xv,e,h,s,cv,cp,w,ierr,herr)
case(5) !TD
if (prop1(i) == 1) then
t1 = xin( (i-1)*2 + 1)
D = xin( (i-1)*2 + 2)
else
t1 = xin( (i-1)*2 + 2)
D = xin( (i-1)*2 + 1)
endif
call TDFLSHdll (t1,D,x,p,Dl,Dv,xl,xv,q,e,h,s,cv,cp,w,ierr,herr)
case(6) !TE
if (prop1(i) == 1) then
t1 = xin( (i-1)*2 + 1)
e = xin( (i-1)*2 + 2)
else
t1 = xin( (i-1)*2 + 2)
e = xin( (i-1)*2 + 1)
endif
call TEFLSHdll (t1,e,x,kr,p,D,Dl,Dv,xl,xv,q,h,s,cv,cp,w,ierr,herr)
case(7) !PH
if (prop1(i) == 2) then
p = xin( (i-1)*2 + 1)
h = xin( (i-1)*2 + 2)
else
p = xin( (i-1)*2 + 2)
h = xin( (i-1)*2 + 1)
endif
call PHFLSHdll (p,h,x,t1,D,Dl,Dv,xl,xv,q,e,s,cv,cp,w,ierr,herr)
case(8) !PS
if (prop1(i) == 2) then
p = xin( (i-1)*2 + 1)
s = xin( (i-1)*2 + 2)
else
p = xin( (i-1)*2 + 2)
s = xin( (i-1)*2 + 1)
endif
call PSFLSHdll (p,s,x,t1,D,Dl,Dv,xl,xv,q,e,h,cv,cp,w,ierr,herr)
case(9) !PQ
if (prop1(i) == 2) then
p = xin( (i-1)*2 + 1)
q = xin( (i-1)*2 + 2)
else
p = xin( (i-1)*2 + 2)
q = xin( (i-1)*2 + 1)
endif
call PQFLSHdll (p,q,x,kq,t1,D,Dl,Dv,xl,xv,e,h,s,cv,cp,w,ierr,herr)
case(10) !PD
if (prop1(i) == 2) then
p = xin( (i-1)*2 + 1)
D = xin( (i-1)*2 + 2)
else
p = xin( (i-1)*2 + 2)
D = xin( (i-1)*2 + 1)
endif
call PDFLSHdll (p,D,x,t1,Dl,Dv,xl,xv,q,e,h,s,cv,cp,w,ierr,herr)
case(11) !PE
if (prop1(i) == 2) then
p = xin( (i-1)*2 + 1)
e = xin( (i-1)*2 + 2)
else
p = xin( (i-1)*2 + 2)
e = xin( (i-1)*2 + 1)
endif
call PEFLSHdll (p,e,x,t1,D,Dl,Dv,xl,xv,q,h,s,cv,cp,w,ierr,herr)
case(12) !HS
if (prop1(i) == 3) then
h = xin( (i-1)*2 + 1)
s = xin( (i-1)*2 + 2)
else
h = xin( (i-1)*2 + 2)
s = xin( (i-1)*2 + 1)
endif
call HSFLSHdll (h,s,x,t1,p,D,Dl,Dv,xl,xv,q,e,cv,cp,w,ierr,herr)
case(13) !HQ
if (prop1(i) == 3) then
h = xin( (i-1)*2 + 1)
q = xin( (i-1)*2 + 2)
else
h = xin( (i-1)*2 + 2)
q = xin( (i-1)*2 + 1)
endif
! call HQFLSHdll (h,s,x,t1,p,D,Dl,Dv,xl,xv,q,e,cv,cp,w,ierr,herr)
!DAA### NOT IMPLIMENTED
case(14) !HD - DH
if (prop1(i) == 3) then
h = xin( (i-1)*2 + 1)
D = xin( (i-1)*2 + 2)
else
h = xin( (i-1)*2 + 2)
D = xin( (i-1)*2 + 1)
endif
call DHFLSHdll (D,h,x,t1,p,Dl,Dv,xl,xv,q,e,s,cv,cp,w,ierr,herr)
case(15) !HE
if (prop1(i) == 3) then
h = xin( (i-1)*2 + 1)
e = xin( (i-1)*2 + 2)
else
h = xin( (i-1)*2 + 2)
e = xin( (i-1)*2 + 1)
endif
! call HEFLSHdll (h,s,x,t1,p,D,Dl,Dv,xl,xv,q,e,cv,cp,w,ierr,herr)
!DAA### NOT IMPLIMENTED
case(16) !SQ
if (prop1(i) == 4) then
s = xin( (i-1)*2 + 1)
q = xin( (i-1)*2 + 2)
else
s = xin( (i-1)*2 + 2)
q = xin( (i-1)*2 + 1)
endif
! call SQFLSHdll (h,s,x,t1,p,D,Dl,Dv,xl,xv,q,e,cv,cp,w,ierr,herr)
!DAA### NOT IMPLIMENTED
case(17) !DS
if (prop1(i) == 4) then
s = xin( (i-1)*2 + 1)
d = xin( (i-1)*2 + 2)
else
s = xin( (i-1)*2 + 2)
d = xin( (i-1)*2 + 1)
endif
call DSFLSHdll (D,s,x,t1,p,Dl,Dv,xl,xv,q,e,h,cv,cp,w,ierr,herr)
case(18) !SE
if (prop1(i) == 4) then
s = xin( (i-1)*2 + 1)
e = xin( (i-1)*2 + 2)
else
s = xin( (i-1)*2 + 2)
e = xin( (i-1)*2 + 1)
endif
! call SEFLSHdll (D,s,x,t1,p,Dl,Dv,xl,xv,q,e,h,cv,cp,w,ierr,herr)
!DAA### NOT IMPLIMENTED
case(19) !QD
if (prop1(i) == 5) then
q = xin( (i-1)*2 + 1)
d = xin( (i-1)*2 + 2)
else
q = xin( (i-1)*2 + 2)
d = xin( (i-1)*2 + 1)
endif
! call QDFLSHdll (D,s,x,t1,p,Dl,Dv,xl,xv,q,e,h,cv,cp,w,ierr,herr)
!DAA### NOT IMPLIMENTED
case(20) !QE
if (prop1(i) == 5) then
q = xin( (i-1)*2 + 1)
e = xin( (i-1)*2 + 2)
else
q = xin( (i-1)*2 + 2)
e = xin( (i-1)*2 + 1)
endif
! call QEFLSHdll (D,s,x,t1,p,Dl,Dv,xl,xv,q,e,h,cv,cp,w,ierr,herr)
!DAA### NOT IMPLIMENTED
case(21) !DE
if (prop1(i) == 6) then
d = xin( (i-1)*2 + 1)
e = xin( (i-1)*2 + 2)
else
d = xin( (i-1)*2 + 2)
e = xin( (i-1)*2 + 1)
endif
! call DEFLSHdll (D,s,x,t1,p,Dl,Dv,xl,xv,q,e,h,cv,cp,w,ierr,herr)
!DAA### NOT IMPLIMENTED
end select
enddo
!Viscosity and Thermoconductivity
call TRNPRPdll (t1,D,x,mu,kt,ierr,herr)
out(1) = wmm
out(2) = ttrp
out(3) = tnbpt
out(4) = tc
out(5) = pc
out(6) = Dc
do i=1,n_points
out( (i-1)*12 + 1 + 6) = t1
out( (i-1)*12 + 2 + 6) = p
out( (i-1)*12 + 3 + 6) = h
out( (i-1)*12 + 4 + 6) = s
out( (i-1)*12 + 5 + 6) = q
out( (i-1)*12 + 6 + 6) = 1.d0/D
out( (i-1)*12 + 7 + 6) = e
out( (i-1)*12 + 8 + 6) = D
out( (i-1)*12 + 9 + 6) = cv
out( (i-1)*12 + 10 + 6) = cp
out( (i-1)*12 + 11 + 6) = mu
out( (i-1)*12 + 12 + 6) = kt
enddo
return 1
end subroutine type75
!===================================================================================================