matplotlib

Table Of Contents

Previous topic

Example Code for C++

Next topic

Example Code for Octave

This Page

Example Code for MATLAB

Code

% Example of CoolProp for MATLAB
% Ian Bell, 2013

disp(['CoolProp version: ', PropsSI('version')])
disp(['CoolProp gitrevision: ', PropsSI('gitrevision')])
disp(['CoolProp fluids: ', PropsSI('FluidsList')])

disp(' ')
disp('************ USING EOS *************')
disp(' ')
disp('FLUID STATE INDEPENDENT INPUTS')
disp(['Critical Density Propane: ', num2str(PropsSI('Propane','rhocrit')), ' kg/m^3'])
disp(['TWO PHASE INPUTS (Pressure)'])
disp(['Density of saturated liquid Propane at 101325 Pa: ', num2str(PropsSI('D','P',101325,'Q',0,'Propane')), ' kg/m^3'])
disp(['Density of saturated vapor R290 at 101325 Pa: ', num2str(PropsSI('D','P',101325,'Q',1,'R290')), ' kg/m^3'])
disp(['TWO PHASE INPUTS (Temperature)'])
disp(['Density of saturated liquid Propane at 300 K: ', num2str(PropsSI('D','T',300,'Q',0,'Propane')), ' kg/m^3'])
disp(['Density of saturated vapor R290 at 300 K: ', num2str(PropsSI('D','T',300,'Q',1,'R290')), ' kg/m^3'])
disp(['SINGLE PHASE CYCLE (propane)'])
p = PropsSI('P','T',300,'D',1,'Propane'); 
h = PropsSI('H','T',300,'D',1,'Propane');
disp(['T,D -> P,H ', num2str(300),',',num2str(1), ' --> ',num2str(p),',',num2str(h)])
T = PropsSI('T','P',p,'H',h,'Propane'); 
D = PropsSI('D','P',p,'H',h,'Propane');
disp(['P,H -> T,D', num2str(p),',',num2str(h),'-->',num2str(T),',',num2str(D)])
 
disp([' '])
disp(['************ USING TTSE ***************'])
disp([' '])
PropsSI('Propane','enable_TTSE')
disp(['TWO PHASE INPUTS (Pressure)'])
disp(['Density of saturated liquid Propane at 101325 Pa: ', num2str(PropsSI('D','P',101325,'Q',0,'Propane')), ' kg/m^3'])
disp(['Density of saturated vapor R290 at 101325 Pa: ', num2str(PropsSI('D','P',101325,'Q',1,'R290')), ' kg/m^3'])
disp(['TWO PHASE INPUTS (Temperature)'])
disp(['Density of saturated liquid Propane at 300 K: ', num2str(PropsSI('D','T',300,'Q',0,'Propane')), ' kg/m^3'])
disp(['Density of saturated vapor R290 at 300 K: ', num2str(PropsSI('D','T',300,'Q',1,'R290')), ' kg/m^3'])
disp(['SINGLE PHASE CYCLE (propane)'])
p = PropsSI('P','T',300,'D',1,'Propane'); 
h = PropsSI('H','T',300,'D',1,'Propane');
disp(['T,D -> P,H ', num2str(300),',',num2str(1), ' --> ',num2str(p),',',num2str(h)])
T = PropsSI('T','P',p,'H',h,'Propane'); 
D = PropsSI('D','P',p,'H',h,'Propane');
disp(['P,H -> T,D ', num2str(p),',',num2str(h),' --> ',num2str(T),',',num2str(D)])
PropsSI('Propane','disable_TTSE')

try
    disp(' ')
    disp('************ USING REFPROP ***************')
    disp(' ')
    disp('FLUID STATE INDEPENDENT INPUTS')
    disp(['Critical Density Propane:', num2str(PropsSI('REFPROP-Propane','rhocrit')), ' kg/m^3'])
    disp(['TWO PHASE INPUTS (Pressure)'])
    disp(['Density of saturated liquid Propane at 101325 Pa: ', num2str(PropsSI('D','P',101325,'Q',0,'REFPROP-Propane')), ' kg/m^3'])
    disp(['Density of saturated vapor R290 at 101325 Pa: ', num2str(PropsSI('D','P',101325,'Q',1,'REFPROP-Propane')), ' kg/m^3'])
    disp(['TWO PHASE INPUTS (Temperature)'])
    disp(['Density of saturated liquid Propane at 300 K: ', num2str(PropsSI('D','T',300,'Q',0,'REFPROP-Propane')), ' kg/m^3'])
    disp(['Density of saturated vapor R290 at 300 K: ', num2str(PropsSI('D','T',300,'Q',1,'REFPROP-Propane')), ' kg/m^3'])
    disp(['SINGLE PHASE CYCLE (propane)'])
    p = PropsSI('P','T',300,'D',1,'REFPROP-Propane');
    h = PropsSI('H','T',300,'D',1,'REFPROP-Propane');
    disp(['T,D -> P,H ', num2str(300),',',num2str(1), ' --> ',num2str(p),',',num2str(h)])
    T = PropsSI('T','P',p,'H',h,'REFPROP-Propane'); 
    D = PropsSI('D','P',p,'H',h,'REFPROP-Propane');
    disp(['P,H -> T,D ', num2str(p),',',num2str(h),' --> ',num2str(T),',',num2str(D)])
catch
    disp(' ')
    disp('************ CANT USE REFPROP ************')
    disp(' ')
end
 
disp(' ')
disp('************ BRINES AND SECONDARY WORKING FLUIDS *************')
disp(' ')
disp(['Density of 50% (mass) ethylene glycol/water at 300 K, 101325 Pa: ', num2str(PropsSI('D','T',300,'P',101325,'EG-50%')), 'kg/m^3'])
disp(['Viscosity of Therminol D12 at 350 K, 101325 Pa: ', num2str(PropsSI('V', 'T', 350, 'P', 101325, 'TD12')), 'Pa-s'])

disp(' ')
disp('************ HUMID AIR PROPERTIES *************')
disp(' ')
disp(['Humidity ratio of 50% rel. hum. air at 300 K, 101.325 kPa: ', num2str(HAProps('W','T',300,'P',101.325,'R',0.5)), ' kg_w/kg_da'])
disp(['Relative humidity from last calculation: ', num2str(HAProps('R','T',300,'P',101.325,'W',HAProps('W','T',300,'P',101.325,'R',0.5))), ' (fractional)'])

Output

 
  To get started, type one of these: helpwin, helpdesk, or demo.
  For product information, visit www.mathworks.com.
 
CoolProp version: 4.2.0
CoolProp gitrevision: b'7cd941f8bb2e09f34b398887280ce20f292b058d'
CoolProp fluids: Water,R134a,Helium,Oxygen,Hydrogen,ParaHydrogen,OrthoHydrogen,Argon,CarbonDioxide,Nitrogen,n-Propane,Ammonia,R1234yf,R1234ze(E),R32,R22,SES36,Ethylene,SulfurHexafluoride,Ethanol,DimethylEther,DimethylCarbonate,R143a,R23,n-Dodecane,Propylene,Cyclopentane,R236FA,R236EA,R227EA,R365MFC,R161,HFE143m,Benzene,n-Undecane,R125,CycloPropane,Neon,R124,Propyne,Fluorine,Methanol,RC318,R21,R114,R13,R14,R12,R113,R1234ze(Z),R1233zd(E),AceticAcid,R245fa,R41,CarbonMonoxide,CarbonylSulfide,n-Decane,HydrogenSulfide,Isopentane,Neopentane,Isohexane,Krypton,n-Nonane,Toluene,Xenon,R116,Acetone,NitrousOxide,SulfurDioxide,R141b,R142b,R218,Methane,Ethane,n-Butane,IsoButane,n-Pentane,n-Hexane,n-Heptane,n-Octane,CycloHexane,R152A,R123,R11,MDM,MD2M,MD3M,D6,MM,MD4M,D4,D5,1-Butene,IsoButene,cis-2-Butene,trans-2-Butene,MethylPalmitate,MethylStearate,MethylOleate,MethylLinoleate,MethylLinolenate,o-Xylene,m-Xylene,p-Xylene,EthylBenzene,Deuterium,ParaDeuterium,OrthoDeuterium,Air,R404A,R410A,R407C,R507A,R407F
 
************ USING EOS *************
 
FLUID STATE INDEPENDENT INPUTS
Critical Density Propane: 220.4781 kg/m^3
TWO PHASE INPUTS (Pressure)
Density of saturated liquid Propane at 101325 Pa: 580.883 kg/m^3
Density of saturated vapor R290 at 101325 Pa: 2.4161 kg/m^3
TWO PHASE INPUTS (Temperature)
Density of saturated liquid Propane at 300 K: 489.4474 kg/m^3
Density of saturated vapor R290 at 300 K: 21.6295 kg/m^3
SINGLE PHASE CYCLE (propane)
T,D -> P,H 300,1 --> 56072.7627,634733.6259
P,H -> T,D56072.7627,634733.6259-->300,1
 
************ USING TTSE ***************
 
TWO PHASE INPUTS (Pressure)
Density of saturated liquid Propane at 101325 Pa: 580.8937 kg/m^3
Density of saturated vapor R290 at 101325 Pa: 2.4163 kg/m^3
TWO PHASE INPUTS (Temperature)
Density of saturated liquid Propane at 300 K: 489.4474 kg/m^3
Density of saturated vapor R290 at 300 K: 21.6295 kg/m^3
SINGLE PHASE CYCLE (propane)
T,D -> P,H 300,1 --> 56072.7644,634733.6259
P,H -> T,D 56072.7644,634733.6259 --> 300,1
 
************ USING REFPROP ***************
 
FLUID STATE INDEPENDENT INPUTS
Critical Density Propane:220.4781 kg/m^3
TWO PHASE INPUTS (Pressure)
Density of saturated liquid Propane at 101325 Pa: 580.883 kg/m^3
Density of saturated vapor R290 at 101325 Pa: 2.4161 kg/m^3
TWO PHASE INPUTS (Temperature)
Density of saturated liquid Propane at 300 K: 489.4474 kg/m^3
Density of saturated vapor R290 at 300 K: 21.6295 kg/m^3
SINGLE PHASE CYCLE (propane)
T,D -> P,H 300,1 --> 56072.7627,634733.6297
P,H -> T,D 56072.7627,634733.6297 --> 300,1
 
************ BRINES AND SECONDARY WORKING FLUIDS *************
 
Density of 50% (mass) ethylene glycol/water at 300 K, 101325 Pa: 1061.1793kg/m^3
Viscosity of Therminol D12 at 350 K, 101325 Pa: 0.00052288Pa-s
 
************ HUMID AIR PROPERTIES *************
 
Humidity ratio of 50% rel. hum. air at 300 K, 101.325 kPa: 0.011096 kg_w/kg_da
Relative humidity from last calculation: 0.5 (fractional)