From ba9c9c768f92058aaca1c37de3c0b80a6e38143f Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Mon, 11 May 2015 16:35:46 -0400 Subject: [PATCH] [Kinetics] Use the name 'ThreeBodyReaction' consistently --- doc/sphinx/cython/kinetics.rst | 2 +- include/cantera/kinetics/GasKinetics.h | 4 ++-- include/cantera/kinetics/Reaction.h | 6 +++--- interfaces/cython/cantera/_cantera.pxd | 4 ++-- interfaces/cython/cantera/reaction.pyx | 10 +++++----- interfaces/cython/cantera/test/test_kinetics.py | 8 ++++---- src/kinetics/GasKinetics.cpp | 8 ++++---- src/kinetics/Kinetics.cpp | 4 ++-- src/kinetics/Reaction.cpp | 14 +++++++------- test/kinetics/kineticsFromScratch.cpp | 6 +++--- 10 files changed, 33 insertions(+), 33 deletions(-) diff --git a/doc/sphinx/cython/kinetics.rst b/doc/sphinx/cython/kinetics.rst index 46632c4f3..dcd8b76d5 100644 --- a/doc/sphinx/cython/kinetics.rst +++ b/doc/sphinx/cython/kinetics.rst @@ -17,7 +17,7 @@ rate expression, indepenent of a specific `Kinetics` object. .. autoclass:: ElementaryReaction(reactants='', products='') :no-undoc-members: -.. autoclass:: ThirdBodyReaction(reactants='', products='') +.. autoclass:: ThreeBodyReaction(reactants='', products='') :no-undoc-members: .. autoclass:: FalloffReaction(reactants='', products='') diff --git a/include/cantera/kinetics/GasKinetics.h b/include/cantera/kinetics/GasKinetics.h index 5951b0bed..271baafc9 100644 --- a/include/cantera/kinetics/GasKinetics.h +++ b/include/cantera/kinetics/GasKinetics.h @@ -113,12 +113,12 @@ protected: void addPlogReaction(ReactionData& r); void addChebyshevReaction(ReactionData& r); - void addThreeBodyReaction(ThirdBodyReaction& r); + void addThreeBodyReaction(ThreeBodyReaction& r); void addFalloffReaction(FalloffReaction& r); void addPlogReaction(PlogReaction& r); void addChebyshevReaction(ChebyshevReaction& r); - void modifyThreeBodyReaction(size_t i, ThirdBodyReaction& r); + void modifyThreeBodyReaction(size_t i, ThreeBodyReaction& r); void modifyFalloffReaction(size_t i, FalloffReaction& r); void modifyPlogReaction(size_t i, PlogReaction& r); void modifyChebyshevReaction(size_t i, ChebyshevReaction& r); diff --git a/include/cantera/kinetics/Reaction.h b/include/cantera/kinetics/Reaction.h index 17cea70dd..c61266d0a 100644 --- a/include/cantera/kinetics/Reaction.h +++ b/include/cantera/kinetics/Reaction.h @@ -107,11 +107,11 @@ public: //! A reaction with a non-reacting third body "M" that acts to add or remove //! energy from the reacting species -class ThirdBodyReaction : public ElementaryReaction +class ThreeBodyReaction : public ElementaryReaction { public: - ThirdBodyReaction(); - ThirdBodyReaction(const Composition& reactants, const Composition& products, + ThreeBodyReaction(); + ThreeBodyReaction(const Composition& reactants, const Composition& products, const Arrhenius& rate, const ThirdBody& tbody); virtual std::string reactantString() const; virtual std::string productString() const; diff --git a/interfaces/cython/cantera/_cantera.pxd b/interfaces/cython/cantera/_cantera.pxd index 9daf99dd7..beb6649ef 100644 --- a/interfaces/cython/cantera/_cantera.pxd +++ b/interfaces/cython/cantera/_cantera.pxd @@ -264,8 +264,8 @@ cdef extern from "cantera/kinetics/Reaction.h" namespace "Cantera": Composition efficiencies double default_efficiency - cdef cppclass CxxThirdBodyReaction "Cantera::ThirdBodyReaction" (CxxElementaryReaction): - CxxThirdBodyReaction() + cdef cppclass CxxThreeBodyReaction "Cantera::ThreeBodyReaction" (CxxElementaryReaction): + CxxThreeBodyReaction() CxxThirdBody third_body cdef cppclass CxxFalloff "Cantera::Falloff": diff --git a/interfaces/cython/cantera/reaction.pyx b/interfaces/cython/cantera/reaction.pyx index 23d61bc26..36938cc61 100644 --- a/interfaces/cython/cantera/reaction.pyx +++ b/interfaces/cython/cantera/reaction.pyx @@ -310,15 +310,15 @@ cdef class ElementaryReaction(Reaction): r.allow_negative_pre_exponential_factor = allow -cdef class ThirdBodyReaction(ElementaryReaction): +cdef class ThreeBodyReaction(ElementaryReaction): """ A reaction with a non-reacting third body "M" that acts to add or remove energy from the reacting species. """ reaction_type = THREE_BODY_RXN - cdef CxxThirdBodyReaction* tbr(self): - return self.reaction + cdef CxxThreeBodyReaction* tbr(self): + return self.reaction property efficiencies: """ @@ -690,7 +690,7 @@ cdef Reaction wrapReaction(shared_ptr[CxxReaction] reaction): if reaction_type == ELEMENTARY_RXN: R = ElementaryReaction(init=False) elif reaction_type == THREE_BODY_RXN: - R = ThirdBodyReaction(init=False) + R = ThreeBodyReaction(init=False) elif reaction_type == FALLOFF_RXN: R = FalloffReaction(init=False) elif reaction_type == CHEMACT_RXN: @@ -714,7 +714,7 @@ cdef CxxReaction* newReaction(int reaction_type): if reaction_type == ELEMENTARY_RXN: return new CxxElementaryReaction() elif reaction_type == THREE_BODY_RXN: - return new CxxThirdBodyReaction() + return new CxxThreeBodyReaction() elif reaction_type == FALLOFF_RXN: return new CxxFalloffReaction() elif reaction_type == CHEMACT_RXN: diff --git a/interfaces/cython/cantera/test/test_kinetics.py b/interfaces/cython/cantera/test/test_kinetics.py index 560553c3a..79c6550f1 100644 --- a/interfaces/cython/cantera/test/test_kinetics.py +++ b/interfaces/cython/cantera/test/test_kinetics.py @@ -605,7 +605,7 @@ class TestReaction(utilities.CanteraTest): r = ct.Reaction.fromCti('''three_body_reaction('2 O + M <=> O2 + M', [1.200000e+11, -1.0, 0.0], efficiencies='AR:0.83 H2:2.4 H2O:15.4')''') - self.assertTrue(isinstance(r, ct.ThirdBodyReaction)) + self.assertTrue(isinstance(r, ct.ThreeBodyReaction)) self.assertEqual(r.reactants['O'], 2) self.assertEqual(r.products['O2'], 1) self.assertEqual(r.efficiencies['H2O'], 15.4) @@ -617,7 +617,7 @@ class TestReaction(utilities.CanteraTest): rxn_node = root.find('.//reaction[@id="0001"]') r = ct.Reaction.fromXml(ET.tostring(rxn_node)) - self.assertTrue(isinstance(r, ct.ThirdBodyReaction)) + self.assertTrue(isinstance(r, ct.ThreeBodyReaction)) self.assertEqual(r.reactants['O'], 2) self.assertEqual(r.products['O2'], 1) self.assertEqual(r.efficiencies['H2O'], 15.4) @@ -673,8 +673,8 @@ class TestReaction(utilities.CanteraTest): species=species, reactions=[r]) - def test_thirdbody(self): - r = ct.ThirdBodyReaction() + def test_threebody(self): + r = ct.ThreeBodyReaction() r.reactants = {'O':1, 'H':1} r.products = {'OH':1} r.rate = ct.Arrhenius(5e11, -1.0, 0.0) diff --git a/src/kinetics/GasKinetics.cpp b/src/kinetics/GasKinetics.cpp index df4f8d6c5..24d362e95 100644 --- a/src/kinetics/GasKinetics.cpp +++ b/src/kinetics/GasKinetics.cpp @@ -280,7 +280,7 @@ bool GasKinetics::addReaction(shared_ptr r) addElementaryReaction(dynamic_cast(*r)); break; case THREE_BODY_RXN: - addThreeBodyReaction(dynamic_cast(*r)); + addThreeBodyReaction(dynamic_cast(*r)); break; case FALLOFF_RXN: case CHEMACT_RXN: @@ -380,7 +380,7 @@ void GasKinetics::addFalloffReaction(FalloffReaction& r) ++m_nfall; } -void GasKinetics::addThreeBodyReaction(ThirdBodyReaction& r) +void GasKinetics::addThreeBodyReaction(ThreeBodyReaction& r) { m_rates.install(nReactions()-1, r.rate); map efficiencies; @@ -420,7 +420,7 @@ void GasKinetics::modifyReaction(size_t i, shared_ptr rNew) modifyElementaryReaction(i, dynamic_cast(*rNew)); break; case THREE_BODY_RXN: - modifyThreeBodyReaction(i, dynamic_cast(*rNew)); + modifyThreeBodyReaction(i, dynamic_cast(*rNew)); break; case FALLOFF_RXN: case CHEMACT_RXN: @@ -443,7 +443,7 @@ void GasKinetics::modifyReaction(size_t i, shared_ptr rNew) m_pres += 0.1234; } -void GasKinetics::modifyThreeBodyReaction(size_t i, ThirdBodyReaction& r) +void GasKinetics::modifyThreeBodyReaction(size_t i, ThreeBodyReaction& r) { m_rates.replace(i, r.rate); } diff --git a/src/kinetics/Kinetics.cpp b/src/kinetics/Kinetics.cpp index 4bbdb57ad..2ddc91113 100644 --- a/src/kinetics/Kinetics.cpp +++ b/src/kinetics/Kinetics.cpp @@ -225,8 +225,8 @@ std::pair Kinetics::checkDuplicates(bool throw_err) const continue; // No overlap in third body efficiencies } } else if (R.reaction_type == THREE_BODY_RXN) { - ThirdBody& tb1 = dynamic_cast(R).third_body; - ThirdBody& tb2 = dynamic_cast(other).third_body; + ThirdBody& tb1 = dynamic_cast(R).third_body; + ThirdBody& tb2 = dynamic_cast(other).third_body; bool thirdBodyOk = true; for (size_t k = 0; k < nTotalSpecies(); k++) { string s = kineticsSpeciesName(k); diff --git a/src/kinetics/Reaction.cpp b/src/kinetics/Reaction.cpp index 8abed3b40..082d4ab06 100644 --- a/src/kinetics/Reaction.cpp +++ b/src/kinetics/Reaction.cpp @@ -133,12 +133,12 @@ ThirdBody::ThirdBody(double default_eff) { } -ThirdBodyReaction::ThirdBodyReaction() +ThreeBodyReaction::ThreeBodyReaction() { reaction_type = THREE_BODY_RXN; } -ThirdBodyReaction::ThirdBodyReaction(const Composition& reactants_, +ThreeBodyReaction::ThreeBodyReaction(const Composition& reactants_, const Composition& products_, const Arrhenius& rate_, const ThirdBody& tbody) @@ -148,11 +148,11 @@ ThirdBodyReaction::ThirdBodyReaction(const Composition& reactants_, reaction_type = THREE_BODY_RXN; } -std::string ThirdBodyReaction::reactantString() const { +std::string ThreeBodyReaction::reactantString() const { return ElementaryReaction::reactantString() + " + M"; } -std::string ThirdBodyReaction::productString() const { +std::string ThreeBodyReaction::productString() const { return ElementaryReaction::productString() + " + M"; } @@ -377,7 +377,7 @@ void setupElementaryReaction(ElementaryReaction& R, const XML_Node& rxn_node) setupReaction(R, rxn_node); } -void setupThirdBodyReaction(ThirdBodyReaction& R, const XML_Node& rxn_node) +void setupThreeBodyReaction(ThreeBodyReaction& R, const XML_Node& rxn_node) { readEfficiencies(R.third_body, rxn_node.child("rateCoeff")); setupElementaryReaction(R, rxn_node); @@ -629,8 +629,8 @@ shared_ptr newReaction(const XML_Node& rxn_node) return R; } else if (type == "threebody" || type == "three_body") { - shared_ptr R(new ThirdBodyReaction()); - setupThirdBodyReaction(*R, rxn_node); + shared_ptr R(new ThreeBodyReaction()); + setupThreeBodyReaction(*R, rxn_node); return R; } else if (type == "falloff") { diff --git a/test/kinetics/kineticsFromScratch.cpp b/test/kinetics/kineticsFromScratch.cpp index e473ea234..e43b48c72 100644 --- a/test/kinetics/kineticsFromScratch.cpp +++ b/test/kinetics/kineticsFromScratch.cpp @@ -71,7 +71,7 @@ TEST_F(KineticsFromScratch, add_three_body_reaction) Arrhenius rate(1.2e11, -1.0, 0.0); ThirdBody tbody; tbody.efficiencies = parseCompString("AR:0.83 H2:2.4 H2O:15.4"); - shared_ptr R(new ThirdBodyReaction(reac, prod, rate, tbody)); + shared_ptr R(new ThreeBodyReaction(reac, prod, rate, tbody)); kin.addReaction(R); kin.finalize(); @@ -85,7 +85,7 @@ TEST_F(KineticsFromScratch, undefined_third_body) Arrhenius rate(1.2e11, -1.0, 0.0); ThirdBody tbody; tbody.efficiencies = parseCompString("H2:0.1 CO2:0.83"); - shared_ptr R(new ThirdBodyReaction(reac, prod, rate, tbody)); + shared_ptr R(new ThreeBodyReaction(reac, prod, rate, tbody)); ASSERT_THROW(kin.addReaction(R), CanteraError); } @@ -97,7 +97,7 @@ TEST_F(KineticsFromScratch, skip_undefined_third_body) Arrhenius rate(1.2e11, -1.0, 0.0); ThirdBody tbody; tbody.efficiencies = parseCompString("H2:0.1 CO2:0.83"); - shared_ptr R(new ThirdBodyReaction(reac, prod, rate, tbody)); + shared_ptr R(new ThreeBodyReaction(reac, prod, rate, tbody)); kin.skipUndeclaredThirdBodies(true); kin.addReaction(R);