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_bwr.for core_cpp.for core_de.for core_ecs.for
core_feq.for core_mlt.for core_ph0.for core_pr.for core_stn.for
flash2.for flsh_sub.for idealgas.for mix_aga8.for mix_hmx.for
prop_sub.for realgas.for sat_sub.for setup.for setup2.for
trns_ecs.for trns_tcx.for trns_vis.for trnsp.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.obj core_ecs.obj core_feq.obj core_mlt.obj core_ph0.obj core_stn.obj core_pr.obj flash2.obj flsh_sub.obj idealgas.obj mix_aga8.obj mix_hmx.obj prop_sub.obj realgas.obj sat_sub.obj setup2.obj trns_ecs.obj trns_tcx.obj trns_vis.obj trnsp.obj utility.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 SETMOD (optional)
call SETUP (REQUIRED)
call SETKTV (optional)
call SETREF (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 K
pressure, fugacity kPa
density mol/L
composition mole fraction
quality mole basis (moles vapor/total moles)
enthalpy, internal energy J/mol
Gibbs, Helmholtz free energy J/mol
entropy, heat capacity J/(mol.K)
speed of sound m/s
Joule-Thompson coefficient K/kPa
d(p)/d(rho) kPa.L/mol
d2(p)/d(rho)2 kPa.(L/mol)^2
viscosity microPa.s (10^-6 Pa.s)
thermal conductivity W/(m.K)
dipole moment debye
surface tension 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 call the SETUP routine with the same inputs as SETUP except for
c the hfld variable. This subroutine is generally used in calls
c to the REFPROP DLL since the call cannot handle a string array.
c The hfld variable is a string of length 10000. For a pure fluid,
c it simply contains the name of the fluid file (with a path if needed).
c For a mixture, it contains the names of the constituents in the
c mixture separated by a |. For the air mixture, this would be
c something like (depends on the need for paths):
c hfld='fluids\nitrogen.fld|fluids\argon.fld|fluids\oxygen.fld|'
subroutine SETFLD