@@ -173,7 +173,6 @@ def writeReaction(f, rxn):
173173 f .write ('reaction(\n ' )
174174 f .write (' reactants=[{0}],\n ' .format (', ' .join ([('"{0}"' .format (spec )) for spec in rxn .reactants ])))
175175 f .write (' products=[{0}],\n ' .format (', ' .join ([('"{0}"' .format (spec )) for spec in rxn .products ])))
176- f .write (' reversible={0!r},\n ' .format (rxn .reversible ))
177176 if rxn .kinetics is not None :
178177 f .write (' kinetics={0!r},\n ' .format (rxn .kinetics ))
179178 if rxn .transitionState is not None :
@@ -205,7 +204,6 @@ def writePDepReaction(f, rxn):
205204 f .write ('pdepreaction(\n ' )
206205 f .write (' reactants=[{0}],\n ' .format (', ' .join ([('"{0}"' .format (spec )) for spec in rxn .reactants ])))
207206 f .write (' products=[{0}],\n ' .format (', ' .join ([('"{0}"' .format (spec )) for spec in rxn .products ])))
208- f .write (' reversible={0!r},\n ' .format (rxn .reversible ))
209207 if rxn .kinetics is not None :
210208 if isinstance (rxn .kinetics , Chebyshev ):
211209 f .write (' kinetics=Chebyshev(\n ' )
@@ -232,67 +230,10 @@ def writePDepReaction(f, rxn):
232230
233231################################################################################
234232
235- def writeOutput (path , network , Tlist , Plist , Elist , method , model ):
236- """
237- Write a MEASURE output file to `path` on disk. The parameters needed mirror
238- those returned by :meth:`readInput()`:
239-
240- * The :class:`Network` object `network` representing the unimolecular
241- reaction network
242-
243- * The list of temperatures `Tlist` in K to be used in the master equation
244- calculation
245-
246- * The list of pressures `Plist` in Pa to be used in the master equation
247- calculation
248-
249- * A tuple `Elist` containing the maximum energy grain size in J/mol and the
250- minimum number of energy grains to use in the master equation calculation;
251- whichever of these results in more energy grains
252-
253- * The approximate `method` to use to estimate the phenomenological rate
254- coefficients :math:`k(T,P)`
255-
256- * The interpolation `model` to fit the estimated :math:`k(T,P)` values to
257-
258- If successful, the file created on disk will contain all of the species
259- and net reaction data, including all phenomenological rate coefficients
260- :math:`k(T,P)`.
261- """
262-
263- logging .info ('Saving output to "{0}"...' .format (path ))
264-
265- f = open (os .path .relpath (path ), 'w' )
266-
267- f .write ('################################################################################\n ' )
268- f .write ('#\n ' )
269- f .write ('# MEASURE output file for {0}\n ' .format (network ))
270- f .write ('#\n ' )
271- f .write ('# Generated on {0}\n ' .format (time .asctime ()))
272- f .write ('#\n ' )
273- f .write ('################################################################################\n \n ' )
274-
275- # Write metadata
276- writeNetworkMetadata (f , network )
277-
278- # Write each species to file
279- writeNetworkSpecies (f , network )
280- f .write ('################################################################################\n \n ' )
281- # Write each configuration to file
282- writeNetworkConfigurations (f , network )
283- f .write ('################################################################################\n \n ' )
284-
285- # Write each net reaction to file
286- writeNetworkNetReactions (f , network )
287-
288- f .close ()
289-
290- ################################################################################
291-
292- def writeInput (path , network , Tlist , Plist , Elist , method , model ):
233+ def writeFile (path , network , Tlist , Plist , Elist , method , model , Tmin , Tmax , Pmin , Pmax ):
293234 """
294235 Write a MEASURE input file to `path` on disk. The parameters needed mirror
295- those returned by :meth:`readInput ()`:
236+ those returned by :meth:`readFile ()`:
296237
297238 * The :class:`Network` object `network` representing the unimolecular
298239 reaction network
@@ -320,7 +261,7 @@ def writeInput(path, network, Tlist, Plist, Elist, method, model):
320261
321262 f .write ('################################################################################\n ' )
322263 f .write ('#\n ' )
323- f .write ('# MEASURE input file for {0}\n ' .format (network ))
264+ f .write ('# MEASURE file for {0}\n ' .format (network ))
324265 f .write ('#\n ' )
325266 f .write ('# Generated on {0}\n ' .format (time .asctime ()))
326267 f .write ('#\n ' )
@@ -353,14 +294,26 @@ def writeInput(path, network, Tlist, Plist, Elist, method, model):
353294 f .write (' },\n ' )
354295 f .write (')\n \n ' )
355296
356- f .write ('temperatures(([{0}],"K"))\n ' .format (', ' .join ([('{0:g}' .format (T )) for T in Tlist ])))
357- f .write ('pressures(([{0}],"bar"))\n ' .format (', ' .join ([('{0:g}' .format (P / 1e5 )) for P in Plist ])))
358- dE , count = Elist
297+ if Tmin is not None and Tmax is not None :
298+ f .write ('temperatures(Tmin=({0},"K"), Tmax=({1},"K"), count={2})\n ' .format (Tmin , Tmax , len (Tlist )))
299+ else :
300+ f .write ('temperatures(([{0}],"K"))\n ' .format (', ' .join ([('{0:g}' .format (T )) for T in Tlist ])))
301+ if Pmin is not None and Pmax is not None :
302+ f .write ('pressures(Pmin=({0},"bar"), Pmax=({1},"bar"), count={2})\n ' .format (Pmin / 1e5 , Pmax / 1e5 , len (Plist )))
303+ else :
304+ f .write ('pressures(([{0}],"bar"))\n ' .format (', ' .join ([('{0:g}' .format (P / 1e5 )) for P in Plist ])))
305+ dE = Elist [1 ] - Elist [0 ]; count = len (Elist )
359306 f .write ('energies(dE=({0:g},"kJ/mol"), count={1:d})\n ' .format (dE / 1000.0 , count ))
360307 f .write ('method("{0}")\n ' .format (method ))
361308 if model [0 ].lower () == 'chebyshev' :
362309 f .write ('interpolationModel("chebyshev", {0:d}, {1:d})\n ' .format (model [1 ], model [2 ]))
363310 else :
364311 f .write ('interpolationModel("{0}")\n ' .format (model [0 ].lower ()))
365-
312+ f .write ('\n ' )
313+
314+ if len (network .netReactions ) > 0 :
315+ f .write ('################################################################################\n \n ' )
316+ # Write each net reaction to file
317+ writeNetworkNetReactions (f , network )
318+
366319 f .close ()
0 commit comments