From b6ac3ce9954893862914e1afdfd4370618bed2bd Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Mon, 27 Apr 2015 16:08:01 -0400 Subject: [PATCH] [CTI] Allow CTI files containing only reaction definitions The reactions in these files can be referenced by other CTI/XML files, or used directly to create Reaction objects. The absence of a phase definition requires that either (a) all reactions are in bulk phases, or (b) the rate constants are given in kmol, meter, second units since it is impossible to determine the dimensionality of the concentration for each species. --- interfaces/cython/cantera/ctml_writer.py | 36 ++++++++++++++---------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/interfaces/cython/cantera/ctml_writer.py b/interfaces/cython/cantera/ctml_writer.py index 3b618b28c..c23c2f6b1 100644 --- a/interfaces/cython/cantera/ctml_writer.py +++ b/interfaces/cython/cantera/ctml_writer.py @@ -1188,21 +1188,27 @@ class reaction(object): nm = -999 nl = -999 - mindim = 4 - for ph in _phases: - if ph.has_species(s): - nm, nl = ph.conc_dim() - if ph.is_ideal_gas(): - self._igspecies.append(s) - if not ph in rxnph: - rxnph.append(ph) - self._dims[ph._dim] += 1 - if ph._dim < mindim: - self._rxnphase = ph - mindim = ph._dim - break - if nm == -999: - raise CTI_Error("species "+s+" not found") + if _phases: + mindim = 4 + for ph in _phases: + if ph.has_species(s): + nm, nl = ph.conc_dim() + if ph.is_ideal_gas(): + self._igspecies.append(s) + if not ph in rxnph: + rxnph.append(ph) + self._dims[ph._dim] += 1 + if ph._dim < mindim: + self._rxnphase = ph + mindim = ph._dim + break + if nm == -999: + raise CTI_Error("species "+s+" not found") + else: + # If no phases are defined, assume all reactants are in bulk + # phases + nm = 1 + nl = -3 self.mdim += nm*ns self.ldim += nl*ns