CERFACS Chemistry Sharing knowledge for CFD chemical kinetics

Cantera with Pycharm

Linking Cantera to PyCharm is of interest for debugging some python scripts. Indeed, whether with simple cantera scripts or ARCANE code, it is able to detect coding errors (typo in variable for instance) but also mistakes associated to coding standards.

As cantera is not encapsulated by the pip installation, you need to provide some information to PyCharm so that the software is able to use cantera:

  • First, go to the button menu PyCharm and click on Preferences…. There, open the Build, Execution, Deployment list, and then the Console list. You should find the Python Console screen.
    There, add in the Environment variables line, the variable : /path_to_cantera/INSTALL_DIR/lib/python3.9/site-packages/. Push the OK button.
  • Second, go to the button menu Run and click on Edit configurations. There, click on the Templates list and finally on the Python button.
    As before, add in the Environment variables line the variable : /path_to_cantera/INSTALL_DIR/lib/python3.9/site-packages/. Push the OK button.

If you now try to run your script by right-clicking on it and pushing the Run ‘your script’ button, It should run, congratulations !

You can also run your script with a terminal console through pycharm. The interest of running a script with a python console is that you can see the different variables and their value, which is very useful when debugging and adding some breakpoints for instance. To show variables, click on the glasses in the python console.

WARNING : PyCharm does not work with f90 compilation for ARC mechanisms !!

No content defined in the sidebar.