SD Toolbox error using it in Matlab

291 views
Skip to first unread message

Inés Petrina

unread,
Sep 8, 2021, 4:15:32 PM9/8/21
to Cantera Users' Group
Hello all,

Has anyone been using the Shock Detonation Toolbox with Matlab? I've finally managed to install Cantera correctly but when I tried to run one of the demos files I had an error with the location of the cti files. I ended up copying the pertinent files onto the Cantera data folder and tried to run it again but several error warnings popped up in the Matlab command window and I'm not sure what they're about.

This is are the errors showed in the command window:

demo_PSfr
Error using ThermoPhase (line 23)

***********************************************************************
CanteraError thrown by call_ctml_writer:
Error converting input file "C:\Program Files\Cantera\data/Mevel2017.cti" to CTML.
Python command was: 'python'
The exit code was: 1
-------------- start of converter log --------------
sys.path: ['', 'C:\\Program Files\\Cantera\\bin', 'C:\\Program
Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.2032.0_x64__qbz5n2kfra8p0\\python39.zip', 'C:\\Program
Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.2032.0_x64__qbz5n2kfra8p0\\DLLs', 'C:\\Program
Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.2032.0_x64__qbz5n2kfra8p0\\lib',
'D:\\Users\\Aulas\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0',
'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.2032.0_x64__qbz5n2kfra8p0', 'C:\\Program
Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.2032.0_x64__qbz5n2kfra8p0\\lib\\site-packages']

Traceback (most recent call last):
  File "<stdin>", line 5, in <module>
ModuleNotFoundError: No module named 'cantera'
--------------- end of converter log ---------------
***********************************************************************


Error in Solution (line 50)
t = ThermoPhase(src, id);

Error in PostShock_fr (line 21)
gas1 = Solution(mech);

Error in demo_PSfr (line 41)
[gas] = PostShock_fr(U, P1, T1, q, mech);
 

Thanks for your help.

Bryan Weber

unread,
Sep 8, 2021, 9:33:03 PM9/8/21
to Cantera Users' Group
Hi,

That error mentions that it couldn't find the Cantera Python module, which is needed to convert CTI files to the CTML format that Cantera uses internally. Did you also install the Python interface? How did you install the Matlab package?

Best,
Bryan

Inés Petrina

unread,
Sep 9, 2021, 2:53:03 PM9/9/21
to Cantera Users' Group
Hello Bryan, 

I did install Python using Anaconda, Matlab was already installed, so I don't know the especifics behind the installation. I'm using a computer in my college, not my personal one. After installing Cantera I tried it both in Matlab and IPython with no errors.

I'm not sure what else should I do.

Best,
Inés

Bryan Weber

unread,
Sep 9, 2021, 4:06:20 PM9/9/21
to Cantera Users' Group
Hi Inés,

The Python that Cantera is looking for is the system Python, not the Anaconda Python. You can set the the PYTHON_CMD environment variable, which is specific to how Cantera finds the proper Python to run the converter. Set that environment variable with the path to your Anaconda environment Python executable.

Best,
Bryan

Alfonso Ciccarelli

unread,
Nov 17, 2022, 11:42:08 PM11/17/22
to Cantera Users' Group
Hi Bryan, Hi Inés.

I'm struggling with the same issue, but i'm running MacOs (Ventura). In which way can i manage?

maxime vauvert

unread,
Feb 11, 2023, 9:10:49 AM2/11/23
to Cantera Users' Group
Hi everyone, 

I have the same problem and I'm running MacOs too, as Alfonso. Did you, Alfonso, solve your issue? In case you managed, how did you do it?

Best regards,
Maxime

Ingmar Schoegl

unread,
Feb 11, 2023, 10:19:22 AM2/11/23
to Cantera Users' Group
As long as you are getting the same error as the one reported at the top of this thread and you installed Cantera using Anaconda (or miniconda), I think Bryan has already pointed out the issue: you need to make sure that the Python version matches the one expected from Cantera's conda environment. The easiest solution is to start Matlab from the command line with the conda environment activated.
-ingmar-

maxime vauvert

unread,
Feb 11, 2023, 12:21:43 PM2/11/23
to Cantera Users' Group
I didn't use Anaconda. I installed Cantera Matlab toolbox with the .pkg installer and the Cantera Python package with Pip. I don't know how to change the Python version Cantera has to look for.

Best regards,
Maxime

Shepherd, Joseph E.

unread,
Feb 11, 2023, 2:04:42 PM2/11/23
to canter...@googlegroups.com
Folks,

I have created yaml versions of all the files used by the SDToolbox. These are in the updated .zip download on
https://shepherd.caltech.edu/EDL/PublicResources/sdt/
and individually on the mechanism web page
https://shepherd.caltech.edu/EDL/PublicResources/sdt/cti_mech.html
User will need to edit extensions on data files in the examples until the next release of the SDT.

I have also added a link to the main documentation .pdf file on the main SDT webpage.

Joe
--
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 <mailto:cantera-user...@googlegroups.com> .
To view this discussion on the web visit https://groups.google.com/d/msgid/cantera-users/442a477a-477b-497a-a095-0143427c43e0n%40googlegroups.com <https://groups.google.com/d/msgid/cantera-users/442a477a-477b-497a-a095-0143427c43e0n%40googlegroups.com?utm_medium=email&utm_source=footer> .

Ingmar Schoegl

unread,
Feb 11, 2023, 5:26:08 PM2/11/23
to Cantera Users' Group
Dear Maxime,

If you are not using conda, then your default `python` command appears to be pointing to macOS' system Python 2.7 installation (which you should be able to confirm by typing `python --version` on the command line; another helpful command is `which python`). You will need to activate (or install) a Python 3 version for Cantera's converter scripts to run. In case you are not sure how to do that, information is readily found online. You probably do have Python 3.0 somewhere, as pip shouldn't allow you to install Cantera for Python 2.

Although you're using MATLAB, Python is needed to convert CTI input files to the XML format that can be read by Cantera's core, which has continued to create confusion for the user community. Note that both of these formats are deprecated as of Cantera 2.6 (and will need to be converted to YAML starting with the next 3.0 release). With the new YAML input format, Python is no longer needed, as this format can be read natively independent of Python.

Dear Joe,

Thanks for uploading YAML files - this should help a lot with MATLAB issues.

-ingmar-
Reply all
Reply to author
Forward
0 new messages