Skip to content

Commit 9ab4354

Browse files
committed
Use PythonCall syntax in module
1 parent 5f572c8 commit 9ab4354

File tree

1 file changed

+76
-80
lines changed

1 file changed

+76
-80
lines changed

src/ReactionMechanismSimulator.jl

Lines changed: 76 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,79 @@
1-
import Logging
2-
Logging.disable_logging(Logging.Warn)
3-
41
module ReactionMechanismSimulator
5-
using PyCall
6-
push!(PyVector(pyimport("sys")["path"]), "")
7-
const Chem = PyNULL()
8-
const Desc = PyNULL()
9-
const molecule = PyNULL()
10-
const fragment = PyNULL()
11-
const pydot = PyNULL()
12-
const chemkin =PyNULL()
13-
const species = PyNULL()
14-
const reaction = PyNULL()
15-
const nasa = PyNULL()
16-
const wilhoit = PyNULL()
17-
const arrhenius = PyNULL()
18-
const falloff = PyNULL()
19-
const chebyshev = PyNULL()
20-
const solvation = PyNULL()
21-
const os = PyNULL()
22-
function __init__()
23-
copy!(Chem,pyimport_conda("rdkit.Chem","rdkit","rmg"))
24-
copy!(Desc,pyimport_conda("rdkit.Chem.Descriptors","rdkit","rmg"))
25-
try
26-
copy!(molecule,pyimport("rmgpy.molecule"))
27-
copy!(chemkin,pyimport("rmgpy.chemkin"))
28-
copy!(species,pyimport("rmgpy.species"))
29-
copy!(reaction,pyimport("rmgpy.reaction"))
30-
copy!(nasa,pyimport("rmgpy.thermo.nasa"))
31-
copy!(wilhoit,pyimport("rmgpy.thermo.wilhoit"))
32-
copy!(arrhenius,pyimport("rmgpy.kinetics.arrhenius"))
33-
copy!(falloff,pyimport("rmgpy.kinetics.falloff"))
34-
copy!(chebyshev,pyimport("rmgpy.kinetics.chebyshev"))
35-
copy!(solvation,pyimport("rmgpy.data.solvation"))
36-
copy!(fragment,pyimport("rmgpy.molecule.fragment"))
37-
catch e
38-
copy!(molecule,pyimport_conda("molecule.molecule","rmgmolecule","hwpang"))
39-
copy!(chemkin,pyimport_conda("molecule.chemkin","rmgmolecule","hwpang"))
40-
copy!(species,pyimport_conda("molecule.species","rmgmolecule","hwpang"))
41-
copy!(reaction,pyimport_conda("molecule.reaction","rmgmolecule","hwpang"))
42-
copy!(nasa,pyimport_conda("molecule.thermo.nasa","rmgmolecule","hwpang"))
43-
copy!(wilhoit,pyimport_conda("molecule.thermo.wilhoit","rmgmolecule","hwpang"))
44-
copy!(arrhenius,pyimport_conda("molecule.kinetics.arrhenius","rmgmolecule","hwpang"))
45-
copy!(falloff,pyimport_conda("molecule.kinetics.falloff","rmgmolecule","hwpang"))
46-
copy!(chebyshev,pyimport_conda("molecule.kinetics.chebyshev","rmgmolecule","hwpang"))
47-
copy!(solvation,pyimport_conda("molecule.data.solvation","rmgmolecule","hwpang"))
48-
copy!(fragment,pyimport_conda("molecule.molecule.fragment","rmgmolecule","hwpang"))
49-
end
50-
copy!(pydot,pyimport_conda("pydot","pydot"))
51-
copy!(os,pyimport_conda("os","os"))
2+
using PythonCall
3+
using CondaPkg
4+
packages = keys(CondaPkg.current_packages())
5+
const Chem = PythonCall.pynew()
6+
const Desc = PythonCall.pynew()
7+
const molecule = PythonCall.pynew()
8+
const chemkin = PythonCall.pynew()
9+
const species = PythonCall.pynew()
10+
const reaction = PythonCall.pynew()
11+
const nasa = PythonCall.pynew()
12+
const wilhoit = PythonCall.pynew()
13+
const arrhenius = PythonCall.pynew()
14+
const falloff = PythonCall.pynew()
15+
const chebyshev = PythonCall.pynew()
16+
const solvation = PythonCall.pynew()
17+
const fragment = PythonCall.pynew()
18+
const pydot = PythonCall.pynew()
19+
function __init__()
20+
PythonCall.pycopy!(Chem, pyimport("rdkit.Chem"))
21+
PythonCall.pycopy!(Desc, pyimport("rdkit.Chem.Descriptors"))
22+
try
23+
PythonCall.pycopy!(molecule, pyimport("rmgpy.molecule"))
24+
PythonCall.pycopy!(chemkin, pyimport("rmgpy.chemkin"))
25+
PythonCall.pycopy!(species, pyimport("rmgpy.species"))
26+
PythonCall.pycopy!(reaction, pyimport("rmgpy.reaction"))
27+
PythonCall.pycopy!(nasa, pyimport("rmgpy.thermo.nasa"))
28+
PythonCall.pycopy!(wilhoit, pyimport("rmgpy.thermo.wilhoit"))
29+
PythonCall.pycopy!(arrhenius, pyimport("rmgpy.kinetics.arrhenius"))
30+
PythonCall.pycopy!(falloff, pyimport("rmgpy.kinetics.falloff"))
31+
PythonCall.pycopy!(chebyshev, pyimport("rmgpy.kinetics.chebyshev"))
32+
PythonCall.pycopy!(solvation, pyimport("rmgpy.data.solvation"))
33+
PythonCall.pycopy!(fragment, pyimport("rmgpy.molecule.fragment"))
34+
catch e
35+
PythonCall.pycopy!(molecule, pyimport("molecule.molecule"))
36+
PythonCall.pycopy!(chemkin, pyimport("molecule.chemkin"))
37+
PythonCall.pycopy!(species, pyimport("molecule.species"))
38+
PythonCall.pycopy!(reaction, pyimport("molecule.reaction"))
39+
PythonCall.pycopy!(nasa, pyimport("molecule.thermo.nasa"))
40+
PythonCall.pycopy!(wilhoit, pyimport("molecule.thermo.wilhoit"))
41+
PythonCall.pycopy!(arrhenius, pyimport("molecule.kinetics.arrhenius"))
42+
PythonCall.pycopy!(falloff, pyimport("molecule.kinetics.falloff"))
43+
PythonCall.pycopy!(chebyshev, pyimport("molecule.kinetics.chebyshev"))
44+
PythonCall.pycopy!(solvation, pyimport("molecule.data.solvation"))
45+
PythonCall.pycopy!(fragment, pyimport("molecule.molecule.fragment"))
5246
end
53-
include("Constants.jl")
54-
include("Tools.jl")
55-
include("Calculators/RateUncertainty.jl")
56-
include("Calculators/ThermoUncertainty.jl")
57-
include("Calculators/Thermo.jl")
58-
include("Calculators/Diffusion.jl")
59-
include("Calculators/Rate.jl")
60-
include("Calculators/Viscosity.jl")
61-
include("Calculators/Thermovec.jl")
62-
include("Calculators/Ratevec.jl")
63-
include("Calculators/kLAkH.jl")
64-
include("Species.jl")
65-
include("Solvent.jl")
66-
include("Reaction.jl")
67-
include("Phase.jl")
68-
include("PhaseState.jl")
69-
include("Interface.jl")
70-
include("Domain.jl")
71-
include("yml.jl")
72-
include("Parse.jl")
73-
include("ModelReduction.jl")
74-
include("Reactor.jl")
75-
include("ThreadedSensitivities.jl")
76-
include("Simulation.jl")
77-
include("TransitorySensitivities.jl")
78-
include("AutomaticMechanismAnalysis.jl")
79-
include("EdgeAnalysis.jl")
80-
include("Debugging.jl")
81-
include("Plotting.jl")
82-
include("fluxdiagrams.jl")
47+
PythonCall.pycopy!(pydot, pyimport("pydot"))
48+
end
49+
include("Constants.jl")
50+
include("Tools.jl")
51+
include("Calculators/RateUncertainty.jl")
52+
include("Calculators/ThermoUncertainty.jl")
53+
include("Calculators/Thermo.jl")
54+
include("Calculators/Diffusion.jl")
55+
include("Calculators/Rate.jl")
56+
include("Calculators/Viscosity.jl")
57+
include("Calculators/Thermovec.jl")
58+
include("Calculators/Ratevec.jl")
59+
include("Calculators/kLAkH.jl")
60+
include("Species.jl")
61+
include("Solvent.jl")
62+
include("Reaction.jl")
63+
include("Phase.jl")
64+
include("PhaseState.jl")
65+
include("Interface.jl")
66+
include("Domain.jl")
67+
include("yml.jl")
68+
include("Parse.jl")
69+
include("ModelReduction.jl")
70+
include("Reactor.jl")
71+
include("ThreadedSensitivities.jl")
72+
include("Simulation.jl")
73+
include("TransitorySensitivities.jl")
74+
include("AutomaticMechanismAnalysis.jl")
75+
include("EdgeAnalysis.jl")
76+
include("Debugging.jl")
77+
include("Plotting.jl")
78+
include("fluxdiagrams.jl")
8379
end

0 commit comments

Comments
 (0)