11function convertchemkin2yml (chemkinpath;spcdictpath= " " ,output= " chem.rms" )
22 if spcdictpath != " "
3- spcs,rxns = chemkin[ : loadChemkinFile] (chemkinpath,dictionaryPath= spcdictpath)
3+ spcs,rxns = chemkin. loadChemkinFile (chemkinpath,dictionaryPath= spcdictpath)
44 else
5- spcs,rxns = chemkin[ : loadChemkinFile] (chemkinpath)
5+ spcs,rxns = chemkin. loadChemkinFile (chemkinpath)
66 end
77 writeyml (spcs,rxns;path= output)
88end
99
1010function writeyml (spcs,rxns;path= " chem.rms" )
1111 D = getmechdict (spcs,rxns)
12- yaml[ : dump] (D,stream= pybuiltin (" file" )(path," w" ))
12+ yaml. dump (D,stream= pybuiltin (" file" )(path," w" ))
1313end
1414
1515function getmechdict (spcs,rxns)
@@ -24,103 +24,107 @@ function getmechdict(spcs,rxns)
2424end
2525
2626function getradicals (obj:: T ) where {T}
27- sm = obj[ : molecule] [1 ][ : toSMILES] ()
27+ sm = obj. molecule[1 ]. toSMILES ()
2828 if sm == " [O][O]"
2929 return 0
3030 else
31- return obj[ : molecule] [1 ][ : multiplicity] - 1
31+ return obj. molecule[1 ]. multiplicity- 1
3232 end
3333end
3434
3535function obj2dict (obj,spcs;label= " solvent" )
3636 D = Dict ([])
37- if pybuiltin (" isinstance" )(obj,species[ : Species] )
38- D[" name" ] = obj[ : label]
37+ if pybuiltin (" isinstance" )(obj,species. Species)
38+ D[" name" ] = obj. label
3939 D[" type" ] = " Species"
40- D[" smiles" ] = obj[:molecule ][1 ][:toSMILES ]()
41- D[" thermo" ] = obj2dict (obj[:thermo ],spcs)
40+ if length (obj. molecule) == 0
41+ println (obj)
42+ println (obj. label)
43+ end
44+ D[" smiles" ] = obj. molecule[1 ]. toSMILES ()
45+ D[" thermo" ] = obj2dict (obj. thermo,spcs)
4246 if D[" smiles" ] != " [O][O]"
43- D[" radicalelectrons" ] = obj[ : molecule] [1 ][ : multiplicity] - 1
47+ D[" radicalelectrons" ] = obj. molecule[1 ]. multiplicity- 1
4448 else
4549 D[" radicalelectrons" ] = 0
4650 end
47- elseif pybuiltin (" isinstance" )(obj,nasa[ : NASA] )
48- D[" polys" ] = [obj2dict (k,spcs) for k in obj[ : polynomials] ]
51+ elseif pybuiltin (" isinstance" )(obj,nasa. NASA)
52+ D[" polys" ] = [obj2dict (k,spcs) for k in obj. polynomials]
4953 D[" type" ] = " NASA"
50- elseif pybuiltin (" isinstance" )(obj,nasa[ : NASAPolynomial] )
54+ elseif pybuiltin (" isinstance" )(obj,nasa. NASAPolynomial)
5155 D[" type" ] = " NASApolynomial"
52- D[" coefs" ] = PyVector (obj[ : coeffs] )
53- D[" Tmax" ] = obj[ : Tmax][ : value_si]
54- D[" Tmin" ] = obj[ : Tmin][ : value_si]
55- elseif pybuiltin (" isinstance" )(obj,reaction[ : Reaction] )
56- D[" reactants" ] = [x[ : label] for x in obj[ : reactants] ]
57- D[" products" ] = [x[ : label] for x in obj[ : products] ]
58- D[" kinetics" ] = obj2dict (obj[ : kinetics] ,spcs)
56+ D[" coefs" ] = PyVector (obj. coeffs)
57+ D[" Tmax" ] = obj. Tmax. value_si
58+ D[" Tmin" ] = obj. Tmin. value_si
59+ elseif pybuiltin (" isinstance" )(obj,reaction. Reaction)
60+ D[" reactants" ] = [x. label for x in obj. reactants]
61+ D[" products" ] = [x. label for x in obj. products]
62+ D[" kinetics" ] = obj2dict (obj. kinetics,spcs)
5963 D[" type" ] = " ElementaryReaction"
60- D[" radicalchange" ] = sum ([getradicals (x) for x in obj[ : products ]] )- sum ([getradicals (x) for x in obj[ : reactants] ])
61- elseif pybuiltin (" isinstance" )(obj,arrhenius[ : Arrhenius] )
64+ D[" radicalchange" ] = sum ([getradicals (x) for x in obj. products])- sum ([getradicals (x) for x in obj. reactants])
65+ elseif pybuiltin (" isinstance" )(obj,arrhenius. Arrhenius)
6266 D[" type" ] = " Arrhenius"
63- D[" A" ] = obj[ :A ][ : value_si]
64- D[" Ea" ] = obj[ :Ea ][ : value_si]
65- D[" n" ] = obj[ :n ][ : value_si]
66- elseif pybuiltin (" isinstance" )(obj,arrhenius[ : PDepArrhenius] )
67+ D[" A" ] = obj. A . value_si
68+ D[" Ea" ] = obj. Ea . value_si
69+ D[" n" ] = obj. n . value_si
70+ elseif pybuiltin (" isinstance" )(obj,arrhenius. PDepArrhenius)
6771 D[" type" ] = " PdepArrhenius"
68- D[" Ps" ] = PyVector (obj[ : pressures][ : value_si] )
69- D[" arrs" ] = [obj2dict (x,spcs) for x in obj[ : arrhenius] ]
70- elseif pybuiltin (" isinstance" )(obj,arrhenius[ : MultiArrhenius] )
72+ D[" Ps" ] = PyVector (obj. pressures. value_si)
73+ D[" arrs" ] = [obj2dict (x,spcs) for x in obj. arrhenius]
74+ elseif pybuiltin (" isinstance" )(obj,arrhenius. MultiArrhenius)
7175 D[" type" ] = " MultiArrhenius"
72- D[" arrs" ] = [obj2dict (x,spcs) for x in obj[ : arrhenius] ]
73- elseif pybuiltin (" isinstance" )(obj,arrhenius[ : MultiPDepArrhenius] )
76+ D[" arrs" ] = [obj2dict (x,spcs) for x in obj. arrhenius]
77+ elseif pybuiltin (" isinstance" )(obj,arrhenius. MultiPDepArrhenius)
7478 D[" type" ] = " MultiPdepArrhenius"
75- D[" parrs" ] = [obj2dict (x,spcs) for x in obj[ : arrhenius] ]
76- elseif pybuiltin (" isinstance" )(obj,falloff[ : ThirdBody] )
79+ D[" parrs" ] = [obj2dict (x,spcs) for x in obj. arrhenius]
80+ elseif pybuiltin (" isinstance" )(obj,falloff. ThirdBody)
7781 D[" type" ] = " ThirdBody"
78- D[" arr" ] = obj2dict (obj[ : arrheniusLow] ,spcs)
79- D[" efficiencies" ] = Dict ([spcs[i][ : label] => float (val) for (i,val) in enumerate (obj[ : getEffectiveColliderEfficiencies] (spcs)) if val != 1 ])
80- elseif pybuiltin (" isinstance" )(obj,falloff[ : Lindemann] )
82+ D[" arr" ] = obj2dict (obj. arrheniusLow,spcs)
83+ D[" efficiencies" ] = Dict ([spcs[i]. label=> float (val) for (i,val) in enumerate (obj. getEffectiveColliderEfficiencies (spcs)) if val != 1 ])
84+ elseif pybuiltin (" isinstance" )(obj,falloff. Lindemann)
8185 D[" type" ] = " Lindemann"
82- D[" arrhigh" ] = obj2dict (obj[ : arrheniusHigh] ,spcs)
83- D[" arrlow" ] = obj2dict (obj[ : arrheniusLow] ,spcs)
84- D[" efficiencies" ] = Dict ([spcs[i][ : label] => float (val) for (i,val) in enumerate (obj[ : getEffectiveColliderEfficiencies] (spcs)) if val != 1 ])
85- elseif pybuiltin (" isinstance" )(obj,falloff[ : Troe] )
86+ D[" arrhigh" ] = obj2dict (obj. arrheniusHigh,spcs)
87+ D[" arrlow" ] = obj2dict (obj. arrheniusLow,spcs)
88+ D[" efficiencies" ] = Dict ([spcs[i]. label=> float (val) for (i,val) in enumerate (obj. getEffectiveColliderEfficiencies (spcs)) if val != 1 ])
89+ elseif pybuiltin (" isinstance" )(obj,falloff. Troe)
8690 D[" type" ] = " Troe"
87- D[" arrhigh" ] = obj2dict (obj[ : arrheniusHigh] ,spcs)
88- D[" arrlow" ] = obj2dict (obj[ : arrheniusLow] ,spcs)
89- D[" efficiencies" ] = Dict ([spcs[i][ : label] => float (val) for (i,val) in enumerate (obj[ : getEffectiveColliderEfficiencies] (spcs)) if val != 1 ])
90- D[" a" ] = obj[ : alpha]
91- D[" T1" ] = obj[ :T1 ][ : value_si]
92- if ! isa (obj[ :T2 ] ,Nothing)
93- D[" T2" ] = obj[ :T2 ][ : value_si]
91+ D[" arrhigh" ] = obj2dict (obj. arrheniusHigh,spcs)
92+ D[" arrlow" ] = obj2dict (obj. arrheniusLow,spcs)
93+ D[" efficiencies" ] = Dict ([spcs[i]. label=> float (val) for (i,val) in enumerate (obj. getEffectiveColliderEfficiencies (spcs)) if val != 1 ])
94+ D[" a" ] = obj. alpha
95+ D[" T1" ] = obj. T1 . value_si
96+ if ! isa (obj. T2 ,Nothing)
97+ D[" T2" ] = obj. T2 . value_si
9498 else
9599 D[" T2" ] = 0.0
96100 end
97- D[" T3" ] = obj[ :T3 ][ : value_si]
98- elseif pybuiltin (" isinstance" )(obj,chebyshev[ : Chebyshev] )
101+ D[" T3" ] = obj. T3 . value_si
102+ elseif pybuiltin (" isinstance" )(obj,chebyshev. Chebyshev)
99103 D[" type" ] = " Chebyshev"
100- n,m = size (obj[ : coeffs][ : value_si] )
101- D[" coefs" ] = PyVector ([PyVector (obj[ : coeffs][ : value_si] [i,:]) for i in 1 : n])
102- D[" Tmin" ] = obj[ : Tmin][ : value_si]
103- D[" Tmax" ] = obj[ : Tmax][ : value_si]
104- D[" Pmin" ] = obj[ : Pmin][ : value_si]
105- D[" Pmax" ] = obj[ : Pmax][ : value_si]
106- elseif pybuiltin (" isinstance" )(obj,wilhoit[ : Wilhoit] )
104+ n,m = size (obj. coeffs. value_si)
105+ D[" coefs" ] = PyVector ([PyVector (obj. coeffs. value_si[i,:]) for i in 1 : n])
106+ D[" Tmin" ] = obj. Tmin. value_si
107+ D[" Tmax" ] = obj. Tmax. value_si
108+ D[" Pmin" ] = obj. Pmin. value_si
109+ D[" Pmax" ] = obj. Pmax. value_si
110+ elseif pybuiltin (" isinstance" )(obj,wilhoit. Wilhoit)
107111 D[" type" ] = " Wilhoit"
108- D[" coefs" ] = [obj[ :a0 ] ,obj[ :a1 ] ,obj[ :a2 ] ,obj[ :a3 ] ]
109- D[" Cp0" ] = obj[ : Cp0][ : value_si]
110- D[" Cpinf" ] = obj[ : CpInf][ : value_si]
111- D[" H0" ] = obj[ :H0 ][ : value_si]
112- D[" S0" ] = obj[ :S0 ][ : value_si]
113- D[" B" ] = obj[ :B ][ : value_si]
114- elseif pybuiltin (" isinstance" )(obj,solvation[ : SolventData] )
112+ D[" coefs" ] = [obj. a0 ,obj. a1 ,obj. a2 ,obj. a3 ]
113+ D[" Cp0" ] = obj. Cp0. value_si
114+ D[" Cpinf" ] = obj. CpInf. value_si
115+ D[" H0" ] = obj. H0 . value_si
116+ D[" S0" ] = obj. S0 . value_si
117+ D[" B" ] = obj. B . value_si
118+ elseif pybuiltin (" isinstance" )(obj,solvation. SolventData)
115119 D[" type" ] = " Solvent"
116120 D[" name" ] = label
117121 dsub = dict ()
118122 dsub[" type" ] = " RiedelViscosity"
119- dsub[" A" ] = obj[ :A ][ : value_si]
120- dsub[" B" ] = obj[ :B ][ : value_si]
121- dsub[" C" ] = obj[ :C ][ : value_si]
122- dsub[" D" ] = obj[ :D ][ : value_si]
123- dsub[" E" ] = obj[ :E ][ : value_si]
123+ dsub[" A" ] = obj. A . value_si
124+ dsub[" B" ] = obj. B . value_si
125+ dsub[" C" ] = obj. C . value_si
126+ dsub[" D" ] = obj. D . value_si
127+ dsub[" E" ] = obj. E . value_si
124128 D[" mu" ] = dsub
125129 elseif pybuiltin (" is" )(obj,pybuiltin (" None" ))
126130 return pybuiltin (" None" )
0 commit comments