Cantera and Matlab

85 views
Skip to first unread message

Leo G

unread,
Apr 18, 2025, 10:16:15 AMApr 18
to Cantera Users' Group
Hello everyone,

I am trying to use Cantera with Matlab. Cantera 3.1 seems not to be compatible with the Matlab interface, as mentioned on their website. I tried several solutions, but I am still stuck, and the website for v3.0 is no longer available: https://cantera.org/install/index.html

1. First, I tried using conda with the following command:
conda create --name ct-env --channel cantera cantera cantera-matlab
However, after setting the ctpath.m, I encountered the following error:
>> gas = Solution('gri30.xml')
Invalid MEX-file 'C:\Users\*\.conda\envs\ct-env\share\cantera\matlab\toolbox\ctmethods.mexw64': The specified procedure could not be found.

The MEX file is present but seems to not be working.

2. I also tried cloning the Git repository, followed by scons build and installation. This gave me the Matlab experimental folder. I followed the README procedure and changed the ctRoot.m, but I encountered this error: 
Error using loadlibrary Could not find file C:\Users\*\.conda\envs\ct-env2\include\cantera\clib\ctmatlab.h. 

I see that an .msi installer is also available, and I will try this option last, but I would prefer to stick with conda if possible. If anyone knows how to make it work, I would really appreciate your help.

Lastly, I tried using the Python extension, and it works: 
py.cantera.Solution('gri30.yaml')
However, I do not want to be dependent on Python, as I may need to compile my code using Simulink/Matlab Coder.

Have a nice day.

   

Ingmar Schoegl

unread,
May 31, 2025, 10:51:31 AMMay 31
to Cantera Users' Group
Hi Leo,
While I may not be fully able to assist with the question, I opened an issue report regarding the inaccessible installation instructions. The only thing I remember from when I used MATLAB and conda was that I needed to launch matlab from the command line after switching into that conda environment. Also, the path:
 'C:\Users\*\.conda\envs\ct-env\share\cantera\matlab\toolbox\ctmethods.mexw64'
looks somewhat suspect. I'd suggest replacing the wildcard '*' with your actual user name.
-is-

Shikshit Nawani

unread,
Jun 5, 2025, 10:01:22 AMJun 5
to canter...@googlegroups.com

Use gri30.yaml file


--
You received this message because you are subscribed to the Google Groups "Cantera Users' Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cantera-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/cantera-users/1c9fa222-480b-42ac-929c-5abf93e05a8an%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages