Skip to content

Commit de5b297

Browse files
authored
Merge pull request #196 from ReactionMechanismGenerator/transitoryedge
Transitory Edge Analysis
2 parents 758b25b + 1c68aa4 commit de5b297

7 files changed

Lines changed: 303 additions & 224 deletions

File tree

.github/workflows/CI.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,15 @@ jobs:
2424
${{ runner.os }}-test-${{ env.cache-name }}-
2525
${{ runner.os }}-test-
2626
${{ runner.os }}-
27-
- uses: julia-actions/julia-buildpkg@v1
27+
- uses: conda-incubator/setup-miniconda@v2
28+
with:
29+
environment-file: environment.yml
30+
python-version: 3.7
31+
activate-environment: rms_env
2832
- name: Fix PyCall linking
2933
run: |
30-
julia -e 'ENV["PYTHON"]="/home/runner/.julia/conda/3/bin/python"; using Pkg; Pkg.add("PyCall"); Pkg.build("PyCall")'
34+
julia -e 'ENV["PYTHON"]=ENV["CONDA"] * "/envs/rms_env/bin/python"; using Pkg; Pkg.add("PyCall"); Pkg.build("PyCall")'
35+
- uses: julia-actions/julia-buildpkg@v1
3136
- name: Build
3237
run: |
3338
julia -e 'using Pkg; Pkg.add(PackageSpec(name="StochasticDiffEq",version="6.36.0")); Pkg.develop(PackageSpec(path="../ReactionMechanismSimulator.jl")); Pkg.build("ReactionMechanismSimulator");'

.github/workflows/documentation.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@ jobs:
1515
- uses: julia-actions/setup-julia@latest
1616
with:
1717
version: 1.6
18+
- uses: conda-incubator/setup-miniconda@v2
19+
with:
20+
environment-file: environment.yml
21+
python-version: 3.7
22+
activate-environment: rms_env
1823
- name: Install dependencies
1924
run: |
20-
wget https://repo.anaconda.com/miniconda/Miniconda2-latest-Linux-x86_64.sh -O miniconda.sh;
21-
bash miniconda.sh -b -p $HOME/miniconda
22-
export PATH=$HOME/miniconda/bin:$PATH
23-
conda create -n conda_jl --yes python=3.7 conda
24-
source activate conda_jl
25-
conda install -c rmg --yes rmg
26-
conda update --yes conda
25+
julia -e 'ENV["PYTHON"]=ENV["CONDA"] * "/envs/rms_env/bin/python"; using Pkg; Pkg.add("PyCall"); Pkg.build("PyCall")'
2726
julia --project=docs/ -e 'using Pkg; Pkg.add(PackageSpec(name="StochasticDiffEq",version="6.36.0")); Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate();'
2827
- name: Build and deploy
2928
env:

environment.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: rms_env
2+
channels:
3+
- defaults
4+
- rmg
5+
dependencies:
6+
- rdkit
7+
- rmg
8+
- pydot
9+
- yaml

src/EdgeAnalysis.jl

Lines changed: 267 additions & 202 deletions
Large diffs are not rendered by default.

src/Phase.jl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ function IdealGas(species,reactions; name="",diffusionlimited=false)
4444
echangevec = getfield.(rxns,:electronchange)
4545
if all(echangevec .== 0)
4646
electronchange = nothing
47-
else
47+
else
4848
electronchange = convert(echangevec,Array{Float64,1})
4949
end
5050
reversibility = getfield.(rxns,:reversible)
5151
return IdealGas(species=species,reactions=rxns,name=name,
52-
spcdict=Dict([sp.name=>i for (i,sp) in enumerate(species)]),stoichmatrix=M,Nrp=Nrp,rxnarray=rxnarray,veckinetics=vectuple,
53-
veckineticsinds=posinds, vecthermo=therm, otherreactions=otherrxns, electronchange=electronchange,
52+
spcdict=Dict([sp.name=>i for (i,sp) in enumerate(species)]),stoichmatrix=M,Nrp=Nrp,rxnarray=rxnarray,veckinetics=vectuple,
53+
veckineticsinds=posinds, vecthermo=therm, otherreactions=otherrxns, electronchange=electronchange,
5454
reversibility=reversibility,diffusionlimited=diffusionlimited,)
5555
end
5656
export IdealGas
@@ -84,7 +84,7 @@ function IdealDiluteSolution(species,reactions,solvent; name="",diffusionlimited
8484
echangevec = getfield.(rxns,:electronchange)
8585
if all(echangevec .== 0)
8686
electronchange = nothing
87-
else
87+
else
8888
electronchange = convert(echangevec,Array{Float64,1})
8989
end
9090
reversibility = getfield.(rxns,:reversible)
@@ -125,7 +125,7 @@ function IdealSurface(species,reactions,sitedensity;name="",diffusionlimited=fal
125125
echangevec = getfield.(rxns,:electronchange).*F
126126
if all(echangevec .== 0)
127127
electronchange = nothing
128-
else
128+
else
129129
electronchange = convert(typeof(Nrp),echangevec)
130130
end
131131
reversibility = getfield.(rxns,:reversible)
@@ -209,7 +209,7 @@ function getveckinetics(rxns)
209209
push!(fs,x)
210210
if posinds == Array{Int64,1}()
211211
push!(posinds,length(rinds))
212-
else
212+
else
213213
push!(posinds,length(rinds)+posinds[end])
214214
end
215215
end
@@ -277,7 +277,9 @@ function getreactionindices(spcs,rxns) where {Q<:AbstractPhase}
277277
end
278278
for (key,val) in rxn.kinetics.nameefficiencies
279279
ind = findfirst(isequal(key),names)
280-
rxn.kinetics.efficiencies[ind] = val
280+
if !(ind === nothing)
281+
rxn.kinetics.efficiencies[ind] = val
282+
end
281283
end
282284
end
283285
end

src/ReactionMechanismSimulator.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ module ReactionMechanismSimulator
1717
const yaml = PyNULL()
1818
const os = PyNULL()
1919
function __init__()
20-
copy!(Chem,pyimport_conda("rdkit.Chem","rdkit","rdkit"))
21-
copy!(Desc,pyimport_conda("rdkit.Chem.Descriptors","rdkit","rdkit"))
20+
copy!(Chem,pyimport_conda("rdkit.Chem","rdkit","rmg"))
21+
copy!(Desc,pyimport_conda("rdkit.Chem.Descriptors","rdkit","rmg"))
2222
copy!(molecule,pyimport_conda("rmgpy.molecule","rmg","rmg"))
2323
copy!(pydot,pyimport_conda("pydot","pydot"))
2424
copy!(chemkin,pyimport_conda("rmgpy.chemkin","rmg","rmg"))

src/TestEdgeAnalysis.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,10 @@ using Sundials
5252
coredomain,y0,corep = ConstantTPDomain(phase=coregas,initialconds=initialconds);
5353
react = Reactor(coredomain,y0,(0.0,1e6);p=corep);
5454
coreedgedomain,coreedgey0,coreedgep = ConstantTPDomain(phase=coreedgegas,initialconds=initialconds);
55-
55+
reactedge = Reactor(coreedgedomain,coreedgey0,(0.0,1e6);p=coreedgep);
5656
(terminated,resurrected,invalidobjects,unimolecularthreshold,bimolecularthreshold,
57-
trimolecularthreshold,maxedgespeciesrateratios) = selectobjects(react,coreedgedomain,[],coredomain,
58-
[],corep,coreedgep,0.03,0.03,false,true,5,0.005,1.0,1.0,true,termination,1.0e8)
59-
57+
trimolecularthreshold,maxedgespeciesrateratios) = selectobjects(react,reactedge,coreedgedomain,[],coredomain,
58+
[],corep,coreedgep,0.03,0.03,false,true,5,0.005,1.0,1.0,true,termination,1.0e8,Dict(),20)
6059
@test terminated == false
6160
@test invalidobjects[1].name == "[CH2]CCC"
6261
@test unimolecularthreshold[5] == true

0 commit comments

Comments
 (0)