ReactionMechanismGenerator / ReactionMechanismSimulator.jl

The amazing Reaction Mechanism Simulator for simulating large chemical kinetic mechanisms
https://reactionmechanismgenerator.github.io/ReactionMechanismSimulator.jl
MIT License
75 stars 32 forks source link

Notes on the Installation and Update the Installation #36

Open jiweiqi opened 4 years ago

jiweiqi commented 4 years ago

I don't have access to editing the wiki page. So that I will open an issue page to note down my practice in installing RMS. I would recommend developers install from Github master branch since there is often a need to read the latest source code.

config conda environment for rmg

create and activate conda env

conda create -n conda_jl conda activate conda_jl

install dependence rmg

noting that rmg is only compatible with python version < 3.8. Here we take python=3.7.7 as an example.

conda install -c defaults -c rmg -c rdkit -c cantera -c pytorch -c conda-forge python=3.7.7 rmg

Install the version in the master branch

using Pkg ENV["PYTHON"] = "/home/weiqi/anaconda3/envs/conda_jl/bin/python" Pkg.develop(PackageSpec(url="https://github.com/ReactionMechanismGenerator/ReactionMechanismSimulator.jl"))

Note

I am not sure whether we have to setup ENV["PYTHON"] = "/home/weiqi/anaconda3/envs/conda_jl/bin/python". To me, I don't want to install rmg with my base env since rmg depends on specific version of PyTorch and TensorFlow.

jiweiqi commented 4 years ago

Below are quick test scripts to verify the installation, adapted from example.


using DifferentialEquations
using ReactionMechanismSimulator

file_path = "/home/weiqi/github/ReactionMechanismSimulator.jl/src/testing/superminimal.rms"; # Change it to your personal path
#load mechanism dictionary
phaseDict = readinput(file_path); 
#mechanism dictionaries index:  phaseDict[phasename]["Species" or "Reactions"]
spcs = phaseDict["phase"]["Species"]; 
rxns = phaseDict["phase"]["Reactions"];

#######################    INPUT     #######################
V0 = 8.314 * 1000 / 1e5;  # [m^3] # Comparison with chemkin
P0 = 1.0e+5; #[Pa]
# T0 = 1000; #[K]
H2 = 0.67;  #[mol]
O2 = 0.33;  #[mol]
N0 = H2 + O2; 
############################################################

# Define the phase (how species thermodynamic and kinetic properties calculated)
ig = IdealGas(spcs,rxns,name="phase");
# Define initial condition of the reactor
initialconds = Dict(["V"=>V0,"P"=>P0, "H2"=>H2,"O2"=>O2]); 
# Define the domain (encodes how system thermodynamic properties calculated)
domain,y0 = ConstantPDomain(phase=ig,initialconds=initialconds);

#######################    INPUT     #######################
t_final = 2.1; #[s]
solver = DifferentialEquations.CVODE_BDF();
abstol = 1e-20;
reltol = 1e-12;
############################################################

react = Reactor(domain,y0,(0.0,t_final)); #Create the reactor object

#solve the ode associated with the reactor
sol = solve(react.ode,solver, abstol=reltol,reltol=reltol);
bsol = Simulation(sol,domain);

sol(2.0000)[domain.indexes[end]]
jiweiqi commented 4 years ago

@mjohnson541 Any suggestion?

mjohnson541 commented 4 years ago

So I've been working on this. v0.2.0 and v0.2.1 were able to install automatically when tested on the registry. But v0.3.0 is having trouble because PyCall is automatically installing 3.8 which isn't compatible with some of the dependencies....once this is resolved it should be easy to install from the Julia package manager. I also now have a conda package for pyrms on the rmg conda channel, once installed you need to run pyrms.install() to install the julia packages. It can be checkout for development or a local repo can be installed in Pkg afterwards.