Octave Wrapper#
Some Notes on GNU Octave Packages#
Warning
Currently, GNU Octave is built using a very specific version of the GCC toolchain and requires any add-in packages like the CoolProp wrapper to be built with the exact same toolchain version for GCC compatibility. Slight deviations from this toolchain, especially the GCC version, will render the package unusable in the target version of GNU Octave.
A per-install “site” folder is kept on Octave’s path at every launch, and it’s found this way:
octave-config -p LOCALOCTFILEDIR
On Linux, with a distro-packaged Octave (Ubuntu’s
octave/octave-dev, for instance), that folder is usually tucked under/usr/lib/.../octave/site/oct/...and owned by root, sosudois needed to drop a file there.On Windows, the official installer’s own site folder sits under
Program Filesand needs an administrator shell; MSYS2 UCRT64’s site folder, on the other hand, is normally writable without elevation, since the whole install tree there is user-owned.When those privileges aren’t available, or a shared system folder is best left alone, Octave’s own no-privileges trick comes in handy: a line is added to
~/.octaverc(created once, by hand, in the user’s home directory) that callsaddpath()on a folder that’s already owned, and.octfiles are dropped there from then on. Since~/.octavercruns automatically at every Octave startup, nothing requires repeating at the top of each Octave script/session. This method is used by the CoolPropcmake --install .command that is discussed below.Alternatively, the same
addpath()command can be used at the script/session level by placing it directly inside a single session or script, to avoid load-every-time behavior:Example: the folder holding
CoolProp.octis added to the Octave path inside a single Octave session/script like this (Leaving off the .oct extension):addpath('/home/?user_name?/Some_folder/CoolProp')
There is example code at the end of this page that demonstrates Octave calls to CoolProp functions. This code script is generated by the build script and placed in every build directory for package verification when building the CoolProp wrapper.
Pre-compiled Binaries#
Pre-compiled release binaries are no longer supplied in CoolProp’s SourceForge repository. There are simply too many OS, hardware, and Octave version combinations to keep current and cross-combinations are binary incompatible.
User-Compiled Binaries#
Common Requirements#
Compilation of the Octave wrapper requires a few common wrapper pre-requisites
Additional requirements:
SWIG (see common wrapper pre-requisites)
Octave (and development headers)
Linux#
On Ubuntu and friends, GNU Octave and its associated build dependencies are installed this way:
sudo apt-get install swig octave octave-dev build-essential cmake ninja-build git
Note
The development package, octave-dev, used to be called liboctave-dev on older Debian/Ubuntu releases. Either way, apt builds octave and its matching dev package from the same source and pins them to each other with a hard version dependency, so there’s no separate compiler toolchain to match by hand.
The Octave version that comes from apt depends on which Ubuntu release is used. Ubuntu 24.04 LTS ships Octave 8.4.0 and 26.04 LTS ships Octave 11.1.0, which is much closer to the current upstream version as of this update. Either way, the dev package is version-locked to its matching octave package, so the GCC compiler version is always in sync.
OSX#
Per https://wiki.octave.org/Octave_for_macOS, there’s no installer anymore for the latest GNU Octave on macOS; Homebrew is now the maintained path to the current stable release. This has not been tested in recent years by the CoolProp team. Following installation, it might be desirable to add the octave binary folder onto the path. To do so, add to the file .profile (or create it) in the user’s home directory:
export PATH="$(brew --prefix octave)/bin:$PATH"
Attention
Testing and updating of this OSX section is requested by an OSX Octave user. An update PR is welcome.
Windows#
On Windows, the situation has improved dramatically over the last several years and two routes are supported. Either one works, depending on how GNU Octave should be run on the Windows machine. However, as noted above, a CoolProp.oct package only loads in the exact Octave version it’s built against; both must use the exact GCC compiler version.
One of the two routes below should be used exclusively:
The official Octave installer’s own bundled toolchain (the easier route for most people) Octave is downloaded and installed as usual from Octave for Windows. A matched GCC, CMake, and Python are shipped right inside the installer’s own folder, reached by opening “Bash Shell” from Octave’s Start Menu entry: a shell with that toolchain already first on
PATH, and the bundled GCC is guaranteed to match its companion Octave version. Two build tools are not bundled, though, and need to be added by hand once per machine; see the note in the build steps below.Note
The Windows Installer (11.3.0) is currently, as of this page update, built on
MSYS2 MinGW-w64, which is now deprecated by MSYS2 in favor ofMSYS2 UCRT64. However, since the official installer ships the entire toolchain with Octave, it can still be used. It is expected that subsequent versions will be forced to switch toMSYS2 UCRT64.MSYS2 UCRT64 (for the most current Octave/GCC, or when MSYS2 is already in use). For this option, GNU Octave is not installed natively on Windows, it is installed and run within an
MSYS2 UCRT64emulation environment.Install MSYS2 from msys2.org.
Open an MSYS2 UCRT64 shell (not MSYS, not MINGW64) and run
pacman -Syuuntil it reports nothing left to do.Then, and only then, install Octave and the build tools as follows:
pacman -S mingw-w64-ucrt-x86_64-octave mingw-w64-ucrt-x86_64-toolchain mingw-w64-ucrt-x86_64-cmake mingw-w64-ucrt-x86_64-ninja mingw-w64-ucrt-x86_64-swig
MSYS2 UCRT64installs its own UCRT64-based version of GNU OctaveSee CoolProp’s MSYS2 Setup Help for more information.
Tip
The full
pacman -Syuupgrade is always run before Octave is installed, and repeated until nothing is left to do. It may ask for the shell to be closed and reopened partway through, and that step matters. Skipping it can leave a GCC package conflict behind. Octave is never installed onto a partially upgraded MSYS2.
Warning
A standalone MinGW-w64 toolchain installed apart from either recommended route above (e.g., an old bare MinGW install or a distribution like TDM-GCC) isn’t recommended. Nothing guarantees its GCC version matches whichever Octave it’s loaded into, and a mismatch fails at module load time with an unhelpful “specified procedure could not be found” error, not at build time. TDM-GCC in particular also targets the older msvcrt.dll runtime rather than the UCRT runtime used by both recommended routes above, so it’s doubly unsuitable. Additionally, Microsoft’s Visual C/C++ compiler (MSVC) is not an option.
Build#
On Linux, once the dependencies above are in place, the builder is run this way:
# Check out the sources from GitHub
git clone https://github.com/CoolProp/CoolProp.git
# ...and move into the folder just created
cd CoolProp
# Make a build folder and change to that folder
# The build folder must start with "build", e.g., "buildOctave"
mkdir -p build && cd build
# Use CMake to generate the make file
cmake .. -DCOOLPROP_OCTAVE_MODULE=ON
# Build the OCT file
cmake --build .
# (OPTIONAL) Install, and register it with ~/.octaverc for auto-loading
cmake --install .
CoolProp.oct is optionally installed in the last step under the build’s own install path prefix rather than into Octave’s (often root-owned) site folder. A line pointing to that path is added to the user’s ~/.octaverc so that the package is automatically on every Octave startup.
Note
The CMake script defaults to an optimized Release build. An unoptimized build (using the switch -DCMAKE_BUILD_TYPE=Debug) still works if desired. However, there will be a noticeable delay (~30s) on the first CoolProp.* function call while the fluid library is initialized.
On Windows, the same build is run from whichever shell matches the Octave installation route chosen above:
From the official installer’s own Bash Shell (Recommended):
Note
This Bash Shell doesn’t actually bundle SWIG or a CMake-compatible build driver, even though its CMake reports both Ninja and MinGW Makefiles as available generators; that list is just what CMake was compiled to support, not what’s installed on this machine. Two one-time fixes, neither needing admin rights:
SWIG: download
swigwin-<version>.zipfrom swig.org (a self-contained build, no installer). SWIG only generates wrapper source, so it doesn’t need to match the GCC/Octave toolchain the wayCoolProp.octdoes. Unzip it anywhere and add that folder toPATHfor this session:export PATH="/c/path/to/swigwin-<version>:$PATH"
Build driver:
mingw32-make.exeandninja.exeare both missing, so-G "MinGW Makefiles"and-G Ninjafail. Use-G "MSYS Makefiles"instead, which runs on this shell’s own bundledmake.
# Clone the CoolProp repository in a CoolProp directory at the current location
git clone https://github.com/CoolProp/CoolProp.git
# Change to the CoolProp folder just created
cd CoolProp
# Make a build* directory and cd into that directory
mkdir buildOct && cd buildOct
# Create the make system for the Octave wrapper using the MSYS generator
cmake .. -G "MSYS Makefiles" -DCOOLPROP_OCTAVE_MODULE=ON
# Build the CoolProp wrapper package
cmake --build .
# (OPTIONAL) Register the package in ~/.octaverc for auto-loading
cmake --install .
From an MSYS2 UCRT64 shell:
# Clone the CoolProp repository in a CoolProp directory at the current location
git clone https://github.com/CoolProp/CoolProp.git
# Change to the CoolProp folder just created
cd CoolProp
# Make a build* directory and cd into that directory
mkdir buildOct && cd buildOct
# Create the make system for the Octave wrapper using the Ninja generator
cmake .. -G Ninja -DCOOLPROP_OCTAVE_MODULE=ON
# Build the CoolProp wrapper package
cmake --build .
# (OPTIONAL) Register the package in ~/.octaverc for auto-loading
cmake --install .
cmake --install . works the same way here as on Linux: no administrator shell is needed, since it installs under the build’s own prefix and adds that folder to ~/.octaverc automatically. Of course, the file can be saved in any desired location and the ~/.octaverc file can be updated to point to the package there.
Verifying the CoolProp Build#
A generated Octave example is how a build is verified. The example Octave code is written straight into the build folder as Example.m and run this way:
octave Example.m
This file can also be loaded into the GUI editor and run by pressing F5.
Note
The commands below assume CoolProp.oct is already on Octave’s path, which the (optional) cmake --install . step arranges via ~/.octaverc. When that step was skipped, either run Octave from inside the build folder, or add it to the path for the session first with addpath('/path/to/build/folder').
The first call to any CoolProp.* function can take several seconds while CoolProp’s fluid library gets initialized; that’s expected, not a hang. A quicker one-line check that skips the rest of the example:
octave --no-gui --eval "CoolProp; disp(CoolProp.get_global_param_string('version'))"
From the GUI, just issue the following commands at the prompt:
octave:1> CoolProp;
octave:2> CoolProp.get_global_param_string("version")
The example script’s two REFPROP-dependent sections print a short notice and are skipped automatically when NIST REFPROP isn’t installed on the user’s machine, rather than aborting the entire script on failure to load REFPROP.
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 https://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')]);
try
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')]);
catch err
disp(['REFPROP example skipped: ', err.message])
end_try_catch
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')]);
try
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')]);
catch err
disp(['REFPROP example skipped: ', err.message])
end_try_catch
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: 8.1.0
CoolProp gitrevision: 4e19537788421c957d7dab7ba5d6bff34404a023
CoolProp Fluids: Methane,SulfurHexafluoride,VinylChloride,DimethylCarbonate,Ethylene,1-Butene,Novec649,Oxygen,n-Perfluorobutane,R141b,n-Nonane,R404A,R134a,n-Hexane,R13,DiethylEther,RC318,R245fa,EthylBenzene,n-Dodecane,Neopentane,EthyleneOxide,IsoButene,MethylStearate,R227EA,OrthoHydrogen,MethylOleate,MethylLinoleate,HFE143m,R1233zd(E),Helium,R1234ze(E),R13I1,R40,Ammonia,m-Xylene,Air,MD2M,CycloHexane,R1130(E),Isohexane,R1336mzz(E),D5,Dichloroethane,IsoButane,Cyclopentane,OrthoDeuterium,CarbonMonoxide,R41,NitrousOxide,R1132a,SulfurDioxide,n-Butane,R21,Chlorine,R143a,Xenon,HydrogenChloride,R507A,p-Xylene,o-Xylene,R218,DimethylEther,R116,cis-2-Butene,MM,Tetrahydrofuran,R161,Hydrogen,R245ca,Nitrogen,R365MFC,n-Perfluorohexane,R113,Isopentane,CycloPropane,Ethane,n-Undecane,R1132(E),Benzene,Krypton,R1243zf,n-Perfluoropentane,n-Decane,MD3M,MD4M,R236FA,R14,n-Pentane,R125,Toluene,R11,Neon,R123,HydrogenSulfide,CarbonylSulfide,Ethanol,R152A,R23,n-Heptane,ParaHydrogen,Argon,R124,R410A,HeavyWater,ParaDeuterium,Propylene,R1123,Methanol,n-Propane,R1234yf,MethylPalmitate,D6,CarbonDioxide,R236EA,SES36,Acetone,MDM,D4,R115,Fluorine,Deuterium,Water,trans-2-Butene,R142b,MethylLinolenate,R1336mzz(Z),R32,R1234ze(Z),PropyleneGlycol,R407C,Propyne,n-Octane,R1224YDZ,R12,R114,R22
*********** 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
Page Last Updated and verified: 11-20-2026