# Calling chemical kinetics solvers like CHEMKIN or Cantera from Julia

**URL:** <https://discourse.julialang.org/t/calling-chemical-kinetics-solvers-like-chemkin-or-cantera-from-julia/50568>\
**Category:** Modelling & Simulations\
**Tags:** question, package, scientific-computing, sciml\
**Created:** [November 22, 2020, 5:28am UTC](https://discourse.julialang.org/t/calling-chemical-kinetics-solvers-like-chemkin-or-cantera-from-julia/50568 "2020-11-22T05:28:45Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![R\_Surya\_Narayan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/r_surya_narayan/32/7867_2.png) [@R\_Surya\_Narayan](https://discourse.julialang.org/u/R_Surya_Narayan)\
**Post date:** [December 13, 2020, 1:20pm UTC](https://discourse.julialang.org/t/calling-chemical-kinetics-solvers-like-chemkin-or-cantera-from-julia/50568/2 "2020-12-13T13:20:06Z")

</div>

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
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
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
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

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`

---

_[View the full topic](https://discourse.julialang.org/t/calling-chemical-kinetics-solvers-like-chemkin-or-cantera-from-julia/50568)._
