Octave Wrapper

Pre-compiled Binaries

Pre-compiled release binaries can be downloaded from Octave. Development binaries coming from the buildbot server can be found at 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 begining 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:

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

  1. Download a MinGW build from Octave for windows.
  2. Extract the zip file to somewhere on your computer without any spaces in the path (c:\octave-x.x.x is a good choice)
  3. 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
# 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, include, etc. (or set a system variable in your windows installation)
set OCTAVE_ROOT=c:\path\to\octave\root
# Add the bin folder of your octave install to the system path
set PATH=c:\path\to\octave\bin;%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
# 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&Ethane');
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

GNU Octave, version 3.8.2
Copyright (C) 2014 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type 'warranty'.

Octave was configured for "x86_64-apple-darwin13.4.0".

Additional information about Octave is available at http://www.octave.org.

Please contribute if you find this software useful.
For more information, visit http://www.octave.org/get-involved.html

Read http://www.octave.org/bugs.html to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.

**************** INFORMATION ***************
This example was auto-generated by the language-agnostic dev/scripts/example_generator.py script written by Ian Bell
CoolProp version: 6.1.0
CoolProp gitrevision: 7864c2614ce5a0ef972386ee7f39859f0d3f8038
CoolProp Fluids: 1-Butene,Acetone,Air,Ammonia,Argon,Benzene,CarbonDioxide,CarbonMonoxide,CarbonylSulfide,cis-2-Butene,CycloHexane,Cyclopentane,CycloPropane,D4,D5,D6,Deuterium,Dichloroethane,DiethylEther,DimethylCarbonate,DimethylEther,Ethane,Ethanol,EthylBenzene,Ethylene,EthyleneOxide,Fluorine,HeavyWater,Helium,HFE143m,Hydrogen,HydrogenChloride,HydrogenSulfide,IsoButane,IsoButene,Isohexane,Isopentane,Krypton,m-Xylene,MD2M,MD3M,MD4M,MDM,Methane,Methanol,MethylLinoleate,MethylLinolenate,MethylOleate,MethylPalmitate,MethylStearate,MM,n-Butane,n-Decane,n-Dodecane,n-Heptane,n-Hexane,n-Nonane,n-Octane,n-Pentane,n-Propane,n-Undecane,Neon,Neopentane,Nitrogen,NitrousOxide,Novec649,o-Xylene,OrthoDeuterium,OrthoHydrogen,Oxygen,p-Xylene,ParaDeuterium,ParaHydrogen,Propylene,Propyne,R11,R113,R114,R115,R116,R12,R123,R1233zd(E),R1234yf,R1234ze(E),R1234ze(Z),R124,R125,R13,R134a,R13I1,R14,R141b,R142b,R143a,R152A,R161,R21,R218,R22,R227EA,R23,R236EA,R236FA,R245ca,R245fa,R32,R365MFC,R40,R404A,R407C,R41,R410A,R507A,RC318,SES36,SulfurDioxide,SulfurHexafluoride,Toluene,trans-2-Butene,Water,Xenon
*********** HIGH LEVEL INTERFACE *****************
Critical temperature of water: 647.096 K
Boiling temperature of water at 101325 Pa: 373.124 K
Phase of water at 101325 Pa and 300 K: liquid
c_p of water at 101325 Pa and 300 K: 4180.636 J/kg/K
c_p of water (using derivatives) at 101325 Pa and 300 K: 4180.636 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.179 kg/m^3
Viscosity of Therminol D12 at 350 K, 101325 Pa: 0.00052288 Pa-s
*********** REFPROP *****************
REFPROP version: 9.1.1.10
Critical temperature of water: 647.096 K
Boiling temperature of water at 101325 Pa: 373.124 K
c_p of water at 101325 Pa and 300 K: 4180.636 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.52 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