From 7e71645efb29f0510586a86e15d2d79d590a833c Mon Sep 17 00:00:00 2001 From: imitrichev Date: Fri, 5 Feb 2016 00:06:05 +0400 Subject: [PATCH] [CTI/CTML] Add 'nonreactant_orders' option to allow non-reactant orders The flag 'allow_nonreactant_orders' in class Reaction is set to 'true' when using this option in cti/ctml. Resolves #317 Resolves #321 --- doc/sphinx/cti/reactions.rst | 9 +++++++++ interfaces/cython/cantera/ctml_writer.py | 13 +++++++++---- src/kinetics/Reaction.cpp | 3 +++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/doc/sphinx/cti/reactions.rst b/doc/sphinx/cti/reactions.rst index bb9760aee..c78048087 100644 --- a/doc/sphinx/cti/reactions.rst +++ b/doc/sphinx/cti/reactions.rst @@ -483,6 +483,8 @@ This reaction could be defined as:: Special care is required in this case since the units of the pre-exponential factor depend on the sum of the reaction orders, which may not be an integer. +Note that you can change reaction orders only for irreversible reactions. + Normally, reaction orders are required to be positive. However, in some cases negative reaction orders are found to be better fits for experimental data. In these cases, the default behavior may be overridden by adding @@ -491,6 +493,13 @@ these cases, the default behavior may be overridden by adding reaction("C8H18 + 12.5 O2 => 8 CO2 + 9 H2O", [4.6e11, 0.0, 30.0], order="C8H18:-0.25 O2:1.75", options=['negative_orders']) +Some global reactions could have reactions orders for non-reactant species. One +should add ``nonreactant_orders`` to the reaction options to use this feature:: + + reaction("C8H18 + 12.5 O2 => 8 CO2 + 9 H2O", [4.6e11, 0.0, 30.0], + order="C8H18:-0.25 CO:0.15", + options=['negative_orders', 'nonreactant_orders']) + .. rubric:: References diff --git a/interfaces/cython/cantera/ctml_writer.py b/interfaces/cython/cantera/ctml_writer.py index 28013374a..441ef33de 100644 --- a/interfaces/cython/cantera/ctml_writer.py +++ b/interfaces/cython/cantera/ctml_writer.py @@ -1110,7 +1110,8 @@ class reaction(object): e.g. ``"CH4:0.25 O2:1.5"``. :param options: Processing options, as described in :ref:`sec-reaction-options`. May be one or more (as a list) of the - following: 'skip', 'duplicate', 'negative_A', 'negative_orders'. + following: 'skip', 'duplicate', 'negative_A', 'negative_orders', + 'nonreactant_orders'. """ self._id = id self._e = equation @@ -1137,10 +1138,12 @@ class reaction(object): if self._order: order = getPairs(self._order) for o in order.keys(): - if o in self._rxnorder: - self._rxnorder[o] = order[o] + if (o not in self._rxnorder and + 'nonreactant_orders' not in self._options): + raise CTI_Error("order specified for non-reactant: " + o + + " and no 'nonreactant_orders' option given") else: - raise CTI_Error("order specified for non-reactant: "+o) + self._rxnorder[o] = order[o] self._kf = kf self._igspecies = [] @@ -1211,6 +1214,8 @@ class reaction(object): r['negative_A'] = 'yes' if 'negative_orders' in self._options: r['negative_orders'] = 'yes' + if 'nonreactant_orders' in self._options: + r['nonreactant_orders'] = 'yes' ee = self._e.replace('<','[').replace('>',']') r.addChild('equation',ee) diff --git a/src/kinetics/Reaction.cpp b/src/kinetics/Reaction.cpp index 44467502b..98a79882a 100644 --- a/src/kinetics/Reaction.cpp +++ b/src/kinetics/Reaction.cpp @@ -360,6 +360,9 @@ void setupElementaryReaction(ElementaryReaction& R, const XML_Node& rxn_node) if (rxn_node["negative_orders"] == "yes") { R.allow_negative_orders = true; } + if (rxn_node["nonreactant_orders"] == "yes") { + R.allow_nonreactant_orders = true; + } setupReaction(R, rxn_node); }