Calling chemical kinetics solvers like CHEMKIN or Cantera from Julia

Step 1: Go to the Cantera Downloads page and install Cantera in your system using Python installation. Follow the steps in the website as is and test if Cantera works in the Python IDLE. Copy the location of the python.exe.
Step 2: Open the Julia interpreter/REPL in your IDE (I used Juno) and use the following commands to add PyCall.

julia>>using Pkg
julia>>Pkg.add("PyCall")

Step 3: Once Julia is done updating its registries, update the local python environment that has the Cantera installation using the following commands:

julia>>using PyCall
julia>>ENV["PYTHON"] = "location of the python.exe"

(The location should look something like C:\Users\hi\AppData\Local\Programs\Python\Python37)
Step 4: Rebuild PyCall using:

julia>>using Pkg
julia>>Pkg.build("PyCall")

Step 5: STOP Julia and restart.
Step 6: Test run Cantera in the Julia REPL using the following commands


julia>>using PyCall
julia>>pyimport("cantera")
PyObject <cantera.composite.Solution object at 0x000000004581D908>
julia>>gas1=cantera.Solution("gri30.xml")
gri30:

       temperature             300  K
          pressure          101325  Pa
           density       0.0818891  kg/m^3
  mean mol. weight         2.01588  amu

                          1 kg            1 kmol
                       -----------      ------------
          enthalpy           26470        5.336e+04     J
   internal energy     -1.2109e+06       -2.441e+06     J
           entropy           64914        1.309e+05     J/K
    Gibbs function     -1.9448e+07        -3.92e+07     J
 heat capacity c_p           14312        2.885e+04     J/K
 heat capacity c_v           10187        2.054e+04     J/K

                           X                 Y          Chem. Pot. / RT
                     -------------     ------------     ------------
                H2              1                1         -15.7173
     [  +52 minor]              0                0

NOTE: Pls note that julia uses double quotes instead of single quotes inside the Solution() function. The python version works with single quotes.
Julia throws the following error if single quotes are used.
ERROR: syntax: character literal contains multiple characters

2 Likes