Octave Wrapper¶
Pre-compiled Binaries¶
Pre-compiled release binaries can be downloaded from 6.8.1dev Octave. Development binaries coming from the buildbot server can be found at nightly Octave. Download the oct file appropriate to your system.
On Linux systems you can put the generated .oct file in
/usr/share/octave/?octave.version.number?/m
folder. You will need superuser
privileges to do this.
If you place .oct file somewhere outside octave path, you have to use “addpath” function at beginning of your code.
Example: adding the folder that contains CoolProp.oct file to the Octave path:
addpath('/home/?user_name?/Some_folder/CoolProp')
There is example code at the end of this page
User-Compiled Binaries¶
Common Requirements¶
Compilation of the Octave wrapper requires a few common wrapper pre-requisites
You will also need:
SWIG (see common wrapper pre-requisites)
Octave (and development headers)
Linux¶
For ubuntu and friends, you can install build dependencies using:
sudo apt-get install swig octave liboctave-dev
OSX¶
For OSX, your best best is a binary installer (see http://wiki.octave.org/Octave_for_MacOS_X), alternatively, you can install from Homebrew, though as of July 6, 2014, this functionality was broken in OSX 10.9. If you use the installer, you might want to add the octave binary folder onto the path. To do so, add to the file .profile (or create it) in your home directory:
export PATH="/usr/local/octave/3.8.0/bin:$PATH"
Windows¶
For windows, the situation is ok, but not great. Only the MinGW builds are supported, and not comfortably
Download a MinGW build from Octave for windows.
Extract the zip file to somewhere on your computer without any spaces in the path (c:\octave-x.x.x is a good choice)
Rename the sh.exe in the bin folder of your installation to _sh.exe
Warning
MinGW has problems with the latest version of CoolProp. This seems to be a GCC-related issue and using a more up-to-date version of GCC helps. Unfortunately, MinGW is stuck at GCC 4.8. You could try the TDM-GCC distribution that comes with the latest GCC. This version seems to work fine.
Build¶
Once the dependencies are installed, you can run the builder and tests using:
# Check out the sources for CoolProp
git clone https://github.com/CoolProp/CoolProp --recursive
# Move into the folder you just created
cd CoolProp
# Make a build folder
mkdir -p build && cd build
# Build the makefile using CMake
cmake .. -DCOOLPROP_OCTAVE_MODULE=ON -DBUILD_TESTING=ON -DCMAKE_CXX_STANDARD=11
# Make the OCT files
cmake --build .
# Run the integration tests (optional)
ctest --extra-verbose
On windows, you need to just slightly modify the building procedure:
# The folder containing the folders bin, mingw, swigwin, include, etc...
# is required
set OCTAVE_ROOT=c:\octave-x.y.z
set PATH=c:\MinGW;c:\octave-x.y.z\bin;c:\swigwin-x.y.z;%PATH%
# Check out the sources for CoolProp
git clone https://github.com/CoolProp/CoolProp --recursive
# Move into the folder you just created
cd CoolProp
# Make a build folder
mkdir build
# Move into that folder
cd build
# Build the makefile using CMake
cmake .. -G "MinGW Makefiles" -DCOOLPROP_OCTAVE_MODULE=ON -DBUILD_TESTING=ON -DCMAKE_CXX_STANDARD=11
# Make the OCT files
cmake --build .
# Run the integration tests (optional)
ctest --extra-verbose
Example Code¶
CoolProp
disp([num2str('**************** INFORMATION ***************')]);
disp([num2str('This example was auto-generated by the language-agnostic dev/scripts/example_generator.py script written by Ian Bell')]);
disp([num2str('CoolProp version:'), ' ', num2str(CoolProp.get_global_param_string('version'))]);
disp([num2str('CoolProp gitrevision:'), ' ', num2str(CoolProp.get_global_param_string('gitrevision'))]);
disp([num2str('CoolProp Fluids:'), ' ', num2str(CoolProp.get_global_param_string('FluidsList'))]);
% See http://www.coolprop.org/coolprop/HighLevelAPI.html#table-of-string-inputs-to-propssi-function for a list of inputs to high-level interface;
disp([num2str('*********** HIGH LEVEL INTERFACE *****************')]);
disp([num2str('Critical temperature of water:'), ' ', num2str(CoolProp.Props1SI('Water', 'Tcrit')), ' ', num2str('K')]);
disp([num2str('Boiling temperature of water at 101325 Pa:'), ' ', num2str(CoolProp.PropsSI('T', 'P', 101325, 'Q', 0, 'Water')), ' ', num2str('K')]);
disp([num2str('Phase of water at 101325 Pa and 300 K:'), ' ', num2str(CoolProp.PhaseSI('P', 101325, 'T', 300, 'Water'))]);
disp([num2str('c_p of water at 101325 Pa and 300 K:'), ' ', num2str(CoolProp.PropsSI('C', 'P', 101325, 'T', 300, 'Water')), ' ', num2str('J/kg/K')]);
disp([num2str('c_p of water (using derivatives) at 101325 Pa and 300 K:'), ' ', num2str(CoolProp.PropsSI('d(H)/d(T)|P', 'P', 101325, 'T', 300, 'Water')), ' ', num2str('J/kg/K')]);
disp([num2str('*********** HUMID AIR PROPERTIES *****************')]);
disp([num2str('Humidity ratio of 50% rel. hum. air at 300 K, 101325 Pa:'), ' ', num2str(CoolProp.HAPropsSI('W', 'T', 300, 'P', 101325, 'R', 0.5)), ' ', num2str('kg_w/kg_da')]);
disp([num2str('Relative humidity from last calculation:'), ' ', num2str(CoolProp.HAPropsSI('R', 'T', 300, 'P', 101325, 'W', CoolProp.HAPropsSI('W', 'T', 300, 'P', 101325, 'R', 0.5))), ' ', num2str('(fractional)')]);
disp([num2str('*********** INCOMPRESSIBLE FLUID AND BRINES *****************')]);
disp([num2str('Density of 50% (mass) ethylene glycol/water at 300 K, 101325 Pa:'), ' ', num2str(CoolProp.PropsSI('D', 'T', 300, 'P', 101325, 'INCOMP::MEG-50%')), ' ', num2str('kg/m^3')]);
disp([num2str('Viscosity of Therminol D12 at 350 K, 101325 Pa:'), ' ', num2str(CoolProp.PropsSI('V', 'T', 350, 'P', 101325, 'INCOMP::TD12')), ' ', num2str('Pa-s')]);
% If you don't have REFPROP installed, disable the following lines;
disp([num2str('*********** REFPROP *****************')]);
disp([num2str('REFPROP version:'), ' ', num2str(CoolProp.get_global_param_string('REFPROP_version'))]);
disp([num2str('Critical temperature of water:'), ' ', num2str(CoolProp.Props1SI('REFPROP::WATER', 'Tcrit')), ' ', num2str('K')]);
disp([num2str('Boiling temperature of water at 101325 Pa:'), ' ', num2str(CoolProp.PropsSI('T', 'P', 101325, 'Q', 0, 'REFPROP::WATER')), ' ', num2str('K')]);
disp([num2str('c_p of water at 101325 Pa and 300 K:'), ' ', num2str(CoolProp.PropsSI('C', 'P', 101325, 'T', 300, 'REFPROP::WATER')), ' ', num2str('J/kg/K')]);
disp([num2str('*********** TABULAR BACKENDS *****************')]);
TAB = AbstractState.factory('BICUBIC&HEOS', 'R245fa');
TAB.update(CoolProp.PT_INPUTS, 101325, 300);
disp([num2str('Mass density of refrigerant R245fa at 300 K, 101325 Pa:'), ' ', num2str(TAB.rhomass()), ' ', num2str('kg/m^3')]);
disp([num2str('*********** SATURATION DERIVATIVES (LOW-LEVEL INTERFACE) ***************')]);
AS_SAT = AbstractState.factory('HEOS', 'R245fa');
AS_SAT.update(CoolProp.PQ_INPUTS, 101325, 0);
disp([num2str('First saturation derivative:'), ' ', num2str(AS_SAT.first_saturation_deriv(CoolProp.iP, CoolProp.iT)), ' ', num2str('Pa/K')]);
disp([num2str('*********** LOW-LEVEL INTERFACE *****************')]);
AS = AbstractState.factory('HEOS', 'Water&Ethanol');
z = DoubleVector(); z.push_back(0.5); z.push_back(0.5);;
AS.set_mole_fractions(z);
AS.update(CoolProp.PQ_INPUTS, 101325, 1);
disp([num2str('Normal boiling point temperature of water and ethanol:'), ' ', num2str(AS.T()), ' ', num2str('K')]);
% If you don't have REFPROP installed, disable the following block;
disp([num2str('*********** LOW-LEVEL INTERFACE (REFPROP) *****************')]);
AS2 = AbstractState.factory('REFPROP', 'METHANEÐANE');
z2 = DoubleVector(); z2.push_back(0.2); z2.push_back(0.8);;
AS2.set_mole_fractions(z2);
AS2.update(CoolProp.QT_INPUTS, 1, 120);
disp([num2str('Vapor molar density:'), ' ', num2str(AS2.keyed_output(CoolProp.iDmolar)), ' ', num2str('mol/m^3')]);
Example Code Output¶
**************** INFORMATION ***************
This example was auto-generated by the language-agnostic dev/scripts/example_generator.py script written by Ian Bell
CoolProp version: 6.8.1dev
CoolProp gitrevision: 45fdfaa8ea5c29509af83810de83a0e9cd2c2f21
CoolProp Fluids: R13I1,cis-2-Butene,CycloPropane,MD3M,NitrousOxide,SulfurHexafluoride,R161,1-Butene,MethylStearate,MethylOleate,SES36,R245fa,Isopentane,Neopentane,R41,Neon,o-Xylene,HeavyWater,CarbonMonoxide,R124,Dichloroethane,ParaHydrogen,R11,R14,n-Butane,R236FA,Hydrogen,R134a,Air,n-Pentane,R227EA,R23,OrthoDeuterium,OrthoHydrogen,CarbonylSulfide,MD2M,Benzene,MethylPalmitate,Deuterium,R113,n-Hexane,Water,n-Dodecane,trans-2-Butene,R1243zf,Krypton,R152A,Novec649,R22,EthylBenzene,CarbonDioxide,D4,R125,RC318,ParaDeuterium,R143a,MethylLinoleate,R1233zd(E),Helium,R1336MZZE,Nitrogen,Acetone,R218,m-Xylene,MM,EthyleneOxide,R407C,n-Undecane,n-Propane,HFE143m,Propylene,R21,R142b,R32,R123,Toluene,DimethylCarbonate,R115,DimethylEther,R1234ze(E),R13,Fluorine,Ethylene,R365MFC,IsoButane,Cyclopentane,R141b,Isohexane,Ethane,DiethylEther,Argon,HydrogenSulfide,MethylLinolenate,n-Heptane,n-Decane,IsoButene,HydrogenChloride,Oxygen,R40,CycloHexane,p-Xylene,R404A,Ammonia,SulfurDioxide,R116,R245ca,Xenon,D5,R507A,Methane,Methanol,Propyne,MD4M,R1234ze(Z),Ethanol,n-Octane,R114,D6,R1234yf,n-Nonane,R410A,R236EA,R12,MDM
*********** HIGH LEVEL INTERFACE *****************
Critical temperature of water: 647.096 K
Boiling temperature of water at 101325 Pa: 373.1243 K
Phase of water at 101325 Pa and 300 K: liquid
c_p of water at 101325 Pa and 300 K: 4180.6358 J/kg/K
c_p of water (using derivatives) at 101325 Pa and 300 K: 4180.6358 J/kg/K
*********** HUMID AIR PROPERTIES *****************
Humidity ratio of 50% rel. hum. air at 300 K, 101325 Pa: 0.011096 kg_w/kg_da
Relative humidity from last calculation: 0.5 (fractional)
*********** INCOMPRESSIBLE FLUID AND BRINES *****************
Density of 50% (mass) ethylene glycol/water at 300 K, 101325 Pa: 1061.1793 kg/m^3
Viscosity of Therminol D12 at 350 K, 101325 Pa: 0.00052288 Pa-s
*********** REFPROP *****************
REFPROP version: 10.0
Critical temperature of water: 647.096 K
Boiling temperature of water at 101325 Pa: 373.1243 K
c_p of water at 101325 Pa and 300 K: 4180.6358 J/kg/K
*********** TABULAR BACKENDS *****************
Mass density of refrigerant R245fa at 300 K, 101325 Pa: 5.6481 kg/m^3
*********** SATURATION DERIVATIVES (LOW-LEVEL INTERFACE) ***************
First saturation derivative: 4058.5198 Pa/K
*********** LOW-LEVEL INTERFACE *****************
Normal boiling point temperature of water and ethanol: 357.273 K
*********** LOW-LEVEL INTERFACE (REFPROP) *****************
Vapor molar density: 0.44147 mol/m^3
octave: X11 DISPLAY environment variable not set
octave: disabling GUI features
error: ignoring const execution_exception& while preparing to exit