Manual

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 37

USING REFPROP WITH OTHER PROGRAMS The subroutines are contained in a number of files, which are placed in the

"FORTRAN" directory. The following files should be compiled and linked with your own main program: core_anc.for core_feq.for flash2.for prop_sub.for trns_ecs.for core_bwr.for core_mlt.for flsh_sub.for realgas.for trns_tcx.for core_cpp.for core_ph0.for idealgas.for sat_sub.for trns_vis.for core_de.for core_pr.for mix_aga8.for setup.for trnsp.for core_ecs.for core_stn.for mix_hmx.for setup2.for utility.for

These 26 files were compiled with the Lahey compiler using a command similar to this: lf95 core_anc.for -c -nco -nom -dll -win -ml msvb and linked with the following: lf95 pass_ftn.obj setup.obj core_anc.obj core_bwr.obj core_cpp.obj core_de.ob j core_ecs.obj core_feq.obj core_mlt.obj core_ph0.obj core_stn.obj core_pr.obj f lash2.obj flsh_sub.obj idealgas.obj mix_aga8.obj mix_hmx.obj prop_sub.obj realga s.obj sat_sub.obj setup2.obj trns_ecs.obj trns_tcx.obj trns_vis.obj trnsp.obj ut ility.obj -nco -nom -dll -win -ml msvb -out refprop.dll There is one additional file that comes with REFPROP. This file, called pass_ftn.for, is used only when creating the DLL. Several example files showing how to call the routines are located in your REFPROP\Examples directory. EXAMPLE.FOR shows the common routines that you might need. EX-MIX.FOR shows how to load a mixture .MIX file containing information for specified blends of refrigerants (and air). The file EX-PPF.FOR shows how to use the pseudo-pure fluid files. Any fluids that are used must have a ".fld" extension, e.g., R134a.fld, or a ".ppf" extension, e.g., air.ppf. The file "HMX.bnc" (containing mixture parameters) must also be present. It is suggested (but not required) that these be put into a subdirectory called "fluids" under the directory containing the subroutines and application program. The subroutine SETUP must be called to initialize the pure fluid or mixture components. The call to SETUP will allow the choice of one of three standard reference states for entropy and enthalpy and will automatically load the "NIST-recommended" models for the components as well as mixing rules. The routine SETMOD allows the specification of other models. To define another reference state, or to apply one of the standard states to a mixture of a specified composition, the subroutine SETREF may be used. These additional routines should be called only if the fluids and/or models (or reference state) are changed. The sequence is: call call call call SETMOD SETUP SETKTV SETREF (optional) (REQUIRED) (optional) (optional)

Subroutine SETUP0 calls subroutine SETUP using the same techniques as those used by the graphical interface and the Excel spreadsheet. Subroutine SETMIX reads the *.MIX files and makes the appropriate call to subroutine SETUP. Subroutine SETPATH sets the path where the *.fld files can be found. Subroutine PUREFLD allows the user to calculate the properties of a pure fluid when a mixture has been loaded and the fluid is one of the constituents in the mixture.

Units. The subroutines use the following units for all inputs and outputs: temperature pressure, fugacity density composition quality enthalpy, internal energy Gibbs, Helmholtz free energy entropy, heat capacity speed of sound Joule-Thompson coefficient d(p)/d(rho) d2(p)/d(rho)2 viscosity thermal conductivity dipole moment surface tension K kPa mol/L mole fraction mole basis (moles vapor/total moles) J/mol J/mol J/(mol.K) m/s K/kPa kPa.L/mol kPa.(L/mol)^2 microPa.s (10^-6 Pa.s) W/(m.K) debye N/m

Note: The only exceptions to the above are the conversion utilities XMASS and XMOLE. The interface allows a wide variety of units, but not the subroutines. Naming conventions. The variable type of subroutine arguments can generally be inferred from the first letter of the variable name: a-g and o-z: double precision h: double precision (i.e. enthalpy) or character i-k and m,n: integer l: logical (within subroutines only, no logicals in arguments) also used as integer for exponent of FEQ model The property subroutines are written in ANSI standard Fortran 77 and are compatible with Fortran 90. We are striving to make these as standard and portable as possible, but every compiler has its own sensitive points. Please report any compiler or linker errors or warnings. Potential pitfalls: The fluid data files are read using logical unit 12. Use of this unit in your program may crash the program and should be avoided. The following is a description of the high-level routines that would be used in stand-alone applications. These routines will give you access to all features in a model-independent fashion. (There are corresponding low-level routines for some of these which call specific models. Please do not incorporate the low-level routines into your applications--if you do, you may find that future versions may not work the same.)

INITIALIZATION SUBROUTINES subroutine SETUP (nc,hfiles,hfmix,hrf,ierr,herr) c c define models and initialize arrays c

c A call to this routine is required. c c inputs: c nc--number of components (1 for pure fluid) [integer] c hfiles--array of file names specifying fluid/mixture components c [character*255 variable] for each of the nc components; c e.g., :fluids:r134a.fld (Mac) or fluids\r134a.fld (DOS) or c [full_path]/fluids/r134a.fld (UNIX) c hfmix--mixture coefficients [character*255] c file name containing coefficients for mixture model, c if applicable c e.g., fluids\hmx.bnc c hrf--reference state for thermodynamic calculations [character*3] c 'DEF': default reference state as specified in fluid file c is applied to each pure component c 'NBP': h,s = 0 at pure component normal boiling point(s) c 'ASH': h,s = 0 for sat liquid at -40 C (ASHRAE convention) c 'IIR': h = 200, s = 1.0 for sat liq at 0 C (IIR convention) c other choices are possible, but these require a separate c call to SETREF c outputs: c ierr--error flag: 0 = successful c 101 = error in opening file c 102 = error in file or premature end of file c -103 = unknown model encountered in file c 104 = error in setup of model c 105 = specified model not found c 111 = error in opening mixture file c 112 = mixture file of wrong type c 114 = nc<>nc from setmod c herr--error string (character*255 variable if ierr<>0) c [fluid parameters, etc. returned via various common blocks]

subroutine SETUP0 (i,hfld,hfm,hrf,ierr,herr) c c c c c c c c c c call the SETUP routine with the same inputs as SETUP except for the hfld variable. This subroutine is generally used in calls to the REFPROP DLL since the call cannot handle a string array. The hfld variable is a string of length 10000. For a pure fluid, it simply contains the name of the fluid file (with a path if needed). For a mixture, it contains the names of the constituents in the mixture separated by a |. For the air mixture, this would be something like (depends on the need for paths): hfld='fluids\nitrogen.fld|fluids\argon.fld|fluids\oxygen.fld|'

subroutine SETFLD (icomp,hfile,ierr,herr) c c open a fluid file and read model coefficients (or get from block data) c c inputs: c icomp--pointer specifying component number c zero and negative values are used for ECS reference fluid(s) c hfile--array of file names specifying fluid/mixture components c [character*255 variable] for each of the components;

c --or-c when hf(i) is of the form: c BDATA:nn-nn-nn c use coefficients stored in block data for fluid with CAS c number specified by nn-nn-nn; c e.g. to use stored formulation for R134a, c hf(i) = 'BDATA:811-97-2' c outputs: c ierr--error flag: 0 = successful c 101 = error in opening file c 102 = error in file or premature end of file c -103 = unknown model encountered in file c 104 = error in setup of model c 105 = specified model not found c 106 = cp0 equation not found c herr--error string (character*255 variable if ierr<>0) c [fluid parameters, etc. returned via various common blocks]

subroutine SETMOD (nc,htype,hmix,hcomp,ierr,herr) c c set model(s) other than the NIST-recommended ('NBS') ones c c This subroutine must be called before SETUP; it need not be called c at all if the default (NIST-recommended) models are desired. c c inputs: c nc--number of components (1 for pure fluid) [integer] c htype--flag indicating which models are to be set [character*3] c 'EOS': equation of state for thermodynamic properties c 'ETA': viscosity c 'TCX': thermal conductivity c 'STN': surface tension c 'NBS': reset all of the above model types and all c subsidiary component models to 'NBS'; c values of hmix and hcomp are ignored c hmix--mixture model to use for the property specified in htype [character* 3]; c ignored if number of components = 1 c some allowable choices for hmix: c 'NBS': use NIST recommendation for specified fluid/mixture c 'HMX': mixture Helmholtz model for thermodynamic properties c 'ECS': extended corresponding states for viscosity or therm. cond . c 'STX': surface tension mixture model c hcomp--component model(s) to use for property specified in htype [array (1. .nc) of character*3] c 'NBS': NIST recommendation for specified fluid/mixture c some allowable choices for an equation of state: c 'FEQ': Helmholtz free energy model c 'BWR': pure fluid modified Benedict-Webb-Rubin (MBWR) c 'ECS': pure fluid thermo extended corresponding states c some allowable choices for viscosity: c 'ECS': extended corresponding states (all fluids) c 'VS1': the 'composite' model for R134a, R152a, NH3, etc. c 'VS2': Younglove-Ely model for hydrocarbons c 'VS4': Generalized friction theory of Quinones-Cisneros and Deite rs

c some allowable choices for thermal conductivity: c 'ECS': extended corresponding states (all fluids) c 'TC1': the 'composite' model for R134a, R152a, etc. c 'TC2': Younglove-Ely model for hydrocarbons c some allowable choices for surface tension: c 'ST1': surface tension as f(tau); tau = 1 - T/Tc c c outputs: c ierr--error flag: 0 = successful c 113 = nc outside of bounds c herr--error string (character*255 variable if ierr<>0) c [fluid parameters, etc. returned via various common blocks]

subroutine GERG04 (nc,iflag,ierr,herr) c c c c c c c c c c c c set the pure model(s) to those used by the GERG 2004 formulation. This subroutine must be called before SETUP; it need not be called at all if the default (NIST-recommended) models are desired. inputs: nc--number of components (1 for pure fluid) iflag--set to 1 to load the GERG 2004 equations, set to 0 for defaults outputs: ierr--error flag: 0 = successful herr--error string returned from SETMOD

subroutine SETREF (hrf,ixflag,x0,h0,s0,t0,p0,ierr,herr) c c c c c c c c c c c c c c c c c c c c c c c c c c set reference state enthalpy and entropy This subroutine must be called after SETUP; it need not be called at all if the reference state specified in the call to SETUP is to be used. inputs: hrf--reference state for thermodynamic calculations [character*3] 'NBP': h,s = 0 at normal boiling point(s) 'ASH': h,s = 0 for sat liquid at -40 C (ASHRAE convention) 'IIR': h = 200, s = 1.0 for sat liq at 0 C (IIR convention) 'DEF': default reference state as specified in fluid file is applied to each component (ixflag = 1 is used) 'OTH': other, as specified by h0, s0, t0, p0 (real gas state) 'OT0': other, as specified by h0, s0, t0, p0 (ideal gas state) '???': change hrf to the current reference state and exit. ixflag--composition flag: 1 = ref state applied to pure components 2 = ref state applied to mixture x0 following input has meaning only if ixflag = 2 x0--composition for which h0, s0 apply; array(1:nc) [mol frac] this is useful for mixtures of a predefined composition, e.g. refrigerant blends such as R410A following inputs have meaning only if hrf = 'OTH' h0--reference state enthalpy at t0,p0 {x0} [J/mol] s0--reference state entropy at t0,p0 {x0} [J/mol-K]

c t0--reference state temperature [K] c t0 = -1 indicates saturated liquid at normal boiling point c (bubble point for a mixture) c p0--reference state pressure [kPa] c p0 = -1 indicates saturated liquid at t0 {and x0} c p0 = -2 indicates saturated vapor at t0 {and x0} c outputs: c ierr--error flag: 0 = successful c 22 = Tmin > Tref for IIR reference state c 23 = Tcrit < Tref for IIR reference state c 24 = Tmin > Tref for ASHRAE reference state c 25 = Tcrit < Tref for ASHRAE reference state c 26 = Tmin > Tnbp for NBP reference state c 27 = Tref, Pref for OTH ref state outside limits c -28 = can't apply 'DEF' to mixture; c will apply to pure components c -29 = unknown reference state specified; c will use 'DEF' c herr--error string (character*255 variable if ierr<>0) c [fluid parameters, etc. returned via various common blocks]

subroutine SETMIX (hmxnme,hfmix,hrf,ncc,hfiles,x,ierr,herr) c c c c c c c c c c c c c c c c c c c c open a mixture file (e.g., R410A.mix) and read constituents and mole fractions inputs: hmxnme--mixture file name to be read in [character*255] hfmix--mixture coefficients [character*255] file name containing coefficients for mixture model hrf--reference state for thermodynamic calculations [character*3] (see info in subroutine setup for specifics) outputs: ncc--number of fluids in mixture hfiles--array of file names specifying mixture components that were used to call setup. [character*255 variable] x--array of mole fractions for the specified mixture ierr--error flag: 0 = successful 101 = error in opening file -102 = mixture file contains mixing parameters -103 = composition not equal to one herr--error string (character*255 variable if ierr<>0)

subroutine SETPATH (hpth) c c set the path where the fluid files are located c c inputs: c hpth--location of the fluid files [character*255 variable] c The path does not need to contain the ending "\" and it can c point directly to the location where the DLL is stored if a c fluids subdirectory (with the corresponding fluid files) is c located there. c example: hpth='C:\Program Files\Refprop'

subroutine PUREFLD (icomp) c c c c c c c c Change the standard mixture setup so that the can be calculated as if SETUP had been called Calling this routine will disable all mixture To reset the mixture setup, call this routine properties of one fluid for a pure fluid. calculations. with icomp=0.

inputs: icomp--fluid number in a mixture to use as a pure fluid

subroutine GETMOD (icomp,htype,hcode,hcite) c c retrieve citation information for the property models used c c inputs: c icomp--pointer specifying component number c zero and negative values are used for ECS reference fluid(s) c htype--flag indicating which model is to be retrieved [character*3] c 'EOS': equation of state for thermodynamic properties c 'CP0': ideal part of EOS (e.g. ideal-gas heat capacity) c 'ETA': viscosity c 'VSK': viscosity critical enhancement c 'TCX': thermal conductivity c 'TKK': thermal conductivity critical enhancement c 'STN': surface tension c 'DE ': dielectric constant c 'MLT': melting line (freezing line, actually) c 'SBL': sublimation line c 'PS ': vapor pressure equation c 'DL ': saturated liquid density equation c 'DV ': saturated vapor density equation c outputs: c hcode--component model used for property specified in htype c c some possibilities for thermodynamic properties: c 'FEQ': Helmholtz free energy model c 'BWR': pure fluid modified Benedict-Webb-Rubin (MBWR) c 'ECS': pure fluid thermo extended corresponding states c c some possibilities for viscosity: c 'ECS': extended corresponding states (all fluids) c 'VS1': the 'composite' model for R134a, R152a, NH3, etc. c 'VS2': Younglove-Ely model for hydrocarbons c 'VS4': generalized friction theory of Quinones-Cisneros and Dieters c c some possibilities for thermal conductivity: c 'ECS': extended corresponding states (all fluids) c 'TC1': the 'composite' model for R134a, R152a, etc. c 'TC2': Younglove-Ely model for hydrocarbons c c some possibilities for surface tension: c 'ST1': surface tension as f(tau); tau = 1 - T/Tc c

c c c

hcite--component model used for property specified in htype; the first 3 characters repeat the model designation of hcode and the remaining are the citation for the source

subroutine SETKTV (icomp,jcomp,hmodij,fij,hfmix,ierr,herr) c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c set mixture model and/or parameters This subroutine must be called after SETUP, but before any call to SETREF; it need not be called at all if the default mixture parameters (those read in by SETUP) are to be used. inputs: icomp--component i jcomp--component j hmodij--mixing rule for the binary pair i,j [character*3] e.g. 'LJ1' (Lemmon-Jacobsen model) 'LM1' (modified Lemmon-Jacobsen model) or 'LIN' (linear mixing rules) 'RST' indicates reset all pairs to values from original call to SETUP (i.e. those read from file) [all other inputs are ignored] fij--binary mixture parameters [array of dimension nmxpar; currently nmxpar is set to 6] the parameters will vary depending on hmodij; for example, for the Lemmon-Jacobsen model (LJ1): fij(1) = zeta fij(2) = xi fij(3) = Fpq fij(4) = beta fij(5) = gamma fij(6) = 'not used' hfmix--file name [character*255] containing generalized parameters for the binary mixture model; this will usually be the same as the corresponding input to SETUP (e.g.,':fluids:hmx.bnc') outputs: ierr--error flag: 0 = successful 111 = error in opening mixture file 112 = mixture file of wrong type -113 = illegal i,j specification (i = j or i > nc or j > nc) herr--error string (character*255 variable if ierr<>0) [mixture parameters returned via various common blocks]

subroutine GETKTV (icomp,jcomp,hmodij,fij,hfmix,hfij,hbinp,hmxrul) c c c c c c c c c retrieve mixture model and parameter info for a specified binary This subroutine should not be called until after a call to SETUP. inputs: icomp--component i jcomp--component j outputs:

c c c c c c c c c c c c c c c c c c c

hmodij--mixing rule for the binary pair i,j (e.g. LJ1 or LIN) [character*3] fij--binary mixture parameters [array of dimension nmxpar; currently nmxpar is set to 6]; the parameters will vary depending on hmodij; hfmix--file name [character*255] containing parameters for the binary mixture model hfij--description of the binary mixture parameters [character*8 array of dimension nmxpar] for example, for the Lemmon-Jacobsen model (LJ1): fij(1) = zeta fij(2) = xi fij(3) = Fpq fij(4) = beta fij(5) = gamma fij(6) = 'not used' hbinp--documentation for the binary parameters [character*255] terminated with ASCII null character hmxrul--description of the mixing rule [character*255]

subroutine GETFIJ (hmodij,fij,hfij,hmxrul) c c c c c c c c c c c c c c c retrieve parameter info for a specified mixing rule This subroutine should not be called until after a call to SETUP. inputs: hmodij--mixing rule for the binary pair i,j (e.g. LJ1 or LIN) [character*3] outputs: fij--binary mixture parameters [array of dimension nmxpar; currently nmxpar is set to 6]; the parameters will vary depending on hmodij; hfij--description of the binary mixture parameters [character*8 array of dimension nmxpar] hmxrul--description of the mixing rule [character*255]

SATURATION-STATE SUBROUTINES subroutine SATT (t,x,kph,p,rhol,rhov,xliq,xvap,ierr,herr) c c iterate for saturated liquid and vapor states given temperature c and the composition of one phase c c inputs: c t--temperature [K] c if t is negative, then use other variables as c initial guesses at abs(t) c x--composition [array of mol frac] (phase specified by kph) c kph--phase flag: 1 = input x is liquid composition (bubble point) c 2 = input x is vapor composition (dew point) c 3 = input x is liquid composition (freezing point)

c 4 = input x is vapor composition (sublimation point) c outputs: c p--pressure [kPa] c rhol--molar density [mol/L] of saturated liquid c rhov--molar density [mol/L] of saturated vapor c For a pseudo pure fluid, the density of the equilibrium phase c is not returned. Call SATT twice, once with kph=1 to get c pliq and rhol, and once with kph=2 to get pvap and rhov. c xliq--liquid phase composition [array of mol frac] c xvap--vapor phase composition [array of mol frac] c ierr--error flag: 0 = successful c 1 = T < Tmin c 8 = x out of range c 9 = T and x out of range c 120 = CRITP did not converge c 121 = T > Tcrit c 122 = TPRHO-liquid did not converge (pure fluid) c 123 = TPRHO-vapor did not converge (pure fluid) c 124 = pure fluid iteration did not converge c following 3 error codes are advisory--iteration will either c converge on later guess or error out (ierr = 128) c -125 = TPRHO did not converge for parent ph (mix) c -126 = TPRHO did not converge for incipient (mix) c -127 = composition iteration did not converge c 128 = mixture iteration did not converge c herr--error string (character*255 variable if ierr<>0)

subroutine SATP (p,x,kph,t,rhol,rhov,xliq,xvap,ierr,herr) c c c c c c c c c c c c c c c c c c c c c c c c c c c c c iterate for saturated liquid and vapor states given pressure and the composition of one phase inputs: p--pressure [kPa] x--composition [array of mol frac] (phase specified by kph) kph--phase flag: 1 = input x is liquid composition 2 = input x is vapor composition 3 = input x is liquid composition (freezing point) 4 = input x is vapor composition (sublimation point) outputs: t--temperature [K] rhol--molar density [mol/L] of saturated liquid rhov--molar density [mol/L] of saturated vapor For a pseudo pure fluid, the density of the equilibrium phase is not returned. Call SATP twice, once with kph=1 to get tliq and rhol, and once with kph=2 to get tvap and rhov. xliq--liquid phase composition [array of mol frac] xvap--vapor phase composition [array of mol frac] ierr--error flag: 0 = successful 2 = P < Ptp 4 = P < 0 8 = x out of range 12 = P and x out of range 140 = CRITP did not converge 141 = P > Pcrit 142 = TPRHO-liquid did not converge (pure fluid)

c c c c c c c c c c c

143 = TPRHO-vapor did not converge (pure fluid) 144 = pure fluid iteration did not converge following 3 error codes are advisory--iteration will either converge on later guess or error out (ierr = 148) -144 = Raoult's law (mixture initial guess) did not converge -145 = TPRHO did not converge for parent ph (mix) -146 = TPRHO did not converge for incipient (mix) -147 = composition iteration did not converge 148 = mixture iteration did not converge herr--error string if ierr<>0 (character*255)

subroutine SATD (rho,x,kph,kr,t,p,rhol,rhov,xliq,xvap,ierr,herr) c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c iterate for temperature and pressure given a density along the saturation boundary and the composition inputs: rho--molar density [mol/L] x--composition [array of mol frac] kph--flag specifying desired root for multi-valued inputs has meaning only for water at temperatures close to its triple point -1 = return middle root (between 0 and 4 C) 1 = return highest temperature root (above 4 C) 3 = return lowest temperature root (along freezing line) outputs: t--temperature [K] p--pressure [kPa] rhol--molar density [mol/L] of saturated liquid rhov--molar density [mol/L] of saturated vapor xliq--liquid phase composition [array of mol frac] xvap--vapor phase composition [array of mol frac] kr--phase flag: 1 = input state is liquid 2 = input state is vapor in equilibrium with liq 3 = input state is liquid in equilibrium with solid 4 = input state is vapor in equilibrium with solid ierr--error flag: 0 = successful 2 = D > Dmax 8 = x out of range 10 = D and x out of range 160 = CRITP did not converge 161 = SATD did not converge herr--error string (character*255 variable if ierr<>0) N.B. kr = 3,4 presently working only for pure components either (rhol,xliq) or (rhov,xvap) will correspond to the input state with the other pair corresponding to the other phase in equilibrium with the input state

subroutine SATH (h,x,kph,nroot,k1,t1,p1,d1,k2,t2,p2,d2,ierr,herr) c c iterate for temperature, pressure, and density given enthalpy along c the saturation boundary and the composition

c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c

inputs: h--molar enthalpy [J/mol] x--composition [array of mol frac] kph--flag specifying desired root 0 = return all roots along the liquid-vapor line 1 = return only liquid VLE root 2 = return only vapor VLE roots 3 = return liquid SLE root (melting line) 4 = return vapor SVE root (sublimation line) outputs: nroot--number of roots. Set to one for kph=1,3,4 if ierr=0 k1--phase of first root (1-liquid, 2-vapor, 3-melt, 4-subl) t1--temperature of first root [K] p1--pressure of first root [kPa] d1--molar density of first root [mol/L] k2--phase of second root (1-liquid, 2-vapor, 3-melt, 4-subl) t2--temperature of second root [K] p2--pressure of second root [kPa] d2--molar density of second root [mol/L] ierr--error flag: 0 = successful 2 = h < hmin 4 = h > hmax 8 = h > htrp (for subl input) 160 = CRITP did not converge 161 = SATH did not converge for one root 162 = SATH did not converge for both roots herr--error string (character*255 variable if ierr<>0) The second root is always set as the root in the vapor at temperatures below the maximum enthalpy on the vapor saturation line. If kph is set to 2, and only one root is found in the vapor (this occurs when h<hcrit) the state point will be placed in k2,t2,p2,d2. If kph=0 and this situation occurred, the first root (k1,t1,p1,d1) would be in the liquid (k1=1, k2=2). N.B. kph = 3,4 presently working only for pure components

subroutine SATE (e,x,kph,nroot,k1,t1,p1,d1,k2,t2,p2,d2,ierr,herr) c c c c c c c c c c c c c c c iterate for temperature, pressure, and density given energy along the saturation boundary and the composition inputs: e--molar energy [J/mol] x--composition [array of mol frac] kph--flag specifying desired root 0 = return all roots along the liquid-vapor line 1 = return only liquid VLE root 2 = return only vapor VLE roots 3 = return liquid SLE root (melting line) 4 = return vapor SVE root (sublimation line) outputs: see SATH for description of outputs

& c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c

subroutine SATS (s,x,kph,nroot,k1,t1,p1,d1,k2,t2,p2,d2, k3,t3,p3,d3,ierr,herr)

iterate for temperature, pressure, and density given an entropy along the saturation boundary and the composition inputs: s--molar entropy [J/mol-K] x--composition [array of mol frac] kph--flag specifying desired root 0 = return all roots along the liquid-vapor line 1 = return only liquid VLE root 2 = return only vapor VLE roots 3 = return liquid SLE root (melting line) 4 = return vapor SVE root (sublimation line) outputs: nroot--number of roots. Set to one for kph=1,3,4 if ierr=0 k1--phase of first root (1-liquid, 2-vapor, 3-melt, 4-subl) t1--temperature of first root [K] p1--pressure of first root [kPa] dl--molar density of first root [mol/L] k2--phase of second root (1-liquid, 2-vapor, 3-melt, 4-subl) t2--temperature of second root [K] p2--pressure of second root [kPa] d2--molar density of second root [mol/L] k3--phase of third root (1-liquid, 2-vapor, 3-melt, 4-subl) t3--temperature of third root [K] p3--pressure of third root [kPa] d3--molar density of third root [mol/L] ierr--error flag: 0 = successful 2 = s < smin 4 = s > smax 8 = s > strp (for subl input) 160 = CRITP did not converge 161 = SATS did not converge for one root 162 = SATS did not converge for two roots 163 = SATS did not converge for all roots herr--error string (character*255 variable if ierr<>0) The second root is always set as the root in the vapor at temperatures below the maximum entropy on the vapor saturation line. If kph is set to 2, and only one root is found in the vapor (this occurs when s<scrit) the state point will be placed in k2,t2,p2,d2. If kph=0 and this situation occurred, the first root (k1,t1,p1,d1) would be in the liquid (k1=1, k2=2). The third root is the root with the lowest temperature. For fluids with multiple roots: When only one root is found in the vapor phase (this happens only at very low temperatures past the region where three roots are located), the value of the root is still placed in k3,t3,p3,d3. For fluids that never have more than one root (when there is no maximum entropy along the saturated vapor line), the value of the root is always placed in k1,t1,p1,d1. N.B. kph = 3,4 presently working only for pure components

subroutine CSATK (icomp,t,kph,p,rho,csat,ierr,herr) c

c c c c c c c c c c c c c c c c c

compute the heat capacity along the saturation line as a function of temperature for a given component csat can be calculated two different ways: Csat = Cp - T(DvDT)(DPDTsat) Csat = Cp - beta/rho*hvap/(vliq - vvap) where beta is the volume expansivity inputs: icomp--component number in mixture (1..nc); 1 for pure fluid t--temperature [K] kph--phase flag: 1 = liquid calculation 2 = vapor calculation outputs: p--saturation pressure [kPa] rho--saturation molar density [mol/L] csat--saturation heat capacity [J/mol-K]

subroutine DPTSATK (icomp,t,kph,p,rho,csat,dpt,ierr,herr) c c c c c c c c c c c c c c c c c compute the heat capacity and dP/dT along the saturation line as a function of temperature for a given component. See also subroutine CSATK. inputs: icomp--component number in mixture (1..nc); 1 for pure fluid t--temperature [K] kph--phase flag: 1 = liquid calculation 2 = vapor calculation outputs: p--saturation pressure [kPa] rho--saturation molar density [mol/L] csat--saturation heat capacity [J/mol-K] (same as that called from CSATK) dpt--dP/dT along the saturation line [kPa/K] (this is not dP/dT "at" the saturation line for the single phase state, but the change in saturated vapor pressure as the saturation temperature changes.)

subroutine CV2PK (icomp,t,rho,cv2p,csat,ierr,herr) c c c c c c c c c c c c c c c c compute the isochoric heat capacity in the two phase (liquid+vapor) region inputs: icomp--component number in mixture (1..nc); 1 for pure fluid t--temperature [K] rho--density [mol/l] if known If rho=0, then a saturated liquid state is assumed. outputs: cv2p--isochoric two-phase heat capacity [J/mol-K] csat--saturation heat capacity [J/mol-K] (Although there is already a csat routine in REFPROP, it is also returned here. However, the calculation speed is slower than csat.)

Two similar routines are provided for calculating surface tension. SURTEN is more efficient if the liquid and vapor density and composition are known (e.g., from a previous call to SATT). If these are not known, then SURFT may be used. subroutine SURFT (t,rhol,xl,sigma,ierr,herr) c c compute surface tension c c inputs: c t--temperature [K] c xl--composition of liquid phase [array of mol frac] c outputs: c rhol--molar density of liquid phase [mol/L] c if rho > 0 use as input value c < 0 call SATT to find density c sigma--surface tension [N/m] c ierr--error flag: 0 = successful c 1 = T < Tmin c 8 = x out of range c 9 = T and x out of range c 120 = CRITP did not converge c 121 = T > Tcrit c 122 = TPRHO-liquid did not converge in SATT c 123 = TPRHO-vapor did not converge in SATT c 124 = SATT pure fluid iteration did not converge c 128 = SATT mixture iteration did not converge c herr--error string if ierr<>0 (character*255)

subroutine SURTEN (t,rhol,rhov,xl,xv,sigma,ierr,herr) c c compute surface tension c c inputs: c t--temperature [K] c rhol--molar density of liquid phase [mol/L] c rhov--molar density of vapor phase [mol/L] c if either rhol or rhov < 0 call SATT to find densities c xl--composition of liquid phase [array of mol frac] c xv--composition of liquid phase [array of mol frac] c (xv is optional input if rhol < 0 or rhov < 0) c outputs: c sigma--surface tension [N/m] c ierr--error flag: 0 = successful c 1 = T < Tmin c 8 = x out of range c 9 = T and x out of range c 120 = CRITP did not converge c 121 = T > Tcrit c 122 = TPRHO-liquid did not converge in SATT c 123 = TPRHO-vapor did not converge in SATT c 124 = SATT pure fluid iteration did not converge c 128 = SATT mixture iteration did not converge

herr--error string if ierr<>0 (character*255)

FLASH SUBROUTINES So-called "flash" calculations involve a determination of the thermodynamic state, given two independent variables plus composition. In addition to the inputs of temperature and pressure, which is the most common flash calculation, REFPROP provides routines for virtually all combinations of temperature, pressure, or density as the first variable and density, internal energy, enthalpy, entropy, or quality as the second variable. The combination of enthalpy and entropy is also supported. Flash subroutines are provided for cases where the state is known to be single phase (liquid or vapor) or two-phase (liquid plus vapor), and also for the general case where the phase is not known. Because of the many combinations and their parallel structure, these routines are described in groups. The first two letters of the subroutine name indicate the independent variables, where T P D E H S Q = = = = = = = temperature [K] pressure [kPa] density [mol/L] internal energy [J/mol] enthalpy [J/mol] entropy [J/mol-K] vapor quality [moles vapor/total moles] or [kg vapor/total kg] depending on the value of the input flag kq

GENERAL FLASH SUBROUTINES For cases where the phase is not known, the following routines are available. subroutine subroutine subroutine subroutine subroutine subroutine subroutine subroutine subroutine subroutine subroutine subroutine subroutine subroutine subroutine subroutine TPFLSH TDFLSH THFLSH TSFLSH TEFLSH PDFLSH PHFLSH PSFLSH PEFLSH HSFLSH ESFLSH DHFLSH DSFLSH DEFLSH TQFLSH PQFLSH (t,p,z,D,Dl,Dv,x,y,q,e,h,s,cv,cp,w,ierr,herr) (t,D,z,p,Dl,Dv,x,y,q,e,h,s,cv,cp,w,ierr,herr) (t,h,z,kr,p,D,Dl,Dv,x,y,q,e,s,cv,cp,w,ierr,herr) (t,s,z,kr,p,D,Dl,Dv,x,y,q,e,h,cv,cp,w,ierr,herr) (t,e,z,kr,p,D,Dl,Dv,x,y,q,h,s,cv,cp,w,ierr,herr) (p,D,z,t,Dl,Dv,x,y,q,e,h,s,cv,cp,w,ierr,herr) (p,h,z,t,D,Dl,Dv,x,y,q,e,s,cv,cp,w,ierr,herr) (p,s,z,t,D,Dl,Dv,x,y,q,e,h,cv,cp,w,ierr,herr) (p,e,z,t,D,Dl,Dv,x,y,q,h,s,cv,cp,w,ierr,herr) (h,s,z,t,p,D,Dl,Dv,x,y,q,e,cv,cp,w,ierr,herr) (e,s,z,t,p,D,Dl,Dv,x,y,q,h,cv,cp,w,ierr,herr) (D,h,z,t,p,Dl,Dv,x,y,q,e,s,cv,cp,w,ierr,herr) (D,s,z,t,p,Dl,Dv,x,y,q,e,h,cv,cp,w,ierr,herr) (D,e,z,t,p,Dl,Dv,x,y,q,h,s,cv,cp,w,ierr,herr) (t,q,z,kq,p,D,Dl,Dv,x,y,e,h,s,cv,cp,w,ierr,herr) (p,q,z,kq,t,D,Dl,Dv,x,y,e,h,s,cv,cp,w,ierr,herr)

c c flash calculation given two independent variables and bulk composition

c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c

These routines accept both single-phase and two-phase states as the input; if the phase is known, the specialized routines are faster inputs--two of the following as indicated by the first two letters of the subroutine name: t--temperature [K] p--pressure [kPa] e--internal energy [J/mol] h--enthalpy [J/mol] s--entropy [[J/mol-K] q--vapor quality [basis specified by kq] q = 0 indicates saturated liquid q = 1 indicates saturated vapor q < 0 or q > 1 are not allowed and will result in warning additional input--required for all routines z--overall (bulk) composition [array of mol frac] additional input--only for TQFLSH and PQFLSH kq--flag specifying units for input quality kq = 1 quality on MOLAR basis [moles vapor/total moles] kq = 2 quality on MASS basis [mass vapor/total mass] outputs--one, two, or all of the following, depending on the inputs: t--temperature [K] p--pressure [kPa] D--overall (bulk) molar density [mol/L] additional outputs--common to all routines Dl--molar density [mol/L] of the liquid phase Dv--molar density [mol/L] of the vapor phase if only one phase is present, Dl = Dv = D x--composition of liquid phase [array of mol frac] y--composition of vapor phase [array of mol frac] if only one phase is present, x = y = z additional output--common to all routines except TQFLSH and PQFLSH q--vapor quality on a MOLAR basis [moles vapor/total moles] q < 0 indicates subcooled (compressed) liquid q = 0 indicates saturated liquid q = 1 indicates saturated vapor q > 1 indicates superheated vapor q = 998 superheated vapor, but quality not defined (t > Tc) q = 999 indicates supercritical state (t > Tc) and (p > Pc) additional outputs--common to all routines, except that input quantities are not repeated e--overall (bulk) internal energy [J/mol] h--overall (bulk) enthalpy [J/mol] s--overall (bulk) entropy [J/mol-K] cv--isochoric (constant V) heat capacity [J/mol-K] cp--isobaric (constant p) heat capacity [J/mol-K] w--speed of sound [m/s] Cp, w are not defined for 2-phase states in such cases, a flag = -9.99998d6 is returned ierr--error flag: 0 = successful 1 = Tin < Tmin 4 = Pin < 0 5 = T and P out of range

c c c c c c

8 = x out of range (component and/or sum < 0 or > 1) 9 = x and T out of range 12 = x out of range and P < 0 13 = x and T and P out of range herr--error string (character*255 variable if ierr<>0)

SINGLE-PHASE FLASH SUBROUTINES These routines accept only single-phase states as inputs. They will be faster than the corresponding general routines, but will fail if called with an incorrect phase specification. The phase-specific subroutines also do not check limits, so may fail if called outside the range of the equation of state. The following single-phase routines are available. subroutine subroutine subroutine subroutine subroutine subroutine subroutine subroutine subroutine subroutine subroutine THFL1 TSFL1 TEFL1 PDFL1 PHFL1 PSFL1 PEFL1 HSFL1 DHFL1 DSFL1 DEFL1 (t,h,x,Dmin,Dmax,D,ierr,herr) (t,s,x,Dmin,Dmax,D,ierr,herr) (t,e,x,Dmin,Dmax,D,ierr,herr) (p,rho,x,t,ierr,herr) (p,h,x,kph,t,D,ierr,herr) (p,s,x,kph,t,D,ierr,herr) (p,e,x,kph,t,D,ierr,herr) (h,s,x,Dmin,Dmax,t,D,ierr,herr) (rho,h,x,t,ierr,herr) (rho,s,x,t,ierr,herr) (rho,e,x,t,ierr,herr)

c c inputs--two of the following as indicated by the first two letters of c the subroutine name: c t--temperature [K] c e--internal energy [J/mol] c h--enthalpy [J/mol] c s--entropy [[J/mol-K] c rho--molar density [mol/L] c c additional inputs c x--overall (bulk) composition [array of mol frac] c Dmin--lower bound on density [mol/L] c Dmax--upper bound on density [mol/L] c kph--phase flag: 1 = liquid c 2 = vapor c c outputs: c t--temperature [K] (present only for HSFL1) c D--molar density [mol/L] c ierr--error flag: 0 = successful c herr--error string (character*255 variable if ierr<>0)

The single-phase temperature-pressure flash is called many times by other routines, and has been optimized for speed; it requires a specific calling sequence.

subroutine TPRHO (t,p,x,kph,kguess,rho,ierr,herr) c c iterate for density as a function of temperature, pressure, and c composition for a specified phase c c*********************************************************************** c WARNING: c Invalid densities will be returned for T & P outside range of validity, c i.e., pressure > melting pressure, pressure less than saturation c pressure for kph=1, etc. c c*********************************************************************** c inputs: c t--temperature [K] c p--pressure [kPa] c x--composition [array of mol frac] c kph--phase flag: 1 = liquid c 2 = vapor c N.B.: 0 = stable phase--NOT ALLOWED (use TPFLSH) c (unless an initial guess is supplied for rho) c -1 = force the search in the liquid phase c -2 = force the search in the vapor phase c kguess--input flag: 1 = first guess for rho provided c 0 = no first guess provided c rho--first guess for molar density [mol/L], only if kguess = 1 c c outputs: c rho--molar density [mol/L] c ierr--error flag: 0 = successful c 200 = CRITP did not converge c 201 = illegal input (kph <= 0) c 202 = liquid-phase iteration did not converge c 203 = vapor-phase iteration did not converge c herr--error string (character*255 variable if ierr<>0)

TWO-PHASE FLASH SUBROUTINES These routines accept only two-phase (liquid + vapor) states as inputs. They will be faster than the corresponding general routines, but will fail if called with an incorrect phase specification. The phase-specific subroutines also do not check limits, so may fail if called outside the range of the equation of state. The following two-phase routines are available. subroutine subroutine subroutine subroutine TPFL2 DHFL2 DSFL2 DEFL2 (t,p,z,Dl,Dv,x,y,q,ierr,herr) (d,h,z,t,p,Dl,Dv,x,y,q,ierr,herr) (d,s,z,t,p,Dl,Dv,x,y,q,ierr,herr) (d,e,z,t,p,Dl,Dv,x,y,q,ierr,herr)

c inputs--two of the following c t--temperature [K] c p--pressure [kPa] c d--bulk molar density [mol/L] c e--internal energy [J/mol] c h--enthalpy [J/mol]

c s--entropy [[J/mol-K] c c outputs: c t--temperature [K] (not present for TPFL2) c p--pressure [kPa] (not present for TPFL2) c Dl--molar density [mol/L] of the liquid phase c Dv--molar density [mol/L] of the vapor phase c x--composition of liquid phase [array of mol frac] c y--composition of vapor phase [array of mol frac] c q--vapor quality on a MOLAR basis [moles vapor/total moles] c ierr--error flag: 0 = successful c herr--error string (character*255 variable if ierr<>0)

The following two-phase flash routines have the option to pass the dew and bubble point conditions as inputs if these values are known (from a previous call to SATT or SATP, for example), these two-phase routines will be significantly faster than the corresponding general FLSH routines described above. Otherwise, the general routines will be more reliable. subroutine THFL2 (t,h,z,ksat,pbub,pdew,Dlbub,Dvdew,ybub,xdew, p,Dl,Dv,x,y,q,ierr,herr) subroutine TSFL2 (t,s,z,ksat,pbub,pdew,Dlbub,Dvdew,ybub,xdew, & p,Dl,Dv,x,y,q,ierr,herr) subroutine TEFL2 (t,e,z,ksat,pbub,pdew,Dlbub,Dvdew,ybub,xdew, & p,Dl,Dv,x,y,q,ierr,herr) subroutine TDFL2 (t,D,z,ksat,pbub,pdew,Dlbub,Dvdew,ybub,xdew, & p,Dl,Dv,x,y,q,ierr,herr) subroutine PDFL2 (p,d,z,ksat,tbub,tdew,Dlbub,Dvdew,ybub,xdew, & t,Dl,Dv,x,y,q,ierr,herr) subroutine PHFL2 (p,h,z,ksat,tbub,tdew,Dlbub,Dvdew,ybub,xdew, & t,Dl,Dv,x,y,q,ierr,herr) subroutine PSFL2 (p,s,z,ksat,tbub,tdew,Dlbub,Dvdew,ybub,xdew, & t,Dl,Dv,x,y,q,ierr,herr) subroutine PEFL2 (p,e,z,ksat,tbub,tdew,Dlbub,Dvdew,ybub,xdew, & t,Dl,Dv,x,y,q,ierr,herr) subroutine TQFL2 (t,q,z,kq,ksat,pbub,pdew,Dlbub,Dvdew,ybub,xdew, & p,Dl,Dv,x,y,ierr,herr) subroutine PQFL2 (p,q,z,kq,ksat,tbub,tdew,Dlbub,Dvdew,ybub,xdew, & t,Dl,Dv,x,y,ierr,herr) & c inputs--two of the following c t--temperature [K] c p--pressure [kPa] c D--overall (bulk) molar density [mol/L] c e--internal energy [J/mol] c h--enthalpy [J/mol] c s--entropy [[J/mol-K] c q--vapor quality on a MOLAR basis [moles vapor/total moles] c c additional input--only for TQFL2 and PQFL2 c kq--flag specifying units for input quality c kq = 1 quality on MOLAR basis [moles vapor/total moles] c kq = 2 quality on MASS basis [mass vapor/total mass] c c additional inputs c z--overall (bulk) composition [array of mol frac] c ksat--flag for bubble and dew point limits c 0 = dew and bubble point limits computed within routine

c c c c c c c c c c c c c c c c c c c c c c c c c

1 = must provide values for following: tbub--bubble point temperature [K] at (p,x=z) tdew--dew point temperature [K] at (p,y=z) --or-pbub--bubble point pressure [kPa] at (t,x=z) pdew--dew point pressure [kPa] at (t,y=z) --and-Dlbub--liquid density [mol/L] at bubble point Dvdew--vapor density [mol/L] at dew point ybub--vapor composition [array of mol frac] at bubble point xdew--liquid composition [array of mol frac] at dew point outputs--one of the following, depending on the inputs: t--temperature [K] p--pressure [kPa] additional outputs--common to all routines Dl--molar density [mol/L] of the liquid phase Dv--molar density [mol/L] of the vapor phase x--composition of liquid phase [array of mol frac] y--composition of vapor phase [array of mol frac] q--vapor quality on a MOLAR basis [moles vapor/total moles] (not present for TQFL2 and PQFL2) ierr--error flag: 0 = successful herr--error string (character*255 variable if ierr<>0)

subroutine DQFL2 (d,q,z,kq,t,p,Dl,Dv,x,y,ierr,herr) c c c c c c c c c c c c c c c c c c c c c c c c c flash calculation given bulk density, quality, and composition This routine accepts only two-phase states as input; it is intended primarily for use by the general density-quality flash routine DQFLSH. It may be called independently if the state is known to be two-phase. But beware--this routine does not check limits. inputs: d--overall (bulk) molar density [mol/L] q--vapor quality on a MOLAR basis [moles vapor/total moles] z--overall (bulk) composition [array of mol frac] kq--flag specifying units for input quality kq = 1 quality on MOLAR basis [moles vapor/total moles] kq = 2 quality on MASS basis [mass vapor/total mass] outputs: t--temperature [K] p--pressure [kPa] Dl--molar density [mol/L] of the liquid phase Dv--molar density [mol/L] of the vapor phase x--composition of liquid phase [array of mol frac] y--composition of vapor phase [array of mol frac] ierr--error flag: 0 = successful herr--error string (character*255 variable if ierr<>0)

THERMODYNAMIC PROPERTY SUBROUTINES AS F(T,rho,X)

The following routines provide thermodynamic properties as a function of temperature, density, and composition. Typically, one or more of these will be called after finding the temperature and/or density with a call to one of the saturation or flash routines. Note that these routines assume that valid inputs are supplied--no range checking is performed. subroutine CRITP (x,tcrit,pcrit,Dcrit,ierr,herr) c c critical parameters as a function of composition c c input: c x--composition [array of mol frac] c outputs: c tcrit--critical temperature [K] c pcrit--critical pressure [kPa] c Dcrit--critical density [mol/L] c ierr--error flag: 0 = successful c 1 = did not converge c herr--error string (character*255 variable if ierr<>0)

subroutine THERM (t,rho,x,p,e,h,s,cv,cp,w,hjt) c c c c c c c c c c c c c c c c c c c c c c c c compute thermal quantities as a function of temperature, density, and compositions using core functions (Helmholtz free energy, ideal gas heat capacity and various derivatives and integrals) Based on derivations in Younglove & McLinden, JPCRD 23 #5, 1994, Appendix A for pressure-explicit equations (e.g. MBWR) and Baehr & Tillner-Roth, Thermodynamic Properties of Environmentally Acceptable Refrigerants, Berlin: Springer-Verlag (1995) for Helmholtz-explicit equations (e.g. FEQ). inputs: t--temperature [K] rho--molar density [mol/L] x--composition [array of mol frac] outputs: p--pressure [kPa] e--internal energy [J/mol] h--enthalpy [J/mol] s--entropy [J/mol-K] Cv--isochoric heat capacity [J/mol-K] Cp--isobaric heat capacity [J/mol-K] w--speed of sound [m/s] hjt--isenthalpic Joule-Thompson coefficient [K/kPa]

& &

subroutine THERM2 (t,rho,x,p,e,h,s,cv,cp,w,Z,hjt,A,G, xkappa,beta,dPdrho,d2PdD2,dPT,drhodT,drhodP, spare1,spare2,spare3,spare4)

c c compute thermal quantities as a function of temperature, density, c and compositions using core functions (Helmholtz free energy, ideal

c c c c c c c c c c c c c c c c c c c c c c c c c c c c c

gas heat capacity and various derivatives and integrals) this routine is the same as THERM, except that additional properties are calculated inputs: t--temperature [K] rho--molar density [mol/L] x--composition [array of mol frac] outputs: p--pressure [kPa] e--internal energy [J/mol] h--enthalpy [J/mol] s--entropy [J/mol-K] Cv--isochoric heat capacity [J/mol-K] Cp--isobaric heat capacity [J/mol-K] w--speed of sound [m/s] Z--compressibility factor (= PV/RT) [dimensionless] hjt--isenthalpic Joule-Thompson coefficient [K/kPa] A--Helmholtz energy [J/mol] G--Gibbs free energy [J/mol] xkappa--isothermal compressibility (= -1/V dV/dP = 1/rho dD/dP) [1/kPa] beta--volume expansivity (= 1/V dV/dT = -1/rho dD/dT) [1/K] dPdrho--derivative dP/drho [kPa-L/mol] d2PdD2--derivative d^2P/drho^2 [kPa-L^2/mol^2] dPT--derivative dP/dT [kPa/K] drhodT--derivative drho/dT [mol/(L-K)] drhodP--derivative drho/dP [mol/(L-kPa)] sparei--4 space holders for possible future properties

subroutine THERM0 (t,rho,x,p0,e0,h0,s0,cv0,cp00,w0,A0,G0) c c c c c c c c c c c c c c c c c c c c c compute ideal gas thermal quantities as a function of temperature, density, and compositions using core functions this routine is the same as THERM, except it only calculates ideal gas properties (Z=1) at any temperature and density inputs: t--temperature [K] rho--molar density [mol/L] x--composition [array of mol frac] outputs: p0--pressure [kPa] e0--internal energy [J/mol] h0--enthalpy [J/mol] s0--entropy [J/mol-K] Cv0--isochoric heat capacity [J/mol-K] Cp00--isobaric heat capacity [J/mol-K] w0--speed of sound [m/s] A0--Helmholtz energy [J/mol] G0--Gibbs free energy [J/mol]

subroutine ENTRO (t,rho,x,s)

c c c c c c c c c c c c c c

compute entropy as a function of temperature, density and composition using core functions (temperature derivative of Helmholtz free energy and ideal gas integrals) based on derivations in Younglove & McLinden, JPCRD 23 #5, 1994, equations A5, A19 - A26 inputs: t--temperature [K] rho--molar density [mol/L] x--composition [array of mol frac] output: s--entropy [J/mol-K]

subroutine ENTHAL (t,rho,x,h) c c c c c c c c c c c c c c compute enthalpy as a function of temperature, density, and composition using core functions (Helmholtz free energy and ideal gas integrals) based on derivations in Younglove & McLinden, JPCRD 23 #5, 1994, equations A7, A18, A19 inputs: t--temperature [K] rho--molar density [mol/L] x--composition [array of mol frac] output: h--enthalpy [J/mol]

subroutine ENERGY (t,rho,x,e) c c c c c c c c c c c c c compute energy as a function of temperature, density, and composition using core functions (Helmholtz free energy and ideal gas integrals) based on derivations in Younglove & McLinden, JPCRD 23 #5, 1994 inputs: t--temperature [K] rho--molar density [mol/L] x--composition [array of mol frac] output: e--energy [J/mol]

subroutine CVCP (t,rho,x,cv,cp) c c compute isochoric (constant volume) and isobaric (constant pressure) c heat capacity as functions of temperature, density, and composition c using core functions

c c c c c c c c c c c

based on derivations in Younglove & McLinden, JPCRD 23 #5, 1994, equation A15, A16 inputs: t--temperature [K] rho--molar density [mol/L] x--composition [array of mol frac] outputs: cv--isochoric heat capacity [J/mol-K] cp--isobaric heat capacity [J/mol-K]

subroutine CVCPK (icomp,t,rho,cv,cp) c c c c c c c c c c c c c c compute isochoric (constant volume) and isobaric (constant pressure) heat capacity as functions of temperature for a given component analogous to CVCP, except for component icomp, this is used by transport routines to calculate Cv & Cp for the reference fluid (component zero) inputs: icomp--component number in mixture (1..nc); 1 for pure fluid t--temperature [K] rho--molar density [mol/L] outputs: cv--isochoric heat capacity [J/mol-K] cp--isobaric heat capacity [J/mol-K]

subroutine GIBBS (t,rho,x,Ar,Gr) c c c c c c c c c c c c c c c c c c c c c c c c c compute residual Helmholtz and Gibbs free energy as a function of temperature, density, and composition using core functions N.B. The quantity calculated is G(T,rho) - G0(T,P*) = G(T,rho) - G0(T,rho) + RTln(RTrho/P*) where G0 is the ideal gas state and P* is a reference pressure which is equal to the current pressure of interest. Since Gr is used only as a difference in phase equilibria calculations where the temperature and pressure of the phases are equal, the (RT/P*) part of the log term will cancel and is omitted. "normal" (not residual) A and G are computed by subroutine AG based on derivations in Younglove & McLinden, JPCRD 23 #5, 1994, equations A8 - A12 inputs: t--temperature [K] rho--molar density [mol/L] x--composition [array of mol frac] outputs: Ar--residual Helmholtz free energy [J/mol]

Gr--residual Gibbs free energy [J/mol]

subroutine AG (t,rho,x,a,g) c c c c c c c c c c c c c compute Helmholtz and Gibbs energies as a function of temperature, density, and composition. N.B. These are not residual values (those are calculated by GIBBS). inputs: t--temperature [K] rho--molar density [mol/L] x--composition [array of mol frac] outputs: a--Helmholtz energy [J/mol] g--Gibbs free energy [J/mol]

subroutine PRESS (t,rho,x,p) c c c c c c c c c c c c compute pressure as a function of temperature, density, and composition using core functions direct implementation of core function of corresponding model inputs: t--temperature [K] rho--molar density [mol/L] x--composition [array of mol frac] output: p--pressure [kPa]

subroutine DPDD (t,rho,x,dpdrho) c c c c c c c c c c compute partial derivative of pressure w.r.t. density at constant temperature as a function of temperature, density, and composition inputs: t--temperature [K] rho--molar density [mol/L] x--composition [array of mol frac] output: dpdrho--dP/drho [kPa-L/mol]

subroutine DPDDK (icomp,t,rho,dPdrho) c c compute partial derivative of pressure w.r.t. density at constant c temperature as a function of temperature and density for a specified c component

c c c c c c c c c c

analogous to DPDD, except for component icomp, this is used by transport routines to calculate dP/dD for the reference fluid (component zero) inputs: icomp--component number in mixture (1..nc); 1 for pure fluid t--temperature [K] rho--molar density [mol/L] output: dPdrho--dP/drho [kPa-L/mol]

subroutine DPDD2 (t,rho,x,d2PdD2) c c c c c c c c c c compute second partial derivative of pressure w.r.t. density at const temperature as a function of temperature, density, and composition inputs: t--temperature [K] rho--molar density [mol/L] x--composition [array of mol frac] output: d2pdD2--d^2P/drho^2 [kPa-L^2/mol^2]

subroutine DPDT (t,rho,x,dpt) c c c c c c c c c c compute partial derivative of pressure w.r.t. temperature at constant density as a function of temperature, density, and composition inputs: t--temperature [K] rho--molar density [mol/L] x--composition [array of mol frac] output: dpt--dP/dT [kPa/K]

subroutine DPDTK (icomp,t,rho,dpt) c c c c c c c c c c c c c compute partial derivative of pressure w.r.t. temperature at constant density as a function of temperature and density for a specified component analogous to DPDT, except for component icomp, this is used by transport routines to calculate dP/dT inputs: icomp--component number in mixture (1..nc); 1 for pure fluid t--temperature [K] rho--molar density [mol/L] output: dpt--dP/dT [kPa/K]

subroutine DDDP (t,rho,x,drhodp) c c c c c c c c c c compute partial derivative of density w.r.t. pressure at constant temperature as a function of temperature, density, and composition inputs: t--temperature [K] rho--molar density [mol/L] x--composition [array of mol frac] output: drhodp--drho/dP [mol/(L-kPa)]

subroutine DDDT (t,rho,x,drhodt) c c c c c c c c c c c c compute partial derivative of density w.r.t. temperature at constant pressure as a function of temperature, density, and composition inputs: t--temperature [K] rho--molar density [mol/L] x--composition [array of mol frac] output: drhodt--drho/dT [mol/(L-K)] d(rho)/d(T) = -d(rho)/dP x dP/dT = -dP/dT / (dP/d(rho))

subroutine DHD1(t,rho,x,dhdt_d,dhdt_p,dhdd_t,dhdd_p,dhdp_t,dhdp_d) c c c c c c c c c c compute partial derivatives of enthalpy w.r.t. t, p, or rho at constant t, p, or rho as a function of temperature, density, and composition inputs: t--temperature [K] rho--molar density [mol/L] x--composition [array of mol frac] output: dht--dH/dT [J/mol-K]

subroutine FGCTY (t,rho,x,f) c c c c c c c c c c compute fugacity for each of the nc components of a mixture by numerical differentiation (using central differences) of the dimensionless residual Helmholtz energy based on derivations in E.W. Lemmon, MS Thesis, University of Idaho (1991); section 3.2 inputs: t--temperature [K]

c rho--molar density [mol/L] c x--composition [array of mol frac] c output: c f--array (1..nc) of fugacities [kPa]

subroutine VIRB (t,x,b) c c c c c c c c c compute second virial coefficient as a function of temperature and composition. inputs: t--temperature [K] x--composition [array of mol frac] outputs: b--second virial coefficient [L/mol]

subroutine DBDT (t,x,dbt) c c c c c c c c c compute the 2nd derivative of B (B is the second virial coefficient) with respect to T as a function of temperature and composition. inputs: t--temperature [K] x--composition [array of mol frac] outputs: dbt--2nd derivative of B with respect to T [L/mol-K]

subroutine VIRC (t,x,c) c c c c c c c c c compute the third virial coefficient as a function of temperature and composition. inputs: t--temperature [K] x--composition [array of mol frac] outputs: c--third virial coefficient [(L/mol)^2]

subroutine VIRD (t,x,d) c c c c c c c c c compute the fourth virial coefficient as a function of temperature and composition. inputs: t--temperature [K] x--composition [array of mol frac] outputs: d--fourth virial coefficient [(L/mol)^3]

subroutine B12 (t,x,b) c c compute b12 as a function of temperature and composition. c c inputs: c t--temperature [K] c x--composition [array of mol frac] c outputs: c b--b12 [(L/mol)^2]

subroutine EXCESS (t,p,x,vE,eE,hE,sE) c c c c c c c c c c c c c compute excess properties as a function of temperature, pressure, and composition. inputs: t--temperature [K] p--pressure [kPa] x--composition [array of mol frac] outputs: vE--excess volume [L/mol] eE--excess energy [J/mol] hE--excess enthalpy [J/mol] sE--excess entropy [J/mol-K]

&

subroutine THERM3 (t,rho,x, xkappa,beta,xisenk,xkt,betas,bs,xkkt,thrott,pi,spht)

c c Compute miscellaneous thermodynamic properties c c inputs: c t--temperature [K] c rho--molar density [mol/L] c x--composition [array of mol frac] c c outputs: c xkappa--Isothermal compressibility c beta--Volume expansivity c xisenk--Isentropic expansion coefficient c xkt--Isothermal expansion coefficient c betas--Adiabatic compressibility c bs--Adiabatic bulk modulus c xkkt--Isothermal bulk modulus c thrott--Isothermal throttling coefficient c pi--Internal pressure c spht--Specific heat input

TRANSPORT PROPERTY SUBROUTINE

subroutine TRNPRP (t,rho,x,eta,tcx,ierr,herr) c c c c c c c c c c c c c c c c c c c c c c c c c c c compute the transport properties of thermal conductivity and viscosity as functions of temperature, density, and composition inputs: t--temperature [K] rho--molar density [mol/L] x--composition array [mol frac] outputs: eta--viscosity (uPa.s) tcx--thermal conductivity (W/m.K) ierr--error flag: 0 = successful -31 = temperature out of range for conductivity -32 = density out of range for conductivity -33 = T and D out of range for conductivity -41 = temperature out of range for viscosity -42 = density out of range for viscosity -43 = T and D out of range for viscosity -51 = T out of range for both visc and t.c. -52 = D out of range for both visc and t.c. -53 = T and/or D out of range for visc and t.c. 39 = model not found for thermal conductivity 49 = model not found for viscosity 50 = ammonia/water mixture (no properties calculated) 51 = exactly at t, rhoc for a pure fluid; k is infinite -58,-59 = ECS model did not converge herr--error string (character*255 variable if ierr<>0)

MISCELLANEOUS PROPERTIES The following routines return the dielectric constant, melting line, and sublimation line. These properties are not available for all fluids in REFPROP. subroutine DIELEC (t,rho,x,de) c c compute the dielectric constant as a function of temperature, density, c and composition. c c inputs: c t--temperature [K] c rho--molar density [mol/L] c x--composition [array of mol frac] c output: c de--dielectric constant

subroutine MELTT (t,x,p,ierr,herr) c c compute the melting line pressure as a function of temperature c and composition. c

c inputs: c t--temperature [K] c x--composition [array of mol frac] c output: c p--melting line pressure [kPa] c ierr--error flag: 0 = successful c herr--error string (character*255 variable if ierr<>0)

subroutine MELTP (p,x,t,ierr,herr) c c compute the melting line temperature as a function of pressure c and composition. c c inputs: c p--melting line pressure [kPa] c x--composition [array of mol frac] c output: c t--temperature [K] c ierr--error flag: 0 = successful c herr--error string (character*255 variable if ierr<>0)

subroutine SUBLT (t,x,p,ierr,herr) c c compute the sublimation line pressure as a function of temperature c and composition. c c inputs: c t--temperature [K] c x--composition [array of mol frac] c output: c p--sublimation line pressure [kPa] c ierr--error flag: 0 = successful c herr--error string (character*255 variable if ierr<>0)

subroutine SUBLP (p,x,t,ierr,herr) c c compute the sublimation line temperature as a function of pressure c and composition. c c inputs: c p--sublimation line pressure [kPa] c x--composition [array of mol frac] c output: c t--temperature [K] c ierr--error flag: 0 = successful c herr--error string (character*255 variable if ierr<>0)

UTILITY SUBROUTINES

The following "utility" routines provide fluid constants, such as the molecular weight, and provide conversions between mass and molar quantities. subroutine INFO (icomp,wmm,ttrp,tnbpt,tc,pc,Dc,Zc,acf,dip,Rgas) c c provides fluid constants for specified component c c input: c icomp--component number in mixture; 1 for pure fluid c outputs: c wmm--molecular weight [g/mol] c ttrp--triple point temperature [K] c tnbpt--normal boiling point temperature [K] c tc--critical temperature [K] c pc--critical pressure [kPa] c Dc--critical density [mol/L] c Zc--compressibility at critical point [pc/(Rgas*Tc*Dc)] c acf--accentric factor [-] c dip--dipole moment [debye] c Rgas--gas constant [J/mol-K]

subroutine NAME (icomp,hname,hn80,hcas) c c provides name information for specified component c c input: c icomp--component number in mixture; 1 for pure fluid c outputs: c hname--component name [character*12] c hn80--component name--long form [character*80] c hcas--CAS (Chemical Abstracts Service) number [character*12]

function WMOL (x) c c molecular weight for a mixture of specified composition c c input: c x--composition array [array of mol frac] c c output (as function value): c WMOL--molar mass [g/mol], a.k.a. "molecular weight"

subroutine XMASS (xmol,xkg,wmix) c c converts composition on a mole fraction basis to mass fraction c c input: c xmol--composition array [array of mol frac] c outputs: c xkg--composition array [array of mass frac]

wmix--molar mass of the mixture [g/mol], a.k.a. "molecular weight"

subroutine XMOLE (xkg,xmol,wmix) c c converts composition on a mass fraction basis to mole fraction c c input: c xkg--composition array [array of mass frac] c outputs: c xmol--composition array [array of mol frac] c wmix--molar mass of the mixture [g/mol], a.k.a. "molecular weight"

subroutine LIMITX (htyp,t,D,p,x,tmin,tmax,Dmax,pmax,ierr,herr) c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c returns limits of a property model as a function of composition and/or checks input t, D, p against those limits Pure fluid limits are read in from the .fld files; for mixtures, a simple mole fraction weighting in reduced variables is used. Attempting calculations below the mininum temperature and/or above the maximum density will result in an error. These will often correspond to a physically unreasonable state; also many equations of state do not extrapolate reliably to lower T's and higher D's. A warning is issued if the temperature is above the maximum but below 1.5 times the maximum; similarly pressures up to twice the maximum result in only a warning. Most equations of state may be extrapolated to higher T's and P's. Temperatures and/or pressures outside these extended limits will result in an error. When calling with an unknown temperature, set t to -1 to avoid performing the melting line check inputs: htyp--flag indicating which models are to be checked [character*3] 'EOS': equation of state for thermodynamic properties 'ETA': viscosity 'TCX': thermal conductivity 'STN': surface tension t--temperature [K] D--molar density [mol/L] p--pressure [kPa] x--composition array [mol frac] N.B.--all inputs must be specified, if one or more are not available, (or not applicable as in case of surface tension) use reasonable values, such as: t = tnbp D = 0 p = 0 outputs: tmin--minimum temperature for model specified by htyp [K] tmax--maximum temperature [K] Dmax--maximum density [mol/L]

c c c c c c c c c c c c c c c c c

pmax--maximum pressure ierr--error flag: 0 = <>0 = -1 = 1 = 2 = -4 = 4 = 8 =

[kPa] all inputs within limits one or more inputs outside limits: 1.5*tmax > t > tmax t < tmin or t > 1.5*tmax D > Dmax or D < 0 2*pmax > p > pmax p < 0 or p > 2*pmax component composition < 0 or > 1 and/or composition sum < 0 or > 1 16 = p>pmelt -16 = t<ttrp (important for water) if multiple inputs are outside limits, ierr = abs[sum(ierr)] with the sign determined by the most severe excursion (ierr > 0 indicate an error--calculations not possible, ierr < 0 indicate a warning--results may be questionable) herr--error string (character*255 variable if ierr<>0)

subroutine LIMITK (htyp,icomp,t,D,p,tmin,tmax,Dmax,pmax,ierr,herr) c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c returns limits of a property model (read in from the .fld files) for a mixture component and/or checks input t, D, p against those limits This routine functions in the same manner as LIMITX except that the composition x is replaced by the component number icomp. Attempting calculations below the minimum temperature and/or above the maximum density will result in an error. These will often correspond to a physically unreasonable state; also many equations of state do not extrapolate reliably to lower T's and higher D's. A warning is issued if the temperature is above the maximum but below 1.5 times the maximum; similarly pressures up to twice the maximum result in only a warning. Most equations of state may be extrapolated to higher T's and P's. Temperatures and/or pressures outside these extended limits will result in an error. inputs: htyp--flag indicating which models are to be checked [character*3] 'EOS': equation of state for thermodynamic properties 'ETA': viscosity 'TCX': thermal conductivity 'STN': surface tension icomp--component number in mixture; 1 for pure fluid t--temperature [K] D--molar density [mol/L] p--pressure [kPa] N.B.--all inputs must be specified, if one or more are not available, (or not applicable as in case of surface tension) use reasonable values, such as: t = tnbp D = 0 p = 0 outputs: tmin--minimum temperature for model specified by htyp [K] tmax--maximum temperature [K] Dmax--maximum density [mol/L]

c c c c c c c c c c c c c c c

pmax--maximum pressure [kPa] ierr--error flag: 0 = all inputs within limits <>0 = one or more inputs outside limits: -1 = 1.5*tmax > t > tmax 1 = t < tmin or t > 1.5*tmax 2 = D > Dmax or D < 0 -4 = 2*pmax > p > pmax 4 = p < 0 or p > 2*pmax 16 = p>pmelt -16 = t<ttrp (important for water) if multiple inputs are outside limits, ierr = abs[sum(ierr)] with the sign determined by the most severe excursion (ierr > 0 indicate an error--calculations not possible, ierr < 0 indicate a warning--results may be questionable) herr--error string (character*255 variable if ierr<>0)

subroutine LIMITS (htyp,x,tmin,tmax,Dmax,pmax) c c c c c c c c c c c c c c c c c c returns limits of a property model as a function of composition Pure fluid limits are read in from the .fld files; for mixtures, a simple mole fraction weighting in reduced variables is used. inputs: htyp--flag indicating which models are to be checked [character*3] 'EOS': equation of state for thermodynamic properties 'ETA': viscosity 'TCX': thermal conductivity 'STN': surface tension x--composition array [mol frac] outputs: tmin--minimum temperature for model specified by htyp [K] tmax--maximum temperature [K] Dmax--maximum density [mol/L] pmax--maximum pressure [kPa]

subroutine ERRMSG (ierr,herr) c c c c c c c c c c c c c c c c c write error messages to default output; this subroutine should be called immediately after any call to a subroutine which potentially can error out inputs: ierr--error flag: 0 = successful (no message will be written) <0 = warning >0 = error herr--error string (character*255 variable) outputs: if iprnterr in common block prnterr is equal to zero: error string written to default output if iprnterr is equal to 1: error string written to screen if ierr is positive

c c c c c c c c c

if iprnterr is equal to -1: error string written to screen if iprnterr is equal to 3, -3: same as 1, -1, but program also pauses Note: no information should be writted to the screen when compiling the DLL.

subroutine QMASS (qmol,xl,xv,qkg,xlkg,xvkg,wliq,wvap,ierr,herr) c c converts quality and composition on a mole basis to a mass basis c c inputs: c qmol--molar quality [moles vapor/total moles] c qmol = 0 indicates saturated liquid c qmol = 1 indicates saturated vapor c 0 < qmol < 1 indicates a two-phase state c qmol < 0 or qmol > 1 are not allowed and will result in warning c xl--composition of liquid phase [array of mol frac] c xv--composition of vapor phase [array of mol frac] c outputs: c qkg--quality on mass basis [mass of vapor/total mass] c xlkg--mass composition of liquid phase [array of mass frac] c xvkg--mass composition of vapor phase [array of mass frac] c wliq--molecular weight of liquid phase [g/mol] c wvap--molecular weight of vapor phase [g/mol] c ierr--error flag: 0 = all inputs within limits c -19: input q < 0 or > 1 c herr--error string (character*255 variable if ierr<>0)

subroutine QMOLE (qkg,xlkg,xvkg,qmol,xl,xv,wliq,wvap,ierr,herr) c c converts quality and composition on a mass basis to a molar basis c c inputs: c qkg--quality on mass basis [mass of vapor/total mass] c qkg = 0 indicates saturated liquid c qkg = 1 indicates saturated vapor c 0 < qkg < 1 indicates a two-phase state c qkg < 0 or qkg > 1 are not allowed and will result in warning c xlkg--mass composition of liquid phase [array of mass frac] c xvkg--mass composition of vapor phase [array of mass frac] c outputs: c qmol--quality on mass basis [mass of vapor/total mass] c xl--molar composition of liquid phase [array of mol frac] c xv--molar composition of vapor phase [array of mol frac] c wliq--molecular weight of liquid phase [g/mol] c wvap--molecular weight of vapor phase [g/mol] c ierr--error flag: 0 = all inputs within limits c -19: input q < 0 or > 1 c herr--error string (character*255 variable if ierr<>0)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy