function[varargout] = flprop(fluid,utemp,varargin)
%FLPROP Interpolates and returns thermophysical properties of various fluids
%By: Tom Ames                   Mark Cutler
%    thomaslames@gmail.com      markjcutler@gmail.com
%flprops calculates and returns various fluid properties using the syntax:
%       [returned properties] = flprops(fluid,temp,property list)
%where fluid is a character array representing the desired fluid, temp is
%the temperatue at which the user would like to get the property values,
%and property list is a comma seperated list of the properties to be
%returned.  The properties are returned as a [1xn] matrix where n represents
%the number of properties requested.  The values in the matrix will be in
%the same order that the user entered them.  The following fluid types
%are supported:
%
%       Gases at atmospheric pressure:
%           Air:                'air'
%           Ammonia:            'nh3'
%           Carbon dioxide:     'co2'
%           Carbon monoxide:    'co'
%           Helium:             'he'
%           Hydrogen:           'h2'
%           Nitrogen:           'n2'
%           Oxygen:             'o2'
%           Water Vapor:        'steam'
%
%       Saturated liquids:
%           Unused Engine Oil:  'oil'
%           Ethylene Glycol:    'eth_gly'
%           Glycerin:           'glyc'
%           Refrigerant-132a:   'r134a'
%           Refrigerant-22:     'r22'
%           Mercury:            'hg'
%           Water:              'water'
%
%The properties supported for both gases at STP and saturated fluids are:
%           density:                'rho'
%           specific heat:          'cp'
%           viscosity:              'mu'
%           kinematic viscosity:    'nu'
%           thermal conductivity:   'k'
%           thermal diffusivity:    'alpha'
%           Prandlt number:         'Pr'
%           expansion coefficient:  'beta'
%
%Values for saturated liquid and vapor mixtures of water are also available.
%To access these values the following syntax is used:
%       [returned properties]=flprops('water',temp,property list,options)
%where options can be of any of the following forms:
%
%           'satvap': returns property values for a satured vapor at the
%               user defined temperature.
%           'satliq': returns property values for a satured liquid at the
%               user defined temperature.
%           'mixture',option2: returns property values for a satured
%               liquid/vapor mixture at the user defined temperature.  The
%               quality of the mixture is calculated using any one of the
%               following user defined values for a property.  Only one
%               should be used, and and it should follow the format shown
%               below:
%                   'quality',value: user knows quality
%                   'v',value: user knows specific volume
%                   'cp',value: user knows specific heat
%                   'mu',value: user knows viscosity
%                   'k',value: user knows thermal conductivity
%                   'Pr',value: user knows Prandlt number
%
%Supported properties are for liquid/vapor mixtures of water are:
%           density:                'rho'
%           specific heat:          'cp'
%           viscosity:              'mu'
%           kinematic viscosity:    'nu'
%           thermal conductivity:   'k'
%           thermal diffusivity:    'alpha'
%           Prandlt number:         'Pr'
%           pressure:               'p'
%           surface tension:        'sigma'
%           heat of vaporizate:     'hfg'
%
%Properties have the following units:
%       Temperature:                    K
%       Density 'rho':                  kg/m^3
%       Specific Heat 'cp':             J/(kg*K)
%       Viscosity 'mu':                 N*s/m^2
%       Kinematic Viscosity 'nu':       m^2/s
%       Thermal Conductivity 'k':       W/(m*K)
%       Thermal Diffusivity 'alpha':    m^2/s
%       Prandlt number 'Pr':            unitless
%       Pressure 'p':                   Pa
%       Surface tension 'sigma':        N/m
%       Heat of Vaporization 'hfg':     J/kg
%       Expansion Coefficient 'beta':   1/K

% possible inputs depending on type of fluid entered
opts1 = strvcat('rho','v','cp','mu','nu','k','alpha','Pr','beta');%saturated liquids and gases at STP
opts2 = strvcat('p','v','rho','hfg','cp','mu','nu','k','alpha','Pr','sigma','beta');
wateropts = strvcat('satliq','satvap','mixture');

%initialized matrices for checking purposes later
rho   = [];
v     = [];
cp    = [];
mu    = [];
nu    = [];
k     = [];
alpha = [];
Pr    = [];
p     = [];
hfg   = [];
sigma = [];
beta  = [];

%devides the inputs into fluid properties and options
numprops = 0;
index = 0;
for(i=[1:length(varargin)])
    if(ischar(varargin{i}))
        if(strmatch(varargin{i},wateropts))
            index=i;
            break;
        else
            numprops = numprops + 1;
        end
    end
end

%big tables
%propopts must set with each fluid depending on what type of fluid it is
if(isequal('air',fluid))
    propopts = opts1;
    temp  = [100:50:1000,1100:100:2500,3000]';
    rho   = [3.556E+00	2.336E+00	1.746E+00	1.395E+00	1.161E+00	9.950E-01	8.711E-01	7.740E-01	6.964E-01	6.329E-01	5.804E-01	5.356E-01	4.975E-01	4.643E-01	4.354E-01	4.097E-01	3.868E-01	3.666E-01	3.482E-01	3.166E-01	2.902E-01	2.679E-01	2.488E-01	2.322E-01	2.177E-01	2.049E-01	1.935E-01	1.833E-01	1.741E-01	1.658E-01	1.582E-01	1.513E-01	1.448E-01	1.389E-01	1.135E-01]';
    cp    = [1.032E+03	1.012E+03	1.007E+03	1.006E+03	1.007E+03	1.009E+03	1.014E+03	1.021E+03	1.030E+03	1.040E+03	1.051E+03	1.063E+03	1.075E+03	1.087E+03	1.099E+03	1.110E+03	1.121E+03	1.131E+03	1.141E+03	1.159E+03	1.175E+03	1.189E+03	1.207E+03	1.230E+03	1.248E+03	1.267E+03	1.286E+03	1.307E+03	1.337E+03	1.372E+03	1.417E+03	1.478E+03	1.558E+03	1.665E+03	2.726E+03]';
    mu    = [7.110E-06	1.034E-05	1.325E-05	1.596E-05	1.846E-05	2.082E-05	2.301E-05	2.507E-05	2.701E-05	2.884E-05	3.058E-05	3.225E-05	3.388E-05	3.546E-05	3.698E-05	3.843E-05	3.981E-05	4.113E-05	4.244E-05	4.490E-05	4.730E-05	4.960E-05	5.300E-05	5.570E-05	5.840E-05	6.110E-05	6.370E-05	6.630E-05	6.890E-05	7.150E-05	7.400E-05	7.660E-05	7.920E-05	8.180E-05	9.550E-05]';
    nu    = [2.000E-06	4.426E-06	7.590E-06	1.144E-05	1.589E-05	2.092E-05	2.641E-05	3.239E-05	3.879E-05	4.557E-05	5.269E-05	6.021E-05	6.810E-05	7.637E-05	8.493E-05	9.380E-05	1.029E-04	1.122E-04	1.219E-04	1.418E-04	1.629E-04	1.851E-04	2.130E-04	2.400E-04	2.680E-04	2.980E-04	3.290E-04	3.620E-04	3.960E-04	4.310E-04	4.680E-04	5.060E-04	5.470E-04	5.890E-04	8.410E-04]';
    k     = [9.340E-03	1.380E-02	1.810E-02	2.230E-02	2.630E-02	3.000E-02	3.380E-02	3.730E-02	4.070E-02	4.390E-02	4.690E-02	4.970E-02	5.240E-02	5.490E-02	5.730E-02	5.960E-02	6.200E-02	6.430E-02	6.670E-02	7.150E-02	7.630E-02	8.200E-02	9.100E-02	1.000E-01	1.060E-01	1.130E-01	1.200E-01	1.280E-01	1.370E-01	1.470E-01	1.600E-01	1.750E-01	1.960E-01	2.220E-01	4.860E-01]';
    alpha = [2.540E-06	5.840E-06	1.030E-05	1.590E-05	2.250E-05	2.990E-05	3.830E-05	4.720E-05	5.670E-05	6.670E-05	7.690E-05	8.730E-05	9.800E-05	1.090E-04	1.200E-04	1.310E-04	1.430E-04	1.550E-04	1.680E-04	1.950E-04	2.240E-04	2.380E-04	3.030E-04	3.500E-04	3.900E-04	4.350E-04	4.820E-04	5.340E-04	5.890E-04	6.460E-04	7.140E-04	7.830E-04	8.690E-04	9.600E-04	1.570E-03]';
    Pr    = [7.860E-01	7.580E-01	7.370E-01	7.200E-01	7.070E-01	7.000E-01	6.900E-01	6.860E-01	6.840E-01	6.830E-01	6.850E-01	6.900E-01	6.950E-01	7.020E-01	7.090E-01	7.160E-01	7.200E-01	7.230E-01	7.260E-01	7.280E-01	7.280E-01	7.190E-01	7.030E-01	6.850E-01	6.880E-01	6.850E-01	6.830E-01	6.770E-01	6.720E-01	6.670E-01	6.550E-01	6.470E-01	6.300E-01	6.130E-01	5.360E-01]';
elseif(isequal('nh3',fluid))
    propopts = opts1;
    temp  = [3.0000E+02	3.2000E+02	3.4000E+02	3.6000E+02	3.8000E+02	4.0000E+02	4.2000E+02	4.4000E+02	4.6000E+02	4.8000E+02	5.0000E+02	5.2000E+02	5.4000E+02	5.6000E+02	5.8000E+02]';
    rho   = [6.8940E-01	6.4480E-01	6.0590E-01	5.7160E-01	5.4100E-01	5.1360E-01	4.8880E-01	4.6640E-01	4.4600E-01	4.2730E-01	4.1010E-01	3.9420E-01	3.7950E-01	3.7080E-01	3.5330E-01]';
    cp    = [2.1580E+00	2.1700E+00	2.1920E+00	2.2210E+00	2.2540E+00	2.2870E+00	2.3220E+00	2.3570E+00	2.3930E+00	2.4300E+00	2.4670E+00	2.5040E+00	2.5400E+00	2.5770E+00	2.6130E+00]';
    mu    = [1.0150E-05	1.0900E-05	1.1650E-05	1.2400E-05	1.3100E-05	1.3800E-05	1.4500E-05	1.5250E-05	1.5900E-05	1.6650E-05	1.7300E-05	1.8000E-05	1.8650E-05	1.9300E-05	1.9950E-05]';
    nu    = [1.4700E-05	1.6900E-05	1.9200E-05	2.1700E-05	2.4200E-05	2.6900E-05	2.9700E-05	3.2700E-05	3.5700E-05	3.9000E-05	4.2200E-05	4.5700E-05	4.9100E-05	5.2000E-05	5.6500E-05]';
    k     = [2.4700E-02	2.7200E-02	2.9300E-02	3.1600E-02	3.4000E-02	3.7000E-02	4.0400E-02	4.3500E-02	4.6300E-02	4.9200E-02	5.2500E-02	5.4500E-02	5.7500E-02	6.0600E-02	6.3800E-02]';
    alpha = [1.6600E-05	1.9400E-05	2.2100E-05	2.4900E-05	2.7900E-05	3.1500E-05	3.5600E-05	3.9600E-05	4.3400E-05	4.7400E-05	5.1900E-05	5.5200E-05	5.9700E-05	6.3400E-05	6.9100E-05]';
    Pr    = [8.8700E-01	8.7000E-01	8.7200E-01	8.7200E-01	8.6900E-01	8.5300E-01	8.3300E-01	8.2600E-01	8.2200E-01	8.2200E-01	8.1300E-01	8.2700E-01	8.2400E-01	8.2700E-01	8.1700E-01]';
elseif(isequal('co2',fluid))
    propopts = opts1;
    temp  = [2.8000E+02	3.0000E+02	3.2000E+02	3.4000E+02	3.6000E+02	3.8000E+02	4.0000E+02	4.5000E+02	5.0000E+02	5.5000E+02	6.0000E+02	6.5000E+02	7.0000E+02	7.5000E+02	8.0000E+02]';
    rho   = [1.9022E+00	1.7730E+00	1.6609E+00	1.5618E+00	1.4743E+00	1.3961E+00	1.3257E+00	1.1782E+00	1.0594E+00	9.6250E-01	8.8260E-01	8.1430E-01	7.5640E-01	7.0570E-01	6.6140E-01]';
    cp    = [8.3000E-01	8.5100E-01	8.7200E-01	8.9100E-01	9.0800E-01	9.2600E-01	9.4200E-01	9.8100E-01	1.0200E+00	1.0500E+00	1.0800E+00	1.1000E+00	1.1300E+00	1.1500E+00	1.1700E+00]';
    mu    = [1.4000E-05	1.4900E-05	1.5600E-05	1.6500E-05	1.7300E-05	1.7100E-05	1.9000E-05	2.1000E-05	2.3100E-05	2.5100E-05	2.7000E-05	2.8800E-05	3.0500E-05	3.2100E-05	3.3700E-05]';
    nu    = [7.3600E-06	8.4000E-06	9.3900E-06	1.0600E-05	1.1700E-05	1.3000E-05	1.4300E-05	1.7800E-05	2.1800E-05	2.6100E-05	3.0600E-05	3.5400E-05	4.0300E-05	4.5500E-05	5.1000E-05]';
    k     = [1.2500E-02	1.6550E-02	1.8050E-02	1.9700E-02	2.1200E-02	2.2750E-02	2.4300E-02	2.8300E-02	3.2500E-02	3.6600E-02	4.0700E-02	4.4500E-02	4.8100E-02	5.1700E-02	5.5100E-02]';
    alpha = [9.6300E-06	1.1000E-05	1.2500E-05	1.4200E-05	1.5800E-05	1.7600E-05	1.9500E-05	2.4500E-05	3.0100E-05	3.6200E-05	4.3800E-05	4.9700E-05	5.6300E-05	6.3700E-05	7.1200E-05]';
    Pr    = [7.6500E-01	7.6600E-01	7.5400E-01	7.4600E-01	7.4100E-01	7.3700E-01	7.3700E-01	7.2800E-01	7.2500E-01	7.2100E-01	7.1700E-01	7.1200E-01	7.1700E-01	7.1400E-01	7.1600E-01]';
elseif(isequal('co',fluid))
    propopts = opts1;
    temp  = [2.0000E+02	2.2000E+02	2.4000E+02	2.6000E+02	2.8000E+02	3.0000E+02	3.2000E+02	3.4000E+02	3.6000E+02	3.8000E+02	4.0000E+02	4.5000E+02	5.0000E+02	5.5000E+02	6.0000E+02	6.5000E+02	7.0000E+02	7.5000E+02	8.0000E+02]';
    rho   = [1.6888E+00	1.5341E+00	1.4055E+00	1.2967E+00	1.2038E+00	1.1233E+00	1.0529E+00	9.9090E-01	9.3570E-01	8.8640E-01	8.4210E-01	7.4830E-01	6.7352E-01	6.1226E-01	5.6126E-01	5.1806E-01	4.8102E-01	4.4899E-01	4.2095E-01]';
    cp    = [1.0450E+00	1.0440E+00	1.0430E+00	1.0430E+00	1.0420E+00	1.0430E+00	1.0430E+00	1.0440E+00	1.0450E+00	1.0470E+00	1.0490E+00	1.0550E+00	1.0650E+00	1.0760E+00	1.0880E+00	1.1010E+00	1.1140E+00	1.1270E+00	1.1400E+00]';
    mu    = [1.2700E-05	1.3700E-05	1.4700E-05	1.5700E-05	1.6600E-05	1.7500E-05	1.8400E-05	1.9300E-05	2.0200E-05	2.1000E-05	2.1800E-05	2.3700E-05	2.5400E-05	2.7100E-05	2.8600E-05	3.0100E-05	3.1500E-05	3.2900E-05	3.4300E-05]';
    nu    = [7.5200E-06	8.9300E-06	1.0500E-05	1.2100E-05	1.3800E-05	1.5600E-05	1.7750E-05	1.9500E-05	2.1600E-05	2.3700E-05	2.5900E-05	3.1700E-05	3.7700E-05	4.4300E-05	5.1000E-05	5.8100E-05	6.5500E-05	7.3300E-05	8.1500E-05]';
    k     = [1.7000E-02	1.9000E-02	2.0600E-02	2.2100E-02	2.3600E-02	2.5000E-02	2.6300E-02	2.7800E-02	2.9100E-02	3.0500E-02	3.1800E-02	3.5000E-02	3.8100E-02	4.1100E-02	4.4000E-02	4.7000E-02	5.0000E-02	5.2800E-02	5.5500E-02]';
    alpha = [9.6300E-06	1.1900E-05	1.4100E-05	1.6300E-05	1.8800E-05	2.1300E-05	2.3900E-05	2.6900E-05	2.9800E-05	3.2900E-05	3.6000E-05	4.4300E-05	5.3100E-05	6.2400E-05	7.2100E-05	8.2400E-05	9.3300E-05	1.0400E-04	1.1600E-04]';
    Pr    = [7.8100E-01	7.5300E-01	7.4400E-01	7.4100E-01	7.3300E-01	7.3000E-01	7.3000E-01	7.2500E-01	7.2500E-01	7.1900E-01	7.1900E-01	7.1400E-01	7.1000E-01	7.1000E-01	7.0700E-01	7.0500E-01	7.0200E-01	7.0200E-01	7.0500E-01]';
elseif(isequal('he',fluid))
    propopts = opts1;
    temp  = [1.0000E+02	1.2000E+02	1.4000E+02	1.6000E+02	1.8000E+02	2.0000E+02	2.2000E+02	2.4000E+02	2.6000E+02	2.8000E+02	3.0000E+02	3.5000E+02	4.0000E+02	4.5000E+02	5.0000E+02	5.5000E+02	6.0000E+02	6.5000E+02	7.0000E+02	7.5000E+02	8.0000E+02	9.0000E+02	1.0000E+03]';
    rho   = [4.8710E-01	4.0600E-01	3.4810E-01	3.0945E-01	2.7080E-01	2.4620E-01	2.2160E-01	2.0455E-01	1.8750E-01	1.7500E-01	1.6250E-01	1.4220E-01	1.2190E-01	1.0972E-01	9.7540E-02	9.0578E-02	8.3615E-02	7.6653E-02	6.9690E-02	6.6207E-02	6.2723E-02	5.5757E-02	4.8790E-02]';
    cp    = [5.1930E-01	5.1930E-01	5.1930E-01	5.1930E-01	5.1930E-01	5.1930E-01	5.1930E-01	5.1930E-01	5.1930E-01	5.1930E-01	5.1930E-01	5.1930E-01	5.1930E-01	5.1930E-01	5.1930E-01	5.1930E-01	5.1930E-01	5.1930E-01	5.1930E-01	5.1930E-01	5.1930E-01	5.1930E-01	5.1930E-01]';
    mu    = [9.6300E-06	1.0700E-05	1.1800E-05	1.2900E-05	1.3900E-05	1.5000E-05	1.6000E-05	1.7000E-05	1.8000E-05	1.9000E-05	1.9900E-05	2.2100E-05	2.4300E-05	2.6300E-05	2.8300E-05	3.0150E-05	3.2000E-05	3.3200E-05	3.5000E-05	3.6400E-05	3.8200E-05	4.1400E-05	4.4600E-05]';
    nu    = [1.9800E-05	2.6400E-05	3.3900E-05	4.2600E-05	5.1300E-05	6.1750E-05	7.2200E-05	8.4100E-05	9.6000E-05	1.0900E-04	1.2200E-04	1.6050E-04	1.9900E-04	2.4450E-04	2.9000E-04	3.4300E-04	3.9600E-04	4.4900E-04	5.0200E-04	5.7067E-04	6.3933E-04	7.7667E-04	9.1400E-04]';
    k     = [7.3000E-02	8.1900E-02	9.0700E-02	9.9200E-02	1.0720E-01	1.1510E-01	1.2310E-01	1.3000E-01	1.3700E-01	1.4500E-01	1.5200E-01	1.7000E-01	1.8700E-01	2.0400E-01	2.2000E-01	2.3600E-01	2.5200E-01	2.6400E-01	2.7800E-01	2.9100E-01	3.0400E-01	3.3000E-01	3.5400E-01]';
    alpha = [2.8900E-05	3.8800E-05	5.0200E-05	6.3200E-05	7.6200E-05	9.1600E-05	1.0700E-04	1.2400E-04	1.4100E-04	1.6050E-04	1.8000E-04	2.3750E-04	2.9500E-04	3.6450E-04	4.3400E-04	5.1750E-04	6.0100E-04	6.8450E-04	7.6800E-04	8.7333E-04	9.7867E-04	1.1893E-03	1.4000E-03]';
    Pr    = [6.8600E-01	6.7900E-01	6.7600E-01	6.7450E-01	6.7300E-01	6.7400E-01	6.7500E-01	6.7850E-01	6.8200E-01	6.8100E-01	6.8000E-01	6.7750E-01	6.7500E-01	6.7150E-01	6.6800E-01	6.6450E-01	6.6100E-01	6.5750E-01	6.5400E-01	6.5400E-01	6.5400E-01	6.5400E-01	6.5400E-01]';
elseif(isequal('h2',fluid))
    propopts = opts1;
    temp  = [1.0000E+02	1.5000E+02	2.0000E+02	2.5000E+02	3.0000E+02	3.5000E+02	4.0000E+02	4.5000E+02	5.0000E+02	5.5000E+02	6.0000E+02	7.0000E+02	8.0000E+02	9.0000E+02	1.0000E+03	1.1000E+03	1.2000E+03	1.3000E+03	1.4000E+03	1.5000E+03	1.6000E+03	1.7000E+03	1.8000E+03	1.9000E+03	2.0000E+03]';
    rho   = [2.4255E-01	1.6156E-01	1.2115E-01	9.6930E-02	8.0780E-02	6.9240E-02	6.2590E-02	5.3860E-02	4.8480E-02	4.4070E-02	4.0400E-02	3.4630E-02	3.1300E-02	2.6940E-02	2.4240E-02	2.2040E-02	2.0200E-02	1.8650E-02	1.7320E-02	1.6160E-02	1.5200E-02	1.4300E-02	1.3500E-02	1.2800E-02	1.2100E-02]';
    cp    = [1.1230E+01	1.2600E+01	1.3540E+01	1.4060E+01	1.4310E+01	1.4430E+01	1.4480E+01	1.4500E+01	1.4520E+01	1.4530E+01	1.4550E+01	1.4610E+01	1.4700E+01	1.4830E+01	1.4990E+01	1.5170E+01	1.5370E+01	1.5590E+01	1.5810E+01	1.6020E+01	1.6280E+01	1.6580E+01	1.6960E+01	1.7490E+01	1.8250E+01]';
    mu    = [4.2100E-06	5.6000E-06	6.8100E-06	7.8900E-06	8.9600E-06	9.8800E-06	1.0820E-05	1.1720E-05	1.2640E-05	1.3430E-05	1.4240E-05	1.5780E-05	1.7240E-05	1.8650E-05	2.0130E-05	2.1300E-05	2.2620E-05	2.3850E-05	2.5070E-05	2.6270E-05	2.7370E-05	2.8490E-05	2.9610E-05	3.0720E-05	3.1820E-05]';
    nu    = [1.7400E-05	3.4700E-05	5.6200E-05	8.1400E-05	1.1100E-04	1.4300E-04	1.7900E-04	2.1800E-04	2.6100E-04	3.0500E-04	3.5200E-04	4.5600E-04	5.6900E-04	6.9220E-04	8.3000E-04	9.6600E-04	1.1200E-03	1.2790E-03	1.4470E-03	1.6260E-03	1.8010E-03	1.9920E-03	2.1930E-03	2.4000E-03	2.6300E-03]';
    k     = [6.7000E-02	1.0100E-01	1.3100E-01	1.5700E-01	1.8300E-01	2.0400E-01	2.2600E-01	2.4700E-01	2.6600E-01	2.8500E-01	3.0500E-01	3.4200E-01	3.7800E-01	4.1200E-01	4.4800E-01	4.8800E-01	5.2800E-01	5.6800E-01	6.1000E-01	6.5500E-01	6.9700E-01	7.4100E-01	7.8600E-01	8.3500E-01	8.7800E-01]';
    alpha = [2.4600E-05	4.9600E-05	7.9900E-05	1.1500E-04	1.5800E-04	2.0400E-04	2.5800E-04	3.1600E-04	3.7800E-04	4.4500E-04	5.1900E-04	6.7600E-04	8.4900E-04	1.0300E-03	1.2300E-03	1.4600E-03	1.7000E-03	1.9550E-03	2.2300E-03	2.5300E-03	2.8150E-03	3.1300E-03	3.4350E-03	3.7300E-03	3.9750E-03]';
    Pr    = [7.0700E-01	6.9900E-01	7.0400E-01	7.0700E-01	7.0100E-01	7.0000E-01	6.9500E-01	6.8900E-01	6.9100E-01	6.8500E-01	6.7800E-01	6.7500E-01	6.7000E-01	6.7100E-01	6.7300E-01	6.6200E-01	6.5900E-01	6.5500E-01	6.5000E-01	6.4300E-01	6.3900E-01	6.3700E-01	6.3900E-01	6.4300E-01	6.6100E-01]';
elseif(isequal('n2',fluid))
    propopts = opts1;
    temp  = [1.0000E+02	1.5000E+02	2.0000E+02	2.5000E+02	3.0000E+02	3.5000E+02	4.0000E+02	4.5000E+02	5.0000E+02	5.5000E+02	6.0000E+02	7.0000E+02	8.0000E+02	9.0000E+02	1.0000E+03	1.1000E+03	1.2000E+03	1.3000E+03]';
    rho   = [3.4388E+00	2.2594E+00	1.6883E+00	1.3488E+00	1.1233E+00	9.6250E-01	8.4250E-01	7.4850E-01	6.7390E-01	6.1240E-01	5.6150E-01	4.8120E-01	4.2110E-01	3.7430E-01	3.3680E-01	3.0620E-01	2.8070E-01	2.5910E-01]';
    cp    = [1.0700E+00	1.0500E+00	1.0430E+00	1.0420E+00	1.0410E+00	1.0420E+00	1.0450E+00	1.0500E+00	1.0560E+00	1.0650E+00	1.0750E+00	1.0980E+00	1.2200E+00	1.1460E+00	1.1670E+00	1.1870E+00	1.2040E+00	1.2190E+00]';
    mu    = [6.8800E-06	1.0060E-05	1.2920E-05	1.5490E-05	1.7820E-05	2.0000E-05	2.2040E-05	2.3960E-05	2.5770E-05	2.7470E-05	2.9080E-05	3.2100E-05	3.4910E-05	3.7530E-05	3.9990E-05	4.2320E-05	4.4530E-05	4.6620E-05]';
    nu    = [2.0000E-06	4.4500E-06	7.6500E-06	1.1480E-05	1.5860E-05	2.0780E-05	2.6160E-05	3.2010E-05	3.8240E-05	4.4860E-05	5.1790E-05	6.6710E-05	8.2900E-05	1.0030E-04	1.1870E-04	1.3820E-04	1.5860E-04	1.7990E-04]';
    k     = [9.5800E-03	1.3900E-02	1.8300E-02	2.2200E-02	2.5900E-02	2.9300E-02	3.2700E-02	3.5800E-02	3.8900E-02	4.1700E-02	4.4600E-02	4.9900E-02	5.4800E-02	5.9700E-02	6.4700E-02	7.0000E-02	7.5800E-02	8.1000E-02]';
    alpha = [2.6000E-06	5.8600E-06	1.0400E-05	1.5800E-05	2.2100E-05	2.9200E-05	3.7100E-05	4.5600E-05	5.4700E-05	6.3900E-05	7.3900E-05	9.4400E-05	1.1600E-04	1.3900E-04	1.5600E-04	1.9300E-04	2.2400E-04	2.5600E-04]';
    Pr    = [7.6800E-01	7.5900E-01	7.3600E-01	7.3700E-01	7.1600E-01	7.1100E-01	7.0400E-01	7.0300E-01	7.0000E-01	7.0200E-01	7.0100E-01	7.0600E-01	7.1500E-01	7.2100E-01	7.2100E-01	7.1800E-01	7.0700E-01	7.0100E-01]';
elseif(isequal('o2',fluid))
    propopts = opts1;
    temp  = [1.0000E+02	1.5000E+02	2.0000E+02	2.5000E+02	3.0000E+02	3.5000E+02	4.0000E+02	4.5000E+02	5.0000E+02	5.5000E+02	6.0000E+02	7.0000E+02	8.0000E+02	9.0000E+02	1.0000E+03	1.1000E+03	1.2000E+03	1.3000E+03]';
    rho   = [3.9450E+00	2.5850E+00	1.9300E+00	1.5420E+00	1.2840E+00	1.1000E+00	9.6200E-01	8.5540E-01	7.6980E-01	6.9980E-01	6.4140E-01	5.4980E-01	4.8100E-01	4.2750E-01	3.8480E-01	3.4980E-01	3.2060E-01	2.9600E-01]';
    cp    = [9.6200E-01	9.2100E-01	9.1500E-01	9.1500E-01	9.2000E-01	9.2900E-01	9.4200E-01	9.5600E-01	9.7200E-01	9.8800E-01	1.0030E+00	1.0310E+00	1.0540E+00	1.0740E+00	1.0900E+00	1.1030E+00	1.1150E+00	1.1250E+00]';
    mu    = [7.6400E-06	1.1480E-05	1.4750E-05	1.7860E-05	2.0720E-05	2.3350E-05	2.5820E-05	2.8140E-05	3.0330E-05	3.2400E-05	3.4370E-05	3.8080E-05	4.1510E-05	4.4720E-05	4.7700E-05	5.0550E-05	5.3250E-05	5.8840E-05]';
    nu    = [1.9400E-06	4.4400E-06	7.6400E-06	1.1580E-05	1.6140E-05	2.1230E-05	2.6840E-05	3.2900E-05	3.9400E-05	4.6300E-05	5.3590E-05	6.9260E-05	8.6320E-05	1.0460E-04	1.2400E-04	1.4450E-04	1.6610E-04	1.8860E-04]';
    k     = [9.2500E-03	1.3800E-02	1.8300E-02	2.2600E-02	2.6800E-02	2.9600E-02	3.3000E-02	3.6300E-02	4.1200E-02	4.4100E-02	4.7300E-02	5.2800E-02	5.8900E-02	6.4900E-02	7.1000E-02	7.5800E-02	8.1900E-02	8.7100E-02]';
    alpha = [2.4400E-06	5.8000E-06	1.0400E-05	1.6000E-05	2.2700E-05	2.9000E-05	3.6400E-05	4.4400E-05	5.5100E-05	6.3800E-05	7.3500E-05	9.3700E-05	1.1600E-04	1.4100E-04	1.6900E-04	1.9600E-04	2.2900E-04	2.6200E-04]';
    Pr    = [7.9600E-01	7.6600E-01	7.3700E-01	7.2300E-01	7.1100E-01	7.3300E-01	7.3700E-01	7.4100E-01	7.1600E-01	7.2600E-01	7.2900E-01	7.4400E-01	7.4300E-01	7.4000E-01	7.3300E-01	7.3600E-01	7.2500E-01	7.2100E-01]';
elseif(isequal('steam',fluid))
    propopts = opts1;
    temp  = [380,400:50:850]';
    rho   = [5.863E-01	5.542E-01	4.902E-01	4.405E-01	4.005E-01	3.652E-01	3.380E-01	3.140E-01	2.931E-01	2.739E-01	2.579E-01]';
    cp    = [2.060E+03	2.014E+03	1.980E+03	1.985E+03	1.997E+03	2.026E+03	2.056E+03	2.085E+03	2.119E+03	2.152E+03	2.186E+03]';
    mu    = [1.271E-05	1.334E-05	1.525E-05	1.704E-05	1.884E-05	2.067E-05	2.247E-05	2.426E-05	2.604E-05	2.786E-05	2.969E-05]';
    nu    = [2.168E-05	2.425E-05	3.111E-05	3.868E-05	4.704E-05	5.660E-05	6.648E-05	7.726E-05	8.884E-05	1.017E-04	1.151E-04]';
    k     = [2.460E-02	2.610E-02	2.990E-02	3.390E-02	3.790E-02	4.220E-02	4.640E-02	5.050E-02	5.490E-02	5.920E-02	6.370E-02]';
    alpha = [2.040E-05	2.340E-05	3.080E-05	3.880E-05	4.740E-05	5.700E-05	6.680E-05	7.710E-05	8.840E-05	1.000E-04	1.130E-04]';
    Pr    = [1.060E+00	1.040E+00	1.010E+00	9.980E-01	9.930E-01	9.930E-01	9.960E-01	1.000E+00	1.000E+00	1.010E+00	1.020E+00]';
elseif(isequal('oil',fluid))
    propopts = opts1;
    temp     = [273,280:10:430];
    rho      = [8.991E+02	8.953E+02	8.900E+02	8.841E+02	8.779E+02	8.718E+02	8.658E+02	8.599E+02	8.539E+02	8.478E+02	8.418E+02	8.360E+02	8.306E+02	8.251E+02	8.189E+02	8.121E+02	8.065E+02]';
    cp       = [1.796E+03	1.827E+03	1.868E+03	1.909E+03	1.951E+03	1.993E+03	2.035E+03	2.076E+03	2.118E+03	2.161E+03	2.206E+03	2.250E+03	2.294E+03	2.337E+03	2.381E+03	2.427E+03	2.471E+03]';
    mu       = [3.850E+00	2.170E+00	9.990E-01	4.860E-01	2.530E-01	1.410E-01	8.360E-02	5.310E-02	3.560E-02	2.520E-02	1.860E-02	1.410E-02	1.100E-02	8.740E-03	6.980E-03	5.640E-03	4.700E-03]';
    nu       = [4.280E-03	2.430E-03	1.120E-03	5.500E-04	2.880E-04	1.610E-04	9.660E-05	6.170E-05	4.170E-05	2.970E-05	2.200E-05	1.690E-05	1.330E-05	1.060E-05	8.520E-06	6.940E-06	5.830E-06]';
    k        = [1.470E-01	1.440E-01	1.450E-01	1.450E-01	1.450E-01	1.430E-01	1.410E-01	1.390E-01	1.380E-01	1.380E-01	1.370E-01	1.360E-01	1.350E-01	1.340E-01	1.330E-01	1.330E-01	1.320E-01]';
    alpha    = [9.100E-08	8.800E-08	8.720E-08	8.590E-08	8.470E-08	8.230E-08	8.000E-08	7.790E-08	7.630E-08	7.530E-08	7.380E-08	7.230E-08	7.090E-08	6.950E-08	6.820E-08	6.750E-08	6.620E-08]';
    Pr       = [4.700E+04	2.750E+04	1.290E+04	6.400E+03	3.400E+03	1.965E+03	1.205E+03	7.930E+02	5.460E+02	3.950E+02	3.000E+02	2.330E+02	1.870E+02	1.520E+02	1.250E+02	1.030E+02	8.800E+01]';
    beta     = [7.000E-04	7.000E-04	7.000E-04	7.000E-04	7.000E-04	7.000E-04	7.000E-04	7.000E-04	7.000E-04	7.000E-04	7.000E-04	7.000E-04	7.000E-04	7.000E-04	7.000E-04	7.000E-04	7.000E-04]';
elseif(isequal('eth_gly',fluid))
    propopts = opts1;
    temp     = [273,280:10:370,373]';
    rho      = [1.131E+03	1.126E+03	1.119E+03	1.114E+03	1.104E+03	1.096E+03	1.090E+03	1.084E+03	1.079E+03	1.074E+03	1.067E+03	1.059E+03]';
    cp       = [2.294E+03	2.323E+03	2.368E+03	2.415E+03	2.460E+03	2.505E+03	2.549E+03	2.592E+03	2.637E+03	2.682E+03	2.728E+03	2.742E+03]';
    mu       = [6.510E-02	4.200E-02	2.470E-02	1.570E-02	1.070E-02	7.570E-03	5.610E-03	4.310E-03	3.420E-03	2.780E-03	2.280E-03	2.150E-03]';
    nu       = [5.760E-05	3.730E-05	2.210E-05	1.410E-05	9.650E-06	6.910E-06	5.150E-06	3.980E-06	3.170E-06	2.590E-06	2.140E-06	2.030E-06]';
    k        = [2.420E-01	2.440E-01	2.480E-01	2.520E-01	2.550E-01	2.580E-01	2.600E-01	2.610E-01	2.610E-01	2.610E-01	2.620E-01	2.630E-01]';
    alpha    = [9.330E-08	9.330E-08	9.360E-08	9.390E-08	9.390E-08	9.400E-08	9.360E-08	9.290E-08	9.170E-08	9.060E-08	9.000E-08	9.060E-08]';
    Pr       = [6.170E+02	4.000E+02	2.360E+02	1.510E+02	1.030E+02	7.350E+01	5.500E+01	4.280E+01	3.460E+01	2.860E+01	2.370E+01	2.240E+01]';
    beta     = [6.500E-04	6.500E-04	6.500E-04	6.500E-04	6.500E-04	6.500E-04	6.500E-04	6.500E-04	6.500E-04	6.500E-04	6.500E-04	6.500E-04]';
elseif(isequal('glyc',fluid))
    propopts = opts1;
    temp     = [273,280:10:320]';
    rho      = [1.2760E+03	1.2719E+03	1.2658E+03	1.2599E+03	1.2539E+03	1.2472E+03]';
    cp       = [2.261E+03	2.298E+03	2.367E+03	2.427E+03	2.490E+03	2.564E+03]';
    mu       = [1.060E+01	5.340E+00	1.850E+00	7.990E-01	3.520E-01	2.100E-01]';
    nu       = [8.310E-03	4.200E-03	1.460E-03	6.340E-04	2.810E-04	1.680E-04]';
    k        = [2.820E-01	2.840E-01	2.860E-01	2.860E-01	2.860E-01	2.870E-01]';
    alpha    = [9.770E-08	9.720E-08	9.550E-08	9.350E-08	9.160E-08	8.970E-08]';
    Pr       = [8.500E+04	4.320E+04	1.530E+04	6.780E+03	3.060E+03	1.870E+03]';
    beta     = [4.700E-04	4.700E-04	4.800E-04	4.800E-04	4.900E-04	5.000E-04]';
elseif(isequal('r134a',fluid))
    propopts = opts1;
    temp     = [2.3000E+02	2.4000E+02	2.5000E+02	2.6000E+02	2.7000E+02	2.8000E+02	2.9000E+02	3.0000E+02	3.1000E+02	3.2000E+02	3.3000E+02	3.4000E+02	3.5000E+02	3.6000E+02	3.7000E+02]';
    rho      = [1.4268E+03	1.3977E+03	1.3679E+03	1.3371E+03	1.3051E+03	1.2718E+03	1.2368E+03	1.1997E+03	1.1599E+03	1.1168E+03	1.0691E+03	1.0150E+03	9.5130E+02	8.7010E+02	7.4030E+02]';
    cp       = [1.2490E+00	1.2670E+00	1.2870E+00	1.3080E+00	1.3330E+00	1.3610E+00	1.3930E+00	1.4320E+00	1.4810E+00	1.5430E+00	1.6270E+00	1.7510E+00	1.9610E+00	2.4370E+00	5.1050E+00]';
    mu       = [4.9120E-04	4.2020E-04	3.6330E-04	3.1660E-04	2.7750E-04	2.4430E-04	2.1560E-04	1.9050E-04	1.6800E-04	1.4780E-04	1.2920E-04	1.1180E-04	8.5100E-05	7.8100E-05	5.8000E-05]';
    nu       = [3.3430E-07	3.0060E-07	2.6560E-07	2.3680E-07	2.1270E-07	1.9210E-07	1.7440E-07	1.5880E-07	1.4490E-07	1.3230E-07	1.2090E-07	1.1020E-07	1.0000E-07	8.9800E-08	7.8300E-08]';
    k        = [1.1210E-01	1.0730E-01	1.0250E-01	9.7900E-02	9.3400E-02	8.9000E-02	8.4600E-02	8.0300E-02	7.6100E-02	7.1800E-02	6.7500E-02	6.3100E-02	5.8600E-02	5.4100E-02	5.1800E-02]';
    alpha    = [6.2900E-08	6.0600E-08	5.8300E-08	5.6000E-08	5.3700E-08	5.1400E-08	4.9100E-08	4.6800E-08	4.4300E-08	4.1700E-08	3.8800E-08	3.5500E-08	3.1400E-08	2.5500E-08	1.3700E-08]';
    Pr       = [5.5000E+00	5.0000E+00	4.6000E+00	4.2000E+00	4.0000E+00	3.7000E+00	3.5000E+00	3.4000E+00	3.3000E+00	3.2000E+00	3.1000E+00	3.1000E+00	3.2000E+00	3.5000E+00	5.7000E+00]';
    beta     = [2.0200E-03	2.1100E-03	2.2300E-03	2.3600E-03	2.5300E-03	2.7300E-03	2.9800E-03	3.3000E-03	3.7300E-03	4.3300E-03	5.1900E-03	6.5700E-03	9.1000E-03	1.5390E-02	5.5240E-02]';
elseif(isequal('r22',fluid))
    propopts = opts1;
    temp     = [2.3000E+02	2.4000E+02	2.5000E+02	2.6000E+02	2.7000E+02	2.8000E+02	2.9000E+02	3.0000E+02	3.1000E+02	3.2000E+02	3.3000E+02	3.4000E+02	3.5000E+02	3.6000E+02]';
    rho      = [1.4160E+03	1.3866E+03	1.3563E+03	1.3249E+03	1.2921E+03	1.2579E+03	1.2217E+03	1.1834E+03	1.1422E+03	1.0974E+03	1.0475E+03	9.9010E+02	9.2010E+02	8.2340E+02]';
    cp       = [1.0870E+00	1.1000E+00	1.1170E+00	1.1370E+00	1.1610E+00	1.1890E+00	1.2230E+00	1.2650E+00	1.3190E+00	1.3910E+00	1.4950E+00	1.6650E+00	1.9970E+00	3.0010E+00]';
    mu       = [3.5580E-04	3.1450E-04	2.7960E-04	2.4970E-04	2.2350E-04	2.0050E-04	1.7980E-04	1.6100E-04	1.4380E-04	1.2780E-04	1.1270E-04	9.8000E-05	8.3100E-05	6.6800E-05]';
    nu       = [2.5130E-07	2.2670E-07	2.0620E-07	1.8840E-07	1.7300E-07	1.5940E-07	1.4720E-07	1.3610E-07	1.2590E-07	1.1650E-07	1.0750E-07	9.8900E-08	9.0400E-08	8.1100E-08]';
    k        = [1.1450E-01	1.0980E-01	1.0520E-01	1.0070E-01	9.6200E-02	9.1700E-02	8.7200E-02	8.2600E-02	7.8100E-02	7.3400E-02	6.8600E-02	6.3600E-02	5.8300E-02	5.3100E-02]';
    alpha    = [7.4400E-08	7.2000E-08	6.9500E-08	6.6800E-08	6.4100E-08	6.1300E-08	5.8300E-08	5.5200E-08	5.1800E-08	4.8100E-08	4.3800E-08	3.8600E-08	3.1700E-08	2.1500E-08]';
    Pr       = [3.4000E+00	3.2000E+00	3.0000E+00	2.8000E+00	2.7000E+00	2.6000E+00	2.5000E+00	2.5000E+00	2.4000E+00	2.4000E+00	2.5000E+00	2.6000E+00	2.8000E+00	3.8000E+00]';
    beta     = [2.0500E-03	2.1600E-03	2.2900E-03	2.4500E-03	2.6300E-03	2.8600E-03	3.1500E-03	3.5100E-03	4.0000E-03	4.6900E-03	5.7500E-03	7.5600E-03	1.1350E-02	2.3880E-02]';
elseif(isequal('hg',fluid))
    propopts = opts1;
    temp     = [273,300:50:600]';
    rho      = [1.360E+04	1.353E+04	1.341E+04	1.329E+04	1.317E+04	1.305E+04	1.293E+04	1.281E+04]';
    cp       = [1.404E+02	1.393E+02	1.377E+02	1.365E+02	1.357E+02	1.353E+02	1.352E+02	1.355E+02]';
    mu       = [1.688E-03	1.523E-03	1.309E-03	1.171E-03	1.075E-03	1.007E-03	9.530E-04	9.110E-04]';
    nu       = [1.240E-07	1.125E-07	9.760E-08	8.820E-08	8.160E-08	7.710E-08	7.370E-08	7.110E-08]';
    k        = [8.180E+00	8.540E+00	9.180E+00	9.800E+00	1.040E+01	1.095E+01	1.145E+01	1.195E+01]';
    alpha    = [4.285E-06	4.530E-06	4.975E-06	5.405E-06	5.810E-06	6.190E-06	6.555E-06	6.880E-06]';
    Pr       = [2.900E-02	2.480E-02	1.960E-02	1.630E-02	1.400E-02	1.250E-02	1.120E-02	1.030E-02]';
    beta     = [1.810E-04	1.810E-04	1.810E-04	1.810E-04	1.810E-04	1.820E-04	1.840E-04	1.870E-04]';
elseif(isequal('water',fluid))
    propopts = opts2;
    temp     = [273.15,275:5:370,373.15,375:5:390,400:10:610,620:5:645,647.3];
    pressure = [6.110E+02	6.970E+02	9.900E+02	1.387E+03	1.917E+03	2.617E+03	3.531E+03	4.712E+03	6.221E+03	8.132E+03	1.053E+04	1.351E+04	1.719E+04	2.167E+04	2.713E+04	3.372E+04	4.163E+04	5.100E+04	6.209E+04	7.514E+04	9.040E+04	1.013E+05	1.082E+05	1.287E+05	1.523E+05	1.794E+05	2.455E+05	3.302E+05	4.370E+05	5.699E+05	7.333E+05	9.319E+05	1.171E+06	1.455E+06	1.790E+06	2.183E+06	2.640E+06	3.166E+06	3.770E+06	4.458E+06	5.238E+06	6.119E+06	7.108E+06	8.216E+06	9.451E+06	1.083E+07	1.235E+07	1.373E+07	1.591E+07	1.691E+07	1.797E+07	1.909E+07	2.027E+07   2.152E+07	2.212E+07]';
    vf       = [1.000E-03	1.000E-03	1.000E-03	1.000E-03	1.001E-03	1.002E-03	1.003E-03	1.005E-03	1.007E-03	1.009E-03	1.011E-03	1.013E-03	1.016E-03	1.018E-03	1.021E-03	1.024E-03	1.027E-03	1.030E-03	1.034E-03	1.038E-03	1.041E-03	1.044E-03	1.045E-03	1.049E-03	1.053E-03	1.058E-03	1.067E-03	1.077E-03	1.088E-03	1.099E-03	1.110E-03	1.123E-03	1.137E-03	1.152E-03	1.167E-03	1.184E-03	1.203E-03	1.222E-03	1.244E-03	1.268E-03	1.294E-03	1.323E-03	1.355E-03	1.392E-03	1.433E-03	1.482E-03	1.541E-03	1.612E-03	1.705E-03	1.778E-03	1.856E-03	1.935E-03	2.075E-03   2.351E-03	3.170E-03]';
    vg       = [2.063E+02	1.817E+02	1.304E+02	9.940E+01	6.970E+01	5.194E+01	3.913E+01	2.974E+01	2.293E+01	1.782E+01	1.398E+01	1.106E+01	8.820E+00	7.090E+00	5.740E+00	4.683E+00	3.846E+00	3.180E+00	2.645E+00	2.212E+00	1.861E+00	1.679E+00	1.574E+00	1.337E+00	1.142E+00	9.800E-01	7.310E-01	5.530E-01	4.250E-01	3.310E-01	2.610E-01	2.080E-01	1.670E-01	1.360E-01	1.110E-01	9.220E-02	7.660E-02	6.310E-02	5.250E-02	4.450E-02	3.750E-02	3.170E-02	2.690E-02	2.280E-02	1.930E-02	1.630E-02	1.370E-02	1.150E-02	9.400E-03	8.500E-03	7.500E-03	6.600E-03	5.700E-03   4.500E-03	3.200E-03]';
    hfg      = [2.502E+06	2.497E+06	2.485E+06	2.473E+06	2.461E+06	2.449E+06	2.438E+06	2.426E+06	2.414E+06	2.402E+06	2.390E+06	2.378E+06	2.366E+06	2.354E+06	2.342E+06	2.329E+06	2.317E+06	2.304E+06	2.291E+06	2.278E+06	2.265E+06	2.257E+06	2.252E+06	2.239E+06	2.225E+06	2.212E+06	2.183E+06	2.153E+06	2.123E+06	2.091E+06	2.059E+06	2.024E+06	1.989E+06	1.951E+06	1.912E+06	1.870E+06	1.825E+06	1.779E+06	1.730E+06	1.679E+06	1.622E+06	1.564E+06	1.499E+06	1.429E+06	1.353E+06	1.274E+06	1.176E+06	1.068E+06	9.410E+05	8.580E+05	7.810E+05	6.830E+05	5.600E+05   3.610E+05	0.000E+00]';
    cpf      = [4.217E+03	4.211E+03	4.198E+03	4.189E+03	4.184E+03	4.181E+03	4.179E+03	4.178E+03	4.178E+03	4.179E+03	4.180E+03	4.182E+03	4.184E+03	4.186E+03	4.188E+03	4.191E+03	4.195E+03	4.199E+03	4.203E+03	4.209E+03	4.214E+03	4.217E+03	4.220E+03	4.226E+03	4.232E+03	4.239E+03	4.256E+03	4.278E+03	4.302E+03	4.331E+03	4.360E+03	4.400E+03	4.440E+03	4.480E+03	4.530E+03	4.590E+03	4.660E+03	4.740E+03	4.840E+03	4.950E+03	5.080E+03	5.240E+03	5.430E+03	5.680E+03	6.000E+03	6.410E+03	7.000E+03	7.850E+03	9.350E+03	1.060E+04	1.260E+04	1.640E+04	2.600E+04   9.000E+04]';
    cpg      = [1.854E+03	1.855E+03	1.858E+03	1.861E+03	1.864E+03	1.868E+03	1.872E+03	1.877E+03	1.882E+03	1.888E+03	1.895E+03	1.903E+03	1.911E+03	1.920E+03	1.930E+03	1.941E+03	1.954E+03	1.968E+03	1.983E+03	1.999E+03	2.017E+03	2.029E+03	2.036E+03	2.057E+03	2.080E+03	2.104E+03	2.158E+03	2.221E+03	2.291E+03	2.369E+03	2.460E+03	2.560E+03	2.680E+03	2.790E+03	2.940E+03	3.100E+03	3.270E+03	3.470E+03	3.700E+03	3.960E+03	4.270E+03	4.640E+03	5.090E+03	5.670E+03	6.400E+03	7.350E+03	8.750E+03	1.110E+04	1.540E+04	1.830E+04	2.210E+04	2.760E+04	4.200E+04]';
    muf      = [1.750E-03	1.652E-03	1.422E-03	1.225E-03	1.080E-03	9.590E-04	8.550E-04	7.690E-04	6.950E-04	6.310E-04	5.770E-04	5.280E-04	4.890E-04	4.530E-04	4.200E-04	3.890E-04	3.650E-04	3.430E-04	3.240E-04	3.060E-04	2.890E-04	2.790E-04	2.740E-04	2.600E-04	2.480E-04	2.370E-04	2.170E-04	2.000E-04	1.850E-04	1.730E-04	1.620E-04	1.520E-04	1.430E-04	1.360E-04	1.290E-04	1.240E-04	1.180E-04	1.130E-04	1.080E-04	1.040E-04	1.010E-04	9.700E-05	9.400E-05	9.100E-05	8.800E-05	8.400E-05	8.100E-05	7.700E-05	7.200E-05	7.000E-05	6.700E-05	6.400E-05	5.900E-05   5.400E-05	4.500E-05]';
    mug      = [8.020E-06	8.090E-06	8.290E-06	8.490E-06	8.690E-06	8.890E-06	9.090E-06	9.290E-06	9.490E-06	9.690E-06	9.890E-06	1.009E-05	1.029E-05	1.049E-05	1.069E-05	1.089E-05	1.109E-05	1.129E-05	1.149E-05	1.169E-05	1.189E-05	1.202E-05	1.209E-05	1.229E-05	1.249E-05	1.269E-05	1.305E-05	1.342E-05	1.379E-05	1.414E-05	1.450E-05	1.485E-05	1.519E-05	1.554E-05	1.588E-05	1.623E-05	1.659E-05	1.695E-05	1.733E-05	1.772E-05	1.810E-05	1.860E-05	1.910E-05	1.970E-05	2.040E-05	2.150E-05	2.270E-05	2.410E-05	2.590E-05	2.700E-05	2.800E-05	3.000E-05	3.200E-05   3.700E-05	4.500E-05]';
    kf       = [5.690E-01	5.740E-01	5.820E-01	5.900E-01	5.980E-01	6.060E-01	6.130E-01	6.200E-01	6.280E-01	6.340E-01	6.400E-01	6.450E-01	6.500E-01	6.560E-01	6.600E-01	6.680E-01	6.680E-01	6.710E-01	6.740E-01	6.770E-01	6.790E-01	6.800E-01	6.810E-01	6.830E-01	6.850E-01	6.860E-01	6.880E-01	6.880E-01	6.880E-01	6.850E-01	6.820E-01	6.780E-01	6.730E-01	6.670E-01	6.600E-01	6.510E-01	6.420E-01	6.310E-01	6.210E-01	6.080E-01	5.940E-01	5.800E-01	5.630E-01	5.480E-01	5.280E-01	5.130E-01	4.970E-01	4.670E-01	4.440E-01	4.300E-01	4.120E-01	3.920E-01	3.670E-01   3.310E-01	2.380E-01]';
    kg       = [1.820E-02	1.830E-02	1.860E-02	1.890E-02	1.930E-02	1.950E-02	1.960E-02	2.010E-02	2.040E-02	2.070E-02	2.100E-02	2.130E-02	2.170E-02	2.200E-02	2.230E-02	2.260E-02	2.300E-02	2.330E-02	2.370E-02	2.410E-02	2.450E-02	2.480E-02	2.490E-02	2.540E-02	2.580E-02	2.630E-02	2.720E-02	2.820E-02	2.980E-02	3.040E-02	3.170E-02	3.310E-02	3.460E-02	3.630E-02	3.810E-02	4.010E-02	4.230E-02	4.470E-02	4.750E-02	5.060E-02	5.400E-02	5.830E-02	6.370E-02	7.670E-02	7.670E-02	8.410E-02	9.290E-02	1.030E-01	1.140E-01	1.210E-01	1.300E-01	1.410E-01	1.550E-01   1.780E-01	2.380E-01]';
    Prf      = [1.299E+01	1.222E+01	1.026E+01	8.810E+00	7.560E+00	6.620E+00	5.830E+00	5.200E+00	4.620E+00	4.160E+00	3.770E+00	3.420E+00	3.150E+00	2.880E+00	2.660E+00	2.450E+00	2.290E+00	2.140E+00	2.020E+00	1.910E+00	1.800E+00	1.760E+00	1.700E+00	1.610E+00	1.530E+00	1.470E+00	1.340E+00	1.240E+00	1.160E+00	1.090E+00	1.040E+00	9.900E-01	9.500E-01	9.200E-01	8.900E-01	8.700E-01	8.600E-01	8.500E-01	8.400E-01	8.500E-01	8.600E-01	8.700E-01	9.000E-01	9.400E-01	9.900E-01	1.050E+00	1.140E+00	1.300E+00	1.520E+00	1.650E+00	2.000E+00	2.700E+00	4.200E+00   1.200E+01]';
    Prg      = [8.150E-01	8.170E-01	8.250E-01	8.330E-01	8.410E-01	8.490E-01	8.570E-01	8.650E-01	8.730E-01	8.830E-01	8.940E-01	9.010E-01	9.080E-01	9.160E-01	9.250E-01	9.330E-01	9.420E-01	9.510E-01	9.600E-01	9.690E-01	9.780E-01	9.840E-01	9.870E-01	9.990E-01	1.004E+00	1.013E+00	1.033E+00	1.054E+00	1.075E+00	1.100E+00	1.120E+00	1.140E+00	1.170E+00	1.200E+00	1.230E+00	1.250E+00	1.280E+00	1.310E+00	1.350E+00	1.390E+00	1.430E+00	1.470E+00	1.520E+00	1.590E+00	1.680E+00	1.840E+00	2.150E+00	2.600E+00	3.460E+00	4.200E+00	4.800E+00	6.000E+00	9.600E+00   2.600E+01]';
    sigma    = [7.550E-02	7.530E-02	7.480E-02	7.430E-02	7.370E-02	7.270E-02	7.170E-02	7.090E-02	7.000E-02	6.920E-02	6.830E-02	6.750E-02	6.660E-02	6.580E-02	6.490E-02	6.410E-02	6.320E-02	6.230E-02	6.140E-02	6.050E-02	5.950E-02	5.890E-02	5.860E-02	5.760E-02	5.660E-02	5.560E-02	5.360E-02	5.150E-02	4.940E-02	4.720E-02	4.510E-02	4.290E-02	4.070E-02	3.850E-02	3.620E-02	3.390E-02	3.160E-02	2.930E-02	2.690E-02	2.450E-02	2.210E-02	1.970E-02	1.730E-02	1.500E-02	1.280E-02	1.050E-02	8.400E-03	6.300E-03	4.500E-03	3.500E-03	2.600E-03	1.500E-03	8.000E-04   1.000E-04	0.000E+00]';
    beta     = [-6.805E-05	-3.274E-05	4.604E-05	1.141E-04	1.740E-04	2.275E-04	2.761E-04	3.206E-04	3.619E-04	4.004E-04	4.367E-04	4.712E-04	5.040E-04	5.355E-04	5.660E-04	5.954E-04	6.242E-04	6.523E-04	6.979E-04	7.071E-04	7.287E-04	7.501E-04	7.610E-04	7.880E-04	8.140E-04	8.410E-04	8.960E-04	9.520E-04	1.010E-03]';
    if(index==0) % no input signifying that the user want liquid water properties
        v  = vf;
        cp = cpf;
        mu = muf;
        k  = kf;
        Pr = Prf;
    elseif(isequal('satliq',varargin{index})) % this returns the same values as not entering an option because all liquied properties are saturated liquid properties.
        v  = vf;
        cp = cpf;
        mu = muf;
        k  = kf;
        Pr = Prf;
    elseif(isequal('satvap',varargin{index})) % this returns values for a saturated liquid.
        v  = vg;
        cp = cpg;
        mu = mug;
        k  = kg;
        Pr = Prg;
    elseif(isequal('mixture',varargin{index})) % this returns values for vapor/liquid mixtures.
        %TODO:  Find out more about quality in heat transfer and find out
        %what properties it can be used on legitimately.
        if(length(varargin)-index<2)
            error('mixture option requires 2 sub options');
        elseif(isequal('quality',varargin{index+1}))
            qual = varargin{index+2};
        else
            %if quality is not defined it must be calculated
            if(isequal('v',varargin{index+1}))
                qual = findqual(vf,vg,varargin{index+2},temp,utemp);
            elseif(isequal('cp',varargin{index+1}))
                qual = findqual(cpf,cpg,varargin{index+2},temp,utemp);
            elseif(isequal('mu',varargin{index+1}))
                qual = findqual(muf,mug,varargin{index+2},temp,utemp);
            elseif(isequal('k',varargin{index+1}))
                qual = findqual(kf,kg,varargin{index+2},temp,utemp);
            elseif(isequal('Pr',varargin{index+1}))
                qual = findqual(Prf,Prg,varargin{index+2},temp,utemp);
            else
                error('%s is not a valid identifier for quality calculations',varargin{index+1});
            end
        end
        %quality check
        if(qual<0 | qual>1)
            error('quality must be between 0 and 1. User defined value after suboption %s is invalid',varargin{index+1});
        end
        % calculate property table at this quality
        v  = flqual( vf, vg,qual);
        cp = flqual(cpf,cpg,qual);
        mu = flqual(muf,mug,qual);
        k  = flqual( kf, kg,qual);
        Pr = flqual(Prf,Prg,qual);
    end
else
    error('invalid fluid');
end

%Here is where the interpolation is called and derived units are computed.
for(j=[1:numprops])
    if(strmatch(varargin{j},propopts,'exact'))
        if(isequal('rho',varargin{j}))
            if(isempty(rho))
                varargout{j} = 1/flinterp(temp,v,utemp);
            else
                varargout{j} = flinterp(temp,rho,utemp);
            end
        elseif(isequal('v',varargin{j}))
            if(isempty(v))
                varargout{j} = 1/flinterp(temp,rho,utemp);
            else
                varargout{j} = flinterp(temp,v,utemp);
            end
        elseif(isequal('cp',varargin{j}))
            varargout{j} = flinterp(temp,cp,utemp);
        elseif(isequal('mu',varargin{j}))
            varargout{j} = flinterp(temp,mu,utemp);
        elseif(isequal('nu',varargin{j}))
            if(isempty(nu))
                if(isempty(v))
                    varargout{j} = flinterp(temp,mu,utemp,rho)/flinterp(temp,rho,utemp);
                else
                    varargout{j} = flinterp(temp,mu,utemp)*flinterp(temp,v,utemp);
                end
            else
                varargout{j} = flinterp(temp,nu,utemp);
            end
        elseif(isequal('k',varargin{j}))
            varargout{j} = flinterp(temp,k,utemp);
        elseif(isequal('alpha',varargin{j}))
            if(isempty(alpha))
                if(isempty(rho))
                    varargout{j} = flinterp(temp,k,utemp)*flinterp(temp,v,utemp)/flinterp(temp,cp,utemp);
                else
                    varargout{j} = flinterp(temp,k,utemp)/(flinterp(temp,rho,utemp)*flinterp(temp,cp,utemp));
                end
            else
                varargout{j} = flinterp(temp,alpha,utemp);
            end
        elseif(isequal('Pr',varargin{j}))
            varargout{j} = flinterp(temp,Pr,utemp);
        elseif(isequal('beta',varargin{j}))
            if(isempty(beta))
                varargout{j} = 1/utemp;
            else
                varargout{j} = flinterp(temp,beta,utemp);
            end
        elseif(isequal('hfg',varargin{j}))
            varargout{j} = flinterp(temp,hfg,utemp);
        elseif(isequal('sigma',varargin{j}))
            varargout{j} = flinterp(temp,sigma,utemp);
        end
    else
        error('%s is not a valid property type for %s.',varargin{j},fluid);
    end
end
end

function[y]=flinterp(temp,prop,utemp)
%make matrices the same length
L = min(length(temp),length(prop));
temp = temp(1:L);
prop = prop(1:L);
%Check to see if user temp is in bounds with new temperature matrix.
if(utemp<temp(1) | utemp>temp(length(temp)))
    error('User defined temperature for %s must be between %f and %f',fluid,temp(1),temp(length(temp)))
end
%interpolate
y = interp1(temp,prop,utemp);
end

function[qual]=findqual(yf,yg,y,temp,utemp)
%computes quality
yf = flinterp(temp,yf,utemp);
yg = flinterp(temp,yg,utemp);
yfg = yg - yf;
qual = (y-yf)/yfg;
end

function[y]=flqual(yf,yg,qual)
%assures yf and yg are of the same length and calculates property values 
%based on quality
L = min(length(yf),length(yg));
yf = yf(1:L);
yg = yg(1:L);
y = (yg-yf)*qual+yf;
end