From d0de362e223e782b3e3fd8f3d04d931b405ceca3 Mon Sep 17 00:00:00 2001 From: Dave Goodwin Date: Thu, 14 Jul 2005 18:48:57 +0000 Subject: [PATCH] *** empty log message *** --- Cantera/src/Kinetics.cpp | 17 ++++++++++----- Cantera/src/Kinetics.h | 37 +++++++++++++++------------------ Cantera/src/MultiPhaseEquil.cpp | 5 +---- Cantera/src/MultiPhaseEquil.h | 7 ++++--- Cantera/src/ct_defs.h | 2 +- Cantera/src/ctexceptions.h | 2 +- Cantera/src/misc.cpp | 12 +++++++++-- Cantera/src/stringUtils.cpp | 3 ++- 8 files changed, 48 insertions(+), 37 deletions(-) diff --git a/Cantera/src/Kinetics.cpp b/Cantera/src/Kinetics.cpp index db7cba121..3450bf4d0 100644 --- a/Cantera/src/Kinetics.cpp +++ b/Cantera/src/Kinetics.cpp @@ -23,23 +23,22 @@ namespace Cantera { Kinetics::Kinetics() : m_ii(0), m_thermo(0), - m_index(-1), m_surfphase(-1) {} + m_index(-1), m_surfphase(-1), m_rxnphase(-1), + m_mindim(4) {} Kinetics::Kinetics(thermo_t* thermo) : m_ii(0), m_index(-1), m_surfphase(-1) , - m_rxnphase(0) + m_rxnphase(0), m_mindim(4) { if (thermo) { addPhase(*thermo); } deprecatedMethod("Kinetics","Kinetics(thermo_t*)","Kinetics()"); + removeAtVersion("Kinetics(thermo_t*)","1.6.0"); } - /** - * Destructor. Does nothing. - */ Kinetics::~Kinetics(){} /** @@ -189,6 +188,14 @@ namespace Cantera { else { m_start.push_back(0); } + + // the phase with lowest dimensionality is assumed to be the + // phase/interface at which reactions take place + if (thermo.nDim() <= m_mindim) { + m_mindim = thermo.nDim(); + m_rxnphase = nPhases(); + } + // there should only be one surface phase int ptype = -100; if (type() == cEdgeKinetics) ptype = cEdge; diff --git a/Cantera/src/Kinetics.h b/Cantera/src/Kinetics.h index f1d54229c..deec33c95 100755 --- a/Cantera/src/Kinetics.h +++ b/Cantera/src/Kinetics.h @@ -25,11 +25,11 @@ namespace Cantera { /// @section kinmodman Models and Managers /// /// A kinetics manager is a C++ class that implements a kinetics - /// model, which is a set of mathematical equation describing how - /// various kinetic quanities are to be computed -- reaction - /// rates, species production rates, etc. Many different kinetics - /// models might be defined to handle different types of kinetic - /// processes. For example, one kinetics model might use + /// model; a kinetics model is a set of mathematical equation + /// describing how various kinetic quanities are to be computed -- + /// reaction rates, species production rates, etc. Many different + /// kinetics models might be defined to handle different types of + /// kinetic processes. For example, one kinetics model might use /// expressions valid for elementary reactions in ideal gas /// mixtures. It might, for example, require the reaction orders /// to be integral and equal to the forward stoichiometric @@ -64,16 +64,6 @@ namespace Cantera { /// kinetics manager classes should have a common set of public /// methods, but differ in how they implement these methods. /// - /// All kinetics manager classes derive from a common base class - /// (class Kinetics). The primary purpose of class Kinetics is to - /// define the common public interface for the family of kinetics - /// managers. For example, Kinetics defines a method - /// getNetProductionRates that every family member is required to - /// implement. The details of how it is implemented are left to - /// the individual manager, but the end result must be that the - /// net production rates for each species are written to an output - /// array. - /// /// A kinetics manager computes reaction rates of progress, /// species production rates, equilibrium constants, and similar /// quantities for a reaction mechanism. All kinetics manager @@ -142,7 +132,7 @@ namespace Cantera { /// Default constructor. Kinetics(); - /// This Constructor initializes with a starting phase. + /// This constructor initializes with a starting phase. /// @deprecated Kinetics(thermo_t* thermo); @@ -155,7 +145,7 @@ namespace Cantera { /// mix_defs.h. virtual int type() { return 0; } - /// Number of reactions in the reaction mechanism + /// Number of reactions in the reaction mechanism. int nReactions() const {return m_ii;} //@} @@ -182,10 +172,15 @@ namespace Cantera { * * If a -1 is returned, then the phase is not defined in * the Kinetics object. - * @todo (HKM -> unfound object will create another entry in the - * map, suggest rewriting this function) */ - int phaseIndex(string ph) { return m_phaseindex[ph] - 1; } + int phaseIndex(string ph) { + if (m_phaseindex.find(ph) == m_phaseindex.end()) { + return -1; + } + else { + return m_phaseindex[ph] - 1; + } + } /** * This returns the integer index of the phase which has @@ -803,6 +798,8 @@ namespace Cantera { */ int m_rxnphase; + /// number of spatial dimensions of lowest-dimensional phase. + int m_mindim; private: diff --git a/Cantera/src/MultiPhaseEquil.cpp b/Cantera/src/MultiPhaseEquil.cpp index 1d4878b4e..dd3cf029f 100644 --- a/Cantera/src/MultiPhaseEquil.cpp +++ b/Cantera/src/MultiPhaseEquil.cpp @@ -735,15 +735,13 @@ namespace Cantera { // don't require formation reactions for solution species // present in trace amounts to be equilibrated - if (!isStoichPhase(ik) && fabs(moles(ik)) <= Tiny) + if (!isStoichPhase(ik) && fabs(moles(ik)) <= SmallNumber) err = 0.0; // for stoichiometric phase species, no error if not present and // delta G for the formation reaction is positive else if (isStoichPhase(ik) && moles(ik) <= 0.0 && m_deltaG_RT[j] >= 0.0) err = 0.0; - //else err = fabs(m_deltaG_RT[j]); - //} else { err = fabs(m_deltaG_RT[j]); } @@ -751,7 +749,6 @@ namespace Cantera { maxerr = err; } } - return maxerr; } } diff --git a/Cantera/src/MultiPhaseEquil.h b/Cantera/src/MultiPhaseEquil.h index 9fa86726d..acfb3523b 100644 --- a/Cantera/src/MultiPhaseEquil.h +++ b/Cantera/src/MultiPhaseEquil.h @@ -104,16 +104,17 @@ namespace Cantera { inline doublereal equilibrate(MultiPhase& s, int XY, doublereal tol = 1.0e-9, int maxsteps = 1000, int loglevel = 0) { s.init(); - //MultiPhaseEquil e(&s); - if (XY == TP || XY == HP) { + writelog("in equilibrate(MultiPhase, ...)\n"); + if (XY == TP || XY == HP || XY == SP || XY == TV) { double err = s.equilibrate(XY, tol, maxsteps, maxsteps, loglevel); if (loglevel > 0) { + writelog("writing log file\n"); write_logfile("equilibrate.html"); } return err; } else { - throw CanteraError("equilibrate","only fixed T, P supported"); + throw CanteraError("equilibrate","unsupported option"); return -1.0; } } diff --git a/Cantera/src/ct_defs.h b/Cantera/src/ct_defs.h index ee46d6e89..4379fdcb4 100755 --- a/Cantera/src/ct_defs.h +++ b/Cantera/src/ct_defs.h @@ -47,7 +47,7 @@ using namespace ct; */ namespace Cantera { -#define CANTERA_VERSION 1.6 + //#define CANTERA_VERSION 1.6 // use kg-moles, rather than g-moles. diff --git a/Cantera/src/ctexceptions.h b/Cantera/src/ctexceptions.h index f1205136e..da524d98d 100755 --- a/Cantera/src/ctexceptions.h +++ b/Cantera/src/ctexceptions.h @@ -39,7 +39,7 @@ namespace Cantera { }; void deprecatedMethod(string classnm, string oldnm, string newnm); - + void removeAtVersion(string func, string version); } #endif diff --git a/Cantera/src/misc.cpp b/Cantera/src/misc.cpp index e255511c1..de0cf7fd5 100755 --- a/Cantera/src/misc.cpp +++ b/Cantera/src/misc.cpp @@ -561,6 +561,15 @@ namespace Cantera { } + void removeAtVersion(string func, string version) { + if (version >= "CANTERA_VERSION") { + writelog("Removed procedure: "+func+"\n"); + writelog("Removed in version: "+version+"\n"); + throw CanteraError("removeAtVersion","procedure has been removed."); + } + } + + /// @defgroup logs Diagnostic Output /// /// Writing diagnostic information to the screen or to a file. @@ -639,7 +648,6 @@ namespace Cantera { /// ////////////////////////////////////////////////////////////////// - /// Create a new group for log messages. Usually this is called /// upon entering the function, with the title parameter equal to /// the name of the function or method. Subsequent messages @@ -689,6 +697,7 @@ namespace Cantera { /// file will be overwritten. will be appended to the name. /// @ingroup HTML_logs void write_logfile(string file) { + if (!__app->xmllog) return; string::size_type idot = file.rfind('.'); string ext = ""; string nm = file; @@ -730,6 +739,5 @@ namespace Cantera { __app->current = 0; } } - /// } diff --git a/Cantera/src/stringUtils.cpp b/Cantera/src/stringUtils.cpp index ef1ea9375..4bd756106 100755 --- a/Cantera/src/stringUtils.cpp +++ b/Cantera/src/stringUtils.cpp @@ -102,7 +102,8 @@ namespace Cantera { s = ""; } nm = stripws(name); - if (x[nm] == 0.0) { + if (x.find(nm) == x.end()) { + //if (x[nm] == 0.0) { throw CanteraError("parseCompString", "unknown species " + nm); }