Scale the default atol (1e-15) by the total mole number of the reactor to maintain accuracy even for very large / very small reactors. Co-authored-by: OpenAI Codex <codex@openai.com>
Experimental MATLAB Toolbox for Cantera
The MATLAB Cantera interface has been fully modernized to improve usability, performance, and maintainability. The legacy toolbox has been replaced with a fully object-oriented structure, providing MATLAB classes that directly map to Cantera objects and functions.
Installation Guide
Prerequisites
- MATLAB (R2024a or later)
- MATLAB-compatible C++ compiler. Refer to the supported compilers list.
Installation Steps
-
Download the MATLAB Cantera toolbox
- Pull Cantera source code from GitHub
-
Obtain Cantera library and header files
- Compile from source by following Cantera Source Install instructions.
-
Add toolbox to MATLAB path
-
Windows/MacOS: Launch MATLAB, navigate to the toolbox folder using Browse for Folder, and add it (including subfolders) to the MATLAB search path. Example:
/path/to/cantera/interfaces/matlab -
Linux: Configure MATLAB to use the system C++ library instead of MATLAB’s built-in version:
export LD_PRELOAD=/path/to/system/C++/libraryThen launch MATLAB and add the toolbox path as above.
-
-
Build the MATLAB Cantera interface Run the following commands in MATLAB:
ctToolboxDir = '/path/to/cantera/source/interfaces/matlab'; ctCLibIncludeDir = '/path/to/cantera/include'; ctLibDir = '/path/to/cantera/library'; ct.buildInterface(ctToolboxDir, ctCLibIncludeDir, ctLibDir);If you compiled Cantera from source,
ctCLibIncludeDirshould bepath/to/cantera/source/interfaces/clib/includeandctLibDirshould bepath/to/cantera/source/build/libor the corresponding locations after installation. -
Verify build After building, the compiled interface should appear under:
/path/to/cantera/interfaces/matlab/cantera/ctMatlab
Usage Guide
-
Load the toolbox
ct.load()The interface supports two modes:
'outofprocess'(default) — higher stability and compatibility with some performance overhead; required on Linux.'inprocess'— runs inside MATLAB with lower overhead.
-
Run examples Navigate to the samples folder:
/samples/matlab -
Run the unit test suite Navigate to the test folder:
/test/matlabExecute:
runMatlabInterfaceTests.m -
Unload the toolbox To stop using the interface, run:
ct.cleanUp ct.unload