Hello all,
I finally found a way of running Cantera in Julia using PyCall. For the benefit of new users who had the same question, I am posting what I did.
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
On Sunday, 13 December 2020 at 01:20:14 UTC+5:30 R Surya Narayan wrote:
Hello everyone, I am trying to implement a chemically coupled method of characteristics application for designing a rocket nozzle, and I feel Cantera has all I need in terms of chemistry and kinetics. Any suggestions on how I can invoke Cantera via Julia will be helpful as I have written the bulk of my code for the main program in Julia. I am using the Juno editor in atom IDE. After going through the google groups I figured there's a way using PyCall in Julia but users have reported it to be unstable ( I'd want to try it out nonetheless and am looking for guidance)
Thanks
Surya