diff --git a/doc/sphinx/cti/reactions.rst b/doc/sphinx/cti/reactions.rst index 2aabcf111..bb9760aee 100644 --- a/doc/sphinx/cti/reactions.rst +++ b/doc/sphinx/cti/reactions.rst @@ -58,9 +58,6 @@ which is defined with an :class:`Arrhenius` entry:: rate_coeff = Arrhenius(A=1.0e13, b=0, E=(7.3, 'kcal/mol')) rate_coeff = Arrhenius(1.0e13, 0, (7.3, 'kcal/mol')) -Note: the usage of ``n`` as the temperature exponent has been deprecated. It is -still available in version 2.2 but will be removed. - As a shorthand, if the ``rate_coeff`` field is assigned a sequence of three numbers, these are assumed to be :math:`(A, b, E)` in the modified Arrhenius function:: rate_coeff = [1.0e13, 0, (7.3, 'kcal/mol')] # equivalent to above diff --git a/include/cantera/base/ctml.h b/include/cantera/base/ctml.h index bbfeb52fc..0b01ac93c 100644 --- a/include/cantera/base/ctml.h +++ b/include/cantera/base/ctml.h @@ -742,25 +742,6 @@ void getNamedStringValue(const XML_Node& node, const std::string& nameString, st std::string getChildValue(const XML_Node& parent, const std::string& nameString); -//! Read an ctml file from a file and fill up an XML tree -/*! - * This is the main routine that reads a ctml file and puts it into - * an XML_Node tree - * - * @param node Root of the tree - * @param file Name of the file - * @param debug Turn on debugging printing - * @deprecated To be removed after Cantera 2.2. Use get_XML_File() instead. - */ -void get_CTML_Tree(XML_Node* node, const std::string& file, - const int debug = 0); - -//! Read an ctml file from a file and fill up an XML tree. -//! @param file Name of the file -//! @return Root of the tree -//! @deprecated To be removed after Cantera 2.2. Use get_XML_File() instead. -XML_Node getCtmlTree(const std::string& file); - //! Convert a cti file into a ctml file /*! * @param file Pointer to the file diff --git a/include/cantera/base/xml.h b/include/cantera/base/xml.h index c18733df9..d4126bfa9 100644 --- a/include/cantera/base/xml.h +++ b/include/cantera/base/xml.h @@ -222,13 +222,6 @@ public: */ std::string value() const; - //! Overloaded parenthesis operator returns the value of the Node - /*! - * @return Returns the value of the node as a string. - * @deprecated Use value() instead. - */ - std::string operator()() const; - //! Return the value of an XML child node as a string /*! * @param cname Name of the child node to the current @@ -559,18 +552,6 @@ public: */ XML_Node* findByName(const std::string& nm, int depth = 100000); - //! Get a vector of pointers to XML_Node containing all of the children - //! of the current node which matches the input name - /*! - * @param name Name of the XML_Node children to search on - * - * @param children output vector of pointers to XML_Node children - * with the matching name - * @deprecated To be removed after Cantera 2.2. Use the version that returns - * the vector of child nodes - */ - void getChildren(const std::string& name, std::vector& children) const; - //! Get a vector of pointers to XML_Node containing all of the children //! of the current node which match the given name /*! diff --git a/include/cantera/equil/MultiPhase.h b/include/cantera/equil/MultiPhase.h index 408c4af63..3773538b9 100644 --- a/include/cantera/equil/MultiPhase.h +++ b/include/cantera/equil/MultiPhase.h @@ -799,13 +799,11 @@ size_t BasisOptimize(int* usedZeroedSpecies, bool doFormRxn, * elements that is necessary for calculation of the formula matrix. * * @ingroup equilfunctions - * @deprecated - The return value for this function is deprecated. After - * Cantera 2.2, this function will return void. */ -size_t ElemRearrange(size_t nComponents, const vector_fp& elementAbundances, - MultiPhase* mphase, - std::vector& orderVectorSpecies, - std::vector& orderVectorElements); +void ElemRearrange(size_t nComponents, const vector_fp& elementAbundances, + MultiPhase* mphase, + std::vector& orderVectorSpecies, + std::vector& orderVectorElements); //! External int that is used to turn on debug printing for the //! BasisOptimze program. diff --git a/include/cantera/equil/equil.h b/include/cantera/equil/equil.h deleted file mode 100644 index 22d190c00..000000000 --- a/include/cantera/equil/equil.h +++ /dev/null @@ -1,88 +0,0 @@ -/** - * @file equil.h - * This file contains the definition of some high level general equilibration - * routines. - * @deprecated All functions defined in this file are deprecated. To be removed - * after Cantera 2.2. - */ - -// Copyright 2001 California Institute of Technology - -#ifndef CT_KERNEL_EQUIL_H -#define CT_KERNEL_EQUIL_H - - -#pragma message("cantera/equil/equil.h is deprecated") -#include "MultiPhase.h" -#include "vcs_defs.h" - -namespace Cantera -{ -/*! - * @defgroup equilfunctions Equilibrium Solver Capability - * - * Cantera has several different equilibrium routines. - */ - -//! Equilibrate a ThermoPhase object -/*! - * Set a single-phase chemical solution to chemical equilibrium. This is a - * convenience function that uses one or the other of the two chemical - * equilibrium solvers. The XY parameter indicates what two thermodynamic - * quantities, other than element composition, are to be held constant during - * the equilibration process. - * - * @param s ThermoPhase object that will be equilibrated. - * @param XY String representation of what two properties - * are being held constant - * @param solver ID of the solver to be used to equilibrate the phase. - * If solver = 0, the ChemEquil solver will be used, - * and if solver = 1, the - * MultiPhaseEquil solver will be used (slower than ChemEquil, - * but more stable). If solver < 0 (default, then ChemEquil will - * be tried first, and if it fails MultiPhaseEquil will be tried. - * @param rtol Relative tolerance - * @param maxsteps Maximum number of steps to take to find the solution - * @param maxiter For the MultiPhaseEquil solver only, this is - * the maximum number of outer temperature or pressure iterations - * to take when T and/or P is not held fixed. - * @param loglevel loglevel Controls amount of diagnostic output. loglevel - * = 0 suppresses diagnostics, and increasingly-verbose messages - * are written as loglevel increases. - * - * @return The number of iterations it took to equilibrate the system. - * @deprecated Use ThermoPhase::equilibrate instead. To be removed after Cantera 2.2. - * @ingroup equilfunctions - */ -int equilibrate(thermo_t& s, const char* XY, - int solver = -1, doublereal rtol = 1.0e-9, int maxsteps = VCS_MAXSTEPS, - int maxiter = 100, int loglevel = -99); - -//! Equilibrate a MultiPhase object -/*! - * Equilibrate a MultiPhase object. The XY parameter indicates what two - * thermodynamic quantities, other than element composition, are to be held - * constant during the equilibration process. - * - * This is the top-level driver for multiphase equilibrium. It doesn't do - * much more than call the equilibrate method of class MultiPhase, except - * that it adds some messages to the logfile, if loglevel is set > 0. - * - * @param s MultiPhase object that will be equilibrated. - * @param XY String representation of what is being held constant - * @param rtol Relative tolerance - * @param maxsteps Maximum number of steps - * @param maxiter Maximum iterations - * @param loglevel loglevel - * - * @return The number of iterations it took to equilibrate the system. - * @deprecated Use MultiPhase::equilibrate instead. To be removed after Cantera 2.2. - * @ingroup equilfunctions - */ -doublereal equilibrate(MultiPhase& s, const char* XY, - doublereal rtol = 1.0e-9, int maxsteps = 5000, int maxiter = 100, - int loglevel = -99); - -} - -#endif diff --git a/include/cantera/equil/vcs_MultiPhaseEquil.h b/include/cantera/equil/vcs_MultiPhaseEquil.h index c95c5ec9d..baf187e42 100644 --- a/include/cantera/equil/vcs_MultiPhaseEquil.h +++ b/include/cantera/equil/vcs_MultiPhaseEquil.h @@ -11,153 +11,6 @@ namespace Cantera { -//! Set a single-phase chemical solution to chemical equilibrium. -/*! - * The function uses the element abundance vector that is currently - * consistent with the composition within the phase itself. Two other - * thermodynamic quantities, determined by the XY string, are held constant - * during the equilibration. This is a convenience function that uses one or - * the other of the two chemical equilibrium solvers. - * - * @param s The object to set to an equilibrium state - * @param XY An integer specifying the two properties to be held constant. - * @param estimateEquil integer indicating whether the solver - * should estimate its own initial condition. - * - If 0, the initial mole fraction vector in the - * ThermoPhase object is used as the initial condition. - * - If 1, the initial mole fraction vector is used if the - * element abundances are satisfied. - * - if -1, the initial mole fraction vector is thrown out, - * and an estimate is formulated. - * @param printLvl Determines the amount of printing that gets sent to stdout - * from the vcs package (Note, you may have to compile with - * debug flags to get some printing). - * @param solver The equilibrium solver to use. If solver = 0, the ChemEquil - * solver will be used, and if solver = 1, the - * vcs_MultiPhaseEquil solver will be used (slower than - * ChemEquil, but more stable). If solver < 0 (default, then - * ChemEquil will be tried first, and if it fails - * vcs_MultiPhaseEquil will be tried. - * @param rtol Relative tolerance of the solve. Defaults to 1.0E-9. - * @param maxsteps The maximum number of steps to take to find the solution. - * @param maxiter For the MultiPhaseEquil solver only, this is the maximum - * number of outer temperature or pressure iterations to take - * when T and/or P is not held fixed. - * @param loglevel Controls amount of diagnostic output. loglevel - * = 0 suppresses diagnostics, and increasingly-verbose - * messages are written as loglevel increases. - * @deprecated Use ThermoPhase::equilibrate instead. To be removed after - * Cantera 2.2. - * @ingroup equilfunctions - */ -int vcs_equilibrate(thermo_t& s, const char* XY, - int estimateEquil = 0, int printLvl = 0, - int solver = -1, doublereal rtol = 1.0e-9, - int maxsteps = VCS_MAXSTEPS, - int maxiter = 100, int loglevel = -99); - -//! Set a multi-phase chemical solution to chemical equilibrium. -/*! - * This function uses the vcs_MultiPhaseEquil interface to the vcs solver. - * The function uses the element abundance vector that is currently - * consistent with the composition within the phases themselves. Two other - * thermodynamic quantities, determined by the XY string, are held constant - * during the equilibration. - * - * @param s The object to set to an equilibrium state - * @param XY A character string representing the unknowns to be held constant - * @param estimateEquil integer indicating whether the solver - * should estimate its own initial condition. - * - If 0, the initial mole fraction vector in the - * ThermoPhase object is used as the initial condition. - * - If 1, the initial mole fraction vector is used if the - * element abundances are satisfied. - * - If -1, the initial mole fraction vector is thrown out, - * and an estimate is formulated. - * @param printLvl Determines the amount of printing that gets sent to stdout - * from the vcs package (Note, you may have to compile with - * debug flags to get some printing). - * @param solver Determines which solver is used. - * - 1 MultiPhaseEquil solver - * - 2 VCSnonideal Solver (default) - * @param rtol Relative tolerance of the solve. Defaults to 1.0E-9. - * @param maxsteps The maximum number of steps to take to find the solution. - * @param maxiter For the MultiPhaseEquil solver only, this is the maximum - * number of outer temperature or pressure iterations to take - * when T and/or P is not held fixed. - * @param loglevel Controls amount of diagnostic output. loglevel - * = 0 suppresses diagnostics, and increasingly-verbose - * messages are written as loglevel increases. - * @deprecated Use MultiPhase::equilibrate instead. To be removed after - * Cantera 2.2. - * @ingroup equilfunctions - */ -int vcs_equilibrate(MultiPhase& s, const char* XY, - int estimateEquil = 0, int printLvl = 0, - int solver = 2, - doublereal rtol = 1.0e-9, int maxsteps = VCS_MAXSTEPS, - int maxiter = 100, int loglevel = -99); - -//! Set a multi-phase chemical solution to chemical equilibrium. -/*! - * This function uses the vcs_MultiPhaseEquil interface to the vcs solver. - * The function uses the element abundance vector that is currently - * consistent with the composition within the phases themselves. Two other - * thermodynamic quantities, determined by the XY string, are held constant - * during the equilibration. - * - * @param s The MultiPhase object to be set to an equilibrium state - * @param ixy An integer specifying the two properties to be held constant. - * @param estimateEquil integer indicating whether the solver - * should estimate its own initial condition. - * - If 0, the initial mole fraction vector in the - * ThermoPhase object is used as the initial condition. - * - If 1, the initial mole fraction vector is used if the - * element abundances are satisfied. - * - if -1, the initial mole fraction vector is thrown out, - * and an estimate is formulated. - * @param printLvl Determines the amount of printing that gets sent to stdout - * from the vcs package (Note, you may have to compile with - * debug flags to get some printing). - * @param solver Determines which solver is used. - * - 1 MultiPhaseEquil solver - * - 2 VCSnonideal Solver (default) - * @param rtol Relative tolerance of the solve. Defaults to 1.0E-9. - * @param maxsteps The maximum number of steps to take to find the solution. - * @param maxiter For the MultiPhaseEquil solver only, this is - * the maximum number of outer temperature or - * pressure iterations to take when T and/or P is - * not held fixed. - * @param loglevel Controls amount of diagnostic output. loglevel - * = 0 suppresses diagnostics, and increasingly-verbose - * messages are written as loglevel increases. - * @deprecated Use MultiPhase::equilibrate instead. To be removed after - * Cantera 2.2. - * @ingroup equilfunctions - */ -int vcs_equilibrate_1(MultiPhase& s, int ixy, - int estimateEquil = 0, int printLvl = 0, - int solver = 2, - doublereal rtol = 1.0e-9, int maxsteps = VCS_MAXSTEPS, - int maxiter = 100, int loglevel = -99); - -//! Determine the phase stability of a single phase given the current conditions -//! in a MultiPhase object -/*! - * @param s The MultiPhase object to be set to an equilibrium state - * @param iphase Phase index within the multiphase object to be - * tested for stability. - * @param funcStab Function value that tests equilibrium. > 0 indicates stable - * < 0 indicates unstable - * @param printLvl Determines the amount of printing that gets sent to - * stdout from the vcs package (Note, you may have to compile - * with debug flags to get some printing). - * @param loglevel Controls amount of diagnostic output. loglevel - * = 0 suppresses diagnostics, and increasingly-verbose - * messages are written as loglevel increases. - */ -int vcs_determine_PhaseStability(MultiPhase& s, int iphase, - double& funcStab, int printLvl, int loglevel); //! Translate a MultiPhase object into a VCS_PROB problem definition object /*! diff --git a/include/cantera/equilibrium.h b/include/cantera/equilibrium.h deleted file mode 100644 index ef5ac0ef9..000000000 --- a/include/cantera/equilibrium.h +++ /dev/null @@ -1,17 +0,0 @@ -/** - * @file equilibrium.h - * cxx layer - Header file providing support for chemical equilibrium calculations - * (see \ref equilfunctions) - * @deprecated Equilibrium solvers are directly available through class - * Cantera::ThermoPhase and class Cantera::MultiPhase - */ -#ifndef CT_EQUIL_INCL -#define CT_EQUIL_INCL -#pragma message("cantera/equilibrium.h is deprecated") -#include "equil/equil.h" -#include "equil/ChemEquil.h" -#include "equil/MultiPhaseEquil.h" -#include "equil/vcs_MultiPhaseEquil.h" -#endif - - diff --git a/include/cantera/kinetics/AqueousKinetics.h b/include/cantera/kinetics/AqueousKinetics.h index 01e08e7bb..b948e46ca 100644 --- a/include/cantera/kinetics/AqueousKinetics.h +++ b/include/cantera/kinetics/AqueousKinetics.h @@ -55,7 +55,6 @@ public: //! Update the equilibrium constants in molar units. void updateKc(); - virtual void addReaction(ReactionData& r); virtual bool addReaction(shared_ptr r); virtual void modifyReaction(size_t i, shared_ptr rNew); }; diff --git a/include/cantera/kinetics/BulkKinetics.h b/include/cantera/kinetics/BulkKinetics.h index c3d1c9795..df831eb69 100644 --- a/include/cantera/kinetics/BulkKinetics.h +++ b/include/cantera/kinetics/BulkKinetics.h @@ -34,7 +34,6 @@ public: virtual void getRevRateConstants(doublereal* krev, bool doIrreversible = false); - virtual void addReaction(ReactionData& r); virtual bool addReaction(shared_ptr r); virtual void init(); virtual void finalize(); @@ -44,7 +43,6 @@ public: protected: - virtual void addElementaryReaction(ReactionData& r); virtual void addElementaryReaction(ElementaryReaction& r); virtual void modifyElementaryReaction(size_t i, ElementaryReaction& rNew); diff --git a/include/cantera/kinetics/ElectrodeKinetics.h b/include/cantera/kinetics/ElectrodeKinetics.h index 6734d604f..887546386 100644 --- a/include/cantera/kinetics/ElectrodeKinetics.h +++ b/include/cantera/kinetics/ElectrodeKinetics.h @@ -75,10 +75,6 @@ public: */ virtual void updateROP(); - virtual void determineFwdOrdersBV(ReactionData& rdata, std::vector& fwdFullorders); - - //void addGlobalReaction(ReactionData& r); - double calcForwardROP_BV(size_t irxn, size_t iBeta, double ioc, double nStoich, double nu, doublereal ioNet); double calcForwardROP_BV_NoAct(size_t irxn, size_t iBeta, double ioc, double nStoich, double nu, doublereal ioNet); diff --git a/include/cantera/kinetics/Enhanced3BConc.h b/include/cantera/kinetics/Enhanced3BConc.h deleted file mode 100644 index 4a3b200b2..000000000 --- a/include/cantera/kinetics/Enhanced3BConc.h +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @file Enhanced3BConc.h - */ -// Copyright 2001 California Institute of Technology - - -#ifndef CT_ENH_CONC_H -#define CT_ENH_CONC_H - -#include "cantera/base/ct_defs.h" -#include "cantera/base/global.h" - -namespace Cantera -{ - -/** - * Computes enhanced third-body concentrations. - * @deprecated Replaced by ThirdBodyCalc. To be removed after Cantera 2.2. - * @see GasKinetics - */ -class Enhanced3BConc -{ - -public: - - Enhanced3BConc() : m_deflt(1.0) { - warn_deprecated("class Enhanced3BConc", - "To be removed after Cantera 2.2."); - } - - Enhanced3BConc(const std::map& enhanced, - doublereal deflt = 1.0) { - warn_deprecated("class Enhanced3BConc", - "To be removed after Cantera 2.2."); - std::map::const_iterator iter; - for (iter = enhanced.begin(); iter != enhanced.end(); ++iter) { - m_index.push_back(iter->first); - m_eff.push_back(iter->second - deflt); - } - m_deflt = deflt; - } - - doublereal update(const vector_fp& c, doublereal ctot) const { - doublereal sum = 0.0; - for (size_t i = 0; i < m_eff.size(); i++) { - sum += m_eff[i] * c[m_index[i]]; - } - return m_deflt * ctot + sum; - } - - void getEfficiencies(vector_fp& eff) const { - for (size_t i = 0; i < m_eff.size(); i++) { - eff[m_index[i]] = m_eff[i] + m_deflt; - } - } - -private: - std::vector m_index; - vector_fp m_eff; - doublereal m_deflt; -}; - -} - -#endif diff --git a/include/cantera/kinetics/FalloffMgr.h b/include/cantera/kinetics/FalloffMgr.h index a1804a9da..76e239d46 100644 --- a/include/cantera/kinetics/FalloffMgr.h +++ b/include/cantera/kinetics/FalloffMgr.h @@ -30,24 +30,6 @@ public: //else m_factory = f; } - //! Install a new falloff function calculator. - /* - * @param rxn Index of the falloff reaction. This will be used to - * determine which array entry is modified in method pr_to_falloff. - * @param falloffType of falloff function to install. - * @param reactionType Either `FALLOFF_RXN` or `CHEMACT_RXN` - * @param c vector of coefficients for the falloff function. - * @deprecated Use install(size_t, int, shared_ptr). To be removed - * after Cantera 2.2. - */ - void install(size_t rxn, int falloffType, int reactionType, - const vector_fp& c) { - warn_deprecated("FalloffMgr::install(size_t, int, int, const vector_fp&)", - "Use install(size_t, int, shared_ptr). To be removed after Cantera 2.2."); - shared_ptr f(m_factory->newFalloff(falloffType,c)); - install(rxn, reactionType, f); - } - //! Install a new falloff function calculator. /* * @param rxn Index of the falloff reaction. This will be used to diff --git a/include/cantera/kinetics/GasKinetics.h b/include/cantera/kinetics/GasKinetics.h index e00fe16d8..f309255f9 100644 --- a/include/cantera/kinetics/GasKinetics.h +++ b/include/cantera/kinetics/GasKinetics.h @@ -52,7 +52,6 @@ public: //! @name Reaction Mechanism Setup Routines //! @{ virtual void init(); - virtual void addReaction(ReactionData& r); virtual bool addReaction(shared_ptr r); virtual void modifyReaction(size_t i, shared_ptr rNew); virtual void finalize(); @@ -111,11 +110,6 @@ protected: void processFalloffReactions(); - void addThreeBodyReaction(ReactionData& r); - void addFalloffReaction(ReactionData& r); - void addPlogReaction(ReactionData& r); - void addChebyshevReaction(ReactionData& r); - void addThreeBodyReaction(ThreeBodyReaction& r); void addFalloffReaction(FalloffReaction& r); void addPlogReaction(PlogReaction& r); diff --git a/include/cantera/kinetics/InterfaceKinetics.h b/include/cantera/kinetics/InterfaceKinetics.h index 1cd2b89af..1f4507cf0 100644 --- a/include/cantera/kinetics/InterfaceKinetics.h +++ b/include/cantera/kinetics/InterfaceKinetics.h @@ -210,7 +210,6 @@ public: virtual void addPhase(thermo_t& thermo); virtual void init(); - virtual void addReaction(ReactionData& r); virtual bool addReaction(shared_ptr r); virtual void modifyReaction(size_t i, shared_ptr rNew); virtual void finalize(); @@ -292,16 +291,6 @@ public: */ virtual void updateMu0(); - //! Number of reactions in the mechanism - /*! - * @deprecated This is a duplicate of Kinetics::nReactions() - */ - size_t reactionNumber() const { - warn_deprecated("InterfaceKinetics::reactionNumber", - "To be removed after Cantera 2.2. Duplicate of nReactions()."); - return m_ii; - } - //! Update the equilibrium constants and stored electrochemical potentials //! in molar units for all reversible reactions and for all species. /*! @@ -391,7 +380,6 @@ public: */ int phaseStability(const size_t iphase) const; - virtual void determineFwdOrdersBV(ReactionData& rdata, vector_fp& fwdFullorders); virtual void determineFwdOrdersBV(ElectrochemicalReaction& r, vector_fp& fwdFullorders); protected: diff --git a/include/cantera/kinetics/Kinetics.h b/include/cantera/kinetics/Kinetics.h index df617150b..99ad9d406 100644 --- a/include/cantera/kinetics/Kinetics.h +++ b/include/cantera/kinetics/Kinetics.h @@ -19,8 +19,6 @@ namespace Cantera { -// forward references -class ReactionData; class Reaction; /** @@ -787,17 +785,6 @@ public: */ virtual void finalize(); - /** - * Add a single reaction to the mechanism. This routine - * must be called after init() and before finalize(). Derived classes - * should call the base class method in addition to handling their - * own specialized behavior. - * - * @param r Reference to the ReactionData object for the reaction - * to be added. - */ - virtual void addReaction(ReactionData& r); - /** * Add a single reaction to the mechanism. Derived classes should call the * base class method in addition to handling their own specialized behavior. @@ -839,12 +826,6 @@ public: m_skipUndeclaredThirdBodies = skip; } - //! @deprecated To be removed after Cantera 2.2. No longer called as part - //! of addReaction. - virtual void installReagents(const ReactionData& r) { - throw NotImplementedError("Kinetics::installReagents"); - } - virtual void installGroups(size_t irxn, const std::vector& r, const std::vector& p); diff --git a/include/cantera/kinetics/RateCoeffMgr.h b/include/cantera/kinetics/RateCoeffMgr.h index f477cba06..e9b2ee770 100644 --- a/include/cantera/kinetics/RateCoeffMgr.h +++ b/include/cantera/kinetics/RateCoeffMgr.h @@ -25,27 +25,6 @@ public: Rate1() {} virtual ~Rate1() {} - /** - * Install a rate coefficient calculator. - * @param rxnNumber the reaction number - * @param rdata rate coefficient specification for the reaction - */ - size_t install(size_t rxnNumber, const ReactionData& rdata) { - /* - * Check to see if the current reaction rate type is the same as the - * type of this class. If not, throw an error condition. - */ - if (rdata.rateCoeffType != R::type()) - throw CanteraError("Rate1::install", - "incorrect rate coefficient type: "+int2str(rdata.rateCoeffType) + ". Was Expecting type: "+ int2str(R::type())); - - // Install a rate calculator and return the index of the calculator. - m_rxn.push_back(rxnNumber); - m_rates.push_back(R(rdata)); - m_indices[rxnNumber] = m_rxn.size() - 1; - return m_rates.size() - 1; - } - /** * Install a rate coefficient calculator. * @param rxnNumber the reaction number diff --git a/include/cantera/kinetics/ReactionData.h b/include/cantera/kinetics/ReactionData.h deleted file mode 100644 index ccf8922f0..000000000 --- a/include/cantera/kinetics/ReactionData.h +++ /dev/null @@ -1,226 +0,0 @@ -/** - * @file ReactionData.h - */ -// Copyright 2001 California Institute of Technology - -#ifndef CT_REACTION_DATA_H -#define CT_REACTION_DATA_H - -#include "cantera/kinetics/reaction_defs.h" -#include "cantera/base/utilities.h" - -namespace Cantera -{ - -//! Intermediate class which stores data about a reaction and its rate -//! parameterization before adding the reaction to a Kinetics object. -/*! - * All data in this class is public. - * @deprecated Use class Reaction and its children. To be removed after - * Cantera 2.2. - */ -class ReactionData -{ -public: - ReactionData() : - reactionType(ELEMENTARY_RXN), - validate(false), - number(0), - rxn_number(0), - filmResistivity(0.0), - equilibriumConstantPower(1.0), - affinityPower(1.0), - reversible(true), - duplicate(false), - rateCoeffType(ARRHENIUS_REACTION_RATECOEFF_TYPE), - falloffType(NONE), - error(0), - equation(""), - default_3b_eff(1.0), - global(false), - isReversibleWithFrac(false), - beta(0.0), - chebTmin(-1.0), - chebTmax(-1.0), - chebPmin(-1.0), - chebPmax(-1.0), - chebDegreeT(0), - chebDegreeP(0) - { - warn_deprecated("class ReactionData", - "To be removed after Cantera 2.2."); - } - - virtual ~ReactionData() {} - - //! Type of the reaction. The valid types are listed in the file, - //! reaction_defs.h, with constants ending in `RXN`. - int reactionType; - - bool validate; //!< Perform validation of the rate coefficient data - int number; //!< Index of this reaction within the mechanism - int rxn_number; //!< @deprecated duplicate of #number - std::vector reactants; //!< Indices of reactant species - std::vector products; //!< Indices of product species - - //! Reaction order with respect to each reactant species, in the order - //! given by #reactants. Usually the same as the stoichiometric coefficients. - /*! - * Length is equal to the number of reactants defined in the reaction - * The order of species is given by the reactants vectors. - */ - vector_fp rorder; - - //! Reaction order of the reverse reaction with respect to each product - //! species, in the order given by #products. Usually the same as the stoichiometric coefficients. - /*! - * Length is equal to the number of products defined in the reaction. - * The order of species is given by the products vectors. - */ - vector_fp porder; - - //! Reaction order for the forward direction of the reaction - /*! - * Length is equal to the number of kinetic species defined in the kinetics object - * The order of species is given by kinetics species vector. - */ - vector_fp forwardFullOrder_; - - //! Reactant stoichiometric coefficients, in the order given by #reactants. - /*! - * Length is equal to the number of products defined in the reaction. - * The order of species is given by the products vectors. - */ - vector_fp rstoich; - - //! Product stoichiometric coefficients, in the order given by #products. - /*! - * Length is equal to the number of products defined in the reaction. - * The order of species is given by the products vectors. - */ - vector_fp pstoich; - - std::vector rgroups; //!< Optional data used in reaction path diagrams - std::vector pgroups; //!< Optional data used in reaction path diagrams - - //! Map of species index to third body efficiency - std::map thirdBodyEfficiencies; - - //! Net stoichiometric coefficients for participating species. Used for - //! duplicate reaction detection. Key is `-1-k` for reactants, `1+k` for - //! products. - std::map net_stoich; - - //! Film Resistivity value - /*! - * Only valid for Butler-Volmer formulations. - * Units are in ohms m2. - * default = 0.0 ohms m2 - */ - doublereal filmResistivity; - - //! Power of the equilibrium constant within the Affinity representation - /*! - * Only valid for Affinity representation. - * default = 1.0 - */ - doublereal equilibriumConstantPower; - - //! Power of the "One minus Affinity" term within the Affinity representation - /*! - * Only value for Affinity representation - * default = 1.0 - */ - doublereal affinityPower; - - //! True if the current reaction is reversible. False otherwise - bool reversible; - - //! True if the current reaction is marked as duplicate - bool duplicate; - - //! Type of the rate coefficient for the forward rate constant - /*! - * The valid types are listed in the file, reaction_defs.h and they - * all end in RATECOEFF_TYPE - */ - int rateCoeffType; - - //! Vector of rate coefficient parameters. For elementary reactions, these - //! are the pre- exponential factor, temperature exponent, and activation - //! energy in the Arrhenius expression. - vector_fp rateCoeffParameters; - - //! Vector of auxiliary rate coefficient parameters. This is used for - //! the alternate Arrhenius parameters used in falloff and chemically - //! activated reactions. - vector_fp auxRateCoeffParameters; - - //! Type of falloff parameterization to use. Values are defined in - //! reaction_defs.h, with names ending in `FALLOFF`. - int falloffType; - - //! Values used in the falloff parameterization. Meaning of each parameter - //! depends on #falloffType. - vector_fp falloffParameters; - - int error; //!< @deprecated unused. To be removed after Cantera 2.2. - - //! The reaction equation. Used only for display purposes. - std::string equation; - - //! The reactants half of the reaction equation, used for display purposes. - std::string reactantString; - - //! The products half of the reaction equation, used for display purposes. - std::string productString; - - //! The default third body efficiency for species not listed in - //! #thirdBodyEfficiencies. - doublereal default_3b_eff; - - //! Adjustments to the Arrhenius rate expression dependent on surface - //! species coverages. Contains 4 elements for each coverage dependency: - //! the species index, and the three coverage parameters (a, E, m). See - //! SurfaceArrhenius for details on the parameterization. - vector_fp cov; - - //! True for "global" reactions which do not follow elementary mass action - //! kinetics, i.e. reactions for which the reaction order is not given by - //! the stoichiometric coefficients. - bool global; - - //! Some reactions can be elementary reactions but have fractional - //! stoichiometries with respect to some products and reactants. An - //! example of these are solid reactions involving phase transformations. - //! Species with fractional stoichiometries must be from single-species - //! phases with unity activities. - bool isReversibleWithFrac; - - //! Forward value of the apparent Electrochemical transfer coefficient - doublereal beta; - - //! Arrhenius parameters for P-log reactions. - //! The keys are the pressures corresponding to each Arrhenius expression. - //! Multiple sets of Arrhenius parameters may be specified at a given - //! pressure. - std::multimap plogParameters; - - double chebTmin; //!< Minimum temperature for Chebyshev fit - double chebTmax; //!< Maximum temperature for Chebyshev fit - double chebPmin; //!< Minimum pressure for Chebyshev fit - double chebPmax; //!< Maximum pressure for Chebyshev fit - size_t chebDegreeT; //!< Degree of Chebyshev fit in T - size_t chebDegreeP; //!< Degree of Chebyshev fit in P - - //! Chebyshev coefficients. length chebDegreeT * chebDegreeP - vector_fp chebCoeffs; - - //! Get the actual third-body efficiency for species *k* - double efficiency(size_t k) const { - return getValue(thirdBodyEfficiencies, k, default_3b_eff); - } -}; -} - -#endif diff --git a/include/cantera/kinetics/ReactionStoichMgr.h b/include/cantera/kinetics/ReactionStoichMgr.h deleted file mode 100644 index 37f4db676..000000000 --- a/include/cantera/kinetics/ReactionStoichMgr.h +++ /dev/null @@ -1,223 +0,0 @@ -/** - * @file ReactionStoichMgr.h - * - * Header file declaring class ReactionStoichMgr. - */ -#ifndef CT_RXN_STOICH -#define CT_RXN_STOICH - -#include "cantera/kinetics/StoichManager.h" - -namespace Cantera -{ - -class ReactionData; -class Reaction; - -/** - * Reaction mechanism stoichiometry manager. This is an internal class used - * by kinetics manager classes, and is not meant for direct use in - * user programs. - * - * Class ReactionStoichMgr handles the calculation of quantities involving - * the stoichiometry of a set of reactions. The reactions may have integer - * or non-integer stoichiometric coefficients. Specifically, its methods compute - * - species creation rates - * - species destruction rates - * - species net production rates - * - the change in molar species properties in the reactions - * - concentration products - * - * To use this class, method add() is first used to add each reaction. - * Once all reactions have been added, the methods that compute various - * quantities may be called. - * - * The nomenclature used below to document the methods is as follows. - * - * - \f$ N_r \f$ - * Integer reactant stoichiometric coefficient matrix. The (k,i) - * element of this matrix is the stoichiometric coefficient of - * species \e k as a reactant in reaction \e i. - * - \f$ N_p \f$ - * Integer product stoichiometric coefficient matrix. The (k,i) - * element of this matrix is the stoichiometric coefficient of - * species \e k as a product in reaction \e i. - * - \f$ Q_{\rm fwd} \f$ - * Vector of length I of forward rates of progress. - * - \f$ Q_{\rm rev} \f$ - * Vector of length I of reverse rates of progress. - * - \f$ C \f$ - * Vector of K species creation rates. - * - \f$ D \f$ - * Vector of K species destruction rates. - * - \f$ W = C - D \f$ - * Vector of K species net production rates. - * @deprecated Unused; Functionality merged into class Kinetics. To be removed - * after Cantera 2.2. - */ -class ReactionStoichMgr -{ -public: - /// Constructor. - ReactionStoichMgr(); - - /// Destructor. - virtual ~ReactionStoichMgr() {} - - ReactionStoichMgr(const ReactionStoichMgr& right); - - ReactionStoichMgr& operator=(const ReactionStoichMgr& right); - - - //! Add a reaction with mass-action kinetics. - /*!Vectors - * 'reactants' and 'products' contain the integer species - * indices of the reactants and products, respectively. Note - * that if more than one molecule of a given species is - * involved in the reaction, then its index is repeated. - * - * For example, suppose a reaction mechanism involves the - * species N2, O2, O, N, NO. N2 is assigned index number 0, O2 - * number 1, and so on through NO with number 4. Then the - * representation of the following reactions is as shown here. - * - * - N + O = NO - * - reactants: (3, 2) - * - products: (4) - * - * - O + O = O2 - * - reactants: (2, 2) [ note repeated index ] - * - products: (1) - * - * @param rxn Reaction number. This number will be used as the index - * into the rate of progress vector in the methods below. - * @param reactants Vector of integer reactant indices - * @param products Vector of integer product indices - * @param reversible True if the reaction is reversible, false otherwise - */ - virtual void add(size_t rxn, const std::vector& reactants, - const std::vector& products, bool reversible); - - /** - * Add a reaction with specified, possibly non-integral, reaction orders. - * @param rxn Reaction number - * @param r Data structure containing reactant and product vectors, etc. - */ - virtual void add(size_t rxn, const ReactionData& r); - - /** - * Species creation rates. Given the arrays of the forward and reverse - * rates of progress for all reactions, compute the species creation - * rates, given by - * \f[ - * C = N_p Q_f + N_r Q_r. - * \f] - */ - virtual void getCreationRates(size_t nSpecies, - const doublereal* fwdRatesOfProgress, - const doublereal* revRatesOfProgress, - doublereal* creationRates); - - /** - * Species destruction rates. Given the arrays of the forward and reverse - * rates of progress for all reactions, compute the species destruction - * rates, given by - * \f[ - * D = N_r Q_f + N_p Q_r, - * \f] - * Note that the stoichiometric coefficient matrices are very sparse, integer - * matrices. - */ - virtual void getDestructionRates(size_t nSpecies, - const doublereal* fwdRatesOfProgress, - const doublereal* revRatesOfProgress, - doublereal* destructionRates); - - /** - * Species net production rates. Given the array of the net rates of - * progress for all reactions, compute the species net production rates, - * given by - * \f[ - * W = (N_r - N_p) Q_{\rm net}, - * \f] - */ - virtual void getNetProductionRates(size_t nsp, const doublereal* ropnet, doublereal* w); - - //! Calculates the change of a molar species property in a reaction. - /*! - * Given an array of species properties 'g', return in array 'dg' the - * change in this quantity in the reactions. Array 'g' must have a length - * at least as great as the number of species, and array 'dg' must have a - * length as great as the total number of reactions. - * \f[ - * \delta g_i = \sum_k{\nu_{i,k} g_k } - * \f] - * - * @param nReactions Number of reactions - * @param g Molar property of the species. - * An example would be the partial molar enthalpy - * Length is equal to number of kinetic species - * @param dg Calculated property change of the reaction. - * An example would be the delta change in enthalpy, - * i.e., the enthalpy of reaction. - */ - virtual void getReactionDelta(size_t nReactions, - const doublereal* g, - doublereal* dg); - - /** - * Given an array of species properties 'g', return in array 'dg' the - * change in this quantity in the reversible reactions. Array 'g' must - * have a length at least as great as the number of species, and array - * 'dg' must have a length as great as the total number of reactions. - * This method only computes 'dg' for the reversible reactions, and the - * entries of 'dg' for the irreversible reactions are unaltered. This is - * primarily designed for use in calculating reverse rate coefficients - * from thermochemistry for reversible reactions. - */ - virtual void getRevReactionDelta(size_t nr, const doublereal* g, doublereal* dg); - - /** - * Given an array of concentrations C, multiply the entries in array R by - * the concentration products for the reactants. - * \f[ - * R_i = R_i * \prod_k C_k^{o_{k,i}} - * \f] - * - * Here \f$ o_{k,i} \f$ is the reaction order of species k in reaction i. - */ - virtual void multiplyReactants(const doublereal* C, doublereal* R); - - /** - * Given an array of concentrations C, multiply the entries in array R by - * the concentration products for the products. - * \f[ - * R_i = R_i * \prod_k C_k^{\nu^{(p)}_{k,i}} - * \f] - * Here \f$ \nu^{(p)}_{k,i} \f$ is the product stoichiometric coefficient - * of species k in reaction i. - */ - virtual void multiplyRevProducts(const doublereal* c, doublereal* r); - - //! @deprecated To be removed after Cantera 2.2 - virtual void write(const std::string& filename); - -protected: - //! @deprecated To be removed after Cantera 2.2 - void writeCreationRates(std::ostream& f); - //! @deprecated To be removed after Cantera 2.2 - void writeDestructionRates(std::ostream& f); - //! @deprecated To be removed after Cantera 2.2 - void writeNetProductionRates(std::ostream& f); - //! @deprecated To be removed after Cantera 2.2 - void writeMultiplyReactants(std::ostream& f); - //! @deprecated To be removed after Cantera 2.2 - void writeMultiplyRevProducts(std::ostream& f); - StoichManagerN m_reactants; - StoichManagerN m_revproducts; - StoichManagerN m_irrevproducts; - vector_fp m_dummy; -}; -} - -#endif diff --git a/include/cantera/kinetics/RxnRates.h b/include/cantera/kinetics/RxnRates.h index b4bb477b1..5841ac960 100644 --- a/include/cantera/kinetics/RxnRates.h +++ b/include/cantera/kinetics/RxnRates.h @@ -8,7 +8,7 @@ #ifndef CT_RXNRATES_H #define CT_RXNRATES_H -#include "ReactionData.h" +#include "cantera/kinetics/reaction_defs.h" #include "cantera/base/ctexceptions.h" #include "cantera/base/stringUtils.h" @@ -39,9 +39,6 @@ public: //! Default constructor. Arrhenius(); - //! Constructor from ReactionData. - explicit Arrhenius(const ReactionData& rdata); - /// Constructor. /// @param A pre-exponential. The unit system is /// (kmol, m, s). The actual units depend on the reaction @@ -152,7 +149,6 @@ public: SurfaceArrhenius(); explicit SurfaceArrhenius(double A, double b, double Ta); - explicit SurfaceArrhenius(const ReactionData& rdata); //! Add a coverage dependency for species *k*, with pre-exponential //! dependence *a*, temperature exponent dependence *m* and activation @@ -223,97 +219,6 @@ protected: }; -//! Arrhenius reaction rate type depends only on temperature -/** - * A reaction rate coefficient of the following form. - * - * \f[ - * k_f = A T^b \exp (-E/RT) - * \f] - * - * @deprecated Duplicate of class Arrhenius. To be removed after Cantera 2.2. - */ -class ExchangeCurrent -{ -public: - - //! return the rate coefficient type. - static int type() { - return EXCHANGE_CURRENT_REACTION_RATECOEFF_TYPE; - } - - //! Default constructor. - ExchangeCurrent(); - - //! Constructor with Arrhenius parameters from a ReactionData struct. - explicit ExchangeCurrent(const ReactionData& rdata); - - /// Constructor. - /// @param A pre-exponential. The unit system is - /// (kmol, m, s). The actual units depend on the reaction - /// order and the dimensionality (surface or bulk). - /// @param b Temperature exponent. Non-dimensional. - /// @param E Activation energy in temperature units. Kelvin. - ExchangeCurrent(doublereal A, doublereal b, doublereal E); - - //! Update concentration-dependent parts of the rate coefficient. - /*! - * For this class, there are no - * concentration-dependent parts, so this method does nothing. - */ - void update_C(const doublereal* c) { - } - - /** - * Update the value of the logarithm of the rate constant. - * - * Note, this function should never be called for negative A values. - * If it does then it will produce a negative overflow result, and - * a zero net forwards reaction rate, instead of a negative reaction - * rate constant that is the expected result. - * @deprecated. To be removed after Cantera 2.2 - */ - doublereal update(doublereal logT, doublereal recipT) const { - return m_logA + m_b*logT - m_E*recipT; - } - - /** - * Update the value the rate constant. - * - * This function returns the actual value of the rate constant. - * It can be safely called for negative values of the pre-exponential - * factor. - */ - doublereal updateRC(doublereal logT, doublereal recipT) const { - return m_A * std::exp(m_b*logT - m_E*recipT); - } - - //! @deprecated. To be removed after Cantera 2.2 - void writeUpdateRHS(std::ostream& s) const { - s << " exp(" << m_logA; - if (m_b != 0.0) { - s << " + " << m_b << " * tlog"; - } - if (m_E != 0.0) { - s << " - " << m_E << " * rt"; - } - s << ");" << std::endl; - } - - //! @deprecated. To be removed after Cantera 2.2 - doublereal activationEnergy_R() const { - return m_E; - } - - //! @deprecated. To be removed after Cantera 2.2 - static bool alwaysComputeRate() { - return false; - } - -protected: - doublereal m_logA, m_b, m_E, m_A; -}; - //! Pressure-dependent reaction rate expressed by logarithmically interpolating //! between Arrhenius rate expressions at various pressures. class Plog @@ -327,9 +232,6 @@ public: //! Default constructor. Plog() {} - //! Constructor from ReactionData. - explicit Plog(const ReactionData& rdata); - //! Constructor from Arrhenius rate expressions at a set of pressures explicit Plog(const std::multimap& rates); @@ -451,9 +353,6 @@ public: //! Default constructor. ChebyshevRate() {} - //! Constructor from ReactionData. - explicit ChebyshevRate(const ReactionData& rdata); - //! Constructor directly from coefficient array /* * @param Tmin Minimum temperature [K] diff --git a/include/cantera/kinetics/StoichManager.h b/include/cantera/kinetics/StoichManager.h index 34f20afd7..8ddcd533a 100644 --- a/include/cantera/kinetics/StoichManager.h +++ b/include/cantera/kinetics/StoichManager.h @@ -670,7 +670,7 @@ inline static void _writeMultiply(InputIter begin, InputIter end, * This class handles operations involving the stoichiometric * coefficients on one side of a reaction (reactant or product) for * a set of reactions comprising a reaction mechanism. This class is - * used by class ReactionStoichMgr, which contains three instances + * used by class Kinetics, which contains three instances * of this class (one to handle operations on the reactions, one for * the products of reversible reactions, and one for the products of * irreversible reactions). diff --git a/include/cantera/kinetics/ThirdBodyMgr.h b/include/cantera/kinetics/ThirdBodyMgr.h deleted file mode 100644 index ed3f8d147..000000000 --- a/include/cantera/kinetics/ThirdBodyMgr.h +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @file ThirdBodyMgr.h - */ - -// Copyright 2001 California Institute of Technology - - -#ifndef CT_THIRDBODY_MGR_H -#define CT_THIRDBODY_MGR_H - -#include "cantera/base/utilities.h" -#include "Enhanced3BConc.h" - - -namespace Cantera -{ - -//! @deprecated Replaced by ThirdBodyCalc. To be removed after Cantera 2.2. -template -class ThirdBodyMgr -{ - -public: - ThirdBodyMgr() { - warn_deprecated("class ThirdBodyMgr", "To be removed after Cantera 2.2."); - } - - void install(size_t rxnNumber, const std::map& enhanced, - doublereal dflt=1.0) { - m_reaction_index.push_back(rxnNumber); - m_concm.push_back(_E(enhanced, dflt)); - } - - void update(const vector_fp& conc, doublereal ctot, doublereal* work) { - typename std::vector<_E>::const_iterator b = m_concm.begin(); - for (; b != m_concm.end(); ++b, ++work) { - *work = b->update(conc, ctot); - } - } - - void multiply(doublereal* output, const doublereal* work) { - scatter_mult(work, work + m_reaction_index.size(), - output, m_reaction_index.begin()); - } - - size_t workSize() { - return m_concm.size(); - } - bool contains(int rxnNumber) { - return (find(m_reaction_index.begin(), - m_reaction_index.end(), rxnNumber) - != m_reaction_index.end()); - } - -protected: - std::vector m_reaction_index; - std::vector<_E> m_concm; -}; - -} - -#endif diff --git a/include/cantera/kinetics/importKinetics.h b/include/cantera/kinetics/importKinetics.h index 40cd36932..78b726e23 100644 --- a/include/cantera/kinetics/importKinetics.h +++ b/include/cantera/kinetics/importKinetics.h @@ -28,91 +28,6 @@ struct ReactionRules { bool allowNegativeA; }; -//!This function returns a ratio if two reactions are duplicates of -//!one another, and 0.0 otherwise. -/*! - * The input arguments are two maps from species number to stoichiometric - * coefficient, one for each reaction. The reactions are considered duplicates - * if their stoichiometric coefficients have the same ratio for all species. - * - * @param r1 map 1 - * @param r2 map 2 - * - * @return - * Returns 0.0 if the reactions are not the same. - * If the reactions are the same, it returns the ratio of the - * stoichiometric coefficients. - * - * @ingroup kineticsmgr - * @deprecated Now handled by Kinetics::checkDuplicateStoich. To be removed - * after Cantera 2.2. - */ -doublereal isDuplicateReaction(std::map& r1, - std::map& r2); - -//! This function will check a specific reaction to see if the elements balance. -/*! - * @param kin Kinetics object - * @param rdata Object containing the information about one reaction - * @param errorTolerance double containing the error tolerance. - * - * @ingroup kineticsmgr - * @deprecated Now handled by Kinetics::checkReactionBalance. To be removed - * after Cantera 2.2. - */ -void checkRxnElementBalance(Kinetics& kin, - const ReactionData& rdata, - doublereal errorTolerance = 1.0e-3); - -/** - * Get the reactants or products of a reaction. The information is returned in - * the spnum, stoich, and order vectors. The length of the vectors is the - * number of different types of reactants or products found for the reaction. - * - * @param[in] rxn XML node pointing to the reaction element in the XML tree. - * @param[in] kin Reference to the kinetics object to install the information - * into. - * @param[in] rp 1 -> Go get the reactants for a reaction; -1 -> Go get the - * products for a reaction - * @param[in] default_phase Name for the default phase to loop up species in. - * @param[out] spnum vector of species numbers found. Length is number of - * reactants or products. - * @param[out] stoich stoichiometric coefficient of the reactant or product. - * Length is number of reactants or products. - * @param[out] order Order of the reactant and product in the reaction rate - * expression. - * @param[in] rules If rules.skipUndeclaredSpecies is set and we fail to find - * a species we simply return false, allowing the calling - * routine to skip this reaction and continue. Otherwise, we - * will throw an error. - * @deprecated Now handled through newReaction() and its support functions. To - * be removed after Cantera 2.2. - */ -bool getReagents(const XML_Node& rxn, Kinetics& kin, int rp, std::string default_phase, - std::vector& spnum, vector_fp& stoich, - vector_fp& order, const ReactionRules& rules); - -//! Read the rate coefficient data from the XML file. -/*! - * Extract the rate coefficient for a reaction from the XML node, kf. - * kf should point to a XML element named "rateCoeff". - * rdata is the partially filled ReactionData object for the reaction. - * This function will fill in more fields in the ReactionData object. - * - * @param kf XML_Node containing information about the rate coefficients. - * @param kin kinetics manager - * @param rdata ReactionData reference - * @param rules Rules for parsing and installing reactions - * - * Trigger an exception for negative A unless specifically authorized. - * - * @deprecated Now handled through newReaction() and its support functions. To - * be removed after Cantera 2.2. - * - * @ingroup kineticsmgr - */ -void getRateCoefficient(const XML_Node& kf, Kinetics& kin, ReactionData& rdata, - const ReactionRules& rules); //! Install information about reactions into the kinetics object, kin. /*! diff --git a/include/cantera/thermo/AdsorbateThermo.h b/include/cantera/thermo/AdsorbateThermo.h index 0a8aca488..467e086f3 100644 --- a/include/cantera/thermo/AdsorbateThermo.h +++ b/include/cantera/thermo/AdsorbateThermo.h @@ -35,25 +35,6 @@ public: m_nFreqs(0) { } - //! Full Constructor - /*! - * @param n Species index - * @param tlow output - Minimum temperature - * @param thigh output - Maximum temperature - * @param pref output - reference pressure (Pa). - * @deprecated Use the constructor which does not require the species index. - * To be removed after Cantera 2.2. - */ - Adsorbate(size_t n, doublereal tlow, doublereal thigh, doublereal pref, - const doublereal* coeffs) - : SpeciesThermoInterpType(n, tlow, thigh, pref) - { - m_nFreqs = int(coeffs[0]); - m_be = coeffs[1]; - m_freq.resize(m_nFreqs); - std::copy(coeffs+2, coeffs + 2 + m_nFreqs, m_freq.begin()); - } - //! Full Constructor /*! * @param tlow output - Minimum temperature @@ -82,17 +63,16 @@ public: doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const { - h_RT[m_index] = _energy_RT(temp); - cp_R[m_index] = (temp*h_RT[m_index] - - (temp-0.01)*_energy_RT(temp-0.01))/0.01; - s_R[m_index] = h_RT[m_index] - _free_energy_RT(temp); + *h_RT = _energy_RT(temp); + *cp_R = (temp**h_RT - (temp-0.01)*_energy_RT(temp-0.01))/0.01; + *s_R = *h_RT - _free_energy_RT(temp); } void reportParameters(size_t& n, int& type, doublereal& tlow, doublereal& thigh, doublereal& pref, doublereal* const coeffs) const { - n = m_index; + n = 0; type = ADSORBATE; tlow = m_lowT; thigh = m_highT; diff --git a/include/cantera/thermo/ConstCpPoly.h b/include/cantera/thermo/ConstCpPoly.h index 7deb788a1..a94a80ceb 100644 --- a/include/cantera/thermo/ConstCpPoly.h +++ b/include/cantera/thermo/ConstCpPoly.h @@ -38,10 +38,6 @@ namespace Cantera * - c[2] = \f$ S_k^o(T_0, p_{ref}) \f$ (J/kmol K) * - c[3] = \f$ {Cp}_k^o(T_0, p_{ref}) \f$ (J(kmol K) * - * The multispecies SimpleThermo class makes the same assumptions as - * this class does. - * - * @see SimpleThermo * @ingroup spthermo */ class ConstCpPoly: public SpeciesThermoInterpType @@ -50,26 +46,6 @@ public: //! empty constructor ConstCpPoly(); - //! Constructor used in templated instantiations - /*! - * @param n Species index - * @param tlow Minimum temperature - * @param thigh Maximum temperature - * @param pref reference pressure (Pa). - * @param coeffs Vector of coefficients used to set the - * parameters for the standard state for species n. - * There are 4 coefficients for the ConstCpPoly parameterization. - * - c[0] = \f$ T_0 \f$(Kelvin) - * - c[1] = \f$ H_k^o(T_0, p_{ref}) \f$ (J/kmol) - * - c[2] = \f$ S_k^o(T_0, p_{ref}) \f$ (J/kmol K) - * - c[3] = \f$ {Cp}_k^o(T_0, p_{ref}) \f$ (J(kmol K) - * @deprecated Use the constructor which does not take the species index. To - * be removed after Cantera 2.2. - */ - ConstCpPoly(size_t n, doublereal tlow, doublereal thigh, - doublereal pref, - const doublereal* coeffs); - //! Normal constructor /*! * @param tlow Minimum temperature diff --git a/include/cantera/thermo/Elements.h b/include/cantera/thermo/Elements.h index 643b64133..1e38797f3 100644 --- a/include/cantera/thermo/Elements.h +++ b/include/cantera/thermo/Elements.h @@ -95,326 +95,6 @@ namespace Cantera //! @exception CanteraError If a match is not found, throws a CanteraError double LookupWtElements(const std::string& ename); -class XML_Node; - -//! Object containing the elements that make up species in a phase. -/*! - * Class Elements manages the elements that are part of a - * chemistry specification. This class may support calculations - * employing Multiple phases. In this case, a single Elements object may - * be shared by more than one Constituents class. Reactions between - * the phases may then be described using stoichiometry base on the - * same Elements class object. - * - * The member functions return information about the elements described - * in a particular instantiation of the class. - * - * @ingroup phases - * @deprecated. Functionality is now part of class Phase. To be removed after - * Cantera 2.2. - */ -class Elements -{ - -public: - - //! Default constructor for the elements class - Elements(); - - //! Default destructor for the elements class - ~Elements(); - - - //! copy constructor - /*! - * This copy constructor just calls the assignment operator for this - * class. It sets the number of subscribers to zer0. - * - * @param right Reference to the object to be copied. - */ - Elements(const Elements& right); - - //! Assignment operator - /*! - * This is the assignment operator for the Elements class. - * Right now we pretty much do a straight uncomplicated - * assignment. However, subscribers are not mucked with, as they - * have to do with the address of the object to be subscribed to - * - * @param right Reference to the object to be copied. - */ - Elements& operator=(const Elements& right); - - - //! Static function to look up an atomic weight - /*! - * This static function looks up the argument string in the - * database above and returns the associated molecular weight. - * The data are from the periodic table. - * - * Note: The idea behind this function is to provide a unified - * source for the element atomic weights. This helps to - * ensure that mass is conserved. - * - * @param ename String, Only the first 3 characters are significant - * - * @return - * Return value contains the atomic weight of the element - * If a match for the string is not found, a value of -1.0 is - * returned. - * - * @exception CanteraError - * If a match is not found, a CanteraError is thrown as well - */ - static double LookupWtElements(const std::string& ename); - /// Atomic weight of element m. - /*! - * @param m element index - */ - doublereal atomicWeight(int m) const { - return m_atomicWeights[m]; - } - - /// Atomic number of element m. - /*! - * @param m element index - */ - int atomicNumber(int m) const { - return m_atomicNumbers[m]; - } - - //! Entropy at 298.15 K and 1 bar of stable state - //! of the element - /*! - * units J kmol-1 K-1 - * - * @param m Element index - */ - doublereal entropyElement298(int m) const; - - //! Return the element constraint type - /*! - * Possible types include: - * - * CT_ELEM_TYPE_ABSPOS 0 - * CT_ELEM_TYPE_ELECTRONCHARGE 1 - * CT_ELEM_TYPE_CHARGENEUTRALITY 2 - * CT_ELEM_TYPE_LATTICERATIO 3 - * CT_ELEM_TYPE_KINETICFROZEN 4 - * CT_ELEM_TYPE_SURFACECONSTRAINT 5 - * CT_ELEM_TYPE_OTHERCONSTRAINT 6 - * - * The default is CT_ELEM_TYPE_ABSPOS - * - * @param m Element index - * - * @return Returns the element type - */ - int elementType(int m) const; - - //! Change the element type of the mth constraint - /*! - * Reassigns an element type - * - * @param m Element index - * @param elem_type New elem type to be assigned - * - * @return Returns the old element type - */ - int changeElementType(int m, int elem_type); - - /// vector of element atomic weights - const vector_fp& atomicWeights() const { - return m_atomicWeights; - } - /** - * Inline function that returns the number of elements in the object. - * - * @return - * \c int: The number of elements in the object. - */ - int nElements() const { - return m_mm; - } - - //! Function that returns the index of an element. - /*! - * Index of element named \c name. The index is an integer - * assigned to each element in the order it was added, - * beginning with 0 for the first element. If \c name is not - * the name of an element in the set, then the value -1 is - * returned. - * - * @param name String containing the index. - */ - int elementIndex(const std::string& name) const; - - //! Name of the element with index \c m. - /*! - * @param m Element index. If m < 0 or m >= nElements() an exception is thrown. - */ - std::string elementName(int m) const; - - //! Returns a string vector containing the element names - /*! - * Returns a read-only reference to the vector of element names. - * @return const vector& : The vector contains - * the element names in their indexed order. - */ - const std::vector& elementNames() const { - return m_elementNames; - } - - //! Add an element to the current set of elements in the current object. - /*! - * The default weight is a special value, which will cause the - * routine to look up the actual weight via a string lookup. - * - * There are two interfaces to this routine. The XML interface - * looks up the required parameters for the regular interface - * and then calls the base routine. - * - * @param symbol string symbol for the element. - * @param weight Atomic weight of the element. If no argument - * is provided, a lookup is attempted. - */ - void addElement(const std::string& symbol, - doublereal weight = -12345.0); - //! Add an element to the current set of elements in the current object. - /*! - * @param e Reference to the XML_Node containing the element information - * The node name is the element symbol and the atomWt attribute - * is used as the atomic weight. - */ - void addElement(const XML_Node& e); - - //! Add an element only if the element hasn't been added before. - /*! - * This is accomplished via a string match on symbol. - * - * @param symbol string symbol for the element. - * @param weight Atomic weight of the element. If no argument - * is provided, a lookup is attempted. - * @param atomicNumber defaults to 0 - * @param entropy298 Value of the entropy at 298 and 1 bar of the - * element in its most stable form. - * The default is to specify an ENTROPY298_UNKNOWN value, - * which will cause a throw error if its ever - * needed. - * @param elem_type New elem type to be assigned. - * The default is a regular element, CT_ELEM_TYPE_ABSPOS - */ - void addUniqueElement(const std::string& symbol, - doublereal weight = -12345.0, int atomicNumber = 0, - doublereal entropy298 = ENTROPY298_UNKNOWN, int elem_type = CT_ELEM_TYPE_ABSPOS); - - //! Add an element to the current set of elements in the current object. - /*! - * @param e Reference to the XML_Node containing the element information - * The node name is the element symbol and the atomWt attribute - * is used as the atomic weight. - */ - void addUniqueElement(const XML_Node& e); - - //! Add multiple elements from a XML_Node phase description - /*! - * @param phase XML_Node reference to a phase - */ - void addElementsFromXML(const XML_Node& phase); - - //! Prohibit addition of more elements, and prepare to add species. - void freezeElements(); - - //! True if freezeElements has been called. - bool elementsFrozen() const; - - /// Remove all elements - void clear(); - - /// True if both elements and species have been frozen - bool ready() const; - - //! subscribe to this object - /*! - * Increment by one the number of subscriptions to this object. - */ - void subscribe(); - - //! unsubscribe to this object - /*! - * decrement by one the number of subscriptions to this object. - */ - int unsubscribe(); - - //! report the number of subscriptions - int reportSubscriptions() const; - -protected: - - /******************************************************************/ - /* Description of DATA in the Object */ - /******************************************************************/ - - //! Number of elements. - int m_mm; - - /* m_elementsFrozen: */ - /** boolean indicating completion of object - * - * If this is true, then no elements may be added to the - * object. - */ - bool m_elementsFrozen; - - /** - * Vector of element atomic weights: - * - * units = kg / kmol - */ - vector_fp m_atomicWeights; - - /** - * Vector of element atomic numbers: - * - */ - vector_int m_atomicNumbers; - - /** Vector of strings containing the names of the elements - * - * Note, a string search is the primary way to identify elements. - */ - std::vector m_elementNames; - - //! Entropy at 298.15 K and 1 bar of stable state - /*! - * units J kmol-1 - */ - vector_fp m_entropy298; - - //! Vector of element types - vector_int m_elem_type; - /** - * Number of Constituents Objects that use this object - * - * Number of Constituents Objects that require this Elements object - * to complete its definition. - * The destructor checks to see that this is equal to zero. - * when the element object is released. - */ - int numSubscribers; - - /********* GLOBAL STATIC SECTION *************/ - -public: - /** Vector of pointers to Elements Objects - * - */ - static std::vector Global_Elements_List; - - friend class Constituents; -}; - - } // namespace #endif diff --git a/include/cantera/thermo/GeneralSpeciesThermo.h b/include/cantera/thermo/GeneralSpeciesThermo.h index 10fe464f2..28948f456 100644 --- a/include/cantera/thermo/GeneralSpeciesThermo.h +++ b/include/cantera/thermo/GeneralSpeciesThermo.h @@ -9,7 +9,7 @@ #ifndef CT_GENERALSPECIESTHERMO_H #define CT_GENERALSPECIESTHERMO_H -#include "SpeciesThermoMgr.h" +#include "SpeciesThermo.h" #include "SpeciesThermoInterpType.h" namespace Cantera @@ -45,39 +45,6 @@ public: virtual SpeciesThermo* duplMyselfAsSpeciesThermo() const ; - //! Install a new species thermodynamic property - //! parameterization for one species. - /*! - * Install a SpeciesThermoInterpType object for the species, index. - * This routine contains an internal list of SpeciesThermoInterpType - * objects that it knows about. A factory-type lookup is done - * to create the object. - * - * @param name Name of the species - * @param index The 'update' method will update the property - * values for this species - * at position i index in the property arrays. - * @param type int flag specifying the type of parameterization to be - * installed. - * @param c vector of coefficients for the parameterization. - * This vector is simply passed through to the - * parameterization constructor. Its length depends upon - * the parameterization. - * @param minTemp minimum temperature for which this parameterization - * is valid. - * @param maxTemp maximum temperature for which this parameterization - * is valid. - * @param refPressure standard-state pressure for this parameterization. - * @see speciesThermoTypes.h - * - * @deprecated Use newSpeciesThermoInterpType and - * GeneralSpeciesThermo::install_STIT. To be removed after Cantera 2.2. - */ - virtual void install(const std::string& name, size_t index, int type, - const doublereal* c, - doublereal minTemp, doublereal maxTemp, - doublereal refPressure); - virtual void install_STIT(size_t index, shared_ptr stit_ptr); diff --git a/include/cantera/thermo/Mu0Poly.h b/include/cantera/thermo/Mu0Poly.h index 93acb7f51..fd4f5d117 100644 --- a/include/cantera/thermo/Mu0Poly.h +++ b/include/cantera/thermo/Mu0Poly.h @@ -74,37 +74,6 @@ public: //! Constructor Mu0Poly(); - //! Constructor used in templated instantiations - /*! - * In the constructor, we calculate and store the - * piecewise linear approximation to the thermodynamic - * functions. - * - * @param n Species index - * @param tlow Minimum temperature - * @param thigh Maximum temperature - * @param pref reference pressure (Pa). - * @param coeffs Vector of coefficients used to set the - * parameters for the standard state for species n. - * There are \f$ 2+npoints*2 \f$ coefficients, where - * \f$ npoints \f$ are the number of temperature points. - * Their identity is further broken down: - * - coeffs[0] = number of points (integer) - * - coeffs[1] = \f$ h^o(298.15 K) \f$ (J/kmol) - * - coeffs[2] = \f$ T_1 \f$ (Kelvin) - * - coeffs[3] = \f$ \mu^o(T_1) \f$ (J/kmol) - * - coeffs[4] = \f$ T_2 \f$ (Kelvin) - * - coeffs[5] = \f$ \mu^o(T_2) \f$ (J/kmol) - * - coeffs[6] = \f$ T_3 \f$ (Kelvin) - * - coeffs[7] = \f$ \mu^o(T_3) \f$ (J/kmol) - * - ........ - * . - * @deprecated Use the constructor which does not require the species index. - * To be removed after Cantera 2.2. - */ - Mu0Poly(size_t n, doublereal tlow, doublereal thigh, - doublereal pref, const doublereal* coeffs); - //! Normal constructor /*! * In the constructor, we calculate and store the piecewise linear diff --git a/include/cantera/thermo/Nasa9Poly1.h b/include/cantera/thermo/Nasa9Poly1.h index 425e4c7f6..dc9f21324 100644 --- a/include/cantera/thermo/Nasa9Poly1.h +++ b/include/cantera/thermo/Nasa9Poly1.h @@ -74,20 +74,6 @@ public: //! Empty constructor Nasa9Poly1(); - //! constructor used in templated instantiations - /*! - * @param n Species index - * @param tlow Minimum temperature - * @param thigh Maximum temperature - * @param pref reference pressure (Pa). - * @param coeffs Vector of coefficients used to set the - * parameters for the standard state. - * @deprecated Use the constructor whic hdoes not require the species - * index. To be removed after Cantera 2.2. - */ - Nasa9Poly1(size_t n, doublereal tlow, doublereal thigh, doublereal pref, - const doublereal* coeffs); - //! Normal constructor /*! * @param tlow Minimum temperature diff --git a/include/cantera/thermo/Nasa9PolyMultiTempRegion.h b/include/cantera/thermo/Nasa9PolyMultiTempRegion.h index a18c178ab..1c3e4cf07 100644 --- a/include/cantera/thermo/Nasa9PolyMultiTempRegion.h +++ b/include/cantera/thermo/Nasa9PolyMultiTempRegion.h @@ -72,8 +72,6 @@ public: virtual int reportType() const; - virtual void setIndex(size_t index); - virtual size_t temperaturePolySize() const { return 7; } virtual void updateTemperaturePoly(double T, double* T_poly) const; diff --git a/include/cantera/thermo/NasaPoly1.h b/include/cantera/thermo/NasaPoly1.h index de14641f2..ba7aab82a 100644 --- a/include/cantera/thermo/NasaPoly1.h +++ b/include/cantera/thermo/NasaPoly1.h @@ -40,7 +40,6 @@ namespace Cantera + \frac{a_3}{3} T^3 + \frac{a_4}{4} T^4 + a_6. * \f] * - * This class is designed specifically for use by class NasaThermo. * @ingroup spthermo */ class NasaPoly1 : public SpeciesThermoInterpType @@ -50,29 +49,6 @@ public: NasaPoly1() : m_coeff(7, 0.0) {} - //! constructor used in templated instantiations - /*! - * @param n Species index - * @param tlow Minimum temperature - * @param thigh Maximum temperature - * @param pref reference pressure (Pa). - * @param coeffs Vector of coefficients used to set the parameters for the - * standard state, in the order [a5,a6,a0,a1,a2,a3,a4] - * @deprecated Use the constructor which does not take species index. To be - * removed after Cantera 2.2. - */ - NasaPoly1(size_t n, doublereal tlow, doublereal thigh, doublereal pref, - const doublereal* coeffs) : - SpeciesThermoInterpType(n, tlow, thigh, pref), - m_coeff(7) - { - for (size_t i = 0; i < 5; i++) { - m_coeff[i] = coeffs[i+2]; - } - m_coeff[5] = coeffs[0]; - m_coeff[6] = coeffs[1]; - } - //! Normal constructor /*! * @param tlow Minimum temperature @@ -142,11 +118,10 @@ public: s = ct0*tt[5] + ct1 + 0.5*ct2 + 1.0/3.0*ct3 +0.25*ct4 + m_coeff[6]; // last term is a6 - // return the computed properties in the location in the output - // arrays for this species - cp_R[m_index] = cp; - h_RT[m_index] = h; - s_R[m_index] = s; + // return the computed properties for this species + *cp_R = cp; + *h_RT = h; + *s_R = s; //writelog("NASA1: for species "+int2str(m_index)+", h_RT = "+ // fp2str(h)+"\n"); } @@ -163,7 +138,7 @@ public: doublereal& tlow, doublereal& thigh, doublereal& pref, doublereal* const coeffs) const { - n = m_index; + n = 0; type = NASA1; tlow = m_lowT; thigh = m_highT; @@ -195,15 +170,12 @@ public: double h = h_RT * GasConstant * temp; if (h298) { - h298[m_index] = h; + *h298 = h; } return h; } virtual void modifyOneHf298(const size_t k, const doublereal Hf298New) { - if (k != m_index) { - return; - } double hcurr = reportHf298(0); double delH = Hf298New - hcurr; m_coeff[5] += (delH) / GasConstant; diff --git a/include/cantera/thermo/NasaPoly2.h b/include/cantera/thermo/NasaPoly2.h index 338726202..29b720940 100644 --- a/include/cantera/thermo/NasaPoly2.h +++ b/include/cantera/thermo/NasaPoly2.h @@ -54,26 +54,6 @@ public: m_coeff(15, 0.0) { } - //! Full Constructor - /*! - * @param n Species index - * @param tlow output - Minimum temperature - * @param thigh output - Maximum temperature - * @param pref output - reference pressure (Pa). - * @param coeffs Vector of coefficients used to set the parameters for - * the standard state [Tmid, 7 low-T coeffs, 7 high-T coeffs] - * @deprecated Use constructor without species index. To be removed after - * Cantera 2.2. - */ - NasaPoly2(size_t n, doublereal tlow, doublereal thigh, doublereal pref, - const doublereal* coeffs) : - SpeciesThermoInterpType(n, tlow, thigh, pref), - m_midT(coeffs[0]), - mnp_low(n, tlow, coeffs[0], pref, coeffs +1), - mnp_high(n, tlow, thigh, pref, coeffs + 8), - m_coeff(coeffs, coeffs + 15) { - } - //! Full Constructor /*! * @param tlow output - Minimum temperature @@ -103,12 +83,6 @@ public: return NASA2; } - virtual void setIndex(size_t index) { - SpeciesThermoInterpType::setIndex(index); - mnp_low.setIndex(index); - mnp_high.setIndex(index); - } - virtual size_t temperaturePolySize() const { return 6; } virtual void updateTemperaturePoly(double T, double* T_poly) const { @@ -159,7 +133,7 @@ public: doublereal& tlow, doublereal& thigh, doublereal& pref, doublereal* const coeffs) const { - n = m_index; + n = 0; type = NASA2; tlow = m_lowT; thigh = m_highT; @@ -177,16 +151,12 @@ public: h = mnp_high.reportHf298(0); } if (h298) { - h298[m_index] = h; + *h298 = h; } return h; } void modifyOneHf298(const size_t k, const doublereal Hf298New) { - if (k != m_index) { - return; - } - doublereal h298now = reportHf298(0); doublereal delH = Hf298New - h298now; double h = mnp_low.reportHf298(0); diff --git a/include/cantera/thermo/Phase.h b/include/cantera/thermo/Phase.h index d8cb64b93..77e8ced47 100644 --- a/include/cantera/thermo/Phase.h +++ b/include/cantera/thermo/Phase.h @@ -415,13 +415,6 @@ public: /// @name Composition //@{ - //! Get the mole fractions by name. - //! @param[out] x composition map containing the species mole fractions. - //! @deprecated To be removed after Cantera 2.2. use - //! `compositionMap getMoleFractionsByName(double threshold)` - //! instead. - void getMoleFractionsByName(compositionMap& x) const; - //! Get the mole fractions by name. //! @param threshold Exclude species with mole fractions less than or //! equal to this threshold. @@ -698,90 +691,11 @@ public: int atomicNumber=0, doublereal entropy298=ENTROPY298_UNKNOWN, int elem_type=CT_ELEM_TYPE_ABSPOS); - //! Add an element from an XML specification. - //! @param e Reference to the XML_Node where the element is described. - //! @deprecated. To be removed after Cantera 2.2. - void addElement(const XML_Node& e); - - //! Add an element, checking for uniqueness - //! The uniqueness is checked by comparing the string symbol. If not - //! unique, nothing is done. - //! @param symbol String symbol of the element - //! @param weight Atomic weight of the element (kg kmol-1). - //! @param atomicNumber Atomic number of the element (unitless) - //! @param entropy298 Entropy of the element at 298 K and 1 bar in its - //! most stable form. The default is the value ENTROPY298_UNKNOWN, which is - //! interpreted as an unknown, and if used will cause %Cantera to throw an - //! error. - //! @param elem_type Specifies the type of the element constraint - //! equation. This defaults to CT_ELEM_TYPE_ABSPOS, i.e., an element. - //! @deprecated. Equivalent to addElement. To be removed after Cantera 2.2. - void addUniqueElement(const std::string& symbol, doublereal weight=-12345.0, - int atomicNumber = 0, - doublereal entropy298 = ENTROPY298_UNKNOWN, - int elem_type = CT_ELEM_TYPE_ABSPOS); - - //! Add an element, checking for uniqueness - //! The uniqueness is checked by comparing the string symbol. If not unique, - //! nothing is done. - //! @param e Reference to the XML_Node where the element is described. - //! @deprecated. To be removed after Cantera 2.2. - void addUniqueElement(const XML_Node& e); - - //! Add all elements referenced in an XML_Node tree - //! @param phase Reference to the root XML_Node of a phase - //! @deprecated. To be removed after Cantera 2.2. - void addElementsFromXML(const XML_Node& phase); - - //! Prohibit addition of more elements, and prepare to add species. - //! @deprecated. To be removed after Cantera 2.2. - void freezeElements(); - - //! True if freezeElements has been called. - //! @deprecated. To be removed after Cantera 2.2. - bool elementsFrozen(); - - //! Add an element after elements have been frozen, checking for uniqueness - //! The uniqueness is checked by comparing the string symbol. If not - //! unique, nothing is done. - //! @param symbol String symbol of the element - //! @param weight Atomic weight of the element (kg kmol-1). - //! @param atomicNumber Atomic number of the element (unitless) - //! @param entropy298 Entropy of the element at 298 K and 1 bar in its - //! most stable form. The default is the value ENTROPY298_UNKNOWN, which - //! if used will cause Cantera to throw an error. - //! @param elem_type Specifies the type of the element constraint - //! equation. This defaults to CT_ELEM_TYPE_ABSPOS, i.e., an element. - //! @deprecated. Equivalent to addElement. To be removed after Cantera 2.2. - size_t addUniqueElementAfterFreeze(const std::string& symbol, - doublereal weight, int atomicNumber, - doublereal entropy298 = ENTROPY298_UNKNOWN, - int elem_type = CT_ELEM_TYPE_ABSPOS); - //! Add a Species to this Phase. Returns `true` if the species was //! successfully added, or `false` if the species was ignored. //! @see ignoreUndefinedElements addUndefinedElements throwUndefinedElements virtual bool addSpecies(shared_ptr spec); - //! @deprecated Use AddSpecies(shared_ptr spec) instead. To be - //! removed after Cantera 2.2. - void addSpecies(const std::string& name, const doublereal* comp, - doublereal charge = 0.0, doublereal size = 1.0); - - //! Add a species to the phase, checking for uniqueness of the name - //! This routine checks for uniqueness of the string name. It only adds the - //! species if it is unique. - //! @param name String name of the species - //! @param comp Array containing the elemental composition of the - //! species. - //! @param charge Charge of the species. Defaults to zero. - //! @param size Size of the species (meters). Defaults to 1 meter. - //! @deprecated Use addSpecies(shared_ptr spec) instead. To be - //! removed after Cantera 2.2. - void addUniqueSpecies(const std::string& name, const doublereal* comp, - doublereal charge = 0.0, - doublereal size = 1.0); - //! Return the Species object for the named species. shared_ptr species(const std::string& name) const; diff --git a/include/cantera/thermo/ShomatePoly.h b/include/cantera/thermo/ShomatePoly.h index 50186c359..e90416103 100644 --- a/include/cantera/thermo/ShomatePoly.h +++ b/include/cantera/thermo/ShomatePoly.h @@ -59,36 +59,6 @@ public: //! Empty constructor ShomatePoly() {} - //! Constructor used in templated instantiations - /*! - * @param n Species index - * @param tlow Minimum temperature - * @param thigh Maximum temperature - * @param pref reference pressure (Pa). - * @param coeffs Vector of coefficients used to set the - * parameters for the standard state for species n. - * There are 7 coefficients for the Shomate polynomial: - * - c[0] = \f$ A \f$ - * - c[1] = \f$ B \f$ - * - c[2] = \f$ C \f$ - * - c[3] = \f$ D \f$ - * - c[4] = \f$ E \f$ - * - c[5] = \f$ F \f$ - * - c[6] = \f$ G \f$ - * - * See the class description for the polynomial representation of the - * thermo functions in terms of \f$ A, \dots, G \f$. - * - * @deprecated Use the alternate constructor which does not take the - * species index. To be removed after Cantera 2.2. - */ - ShomatePoly(size_t n, doublereal tlow, doublereal thigh, doublereal pref, - const doublereal* coeffs) : - SpeciesThermoInterpType(n, tlow, thigh, pref), - m_coeff(coeffs, coeffs + 7) - { - } - //! Normal constructor /*! * @param tlow Minimum temperature @@ -175,9 +145,9 @@ public: * the results by dividing by (GasConstant * T), * where GasConstant has units of J/(kmol * K). */ - cp_R[m_index] = 1.e3 * cp * tt[5]; - h_RT[m_index] = 1.e6 * h * tt[6]; - s_R[m_index] = 1.e3 * s * tt[5]; + *cp_R = 1.e3 * cp * tt[5]; + *h_RT = 1.e6 * h * tt[6]; + *s_R = 1.e3 * s * tt[5]; } virtual void updatePropertiesTemp(const doublereal temp, @@ -192,7 +162,7 @@ public: doublereal& tlow, doublereal& thigh, doublereal& pref, doublereal* const coeffs) const { - n = m_index; + n = 0; type = SHOMATE; tlow = m_lowT; thigh = m_highT; @@ -229,7 +199,7 @@ public: double hh = 1.e6 * h; if (h298) { - h298[m_index] = 1.e6 * h; + *h298 = 1.e6 * h; } return hh; } @@ -296,31 +266,6 @@ public: m_coeff.resize(15); } - //! Constructor used in templated instantiations - /*! - * @param n Species index - * @param tlow Minimum temperature - * @param thigh Maximum temperature - * @param pref reference pressure (Pa). - * @param coeffs Vector of coefficients used to set the - * parameters for the standard state. - * There are 15 coefficients for the 2-zone Shomate polynomial. - * The first coefficient is the value of Tmid. The next 7 - * coefficients are the low temperature range Shomate coefficients. - * The last 7 are the high temperature range Shomate coefficients. - * @deprecated Use the constructor that does not require the species index. - * To be removed after Cantera 2.2. - */ - ShomatePoly2(size_t n, doublereal tlow, doublereal thigh, doublereal pref, - const doublereal* coeffs) : - SpeciesThermoInterpType(n, tlow, thigh, pref), - m_midT(coeffs[0]), - msp_low(n, tlow, coeffs[0], pref, coeffs+1), - msp_high(n, coeffs[0], thigh, pref, coeffs+8), - m_coeff(coeffs, coeffs + 15) - { - } - //! Normal constructor /*! * @param tlow Minimum temperature @@ -347,12 +292,6 @@ public: return SHOMATE2; } - virtual void setIndex(size_t index) { - SpeciesThermoInterpType::setIndex(index); - msp_low.setIndex(index); - msp_high.setIndex(index); - } - virtual size_t temperaturePolySize() const { return 7; } virtual void updateTemperaturePoly(double T, double* T_poly) const { @@ -405,7 +344,7 @@ public: doublereal& tlow, doublereal& thigh, doublereal& pref, doublereal* const coeffs) const { - n = m_index; + n = 0; type = SHOMATE2; tlow = m_lowT; thigh = m_highT; @@ -425,8 +364,8 @@ public: virtual void modifyParameters(doublereal* coeffs) { std::copy(coeffs, coeffs + 15, m_coeff.begin()); m_midT = coeffs[0]; - msp_low = ShomatePoly(m_index, m_lowT, m_midT, m_Pref, coeffs+1); - msp_high = ShomatePoly(m_index, m_midT, m_highT, m_Pref, coeffs+8); + msp_low = ShomatePoly(m_lowT, m_midT, m_Pref, coeffs+1); + msp_high = ShomatePoly(m_midT, m_highT, m_Pref, coeffs+8); } virtual doublereal reportHf298(doublereal* const h298 = 0) const { @@ -437,16 +376,12 @@ public: h = msp_high.reportHf298(h298); } if (h298) { - h298[m_index] = h; + *h298 = h; } return h; } virtual void modifyOneHf298(const size_t k, const doublereal Hf298New) { - if (k != m_index) { - return; - } - doublereal h298now = reportHf298(0); doublereal delH = Hf298New - h298now; double h = msp_low.reportHf298(0); diff --git a/include/cantera/thermo/SimpleThermo.h b/include/cantera/thermo/SimpleThermo.h deleted file mode 100644 index 325773de0..000000000 --- a/include/cantera/thermo/SimpleThermo.h +++ /dev/null @@ -1,363 +0,0 @@ -/** - * @file SimpleThermo.h - * Header for the SimpleThermo (constant heat capacity) species reference-state model - * for multiple species in a phase, derived from the - * \link Cantera::SpeciesThermo SpeciesThermo\endlink base class (see \ref spthermo and - * \link Cantera::SimpleThermo SimpleThermo\endlink). - */ -#ifndef CT_SIMPLETHERMO_H -#define CT_SIMPLETHERMO_H - -#include "SpeciesThermoMgr.h" -#include "speciesThermoTypes.h" -#include "cantera/base/global.h" -#include "cantera/base/utilities.h" - -namespace Cantera -{ -/*! - * A constant-heat capacity species thermodynamic property manager class. This - * makes the assumption that the heat capacity is a constant. Then, the - * following relations are used to complete the specification of the - * thermodynamic functions for each species in the phase. - * - * \f[ - * \frac{c_p(T)}{R} = Cp0\_R - * \f] - * \f[ - * \frac{h^0(T)}{RT} = \frac{1}{T} * (h0\_R + (T - T_0) * Cp0\_R) - * \f] - * \f[ - * \frac{s^0(T)}{R} = (s0\_R + (log(T) - log(T_0)) * Cp0\_R) - * \f] - * - * This parameterization takes 4 input values. These are: - * - c[0] = \f$ T_0 \f$(Kelvin) - * - c[1] = \f$ H_k^o(T_0, p_{ref}) \f$ (J/kmol) - * - c[2] = \f$ S_k^o(T_0, p_{ref}) \f$ (J/kmol K) - * - c[3] = \f$ {Cp}_k^o(T_0, p_{ref}) \f$ (J(kmol K) - * - * All species must have the same reference pressure. - * The single-species standard-state property Manager ConstCpPoly has the same - * parameterization as the SimpleThermo class does. - * - * @see ConstCpPoly - * - * @ingroup mgrsrefcalc - * @deprecated To be removed after Cantera 2.2. Use GeneralSpeciesThermo instead. - */ -class SimpleThermo : public SpeciesThermo -{ -public: - //! The type of parameterization. Note, this value is used in some - //! template functions. For this object the value is SIMPLE. - const int ID; - - //! Constructor - SimpleThermo() : - ID(SIMPLE), - m_tlow_max(0.0), - m_thigh_min(1.e30), - m_p0(-1.0), - m_nspData(0) { - warn_deprecated("class SimpleThermo", "To be removed after " - "Cantera 2.2. Use GeneralSpeciesThermo instead."); - } - - //! Copy constructor - /*! - * @param right Object to be copied - */ - SimpleThermo(const SimpleThermo& right) : - SpeciesThermo(right), - ID(SIMPLE), - m_tlow_max(0.0), - m_thigh_min(1.e30), - m_p0(-1.0), - m_nspData(0) { - /* - * Call the assignment operator - */ - *this = right; - } - - //! Assignment operator - /*! - * @param right Object to be copied - */ - SimpleThermo& operator=(const SimpleThermo& right) { - /* - * Check for self assignment. - */ - if (this == &right) { - return *this; - } - - SpeciesThermo::operator=(right); - m_loc = right.m_loc; - m_index = right.m_index; - m_tlow_max = right.m_tlow_max; - m_thigh_min = right.m_thigh_min; - m_tlow = right.m_tlow; - m_thigh = right.m_thigh; - m_t0 = right.m_t0; - m_logt0 = right.m_logt0; - m_h0_R = right.m_h0_R; - m_s0_R = right.m_s0_R; - m_cp0_R = right.m_cp0_R; - m_p0 = right.m_p0; - m_nspData = right.m_nspData; - - return *this; - } - - virtual SpeciesThermo* duplMyselfAsSpeciesThermo() const { - SimpleThermo* nt = new SimpleThermo(*this); - return (SpeciesThermo*) nt; - } - - //! Install a new species thermodynamic property - //! parameterization for one species. - /*! - * @param name String name of the species - * @param index Species index, k - * @param type int flag specifying the type of parameterization to be - * installed. - * @param c Vector of coefficients for the parameterization. - * There are 4 coefficients. The values (and units) are the following - * - c[0] = \f$ T_0 \f$(Kelvin) - * - c[1] = \f$ H_k^o(T_0, p_{ref}) \f$ (J/kmol) - * - c[2] = \f$ S_k^o(T_0, p_{ref}) \f$ (J/kmol K) - * - c[3] = \f$ {Cp}_k^o(T_0, p_{ref}) \f$ (J(kmol K) - * - * @param minTemp_ minimum temperature for which this parameterization - * is valid. - * @param maxTemp_ maximum temperature for which this parameterization - * is valid. - * @param refPressure_ standard-state pressure for this parameterization. - * - * @see ConstCpPoly - */ - virtual void install(const std::string& name, size_t index, int type, const doublereal* c, - doublereal minTemp_, doublereal maxTemp_, doublereal refPressure_) { - if (type != SIMPLE) { - throw CanteraError("SimpleThermo::install", - "Incompatible thermo parameterization: Got " + - int2str(type) + " but " + int2str(SIMPLE) + - " was expected."); - } - m_logt0.push_back(log(c[0])); - m_t0.push_back(c[0]); - m_h0_R.push_back(c[1]/GasConstant); - m_s0_R.push_back(c[2]/GasConstant); - m_cp0_R.push_back(c[3]/GasConstant); - m_index.push_back(index); - m_loc[index] = m_nspData; - m_nspData++; - doublereal tlow = minTemp_; - doublereal thigh = maxTemp_; - m_tlow_max = std::max(tlow, m_tlow_max); - m_thigh_min = std::min(thigh, m_thigh_min); - - if (m_tlow.size() < index + 1) { - m_tlow.resize(index + 1, tlow); - m_thigh.resize(index + 1, thigh); - } - m_tlow[index] = tlow; - m_thigh[index] = thigh; - - if (m_p0 < 0.0) { - m_p0 = refPressure_; - } else if (fabs(m_p0 - refPressure_) > 0.1) { - std::string logmsg = " WARNING SimpleThermo: New Species, " + name + - ", has a different reference pressure, " - + fp2str(refPressure_) + ", than existing reference pressure, " + fp2str(m_p0) + "\n"; - writelog(logmsg); - logmsg = " This is now a fatal error\n"; - writelog(logmsg); - throw CanteraError("install()", "Species have different reference pressures"); - } - m_p0 = refPressure_; - markInstalled(index); - } - - virtual void install_STIT(size_t index, - shared_ptr stit_ptr) { - throw CanteraError("install_STIT", "not implemented"); - } - - virtual void update(doublereal t, doublereal* cp_R, - doublereal* h_RT, doublereal* s_R) const { - size_t k, ki; - doublereal logt = log(t); - doublereal rt = 1.0/t; - for (k = 0; k < m_nspData; k++) { - ki = m_index[k]; - cp_R[ki] = m_cp0_R[k]; - h_RT[ki] = rt*(m_h0_R[k] + (t - m_t0[k]) * m_cp0_R[k]); - s_R[ki] = m_s0_R[k] + m_cp0_R[k] * (logt - m_logt0[k]); - } - } - - //! Like update(), but only updates the single species k. - /*! - * @param k species index - * @param t Temperature (Kelvin) - * @param cp_R Vector of Dimensionless heat capacities. (length m_kk). - * @param h_RT Vector of Dimensionless enthalpies. (length m_kk). - * @param s_R Vector of Dimensionless entropies. (length m_kk). - */ - virtual void update_one(size_t k, doublereal t, doublereal* cp_R, - doublereal* h_RT, doublereal* s_R) const { - doublereal logt = log(t); - doublereal rt = 1.0/t; - size_t loc = getValue(m_loc, k); - cp_R[k] = m_cp0_R[loc]; - h_RT[k] = rt*(m_h0_R[loc] + (t - m_t0[loc]) * m_cp0_R[loc]); - s_R[k] = m_s0_R[loc] + m_cp0_R[loc] * (logt - m_logt0[loc]); - } - - virtual doublereal minTemp(size_t k=npos) const { - if (k == npos) { - return m_tlow_max; - } else { - return m_tlow[getValue(m_loc, k)]; - } - } - - virtual doublereal maxTemp(size_t k=npos) const { - if (k == npos) { - return m_thigh_min; - } else { - return m_thigh[getValue(m_loc, k)]; - } - } - - virtual doublereal refPressure(size_t k=npos) const { - return m_p0; - } - - virtual int reportType(size_t index) const { - return SIMPLE; - } - - /*! - * This utility function reports back the type of parameterization and all - * of the parameters for the species, index. - * - * @param index Species index - * @param type Integer type of the standard type - * @param c Vector of coefficients used to set the - * parameters for the standard state. - * For the SimpleThermo object, there are 4 coefficients. - * @param minTemp_ output - Minimum temperature - * @param maxTemp_ output - Maximum temperature - * @param refPressure_ output - reference pressure (Pa). - */ - virtual void reportParams(size_t index, int& type, - doublereal* const c, - doublereal& minTemp_, - doublereal& maxTemp_, - doublereal& refPressure_) const { - type = reportType(index); - size_t loc = getValue(m_loc, index); - if (type == SIMPLE) { - c[0] = m_t0[loc]; - c[1] = m_h0_R[loc] * GasConstant; - c[2] = m_s0_R[loc] * GasConstant; - c[3] = m_cp0_R[loc] * GasConstant; - minTemp_ = m_tlow[loc]; - maxTemp_ = m_thigh[loc]; - refPressure_ = m_p0; - } - } - - virtual doublereal reportOneHf298(const size_t k) const { - throw CanteraError("reportHF298", "unimplemented"); - } - - virtual void modifyOneHf298(const size_t k, const doublereal Hf298New) { - throw CanteraError("reportHF298", "unimplemented"); - } - -protected: - //! Mapping between the species index and the vector index where the coefficients are kept - /*! - * This object doesn't have a one-to one correspondence between the species index, kspec, - * and the data location index,indexData, m_cp0_R[indexData]. - * This index keeps track of it. - * indexData = m_loc[kspec] - */ - std::map m_loc; - - //! Map between the vector index where the coefficients are kept and the species index - /*! - * Length is equal to the number of dataPoints. - * kspec = m_index[indexData] - */ - std::vector m_index; - - //! Maximum value of the low temperature limit - doublereal m_tlow_max; - - //! Minimum value of the high temperature limit - doublereal m_thigh_min; - - //! Vector of low temperature limits (species index) - /*! - * Length is equal to number of data points - */ - vector_fp m_tlow; - - //! Vector of low temperature limits (species index) - /*! - * Length is equal to number of data points - */ - vector_fp m_thigh; - - //! Vector of base temperatures (kelvin) - /*! - * Length is equal to the number of species data points - */ - vector_fp m_t0; - - //! Vector of base log temperatures (kelvin) - /*! - * Length is equal to the number of species data points - */ - vector_fp m_logt0; - - //! Vector of base dimensionless Enthalpies - /*! - * Length is equal to the number of species data points - */ - vector_fp m_h0_R; - - //! Vector of base dimensionless Entropies - /*! - * Length is equal to the number of species data points - */ - vector_fp m_s0_R; - - //! Vector of base dimensionless heat capacities - /*! - * Length is equal to the number of species data points - */ - vector_fp m_cp0_R; - - //! Reference pressure (Pa) - /*! - * all species must have the same reference pressure. - */ - doublereal m_p0; - - //! Number of species data points in the object. - /*! - * This is less than or equal to the number of species in the phase. - */ - size_t m_nspData; -}; - -} - -#endif diff --git a/include/cantera/thermo/SpeciesThermo.h b/include/cantera/thermo/SpeciesThermo.h index 0cd0d1bcf..76b407bd4 100644 --- a/include/cantera/thermo/SpeciesThermo.h +++ b/include/cantera/thermo/SpeciesThermo.h @@ -67,37 +67,18 @@ class SpeciesThermoInterpType; * * Usually, all of the species in a phase are installed into a SpeciesThermo * class. However, there is no requirement that a SpeciesThermo - * object handles all of the species in a phase. There are - * two member functions that are called to install each species into - * the SpeciesThermo. - * One routine is called \link SpeciesThermo::install() install()\endlink. - * It is called with the index of the species in the phase, - * an integer type delineating - * the SpeciesThermoInterpType object, and a listing of the - * parameters for that parameterization. A factory routine is called based - * on the integer type. The other routine is called - * \link SpeciesThermo::install_STIT() install_STIT()\endlink. - * It accepts as an argument a pointer to an already formed - * SpeciesThermoInterpType object. + * object handles all of the species in a phase. The member function + * \link SpeciesThermo::install_STIT() install_STIT()\endlink + * is called to install each species into the SpeciesThermo object. * * The following classes inherit from SpeciesThermo. Each of these classes * handle multiple species, usually all of the species in a phase. However, * there is no requirement that a SpeciesThermo object handles all of the * species in a phase. * - * - NasaThermo in file NasaThermo.h - * - This is a two zone model, with each zone consisting of a 7 - * coefficient NASA Polynomial format. - * - ShomateThermo in file ShomateThermo.h - * - This is a two zone model, with each zone consisting of a 7 - * coefficient Shomate Polynomial format. - * - SimpleThermo in file SimpleThermo.h - * - This is a one-zone constant heat capacity model. * - GeneralSpeciesThermo in file GeneralSpeciesThermo.h * - This is a general model. Each species is handled separately * via a vector over SpeciesThermoInterpType classes. - * - SpeciesThermoDuo in file SpeciesThermoMgr.h - * - This is a combination of two SpeciesThermo types. * * The class SpeciesThermoInterpType is a pure virtual base class for * calculation of thermodynamic functions for a single species @@ -129,12 +110,6 @@ class SpeciesThermoInterpType; * - This is a multiple zone model, consisting of the 9 * coefficient NASA Polynomial format in each zone. * - * In particular the NasaThermo SpeciesThermo-derived model has been - * optimized for execution speed. It's the main-stay of gas phase computations - * involving large numbers of species in a phase. It combines the calculation - * of each species, which individually have NasaPoly2 representations, to - * minimize the computational time. - * * The GeneralSpeciesThermo SpeciesThermo object is completely general. It * does not try to coordinate the individual species calculations at all and * therefore is the slowest but most general implementation. @@ -170,34 +145,6 @@ public: */ virtual SpeciesThermo* duplMyselfAsSpeciesThermo() const = 0; - //! Install a new species thermodynamic property - //! parameterization for one species. - /*! - * @see speciesThermoTypes.h - * - * @param name Name of the species - * @param index The 'update' method will update the property - * values for this species - * at position i index in the property arrays. - * @param type int flag specifying the type of parameterization to be - * installed. - * @param c vector of coefficients for the parameterization. - * This vector is simply passed through to the - * parameterization constructor. - * @param minTemp minimum temperature for which this parameterization - * is valid. - * @param maxTemp maximum temperature for which this parameterization - * is valid. - * @param refPressure standard-state pressure for this - * parameterization. - * @deprecated Use newSpeciesThermoInterpType and - * GeneralSpeciesThermo::install_STIT. To be removed after Cantera 2.2. - */ - virtual void install(const std::string& name, size_t index, int type, - const doublereal* c, - doublereal minTemp, doublereal maxTemp, - doublereal refPressure)=0; - //! Install a new species thermodynamic property //! parameterization for one species. /*! diff --git a/include/cantera/thermo/SpeciesThermoFactory.h b/include/cantera/thermo/SpeciesThermoFactory.h index b376404a8..af245cda9 100644 --- a/include/cantera/thermo/SpeciesThermoFactory.h +++ b/include/cantera/thermo/SpeciesThermoFactory.h @@ -1,254 +1,20 @@ /** * @file SpeciesThermoFactory.h - * Header for factory to build instances of classes that manage the + * Header for factory functions to build instances of classes that manage the * standard-state thermodynamic properties of a set of species - * (see \ref spthermo and class - * \link Cantera::SpeciesThermoFactory SpeciesThermoFactory\endlink); + * (see \ref spthermo); */ // Copyright 2001 California Institute of Technology #ifndef SPECIESTHERMO_FACTORY_H #define SPECIESTHERMO_FACTORY_H -#include "SpeciesThermo.h" -#include "cantera/base/ctexceptions.h" -#include "cantera/base/FactoryBase.h" -#include "cantera/base/ct_thread.h" +#include "SpeciesThermoInterpType.h" namespace Cantera { class XML_Node; -class VPStandardStateTP; -class VPSSMgr; -class ThermoPhase; - -/** - * Throw a named error for an unknown or missing species thermo model. - * - * @ingroup thermoprops - */ -class UnknownSpeciesThermoModel: public CanteraError -{ -public: - //! constructor - /*! - * @param proc Function name error occurred. - * @param spName Species Name that caused the error - * @param speciesThermoModel Unrecognized species thermo model name - */ - UnknownSpeciesThermoModel(const std::string& proc, const std::string& spName, - const std::string& speciesThermoModel) : - CanteraError(proc, "species " + spName + - ": Specified speciesThermoPhase model " - + speciesThermoModel + - " does not match any known type.") {} -}; - -//! Factory to build instances of classes that manage the -//! standard-state thermodynamic properties of a set of species. -/*! - * This class is responsible for making the decision concerning - * which derivative of SpeciesThermo object to use. - * The SpeciesThermo object is used to calculate - * thermodynamic functions for the reference state. - * It queries the database of species to understand what - * the requirements are for the submodels for all of the - * species in the phase. Then, it picks the SpeciesThermo - * object to use, and passes it back to the calling routine. - * It doesn't load any of the data into the derived - * SpeciesThermo object. - * - * Making the choice of SpeciesThermo types is the only - * thing this class does. - * - * This class is implemented as a singleton -- one in which - * only one instance is needed. The recommended way to access - * the factory is to call this static method, which - * instantiates the class if it is the first call, but - * otherwise simply returns the pointer to the existing - * instance. - * - * @deprecated To be removed after Cantera 2.2. Use class GeneralSpeciesThermo directly - * @ingroup thermoprops - */ -class SpeciesThermoFactory : public FactoryBase -{ - -public: - - //! Static method to return an instance of this class - /*! - * This class is implemented as a singleton -- one in which only one - * instance is needed. The recommended way to access the factory is to - * call this static method, which instantiates the class if it is the - * first call, but otherwise simply returns the pointer to the existing - * instance. - */ - static SpeciesThermoFactory* factory(); - - //! Delete static instance of this class - /** - * If it is necessary to explicitly delete the factory before - * the process terminates (for example, when checking for - * memory leaks) then this method can be called to delete it. - */ - void deleteFactory(); - - //! Create a new species property manager for the reference state. - /*! - * @param type the integer type to be created. - * @return Returns the pointer to the newly allocated species property - * manager for the reference state - * @deprecated To be removed after Cantera 2.2. Use GeneralSpeciesThermo - * directly. - */ - SpeciesThermo* newSpeciesThermo(int type) const; - - //! Create a new species thermo property manager given a string - /*! - * @param stype String name for the species thermo type - * @return Returns the pointer to the newly malloced species - * property manager for the reference state - * @deprecated To be removed after Cantera 2.2. Use GeneralSpeciesThermo - * directly. - */ - SpeciesThermo* newSpeciesThermoManager(const std::string& stype) const; - - //! Create a new species property manager for the reference - //! state for a group of species - /*! - * This routine will look through species nodes. It will discover what - * each species needs for its species property managers. Then, - * it will malloc and return the proper species property manager to use. - * - * @param spDataNodeList This vector contains a list of species XML - * nodes that will be in the phase - * @return Returns the pointer to the newly malloced species property - * manager for the reference state - * @deprecated To be removed after Cantera 2.2. - */ - SpeciesThermo* newSpeciesThermo(std::vector & spDataNodeList) const; - - //! Install a species thermodynamic property parameterization - //! for the reference state for one species into a species thermo manager. - /*! - * @param k Species number - * @param speciesNode Reference to the XML node specifying the species - * standard state information - * @param th_ptr Pointer to the ThermoPhase object for the species - * @param spthermo Species reference state thermo manager - * @param phaseNode_ptr Optional pointer to the XML phase information for - * the phase in which the species resides - */ - void installThermoForSpecies(size_t k, const XML_Node& speciesNode, - ThermoPhase* th_ptr, SpeciesThermo& spthermo, - const XML_Node* phaseNode_ptr = 0) const; - - //! Install a species thermodynamic property parameterization - //! for the standard state for one species into a species thermo manager, VPSSMgr - /*! - * This is a wrapper around the createInstallVPSS() function in the - * VPStandardStateTP object. - * - * This serves to install the species into vpss_ptr, create a PDSS file. We also - * read the XML database to extract the constants for these steps. - * - * @param k species number - * @param speciesNode Reference to the XML node specifying the species - * standard state information - * @param vp_ptr variable pressure ThermoPhase object - * @param vpss_ptr Pointer to the Manager for calculating variable - * pressure substances. - * @param spthermo_ptr Species reference state thermo manager - * @param phaseNode_ptr Optional Pointer to the XML phase information for - * the phase in which the species resides - * @deprecated To be removed after Cantera 2.2. Call - * VPStandardStateTP::createInstallVPSS directly instead. - */ - void installVPThermoForSpecies(size_t k, const XML_Node& speciesNode, - VPStandardStateTP* vp_ptr, - VPSSMgr* vpss_ptr, - SpeciesThermo* spthermo_ptr, - const XML_Node* phaseNode_ptr) const; - -private: - - //! Pointer to the sole instance of this class, which is static - static SpeciesThermoFactory* s_factory; - - //! Decl of the static mutex variable that locks the SpeciesThermo factory singleton - static mutex_t species_thermo_mutex; - - //! Constructor. This is made private, so that only the static - //! method factory() can instantiate the class. - SpeciesThermoFactory() {} -}; - - -////////////////////// Convenience functions //////////////////// -// -// These functions allow using a different factory class that -// derives from SpeciesThermoFactory. -// -////////////////////////////////////////////////////////////////// - - -//! Create a new species thermo manager instance, by specifying the type and -//! (optionally) a pointer to the factory to use to create it. -/*! - * This utility program will look through species nodes. It will discover what - * each species needs for its species property managers. Then, - * it will malloc and return the proper species property manager to use. - * - * These functions allow using a different factory class that - * derives from SpeciesThermoFactory. - * - * @param type Species thermo type. - * @param f Pointer to a SpeciesThermoFactory. optional parameter. - * Defaults to NULL. - * @deprecated To be removed after Cantera 2.2. Use GeneralSpeciesThermo - * directly. - */ -SpeciesThermo* newSpeciesThermoMgr(int type, SpeciesThermoFactory* f=0); - -//! Create a new species thermo manager instance, by specifying the type and -//! (optionally) a pointer to the factory to use to create it. -/*! - * This utility program is a basic factory operation for spawning a - * new species reference-state thermo manager - * - * These functions allows for using a different factory class that - * derives from SpeciesThermoFactory. However, no applications of this - * have been done yet. - * - * @param stype String specifying the species thermo type - * @param f Pointer to a SpeciesThermoFactory. optional parameter. - * Defaults to NULL. - * @deprecated To be removed after Cantera 2.2. Use GeneralSpeciesThermo - * directly. - */ -SpeciesThermo* newSpeciesThermoMgr(const std::string& stype, - SpeciesThermoFactory* f=0); - -//! Function to return SpeciesThermo manager -/*! - * This utility program will look through species nodes. It will discover what - * each species needs for its species property managers. Then, - * it will malloc and return the proper species reference state manager to use. - * - * These functions allow using a different factory class that - * derives from SpeciesThermoFactory. - * - * @param spDataNodeList This vector contains a list of species XML nodes that - * will be in the phase - * @param f Pointer to a SpeciesThermoFactory. optional - * parameter. Defaults to NULL. - * @deprecated To be removed after Cantera 2.2. - */ -SpeciesThermo* newSpeciesThermoMgr(std::vector spDataNodeList, - SpeciesThermoFactory* f=0); - //! Create a new SpeciesThermoInterpType object given a corresponding constant. /*! diff --git a/include/cantera/thermo/SpeciesThermoInterpType.h b/include/cantera/thermo/SpeciesThermoInterpType.h index 2ce78ddcd..54bbb298c 100644 --- a/include/cantera/thermo/SpeciesThermoInterpType.h +++ b/include/cantera/thermo/SpeciesThermoInterpType.h @@ -160,11 +160,6 @@ class SpeciesThermoInterpType public: SpeciesThermoInterpType(); - //! @deprecated Use the constructor without the species index. To be removed - //! after Cantera 2.2. - SpeciesThermoInterpType(size_t n, doublereal tlow, - doublereal thigh, doublereal pref); - SpeciesThermoInterpType(double tlow, double thigh, double pref); SpeciesThermoInterpType(const SpeciesThermoInterpType& b); @@ -198,17 +193,6 @@ public: //! Returns an integer representing the type of parameterization virtual int reportType() const = 0; - //! Returns an integer representing the species index - //! @deprecated - virtual size_t speciesIndex() const { - return m_index; - } - - //! @deprecated - virtual void setIndex(size_t index) { - m_index = index; - } - //! Number of terms in the temperature polynomial for this parameterization virtual size_t temperaturePolySize() const { return 1; } @@ -316,8 +300,6 @@ protected: doublereal m_highT; //! Reference state pressure doublereal m_Pref; - //! species index @deprecated - size_t m_index; }; //! Class for the thermodynamic manager for an individual species' reference @@ -339,22 +321,6 @@ public: //! Constructor STITbyPDSS(); - //! Main Constructor - /*! - * @param speciesIndex species index for this object. Note, this must - * agree with what was internally set before. - * - * @param vpssmgr_ptr Pointer to the Variable pressure standard state - * manager that owns the PDSS object that will handle calls for this - * object - * - * @param PDSS_ptr Pointer to the PDSS object that handles calls for - * this object - * @deprecated Use the constructor which does not require the species - * index. To be removed after Cantera 2.2. - */ - STITbyPDSS(size_t speciesIndex, VPSSMgr* vpssmgr_ptr, PDSS* PDSS_ptr); - //! Main Constructor /*! * @param vpssmgr_ptr Pointer to the Variable pressure standard state diff --git a/include/cantera/thermo/SpeciesThermoMgr.h b/include/cantera/thermo/SpeciesThermoMgr.h deleted file mode 100644 index 22df41900..000000000 --- a/include/cantera/thermo/SpeciesThermoMgr.h +++ /dev/null @@ -1,224 +0,0 @@ -/** - * @file SpeciesThermoMgr.h - * This file contains descriptions of templated subclasses of - * the virtual base class, SpeciesThermo, which includes SpeciesThermoDuo - * (see \ref mgrsrefcalc and class - * \link Cantera::SpeciesThermoDuo SpeciesThermoDuo\endlink) - */ - -// Copyright 2001 California Institute of Technology - -#ifndef CT_SPECIESTHERMO_MGR_H -#define CT_SPECIESTHERMO_MGR_H - -#include "cantera/base/ctexceptions.h" -#include "cantera/base/stringUtils.h" -#include "SpeciesThermo.h" -#include "cantera/base/utilities.h" - -namespace Cantera -{ -//! Unknown species thermo manager string error -/*! - * @ingroup mgrsrefcalc - */ -class UnknownSpeciesThermo : public CanteraError -{ -public: - //! constructor - /*! - * @param proc name of the procecdure - * @param type unknown type - */ - UnknownSpeciesThermo(const std::string& proc, int type) : - CanteraError(proc, "Specified species parameterization type (" + int2str(type) - + ") does not match any known type.") {} - - //! Alternate constructor - /*! - * @param proc name of the procecdure - * @param stype String name for the unknown type - */ - UnknownSpeciesThermo(const std::string& proc, const std::string& stype) : - CanteraError(proc, "Specified species parameterization type (" + stype - + ") does not match any known type.") {} -}; - -/** - * This species thermo manager requires that all species have one - * of two parameterizations. - * - * Note this seems to be a slow way to do things, and it may be on its way out. - * - * @deprecated To be removed after Cantera 2.2. Use GeneralSpeciesThermo instead. - * @ingroup mgrsrefcalc - */ -template -class SpeciesThermoDuo : public SpeciesThermo -{ -public: - //! Constructor - SpeciesThermoDuo() { - warn_deprecated("class SpeciesThermoDuo", "To be removed after " - "Cantera 2.2. Use GeneralSpeciesThermo instead."); - }; - - //! copy constructor - /*! - * @param right Object to be copied - */ - SpeciesThermoDuo(const SpeciesThermoDuo& right) { - *this = right; - } - - //! Assignment operator - /*! - * @param right Object to be copied - */ - SpeciesThermoDuo& operator=(const SpeciesThermoDuo& right); - - virtual SpeciesThermo* duplMyselfAsSpeciesThermo() const; - - virtual void install(const std::string& name, size_t sp, int type, - const doublereal* c, - doublereal minTemp, doublereal maxTemp, - doublereal refPressure); - - virtual void install_STIT(size_t index, - shared_ptr stit_ptr) { - throw CanteraError("install_STIT", "not implemented"); - } - - virtual void update(doublereal t, doublereal* cp_R, - doublereal* h_RT, doublereal* s_R) const; - - virtual doublereal minTemp(size_t k = npos) const { - return std::max(m_thermo1.minTemp(),m_thermo2.minTemp()); - } - - virtual doublereal maxTemp(size_t k = npos) const { - return std::min(m_thermo1.maxTemp(), m_thermo2.maxTemp()); - } - - virtual doublereal refPressure(size_t k = npos) const { - return m_p0; - } - - virtual int reportType(size_t k) const; - - virtual void reportParams(size_t index, int& type, - doublereal* const c, - doublereal& minTemp, - doublereal& maxTemp, - doublereal& refPressure) const; - - virtual doublereal reportOneHf298(const size_t k) const { - throw CanteraError("reportHF298", "unimplemented"); - } - - virtual void modifyOneHf298(const size_t k, const doublereal Hf298New) { - throw CanteraError("reportHF298", "unimplemented"); - } - -private: - - //! Thermo Type 1 - T1 m_thermo1; - //! Thermo Type 2 - T2 m_thermo2; - //! Reference pressure - doublereal m_p0; - //! map from species to type - std::map speciesToType; -}; - - -// ------------------------- cpp part of file ------------------------------------- - -// Definitions for the SpeciesThermoDuo templated class - -template -SpeciesThermoDuo & -SpeciesThermoDuo::operator=(const SpeciesThermoDuo& right) -{ - if (&right == this) { - return *this; - } - - SpeciesThermo::operator=(right); - m_thermo1 = right.m_thermo1; - m_thermo2 = right.m_thermo2; - m_p0 = right.m_p0; - speciesToType = right.speciesToType; - - return *this; -} - -template -SpeciesThermo* -SpeciesThermoDuo::duplMyselfAsSpeciesThermo() const -{ - return new SpeciesThermoDuo(*this); -} - -template -void -SpeciesThermoDuo::install(const std::string& name, size_t sp, int type, - const doublereal* c, - doublereal minTemp_, - doublereal maxTemp_, - doublereal refPressure_) -{ - m_p0 = refPressure_; - if (type == m_thermo1.ID) { - m_thermo1.install(name, sp, type, c, minTemp_, maxTemp_, - refPressure_); - speciesToType[sp] = m_thermo1.ID; - } else if (type == m_thermo2.ID) { - m_thermo2.install(name, sp, type, c, minTemp_, maxTemp_, - refPressure_); - speciesToType[sp] = m_thermo2.ID; - } else { - throw UnknownSpeciesThermo("SpeciesThermoDuo:install",type); - } - markInstalled(sp); -} - -template -void -SpeciesThermoDuo::update(doublereal t, doublereal* cp_R, - doublereal* h_RT, doublereal* s_R) const -{ - m_thermo1.update(t, cp_R, h_RT, s_R); - m_thermo2.update(t, cp_R, h_RT, s_R); -} - -template -int -SpeciesThermoDuo::reportType(size_t k) const -{ - return getValue(speciesToType, k, -1); -} - -template -void -SpeciesThermoDuo::reportParams(size_t index, int& type, - doublereal* const c, - doublereal& minTemp_, - doublereal& maxTemp_, - doublereal& refPressure_) const -{ - int ctype = reportType(index); - if (ctype == m_thermo1.ID) { - m_thermo1.reportParams(index, type, c, minTemp_, maxTemp_, - refPressure_); - } else if (ctype == m_thermo2.ID) { - m_thermo2.reportParams(index, type, c, minTemp_, maxTemp_, - refPressure_); - } else { - throw CanteraError("SpeciesThermoDuo", "mismatched SpeciesThermoInterpType"); - } -} - -} -#endif diff --git a/include/cantera/thermo/StatMech.h b/include/cantera/thermo/StatMech.h index 2b5150307..8231bffb6 100644 --- a/include/cantera/thermo/StatMech.h +++ b/include/cantera/thermo/StatMech.h @@ -14,7 +14,6 @@ #include "cantera/base/global.h" #include "SpeciesThermoInterpType.h" -#include "SpeciesThermoMgr.h" namespace Cantera { diff --git a/include/cantera/thermo/StoichSubstanceSSTP.h b/include/cantera/thermo/StoichSubstanceSSTP.h index 0906b9342..471465967 100644 --- a/include/cantera/thermo/StoichSubstanceSSTP.h +++ b/include/cantera/thermo/StoichSubstanceSSTP.h @@ -477,60 +477,6 @@ public: virtual void setParametersFromXML(const XML_Node& eosdata); }; -//! Class %electrodeElectron represents an electron in a -//! metal using the Standard hydrogen reference electrode -/*! - * The class is based on the electron have a chemical potential - * equal to one-half of the entropy of the H2 gas at 1 bar. - * - * @deprecated Deprecated in favor of class MetalSHEelectrons. To be removed - * after Cantera 2.2. - */ -class electrodeElectron : public StoichSubstanceSSTP -{ -public: - //! Default constructor for the electrodeElectron class - electrodeElectron(); - - //! Construct and initialize a electrodeElectron ThermoPhase object - //! directly from an ASCII input file - /*! - * @param infile name of the input file - * @param id name of the phase id in the file. - * If this is blank, the first phase in the file is used. - */ - electrodeElectron(const std::string& infile, std::string id = ""); - - //! Construct and initialize a electrodeElectron ThermoPhase object - //! directly from an XML database - /*! - * @param phaseRef XML node pointing to a electrodeElectron description - * @param id Id of the phase. - */ - electrodeElectron(XML_Node& phaseRef, const std::string& id = ""); - - //! Copy constructor - /*! - * @param right Object to be copied - */ - electrodeElectron(const electrodeElectron& right); - - //! Assignment operator - /*! - * @param right Object to be copied - */ - electrodeElectron& operator=(const electrodeElectron& right); - - //! Destructor - virtual ~electrodeElectron() {} - - void setParametersFromXML(const XML_Node& eosdata); - - virtual void initThermoXML(XML_Node& phaseNode, const std::string& id); - - void setParameters(int n, doublereal* const c); -}; - } #endif diff --git a/include/cantera/thermo/ThermoFactory.h b/include/cantera/thermo/ThermoFactory.h index 18463a112..d427a0ebc 100644 --- a/include/cantera/thermo/ThermoFactory.h +++ b/include/cantera/thermo/ThermoFactory.h @@ -18,9 +18,6 @@ namespace Cantera { -class SpeciesThermoFactory; -class VPSSMgr; - /*! * @addtogroup thermoprops * @@ -225,66 +222,14 @@ ThermoPhase* newPhase(const std::string& infile, std::string id=""); * @param spfactory species Thermo factory pointer, if * available. If not available, one will be * created. - * @deprecated the 'spfactory' argument is unused and will be removed after - * Cantera 2.2. * @ingroup thermoprops * - * @deprecated: The return value of this function is always 'true'. After - * Cantera 2.2, this function will return 'void'. */ -bool importPhase(XML_Node& phase, ThermoPhase* th, SpeciesThermoFactory* spfactory = 0); +void importPhase(XML_Node& phase, ThermoPhase* th); //! Add the elements given in an XML_Node tree to the specified phase void installElements(Phase& th, const XML_Node& phaseNode); -//! Install a species into a ThermoPhase object, which defines -//! the phase thermodynamics and speciation. -/*! - * This routine first gathers the information from the Species XML - * tree and calls addUniqueSpecies() to add it to the - * ThermoPhase object, p. - * This information consists of: - * ecomp[] = element composition of species. - * chgr = electric charge of species - * name = string name of species - * sz = size of the species - * (option double used a lot in thermo) - * - * Then, the routine processes the "thermo" XML element and - * calls underlying utility routines to read the XML elements - * containing the thermodynamic information for the reference - * state of the species. Failures or lack of information trigger - * an "UnknownSpeciesThermoModel" exception being thrown. - * - * @param k Species Index in the phase - * @param s XML_Node containing the species data for this species. - * @param p Reference to the ThermoPhase object. - * @param spthermo_ptr Reference to the SpeciesThermo object, where - * the standard state thermo properties for this - * species will be installed. - * @param rule Parameter that handles what to do with species - * who have elements that aren't declared. - * Check that all elements in the species - * exist in 'p'. If rule != 0, quietly skip - * this species if some elements are undeclared; - * otherwise, throw an exception - * @param phaseNode_ptr Pointer to the XML_Node for this phase - * (defaults to 0) - * @param vpss_ptr pointer to the Manager that calculates standard - * state thermo properties - * @param factory Pointer to the SpeciesThermoFactory . - * (defaults to 0) - * @deprecated Use newSpecies and addSpecies. For VPStandardStateTP phases, call - * createInstallPDSS as well. To be removed after Cantera 2.2. - * @return - * Returns true if everything is ok, false otherwise. - */ -bool installSpecies(size_t k, const XML_Node& s, thermo_t& p, - SpeciesThermo* spthermo_ptr, int rule, - XML_Node* phaseNode_ptr = 0, - VPSSMgr* vpss_ptr = 0, - SpeciesThermoFactory* factory = 0); - //! Search an XML tree for species data. /*! * This utility routine will search the XML tree for the species @@ -295,8 +240,6 @@ bool installSpecies(size_t k, const XML_Node& s, thermo_t& p, * @param kname String containing the name of the species. * @param phaseSpeciesData Pointer to the XML speciesData element * containing the species data for that phase. - * - * */ const XML_Node* speciesXML_Node(const std::string& kname, const XML_Node* phaseSpeciesData); @@ -306,5 +249,3 @@ const XML_Node* speciesXML_Node(const std::string& kname, } #endif - - diff --git a/include/cantera/transport.h b/include/cantera/transport.h index 7bbf222da..cebb14171 100644 --- a/include/cantera/transport.h +++ b/include/cantera/transport.h @@ -13,7 +13,6 @@ #include "transport/DustyGasTransport.h" #include "transport/MultiTransport.h" #include "transport/MixTransport.h" -#include "transport/PecosTransport.h" #include "transport/LiquidTransport.h" #include "transport/HighPressureGasTransport.h" #endif diff --git a/include/cantera/transport/DustyGasTransport.h b/include/cantera/transport/DustyGasTransport.h index 6440472ff..dba361337 100644 --- a/include/cantera/transport/DustyGasTransport.h +++ b/include/cantera/transport/DustyGasTransport.h @@ -93,22 +93,6 @@ public: return cDustyGasTransport; } - //! Set the Parameters in the model - /*! - * @param type Type of the parameter to set - * 0 - porosity - * 1 - tortuosity - * 2 - mean pore radius - * 3 - mean particle radius - * 4 - permeability - * @param k Unused int - * @param p pointer to double for the input list of parameters - * @deprecated Use the individual methods setPorosity(), - * setTortuosity(), setMeanPoreRadius(), setMeanParticleDiameter(), - * and setPermeability() - */ - virtual void setParameters(const int type, const int k, const doublereal* const p); - //! Return the Multicomponent diffusion coefficients. Units: [m^2/s]. /*! * Returns the array of multicomponent diffusion coefficients. diff --git a/include/cantera/transport/PecosTransport.h b/include/cantera/transport/PecosTransport.h deleted file mode 100644 index 8ed70b451..000000000 --- a/include/cantera/transport/PecosTransport.h +++ /dev/null @@ -1,314 +0,0 @@ -/** - * @file PecosTransport.h - * Header file defining class PecosTransport - */ - -// Copyright 2001 California Institute of Technology - -#ifndef CT_PECOSTRAN_H -#define CT_PECOSTRAN_H - -#include "TransportBase.h" -#include "cantera/numerics/DenseMatrix.h" - -namespace Cantera -{ - -class GasTransportParams; -/** - * Class PecosTransport implements mixture-averaged transport - * properties for ideal gas mixtures. - * @deprecated Incomplete stub class, to be removed after Cantera 2.2. - */ -class PecosTransport : public Transport -{ - -public: - virtual int model() const { - return cPecosTransport; - } - - //! Viscosity of the mixture - /*! - * The viscosity is computed using the Wilke mixture rule. - * \f[ - * \mu = \sum_k \frac{\mu_k X_k}{\sum_j \Phi_{k,j} X_j}. - * \f] - * Here \f$ \mu_k \f$ is the viscosity of pure species \e k, - * and - * \f[ - * \Phi_{k,j} = \frac{\left[1 - * + \sqrt{\left(\frac{\mu_k}{\mu_j}\sqrt{\frac{M_j}{M_k}}\right)}\right]^2} - * {\sqrt{8}\sqrt{1 + M_k/M_j}} - * \f] - * @see updateViscosity_T(); - */ - virtual doublereal viscosity(); - - virtual void getSpeciesViscosities(doublereal* const visc) { - update_T(); - updateViscosity_T(); - copy(m_visc.begin(), m_visc.end(), visc); - } - - //! Return the thermal diffusion coefficients - /*! - * For this approximation, these are all zero. - */ - virtual void getThermalDiffCoeffs(doublereal* const dt); - - //! Returns the mixture thermal conductivity - /*! - * This is computed using the lumped model, - * \f[ - * k = k^{tr} + k^{ve} - * \f] - * where, - * \f[ - * k^{tr}= 5/2 \mu_s C_{v,s}^{trans} + \mu_s C_{v,s}^{rot} - * \f] - * and, - * \f[ - * k^{ve}= \mu_s C_{v,s}^{vib} + \mu_s C_{v,s}^{elec} - * \f] - * - * The thermal conductivity is computed using the Wilke mixture rule. - * \f[ - * k = \sum_s \frac{k_s X_s}{\sum_j \Phi_{s,j} X_j}. - * \f] - * Here \f$ k_s \f$ is the conductivity of pure species \e s, - * and - * \f[ - * \Phi_{s,j} = \frac{\left[1 - * + \sqrt{\left(\frac{\mu_k}{\mu_j}\sqrt{\frac{M_j}{M_s}}\right)}\right]^2} - * {\sqrt{8}\sqrt{1 + M_s/M_j}} - * \f] - * @see updateCond_T(); - * @todo Reconcile these these formulas with the implementation - */ - virtual doublereal thermalConductivity(); - - //! binary diffusion coefficients - /*! - * Using Ramshaw's self-consistent Effective Binary Diffusion - * (1990, J. Non-Equilib. Thermo) - */ - virtual void getBinaryDiffCoeffs(const size_t ld, doublereal* const d); - - //! Mixture-averaged diffusion coefficients [m^2/s]. - /*! - * For the single species case or the pure fluid case the routine returns - * the self-diffusion coefficient. This is need to avoid a NaN result. - */ - virtual void getMixDiffCoeffs(doublereal* const d); - - //! Returns the mixture-averaged diffusion coefficients [m^2/s]. - //! These are the coefficients for calculating the molar diffusive fluxes - //! from the species mole fraction gradients, computed according to - //! Eq. 12.176 in "Chemically Reacting Flow": - //! - //! \f[ D_{km}^* = \frac{1-X_k}{\sum_{j \ne k}^K X_j/\mathcal{D}_{kj}} \f] - //! - //! @param[out] d vector of mixture-averaged diffusion coefficients for - //! each species, length m_nsp. - void getMixDiffCoeffsMole(doublereal* const d); - - //! Returns the mixture-averaged diffusion coefficients [m^2/s]. - //! These are the coefficients for calculating the diffusive mass fluxes - //! from the species mass fraction gradients, computed according to - //! Eq. 12.178 in "Chemically Reacting Flow": - //! - //! \f[ \frac{1}{D_{km}} = \sum_{j \ne k}^K \frac{X_j}{\mathcal{D}_{kj}} + - //! \frac{X_k}{1-Y_k} \sum_{j \ne k}^K \frac{Y_j}{\mathcal{D}_{kj}} \f] - //! - //! @param[out] d vector of mixture-averaged diffusion coefficients for - //! each species, length m_nsp. - void getMixDiffCoeffsMass(doublereal* const d); - - virtual void getMobilities(doublereal* const mobil); - virtual void update_T(); - - /** - * This is called the first time any transport property is requested from - * Mixture after the concentrations have changed. - */ - virtual void update_C(); - - //! Get the species diffusive mass fluxes wrt to the mass averaged - //! velocity, given the gradients in mole fraction and temperature - /*! - * The diffusive mass flux of species \e k is computed from - * \f[ - * \vec{j}_k = -n M_k D_k \nabla X_k + \frac{\rho_k}{\rho} \sum_r n M_r D_r \nabla X_r - * \f] - * This neglects pressure, forced and thermal diffusion. - * Units for the returned fluxes are kg m-2 s-1. - * - * @param ndim Number of dimensions in the flux expressions - * @param grad_T Gradient of the temperature - * (length = ndim) - * @param ldx Leading dimension of the grad_X array - * (usually equal to m_nsp but not always) - * @param grad_X Gradients of the mole fraction - * Flat vector with the m_nsp in the inner loop. - * length = ldx * ndim - * @param ldf Leading dimension of the fluxes array - * (usually equal to m_nsp but not always) - * @param fluxes Output of the diffusive mass fluxes - * Flat vector with the m_nsp in the inner loop. - * length = ldx * ndim - */ - virtual void getSpeciesFluxes(size_t ndim, - const doublereal* const grad_T, - size_t ldx, - const doublereal* const grad_X, - size_t ldf, doublereal* const fluxes); - - //! Initialize the transport object - /*! - * Here we change all of the internal dimensions to be sufficient. - * We get the object ready to do property evaluations. - * - * @param tr Transport parameters for all of the species in the phase. - */ - virtual bool initGas(GasTransportParams& tr); - - /** - * Reads the transport table specified (currently defaults to internal file) - * - * Reads the user-specified transport table, appending new species - * data and/or replacing default species data. - */ - void read_blottner_transport_table(); - - friend class TransportFactory; - -protected: - PecosTransport(); - -private: - - //! Calculate the pressure from the ideal gas law - doublereal pressure_ig() const { - return (m_thermo->molarDensity() * GasConstant * - m_thermo->temperature()); - } - - // mixture attributes - int m_nsp; - vector_fp m_mw; - - // polynomial fits - std::vector m_visccoeffs; - std::vector m_condcoeffs; - std::vector m_diffcoeffs; - vector_fp m_polytempvec; - - // blottner fits - //int species = 20; - double a[500], b[500], c[500]; - - // property values - DenseMatrix m_bdiff; - vector_fp m_visc; - vector_fp m_sqvisc; - vector_fp m_cond; - - vector_fp m_molefracs; - - std::vector > m_poly; - std::vector m_astar_poly; - std::vector m_bstar_poly; - std::vector m_cstar_poly; - std::vector m_om22_poly; - DenseMatrix m_astar; - DenseMatrix m_bstar; - DenseMatrix m_cstar; - DenseMatrix m_om22; - - DenseMatrix m_phi; // viscosity weighting functions - DenseMatrix m_wratjk, m_wratkj1; - - vector_fp m_zrot; - vector_fp m_crot; - vector_fp m_cinternal; - vector_fp m_eps; - vector_fp m_alpha; - vector_fp m_dipoleDiag; - - doublereal m_temp, m_logt, m_kbt, m_t14, m_t32; - doublereal m_sqrt_kbt, m_sqrt_t; - - vector_fp m_sqrt_eps_k; - DenseMatrix m_log_eps_k; - vector_fp m_frot_298; - vector_fp m_rotrelax; - - doublereal m_lambda; - doublereal m_viscmix; - - // work space - vector_fp m_spwork; - - void updateThermal_T(); - - /** - * Update the temperature-dependent viscosity terms. Updates the array of - * pure species viscosities, and the weighting functions in the viscosity - * mixture rule. The flag m_visc_ok is set to true. - */ - void updateViscosity_T(); - - /** - * Update the temperature-dependent parts of the mixture-averaged - * thermal conductivity. - * - * Calculated as, - * \f[ - * k= \mu_s (5/2 * C_{v,s}^{trans} + C_{v,s}^{rot} + C_{v,s}^{vib} - * \f] - */ - void updateCond_T(); - - /** - * Update the pure-species viscosities. (Pa-s) = (kg/m/sec) - * - * Using Blottner fit for viscosity. Defines kinematic viscosity - * of the form - * \f[ - * \mu_s\left(T\right) = 0.10 \exp\left(A_s\left(\log T\right)^2 + B_s\log T + C_s\right) - * \f] - * where \f$ A_s \f$, \f$ B_s \f$, and \f$ C_s \f$ are constants. - */ - void updateSpeciesViscosities(); - - /** - * Update the binary diffusion coefficients. These are evaluated - * from the polynomial fits at unit pressure (1 Pa). - */ - void updateDiff_T(); - void correctBinDiffCoeffs(); - bool m_viscmix_ok; - bool m_viscwt_ok; - bool m_spvisc_ok; - bool m_diffmix_ok; - bool m_bindiff_ok; - bool m_abc_ok; - bool m_spcond_ok; - bool m_condmix_ok; - - int m_mode; - - DenseMatrix m_epsilon; - DenseMatrix m_diam; - DenseMatrix incl; - bool m_debug; - - // specific heats - vector_fp cv_rot; - vector_fp cp_R; - vector_fp cv_int; - -}; -} -#endif diff --git a/include/cantera/transport/TransportBase.h b/include/cantera/transport/TransportBase.h index 6178f8fe4..d19505e6f 100644 --- a/include/cantera/transport/TransportBase.h +++ b/include/cantera/transport/TransportBase.h @@ -52,7 +52,6 @@ const int cAqueousTransport = 750; const int cSimpleTransport = 770; const int cRadiativeTransport = 800; const int cWaterTransport = 721; -const int cPecosTransport = 900; //! \endcond //! The diffusion fluxes must be referenced to a particular reference diff --git a/include/cantera/transport/TransportFactory.h b/include/cantera/transport/TransportFactory.h index 52e05f13b..747e8ed07 100644 --- a/include/cantera/transport/TransportFactory.h +++ b/include/cantera/transport/TransportFactory.h @@ -107,22 +107,6 @@ public: virtual Transport* newTransport(thermo_t* thermo, int log_level=0); - //! Initialize an existing transport manager - /*! - * This routine sets up an existing gas-phase transport manager. It - * calculates the collision integrals and calls the initGas() function to - * populate the species-dependent data structure. - * - * @param tr Pointer to the Transport manager - * @param thermo Pointer to the ThermoPhase object - * @param mode Chemkin compatible mode or not. This alters the specification of the - * collision integrals. defaults to no. - * @param log_level Defaults to zero, no logging - * @deprecated To be removed after Cantera 2.2. This initialization is now - * handled directly by GasTransport::init. - */ - virtual void initTransport(Transport* tr, thermo_t* thermo, int mode=0, int log_level=0); - //! Initialize an existing transport manager for liquid phase /*! * This routine sets up an existing liquid-phase transport manager. It is diff --git a/include/cantera/transport/TransportParams.h b/include/cantera/transport/TransportParams.h index 76585be9f..edd198c0d 100644 --- a/include/cantera/transport/TransportParams.h +++ b/include/cantera/transport/TransportParams.h @@ -54,200 +54,6 @@ public: int log_level; }; -//! This structure holds transport model parameters relevant to transport in ideal -//! gases with a kinetic theory of gases derived transport model. -/*! - * This structure is used by TransportFactory object. - * @deprecated Unused. Mostly merged into class GasTransport. This class will be - * removed after Cantera 2.2. - */ -class GasTransportParams : public TransportParams -{ -public: - GasTransportParams(); - - // polynomial fits - - //! temperature-fit of the viscosity - /*! - * The outer loop the number of species, nsp - * The inner loop is over degree + 1, which is the polynomial order of the collision integral fit. - */ - std::vector visccoeffs; - - //! temperature-fits of the heat conduction - /*! - * The outer loop the number of species, nsp - * The inner loop is over degree + 1, which is the polynomial order of the collision integral fit. - */ - std::vector condcoeffs; - - //! temperature-fits of the diffusivity - /*! - * The outer loop the number of species, nsp - * The inner loop is over degree + 1, which is the polynomial order of the collision integral fit. - */ - std::vector diffcoeffs; - - //! This is vector of vectors containing the integer lookup value for the (i,j) interaction - /*! - * The outer loop is over a flat (i,j) index that is parameterized on the tr.delta(i,j) value. - * Unique values of delta get their own spot in the array. The values of delta are stored in - * the fitlist vector. - * - * The inner loop is over degree + 1, which is the polynomial order of the collision integral fit. - */ - std::vector > poly; - - //! This is vector of vectors containing the astar fit. - /*! - * The outer loop is over a flat (i,j) index that is parameterized on the tr.delta(i,j) value. - * Unique values of delta get their own spot in the array. The values of delta are stored in - * the fitlist vector. - * - * The inner loop is over degree + 1, which is the polynomial order of the collision integral fit. - */ - std::vector omega22_poly; - - //! This is vector of vectors containing the astar fit. - /*! - * The outer loop is over a flat (i,j) index that is parameterized on the tr.delta(i,j) value. - * Unique values of delta get their own spot in the array. The values of delta are stored in - * the fitlist vector. - * - * The inner loop is over degree + 1, which is the polynomial order of the collision integral fit. - */ - std::vector astar_poly; - - //! This is vector of vectors containing the astar fit. - /*! - * The outer loop is over a flat (i,j) index that is parameterized on the tr.delta(i,j) value. - * Unique values of delta get their own spot in the array. The values of delta are stored in - * the fitlist vector. - * - * The inner loop is over degree + 1, which is the polynomial order of the collision integral fit. - */ - std::vector bstar_poly; - - //! This is vector of vectors containing the astar fit. - /*! - * The outer loop is over a flat (i,j) index that is parameterized on the tr.delta(i,j) value. - * Unique values of delta get their own spot in the array. The values of delta are stored in - * the fitlist vector. - * - * The inner loop is over degree + 1, which is the polynomial order of the collision integral fit. - */ - std::vector cstar_poly; - - //! Rotational relaxation number for the species in the current phase - /*! - * length is the number of species in the phase - * units are dimensionless - */ - vector_fp zrot; - - //! Dimensionless rotational heat capacity of the species in the current phase - /*! - * These values are 0, 1 and 1.5 for single-molecule, linear, and nonlinear species respectively - * length is the number of species in the phase - * units are dimensionless (Cr / R) - */ - vector_fp crot; - - //! Vector of booleans indicating whether a species is a polar molecule - /*! - * Length is nsp - */ - std::vector polar; - - //! Polarizability of each species in the phase - /*! - * Length = nsp - * Units = m^3 - */ - vector_fp alpha; - - //! This is vector containing the values of delta(i,j) that are used in the collision integral fits. - /*! - * This is used in astar_poly, bstar_poly, cstar_poly, and omega22_poly. - * The outer loop is over a flat (i,j) index that is parameterized on the tr.delta(i,j) value. - * Unique values of delta get their own spot in the array. The values of delta are stored in - * the fitlist vector. - */ - vector_fp fitlist; - - //! Lennard-Jones well-depth of the species in the current phase - /*! - * length is the number of species in the phase - * Units are Joules (Note this is not Joules/kmol) (note, no kmol -> this is a per molecule amount) - */ - vector_fp eps; - - //! Lennard-Jones diameter of the species in the current phase - /*! - * length is the number of species in the phase - * units are in meters. - */ - vector_fp sigma; - - //! This is the reduced mass of the interaction between species i and j - /*! - * tr.reducedMass(i,j) = tr.mw[i] * tr.mw[j] / (Avogadro * (tr.mw[i] + tr.mw[j])); - * - * Units are kg (note, no kmol -> this is a per molecule amount) - * - * Length nsp * nsp. This is a symmetric matrix - */ - DenseMatrix reducedMass; - - //! hard-sphere diameter for (i,j) collision - /*! - * diam(i,j) = 0.5*(tr.sigma[i] + tr.sigma[j]); - * Units are m (note, no kmol -> this is a per molecule amount) - * - * Length nsp * nsp. This is a symmetric matrix. - */ - DenseMatrix diam; - - //! The effective well depth for (i,j) collisions - /*! - * epsilon(i,j) = sqrt(tr.eps[i]*tr.eps[j]); - * Units are Joules (note, no kmol -> this is a per molecule amount) - * - * Length nsp * nsp. This is a symmetric matrix. - */ - DenseMatrix epsilon; - - //! The effective dipole moment for (i,j) collisions - /*! - * dipoleMoment has units of Debye. A Debye is 3.335e-30 C-m - * - * tr.dipole(i,i) = 1.e-21 / lightSpeed * dipoleMoment; - * tr.dipole(i,j) = sqrt(tr.dipole(i,i)*tr.dipole(j,j)); - * (note, no kmol -> this is a per molecule amount) - * - * Length nsp * nsp. This is a symmetric matrix. - */ - DenseMatrix dipole; - - //! Matrix containing the reduced dipole moment of the interaction between two species - /*! - * This is the reduced dipole moment of the interaction between two species - * 0.5 * tr.dipole(i,j)^2 / (4 * Pi * epsilon_0 * epsilon(i,j) * d^3); - * - * Length nsp * nsp .This is a symmetric matrix - */ - DenseMatrix delta; - - //! Pitzer acentric factor - /*! - * Length is the number of species in the phase. - * Unitless - */ - vector_fp w_ac; - -}; - } // End of namespace Cantera #endif //CT_TRANSPORTPARAMS_H diff --git a/include/cantera/zeroD/ReactorNet.h b/include/cantera/zeroD/ReactorNet.h index 0a936f17f..416240c60 100644 --- a/include/cantera/zeroD/ReactorNet.h +++ b/include/cantera/zeroD/ReactorNet.h @@ -117,13 +117,6 @@ public: //! Add the reactor *r* to this reactor network. void addReactor(Reactor& r); - //! Add the reactor *r* to this reactor network. - /** - * @deprecated To be removed after Cantera 2.2. Use addReactor(Reactor&) - * instead. - */ - void addReactor(Reactor* r, bool iown = false); - //! Return a reference to the *n*-th reactor in this network. The reactor //! indices are determined by the order in which the reactors were added //! to the reactor network. diff --git a/interfaces/cython/cantera/ctml_writer.py b/interfaces/cython/cantera/ctml_writer.py index e2acae6f2..6f2b94a72 100644 --- a/interfaces/cython/cantera/ctml_writer.py +++ b/interfaces/cython/cantera/ctml_writer.py @@ -994,8 +994,7 @@ class Arrhenius(rate_expression): A = 0.0, b = 0.0, E = 0.0, - coverage = [], - n = None): + coverage = []): """ :param A: The pre-exponential coefficient. Required input. If entered without @@ -1011,22 +1010,7 @@ class Arrhenius(rate_expression): parameters. For multiple coverage dependencies, a list of lists containing the individual sets of coverage parameters. Only used for surface and edge reactions. - :param n: - The temperature exponent. Dimensionless. Default: 0.0. Deprecated usage - provided for compatibility. """ - if n is not None and b != 0.0: - raise CTI_Error("n and b cannot both be specified for the " - "temperature exponent. Specify one or the other.") - elif n is not None and b == 0.0: - b = n - _printerr( - "Warning: Usage of n to specify the temperature exponent is " - "deprecated and will be removed in a future version. Use b " - "to specify the temperature exponent by keyword. Please check " - "your cti file for places where the temperature exponent of " - "the reaction rate is set by n = XXX and change them to " - "b = XXX.") self._c = [A, b, E] diff --git a/src/base/ct2ctml.cpp b/src/base/ct2ctml.cpp index f0a190586..fae0d35a0 100644 --- a/src/base/ct2ctml.cpp +++ b/src/base/ct2ctml.cpp @@ -274,22 +274,4 @@ void ck2cti(const std::string& in_file, const std::string& thermo_file, } } -void get_CTML_Tree(XML_Node* rootPtr, const std::string& file, const int debug) -{ - warn_deprecated("get_CTML_Tree", "To be removed after Cantera 2.2. " - "Use get_XML_File instead."); - XML_Node* src = get_XML_File(file); - src->copy(rootPtr); -} - -XML_Node getCtmlTree(const std::string& file) -{ - warn_deprecated("getCtmlTree", "To be removed after Cantera 2.2. " - "Use get_XML_File instead."); - XML_Node root; - XML_Node* src = get_XML_File(file); - src->copy(&root); - return root; -} - } diff --git a/src/base/xml.cpp b/src/base/xml.cpp index 48bd039ea..7be7e9656 100644 --- a/src/base/xml.cpp +++ b/src/base/xml.cpp @@ -471,13 +471,6 @@ std::string XML_Node::value() const return m_value; } -std::string XML_Node::operator()() const -{ - warn_deprecated("XML_Node::operator()", - "To be removed after Cantera 2.2. Use XML_Node::value()."); - return m_value; -} - doublereal XML_Node::fp_value() const { return fpValueCheck(m_value); @@ -912,18 +905,6 @@ void XML_Node::unlock() } } -void XML_Node::getChildren(const std::string& nm, - std::vector& children_) const -{ - warn_deprecated("XML_Node::getChildren", "To be removed after Cantera 2.2." - "Use overload that returns the vector of XML_Node pointers."); - for (size_t i = 0; i < nChildren(); i++) { - if (child(i).name() == nm) { - children_.push_back(&child(i)); - } - } -} - std::vector XML_Node::getChildren(const std::string& nm) const { std::vector children_; diff --git a/src/equil/BasisOptimize.cpp b/src/equil/BasisOptimize.cpp index 4a2a8862c..3b016ddb7 100644 --- a/src/equil/BasisOptimize.cpp +++ b/src/equil/BasisOptimize.cpp @@ -419,10 +419,10 @@ static void print_stringTrunc(const char* str, int space, int alignment) } } -size_t ElemRearrange(size_t nComponents, const vector_fp& elementAbundances, - MultiPhase* mphase, - std::vector& orderVectorSpecies, - std::vector& orderVectorElements) +void ElemRearrange(size_t nComponents, const vector_fp& elementAbundances, + MultiPhase* mphase, + std::vector& orderVectorSpecies, + std::vector& orderVectorElements) { size_t j, k, l, i, jl, ml, jr, ielem, jj, kk=0; @@ -627,7 +627,6 @@ size_t ElemRearrange(size_t nComponents, const vector_fp& elementAbundances, * jr is counted from 0, via the C convention. */ } while (jr < (nComponents-1)); - return nComponents; } } diff --git a/src/equil/equilibrate.cpp b/src/equil/equilibrate.cpp deleted file mode 100644 index bb04d90ad..000000000 --- a/src/equil/equilibrate.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/** - * @file equilibrate.cpp Driver routines for the chemical equilibrium solvers. - */ - -#include "cantera/equil/ChemEquil.h" -#include "cantera/equil/vcs_MultiPhaseEquil.h" - -namespace Cantera -{ - -doublereal equilibrate(MultiPhase& s, const char* XY, - doublereal tol, int maxsteps, int maxiter, - int loglevel) -{ - warn_deprecated("equilibrate(MultiPhase&, ...)", - "Use MultiPhase::equilibrate instead. To be removed after Cantera 2.2."); - s.init(); - int ixy = _equilflag(XY); - if (ixy == TP || ixy == HP || ixy == SP || ixy == TV) { - try { - double err = s.equilibrate(ixy, tol, maxsteps, maxiter, loglevel); - return err; - } catch (CanteraError& err) { - err.save(); - throw err; - } - } else { - throw CanteraError("equilibrate","unsupported option"); - return -1.0; - } - return 0.0; -} - -int equilibrate(thermo_t& s, const char* XY, int solver, - doublereal rtol, int maxsteps, int maxiter, int loglevel) -{ - warn_deprecated("equilibrate(ThermoPhase&, ...)", - "Use ThermoPhase::equilibrate instead. To be removed after Cantera 2.2."); - bool redo = true; - int retn = -1; - int nAttempts = 0; - int retnSub = 0; - - while (redo) { - if (solver >= 2) { - int printLvlSub = loglevel; - int estimateEquil = 0; - try { - MultiPhase m; - m.addPhase(&s, 1.0); - m.init(); - nAttempts++; - vcs_equilibrate(m, XY, estimateEquil, printLvlSub, solver, - rtol, maxsteps, maxiter, loglevel-1); - redo = false; - retn = nAttempts; - } catch (CanteraError& err) { - err.save(); - if (nAttempts < 2) { - solver = -1; - } else { - throw err; - } - } - } else if (solver == 1) { - try { - MultiPhase m; - m.addPhase(&s, 1.0); - m.init(); - nAttempts++; - equilibrate(m, XY, rtol, maxsteps, maxiter, loglevel-1); - redo = false; - retn = nAttempts; - } catch (CanteraError& err) { - err.save(); - if (nAttempts < 2) { - solver = -1; - } else { - throw err; - } - } - } else { // solver <= 0 - /* - * Call the element potential solver - */ - try { - ChemEquil e; - e.options.maxIterations = maxsteps; - e.options.relTolerance = rtol; - nAttempts++; - bool useThermoPhaseElementPotentials = true; - retnSub = e.equilibrate(s, XY, useThermoPhaseElementPotentials, - loglevel-1); - if (retnSub < 0) { - if (nAttempts < 2) { - solver = 1; - } else { - throw CanteraError("equilibrate", - "Both equilibrium solvers failed"); - } - } - retn = nAttempts; - s.setElementPotentials(e.elementPotentials()); - redo = false; - } - - catch (CanteraError& err) { - err.save(); - // If ChemEquil fails, try the MultiPhase solver - if (solver < 0) { - solver = 1; - } else { - redo = false; - throw err; - } - } - } - } // while (redo) - /* - * We are here only for a success - */ - return retn; -} -} diff --git a/src/equil/vcs_equilibrate.cpp b/src/equil/vcs_equilibrate.cpp deleted file mode 100644 index cefe7bda2..000000000 --- a/src/equil/vcs_equilibrate.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/** - * @file vcs_equilibrate.cpp - * Driver routines for equilibrium solvers - */ -/* - * Copyright (2006) Sandia Corporation. Under the terms of - * Contract DE-AC04-94AL85000 with Sandia Corporation, the - * U.S. Government retains certain rights in this software. - */ -#include "cantera/equil/vcs_MultiPhaseEquil.h" -#include "cantera/equil/equil.h" - -#include "cantera/base/stringUtils.h" -#include "cantera/equil/ChemEquil.h" - -using namespace std; - -namespace Cantera -{ -int vcs_equilibrate(thermo_t& s, const char* XY, - int estimateEquil, int printLvl, - int solver, - doublereal rtol, int maxsteps, int maxiter, - int loglevel) -{ - warn_deprecated("vcs_equilibrate", "Use ThermoPhase::equilibrate instead. " - "To be removed after Cantera 2.2."); - MultiPhase* m = 0; - int retn = 1; - - if (solver == 2) { - m = new MultiPhase; - try { - /* - * Set the kmoles of the phase to 1.0, arbitrarily. - * It actually doesn't matter. - */ - m->addPhase(&s, 1.0); - m->init(); - - retn = vcs_equilibrate(*m, XY, estimateEquil, printLvl, solver, - rtol, maxsteps, maxiter, loglevel); - delete m; - } catch (CanteraError& err) { - err.save(); - delete m; - throw err; - } - } else if (solver == 1) { - m = new MultiPhase; - try { - m->addPhase(&s, 1.0); - m->init(); - (void) equilibrate(*m, XY, rtol, maxsteps, maxiter, loglevel-1); - delete m; - retn = 1; - } catch (CanteraError& err) { - err.save(); - delete m; - throw err; - } - } else if (solver == 0) { - ChemEquil* e = new ChemEquil; - try { - e->options.maxIterations = maxsteps; - e->options.relTolerance = rtol; - bool useThermoPhaseElementPotentials = false; - if (estimateEquil == 0) { - useThermoPhaseElementPotentials = true; - } - int retnSub = e->equilibrate(s, XY, - useThermoPhaseElementPotentials, loglevel-1); - if (retnSub < 0) { - delete e; - throw CanteraError("equilibrate", - "ChemEquil equilibrium solver failed"); - } - retn = 1; - s.setElementPotentials(e->elementPotentials()); - delete e; - } catch (CanteraError& err) { - err.save(); - delete e; - throw err; - } - } else { - throw CanteraError("vcs_equilibrate", - "unknown solver"); - } - - /* - * We are here only for a success - */ - return retn; -} - -int vcs_equilibrate(MultiPhase& s, const char* XY, - int estimateEquil, int printLvl, int solver, - doublereal tol, int maxsteps, int maxiter, - int loglevel) -{ - int ixy = _equilflag(XY); - int retn = vcs_equilibrate_1(s, ixy, estimateEquil, printLvl, solver, - tol, maxsteps, maxiter, loglevel); - return retn; -} - -int vcs_equilibrate_1(MultiPhase& s, int ixy, - int estimateEquil, int printLvl, int solver, - doublereal tol, int maxsteps, int maxiter, int loglevel) -{ - warn_deprecated("vcs_equilibrate_1", "Use MultiPhase::equilibrate instead. " - "To be removed after Cantera 2.2."); - static int counter = 0; - int retn = 1; - - int printLvlSub = std::max(0, printLvl-1); - - s.init(); - - if (solver == 2) { - try { - vcs_MultiPhaseEquil* eqsolve = new vcs_MultiPhaseEquil(&s, printLvlSub); - int err = eqsolve->equilibrate(ixy, estimateEquil, printLvlSub, tol, maxsteps, loglevel); - if (err != 0) { - retn = -1; - } - // hard code a csv output file. - if (printLvl > 0) { - string reportFile = "vcs_equilibrate_res.csv"; - if (counter > 0) { - reportFile = "vcs_equilibrate_res_" + int2str(counter) + ".csv"; - } - eqsolve->reportCSV(reportFile); - counter++; - } - delete eqsolve; - } catch (CanteraError& e) { - e.save(); - retn = -1; - throw e; - } - } else if (solver == 1) { - if (ixy == TP || ixy == HP || ixy == SP || ixy == TV) { - try { - s.equilibrate(ixy, tol, maxsteps, maxiter, loglevel); - return 0; - } catch (CanteraError& e) { - e.save(); - throw e; - } - } else { - throw CanteraError("equilibrate","unsupported option"); - } - } else { - throw CanteraError("vcs_equilibrate_1", "unknown solver"); - } - return retn; -} - -int vcs_determine_PhaseStability(MultiPhase& s, int iphase, - double& funcStab, int printLvl, int loglevel) -{ - int iStab = 0; - static int counter = 0; - int printLvlSub = std::max(0, printLvl-1); - - s.init(); - try { - vcs_MultiPhaseEquil* eqsolve = new vcs_MultiPhaseEquil(&s, printLvlSub); - iStab = eqsolve->determine_PhaseStability(iphase, funcStab, printLvlSub, loglevel); - // hard code a csv output file. - if (printLvl > 0) { - string reportFile = "vcs_phaseStability.csv"; - if (counter > 0) { - reportFile = "vcs_phaseStability_" + int2str(counter) + ".csv"; - } - eqsolve->reportCSV(reportFile); - counter++; - } - delete eqsolve; - } catch (CanteraError& e) { - throw e; - } - return iStab; -} - -} diff --git a/src/kinetics/AqueousKinetics.cpp b/src/kinetics/AqueousKinetics.cpp index 1774bf130..e7bcc99b1 100644 --- a/src/kinetics/AqueousKinetics.cpp +++ b/src/kinetics/AqueousKinetics.cpp @@ -148,15 +148,6 @@ void AqueousKinetics::getFwdRateConstants(doublereal* kfwd) } } -void AqueousKinetics::addReaction(ReactionData& r) -{ - if (r.reactionType == ELEMENTARY_RXN) { - addElementaryReaction(r); - } - - BulkKinetics::addReaction(r); -} - bool AqueousKinetics::addReaction(shared_ptr r) { bool added = BulkKinetics::addReaction(r); diff --git a/src/kinetics/BulkKinetics.cpp b/src/kinetics/BulkKinetics.cpp index f7ba6a8f2..9097d2037 100644 --- a/src/kinetics/BulkKinetics.cpp +++ b/src/kinetics/BulkKinetics.cpp @@ -115,19 +115,6 @@ void BulkKinetics::getRevRateConstants(doublereal* krev, bool doIrreversible) } } -void BulkKinetics::addReaction(ReactionData& r) -{ - Kinetics::addReaction(r); - m_dn.push_back(accumulate(r.pstoich.begin(), r.pstoich.end(), 0.0) - - accumulate(r.rstoich.begin(), r.rstoich.end(), 0.0)); - - if (r.reversible) { - m_revindex.push_back(nReactions()); - } else { - m_irrev.push_back(nReactions()); - } -} - bool BulkKinetics::addReaction(shared_ptr r) { bool added = Kinetics::addReaction(r); @@ -156,11 +143,6 @@ bool BulkKinetics::addReaction(shared_ptr r) return true; } -void BulkKinetics::addElementaryReaction(ReactionData& r) -{ - m_rates.install(nReactions(), r); -} - void BulkKinetics::addElementaryReaction(ElementaryReaction& r) { m_rates.install(nReactions()-1, r.rate); diff --git a/src/kinetics/ElectrodeKinetics.cpp b/src/kinetics/ElectrodeKinetics.cpp index c44503cd6..ad463eaa1 100644 --- a/src/kinetics/ElectrodeKinetics.cpp +++ b/src/kinetics/ElectrodeKinetics.cpp @@ -484,55 +484,6 @@ void ElectrodeKinetics::updateROP() } //================================================================================================================== // -// This version of takes the electrons out of the reaction rate expression -// (note: with proper specification of the phase, this shouldn't make a numerical difference (power of 1). -// But it certainly is a complication and unneeded work) -// (TODO: probably can take stoichiometric solids out of the reaction order expression as well. -// They all contribute powers of 1 as well) -// -void ElectrodeKinetics::determineFwdOrdersBV(ReactionData& rdata, std::vector& fwdFullorders) -{ - // - // Start out with the full ROP orders vector. - // This vector will have the BV exchange current density orders in it. - // - fwdFullorders = rdata.forwardFullOrder_; - // - // forward and reverse beta values - // - double betaf = rdata.beta; - //double betar = 1.0 - betaf; - // - // Loop over the reactants doing away the BV terms. - // This should leave the reactant terms only, even if they are non-mass action. - // - for (size_t j = 0; j < rdata.reactants.size(); j++) { - size_t kkin = rdata.reactants[j]; - double oo = rdata.rstoich[j]; - if (kkin != kElectronIndex_) { - fwdFullorders[kkin] += betaf * oo; - if (abs(fwdFullorders[kkin]) < 0.00001) { - fwdFullorders[kkin] = 0.0; - } - } else { - fwdFullorders[kkin] = 0.0; - } - } - for (size_t j = 0; j < rdata.products.size(); j++) { - size_t kkin = rdata.products[j]; - double oo = rdata.pstoich[j]; - if (kkin != kElectronIndex_) { - fwdFullorders[kkin] -= betaf * oo; - if (abs(fwdFullorders[kkin]) < 0.00001) { - fwdFullorders[kkin] = 0.0; - } - } else { - fwdFullorders[kkin] = 0.0; - } - } -} -//================================================================================================================== -// // When the BV form is used we still need to go backwards to calculate the forward rate of progress. // This routine does that // diff --git a/src/kinetics/GasKinetics.cpp b/src/kinetics/GasKinetics.cpp index 24d362e95..b46e6bc92 100644 --- a/src/kinetics/GasKinetics.cpp +++ b/src/kinetics/GasKinetics.cpp @@ -240,33 +240,6 @@ void GasKinetics::getFwdRateConstants(doublereal* kfwd) } } -void GasKinetics::addReaction(ReactionData& r) -{ - switch (r.reactionType) { - case ELEMENTARY_RXN: - addElementaryReaction(r); - break; - case THREE_BODY_RXN: - addThreeBodyReaction(r); - break; - case FALLOFF_RXN: - case CHEMACT_RXN: - addFalloffReaction(r); - break; - case PLOG_RXN: - addPlogReaction(r); - break; - case CHEBYSHEV_RXN: - addChebyshevReaction(r); - break; - default: - throw CanteraError("GasKinetics::addReaction", "Invalid reaction type specified"); - } - - // operations common to all reaction types - BulkKinetics::addReaction(r); -} - bool GasKinetics::addReaction(shared_ptr r) { // operations common to all reaction types @@ -299,50 +272,6 @@ bool GasKinetics::addReaction(shared_ptr r) return true; } -void GasKinetics::addFalloffReaction(ReactionData& r) -{ - // install high and low rate coeff calculators - // and add constant terms to high and low rate coeff value vectors - m_falloff_high_rates.install(m_nfall, r); - m_rfn_high.push_back(r.rateCoeffParameters[0]); - std::swap(r.rateCoeffParameters, r.auxRateCoeffParameters); - m_falloff_low_rates.install(m_nfall, r); - m_rfn_low.push_back(r.rateCoeffParameters[0]); - - // add this reaction number to the list of falloff reactions - m_fallindx.push_back(nReactions()); - m_rfallindx[nReactions()] = m_nfall; - - // install the enhanced third-body concentration calculator for this - // reaction - m_falloff_concm.install(m_nfall, r.thirdBodyEfficiencies, - r.default_3b_eff); - - // install the falloff function calculator for this reaction - m_falloffn.install(m_nfall, r.falloffType, r.reactionType, - r.falloffParameters); - - // increment the falloff reaction counter - ++m_nfall; -} - -void GasKinetics::addThreeBodyReaction(ReactionData& r) -{ - m_rates.install(nReactions(), r); - m_3b_concm.install(nReactions(), r.thirdBodyEfficiencies, - r.default_3b_eff); -} - -void GasKinetics::addPlogReaction(ReactionData& r) -{ - m_plog_rates.install(nReactions(), r); -} - -void GasKinetics::addChebyshevReaction(ReactionData& r) -{ - m_cheb_rates.install(nReactions(), r); -} - void GasKinetics::addFalloffReaction(FalloffReaction& r) { // install high and low rate coeff calculators diff --git a/src/kinetics/InterfaceKinetics.cpp b/src/kinetics/InterfaceKinetics.cpp index 00b6cc2bb..d2af00ae4 100644 --- a/src/kinetics/InterfaceKinetics.cpp +++ b/src/kinetics/InterfaceKinetics.cpp @@ -6,7 +6,6 @@ #include "cantera/kinetics/InterfaceKinetics.h" #include "cantera/kinetics/EdgeKinetics.h" -#include "cantera/kinetics/ReactionData.h" #include "cantera/kinetics/RateCoeffMgr.h" #include "cantera/kinetics/ImplicitSurfChem.h" #include "cantera/thermo/SurfPhase.h" @@ -764,123 +763,6 @@ void InterfaceKinetics::getDeltaSSEntropy(doublereal* deltaS) getReactionDelta(DATA_PTR(m_grt), deltaS); } -void InterfaceKinetics::addReaction(ReactionData& r) -{ - int reactionType = r.reactionType; - - // Install rate coeff calculator - if (r.cov.size() > 3) { - m_has_coverage_dependence = true; - } - for (size_t m = 0; m < r.cov.size(); m++) { - r.rateCoeffParameters.push_back(r.cov[m]); - } - - /* - * Temporarily change the reaction rate coefficient type to surface arrhenius. - * This is what is expected. We'll handle exchange current types below by hand. - */ - int reactionRateCoeffType_orig = r.rateCoeffType; - if (r.rateCoeffType == EXCHANGE_CURRENT_REACTION_RATECOEFF_TYPE) { - r.rateCoeffType = SURF_ARRHENIUS_REACTION_RATECOEFF_TYPE; - } - if (r.rateCoeffType == ARRHENIUS_REACTION_RATECOEFF_TYPE) { - r.rateCoeffType = SURF_ARRHENIUS_REACTION_RATECOEFF_TYPE; - } - /* - * Install the reaction rate into the vector of reactions handled by this class - */ - m_rates.install(m_ii, r); - - /* - * Change the reaction rate coefficient type back to its original value - */ - r.rateCoeffType = reactionRateCoeffType_orig; - - // Store activation energy - m_E.push_back(r.rateCoeffParameters[2]); - - if (r.beta > 0.0) { - m_has_electrochem_rxns = true; - m_beta.push_back(r.beta); - m_ctrxn.push_back(m_ii); - if (r.rateCoeffType == EXCHANGE_CURRENT_REACTION_RATECOEFF_TYPE) { - m_has_exchange_current_density_formulation = true; - m_ctrxn_ecdf.push_back(1); - } else { - m_ctrxn_ecdf.push_back(0); - } - m_ctrxn_resistivity_.push_back(r.filmResistivity); - - if (reactionType == BUTLERVOLMER_NOACTIVITYCOEFFS_RXN || - reactionType == BUTLERVOLMER_RXN || - reactionType == SURFACEAFFINITY_RXN || - reactionType == GLOBAL_RXN) { - // Specify alternative forms of the electrochemical reaction - if (r.reactionType == BUTLERVOLMER_RXN) { - m_ctrxn_BVform.push_back(1); - } else if (r.reactionType == BUTLERVOLMER_NOACTIVITYCOEFFS_RXN) { - m_ctrxn_BVform.push_back(2); - } else { - // set the default to be the normal forward / reverse calculation method - m_ctrxn_BVform.push_back(0); - } - if (r.forwardFullOrder_.size() > 0) { - RxnOrders* ro = new RxnOrders(); - ro->fill(r.forwardFullOrder_); - m_ctrxn_ROPOrdersList_.push_back(ro); - m_ctrxn_FwdOrdersList_.push_back(0); - - // Fill in the Fwd Orders dependence here for B-V reactions - if (r.reactionType == BUTLERVOLMER_NOACTIVITYCOEFFS_RXN || - r.reactionType == BUTLERVOLMER_RXN) { - vector_fp fwdFullorders(m_kk, 0.0); - determineFwdOrdersBV(r, fwdFullorders); - RxnOrders* ro = new RxnOrders(); - ro->fill(fwdFullorders); - m_ctrxn_FwdOrdersList_[m_ii] = ro; - } - } else { - m_ctrxn_ROPOrdersList_.push_back(0); - m_ctrxn_FwdOrdersList_.push_back(0); - } - - } else { - m_ctrxn_BVform.push_back(0); - m_ctrxn_ROPOrdersList_.push_back(0); - m_ctrxn_FwdOrdersList_.push_back(0); - if (r.filmResistivity > 0.0) { - throw CanteraError("InterfaceKinetics::addReaction()", - "film resistivity set for elementary reaction"); - } - } - } - - if (r.reversible) { - m_revindex.push_back(nReactions()); - m_nrev++; - } else { - m_irrev.push_back(nReactions()); - m_nirrev++; - } - Kinetics::addReaction(r); - - m_rxnPhaseIsReactant.push_back(std::vector(nPhases(), false)); - m_rxnPhaseIsProduct.push_back(std::vector(nPhases(), false)); - - size_t i = m_ii - 1; - for (size_t ik = 0; ik < r.reactants.size(); ik++) { - size_t k = r.reactants[ik]; - size_t p = speciesPhaseIndex(k); - m_rxnPhaseIsReactant[i][p] = true; - } - for (size_t ik = 0; ik < r.products.size(); ik++) { - size_t k = r.products[ik]; - size_t p = speciesPhaseIndex(k); - m_rxnPhaseIsProduct[i][p] = true; - } -} - bool InterfaceKinetics::addReaction(shared_ptr r_base) { size_t i = nReactions(); @@ -1259,39 +1141,6 @@ void InterfaceKinetics::setPhaseStability(const size_t iphase, const int isStabl } } -void InterfaceKinetics::determineFwdOrdersBV(ReactionData& rdata, std::vector& fwdFullorders) -{ - // Start out with the full ROP orders vector. - // This vector will have the BV exchange current density orders in it. - fwdFullorders = rdata.forwardFullOrder_; - - // forward and reverse beta values - double betaf = rdata.beta; - - // Loop over the reactants doing away with the BV terms. - // This should leave the reactant terms only, even if they are non-mass action. - for (size_t j = 0; j < rdata.reactants.size(); j++) { - size_t kkin = rdata.reactants[j]; - double oo = rdata.rstoich[j]; - fwdFullorders[kkin] += betaf * oo; - // just to make sure roundoff doesn't leave a term that should be zero (haven't checked this out yet) - if (abs(fwdFullorders[kkin]) < 0.00001) { - fwdFullorders[kkin] = 0.0; - } - } - - // Loop over the products doing away with the BV terms. - // This should leave the reactant terms only, even if they are non-mass action. - for (size_t j = 0; j < rdata.products.size(); j++) { - size_t kkin = rdata.products[j]; - double oo = rdata.pstoich[j]; - fwdFullorders[kkin] -= betaf * oo; - if (abs(fwdFullorders[kkin]) < 0.00001) { - fwdFullorders[kkin] = 0.0; - } - } -} - void InterfaceKinetics::determineFwdOrdersBV(ElectrochemicalReaction& r, std::vector& fwdFullOrders) { // Start out with the full ROP orders vector. diff --git a/src/kinetics/Kinetics.cpp b/src/kinetics/Kinetics.cpp index c6f37c8a9..da5659569 100644 --- a/src/kinetics/Kinetics.cpp +++ b/src/kinetics/Kinetics.cpp @@ -8,7 +8,6 @@ // Copyright 2001-2004 California Institute of Technology #include "cantera/kinetics/Kinetics.h" -#include "cantera/kinetics/ReactionData.h" #include "cantera/kinetics/Reaction.h" #include "cantera/base/stringUtils.h" @@ -554,105 +553,6 @@ void Kinetics::finalize() } } -void Kinetics::addReaction(ReactionData& r) { - // vectors rk and pk are lists of species numbers, with repeated entries - // for species with stoichiometric coefficients > 1. This allows the - // reaction to be defined with unity reaction order for each reactant, and - // so the faster method 'multiply' can be used to compute the rate of - // progress instead of 'power'. - std::vector rk; - for (size_t n = 0; n < r.reactants.size(); n++) { - double nsFlt = r.rstoich[n]; - size_t ns = (size_t) nsFlt; - if ((double) ns != nsFlt) { - ns = std::max(ns, 1); - } - if (r.rstoich[n] != 0.0) { - m_rrxn[r.reactants[n]][m_ii] += r.rstoich[n]; - } - for (size_t m = 0; m < ns; m++) { - rk.push_back(r.reactants[n]); - } - } - m_reactants.push_back(rk); - - std::vector pk; - for (size_t n = 0; n < r.products.size(); n++) { - double nsFlt = r.pstoich[n]; - size_t ns = (size_t) nsFlt; - if ((double) ns != nsFlt) { - ns = std::max(ns, 1); - } - if (r.pstoich[n] != 0.0) { - m_prxn[r.products[n]][m_ii] += r.pstoich[n]; - } - for (size_t m = 0; m < ns; m++) { - pk.push_back(r.products[n]); - } - } - m_products.push_back(pk); - - std::vector extReactants = r.reactants; - vector_fp extRStoich = r.rstoich; - vector_fp extROrder = r.rorder; - - // If the reaction order involves non-reactant species, add extra terms to - // the reactants with zero stoichiometry so that the stoichiometry manager - // can be used to compute the global forward reaction rate. - if (r.forwardFullOrder_.size() > 0) { - size_t nsp = r.forwardFullOrder_.size(); - - // Set up a signal vector to indicate whether the species has been added - // into the input vectors for the stoich manager - vector_int kHandled(nsp, 0); - - // Loop over the reactants which are also nonzero stoichioemtric entries - // making sure the forwardFullOrder_ entries take precedence over rorder - // entries - for (size_t kk = 0; kk < r.reactants.size(); kk++) { - size_t k = r.reactants[kk]; - double oo = r.rorder[kk]; - double of = r.forwardFullOrder_[k]; - if (of != oo) { - extROrder[kk] = of; - } - kHandled[k] = 1; - } - for (size_t k = 0; k < nsp; k++) { - double of = r.forwardFullOrder_[k]; - if (of != 0.0) { - if (kHandled[k] == 0) { - // Add extra entries to reactant inputs. Set their reactant - // stoichiometric entries to zero. - extReactants.push_back(k); - extROrder.push_back(of); - extRStoich.push_back(0.0); - } - } - } - } - - size_t irxn = nReactions(); - m_reactantStoich.add(irxn, extReactants, extROrder, extRStoich); - if (r.reversible) { - m_revProductStoich.add(irxn, r.products, r.porder, r.pstoich); - } else { - m_irrevProductStoich.add(irxn, r.products, r.porder, r.pstoich); - } - - installGroups(nReactions(), r.rgroups, r.pgroups); - incrementRxnCount(); - m_rxneqn.push_back(r.equation); - m_reactantStrings.push_back(r.reactantString); - m_productStrings.push_back(r.productString); - m_rxntype.push_back(r.reactionType); - m_rfn.push_back(0.0); - m_rkcn.push_back(0.0); - m_ropf.push_back(0.0); - m_ropr.push_back(0.0); - m_ropnet.push_back(0.0); -} - bool Kinetics::addReaction(shared_ptr r) { r->validate(); diff --git a/src/kinetics/ReactionStoichMgr.cpp b/src/kinetics/ReactionStoichMgr.cpp deleted file mode 100644 index c06e53da5..000000000 --- a/src/kinetics/ReactionStoichMgr.cpp +++ /dev/null @@ -1,336 +0,0 @@ -//------------------------------------------------ -/// -/// @file ReactionStoichMgr.cpp -/// -/// -//------------------------------------------------ - -#include "cantera/kinetics/ReactionStoichMgr.h" - -#include "cantera/base/ctexceptions.h" -#include "cantera/kinetics/ReactionData.h" -#include "cantera/kinetics/Reaction.h" - -#include - -using namespace std; - -namespace Cantera -{ -ReactionStoichMgr::ReactionStoichMgr() -{ - warn_deprecated("class ReactionStoichMgr", - "To be removed after Cantera 2.2."); - m_dummy.resize(10,1.0); -} - -ReactionStoichMgr::ReactionStoichMgr(const ReactionStoichMgr& right) : - m_reactants(right.m_reactants), - m_revproducts(right.m_revproducts), - m_irrevproducts(right.m_irrevproducts), - m_dummy(right.m_dummy) -{ -} - -ReactionStoichMgr& ReactionStoichMgr::operator=(const ReactionStoichMgr& right) -{ - if (this != &right) { - - m_reactants = right.m_reactants; - m_revproducts = right.m_revproducts; - m_irrevproducts = right.m_irrevproducts; - m_dummy = right.m_dummy; - } - return *this; -} - -void ReactionStoichMgr::add(size_t rxn, const std::vector& reactants, - const std::vector& products, - bool reversible) -{ - - m_reactants.add(rxn, reactants); - - if (reversible) { - m_revproducts.add(rxn, products); - } else { - m_irrevproducts.add(rxn, products); - } -} - -// Add the reaction into the stoichiometric manager -void ReactionStoichMgr::add(size_t rxn, const ReactionData& r) -{ - size_t k; - std::vector rk; - doublereal frac; - doublereal oo, os, of; - bool doGlobal = false; - std::vector extReactants = r.reactants; - vector_fp extRStoich = r.rstoich; - vector_fp extROrder = r.rorder; - - // - // If we have a complete global reaction then we need to do something more complete - // than the previous treatment. Basically we will use the reactant manager to calculate the - // global forward reaction rate of progress. - // - if (r.forwardFullOrder_.size() > 0) { - // - // Trigger a treatment where the order of the reaction and the stoichiometry - // are treated as different. - // - doGlobal = true; - size_t nsp = r.forwardFullOrder_.size(); - // - // Set up a signal vector to indicate whether the species has been added into - // the input vectors for the stoich manager - // - vector_int kHandled(nsp, 0); - // - // Loop over the reactants which are also nonzero stoichioemtric entries - // making sure the forwardFullOrder_ entries take precedence over rorder entries - // - for (size_t kk = 0; kk < r.reactants.size(); kk++) { - k = r.reactants[kk]; - os = r.rstoich[kk]; - oo = r.rorder[kk]; - of = r.forwardFullOrder_[k]; - if (of != oo) { - extROrder[kk] = of; - } - kHandled[k] = 1; - } - for (k = 0; k < nsp; k++) { - of = r.forwardFullOrder_[k]; - if (of != 0.0) { - if (kHandled[k] == 0) { - // - // Add extra entries to reactant inputs. Set their reactant stoichiometric entries to zero. - // - extReactants.push_back(k); - extROrder.push_back(of); - extRStoich.push_back(0.0); - } - } - } - } - - bool isfrac = false; - for (size_t n = 0; n < r.reactants.size(); n++) { - size_t ns = size_t(r.rstoich[n]); - frac = r.rstoich[n] - 1.0*int(r.rstoich[n]); - if (frac != 0.0) { - isfrac = true; - } - for (size_t m = 0; m < ns; m++) { - rk.push_back(r.reactants[n]); - } - } - - // - // If the reaction is non-mass action add it in in a general way - // Reactants get extra terms for the forward reaction rate of progress - // that may have zero stoichiometries. - // - if (doGlobal) { - m_reactants.add(rxn, extReactants, extROrder, extRStoich); - } else { - // - // this is confusing. The only issue should be whether rorder is different than rstoich! - // - if (isfrac || r.global || rk.size() > 3) { - m_reactants.add(rxn, r.reactants, r.rorder, r.rstoich); - } else { - m_reactants.add(rxn, rk); - } - } - - std::vector pk; - isfrac = false; - for (size_t n = 0; n < r.products.size(); n++) { - size_t ns = size_t(r.pstoich[n]); - frac = r.pstoich[n] - 1.0*int(r.pstoich[n]); - if (frac != 0.0) { - isfrac = true; - } - for (size_t m = 0; m < ns; m++) { - pk.push_back(r.products[n]); - } - } - - if (r.reversible) { - // - // this is confusing. The only issue should be whether porder is different than pstoich! - // - if (pk.size() > 3 || r.isReversibleWithFrac) { - m_revproducts.add(rxn, r.products, r.porder, r.pstoich); - } else { - m_revproducts.add(rxn, pk); - } - } else { - // - // this is confusing. The only issue should be whether porder is different than pstoich! - // - if (isfrac || pk.size() > 3) { - m_irrevproducts.add(rxn, r.products, r.porder, r.pstoich); - } else { - m_irrevproducts.add(rxn, pk); - } - } -} - -void ReactionStoichMgr::getCreationRates(size_t nsp, const doublereal* ropf, - const doublereal* ropr, doublereal* c) -{ - // zero out the output array - fill(c, c + nsp, 0.0); - - // the forward direction creates product species - m_revproducts.incrementSpecies(ropf, c); - m_irrevproducts.incrementSpecies(ropf, c); - - // the reverse direction creates reactant species - m_reactants.incrementSpecies(ropr, c); -} - -void ReactionStoichMgr::getDestructionRates(size_t nsp, const doublereal* ropf, - const doublereal* ropr, - doublereal* d) -{ - fill(d, d + nsp, 0.0); - // the reverse direction destroys products in reversible reactions - m_revproducts.incrementSpecies(ropr, d); - // the forward direction destroys reactants - m_reactants.incrementSpecies(ropf, d); -} - -void ReactionStoichMgr::getNetProductionRates(size_t nsp, - const doublereal* ropnet, - doublereal* w) -{ - fill(w, w + nsp, 0.0); - // products are created for positive net rate of progress - m_revproducts.incrementSpecies(ropnet, w); - m_irrevproducts.incrementSpecies(ropnet, w); - // reactants are destroyed for positive net rate of progress - m_reactants.decrementSpecies(ropnet, w); -} - -void ReactionStoichMgr::getReactionDelta(size_t nr, const doublereal* g, - doublereal* dg) -{ - fill(dg, dg + nr, 0.0); - // products add - m_revproducts.incrementReactions(g, dg); - m_irrevproducts.incrementReactions(g, dg); - // reactants subtract - m_reactants.decrementReactions(g, dg); -} - -void ReactionStoichMgr::getRevReactionDelta(size_t nr, const doublereal* g, - doublereal* dg) -{ - fill(dg, dg + nr, 0.0); - m_revproducts.incrementReactions(g, dg); - m_reactants.decrementReactions(g, dg); -} - -void ReactionStoichMgr::multiplyReactants(const doublereal* c, doublereal* r) -{ - m_reactants.multiply(c, r); -} - -void ReactionStoichMgr::multiplyRevProducts(const doublereal* c, doublereal* r) -{ - m_revproducts.multiply(c, r); -} - -void ReactionStoichMgr::write(const string& filename) -{ - ofstream f(filename.c_str()); - f << "namespace mech {" << endl; - writeCreationRates(f); - writeDestructionRates(f); - writeNetProductionRates(f); - writeMultiplyReactants(f); - writeMultiplyRevProducts(f); - f << "} // namespace mech" << endl; - f.close(); -} - -void ReactionStoichMgr::writeCreationRates(ostream& f) -{ - f << " void getCreationRates(const doublereal* rf, const doublereal* rb," << endl; - f << " doublereal* c) {" << endl; - map out; - m_revproducts.writeIncrementSpecies("rf",out); - m_irrevproducts.writeIncrementSpecies("rf",out); - m_reactants.writeIncrementSpecies("rb",out); - map::iterator b; - for (b = out.begin(); b != out.end(); ++b) { - string rhs = wrapString(b->second); - rhs[1] = '='; - f << " c[" << b->first << "] " << rhs << ";" << endl; - } - f << " }" << endl << endl << endl; -} - -void ReactionStoichMgr::writeDestructionRates(ostream& f) -{ - f << " void getDestructionRates(const doublereal* rf, const doublereal* rb," << endl; - f << " doublereal* d) {" << endl; - map out; - m_revproducts.writeIncrementSpecies("rb",out); - m_reactants.writeIncrementSpecies("rf",out); - map::iterator b; - for (b = out.begin(); b != out.end(); ++b) { - string rhs = wrapString(b->second); - rhs[1] = '='; - f << " d[" << b->first << "] " << rhs << ";" << endl; - } - f << " }" << endl << endl << endl; -} - -void ReactionStoichMgr::writeNetProductionRates(ostream& f) -{ - f << " void getNetProductionRates(const doublereal* r, doublereal* w) {" << endl; - map out; - m_revproducts.writeIncrementSpecies("r",out); - m_irrevproducts.writeIncrementSpecies("r",out); - m_reactants.writeDecrementSpecies("r",out); - map::iterator b; - for (b = out.begin(); b != out.end(); ++b) { - string rhs = wrapString(b->second); - rhs[1] = '='; - f << " w[" << b->first << "] " << rhs << ";" << endl; - } - f << " }" << endl << endl << endl; -} - -void ReactionStoichMgr::writeMultiplyReactants(ostream& f) -{ - f << " void multiplyReactants(const doublereal* c, doublereal* r) {" << endl; - map out; - m_reactants.writeMultiply("c",out); - map::iterator b; - for (b = out.begin(); b != out.end(); ++b) { - string rhs = b->second; - f << " r[" << b->first << "] *= " << rhs << ";" << endl; - } - f << " }" << endl << endl << endl; -} - -void ReactionStoichMgr::writeMultiplyRevProducts(ostream& f) -{ - f << " void multiplyRevProducts(const doublereal* c, doublereal* r) {" << endl; - map out; - m_revproducts.writeMultiply("c",out); - map::iterator b; - for (b = out.begin(); b != out.end(); ++b) { - string rhs = b->second; - f << " r[" << b->first << "] *= " << rhs << ";" << endl; - } - f << " }" << endl << endl << endl; -} -} diff --git a/src/kinetics/RxnRates.cpp b/src/kinetics/RxnRates.cpp index aa03fd58f..fc3823f4a 100644 --- a/src/kinetics/RxnRates.cpp +++ b/src/kinetics/RxnRates.cpp @@ -13,18 +13,6 @@ Arrhenius::Arrhenius() { } -Arrhenius::Arrhenius(const ReactionData& rdata) - : m_b(rdata.rateCoeffParameters[1]) - , m_E(rdata.rateCoeffParameters[2]) - , m_A(rdata.rateCoeffParameters[0]) -{ - if (m_A <= 0.0) { - m_logA = -1.0E300; - } else { - m_logA = std::log(m_A); - } -} - Arrhenius::Arrhenius(doublereal A, doublereal b, doublereal E) : m_b(b) , m_E(E) @@ -63,31 +51,6 @@ SurfaceArrhenius::SurfaceArrhenius(double A, double b, double Ta) { } -SurfaceArrhenius::SurfaceArrhenius(const ReactionData& rdata) - : m_b(rdata.rateCoeffParameters[1]) - , m_E(rdata.rateCoeffParameters[2]) - , m_A(rdata.rateCoeffParameters[0]) - , m_acov(0.0) - , m_ecov(0.0) - , m_mcov(0.0) - , m_ncov(0) - , m_nmcov(0) -{ - if (m_A <= 0.0) { - m_logA = -1.0E300; - } else { - m_logA = std::log(m_A); - } - - const vector_fp& data = rdata.rateCoeffParameters; - if (data.size() >= 7) { - for (size_t n = 3; n < data.size()-3; n += 4) { - addCoverageDependence(size_t(data[n]), data[n+1], - data[n+2], data[n+3]); - } - } -} - void SurfaceArrhenius::addCoverageDependence(size_t k, doublereal a, doublereal m, doublereal e) { m_ncov++; @@ -101,80 +64,6 @@ void SurfaceArrhenius::addCoverageDependence(size_t k, doublereal a, } } -ExchangeCurrent::ExchangeCurrent() - : m_logA(-1.0E300) - , m_b(0.0) - , m_E(0.0) - , m_A(0.0) -{ - warn_deprecated("class ExchangeCurrent", "Duplicate of class Arrhenius." - " To be removed after Cantera 2.2."); -} - -ExchangeCurrent::ExchangeCurrent(const ReactionData& rdata) - : m_b(rdata.rateCoeffParameters[1]) - , m_E(rdata.rateCoeffParameters[2]) - , m_A(rdata.rateCoeffParameters[0]) -{ - warn_deprecated("class ExchangeCurrent", "Duplicate of class Arrhenius." - " To be removed after Cantera 2.2."); - if (m_A <= 0.0) { - m_logA = -1.0E300; - } else { - m_logA = std::log(m_A); - } -} - -ExchangeCurrent::ExchangeCurrent(doublereal A, doublereal b, doublereal E) - : m_b(b) - , m_E(E) - , m_A(A) -{ - warn_deprecated("class ExchangeCurrent", "Duplicate of class Arrhenius." - " To be removed after Cantera 2.2."); - if (m_A <= 0.0) { - m_logA = -1.0E300; - } else { - m_logA = std::log(m_A); - } -} - -Plog::Plog(const ReactionData& rdata) - : logP_(-1000) - , logP1_(1000) - , logP2_(-1000) - , rDeltaP_(-1.0) -{ - typedef std::multimap::const_iterator iter_t; - - size_t j = 0; - // Insert intermediate pressures - rates_.reserve(rdata.plogParameters.size()); - for (iter_t iter = rdata.plogParameters.begin(); - iter != rdata.plogParameters.end(); - iter++) { - double logp = std::log(iter->first); - if (pressures_.empty() || pressures_.rbegin()->first != logp) { - // starting a new group - pressures_[logp] = std::make_pair(j, j+1); - } else { - // another rate expression at the same pressure - pressures_[logp].second = j+1; - } - - j++; - rates_.push_back(Arrhenius(iter->second[0], iter->second[1], - iter->second[2])); - } - - // Duplicate the first and last groups to handle P < P_0 and P > P_N - pressures_.insert(std::make_pair(-1000.0, pressures_.begin()->second)); - pressures_.insert(std::make_pair(1000.0, pressures_.rbegin()->second)); - - if (rdata.validate) { - validate(rdata.equation); - } -} Plog::Plog(const std::multimap& rates) : logP_(-1000) @@ -244,26 +133,6 @@ std::vector > Plog::rates() const return R; } -ChebyshevRate::ChebyshevRate(const ReactionData& rdata) - : Tmin_(rdata.chebTmin) - , Tmax_(rdata.chebTmax) - , Pmin_(rdata.chebPmin) - , Pmax_(rdata.chebPmax) - , nP_(rdata.chebDegreeP) - , nT_(rdata.chebDegreeT) - , chebCoeffs_(rdata.chebCoeffs) - , dotProd_(rdata.chebDegreeT) -{ - double logPmin = std::log10(rdata.chebPmin); - double logPmax = std::log10(rdata.chebPmax); - double TminInv = 1.0 / rdata.chebTmin; - double TmaxInv = 1.0 / rdata.chebTmax; - - TrNum_ = - TminInv - TmaxInv; - TrDen_ = 1.0 / (TmaxInv - TminInv); - PrNum_ = - logPmin - logPmax; - PrDen_ = 1.0 / (logPmax - logPmin); -} ChebyshevRate::ChebyshevRate(double Tmin, double Tmax, double Pmin, double Pmax, const Array2D& coeffs) diff --git a/src/kinetics/importKinetics.cpp b/src/kinetics/importKinetics.cpp index 794d124db..e62f92f42 100644 --- a/src/kinetics/importKinetics.cpp +++ b/src/kinetics/importKinetics.cpp @@ -13,7 +13,6 @@ #include "cantera/kinetics/importKinetics.h" #include "cantera/thermo/ThermoFactory.h" -#include "cantera/kinetics/ReactionData.h" #include "cantera/kinetics/Reaction.h" #include "cantera/base/stringUtils.h" #include "cantera/base/ctml.h" @@ -32,531 +31,6 @@ ReactionRules::ReactionRules() : { } -void checkRxnElementBalance(Kinetics& kin, - const ReactionData& rdata, doublereal errorTolerance) -{ - warn_deprecated("checkRxnElementBalance", "Now handled by " - "Kinetics::checkReactionBalance. To be removed after Cantera 2.2."); - doublereal kstoich; - - map bal, balr, balp; - bal.clear(); - balp.clear(); - balr.clear(); - size_t np = rdata.products.size(); - - // iterate over the products - for (size_t index = 0; index < np; index++) { - size_t kp = rdata.products[index]; // index of the product in 'kin' - size_t n = kin.speciesPhaseIndex(kp); // phase this product belongs to - size_t klocal = kp - kin.kineticsSpeciesIndex(0,n); // index within this phase - kstoich = rdata.pstoich[index]; // product stoichiometric coeff - const ThermoPhase& ph = kin.speciesPhase(kp); - for (size_t m = 0; m < ph.nElements(); m++) { - bal[ph.elementName(m)] += kstoich*ph.nAtoms(klocal,m); - balp[ph.elementName(m)] += kstoich*ph.nAtoms(klocal,m); - } - } - for (size_t index = 0; index < rdata.reactants.size(); index++) { - size_t kr = rdata.reactants[index]; - size_t n = kin.speciesPhaseIndex(kr); - size_t klocal = kr - kin.kineticsSpeciesIndex(0,n); - kstoich = rdata.rstoich[index]; - const ThermoPhase& ph = kin.speciesPhase(kr); - for (size_t m = 0; m < ph.nElements(); m++) { - bal[ph.elementName(m)] -= kstoich*ph.nAtoms(klocal,m); - balr[ph.elementName(m)] += kstoich*ph.nAtoms(klocal,m); - } - } - - map::iterator b = bal.begin(); - string msg = "\n\tElement Reactants Products"; - bool ok = true; - doublereal err, elemsum; - for (; b != bal.end(); ++b) { - elemsum = fabs(balr[b->first]) + fabs(balp[b->first]); - if (elemsum > 0.0) { - err = fabs(b->second/elemsum); - if (err > errorTolerance) { - ok = false; - msg += "\n\t"+b->first+" "+ fp2str(balr[b->first]) - +" "+ fp2str(balp[b->first]); - } - } - } - if (!ok) { - msg = "The following reaction is unbalanced:\n\t" - + rdata.equation + "\n" + msg + "\n"; - throw CanteraError("checkRxnElementBalance",msg); - } -} - -bool getReagents(const XML_Node& rxn, Kinetics& kin, int rp, - std::string default_phase, std::vector& spnum, - vector_fp& stoich, vector_fp& order, - const ReactionRules& rules) -{ - warn_deprecated("getReagents", "Now handled through newReaction() and its " - "support functions. To be removed after Cantera 2.2."); - string rptype; - - /* - * The id of reactants and products are kept in child elements - * of reaction, named "reactants" and "products". We search - * the XML tree for these children based on the value of rp, - * and store the XML element pointer here. - */ - if (rp == 1) { - rptype = "reactants"; - } else { - rptype = "products"; - } - const XML_Node& rg = rxn.child(rptype); - - /* - * The species and stoichiometric coefficient for the species - * are stored as a colon separated pair. Get all of these - * pairs in the reactions/products object. - */ - std::vector key, val; - getPairs(rg, key, val); - - /* - * Loop over each of the pairs and process them - */ - doublereal ord, stch; - string ph, spName; - map speciesMap; - for (size_t n = 0; n < key.size(); n++) { - spName = key[n]; // sp is the string name for species - ph = ""; - /* - * Search for the species in the kinetics object using the - * member function kineticsSpeciesIndex(). We will search - * for the species in all phases defined in the kinetics operator. - */ - size_t isp = kin.kineticsSpeciesIndex(spName); - if (isp == npos) { - if (rules.skipUndeclaredSpecies) { - return false; - } else { - throw CanteraError("getReagents", - "Undeclared reactant or product species " + spName); - return false; - } - } - - /* - * For each reagent, we store the the species number, isp - * the stoichiometric coefficient, val[n], and the order - * species in the reaction rate expression. We assume mass - * action kinetics here, but will modify this below for - * specified species. - */ - spnum.push_back(isp); - stch = fpValue(val[n]); - stoich.push_back(stch); - ord = doublereal(stch); - order.push_back(ord); - - /* - * Needed to process reaction orders below. - */ - speciesMap[spName] = order.size(); - } - - /* - * Check to see if reaction orders have been specified. - */ - - if (rp == 1 && rxn.hasChild("order")) { - std::vector ord = rxn.getChildren("order"); - doublereal forder; - for (size_t nn = 0; nn < ord.size(); nn++) { - const XML_Node& oo = *ord[nn]; - string sp = oo["species"]; - size_t loc = speciesMap[sp]; - if (loc == 0) - throw CanteraError("getReagents", - "reaction order specified for non-reactant: " - +sp); - forder = oo.fp_value(); - if (forder < 0.0) { - throw CanteraError("getReagents", - "reaction order must be non-negative"); - } - // replace the stoichiometric coefficient - // stored above in 'order' with the specified - // reaction order - order[loc-1] = forder; - } - } - return true; -} - -/** - * getArrhenius() parses the XML element called Arrhenius. - * The Arrhenius expression is - * \f[ k = A T^(b) exp (-E_a / RT). \f] - * @deprecated to be removed after Cantera 2.2. - */ -static void getArrhenius(const XML_Node& node, int& labeled, - doublereal& A, doublereal& b, doublereal& E) -{ - if (node["name"] == "k0") { - labeled = -1; - } else if (node["name"] == "kHigh") { - labeled = 1; - } else { - labeled = 0; - } - /* - * We parse the children for the A, b, and E components. - */ - A = getFloat(node, "A", "toSI"); - b = getFloat(node, "b"); - E = getFloat(node, "E", "actEnergy"); - E /= GasConstant; -} - -/** - * getStick() processes the XML element called Stick that specifies - * the sticking coefficient reaction. This routine will - * translate the sticking coefficient value into a "normal" - * rate constant for the surface reaction. - * - * Output - * ----------- - * Output is the normal Arrhenius expressions for a surface - * reaction rate constant. - * - * A - units such that rate of rxn has kmol/m^2/s when - * A is multiplied by activity concentrations of - * reactants in the normal manner. - * n - unitless - * E - Units 1/Kelvin - * @deprecated to be removed after Cantera 2.2. - */ -static void getStick(const XML_Node& node, Kinetics& kin, - ReactionData& r, doublereal& A, doublereal& b, doublereal& E) -{ - size_t nr = r.reactants.size(); - size_t k, klocal, not_surf = 0; - size_t np = 0; - doublereal f = 1.0; - doublereal order; - /* - * species is the name of the special reactant whose surface - * flux rate will be calculated. - * isp = species # in the local phase - * ispKinetics = species # in the kinetics object - * ispPhaseIndex = phase # of the special species - */ - string spname = node["species"]; - ThermoPhase& th = kin.speciesPhase(spname); - size_t isp = th.speciesIndex(spname); - size_t ispKinetics = kin.kineticsSpeciesIndex(spname); - size_t ispPhaseIndex = kin.speciesPhaseIndex(ispKinetics); - - doublereal ispMW = th.molecularWeights()[isp]; - doublereal sc; - - // loop over the reactants - for (size_t n = 0; n < nr; n++) { - k = r.reactants[n]; - order = r.rorder[n]; // stoich coeff - - // get the phase species k belongs to - np = kin.speciesPhaseIndex(k); - const ThermoPhase& p = kin.thermo(np); - - // get the local index of species k in this phase - klocal = p.speciesIndex(kin.kineticsSpeciesName(k)); - - // if it is a surface species, divide f by the standard - // concentration for this species, in order to convert - // from concentration units used in the law of mass action - // to coverages used in the sticking probability expression - if (p.eosType() == cSurf || p.eosType() == cEdge) { - sc = p.standardConcentration(klocal); - f /= pow(sc, order); - } - // Otherwise: - else { - // We only allow one species to be in the phase containing the - // special sticking coefficient species. - if (ispPhaseIndex == np) { - not_surf++; - } - // Other bulk phase species on the other side of ther interface are - // treated like surface species. - else { - sc = p.standardConcentration(klocal); - f /= pow(sc, order); - } - } - } - if (not_surf != 1) { - throw CanteraError("getStick", - "reaction probabilities can only be used in " - "reactions with exactly 1 gas/liquid species."); - } - - doublereal cbar = sqrt(8.0*GasConstant/(Pi*ispMW)); - A = 0.25 * getFloat(node, "A", "toSI") * cbar * f; - b = getFloat(node, "b") + 0.5; - E = getFloat(node, "E", "actEnergy"); - E /= GasConstant; -} - -//! Read the XML data concerning the coverage dependence of an interfacial reaction -/*! - * @param node XML node with name reaction containing the reaction information - * @param surfphase Surface phase - * @param rdata Reaction data for the reaction. - * - * Example: - * @verbatim - - 1.0E-5 - 0.0 - 0.0 - -@endverbatim - * @deprecated to be removed after Cantera 2.2. - */ -static void getCoverageDependence(const XML_Node& node, - thermo_t& surfphase, ReactionData& rdata) -{ - vector cov = node.getChildren("coverage"); - size_t k, nc = cov.size(); - doublereal e; - string spname; - if (nc > 0) { - for (size_t n = 0; n < nc; n++) { - const XML_Node& cnode = *cov[n]; - spname = cnode["species"]; - k = surfphase.speciesIndex(spname); - rdata.cov.push_back(doublereal(k)); - rdata.cov.push_back(getFloat(cnode, "a")); - rdata.cov.push_back(getFloat(cnode, "m")); - e = getFloat(cnode, "e", "actEnergy"); - rdata.cov.push_back(e/GasConstant); - } - } -} - -//! Get falloff parameters for a reaction. -/*! - * This routine reads the falloff XML node and extracts parameters into a - * vector of doubles - * - * @verbatim - 0.5 73.2 5000. 9999. - @endverbatim - * @deprecated to be removed after Cantera 2.2. -*/ -static void getFalloff(const XML_Node& f, ReactionData& rdata) -{ - string type = f["type"]; - vector p; - getStringArray(f,p); - vector_fp c; - size_t np = p.size(); - for (size_t n = 0; n < np; n++) { - c.push_back(fpValue(p[n])); - } - if (type == "Troe") { - if (np == 3 || np == 4) { - rdata.falloffType = TROE_FALLOFF; - } else { - throw CanteraError("getFalloff()", "Troe parameterization is specified by number of parameters, " - + int2str(np) + ", is not equal to 3 or 4"); - } - } else if (type == "SRI") { - if (np == 3 || np == 5) { - rdata.falloffType = SRI_FALLOFF; - } else { - throw CanteraError("getFalloff()", "SRI parameterization is specified by number of parameters, " - + int2str(np) + ", is not equal to 3 or 5"); - } - } - rdata.falloffParameters = c; -} - -/** - * Get the enhanced collision efficiencies. It is assumed that the - * reaction mechanism is homogeneous, so that all species belong - * to phase(0) of 'kin'. - * @deprecated to be removed after Cantera 2.2. - */ -static void getEfficiencies(const XML_Node& eff, Kinetics& kin, - ReactionData& rdata, const ReactionRules& rules) -{ - // set the default collision efficiency - rdata.default_3b_eff = fpValue(eff["default"]); - - vector key, val; - getPairs(eff, key, val); - string nm; - string phse = kin.thermo(0).id(); - for (size_t n = 0; n < key.size(); n++) { - nm = key[n]; - size_t k = kin.kineticsSpeciesIndex(nm, phse); - if (k != npos) { - rdata.thirdBodyEfficiencies[k] = fpValue(val[n]); - } else if (!rules.skipUndeclaredThirdBodies) { - throw CanteraError("getEfficiencies", "Encountered third-body " - "efficiency for undefined species \"" + nm + "\"\n" - "while adding reaction " + int2str(rdata.number+1) + "."); - } - } -} - -void getRateCoefficient(const XML_Node& kf, Kinetics& kin, - ReactionData& rdata, const ReactionRules& rules) -{ - warn_deprecated("getRateCoefficent", "Now handled through newReaction() " - "and its support functions. To be removed after Cantera 2.2."); - if (rdata.reactionType == PLOG_RXN) { - rdata.rateCoeffType = PLOG_REACTION_RATECOEFF_TYPE; - for (size_t m = 0; m < kf.nChildren(); m++) { - const XML_Node& node = kf.child(m); - double p = getFloat(node, "P", "toSI"); - vector_fp& rate = rdata.plogParameters.insert( - std::make_pair(p, vector_fp()))->second; - rate.resize(3); - rate[0] = getFloat(node, "A", "toSI"); - rate[1] = getFloat(node, "b"); - rate[2] = getFloat(node, "E", "actEnergy") / GasConstant; - } - - } else if (rdata.reactionType == CHEBYSHEV_RXN) { - rdata.rateCoeffType = CHEBYSHEV_REACTION_RATECOEFF_TYPE; - rdata.chebTmin = getFloat(kf, "Tmin", "toSI"); - rdata.chebTmax = getFloat(kf, "Tmax", "toSI"); - rdata.chebPmin = getFloat(kf, "Pmin", "toSI"); - rdata.chebPmax = getFloat(kf, "Pmax", "toSI"); - const XML_Node& coeffs = kf.child("floatArray"); - rdata.chebDegreeP = atoi(coeffs["degreeP"].c_str()); - rdata.chebDegreeT = atoi(coeffs["degreeT"].c_str()); - getFloatArray(kf, rdata.chebCoeffs, false); - - } else { - - string type = kf.attrib("type"); - if (type == "") { - type = "Arrhenius"; - rdata.rateCoeffType = ARRHENIUS_REACTION_RATECOEFF_TYPE; - } - if (type == "ExchangeCurrentDensity") { - rdata.rateCoeffType = EXCHANGE_CURRENT_REACTION_RATECOEFF_TYPE; - } else if (type == "Arrhenius") { - - } else { - throw CanteraError("getRateCoefficient", "Unknown type: " + type); - } - - vector_fp c_alt(3,0.0), c_base(3,0.0); - for (size_t m = 0; m < kf.nChildren(); m++) { - const XML_Node& c = kf.child(m); - string nm = c.name(); - int labeled=0; - - if (nm == "Arrhenius") { - vector_fp coeff(3); - if (c["type"] == "stick") { - getStick(c, kin, rdata, coeff[0], coeff[1], coeff[2]); - c_base = coeff; - } else { - getArrhenius(c, labeled, coeff[0], coeff[1], coeff[2]); - if (labeled == 0 || rdata.reactionType == THREE_BODY_RXN - || rdata.reactionType == ELEMENTARY_RXN) { - c_base = coeff; - } else { - c_alt = coeff; - } - } - if (rdata.reactionType == SURFACE_RXN || rdata.reactionType == EDGE_RXN) { - getCoverageDependence(c, - kin.thermo(kin.surfacePhaseIndex()), rdata); - } - - if (coeff[0] < 0.0 && !rules.allowNegativeA) { - throw CanteraError("getRateCoefficient", - "negative A coefficient for reaction "+int2str(rdata.number)); - } - } else if (nm == "Arrhenius_ExchangeCurrentDensity") { - vector_fp coeff(3); - getArrhenius(c, labeled, coeff[0], coeff[1], coeff[2]); - c_base = coeff; - rdata.rateCoeffType = EXCHANGE_CURRENT_REACTION_RATECOEFF_TYPE; - } else if (nm == "falloff") { - getFalloff(c, rdata); - } else if (nm == "efficiencies") { - getEfficiencies(c, kin, rdata, rules); - } else if (nm == "electrochem") { - rdata.beta = fpValue(c["beta"]); - } - } - /* - * Store the coefficients in the ReactionData object for return - * from this function. - */ - if (rdata.reactionType == FALLOFF_RXN) { - rdata.rateCoeffParameters = c_base; - rdata.auxRateCoeffParameters = c_alt; - } else if (rdata.reactionType == CHEMACT_RXN) { - rdata.rateCoeffParameters = c_alt; - rdata.auxRateCoeffParameters = c_base; - } else { - rdata.rateCoeffParameters = c_base; - } - - } -} - -doublereal isDuplicateReaction(std::map& r1, - std::map& r2) -{ - warn_deprecated("isDuplicateReaction", "Now handled by " - "Kinetics::checkDuplicateStoich. To be removed after Cantera 2.2."); - map::const_iterator b = r1.begin(), e = r1.end(); - int k1 = b->first; - // check for duplicate written in the same direction - doublereal ratio = 0.0; - if (r1[k1] && r2[k1]) { - ratio = r2[k1]/r1[k1]; - ++b; - bool different = false; - for (; b != e; ++b) { - k1 = b->first; - if (!r1[k1] || !r2[k1] || fabs(r2[k1]/r1[k1] - ratio) > 1.e-8) { - different = true; - break; - } - } - if (!different) { - return ratio; - } - } - - // check for duplicate written in the reverse direction - b = r1.begin(); - k1 = b->first; - if (r1[k1] == 0.0 || r2[-k1] == 0.0) { - return 0.0; - } - ratio = r2[-k1]/r1[k1]; - ++b; - for (; b != e; ++b) { - k1 = b->first; - if (!r1[k1] || !r2[-k1] || fabs(r2[-k1]/r1[k1] - ratio) > 1.e-8) { - return 0.0; - } - } - return ratio; -} bool installReactionArrays(const XML_Node& p, Kinetics& kin, std::string default_phase, bool check_for_duplicates) diff --git a/src/thermo/ConstCpPoly.cpp b/src/thermo/ConstCpPoly.cpp index f7c59e66f..141e5c05b 100644 --- a/src/thermo/ConstCpPoly.cpp +++ b/src/thermo/ConstCpPoly.cpp @@ -19,18 +19,6 @@ ConstCpPoly::ConstCpPoly() { } -ConstCpPoly::ConstCpPoly(size_t n, doublereal tlow, doublereal thigh, - doublereal pref, - const doublereal* coeffs) : - SpeciesThermoInterpType(n, tlow, thigh, pref) -{ - m_t0 = coeffs[0]; - m_h0_R = coeffs[1] / GasConstant; - m_s0_R = coeffs[2] / GasConstant; - m_cp0_R = coeffs[3] / GasConstant; - m_logt0 = log(m_t0); -} - ConstCpPoly::ConstCpPoly(double tlow, double thigh, double pref, const double* coeffs) : SpeciesThermoInterpType(tlow, thigh, pref) @@ -56,9 +44,9 @@ void ConstCpPoly::updateProperties(const doublereal* tt, double t = *tt; doublereal logt = log(t); doublereal rt = 1.0/t; - cp_R[m_index] = m_cp0_R; - h_RT[m_index] = rt*(m_h0_R + (t - m_t0) * m_cp0_R); - s_R[m_index] = m_s0_R + m_cp0_R * (logt - m_logt0); + *cp_R = m_cp0_R; + *h_RT = rt*(m_h0_R + (t - m_t0) * m_cp0_R); + *s_R = m_s0_R + m_cp0_R * (logt - m_logt0); } void ConstCpPoly::updatePropertiesTemp(const doublereal temp, @@ -68,9 +56,9 @@ void ConstCpPoly::updatePropertiesTemp(const doublereal temp, { doublereal logt = log(temp); doublereal rt = 1.0/temp; - cp_R[m_index] = m_cp0_R; - h_RT[m_index] = rt*(m_h0_R + (temp - m_t0) * m_cp0_R); - s_R[m_index] = m_s0_R + m_cp0_R * (logt - m_logt0); + *cp_R = m_cp0_R; + *h_RT = rt*(m_h0_R + (temp - m_t0) * m_cp0_R); + *s_R = m_s0_R + m_cp0_R * (logt - m_logt0); } void ConstCpPoly::reportParameters(size_t& n, int& type, @@ -78,7 +66,7 @@ void ConstCpPoly::reportParameters(size_t& n, int& type, doublereal& pref, doublereal* const coeffs) const { - n = m_index; + n = 0; type = CONSTANT_CP; tlow = m_lowT; thigh = m_highT; @@ -103,16 +91,13 @@ doublereal ConstCpPoly::reportHf298(doublereal* const h298) const double temp = 298.15; doublereal h = GasConstant * (m_h0_R + (temp - m_t0) * m_cp0_R); if (h298) { - h298[m_index] = h; + *h298 = h; } return h; } void ConstCpPoly::modifyOneHf298(const size_t k, const doublereal Hf298New) { - if (k != m_index) { - return; - } doublereal hnow = reportHf298(); doublereal delH = Hf298New - hnow; m_h0_R += delH / GasConstant; diff --git a/src/thermo/Elements.cpp b/src/thermo/Elements.cpp index 6ae2e8d88..a465aeebc 100644 --- a/src/thermo/Elements.cpp +++ b/src/thermo/Elements.cpp @@ -135,39 +135,6 @@ static struct awData aWTable[] = { }; -// Static function to look up an atomic weight -/* - * This static function looks up the argument string in the - * database above and returns the associated molecular weight. - * The data are from the periodic table. - * - * Note: The idea behind this function is to provide a unified - * source for the element atomic weights. This helps to - * ensure that mass is conserved. - * - * @param s String, Only the first 3 characters are significant - * - * @return - * Return value contains the atomic weight of the element - * If a match for the string is not found, a value of -1.0 is - * returned. - * - * @exception CanteraError - * If a match is not found, a CanteraError is thrown as well - */ -doublereal Elements::LookupWtElements(const std::string& ename) -{ - int num = sizeof(aWTable) / sizeof(struct awData); - string s3 = ename.substr(0,3); - for (int i = 0; i < num; i++) { - if (s3 == aWTable[i].name) { - return aWTable[i].atomicWeight; - } - } - throw CanteraError("LookupWtElements", "element not found"); - return -1.0; -} - doublereal LookupWtElements(const std::string& ename) { int num = sizeof(aWTable) / sizeof(struct awData); @@ -181,409 +148,4 @@ doublereal LookupWtElements(const std::string& ename) return -1.0; } -//! Exception class to indicate a fixed set of elements. -/*! - * This class is used to warn the user when the number of elements - * are changed after at least one species is defined. - */ -class ElementsFrozen : public CanteraError -{ -public: - //! Constructor for class - /*! - * @param func Function where the error occurred. - */ - ElementsFrozen(string func) - : CanteraError(func, - "elements cannot be added after species.") {} -}; - -/* - * Elements Class Constructor - * We initialize all internal variables to zero here. - */ -Elements::Elements() : - m_mm(0), - m_elementsFrozen(false), - m_elem_type(0), - numSubscribers(0) -{ - warn_deprecated("class Elements", - "Functionality is now part of class Phase. " - "To be removed after Cantera 2.2."); -} - -/* - * Elements Class Destructor - * If the number of subscribers is not zero, through an error. - * A logic problem has occurred. - * - * @exception CanteraError - */ -Elements::~Elements() -{ - if (numSubscribers != 0) { - throw CanteraError("~Elements", "numSubscribers not zero"); - } -} - -Elements::Elements(const Elements& right) : - m_mm(0), - m_elementsFrozen(false), - numSubscribers(0) -{ - *this = right; -} - -Elements& Elements::operator=(const Elements& right) -{ - if (&right == this) { - return *this; - } - - m_mm = right.m_mm; - m_elementsFrozen = right.m_elementsFrozen; - m_atomicWeights = right.m_atomicWeights; - m_atomicNumbers = right.m_atomicNumbers; - m_elementNames = right.m_elementNames; - m_entropy298 = right.m_entropy298; - m_elem_type = right.m_elem_type; - numSubscribers = 0; - - return *this; -} - - - -/* - * freezeElements(): - * - * Set the freeze flag. This is a prerequesite to other - * activivities, i.e., this is done before species are defined. - */ -void Elements::freezeElements() -{ - m_elementsFrozen = true; -} - -/* - * elementIndex(): - * - * Index of element named \c name. The index is an integer - * assigned to each element in the order it was added, - * beginning with 0 for the first element. If \c name is not - * the name of an element in the set, then the value -1 is - * returned. - * - */ -int Elements::elementIndex(const std::string& name) const -{ - for (int i = 0; i < m_mm; i++) { - if (m_elementNames[i] == name) { - return i; - } - } - return -1; -} - -/* - * - * Name of the element with index \c m. @param m Element - * index. If m < 0 or m >= nElements() an exception is thrown. - */ -string Elements::elementName(int m) const -{ - if (m < 0 || m >= nElements()) { - throw CanteraError("Elements::elementName()", "out of bounds: " + int2str(m) + " " + int2str(nElements())); - } - return m_elementNames[m]; -} - - -doublereal Elements::entropyElement298(int m) const -{ - AssertThrowMsg(m_entropy298[m] != ENTROPY298_UNKNOWN, - "Elements::entropy298", - "Entropy at 298 K of element is unknown"); - AssertTrace(m >= 0 && m < m_mm); - return m_entropy298[m]; -} -//==================================================================================================================== -//! Return the element constraint type -/*! - * Possible types include: - * - * CT_ELEM_TYPE_TURNEDOFF -1 - * CT_ELEM_TYPE_ABSPOS 0 - * CT_ELEM_TYPE_ELECTRONCHARGE 1 - * CT_ELEM_TYPE_CHARGENEUTRALITY 2 - * CT_ELEM_TYPE_LATTICERATIO 3 - * CT_ELEM_TYPE_KINETICFROZEN 4 - * CT_ELEM_TYPE_SURFACECONSTRAINT 5 - * CT_ELEM_TYPE_OTHERCONSTRAINT 6 - * - * The default is CT_ELEM_TYPE_ABSPOS - */ -int Elements::elementType(int m) const -{ - return m_elem_type[m]; -} -//==================================================================================================================== -// Change the element type of the mth constraint -/* - * Reassigns an element type - * - * @param m Element index - * @param elem_type New elem type to be assigned - * - * @return Returns the old element type - */ -int Elements::changeElementType(int m, int elem_type) -{ - int old = m_elem_type[m]; - m_elem_type[m] = elem_type; - return old; -} -//==================================================================================================================== -/* - * - * Add an element to the current set of elements in the current object. - * @param symbol symbol string - * @param weight atomic weight in kg/kmol. - * - * The default weight is a special value, which will cause the - * routine to look up the actual weight via a string lookup. - * - * There are two interfaces to this routine. The XML interface - * looks up the required parameters for the regular interface - * and then calls the base routine. - */ -void Elements::addElement(const std::string& symbol, doublereal weight) -{ - if (weight == -12345.0) { - weight = LookupWtElements(symbol); - if (weight < 0.0) { - throw ElementsFrozen("addElement"); - } - } - if (m_elementsFrozen) { - throw ElementsFrozen("addElement"); - return; - } - m_atomicWeights.push_back(weight); - m_elementNames.push_back(symbol); - if (symbol == "E") { - m_elem_type.push_back(CT_ELEM_TYPE_ELECTRONCHARGE); - } else { - m_elem_type.push_back(CT_ELEM_TYPE_ABSPOS); - } - - m_mm++; -} -//=========================================================================================================== -void Elements::addElement(const XML_Node& e) -{ - doublereal weight = fpValue(e["atomicWt"]); - string symbol = e["name"]; - addElement(symbol, weight); -} -//=========================================================================================================== -/* - * addUniqueElement(): - * - * Add a unique element to the set. This routine will not allow - * duplicate elements to be input. - * - * @param symbol symbol string - * @param weight atomic weight in kg/kmol. - * - * - * The default weight is a special value, which will cause the - * routine to look up the actual weight via a string lookup. - */ -void Elements::addUniqueElement(const std::string& symbol, doublereal weight, - int atomicNumber_, doublereal entropy298, - int elem_type) -{ - if (weight == -12345.0) { - weight = LookupWtElements(symbol); - if (weight < 0.0) { - throw ElementsFrozen("addElement"); - } - } - /* - * First decide if this element has been previously added - * by conducting a string search. If it unique, add it to - * the list. - */ - int ifound = 0; - int i = 0; - for (vector::const_iterator it = m_elementNames.begin(); - it < m_elementNames.end(); ++it, ++i) { - if (*it == symbol) { - ifound = 1; - break; - } - } - if (!ifound) { - if (m_elementsFrozen) { - throw ElementsFrozen("addElement"); - return; - } - m_atomicWeights.push_back(weight); - m_elementNames.push_back(symbol); - m_atomicNumbers.push_back(atomicNumber_); - m_entropy298.push_back(entropy298); - if (symbol == "E") { - m_elem_type.push_back(CT_ELEM_TYPE_ELECTRONCHARGE); - } else { - m_elem_type.push_back(elem_type); - } - m_mm++; - } else { - if (m_atomicWeights[i] != weight) { - throw CanteraError("AddUniqueElement", - "Duplicate Elements (" + symbol + ") have different weights"); - } - } -} - -/* - * @todo call addUniqueElement(symbol, weight) instead of - * addElement. - */ -void Elements::addUniqueElement(const XML_Node& e) -{ - doublereal weight = 0.0; - if (e.hasAttrib("atomicWt")) { - weight = fpValue(stripws(e["atomicWt"])); - } - int anum = 0; - if (e.hasAttrib("atomicNumber")) { - anum = atoi(stripws(e["atomicNumber"]).c_str()); - } - string symbol = e["name"]; - doublereal entropy298 = ENTROPY298_UNKNOWN; - if (e.hasChild("entropy298")) { - XML_Node& e298Node = e.child("entropy298"); - if (e298Node.hasAttrib("value")) { - entropy298 = fpValueCheck(stripws(e298Node["value"])); - } - } - if (weight != 0.0) { - addUniqueElement(symbol, weight, anum, entropy298); - } else { - addUniqueElement(symbol); - } -} - -// True if freezeElements has been called. -bool Elements::elementsFrozen() const -{ - return m_elementsFrozen; -} - -/* - * clear() - * - * Remove all elements from the structure. - */ -void Elements::clear() -{ - m_mm = 0; - m_atomicWeights.resize(0); - m_elementNames.resize(0); - m_entropy298.resize(0); - m_elem_type.resize(0); - m_elementsFrozen = false; -} - -/* - * ready(): - * - * True if the elements have been frozen - */ -bool Elements::ready() const -{ - return m_elementsFrozen; -} - - -void Elements::addElementsFromXML(const XML_Node& phase) -{ - - // get the declared element names - if (! phase.hasChild("elementArray")) { - throw CanteraError("Elements::addElementsFromXML", - "phase XML node doesn't have \"elementArray\" XML Node"); - } - XML_Node& elements = phase.child("elementArray"); - vector enames; - getStringArray(elements, enames); - - // // element database defaults to elements.xml - string element_database = "elements.xml"; - if (elements.hasAttrib("datasrc")) { - element_database = elements["datasrc"]; - } - - XML_Node* doc = get_XML_File(element_database); - XML_Node* dbe = &doc->child("elementData"); - - XML_Node& root = phase.root(); - XML_Node* local_db = 0; - if (root.hasChild("elementData")) { - local_db = &root.child("elementData"); - } - - int nel = static_cast(enames.size()); - int i; - string enm; - XML_Node* e = 0; - for (i = 0; i < nel; i++) { - e = 0; - if (local_db) { - e = local_db->findByAttr("name",enames[i]); - } - if (!e) { - e = dbe->findByAttr("name",enames[i]); - } - if (e) { - addUniqueElement(*e); - } else { - throw CanteraError("addElementsFromXML","no data for element " - +enames[i]); - } - } - -} - -/* - * subscribe(), unsubscribe(), and reportSubscriptions(): - * - * Handles setting and reporting the number of subscriptions to this - * object. - */ -void Elements::subscribe() -{ - ++numSubscribers; -} -int Elements::unsubscribe() -{ - --numSubscribers; - return numSubscribers; -} -int Elements::reportSubscriptions() const -{ - return numSubscribers; -} - -/********************* GLOBAL STATIC SECTION **************************/ -/* - * We keep track of a vector of pointers to element objects. - * Initially there are no Elements objects. Whenever one is created, - * the pointer to that object is added onto this list. - */ -vector Elements::Global_Elements_List; -/***********************************************************************/ } diff --git a/src/thermo/GeneralSpeciesThermo.cpp b/src/thermo/GeneralSpeciesThermo.cpp index 3a5f3df5d..9eb3adf01 100644 --- a/src/thermo/GeneralSpeciesThermo.cpp +++ b/src/thermo/GeneralSpeciesThermo.cpp @@ -8,6 +8,9 @@ #include "cantera/thermo/GeneralSpeciesThermo.h" #include "cantera/thermo/SpeciesThermoFactory.h" +#include "cantera/base/stringUtils.h" +#include "cantera/base/utilities.h" +#include "cantera/base/ctexceptions.h" namespace Cantera { @@ -76,31 +79,6 @@ GeneralSpeciesThermo::duplMyselfAsSpeciesThermo() const return new GeneralSpeciesThermo(*this); } -void GeneralSpeciesThermo::install(const std::string& name, - size_t index, - int type, - const doublereal* c, - doublereal minTemp_, - doublereal maxTemp_, - doublereal refPressure_) -{ - warn_deprecated("GeneralSpeciesThermo::install", - "Use newSpeciesThermoInterpType and " - "GeneralSpeciesThermo::install_STIT instead"); - if (minTemp_ <= 0.0) { - throw CanteraError("GeneralSpeciesThermo::install", - "T_min must be positive"); - } - - /* - * Create the necessary object - */ - shared_ptr sp(newSpeciesThermoInterpType(type, - minTemp_, maxTemp_, refPressure_, c)); - sp->validate(name); - install_STIT(index, sp); -} - void GeneralSpeciesThermo::install_STIT(size_t index, shared_ptr stit_ptr) { @@ -126,7 +104,7 @@ void GeneralSpeciesThermo::install_STIT(size_t index, void GeneralSpeciesThermo::installPDSShandler(size_t k, PDSS* PDSS_ptr, VPSSMgr* vpssmgr_ptr) { - shared_ptr stit_ptr(new STITbyPDSS(k, vpssmgr_ptr, PDSS_ptr)); + shared_ptr stit_ptr(new STITbyPDSS(vpssmgr_ptr, PDSS_ptr)); install_STIT(k, stit_ptr); } diff --git a/src/thermo/LatticeSolidPhase.cpp b/src/thermo/LatticeSolidPhase.cpp index c682b7e3c..bc19cc86e 100644 --- a/src/thermo/LatticeSolidPhase.cpp +++ b/src/thermo/LatticeSolidPhase.cpp @@ -11,6 +11,7 @@ #include "cantera/thermo/SpeciesThermoFactory.h" #include "cantera/thermo/GeneralSpeciesThermo.h" #include "cantera/base/ctml.h" +#include "cantera/base/stringUtils.h" #include "cantera/base/utilities.h" using namespace std; diff --git a/src/thermo/Mu0Poly.cpp b/src/thermo/Mu0Poly.cpp index ce73e566e..00797ef97 100644 --- a/src/thermo/Mu0Poly.cpp +++ b/src/thermo/Mu0Poly.cpp @@ -19,16 +19,6 @@ Mu0Poly::Mu0Poly() : m_numIntervals(0), { } -Mu0Poly::Mu0Poly(size_t n, doublereal tlow, doublereal thigh, - doublereal pref, - const doublereal* coeffs) : - SpeciesThermoInterpType(n, tlow, thigh, pref), - m_numIntervals(0), - m_H298(0.0) -{ - processCoeffs(coeffs); -} - Mu0Poly::Mu0Poly(double tlow, double thigh, double pref, const double* coeffs) : SpeciesThermoInterpType(tlow, thigh, pref), m_numIntervals(0), @@ -57,9 +47,9 @@ void Mu0Poly::updateProperties(const doublereal* tt, doublereal* cp_R, } double T1 = m_t0_int[j]; double cp_Rj = m_cp0_R_int[j]; - cp_R[m_index] = cp_Rj; - h_RT[m_index] = (m_h0_R_int[j] + (T - T1) * cp_Rj)/T; - s_R[m_index] = m_s0_R_int[j] + cp_Rj * (log(T/T1)); + *cp_R = cp_Rj; + *h_RT = (m_h0_R_int[j] + (T - T1) * cp_Rj)/T; + *s_R = m_s0_R_int[j] + cp_Rj * (log(T/T1)); } void Mu0Poly::updatePropertiesTemp(const doublereal T, @@ -75,7 +65,7 @@ void Mu0Poly::reportParameters(size_t& n, int& type, doublereal& pref, doublereal* const coeffs) const { - n = m_index; + n = 0; type = MU0_INTERP; tlow = m_lowT; thigh = m_highT; diff --git a/src/thermo/Nasa9Poly1.cpp b/src/thermo/Nasa9Poly1.cpp index d5f3b31ae..0a061d766 100644 --- a/src/thermo/Nasa9Poly1.cpp +++ b/src/thermo/Nasa9Poly1.cpp @@ -21,14 +21,6 @@ Nasa9Poly1::Nasa9Poly1() m_Pref = 1.0e5; } -Nasa9Poly1::Nasa9Poly1(size_t n, doublereal tlow, doublereal thigh, - doublereal pref, - const doublereal* coeffs) : - SpeciesThermoInterpType(n, tlow, thigh, pref), - m_coeff(coeffs, coeffs + 9) -{ -} - Nasa9Poly1::Nasa9Poly1(double tlow, double thigh, double pref, const double* coeffs) : SpeciesThermoInterpType(tlow, thigh, pref), @@ -77,11 +69,10 @@ void Nasa9Poly1::updateProperties(const doublereal* tt, doublereal sdivR = -0.5*ct0 - ct1 + tt[6]*ct2 + ct3 + 0.5*ct4 + 1.0/3.0*ct5 + 0.25*ct6 + m_coeff[8]; - // return the computed properties in the location in the output - // arrays for this species - cp_R[m_index] = cpdivR; - h_RT[m_index] = hdivRT; - s_R[m_index] = sdivR; + // return the computed properties for this species + *cp_R = cpdivR; + *h_RT = hdivRT; + *s_R = sdivR; } void Nasa9Poly1::updatePropertiesTemp(const doublereal temp, @@ -98,7 +89,7 @@ void Nasa9Poly1::reportParameters(size_t& n, int& type, doublereal& pref, doublereal* const coeffs) const { - n = m_index; + n = 0; type = NASA9; tlow = m_lowT; thigh = m_highT; diff --git a/src/thermo/Nasa9PolyMultiTempRegion.cpp b/src/thermo/Nasa9PolyMultiTempRegion.cpp index 5692ef4c9..203a20195 100644 --- a/src/thermo/Nasa9PolyMultiTempRegion.cpp +++ b/src/thermo/Nasa9PolyMultiTempRegion.cpp @@ -37,13 +37,8 @@ Nasa9PolyMultiTempRegion::Nasa9PolyMultiTempRegion(vector& regionPt m_lowT = m_regionPts[0]->minTemp(); m_highT = m_regionPts[m_numTempRegions-1]->maxTemp(); m_Pref = m_regionPts[0]->refPressure(); - m_index = m_regionPts[0]->speciesIndex(); for (size_t i = 0; i < m_numTempRegions; i++) { m_lowerTempBounds[i] = m_regionPts[i]->minTemp(); - if (m_regionPts[i]->speciesIndex() != m_index) { - throw CanteraError("Nasa9PolyMultiTempRegion::Nasa9PolyMultiTempRegion", - "m_index inconsistency"); - } if (fabs(m_regionPts[i]->refPressure() - m_Pref) > 0.0001) { throw CanteraError("Nasa9PolyMultiTempRegion::Nasa9PolyMultiTempRegion", "refPressure inconsistency"); @@ -113,13 +108,6 @@ int Nasa9PolyMultiTempRegion::reportType() const return NASA9MULTITEMP; } -void Nasa9PolyMultiTempRegion::setIndex(size_t index) { - SpeciesThermoInterpType::setIndex(index); - for (size_t i = 0; i < m_numTempRegions; i++) { - m_regionPts[i]->setIndex(index); - } -} - void Nasa9PolyMultiTempRegion::updateTemperaturePoly(double T, double* T_poly) const { T_poly[0] = T; @@ -168,7 +156,7 @@ void Nasa9PolyMultiTempRegion::reportParameters(size_t& n, int& type, doublereal& pref, doublereal* const coeffs) const { - n = m_index; + n = 0; type = NASA9MULTITEMP; tlow = m_lowT; thigh = m_highT; diff --git a/src/thermo/NasaPoly2.cpp b/src/thermo/NasaPoly2.cpp index 70e474bec..e34aa1642 100644 --- a/src/thermo/NasaPoly2.cpp +++ b/src/thermo/NasaPoly2.cpp @@ -6,13 +6,10 @@ namespace Cantera { void NasaPoly2::validate(const std::string& name) { - size_t offset = mnp_low.speciesIndex(); double cp_low, h_low, s_low; double cp_high, h_high, s_high; - mnp_low.updatePropertiesTemp(m_midT, &cp_low - offset, - &h_low - offset, &s_low - offset); - mnp_high.updatePropertiesTemp(m_midT, &cp_high - offset, - &h_high - offset, &s_high - offset); + mnp_low.updatePropertiesTemp(m_midT, &cp_low, &h_low, &s_low); + mnp_high.updatePropertiesTemp(m_midT, &cp_high, &h_high, &s_high); double delta = cp_low - cp_high; if (fabs(delta/(fabs(cp_low)+1.0E-4)) > 0.001) { diff --git a/src/thermo/NasaThermo.cpp b/src/thermo/NasaThermo.cpp deleted file mode 100644 index cc2a8d337..000000000 --- a/src/thermo/NasaThermo.cpp +++ /dev/null @@ -1,473 +0,0 @@ -/*! - * @file NasaThermo.cpp Implementation of class Cantera::NasaThermo - */ -#include "NasaThermo.h" - -#include "cantera/numerics/DenseMatrix.h" -#include "cantera/numerics/ctlapack.h" - -namespace Cantera -{ - -NasaThermo::NasaThermo() : - ID(NASA), - m_tlow_max(0.0), - m_thigh_min(1.e30), - m_p0(-1.0), - m_ngroups(0) -{ - warn_deprecated("class NasaThermo", "To be removed after " - "Cantera 2.2. Use GeneralSpeciesThermo instead."); - m_t.resize(6); -} - -NasaThermo::NasaThermo(const NasaThermo& right) : - ID(NASA), - m_tlow_max(0.0), - m_thigh_min(1.e30), - m_p0(-1.0), - m_ngroups(0) { - *this = right; -} - -NasaThermo& NasaThermo::operator=(const NasaThermo& right) -{ - /* - * Check for self assignment. - */ - if (this == &right) { - return *this; - } - - SpeciesThermo::operator=(right); - m_high = right.m_high; - m_low = right.m_low; - m_index = right.m_index; - m_tmid = right.m_tmid; - m_tlow_max = right.m_tlow_max; - m_thigh_min = right.m_thigh_min; - m_tlow = right.m_tlow; - m_thigh = right.m_thigh; - m_p0 = right.m_p0; - m_ngroups = right.m_ngroups; - m_t = right.m_t; - m_group_map = right.m_group_map; - m_posInGroup_map = right.m_posInGroup_map; - m_name = right.m_name; - - return *this; -} - -void NasaThermo::install(const std::string& name, size_t index, int type, - const doublereal* c, - doublereal min_temp, doublereal max_temp, - doublereal ref_pressure) -{ - if (type != NASA) { - throw CanteraError("NasaThermo::install", - "Incompatible thermo parameterization: Got " + - int2str(type) + " but " + int2str(NASA) + - " was expected."); - } - m_name[index] = name; - int imid = int(c[0]); // midpoint temp converted to integer - int igrp = m_index[imid]; // has this value been seen before? - if (igrp == 0) { // if not, prepare new group - std::vector v; - m_high.push_back(v); - m_low.push_back(v); - m_tmid.push_back(c[0]); - m_index[imid] = igrp = static_cast(m_high.size()); - m_ngroups++; - } - - m_group_map[index] = igrp; - m_posInGroup_map[index] = (int) m_low[igrp-1].size(); - - doublereal tlow = min_temp; - doublereal tmid = c[0]; - doublereal thigh = max_temp; - - vector_fp chigh(c+8, c+15); - vector_fp clow(c+1, c+8); - - checkContinuity(name, tmid, &clow[0], &chigh[0]); - - - m_high[igrp-1].push_back(NasaPoly1(index, tmid, thigh, - ref_pressure, &chigh[0])); - m_low[igrp-1].push_back(NasaPoly1(index, tlow, tmid, - ref_pressure, &clow[0])); - - m_tlow_max = std::max(tlow, m_tlow_max); - m_thigh_min = std::min(thigh, m_thigh_min); - if (m_tlow.size() < index + 1) { - m_tlow.resize(index + 1, tlow); - m_thigh.resize(index + 1, thigh); - } - m_tlow[index] = tlow; - m_thigh[index] = thigh; - if (m_p0 < 0.0) { - m_p0 = ref_pressure; - } else if (fabs(m_p0 - ref_pressure) > 0.1) { - std::string logmsg = " ERROR NasaThermo: New Species, " + name + ", has a different reference pressure, " - + fp2str(ref_pressure) + ", than existing reference pressure, " + fp2str(m_p0) + "\n"; - writelog(logmsg); - logmsg = " This is now a fatal error\n"; - writelog(logmsg); - throw CanteraError("install()", "species have different reference pressures"); - } - m_p0 = ref_pressure; - markInstalled(index); -} - -void NasaThermo::update_one(size_t k, doublereal t, doublereal* cp_R, - doublereal* h_RT, doublereal* s_R) const -{ - m_t[0] = t; - m_t[1] = t*t; - m_t[2] = m_t[1]*t; - m_t[3] = m_t[2]*t; - m_t[4] = 1.0/t; - m_t[5] = log(t); - - size_t grp = getValue(m_group_map, k); - size_t pos = getValue(m_posInGroup_map, k); - const std::vector &mlg = m_low[grp-1]; - const NasaPoly1* nlow = &(mlg[pos]); - - doublereal tmid = nlow->maxTemp(); - if (t < tmid) { - nlow->updateProperties(&m_t[0], cp_R, h_RT, s_R); - } else { - const std::vector &mhg = m_high[grp-1]; - const NasaPoly1* nhigh = &(mhg[pos]); - nhigh->updateProperties(&m_t[0], cp_R, h_RT, s_R); - } -} - -void NasaThermo::update(doublereal t, doublereal* cp_R, - doublereal* h_RT, doublereal* s_R) const -{ - // load functions of temperature into m_t vector - m_t[0] = t; - m_t[1] = t*t; - m_t[2] = m_t[1]*t; - m_t[3] = m_t[2]*t; - m_t[4] = 1.0/t; - m_t[5] = log(t); - - // iterate over the groups - std::vector::const_iterator _begin, _end; - for (int i = 0; i != m_ngroups; i++) { - if (t > m_tmid[i]) { - _begin = m_high[i].begin(); - _end = m_high[i].end(); - } else { - _begin = m_low[i].begin(); - _end = m_low[i].end(); - } - for (; _begin != _end; ++_begin) { - _begin->updateProperties(&m_t[0], cp_R, h_RT, s_R); - } - } -} - -void NasaThermo::reportParams(size_t index, int& type, - doublereal* const c, - doublereal& minTemp, - doublereal& maxTemp, - doublereal& refPressure) const -{ - type = reportType(index); - if (type == NASA) { - size_t grp = getValue(m_group_map, index); - size_t pos = getValue(m_posInGroup_map, index); - const std::vector &mlg = m_low[grp-1]; - const std::vector &mhg = m_high[grp-1]; - const NasaPoly1* lowPoly = &(mlg[pos]); - const NasaPoly1* highPoly = &(mhg[pos]); - int itype = NASA; - doublereal tmid = lowPoly->maxTemp(); - c[0] = tmid; - size_t n; - double ttemp; - lowPoly->reportParameters(n, itype, minTemp, ttemp, refPressure, - c + 1); - if (n != index) { - throw CanteraError("NasaThermo::reportParams", "Index mismatch"); - } - if (itype != NASA1) { - throw CanteraError("NasaThermo::reportParams", - "Thermo type mismatch for low-T polynomial"); - } - highPoly->reportParameters(n, itype, ttemp, maxTemp, refPressure, - c + 8); - if (n != index) { - throw CanteraError("NasaThermo::reportParams", "Index mismatch"); - } - if (itype != NASA1) { - throw CanteraError("NasaThermo::reportParams", - "Thermo type mismatch for high-T polynomial"); - } - } else { - throw CanteraError("NasaThermo::reportParams", "Thermo type mismatch"); - } -} - -doublereal NasaThermo::reportOneHf298(const size_t k) const -{ - size_t grp = getValue(m_group_map, k); - size_t pos = getValue(m_posInGroup_map, k); - const std::vector &mlg = m_low[grp-1]; - const NasaPoly1* nlow = &(mlg[pos]); - doublereal tmid = nlow->maxTemp(); - if (298.15 <= tmid) { - return nlow->reportHf298(0); - } else { - const std::vector &mhg = m_high[grp-1]; - const NasaPoly1* nhigh = &(mhg[pos]); - return nhigh->reportHf298(0); - } -} - -void NasaThermo::modifyOneHf298(const size_t k, const doublereal Hf298New) -{ - size_t grp = getValue(m_group_map, k); - size_t pos = getValue(m_posInGroup_map, k); - std::vector &mlg = m_low[grp-1]; - NasaPoly1* nlow = &(mlg[pos]); - std::vector &mhg = m_high[grp-1]; - NasaPoly1* nhigh = &(mhg[pos]); - doublereal tmid = nlow->maxTemp(); - - double hnow = reportOneHf298(k); - double delH = Hf298New - hnow; - if (298.15 <= tmid) { - nlow->modifyOneHf298(k, Hf298New); - double h = nhigh->reportHf298(0); - double hnew = h + delH; - nhigh->modifyOneHf298(k, hnew); - } else { - nhigh->modifyOneHf298(k, Hf298New); - double h = nlow->reportHf298(0); - double hnew = h + delH; - nlow->modifyOneHf298(k, hnew); - } -} - -doublereal NasaThermo::cp_R(double t, const doublereal* c) -{ - return poly4(t, c+2); -} - -doublereal NasaThermo::enthalpy_RT(double t, const doublereal* c) { - return c[2] + 0.5*c[3]*t + 1.0/3.0*c[4]*t*t - + 0.25*c[5]*t*t*t + 0.2*c[6]*t*t*t*t - + c[0]/t; -} - -doublereal NasaThermo::entropy_R(double t, const doublereal* c) { - return c[2]*log(t) + c[3]*t + 0.5*c[4]*t*t - + 1.0/3.0*c[5]*t*t*t + 0.25*c[6]*t*t*t*t - + c[1]; -} - -doublereal NasaThermo::checkContinuity(const std::string& name, double tmid, - doublereal* clow, doublereal* chigh) -{ - // heat capacity - doublereal cplow = cp_R(tmid, clow); - doublereal cphigh = cp_R(tmid, chigh); - doublereal delta = cplow - cphigh; - doublereal maxError = std::abs(delta); - if (fabs(delta/(fabs(cplow)+1.0E-4)) > 0.001) { - writelog("\n\n**** WARNING ****\nFor species "+name+ - ", discontinuity in cp/R detected at Tmid = " - +fp2str(tmid)+"\n"); - writelog("\tValue computed using low-temperature polynomial: " - +fp2str(cplow)+".\n"); - writelog("\tValue computed using high-temperature polynomial: " - +fp2str(cphigh)+".\n"); - } - - // enthalpy - doublereal hrtlow = enthalpy_RT(tmid, clow); - doublereal hrthigh = enthalpy_RT(tmid, chigh); - delta = hrtlow - hrthigh; - maxError = std::max(std::abs(delta), maxError); - if (fabs(delta/(fabs(hrtlow)+cplow*tmid)) > 0.001) { - writelog("\n\n**** WARNING ****\nFor species "+name+ - ", discontinuity in h/RT detected at Tmid = " - +fp2str(tmid)+"\n"); - writelog("\tValue computed using low-temperature polynomial: " - +fp2str(hrtlow)+".\n"); - writelog("\tValue computed using high-temperature polynomial: " - +fp2str(hrthigh)+".\n"); - } - - // entropy - doublereal srlow = entropy_R(tmid, clow); - doublereal srhigh = entropy_R(tmid, chigh); - delta = srlow - srhigh; - maxError = std::max(std::abs(delta), maxError); - if (fabs(delta/(fabs(srlow)+cplow)) > 0.001) { - writelog("\n\n**** WARNING ****\nFor species "+name+ - ", discontinuity in s/R detected at Tmid = " - +fp2str(tmid)+"\n"); - writelog("\tValue computed using low-temperature polynomial: " - +fp2str(srlow)+".\n"); - writelog("\tValue computed using high-temperature polynomial: " - +fp2str(srhigh)+".\n"); - } - - return maxError; -} - -void NasaThermo::fixDiscontinuities(doublereal Tlow, doublereal Tmid, - doublereal Thigh, doublereal* clow, - doublereal* chigh) -{ - // The thermodynamic parameters can be written in terms nondimensionalized - // coefficients A[i] and the nondimensional temperature t = T/Tmid as: - // - // C_low(t) = A[0] + A[i] * t**i - // H_low(t) = A[0] + A[i] / (i+1) * t**i + A[5] / t - // S_low(t) = A[0]*ln(t) + A[i] / i * t**i + A[6] - // - // where the implicit sum is over the range 1 <= i <= 4 and the - // nondimensional coefficients are related to the dimensional coefficients - // a[i] by: - // - // A[0] = a[0] - // A[i] = Tmid**i * a[i], 1 <= i <= 4 - // A[5] = a[5] / Tmid - // A[6] = a[6] + a[0] * ln(Tmid) - // - // and corresponding relationships hold for the high-temperature - // polynomial coefficients B[i]. This nondimensionalization is necessary - // in order for the resulting matrix to be well-conditioned. - // - // The requirement that C_low(1) = C_high(1) is satisfied by: - // - // B[0] = A[0] + (A[i] - B[i]) - // C_high(t) = A[0] + (A[i] + B[i] * t**i - 1) - // - // The requirement that H_low(1) = H_high(1) is satisfied by: - // - // B[5] = A[5] + (i / (i+1) * (B[i] - A[i])) - // H_high(t) = A[0] + A[5] / t + (1 - i / (i+1) / t) * A[i] + - // (t**i / (i+1) - 1 + i / (i+1) / t) * B[i] - // - // The requirement that S_low(1) = S_high(1) is satisfied by: - // - // B[6] = A[6] + (A[i] - B[i]) / i - // S_high(t) = A[0] * ln(t) + A[6] + (ln(t) + 1 / i) * A[i] + - // (-ln(t) + t**i / i - 1 / i) * B[i] - - // Formulate a linear least squares problem for the nondimensionalized - // coefficients. In the system of equations M*x = b: - // - each row of M consists of the factors in one of the above equations - // for C_low, H_high, etc. evaluated at some temperature between Tlow - // and Thigh - // - x is a vector of the 11 independent coefficients (A[0] through A[6] - // and B[1] through B[4]) - // - B is a vector of the corresponding value of C, H, or S computed using - // the original polynomial. - - const size_t nTemps = 12; - const size_t nCols = 11; // number of independent coefficients - const size_t nRows = 3*nTemps; // Evaluate C, H, and S at each temperature - DenseMatrix M(nRows, nCols, 0.0); - vector_fp b(nRows); - doublereal sqrtDeltaT = sqrt(Thigh) - sqrt(Tlow); - vector_fp tpow(5); - for (size_t j = 0; j < nTemps; j++) { - double T = pow(sqrt(Tlow) + sqrtDeltaT * j / (nTemps - 1.0), 2); - double t = T / Tmid; // non-dimensionalized temperature - double logt = std::log(t); - size_t n = 3 * j; // row index - for (int i = 1; i <= 4; i++) { - tpow[i] = pow(t, i); - } - - // row n: Cp/R - // row n+1: H/RT - // row n+2: S/R - // columns 0 through 6 are for the low-T coefficients - // columns 7 through 10 are for the independent high-T coefficients - M(n, 0) = 1.0; - M(n+1,0) = 1.0; - M(n+2,0) = logt; - M(n+1,5) = 1.0 / t; - M(n+2,6) = 1.0; - if (t <= 1.0) { - for (int i = 1; i <= 4; i++) { - M(n,i) = tpow[i]; - M(n+1,i) = tpow[i] / (i+1); - M(n+2,i) = tpow[i] / i; - } - b[n] = cp_R(T, clow); - b[n+1] = enthalpy_RT(T, clow); - b[n+2] = entropy_R(T, clow); - } else { - for (int i = 1; i <= 4; i++) { - M(n,i) = 1.0; - M(n,i+6) = tpow[i] - 1.0; - M(n+1,i) = 1 - i / ((i + 1.0) * t); - M(n+1,i+6) = -1 + tpow[i] / (i+1) + i / ((i+1) * t); - M(n+2,i) = logt + 1.0 / i; - M(n+2,i+6) = -logt + (tpow[i] - 1.0) / i; - } - b[n] = cp_R(T, chigh); - b[n+1] = enthalpy_RT(T, chigh); - b[n+2] = entropy_R(T, chigh); - } - } - - // Solve the least squares problem - vector_fp sigma(nRows); - size_t rank; - int info; - vector_fp work(1); - int lwork = -1; - // First get the desired size of the work array - ct_dgelss(nRows, nCols, 1, &M(0,0), nRows, &b[0], nRows, - &sigma[0], -1, rank, &work[0], lwork, info); - work.resize(static_cast(work[0])); - lwork = static_cast(work[0]); - ct_dgelss(nRows, nCols, 1, &M(0,0), nRows, &b[0], nRows, - &sigma[0], -1, rank, &work[0], lwork, info); - - AssertTrace(info == 0); - AssertTrace(rank == nCols); - AssertTrace(sigma[0] / sigma[10] < 1e20); // condition number - - // Compute the full set of nondimensionalized coefficients - // (dgelss returns the solution of M*x = b in b). - - // Note that clow and chigh store the coefficients in the order: - // clow = [a[5], a[6], a[0], a[1], a[2], a[3], a[4]] - clow[2] = chigh[2] = b[0]; - clow[0] = chigh[0] = b[5]; - clow[1] = chigh[1] = b[6]; - for (int i = 1; i <= 4; i++) { - clow[2+i] = b[i]; - chigh[2+i] = b[6+i]; - chigh[2] += clow[2+i] - chigh[2+i]; - chigh[0] += i / (i + 1.0) * (chigh[2+i] - clow[2+i]); - chigh[1] += (clow[2+i] - chigh[2+i]) / i; - } - - // redimensionalize - for (int i = 1; i <= 4; i++) { - clow[2+i] /= pow(Tmid, i); - chigh[2+i] /= pow(Tmid, i); - } - clow[0] *= Tmid; - chigh[0] *= Tmid; - clow[1] -= clow[2] * std::log(Tmid); - chigh[1] -= chigh[2] * std::log(Tmid); -} - -} diff --git a/src/thermo/NasaThermo.h b/src/thermo/NasaThermo.h deleted file mode 100644 index 7887c24f8..000000000 --- a/src/thermo/NasaThermo.h +++ /dev/null @@ -1,293 +0,0 @@ -/** - * @file NasaThermo.h - * Header for the 2 regime 7 coefficient NASA thermodynamic - * polynomials for multiple species in a phase, derived from the - * \link Cantera::SpeciesThermo SpeciesThermo\endlink base class (see \ref mgrsrefcalc and - * \link Cantera::NasaThermo NasaThermo\endlink). - */ -// Copyright 2003 California Institute of Technology - -#ifndef CT_NASATHERMO_H -#define CT_NASATHERMO_H - -#include "cantera/thermo/SpeciesThermoMgr.h" -#include "cantera/thermo/NasaPoly1.h" - -namespace Cantera -{ -/** - * A species thermodynamic property manager for the NASA - * polynomial parameterization with two temperature ranges. - * - * This class is designed to efficiently evaluate the properties - * of a large number of species with the NASA parameterization. - * - * The original NASA polynomial parameterization expressed the - * heat capacity as a fourth-order polynomial in temperature, with - * separate coefficients for each of two temperature ranges. (The - * newer NASA format adds coefficients for 1/T and 1/T^2, and - * allows multiple temperature ranges.) This class is designed for - * use with the original parameterization, which is used, for - * example, by the Chemkin software package. - * - * In many cases, the midpoint temperature is the same for many - * species. To take advantage of this, class NasaThermo groups - * species with a common midpoint temperature, so that checking - * which range the desired temperature is in need be done only - * once for each group. - * - * @note There is a special CTML element for entering the - * coefficients of this parameterization. - * @see importCTML - * - * @ingroup mgrsrefcalc - * @deprecated To be removed after Cantera 2.2. Use GeneralSpeciesThermo instead. - */ -class NasaThermo : public SpeciesThermo -{ -public: - NasaThermo(); - - NasaThermo(const NasaThermo& right); - - NasaThermo& operator=(const NasaThermo& right); - - virtual SpeciesThermo* duplMyselfAsSpeciesThermo() const { - NasaThermo* nt = new NasaThermo(*this); - return (SpeciesThermo*) nt; - } - - //! install a new species thermodynamic property - //! parameterization for one species. - /*! - * @param name Name of the species - * @param index The 'update' method will update the property values for - * this species at position i index in the property - * arrays. - * @param type int flag specifying the type of parameterization to be - * installed. - * @param c vector of coefficients for the parameterization. - * - c[0] midpoint temperature - * - c[1] - c[7] coefficients for low T range - * - c[8] - c[14] coefficients for high T range - * @param min_temp minimum temperature for which this parameterization - * is valid. - * @param max_temp maximum temperature for which this parameterization - * is valid. - * @param ref_pressure standard-state pressure for this parameterization. - * @see speciesThermoTypes.h - */ - virtual void install(const std::string& name, size_t index, int type, - const doublereal* c, - doublereal min_temp, doublereal max_temp, - doublereal ref_pressure); - - virtual void install_STIT(size_t index, shared_ptr stit_ptr) { - throw CanteraError("install_STIT", "not implemented"); - } - - //! Like update(), but only updates the single species k. - /*! - * @param k species index - * @param t Temperature (Kelvin) - * @param cp_R Vector of Dimensionless heat capacities. (length m_kk). - * @param h_RT Vector of Dimensionless enthalpies. (length m_kk). - * @param s_R Vector of Dimensionless entropies. (length m_kk). - */ - virtual void update_one(size_t k, doublereal t, doublereal* cp_R, - doublereal* h_RT, doublereal* s_R) const; - - virtual void update(doublereal t, doublereal* cp_R, - doublereal* h_RT, doublereal* s_R) const; - - virtual doublereal minTemp(size_t k=npos) const { - if (k == npos) { - return m_tlow_max; - } else { - return m_tlow[k]; - } - } - - virtual doublereal maxTemp(size_t k=npos) const { - if (k == npos) { - return m_thigh_min; - } else { - return m_thigh[k]; - } - } - - virtual doublereal refPressure(size_t k=npos) const { - return m_p0; - } - - virtual int reportType(size_t index) const { - return NASA; - } - - /*! - * This utility function reports back the type of - * parameterization and all of the parameters for the - * species, index. - * - * @param index Species index - * @param type Integer type of the standard type - * @param c Vector of coefficients used to set the - * parameters for the standard state. - * For the NASA object, there are 15 coefficients. - * @param minTemp output - Minimum temperature - * @param maxTemp output - Maximum temperature - * @param refPressure output - reference pressure (Pa). - */ - virtual void reportParams(size_t index, int& type, - doublereal* const c, - doublereal& minTemp, - doublereal& maxTemp, - doublereal& refPressure) const; - - virtual doublereal reportOneHf298(const size_t k) const; - virtual void modifyOneHf298(const size_t k, const doublereal Hf298New); - - //! Initialized to the type of parameterization - /*! - * Note, this value is used in some template functions - */ - const int ID; - -protected: - //! Vector of vector of NasaPoly1's for the high temp region. - /*! - * This is the high temp region representation. - * The first Length is equal to the number of groups. - * The second vector is equal to the number of species - * in that particular group. - */ - std::vector > m_high; - - //! Vector of vector of NasaPoly1's for the low temp region. - /*! - * This is the low temp region representation. - * The first Length is equal to the number of groups. - * The second vector is equal to the number of species - * in that particular group. - */ - std::vector > m_low; - - //! Map between the midpoint temperature, as an int, to the group number - /*! - * Length is equal to the number of groups. Only used in the setup. - */ - std::map m_index; - - //! Vector of log temperature limits - /*! - * Length is equal to the number of groups. - */ - vector_fp m_tmid; - - //! Maximum value of the low temperature limit - doublereal m_tlow_max; - - //! Minimum value of the high temperature limit - doublereal m_thigh_min; - - //! Vector of low temperature limits (species index) - /*! - * Length is equal to number of species - */ - vector_fp m_tlow; - - //! Vector of low temperature limits (species index) - /*! - * Length is equal to number of species - */ - vector_fp m_thigh; - - //! Reference pressure (Pa) - /*! - * all species must have the same reference pressure. - */ - doublereal m_p0; - - //! number of groups - int m_ngroups; - - //! Vector of temperature polynomials - mutable vector_fp m_t; - - /*! - * This map takes as its index, the species index in the phase. - * It returns the group index, where the temperature polynomials - * for that species are stored. group indices start at 1, - * so a decrement is always performed to access vectors. - */ - std::map m_group_map; - - /*! - * This map takes as its index, the species index in the phase. - * It returns the position index within the group, where the - * temperature polynomials for that species are stored. - */ - std::map m_posInGroup_map; - - //! Species name as a function of the species index - std::map m_name; - -protected: - //! Compute the nondimensional heat capacity using the given NASA polynomial - /*! - * @param t temperature - * @param c coefficient array - */ - doublereal cp_R(double t, const doublereal* c); - - //! Compute the nondimensional enthalpy using the given NASA polynomial - /*! - * @param t temperature - * @param c coefficient array - */ - doublereal enthalpy_RT(double t, const doublereal* c); - - //! Compute the nondimensional entropy using the given NASA polynomial - /*! - * @param t temperature - * @param c coefficient array - */ - doublereal entropy_R(double t, const doublereal* c); - - //! Adjust polynomials to be continuous at the midpoint temperature. - /*! - * Check to see if the provided coefficients are nearly continuous. Adjust - * the values to get more precise continuity to avoid convergence - * issues with algorithms that expect these quantities to be continuous. - * - * @param name string name of species - * @param tmid Mid temperature, between the two temperature regions - * @param clow coefficients for lower temperature region - * @param chigh coefficients for higher temperature region - */ - double checkContinuity(const std::string& name, double tmid, - doublereal* clow, doublereal* chigh); - - //! Adjust polynomials to be continuous at the midpoint temperature. - /*! - * We seek a set of coefficients for the low- and high-temperature - * polynomials which are continuous in Cp, H, and S at the midpoint while - * minimizing the difference between the values in Cp, H, and S over the - * entire valid temperature range. To do this, we formulate a linear - * least-squares problem to be solved for 11 of the 14 coefficients, with - * the remaining 3 coefficients eliminated in the process of satisfying - * the continuity constraints. - * - * @param Tlow Minimum temperature at which the low-T polynomial is valid - * @param Tmid Mid temperature, between the two temperature regions - * @param Thigh Maximum temperature at which the high-T polynomial is valid - * @param clow coefficients for lower temperature region - * @param chigh coefficients for higher temperature region - */ - void fixDiscontinuities(doublereal Tlow, doublereal Tmid, doublereal Thigh, - doublereal* clow, doublereal* chigh); -}; - -} - -#endif diff --git a/src/thermo/Phase.cpp b/src/thermo/Phase.cpp index 75a65f848..2a22b6285 100644 --- a/src/thermo/Phase.cpp +++ b/src/thermo/Phase.cpp @@ -531,18 +531,6 @@ const vector_fp& Phase::molecularWeights() const return m_molwts; } -void Phase::getMoleFractionsByName(compositionMap& x) const -{ - warn_deprecated("void Phase::getMoleFractionsByName(compositionMap&)", - "To be removed after Cantera 2.2. Use" - " 'compositionMap getMoleFractionsByName(double threshold)'" - " instead"); - x.clear(); - for (size_t k = 0; k < m_kk; k++) { - x[speciesName(k)] = Phase::moleFraction(k); - } -} - compositionMap Phase::getMoleFractionsByName(double threshold) const { compositionMap comp; @@ -778,79 +766,6 @@ size_t Phase::addElement(const std::string& symbol, doublereal weight, return m_mm-1; } -void Phase::addElement(const XML_Node& e) -{ - warn_deprecated("Phase::addElement(XML_Node&)", - "To be removed after Cantera 2.2."); - doublereal weight = 0.0; - if (e.hasAttrib("atomicWt")) { - weight = fpValue(stripws(e["atomicWt"])); - } - int anum = 0; - if (e.hasAttrib("atomicNumber")) { - anum = atoi(stripws(e["atomicNumber"]).c_str()); - } - string symbol = e["name"]; - doublereal entropy298 = ENTROPY298_UNKNOWN; - if (e.hasChild("entropy298")) { - XML_Node& e298Node = e.child("entropy298"); - if (e298Node.hasAttrib("value")) { - entropy298 = fpValueCheck(stripws(e298Node["value"])); - } - } - if (weight != 0.0) { - addElement(symbol, weight, anum, entropy298); - } else { - addElement(symbol); - } -} - -void Phase::addUniqueElement(const std::string& symbol, doublereal weight, - int atomic_number, doublereal entropy298, - int elem_type) -{ - warn_deprecated("Phase::addUniqueElement", - "Equivalent to Phase::addElement. " - "To be removed after Cantera 2.2."); - addElement(symbol, weight, atomic_number, entropy298, elem_type); -} - -void Phase::addUniqueElement(const XML_Node& e) -{ - warn_deprecated("Phase::addUniqueElement", - "To be removed after Cantera 2.2."); - addElement(e); -} - -void Phase::addElementsFromXML(const XML_Node& phase) -{ - warn_deprecated("Phase::addElementsFromXML", - "Use 'addElements' function. " - "To be removed after Cantera 2.2."); - installElements(*this, phase); -} - -void Phase::freezeElements() -{ - warn_deprecated("Phase::freezeElements", "To be removed after Cantera 2.2."); -} - -bool Phase::elementsFrozen() -{ - warn_deprecated("Phase::elementsFrozen", "To be removed after Cantera 2.2."); - return false; -} - -size_t Phase::addUniqueElementAfterFreeze(const std::string& symbol, - doublereal weight, int atomicNumber, - doublereal entropy298, int elem_type) -{ - warn_deprecated("Phase::addUniqueElementAfterFreeze", - "Equivalent to Phase::addElement. " - "To be removed after Cantera 2.2"); - return addElement(symbol, weight, atomicNumber, entropy298, elem_type); -} - bool Phase::addSpecies(shared_ptr spec) { m_species[spec->name] = spec; vector_fp comp(nElements()); @@ -937,54 +852,6 @@ bool Phase::addSpecies(shared_ptr spec) { return true; } -void Phase::addSpecies(const std::string& name_, const doublereal* comp, - doublereal charge_, doublereal size_) -{ - warn_deprecated("Phase::addSpecies(string, double*, double, double)", - "Use AddSpecies(shared_ptr spec) instead. To be removed " - "after Cantera 2.2."); - compositionMap cmap; - for (size_t i = 0; i < nElements(); i++) { - if (comp[i]) { - cmap[elementName(i)] = comp[i]; - } - } - shared_ptr sp(new Species(name_, cmap, charge_, size_)); - Phase::addSpecies(sp); -} - -void Phase::addUniqueSpecies(const std::string& name_, const doublereal* comp, - doublereal charge_, doublereal size_) -{ - warn_deprecated("Phase::addUniqueSpecies", - "Use AddSpecies(shared_ptr spec) instead. To be removed " - "after Cantera 2.2."); - for (size_t k = 0; k < m_kk; k++) { - if (m_speciesNames[k] == name_) { - // We have found a match. Do some compatibility checks. - for (size_t i = 0; i < m_mm; i++) { - if (comp[i] != m_speciesComp[k * m_mm + i]) { - throw CanteraError("addUniqueSpecies", - "Duplicate species have different " - "compositions: " + name_); - } - } - if (charge_ != m_speciesCharge[k]) { - throw CanteraError("addUniqueSpecies", - "Duplicate species have different " - "charges: " + name_); - } - if (size_ != m_speciesSize[k]) { - throw CanteraError("addUniqueSpecies", - "Duplicate species have different " - "sizes: " + name_); - } - return; - } - } - addSpecies(name_, comp, charge_, size_); -} - shared_ptr Phase::species(const std::string& name) const { return getValue(m_species, name); diff --git a/src/thermo/ShomateThermo.h b/src/thermo/ShomateThermo.h deleted file mode 100644 index 3e2a055a7..000000000 --- a/src/thermo/ShomateThermo.h +++ /dev/null @@ -1,451 +0,0 @@ -/** - * @file ShomateThermo.h - * Header for the 2 regions Shomate polynomial - * for multiple species in a phase, derived from the - * \link Cantera::SpeciesThermo SpeciesThermo\endlink base class (see \ref mgrsrefcalc and - * \link Cantera::ShomateThermo ShomateThermo\endlink). - */ -// Copyright 2001 California Institute of Technology - -#ifndef CT_SHOMATETHERMO_H -#define CT_SHOMATETHERMO_H - -#include "cantera/thermo/SpeciesThermoMgr.h" -#include "cantera/thermo/ShomatePoly.h" -#include "cantera/base/global.h" -#include "cantera/base/utilities.h" - -namespace Cantera -{ -//! A species thermodynamic property manager for the Shomate polynomial parameterization. -/*! - * This is the parameterization used - * in the NIST Chemistry WebBook (http://webbook.nist.gov/chemistry) - * The parameterization assumes there are two temperature regions - * each with its own Shomate polynomial representation, for each - * species in the phase. - * - * \f[ - * \tilde{c}_p^0(T) = A + B t + C t^2 + D t^3 + \frac{E}{t^2} - * \f] - * \f[ - * \tilde{h}^0(T) = A t + \frac{B t^2}{2} + \frac{C t^3}{3} - + \frac{D t^4}{4} - \frac{E}{t} + F. - * \f] - * \f[ - * \tilde{s}^0(T) = A\ln t + B t + \frac{C t^2}{2} - + \frac{D t^3}{3} - \frac{E}{2t^2} + G. - * \f] - * - * In the above expressions, the thermodynamic polynomials are expressed - * in dimensional units, but the temperature,\f$ t \f$, is divided by 1000. The - * following dimensions are assumed in the above expressions: - * - * - \f$ \tilde{c}_p^0(T)\f$ = Heat Capacity (J/gmol*K) - * - \f$ \tilde{h}^0(T) \f$ = standard Enthalpy (kJ/gmol) - * - \f$ \tilde{s}^0(T) \f$= standard Entropy (J/gmol*K) - * - \f$ t \f$= temperature (K) / 1000. - * - * Note, the polynomial data (i.e., A, ... , G) is entered in dimensional form. - * - * This is in contrast to the NASA database polynomials which are entered in - * nondimensional form (i.e., NASA parameterizes C_p/R, while Shomate - * parameterizes C_p assuming units of J/gmol*K - and kJ/gmol*K for H). - * Note, also that the H - H_298.15 equation has units of kJ/gmol, because of - * the implicit integration of (t = T 1000), which provides a - * multiplier of 1000 to the Enthalpy equation. - * - * @deprecated To be removed after Cantera 2.2. Use GeneralSpeciesThermo instead. - * @ingroup mgrsrefcalc - */ -class ShomateThermo : public SpeciesThermo -{ -public: - //! Initialized to the type of parameterization - /*! - * Note, this value is used in some template functions - */ - const int ID; - - //! constructor - ShomateThermo() : - ID(SHOMATE), - m_tlow_max(0.0), - m_thigh_min(1.e30), - m_p0(-1.0), - m_ngroups(0) { - warn_deprecated("class ShomateThermo", "To be removed after " - "Cantera 2.2. Use GeneralSpeciesThermo instead."); - m_t.resize(7); - } - - //! Copy Constructor - /*! - * @param right Object to be copied - */ - ShomateThermo(const ShomateThermo& right) : - ID(SHOMATE), - m_tlow_max(0.0), - m_thigh_min(1.e30), - m_p0(-1.0), - m_ngroups(0) { - *this = right; - } - - //! Assignment Operator - /*! - * @param right Object to be copied - */ - ShomateThermo& operator=(const ShomateThermo& right) { - if (&right == this) { - return *this; - } - - SpeciesThermo::operator=(right); - m_high = right.m_high; - m_low = right.m_low; - m_index = right.m_index; - m_tmid = right.m_tmid; - m_tlow_max = right.m_tlow_max; - m_thigh_min = right.m_thigh_min; - m_tlow = right.m_tlow; - m_thigh = right.m_thigh; - m_p0 = right.m_p0; - m_ngroups = right.m_ngroups; - m_t = right.m_t; - m_group_map = right.m_group_map; - m_posInGroup_map = right.m_posInGroup_map; - - return *this; - } - - virtual SpeciesThermo* duplMyselfAsSpeciesThermo() const { - return new ShomateThermo(*this); - } - - //! Install a new species thermodynamic property - //! parameterization for one species using Shomate polynomials - /*! - * Two temperature regions are assumed. - * - * @param name Name of the species - * @param index Species index - * @param type int flag specifying the type of parameterization to be - * installed. - * @param c Vector of coefficients for the parameterization. - * There are 15 coefficients for the 2-zone Shomate polynomial. - * The first coefficient is the value of Tmid. The next 7 - * coefficients are the low temperature range Shomate coefficients. - * The last 7 are the high temperature range Shomate coefficients. - * - * @param minTemp minimum temperature for which this parameterization - * is valid. - * @param maxTemp maximum temperature for which this parameterization - * is valid. - * @param refPressure standard-state pressure for this - * parameterization. - * - * @see ShomatePoly - * @see ShomatePoly2 - */ - virtual void install(const std::string& name, size_t index, int type, - const doublereal* c, - doublereal minTemp, doublereal maxTemp, - doublereal refPressure) { - if (type != SHOMATE) { - throw CanteraError("ShomateThermo::install", - "Incompatible thermo parameterization: Got " + - int2str(type) + " but " + int2str(SHOMATE) + - " was expected."); - } - int imid = int(c[0]); // midpoint temp converted to integer - int igrp = m_index[imid]; // has this value been seen before? - if (igrp == 0) { // if not, prepare new group - std::vector v; - m_high.push_back(v); - m_low.push_back(v); - m_tmid.push_back(c[0]); - m_index[imid] = igrp = static_cast(m_high.size()); - m_ngroups++; - } - m_group_map[index] = igrp; - m_posInGroup_map[index] = (int) m_low[igrp-1].size(); - doublereal tlow = minTemp; - doublereal tmid = c[0]; - doublereal thigh = maxTemp; - - const doublereal* clow = c + 1; - const doublereal* chigh = c + 8; - m_high[igrp-1].push_back(ShomatePoly(index, tmid, thigh, - refPressure, chigh)); - m_low[igrp-1].push_back(ShomatePoly(index, tlow, tmid, - refPressure, clow)); - m_tlow_max = std::max(m_tlow_max, tlow); - m_thigh_min = std::min(m_thigh_min, thigh); - if (m_tlow.size() < index + 1) { - m_tlow.resize(index + 1, tlow); - m_thigh.resize(index + 1, thigh); - } - m_tlow[index] = tlow; - m_thigh[index] = thigh; - - if (m_p0 < 0.0) { - m_p0 = refPressure; - } else if (fabs(m_p0 - refPressure) > 0.1) { - std::string logmsg = " ERROR ShomateThermo: New Species, " + name - + ", has a different reference pressure, " - + fp2str(refPressure) + ", than existing reference pressure, " + fp2str(m_p0) + "\n"; - writelog(logmsg); - logmsg = " This is now a fatal error\n"; - writelog(logmsg); - throw CanteraError("install()", "Species have different reference pressures"); - } - m_p0 = refPressure; - markInstalled(index); - } - - virtual void install_STIT(size_t index, - shared_ptr stit_ptr) { - throw CanteraError("install_STIT", "not implemented"); - } - - //! Like update(), but only updates the single species k. - /*! - * @param k species index - * @param t Temperature (Kelvin) - * @param cp_R Vector of Dimensionless heat capacities. (length m_kk). - * @param h_RT Vector of Dimensionless enthalpies. (length m_kk). - * @param s_R Vector of Dimensionless entropies. (length m_kk). - */ - virtual void update_one(size_t k, doublereal t, doublereal* cp_R, - doublereal* h_RT, doublereal* s_R) const { - doublereal tt = 1.e-3*t; - m_t[0] = tt; - m_t[1] = tt*tt; - m_t[2] = m_t[1]*tt; - m_t[3] = 1.0/m_t[1]; - m_t[4] = log(tt); - m_t[5] = 1.0/GasConstant; - m_t[6] = 1.0/(GasConstant * t); - - size_t grp = getValue(m_group_map, k); - size_t pos = getValue(m_posInGroup_map, k); - const std::vector &mlg = m_low[grp-1]; - const ShomatePoly* nlow = &(mlg[pos]); - - if (t < nlow->maxTemp()) { - nlow->updateProperties(&m_t[0], cp_R, h_RT, s_R); - } else { - const std::vector &mhg = m_high[grp-1]; - const ShomatePoly* nhigh = &(mhg[pos]); - nhigh->updateProperties(&m_t[0], cp_R, h_RT, s_R); - } - } - - virtual void update(doublereal t, doublereal* cp_R, - doublereal* h_RT, doublereal* s_R) const { - doublereal tt = 1.e-3*t; - m_t[0] = tt; - m_t[1] = tt*tt; - m_t[2] = m_t[1]*tt; - m_t[3] = 1.0/m_t[1]; - m_t[4] = log(tt); - m_t[5] = 1.0/GasConstant; - m_t[6] = 1.0/(GasConstant * t); - - std::vector::const_iterator _begin, _end; - for (int i = 0; i != m_ngroups; i++) { - if (t > m_tmid[i]) { - _begin = m_high[i].begin(); - _end = m_high[i].end(); - } else { - _begin = m_low[i].begin(); - _end = m_low[i].end(); - } - for (; _begin != _end; ++_begin) { - _begin->updateProperties(&m_t[0], cp_R, h_RT, s_R); - } - } - } - - virtual doublereal minTemp(size_t k=npos) const { - if (k == npos) { - return m_tlow_max; - } else { - return m_tlow[k]; - } - } - - virtual doublereal maxTemp(size_t k=npos) const { - if (k == npos) { - return m_thigh_min; - } else { - return m_thigh[k]; - } - } - - virtual doublereal refPressure(size_t k=npos) const { - return m_p0; - } - - virtual int reportType(size_t index) const { - return SHOMATE; - } - - virtual void reportParams(size_t index, int& type, - doublereal* const c, - doublereal& minTemp, - doublereal& maxTemp, - doublereal& refPressure) const { - type = reportType(index); - if (type == SHOMATE) { - size_t grp = getValue(m_group_map, index); - size_t pos = getValue(m_posInGroup_map, index); - int itype = SHOMATE; - const std::vector &mlg = m_low[grp-1]; - const std::vector &mhg = m_high[grp-1]; - const ShomatePoly* lowPoly = &(mlg[pos]); - const ShomatePoly* highPoly = &(mhg[pos]); - doublereal tmid = lowPoly->maxTemp(); - c[0] = tmid; - size_t n; - double ttemp; - lowPoly->reportParameters(n, itype, minTemp, ttemp, refPressure, - c + 1); - if (n != index) { - throw CanteraError("ShomateThermo::reportParams", - "Index mismatch in low-T polynomial"); - } - if (itype != SHOMATE && itype != SHOMATE1) { - throw CanteraError("ShomateThermo::reportParams", - "Thermo type mismatch in low-T polynomial"); - } - highPoly->reportParameters(n, itype, ttemp, maxTemp, - refPressure, c + 8); - if (n != index) { - throw CanteraError("ShomateThermo::reportParams", - "Index mismatch in high-T polynomial"); - } - if (itype != SHOMATE && itype != SHOMATE1) { - throw CanteraError("ShomateThermo::reportParams", - "Thermo type mismatch in high-T polynomial"); - } - } else { - throw CanteraError("ShomateThermo::reportParams", "Thermo type mismatch"); - } - } - - virtual doublereal reportOneHf298(const size_t k) const { - size_t grp = getValue(m_group_map, k); - size_t pos = getValue(m_posInGroup_map, k); - const ShomatePoly& nlow = m_low[grp-1][pos]; - - if (nlow.maxTemp() > 298.15) { - return nlow.reportHf298(); - } else { - const ShomatePoly& nhigh = m_high[grp-1][pos]; - return nhigh.reportHf298(); - } - } - - virtual void modifyOneHf298(const size_t k, const doublereal Hf298New) { - - size_t grp = m_group_map[k]; - size_t pos = m_posInGroup_map[k]; - ShomatePoly& nlow = m_low[grp-1][pos]; - ShomatePoly& nhigh = m_high[grp-1][pos]; - - double hnow = reportOneHf298(k); - double delH = Hf298New - hnow; - if (nlow.maxTemp() > 298.15) { - nlow.modifyOneHf298(k, Hf298New); - double h = nhigh.reportHf298(0); - double hnew = h + delH; - nhigh.modifyOneHf298(k, hnew); - } else { - nhigh.modifyOneHf298(k, Hf298New); - double h = nlow.reportHf298(0); - double hnew = h + delH; - nlow.modifyOneHf298(k, hnew); - } - - } - -protected: - //! Vector of vector of NasaPoly1's for the high temp region. - /*! - * This is the high temp region representation. The first Length is equal - * to the number of groups. The second vector is equal to the number of - * species in that particular group. - */ - std::vector > m_high; - - //! Vector of vector of NasaPoly1's for the low temp region. - /*! - * This is the low temp region representation. The first Length is equal - * to the number of groups. The second vector is equal to the number of - * species in that particular group. - */ - std::vector > m_low; - - //! Map between the midpoint temperature, as an int, to the group number - /*! - * Length is equal to the number of groups. Only used in the setup. - */ - std::map m_index; - - //! Vector of log temperature limits - /*! - * Length is equal to the number of groups. - */ - vector_fp m_tmid; - - //! Maximum value of the low temperature limit - doublereal m_tlow_max; - - //! Minimum value of the high temperature limit - doublereal m_thigh_min; - - //! Vector of low temperature limits (species index) - /*! - * Length is equal to number of species - */ - vector_fp m_tlow; - - //! Vector of low temperature limits (species index) - /*! - * Length is equal to number of species - */ - vector_fp m_thigh; - - //! Reference pressure (Pa) - /*! - * all species must have the same reference pressure. - */ - doublereal m_p0; - - //! number of groups - int m_ngroups; - - //! Vector of temperature polynomials - mutable vector_fp m_t; - - /*! - * This map takes as its index, the species index in the phase. - * It returns the group index, where the temperature polynomials - * for that species are stored. group indices start at 1, - * so a decrement is always performed to access vectors. - */ - std::map m_group_map; - - /*! - * This map takes as its index, the species index in the phase. - * It returns the position index within the group, where the - * temperature polynomials for that species are stored. - */ - std::map m_posInGroup_map; -}; - -} - -#endif diff --git a/src/thermo/SpeciesThermoFactory.cpp b/src/thermo/SpeciesThermoFactory.cpp index 71d492edf..49fe191df 100644 --- a/src/thermo/SpeciesThermoFactory.cpp +++ b/src/thermo/SpeciesThermoFactory.cpp @@ -1,187 +1,32 @@ /** * @file SpeciesThermoFactory.cpp - * Definitions for factory to build instances of classes that manage the - * standard-state thermodynamic properties of a set of species - * (see \ref spthermo and class \link Cantera::SpeciesThermoFactory SpeciesThermoFactory\endlink); + * Definitions for factory functions to build instances of classes that + * manage the standard-state thermodynamic properties of a set of species + * (see \ref spthermo); */ // Copyright 2001 California Institute of Technology #include "cantera/thermo/SpeciesThermoFactory.h" - #include "cantera/thermo/SpeciesThermo.h" -#include "NasaThermo.h" -#include "ShomateThermo.h" -#include "cantera/thermo/SimpleThermo.h" #include "cantera/thermo/GeneralSpeciesThermo.h" #include "cantera/thermo/Mu0Poly.h" #include "cantera/thermo/Nasa9PolyMultiTempRegion.h" #include "cantera/thermo/Nasa9Poly1.h" #include "cantera/thermo/StatMech.h" #include "cantera/thermo/NasaPoly2.h" +#include "cantera/thermo/ShomatePoly.h" #include "cantera/thermo/ConstCpPoly.h" #include "cantera/thermo/AdsorbateThermo.h" -#include "cantera/thermo/SpeciesThermoMgr.h" #include "cantera/thermo/speciesThermoTypes.h" #include "cantera/thermo/VPSSMgr.h" #include "cantera/thermo/VPStandardStateTP.h" - #include "cantera/base/ctml.h" +#include "cantera/base/stringUtils.h" using namespace std; namespace Cantera { -SpeciesThermoFactory* SpeciesThermoFactory::s_factory = 0; -mutex_t SpeciesThermoFactory::species_thermo_mutex; - -//! Examine the types of species thermo parameterizations, -//! and return a flag indicating the type of reference state thermo manager -//! that will be needed in order to evaluate them all. -/*! - * - * @param spDataNodeList This vector contains a list - * of species XML nodes that will be in the phase - * @param has_nasa Return int that indicates whether the phase has a NASA polynomial form for one of its species - * @param has_shomate Return int that indicates whether the phase has a SHOMATE polynomial form for one of its species - * @param has_simple Return int that indicates whether the phase has a SIMPLE polynomial form for one of its species - * @param has_other Return int that indicates whether the phase has a form for one of its species that is not one of the ones listed above. - * - * @todo Make sure that spDadta_node is species Data XML node by checking its name is speciesData - * @deprecated - */ -static void getSpeciesThermoTypes(std::vector & spDataNodeList, - int& has_nasa, int& has_shomate, int& has_simple, - int& has_other) -{ - for (size_t n = 0; n < spDataNodeList.size(); n++) { - XML_Node* spNode = spDataNodeList[n]; - if (spNode->hasChild("standardState")) { - string mname = spNode->child("standardState")["model"]; - if (mname == "water" || mname == "waterIAPWS") { - has_other = 1; - continue; - } - } - if (spNode->hasChild("thermo")) { - const XML_Node& th = spNode->child("thermo"); - if (th.hasChild("NASA")) { - has_nasa = 1; - } else if (th.hasChild("Shomate")) { - has_shomate = 1; - } else if (th.hasChild("MinEQ3")) { - has_shomate = 1; - } else if (th.hasChild("const_cp")) { - has_simple = 1; - } else if (th.hasChild("poly")) { - if (th.child("poly")["order"] == "1") { - has_simple = 1; - } else throw CanteraError("newSpeciesThermo", - "poly with order > 1 not yet supported"); - } else if (th.hasChild("Mu0")) { - has_other = 1; - } else if (th.hasChild("NASA9")) { - has_other = 1; - } else if (th.hasChild("NASA9MULTITEMP")) { - has_other = 1; - } else if (th.hasChild("adsorbate")) { - has_other = 1; - } else { - has_other = 1; - } - } else { - throw CanteraError("getSpeciesThermoTypes:", - spNode->attrib("name") + " is missing the thermo XML node"); - } - } -} - -SpeciesThermoFactory* SpeciesThermoFactory::factory() -{ - warn_deprecated("class SpeciesThermoFactory", - "To be removed after Cantera 2.2."); - ScopedLock lock(species_thermo_mutex); - if (!s_factory) { - s_factory = new SpeciesThermoFactory; - } - return s_factory; -} - -void SpeciesThermoFactory::deleteFactory() -{ - ScopedLock lock(species_thermo_mutex); - delete s_factory; - s_factory = 0; -} - -SpeciesThermo* SpeciesThermoFactory::newSpeciesThermo(std::vector & spDataNodeList) const -{ - warn_deprecated("SpeciesThermoFactory::newSpeciesThermo", - "To be removed after Cantera 2.2. Use class GeneralSpeciesThermo directly."); - int inasa = 0, ishomate = 0, isimple = 0, iother = 0; - try { - getSpeciesThermoTypes(spDataNodeList, inasa, ishomate, isimple, iother); - } catch (UnknownSpeciesThermoModel) { - iother = 1; - popError(); - } - if (iother) { - return new GeneralSpeciesThermo(); - } - return newSpeciesThermo(NASA*inasa - + SHOMATE*ishomate + SIMPLE*isimple); -} - -SpeciesThermo* SpeciesThermoFactory::newSpeciesThermo(int type) const -{ - warn_deprecated("SpeciesThermoFactory::newSpeciesThermo", - "To be removed after Cantera 2.2. Use class GeneralSpeciesThermo directly."); - switch (type) { - case NASA: - return new NasaThermo; - case SHOMATE: - return new ShomateThermo; - case SIMPLE: - return new SimpleThermo; - case NASA + SHOMATE: - return new SpeciesThermoDuo; - case NASA + SIMPLE: - return new SpeciesThermoDuo; - case SHOMATE + SIMPLE: - return new SpeciesThermoDuo; - default: - throw UnknownSpeciesThermo("SpeciesThermoFactory::newSpeciesThermo", - type); - return 0; - } -} - -SpeciesThermo* SpeciesThermoFactory::newSpeciesThermoManager(const std::string& stype) const -{ - warn_deprecated("SpeciesThermoFactory::newSpeciesThermo", - "To be removed after Cantera 2.2. Use class GeneralSpeciesThermo directly."); - std::string ltype = lowercase(stype); - if (ltype == "nasa") { - return new NasaThermo; - } else if (ltype == "shomate") { - return new ShomateThermo; - } else if (ltype == "simple" || ltype == "constant_cp") { - return new SimpleThermo; - } else if (ltype == "nasa_shomate_duo") { - return new SpeciesThermoDuo; - } else if (ltype == "nasa_simple_duo") { - return new SpeciesThermoDuo; - } else if (ltype == "shomate_simple_duo") { - return new SpeciesThermoDuo; - } else if (ltype == "general") { - return new GeneralSpeciesThermo(); - } else if (ltype == "") { - return (SpeciesThermo*) 0; - } else { - throw UnknownSpeciesThermo("SpeciesThermoFactory::newSpeciesThermoManager", - stype); - } - return (SpeciesThermo*) 0; -} SpeciesThermoInterpType* newSpeciesThermoInterpType(int type, double tlow, double thigh, double pref, const double* coeffs) @@ -561,37 +406,7 @@ static SpeciesThermoInterpType* newAdsorbateThermoFromXML(const XML_Node& f) coeffs[0] = static_cast(freqs.size()); coeffs[1] = getFloat(f, "binding_energy", "toSI"); copy(freqs.begin(), freqs.end(), coeffs.begin() + 2); - return new Adsorbate(0, tmin, tmax, pref, &coeffs[0]); -} - -void SpeciesThermoFactory::installThermoForSpecies -(size_t k, const XML_Node& speciesNode, ThermoPhase* th_ptr, - SpeciesThermo& spthermo, const XML_Node* phaseNode_ptr) const -{ - shared_ptr stit( - newSpeciesThermoInterpType(speciesNode.child("thermo"))); - stit->validate(speciesNode["name"]); - spthermo.install_STIT(k, stit); -} - -void SpeciesThermoFactory::installVPThermoForSpecies(size_t k, - const XML_Node& speciesNode, - VPStandardStateTP* vp_ptr, - VPSSMgr* vpssmgr_ptr, - SpeciesThermo* spthermo_ptr, - const XML_Node* phaseNode_ptr) const -{ - warn_deprecated("SpeciesThermoFactory::installVPThermoForSpecies", - "Call VPStandardStateTP::createInstallPDSS directly."); - // Call the VPStandardStateTP object to install the pressure dependent species - // standard state into the object. - // - // We don't need to pass spthermo_ptr down, because it's already installed - // into vp_ptr. - // - // We don't need to pass vpssmgr_ptr down, because it's already installed - // into vp_ptr. - vp_ptr->createInstallPDSS(k, speciesNode, phaseNode_ptr); + return new Adsorbate(tmin, tmax, pref, &coeffs[0]); } SpeciesThermoInterpType* newSpeciesThermoInterpType(const XML_Node& thermo) @@ -626,7 +441,7 @@ SpeciesThermoInterpType* newSpeciesThermoInterpType(const XML_Node& thermo) std::string model = lowercase(thermo["model"]); if (model == "mineraleq3") { if (thermoType != "mineq3") { - throw CanteraError("SpeciesThermoFactory::installThermoForSpecies", + throw CanteraError("newSpeciesThermoInterpType", "confused: expected MinEQ3"); } return newShomateForMineralEQ3(*tp[0]); @@ -655,36 +470,4 @@ SpeciesThermoInterpType* newSpeciesThermoInterpType(const XML_Node& thermo) } } -SpeciesThermo* newSpeciesThermoMgr(int type, SpeciesThermoFactory* f) -{ - warn_deprecated("newSpeciesThermoMgr", "To be removed after Cantera 2.2. " - "Use class GeneralSpeciesThermo directly."); - if (f == 0) { - f = SpeciesThermoFactory::factory(); - } - return f->newSpeciesThermo(type); -} - -SpeciesThermo* newSpeciesThermoMgr(const std::string& stype, - SpeciesThermoFactory* f) -{ - warn_deprecated("newSpeciesThermoMgr", "To be removed after Cantera 2.2. " - "Use class GeneralSpeciesThermo directly."); - if (f == 0) { - f = SpeciesThermoFactory::factory(); - } - return f->newSpeciesThermoManager(stype); -} - -SpeciesThermo* newSpeciesThermoMgr(std::vector spData_nodes, - SpeciesThermoFactory* f) -{ - warn_deprecated("newSpeciesThermoMgr", "To be removed after Cantera 2.2. " - "Use class GeneralSpeciesThermo directly."); - if (f == 0) { - f = SpeciesThermoFactory::factory(); - } - return f->newSpeciesThermo(spData_nodes); -} - } diff --git a/src/thermo/SpeciesThermoInterpType.cpp b/src/thermo/SpeciesThermoInterpType.cpp index a7d535979..a630f5f53 100644 --- a/src/thermo/SpeciesThermoInterpType.cpp +++ b/src/thermo/SpeciesThermoInterpType.cpp @@ -14,40 +14,23 @@ namespace Cantera SpeciesThermoInterpType::SpeciesThermoInterpType() : m_lowT(0.0), m_highT(0.0), - m_Pref(0.0), - m_index(0) + m_Pref(0.0) { } -SpeciesThermoInterpType::SpeciesThermoInterpType(size_t n, doublereal tlow, - doublereal thigh, - doublereal pref) : - m_lowT(tlow), - m_highT(thigh), - m_Pref(pref), - m_index(n) -{ - warn_deprecated("Constructor SpeciesThermoInterpType(size_t n, ...)", - "Use the constructor which does not take a species index." - " Applies to all classes derived from SpeciesThermoInterpType." - " To be removed after Cantera 2.2."); -} - SpeciesThermoInterpType::SpeciesThermoInterpType(double tlow, double thigh, double pref) : m_lowT(tlow), m_highT(thigh), - m_Pref(pref), - m_index(0) + m_Pref(pref) { } SpeciesThermoInterpType::SpeciesThermoInterpType(const SpeciesThermoInterpType &b) : m_lowT(b.m_lowT), m_highT(b.m_highT), - m_Pref(b.m_Pref), - m_index(b.m_index) + m_Pref(b.m_Pref) { } @@ -75,15 +58,6 @@ void SpeciesThermoInterpType::modifyOneHf298(const size_t k, STITbyPDSS::STITbyPDSS() { - m_index = npos; -} - -STITbyPDSS::STITbyPDSS(size_t k, VPSSMgr* vpssmgr_ptr, PDSS* PDSS_ptr) : - SpeciesThermoInterpType(), - m_vpssmgr_ptr(vpssmgr_ptr), - m_PDSS_ptr(PDSS_ptr) -{ - m_index = k; } STITbyPDSS::STITbyPDSS(VPSSMgr* vpssmgr_ptr, PDSS* PDSS_ptr) : @@ -109,8 +83,6 @@ STITbyPDSS::duplMyselfAsSpeciesThermoInterpType() const void STITbyPDSS::initAllPtrs(size_t speciesIndex, VPSSMgr* vpssmgr_ptr, PDSS* PDSS_ptr) { - AssertThrow(speciesIndex == m_index, - "STITbyPDSS::initAllPtrs internal confusion"); m_vpssmgr_ptr = vpssmgr_ptr; m_PDSS_ptr = PDSS_ptr; } @@ -149,11 +121,9 @@ void STITbyPDSS::updatePropertiesTemp(const doublereal temp, doublereal* s_R) const { m_PDSS_ptr->setTemperature(temp); - AssertThrowMsg(m_index != npos, "STITbyPDSS::updatePropertiesTemp", - "object was probably not installed correctly"); - h_RT[m_index] = m_PDSS_ptr->enthalpy_RT_ref(); - cp_R[m_index] = m_PDSS_ptr->cp_R_ref(); - s_R[m_index] = m_PDSS_ptr->entropy_R_ref(); + *h_RT = m_PDSS_ptr->enthalpy_RT_ref(); + *cp_R = m_PDSS_ptr->cp_R_ref(); + *s_R = m_PDSS_ptr->entropy_R_ref(); } void STITbyPDSS::reportParameters(size_t& index, int& type, @@ -161,10 +131,10 @@ void STITbyPDSS::reportParameters(size_t& index, int& type, doublereal& refPressure, doublereal* const coeffs) const { - index = m_index; + index = 0; type = PDSS_TYPE; - minTemp = m_vpssmgr_ptr->minTemp(m_index); - maxTemp = m_vpssmgr_ptr->maxTemp(m_index); + minTemp = m_vpssmgr_ptr->minTemp(); + maxTemp = m_vpssmgr_ptr->maxTemp(); refPressure = m_PDSS_ptr->refPressure(); } diff --git a/src/thermo/StatMech.cpp b/src/thermo/StatMech.cpp index 7a56f3e2a..59291d314 100644 --- a/src/thermo/StatMech.cpp +++ b/src/thermo/StatMech.cpp @@ -6,6 +6,7 @@ // Copyright 2007 Sandia National Laboratories #include "cantera/thermo/StatMech.h" +#include "cantera/base/ctexceptions.h" #include namespace Cantera @@ -18,7 +19,7 @@ StatMech::StatMech(int n, doublereal tlow, doublereal thigh, doublereal pref, const doublereal* coeffs, const std::string& my_name) : - SpeciesThermoInterpType(n, tlow, thigh, pref), + SpeciesThermoInterpType(tlow, thigh, pref), sp_name(my_name) { // should error on zero -- cannot take ln(0) @@ -591,9 +592,9 @@ void StatMech::updateProperties(const doublereal* tt, // return the computed properties in the location in the output // arrays for this species - cp_R[m_index] = cpdivR; - h_RT[m_index] = hdivRT; - s_R [m_index] = sdivR; + *cp_R = cpdivR; + *h_RT = hdivRT; + *s_R = sdivR; } void StatMech::updatePropertiesTemp(const doublereal temp, @@ -612,7 +613,7 @@ void StatMech::reportParameters(size_t& n, int& type, { species* s; - n = m_index; + n = 0; type = STAT; tlow = m_lowT; thigh = m_highT; diff --git a/src/thermo/StoichSubstanceSSTP.cpp b/src/thermo/StoichSubstanceSSTP.cpp index a2e25aa3b..b8e8f44f1 100644 --- a/src/thermo/StoichSubstanceSSTP.cpp +++ b/src/thermo/StoichSubstanceSSTP.cpp @@ -255,83 +255,4 @@ void StoichSubstanceSSTP::setParametersFromXML(const XML_Node& eosdata) setDensity(getFloat(eosdata, "density", "toSI")); } -// ------ Methods of class electrodeElectron ------ - -electrodeElectron::electrodeElectron(): - StoichSubstanceSSTP() -{ - warn_deprecated("Class electrodeElectron", - "To be removed after Cantera 2.2."); -} - -electrodeElectron::electrodeElectron(const std::string& infile, std::string id_) : - StoichSubstanceSSTP() -{ - XML_Node* root = get_XML_File(infile); - if (id_ == "-") { - id_ = ""; - } - XML_Node* xphase = get_XML_NameID("phase", std::string("#")+id_, root); - if (!xphase) { - throw CanteraError("electrodeElectron::electrodeElectron", - "Couldn't find phase name in file:" + id_); - } - // Check the model name to ensure we have compatibility - if (xphase->child("thermo")["model"] != "electrodeElectron") { - throw CanteraError("electrodeElectron::electrodeElectron", - "thermo model attribute must be electrodeElectron"); - } - importPhase(*xphase, this); -} - -electrodeElectron::electrodeElectron(XML_Node& xmlphase, const std::string& id_) : - StoichSubstanceSSTP() -{ - if (id_ != "" && id_ != xmlphase["id"]) { - throw CanteraError("electrodeElectron::electrodeElectron", - "id's don't match"); - } - if (xmlphase.child("thermo")["model"] != "electrodeElectron") { - throw CanteraError("electrodeElectron::electrodeElectron", - "thermo model attribute must be electrodeElectron"); - } - importPhase(xmlphase, this); -} - -electrodeElectron::electrodeElectron(const electrodeElectron& right) : - StoichSubstanceSSTP() -{ - *this = right; -} - -electrodeElectron& -electrodeElectron::operator=(const electrodeElectron& right) -{ - if (&right != this) { - StoichSubstanceSSTP::operator=(right); - } - return *this; -} - -void electrodeElectron::setParametersFromXML(const XML_Node& eosdata) -{ - if (eosdata["model"] != "electrodeElectron") { - throw CanteraError("electrodeElectron::setParametersFromXML", - "thermo model attribute must be electrodeElectron"); - } -} - -void electrodeElectron::initThermoXML(XML_Node& phaseNode, const std::string& id_) -{ - doublereal rho = 10.0; - setDensity(rho); - SingleSpeciesTP::initThermoXML(phaseNode, id_); -} - -void electrodeElectron::setParameters(int n, doublereal* const c) -{ - doublereal rho = 10.0; - setDensity(rho); -} - } diff --git a/src/thermo/ThermoFactory.cpp b/src/thermo/ThermoFactory.cpp index 065f45386..f0526edc5 100644 --- a/src/thermo/ThermoFactory.cpp +++ b/src/thermo/ThermoFactory.cpp @@ -313,8 +313,7 @@ static void formSpeciesXMLNodeList(std::vector &spDataNodeList, } } -bool importPhase(XML_Node& phase, ThermoPhase* th, - SpeciesThermoFactory* spfactory) +void importPhase(XML_Node& phase, ThermoPhase* th) { // Check the the supplied XML node in fact represents a phase. if (phase.name() != "phase") { @@ -490,8 +489,6 @@ bool importPhase(XML_Node& phase, ThermoPhase* th, // that requires the XML phase object std::string id = ""; th->initThermoXML(phase, id); - - return true; } void installElements(Phase& th, const XML_Node& phaseNode) @@ -559,23 +556,6 @@ void installElements(Phase& th, const XML_Node& phaseNode) } } -bool installSpecies(size_t k, const XML_Node& s, thermo_t& th, - SpeciesThermo* spthermo_ptr, int rule, - XML_Node* phaseNode_ptr, - VPSSMgr* vpss_ptr, - SpeciesThermoFactory* factory) -{ - warn_deprecated("installSpecies", "Use newSpecies and addSpecies. For" - " VPStandardStateTP phases, call createInstallPDSS as well." - " To be removed after Cantera 2.2."); - th.addSpecies(newSpecies(s)); - VPStandardStateTP* vp_ptr = dynamic_cast(&th); - if (vp_ptr) { - vp_ptr->createInstallPDSS(k, s, phaseNode_ptr); - } - return true; -} - const XML_Node* speciesXML_Node(const std::string& kname, const XML_Node* phaseSpeciesData) { diff --git a/src/thermo/VPSSMgr_IdealGas.cpp b/src/thermo/VPSSMgr_IdealGas.cpp index 49fe4288c..ff08f0f16 100644 --- a/src/thermo/VPSSMgr_IdealGas.cpp +++ b/src/thermo/VPSSMgr_IdealGas.cpp @@ -15,8 +15,8 @@ #include "cantera/thermo/VPSSMgr_IdealGas.h" #include "cantera/base/ctml.h" #include "cantera/thermo/SpeciesThermoFactory.h" +#include "cantera/thermo/SpeciesThermo.h" #include "cantera/thermo/PDSS_IdealGas.h" -#include "cantera/thermo/SpeciesThermoInterpType.h" using namespace std; diff --git a/src/thermo/VPSSMgr_Water_HKFT.cpp b/src/thermo/VPSSMgr_Water_HKFT.cpp index ce1f112b0..03c60519a 100644 --- a/src/thermo/VPSSMgr_Water_HKFT.cpp +++ b/src/thermo/VPSSMgr_Water_HKFT.cpp @@ -20,6 +20,7 @@ #include "cantera/thermo/VPStandardStateTP.h" #include "cantera/thermo/GeneralSpeciesThermo.h" #include "cantera/base/xml.h" +#include "cantera/base/stringUtils.h" using namespace std; diff --git a/src/transport/DustyGasTransport.cpp b/src/transport/DustyGasTransport.cpp index fdde7a601..6f087eca0 100644 --- a/src/transport/DustyGasTransport.cpp +++ b/src/transport/DustyGasTransport.cpp @@ -96,30 +96,6 @@ void DustyGasTransport::setThermo(thermo_t& thermo) m_gastran->setThermo(thermo); } -void DustyGasTransport::setParameters(const int type, const int k, const doublereal* const p) -{ - warn_deprecated("DustyGasTransport::setParameters", "To be removed after Cantera 2.2"); - switch (type) { - case 0: - setPorosity(p[0]); - break; - case 1: - setTortuosity(p[0]); - break; - case 2: - setMeanPoreRadius(p[0]); - break; - case 3: - setMeanParticleDiameter(p[0]); - break; - case 4: - setPermeability(p[0]); - break; - default: - throw CanteraError("DustyGasTransport::init", "unknown parameter"); - } -} - void DustyGasTransport::initialize(ThermoPhase* phase, Transport* gastr) { diff --git a/src/transport/PecosTransport.cpp b/src/transport/PecosTransport.cpp deleted file mode 100755 index 3d45cb756..000000000 --- a/src/transport/PecosTransport.cpp +++ /dev/null @@ -1,547 +0,0 @@ -/** - * @file PecosTransport.cpp - * Mixture-averaged transport properties. - */ - -#include "cantera/transport/PecosTransport.h" -#include "cantera/transport/TransportParams.h" -#include "cantera/base/stringUtils.h" -#include "cantera/thermo/IdealGasPhase.h" - -#include - -using namespace std; - -namespace Cantera -{ - -PecosTransport::PecosTransport() : - m_nsp(0), - m_temp(-1.0), - m_logt(0.0) -{ - warn_deprecated("class PecosTransport", "To be removed after Cantera 2.2"); -} - -bool PecosTransport::initGas(GasTransportParams& tr) -{ - // constant substance attributes - m_thermo = tr.thermo; - m_nsp = static_cast(m_thermo->nSpecies()); - - // make a local copy of the molecular weights - m_mw.resize(m_nsp); - copy(m_thermo->molecularWeights().begin(), - m_thermo->molecularWeights().end(), m_mw.begin()); - - // copy polynomials and parameters into local storage - m_poly = tr.poly; - m_visccoeffs = tr.visccoeffs; - m_condcoeffs = tr.condcoeffs; - m_diffcoeffs = tr.diffcoeffs; - - m_zrot = tr.zrot; - m_crot = tr.crot; - m_epsilon = tr.epsilon; - m_mode = tr.mode_; - m_diam = tr.diam; - m_eps = tr.eps; - m_alpha = tr.alpha; - m_dipoleDiag.resize(m_nsp); - for (int i = 0; i < m_nsp; i++) { - m_dipoleDiag[i] = tr.dipole(i,i); - } - - m_phi.resize(m_nsp, m_nsp, 0.0); - m_wratjk.resize(m_nsp, m_nsp, 0.0); - m_wratkj1.resize(m_nsp, m_nsp, 0.0); - int j, k; - for (j = 0; j < m_nsp; j++) - for (k = j; k < m_nsp; k++) { - m_wratjk(j,k) = sqrt(m_mw[j]/m_mw[k]); - m_wratjk(k,j) = sqrt(m_wratjk(j,k)); - m_wratkj1(j,k) = sqrt(1.0 + m_mw[k]/m_mw[j]); - } - - m_polytempvec.resize(5); - m_visc.resize(m_nsp); - m_sqvisc.resize(m_nsp); - m_cond.resize(m_nsp); - m_bdiff.resize(m_nsp, m_nsp); - - m_molefracs.resize(m_nsp); - m_spwork.resize(m_nsp); - - // set flags all false - m_viscmix_ok = false; - m_viscwt_ok = false; - m_spvisc_ok = false; - m_spcond_ok = false; - m_condmix_ok = false; - m_spcond_ok = false; - m_diffmix_ok = false; - m_abc_ok = false; - - // read blottner fit parameters (A,B,C) - read_blottner_transport_table(); - - // set specific heats - cv_rot.resize(m_nsp); - cp_R.resize(m_nsp); - cv_int.resize(m_nsp); - - for (k = 0; k < m_nsp; k++) { - cv_rot[k] = tr.crot[k]; - cp_R[k] = ((IdealGasPhase*)tr.thermo)->cp_R_ref()[k]; - cv_int[k] = cp_R[k] - 2.5 - cv_rot[k]; - } - return true; -} - -doublereal PecosTransport::viscosity() -{ - update_T(); - update_C(); - - if (m_viscmix_ok) { - return m_viscmix; - } - - doublereal vismix = 0.0; - int k; - // update m_visc and m_phi if necessary - if (!m_viscwt_ok) { - updateViscosity_T(); - } - - multiply(m_phi, DATA_PTR(m_molefracs), DATA_PTR(m_spwork)); - - for (k = 0; k < m_nsp; k++) { - vismix += m_molefracs[k] * m_visc[k]/m_spwork[k]; //denom; - } - m_viscmix = vismix; - return vismix; -} - -void PecosTransport::getBinaryDiffCoeffs(const size_t ld, doublereal* const d) -{ - int i,j; - - update_T(); - - // if necessary, evaluate the binary diffusion coefficents - if (!m_bindiff_ok) { - updateDiff_T(); - } - - doublereal rp = 1.0/pressure_ig(); - for (i = 0; i < m_nsp; i++) - for (j = 0; j < m_nsp; j++) { - d[ld*j + i] = rp * m_bdiff(i,j); - } -} - -void PecosTransport::getMobilities(doublereal* const mobil) -{ - int k; - getMixDiffCoeffs(DATA_PTR(m_spwork)); - doublereal c1 = ElectronCharge / (Boltzmann * m_temp); - for (k = 0; k < m_nsp; k++) { - mobil[k] = c1 * m_spwork[k] * m_thermo->charge(k); - } -} - -doublereal PecosTransport::thermalConductivity() -{ - int k; - doublereal lambda = 0.0; - - update_T(); - update_C(); - - // update m_cond and m_phi if necessary - if (!m_spcond_ok) { - updateCond_T(); - } - if (!m_condmix_ok) { - - multiply(m_phi, DATA_PTR(m_molefracs), DATA_PTR(m_spwork)); - - for (k = 0; k < m_nsp; k++) { - lambda += m_molefracs[k] * m_cond[k]/m_spwork[k]; //denom; - } - - } - m_lambda = lambda; - return m_lambda; - -} - -void PecosTransport::getThermalDiffCoeffs(doublereal* const dt) -{ - int k; - for (k = 0; k < m_nsp; k++) { - dt[k] = 0.0; - } -} - -void PecosTransport::getSpeciesFluxes(size_t ndim, - const doublereal* const grad_T, - size_t ldx, const doublereal* const grad_X, - size_t ldf, doublereal* const fluxes) -{ - size_t n = 0; - int k; - - update_T(); - update_C(); - - getMixDiffCoeffs(DATA_PTR(m_spwork)); - - const vector_fp& mw = m_thermo->molecularWeights(); - const doublereal* y = m_thermo->massFractions(); - doublereal rhon = m_thermo->molarDensity(); - - vector_fp sum(ndim,0.0); - - doublereal correction=0.0; - // grab 2nd (summation) term -- still need to multiply by mass fraction (\rho_s / \rho) - for (k = 0; k < m_nsp; k++) { - correction += rhon * mw[k] * m_spwork[k] * grad_X[n*ldx + k]; - } - - for (n = 0; n < ndim; n++) { - for (k = 0; k < m_nsp; k++) { - fluxes[n*ldf + k] = -rhon * mw[k] * m_spwork[k] * grad_X[n*ldx + k] + y[k]*correction; - sum[n] += fluxes[n*ldf + k]; - } - } - // add correction flux to enforce sum to zero - for (n = 0; n < ndim; n++) { - for (k = 0; k < m_nsp; k++) { - fluxes[n*ldf + k] -= y[k]*sum[n]; - } - } -} - -void PecosTransport::getMixDiffCoeffs(doublereal* const d) -{ - update_T(); - update_C(); - - // update the binary diffusion coefficients if necessary - if (!m_bindiff_ok) { - updateDiff_T(); - } - - int k, j; - doublereal mmw = m_thermo->meanMolecularWeight(); - doublereal sumxw = 0.0, sum2; - doublereal p = pressure_ig(); - if (m_nsp == 1) { - d[0] = m_bdiff(0,0) / p; - } else { - for (k = 0; k < m_nsp; k++) { - sumxw += m_molefracs[k] * m_mw[k]; - } - for (k = 0; k < m_nsp; k++) { - sum2 = 0.0; - for (j = 0; j < m_nsp; j++) { - if (j != k) { - sum2 += m_molefracs[j] / m_bdiff(j,k); - } - } - if (sum2 <= 0.0) { - d[k] = m_bdiff(k,k) / p; - } else { - d[k] = (sumxw - m_molefracs[k] * m_mw[k])/(p * mmw * sum2); - } - } - } -} - -void PecosTransport::getMixDiffCoeffsMole(doublereal* const d) -{ - update_T(); - update_C(); - - // update the binary diffusion coefficients if necessary - if (!m_bindiff_ok) { - updateDiff_T(); - } - - doublereal p = m_thermo->pressure(); - if (m_nsp == 1) { - d[0] = m_bdiff(0,0) / p; - } else { - for (int k = 0; k < m_nsp; k++) { - double sum2 = 0.0; - for (int j = 0; j < m_nsp; j++) { - if (j != k) { - sum2 += m_molefracs[j] / m_bdiff(j,k); - } - } - if (sum2 <= 0.0) { - d[k] = m_bdiff(k,k) / p; - } else { - d[k] = (1 - m_molefracs[k]) / (p * sum2); - } - } - } -} - -void PecosTransport::getMixDiffCoeffsMass(doublereal* const d) -{ - update_T(); - update_C(); - - // update the binary diffusion coefficients if necessary - if (!m_bindiff_ok) { - updateDiff_T(); - } - - doublereal mmw = m_thermo->meanMolecularWeight(); - doublereal p = m_thermo->pressure(); - - if (m_nsp == 1) { - d[0] = m_bdiff(0,0) / p; - } else { - for (int k=0; ktemperature(); - if (t == m_temp) { - return; - } - if (t <= 0.0) { - throw CanteraError("PecosTransport::update_T", - "negative temperature "+fp2str(t)); - } - m_temp = t; - m_logt = log(m_temp); - m_kbt = Boltzmann * m_temp; - m_sqrt_t = sqrt(m_temp); - m_t14 = sqrt(m_sqrt_t); - m_t32 = m_temp * m_sqrt_t; - m_sqrt_kbt = sqrt(Boltzmann*m_temp); - - // compute powers of log(T) - m_polytempvec[0] = 1.0; - m_polytempvec[1] = m_logt; - m_polytempvec[2] = m_logt*m_logt; - m_polytempvec[3] = m_logt*m_logt*m_logt; - m_polytempvec[4] = m_logt*m_logt*m_logt*m_logt; - - // temperature has changed, so polynomial fits will need to be redone. - m_viscmix_ok = false; - m_spvisc_ok = false; - m_viscwt_ok = false; - m_spcond_ok = false; - m_diffmix_ok = false; - m_bindiff_ok = false; - m_abc_ok = false; - m_condmix_ok = false; -} - -void PecosTransport::update_C() -{ - // signal that concentration-dependent quantities will need to - // be recomputed before use, and update the local mole - // fractions. - - m_viscmix_ok = false; - m_diffmix_ok = false; - m_condmix_ok = false; - - m_thermo->getMoleFractions(DATA_PTR(m_molefracs)); - - // add an offset to avoid a pure species condition - int k; - for (k = 0; k < m_nsp; k++) { - m_molefracs[k] = std::max(Tiny, m_molefracs[k]); - } -} - -void PecosTransport::updateCond_T() -{ - int k; - doublereal fivehalves = 5/2; - for (k = 0; k < m_nsp; k++) { - // need to add cv_elec in the future - m_cond[k] = m_visc[k] * (fivehalves * cv_int[k] + cv_rot[k] + m_thermo->cv_vib(k,m_temp)); - } - m_spcond_ok = true; - m_condmix_ok = false; -} - -void PecosTransport::updateDiff_T() -{ - // evaluate binary diffusion coefficients at unit pressure - int i,j; - int ic = 0; - if (m_mode == CK_Mode) { - for (i = 0; i < m_nsp; i++) { - for (j = i; j < m_nsp; j++) { - m_bdiff(i,j) = exp(dot4(m_polytempvec, m_diffcoeffs[ic])); - m_bdiff(j,i) = m_bdiff(i,j); - ic++; - } - } - } else { - for (i = 0; i < m_nsp; i++) { - for (j = i; j < m_nsp; j++) { - m_bdiff(i,j) = m_temp * m_sqrt_t*dot5(m_polytempvec, - m_diffcoeffs[ic]); - m_bdiff(j,i) = m_bdiff(i,j); - ic++; - } - } - } - - m_bindiff_ok = true; - m_diffmix_ok = false; -} - -void PecosTransport::updateSpeciesViscosities() -{ - int k; - // iterate over species, update pure-species viscosity - for (k = 0; k < m_nsp; k++) { - m_visc[k] = 0.10*std::exp(a[k]*(m_logt*m_logt) + b[k]*m_logt + c[k]); - m_sqvisc[k] = sqrt(m_visc[k]); - } - - // time to update mixing - m_spvisc_ok = true; -} - -void PecosTransport::read_blottner_transport_table() -{ - // from: AIAA-1997-2474 and Sandia Report SC-RR-70-754 - // - // # Air -- Identical to N2 fit - // # N -- Sandia Report SC-RR-70-754 - // # N2 -- Sandia Report SC-RR-70-754 - // # CPN2 -- Identical to N2 fit - // # NO -- Sandia Report SC-RR-70-754 - // # O -- Sandia Report SC-RR-70-754 - // # O2 -- Sandia Report SC-RR-70-754 - // # C -- AIAA-1997-2474 - // # C2 -- AIAA-1997-2474 - // # C3 -- AIAA-1997-2474 - // # C2H -- wild-ass guess: identical to HCN fit - // # CN -- AIAA-1997-2474 - // # CO -- AIAA-1997-2474 - // # CO2 -- AIAA-1997-2474 - // # HCN -- AIAA-1997-2474 - // # H -- AIAA-1997-2474 - // # H2 -- AIAA-1997-2474 - // # e -- Sandia Report SC-RR-70-754 - - istringstream blot - ("Air 2.68142000000e-02 3.17783800000e-01 -1.13155513000e+01\n" - "CPAir 2.68142000000e-02 3.17783800000e-01 -1.13155513000e+01\n" - "N 1.15572000000e-02 6.03167900000e-01 -1.24327495000e+01\n" - "N2 2.68142000000e-02 3.17783800000e-01 -1.13155513000e+01\n" - "CPN2 2.68142000000e-02 3.17783800000e-01 -1.13155513000e+01\n" - "NO 4.36378000000e-02 -3.35511000000e-02 -9.57674300000e+00\n" - "O 2.03144000000e-02 4.29440400000e-01 -1.16031403000e+01\n" - "O2 4.49290000000e-02 -8.26158000000e-02 -9.20194750000e+00\n" - "C -8.3285e-3 0.7703240 -12.7378000\n" - "C2 -8.4311e-3 0.7876060 -13.0268000\n" - "C3 -8.4312e-3 0.7876090 -12.8240000\n" - "C2H -2.4241e-2 1.0946550 -14.5835500\n" - "CN -8.3811e-3 0.7860330 -12.9406000\n" - "CO -0.019527394 1.013295 -13.97873\n" - "CO2 -0.019527387 1.047818 -14.32212\n" - "HCN -2.4241e-2 1.0946550 -14.5835500\n" - "H -8.3912e-3 0.7743270 -13.6653000\n" - "H2 -8.3346e-3 0.7815380 -13.5351000\n" - "e 0.00000000000e+00 0.00000000000e+00 -1.16031403000e+01\n"); - - string line; - string name; - string ss1,ss2,ss3,ss4,sss; - int k; - int i = 0; - - while (std::getline(blot, line)) { - - istringstream ss(line); - std::getline(ss, ss1, ' '); - std::getline(ss, ss2, ' '); - std::getline(ss, ss3, ' '); - std::getline(ss, ss4, ' '); - name = ss1; - - // now put coefficients in correct species - for (k = 0; k < m_nsp; k++) { - string sss = m_thermo->speciesName(k); - - // this is the right species index - if (sss.compare(ss1) == 0) { - a[k] = fpValue(ss2); - b[k] = fpValue(ss3); - c[k] = fpValue(ss4); - - // index - i++; - } else { // default to air - - a[k] = 0.026; - b[k] = 0.3; - c[k] = -11.3; - } - - } // done with for loop - } -} - -void PecosTransport::updateViscosity_T() -{ - doublereal vratiokj, wratiojk, factor1; - - if (!m_spvisc_ok) { - updateSpeciesViscosities(); - } - - // see Eq. (9-5.15) of Reid, Prausnitz, and Poling - int j, k; - for (j = 0; j < m_nsp; j++) { - for (k = j; k < m_nsp; k++) { - vratiokj = m_visc[k]/m_visc[j]; - wratiojk = m_mw[j]/m_mw[k]; - - // Note that m_wratjk(k,j) holds the square root of - // m_wratjk(j,k)! - factor1 = 1.0 + (m_sqvisc[k]/m_sqvisc[j]) * m_wratjk(k,j); - m_phi(k,j) = factor1*factor1 / - (sqrt(8.0) * m_wratkj1(j,k)); - m_phi(j,k) = m_phi(k,j)/(vratiokj * wratiojk); - } - } - m_viscwt_ok = true; -} - -} diff --git a/src/transport/TransportFactory.cpp b/src/transport/TransportFactory.cpp index 17c80bfa6..0d4ebaec3 100644 --- a/src/transport/TransportFactory.cpp +++ b/src/transport/TransportFactory.cpp @@ -6,7 +6,6 @@ // known transport models #include "cantera/transport/MultiTransport.h" -#include "cantera/transport/PecosTransport.h" #include "cantera/transport/MixTransport.h" #include "cantera/transport/SolidTransport.h" #include "cantera/transport/DustyGasTransport.h" @@ -59,7 +58,6 @@ TransportFactory::TransportFactory() m_models["Simple"] = cSimpleTransport; m_models["User"] = cUserTransport; m_models["HighP"] = cHighP; - m_models["Pecos"] = cPecosTransport; m_models["None"] = None; for (map::iterator iter = m_models.begin(); iter != m_models.end(); @@ -277,15 +275,6 @@ Transport* TransportFactory::newTransport(thermo_t* phase, int log_level) return newTransport(transportModel, phase,log_level); } -void TransportFactory::initTransport(Transport* tr, thermo_t* thermo, - int mode, int log_level) -{ - warn_deprecated("TransportFactory::initTransport", - "To be removed after Cantera 2.2. This initialization is " - "now handled directly by GasTransport::init"); - tr->init(thermo); -} - void TransportFactory::setupLiquidTransport(thermo_t* thermo, int log_level, LiquidTransportParams& trParam) { diff --git a/src/transport/TransportParams.cpp b/src/transport/TransportParams.cpp index 11362886b..7b42e10fd 100644 --- a/src/transport/TransportParams.cpp +++ b/src/transport/TransportParams.cpp @@ -24,31 +24,4 @@ TransportParams::TransportParams() : { } -GasTransportParams::GasTransportParams() : - TransportParams(), - visccoeffs(0), - condcoeffs(0), - diffcoeffs(0), - poly(0), - omega22_poly(0), - astar_poly(0), - bstar_poly(0), - cstar_poly(0), - zrot(0), - crot(0), - polar(0), - alpha(0), - fitlist(0), - eps(0), - sigma(0), - reducedMass(0, 0), - diam(0, 0), - epsilon(0, 0), - dipole(0, 0), - delta(0, 0) -{ - warn_deprecated("class GasTransportParams", - "To be removed after Cantera 2.2."); -} - } // End of namespace Cantera diff --git a/src/zeroD/ReactorNet.cpp b/src/zeroD/ReactorNet.cpp index aef2b28a8..7562f047b 100644 --- a/src/zeroD/ReactorNet.cpp +++ b/src/zeroD/ReactorNet.cpp @@ -138,25 +138,6 @@ double ReactorNet::step(doublereal time) return m_time; } -void ReactorNet::addReactor(Reactor* r, bool iown) -{ - warn_deprecated("ReactorNet::addReactor(Reactor*)", - "To be removed after Cantera 2.2. Use 'addReactor(Reactor&) instead'."); - if (iown) { - warn_deprecated("ReactorNet::addReactor", - "Ownership of Reactors by ReactorNet is deprecated."); - } - r->setNetwork(this); - if (r->type() >= ReactorType) { - m_reactors.push_back(r); - m_iown.push_back(iown); - writelog("Adding reactor "+r->name()+"\n", m_verbose); - } else { - writelog("Not adding reactor "+r->name()+ - ", since type = "+int2str(r->type())+"\n", m_verbose); - } -} - void ReactorNet::addReactor(Reactor& r) { r.setNetwork(this); diff --git a/test/thermo/MaskellSolidSolnPhase_Test.cpp b/test/thermo/MaskellSolidSolnPhase_Test.cpp index f170c23d4..5110c81f9 100644 --- a/test/thermo/MaskellSolidSolnPhase_Test.cpp +++ b/test/thermo/MaskellSolidSolnPhase_Test.cpp @@ -1,6 +1,5 @@ #include "gtest/gtest.h" #include "cantera/thermo/MaskellSolidSolnPhase.h" -#include "cantera/thermo/SimpleThermo.h" #include "cantera/thermo/VPSSMgr_General.h" #include "cantera/thermo/ThermoFactory.h" #include diff --git a/test/thermo/nasapoly.cpp b/test/thermo/nasapoly.cpp index c7f3ad07f..c226b09c6 100644 --- a/test/thermo/nasapoly.cpp +++ b/test/thermo/nasapoly.cpp @@ -36,7 +36,6 @@ protected: EXPECT_EQ(poly.minTemp(), q.minTemp()); EXPECT_EQ(poly.maxTemp(), q.maxTemp()); EXPECT_EQ(poly.refPressure(), q.refPressure()); - EXPECT_EQ(poly.speciesIndex(), q.speciesIndex()); double cp_R1, h_RT1, s_R1; double cp_R2, h_RT2, s_R2; @@ -57,7 +56,6 @@ TEST_F(NasaPoly1Test, Initialization) EXPECT_EQ(poly.minTemp(), 200.0); EXPECT_EQ(poly.maxTemp(), 1000.0); EXPECT_EQ(poly.refPressure(), 101325.0); - EXPECT_EQ(poly.speciesIndex(), (size_t) 0); } TEST_F(NasaPoly1Test, Copy) diff --git a/test/thermo/thermoParameterizations.cpp b/test/thermo/thermoParameterizations.cpp index 734d5acd1..a316290db 100644 --- a/test/thermo/thermoParameterizations.cpp +++ b/test/thermo/thermoParameterizations.cpp @@ -1,11 +1,11 @@ #include "gtest/gtest.h" #include "cantera/thermo/speciesThermoTypes.h" -#include "cantera/thermo/SimpleThermo.h" #include "cantera/thermo/IdealGasPhase.h" #include "cantera/thermo/ConstCpPoly.h" #include "cantera/thermo/GeneralSpeciesThermo.h" #include "cantera/thermo/NasaPoly2.h" #include "cantera/thermo/ShomatePoly.h" +#include "cantera/base/stringUtils.h" #include "thermo_data.h" using namespace Cantera; diff --git a/test_problems/PecosTransport/PecosTransport.cpp b/test_problems/PecosTransport/PecosTransport.cpp deleted file mode 100644 index ab60a6b45..000000000 --- a/test_problems/PecosTransport/PecosTransport.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/** - * @file mixGasTransport.cpp - * test problem for mixture transport - */ - -// Example -// -// Test case for mixture transport in a gas -// The basic idea is to set up a gradient of some kind. -// Then the resulting transport coefficients out. -// Essentially all of the interface routines should be -// exercised and the results dumped out. -// -// A blessed solution test will make sure that the actual -// solution doesn't change as a function of time or -// further development. - -// perhaps, later, an analytical solution could be added - -#include "cantera/transport.h" -#include "cantera/IdealGasMix.h" -#include "cantera/transport/TransportFactory.h" - -#include - -using namespace std; -using namespace Cantera; - -void printDbl(double val) -{ - if (fabs(val) < 5.0E-17) { - cout << " nil"; - } else { - cout << val; - } -} - -int main(int argc, char** argv) -{ - size_t k; - string infile = "diamond.xml"; - - try { - - - IdealGasMix g("gri30.xml", "gri30_mix"); - size_t nsp = g.nSpecies(); - double pres = 1.0E5; - vector_fp Xset(nsp, 0.0); - Xset[0] = 0.269205 ; - Xset[1] = 0.000107082; - Xset[2] = 1.36377e-09 ; - Xset[3] = 4.35475e-10; - Xset[4] = 4.34036e-06 ; - Xset[5] = 0.192249; - Xset[6] = 3.59356e-13; - Xset[7] = 2.78061e-12 ; - Xset[8] = 4.7406e-18 ; - Xset[9] = 4.12955e-17 ; - Xset[10] = 2.58549e-14 ; - Xset[11] = 8.96502e-16 ; - Xset[12] = 6.09056e-11 ; - Xset[13] = 7.56752e-09 ; - Xset[14] = 0.192253; - Xset[15] = 0.0385036; - Xset[16] = 1.49596e-08 ; - Xset[17] = 2.22378e-08 ; - Xset[18] = 1.43096e-13 ; - Xset[19] = 1.45312e-15 ; - Xset[20] = 1.96948e-12 ; - Xset[21] = 8.41937e-19; - Xset[22] = 3.18852e-13 ; - Xset[23] = 7.93625e-18 ; - Xset[24] = 3.20653e-15 ; - Xset[25] = 1.15149e-19 ; - Xset[26] = 1.61189e-18 ; - Xset[27] = 1.4719e-15 ; - Xset[28] = 5.24728e-13 ; - Xset[29] = 6.90582e-17 ; - Xset[30] = 6.37248e-12 ; - Xset[31] =5.93728e-11 ; - Xset[32] = 2.71219e-09 ; - Xset[33] = 2.66645e-06 ; - Xset[34] = 6.57142e-11 ; - Xset[35] = 9.52453e-08 ; - Xset[36] = 1.26006e-14; - Xset[37] = 3.49802e-12; - Xset[38] = 1.19232e-11 ; - Xset[39] = 7.17782e-13 ; - Xset[40] = 1.85347e-07 ; - Xset[41] = 8.25325e-14 ; - Xset[42] = 5.00914e-20 ; - Xset[43] = 1.54407e-16 ; - Xset[44] =3.07176e-11 ; - Xset[45] =4.93198e-08 ; - Xset[46] =4.84792e-12 ; - Xset[47] = 0.307675 ; - Xset[48] =0; - Xset[49] =6.21649e-29; - Xset[50] = 8.42393e-28 ; - Xset[51] = 6.77865e-18; - Xset[52] = 2.19225e-16; - double T1 = 1500.; - - double sum = 0.0; - for (k = 0; k < nsp; k++) { - sum += Xset[k]; - } - for (k = 0; k < nsp; k++) { - Xset[k] /= sum; - } - - vector_fp X2set(nsp, 0.0); - X2set[0] = 0.25 ; - X2set[5] = 0.17; - X2set[14] = 0.15; - X2set[15] = 0.05; - X2set[47] = 0.38 ; - double T2 = 1200.; - - double dist = 0.1; - - vector_fp X3set(nsp, 0.0); - X3set[0] = 0.27 ; - X3set[5] = 0.15; - X3set[14] = 0.18; - X3set[15] = 0.06; - X3set[47] = 0.36 ; - double T3 = 1400.; - - vector_fp grad_T(3, 0.0); - - Array2D grad_X(nsp, 2, 0.0); - - - for (k = 0; k < nsp; k++) { - grad_X(k,0) = (X2set[k] - Xset[k])/dist; - grad_X(k,1) = (X3set[k] - Xset[k])/dist; - } - - grad_T[0] = (T2 - T1) / dist; - grad_T[1] = (T3 - T1) / dist; - - int log_level = 0; - Transport* tran = newTransportMgr("Pecos", &g, log_level=0); - PecosTransport* tranMix = dynamic_cast(tran); - - g.setState_TPX(1500.0, pres, DATA_PTR(Xset)); - - vector_fp mixDiffs(nsp, 0.0); - - tranMix->getMixDiffCoeffsMass(DATA_PTR(mixDiffs)); - printf(" Dump of the mixture Diffusivities:\n"); - for (k = 0; k < nsp; k++) { - string sss = g.speciesName(k); - printf(" %15s %13.5g\n", sss.c_str(), mixDiffs[k]); - } - - vector_fp specVisc(nsp, 0.0); - - tranMix->getSpeciesViscosities(DATA_PTR(specVisc)); - printf(" Dump of the species viscosities:\n"); - for (k = 0; k < nsp; k++) { - string sss = g.speciesName(k); - printf(" %15s %13.5g\n", sss.c_str(), specVisc[k]); - } - - vector_fp thermDiff(nsp, 0.0); - tranMix->getThermalDiffCoeffs(DATA_PTR(thermDiff)); - printf(" Dump of the Thermal Diffusivities :\n"); - for (k = 0; k < nsp; k++) { - string sss = g.speciesName(k); - printf(" %15s %13.5g\n", sss.c_str(), thermDiff[k]); - } - - printf("Viscoscity and thermal Cond vs. T\n"); - for (k = 0; k < 10; k++) { - T1 = 400. + 100. * k; - g.setState_TPX(T1, pres, DATA_PTR(Xset)); - double visc = tran->viscosity(); - double cond = tran->thermalConductivity(); - printf(" %13g %13.5g %13.5g\n", T1, visc, cond); - } - - g.setState_TPX(T1, pres, DATA_PTR(Xset)); - - Array2D Bdiff(nsp, nsp, 0.0); - printf("Binary Diffusion Coefficients H2 vs species\n"); - - tranMix->getBinaryDiffCoeffs(nsp, Bdiff.ptrColumn(0)); - for (k = 0; k < nsp; k++) { - string sss = g.speciesName(k); - printf(" H2 - %15s %13.5g %13.5g\n", sss.c_str(), Bdiff(0,k), Bdiff(k,0)); - } - - - vector_fp specMob(nsp, 0.0); - - tranMix->getMobilities(DATA_PTR(specMob)); - printf(" Dump of the species mobilities:\n"); - for (k = 0; k < nsp; k++) { - string sss = g.speciesName(k); - printf(" %15s %13.5g\n", sss.c_str(), specMob[k]); - } - - Array2D fluxes(nsp, 2, 0.0); - - tranMix->getSpeciesFluxes(2, DATA_PTR(grad_T), nsp, - grad_X.ptrColumn(0), nsp, fluxes.ptrColumn(0)); - printf(" Dump of the species fluxes:\n"); - double sum1 = 0.0; - double sum2 = 0.0; - double max1 = 0.0; - double max2 = 0.0; - for (k = 0; k < nsp; k++) { - string sss = g.speciesName(k); - printf(" %15s %13.5g %13.5g\n", sss.c_str(), fluxes(k,0), fluxes(k,1)); - sum1 += fluxes(k,0); - if (fabs(fluxes(k,0)) > max1) { - max1 = fabs(fluxes(k,0)); - } - sum2 += fluxes(k,1); - if (fabs(fluxes(k,1)) > max2) { - max2 = fabs(fluxes(k,0)); - } - } - - // Make sure roundoff error doesn't interfere with the printout. - // these should be zero. - if (fabs(sum1) * 1.0E14 > max1) { - printf("sum in x direction = %13.5g\n", sum1); - } else { - printf("sum in x direction = 0\n"); - } - if (fabs(sum2) * 1.0E14 > max2) { - printf("sum in y direction = %13.5g\n", sum1); - } else { - printf("sum in y direction = 0\n"); - } - - std::cout << "Sum of Diffusive Mass Fluxes: " << sum1 << std::endl; - std::cout << "Sum of Diffusive Mass Fluxes: " << sum2 << std::endl; - - - - } catch (CanteraError) { - showErrors(cout); - } - - return 0; -} -/***********************************************************/ diff --git a/test_problems/PecosTransport/output_blessed.txt b/test_problems/PecosTransport/output_blessed.txt deleted file mode 100644 index 4a360bb6a..000000000 --- a/test_problems/PecosTransport/output_blessed.txt +++ /dev/null @@ -1,176 +0,0 @@ - Dump of the mixture Diffusivities: - H2 0.001204 - H 0.0022584 - O 0.00064032 - O2 0.00042264 - OH 0.00062946 - H2O 0.00051533 - HO2 0.00042019 - H2O2 0.00041763 - C 0.00059188 - CH 0.00068026 - CH2 0.0004608 - CH2(S) 0.0004608 - CH3 0.00045156 - CH4 0.00044985 - CO 0.0004216 - CO2 0.00034577 - HCO 0.00036192 - CH2O 0.00035926 - CH2OH 0.00035027 - CH3O 0.00035027 - CH3OH 0.00035149 - C2H 0.0003524 - C2H2 0.00034919 - C2H3 0.00034618 - C2H4 0.00034633 - C2H5 0.00031771 - C2H6 0.00031538 - HCCO 0.00053082 - CH2CO 0.00030634 - HCCOH 0.00030634 - N 0.00056491 - NH 0.00067404 - NH2 0.00066041 - NH3 0.00050222 - NNH 0.00040495 - NO 0.00041226 - NO2 0.00037026 - N2O 0.00033509 - HNO 0.00041903 - CN 0.00040648 - HCN 0.00035852 - H2CN 0.00035559 - HCNN 0.00053081 - HCNO 0.00033642 - HOCN 0.00033642 - HNCO 0.00033642 - NCO 0.00033783 - N2 0.00043046 - AR 0.00041248 - C3H7 0.00024676 - C3H8 0.00024577 - CH2CHO 0.00030507 - CH3CHO 0.00030384 - Dump of the species viscosities: - H2 4.4588e-05 - H 4.4588e-05 - O 4.4588e-05 - O2 4.4588e-05 - OH 4.4588e-05 - H2O 4.4588e-05 - HO2 4.4588e-05 - H2O2 4.4588e-05 - C 4.4588e-05 - CH 4.4588e-05 - CH2 4.4588e-05 - CH2(S) 4.4588e-05 - CH3 4.4588e-05 - CH4 4.4588e-05 - CO 4.4588e-05 - CO2 4.4588e-05 - HCO 4.4588e-05 - CH2O 4.4588e-05 - CH2OH 4.4588e-05 - CH3O 4.4588e-05 - CH3OH 4.4588e-05 - C2H 4.4588e-05 - C2H2 4.4588e-05 - C2H3 4.4588e-05 - C2H4 4.4588e-05 - C2H5 4.4588e-05 - C2H6 4.4588e-05 - HCCO 4.4588e-05 - CH2CO 4.4588e-05 - HCCOH 4.4588e-05 - N 4.4588e-05 - NH 4.4588e-05 - NH2 4.4588e-05 - NH3 4.4588e-05 - NNH 4.4588e-05 - NO 4.4588e-05 - NO2 4.4588e-05 - N2O 4.4588e-05 - HNO 4.4588e-05 - CN 4.4588e-05 - HCN 4.4588e-05 - H2CN 4.4588e-05 - HCNN 4.4588e-05 - HCNO 4.4588e-05 - HOCN 4.4588e-05 - HNCO 4.4588e-05 - NCO 4.4588e-05 - N2 4.4588e-05 - AR 4.4588e-05 - C3H7 4.4588e-05 - C3H8 4.4588e-05 - CH2CHO 4.4588e-05 - CH3CHO 4.4588e-05 - Dump of the Thermal Diffusivities : - H2 0 - H 0 - O 0 - O2 0 - OH 0 - H2O 0 - HO2 0 - H2O2 0 - C 0 - CH 0 - CH2 0 - CH2(S) 0 - CH3 0 - CH4 0 - CO 0 - CO2 0 - HCO 0 - CH2O 0 - CH2OH 0 - CH3O 0 - CH3OH 0 - C2H 0 - C2H2 0 - C2H3 0 - C2H4 0 - C2H5 0 - C2H6 0 - HCCO 0 - CH2CO 0 - HCCOH 0 - N 0 - NH 0 - NH2 0 - NH3 0 - NNH 0 - NO 0 - NO2 0 - N2O 0 - HNO 0 - CN 0 - HCN 0 - H2CN 0 - HCNN 0 - HCNO 0 - HOCN 0 - HNCO 0 - NCO 0 - N2 0 - AR 0 - C3H7 0 - C3H8 0 - CH2CHO 0 - CH3CHO 0 -Viscoscity and thermal Cond vs. T - - -************************************************ - Cantera Error! -************************************************ - - -Procedure: Error in IdealGasPhase.cpp -Error: cv_vib only supported for StatMech!. - - - - diff --git a/test_problems/PecosTransport/runtest b/test_problems/PecosTransport/runtest deleted file mode 100755 index ab7e3d312..000000000 --- a/test_problems/PecosTransport/runtest +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# -# - -temp_success="1" -/bin/rm -f output.txt outputa.txt -tname="PecosTransport" -################################################################# -# -################################################################# -CANTERA_DATA=${CANTERA_DATA:=../../data/inputs}; export CANTERA_DATA - -CANTERA_BIN=${CANTERA_BIN:=../../bin} -./PecosTransport > output.txt -retnStat=$? -if [ $retnStat != "0" ] -then - temp_success="0" - echo "$tname ($tname test) returned with bad status, $retnStat, check output" - exit 1 -fi - -../../bin/exp3to2.sh output.txt > outputa.txt -diff -w outputa.txt output_blessed.txt > diff_test.out -retnStat=$? -if [ $retnStat = "0" ] -then - echo "successful diff comparison on $tname test" - exit 0 -else - echo "unsuccessful diff comparison on $tname test" - echo "FAILED" > csvCode.txt - temp_success="0" - exit 1 -fi - diff --git a/test_problems/statmech_transport/output_blessed.txt b/test_problems/statmech_transport/output_blessed.txt deleted file mode 100644 index 012ea92e8..000000000 --- a/test_problems/statmech_transport/output_blessed.txt +++ /dev/null @@ -1 +0,0 @@ -here diff --git a/test_problems/statmech_transport/statmech_transport.cpp b/test_problems/statmech_transport/statmech_transport.cpp deleted file mode 100644 index 51ed0f69f..000000000 --- a/test_problems/statmech_transport/statmech_transport.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/** - * @file statmech - * test problem for statistical mechanics in cantera - */ - -// Example -// -// Test case for the statistical mechanics in cantera -// - -#include "cantera/transport.h" -#include "cantera/IdealGasMix.h" -#include "cantera/equil/equil.h" - -using namespace std; -using namespace Cantera; - -int main(int argc, char** argv) -{ - - try { - int k; - IdealGasMix g("test_stat_trans.xml", "example"); - int nsp = g.nSpecies(); - double pres = 1.0E5; - - vector_fp Xset(nsp, 0.0); - Xset[0] = 0.5 ; - Xset[1] = 0.5; - - g.setState_TPX(1500.0, pres, DATA_PTR(Xset)); - equilibrate(g, "TP", -1); - - // init pecos transport - int log_level = 0; - Transport* tran = newTransportMgr("Pecos", &g, log_level=0); - PecosTransport* tranMix = dynamic_cast(tran); - - cout << "here" << std::endl; - - - vector_fp cp_R(nsp, 0.0); - g.getCp_R(DATA_PTR(cp_R)); - - //for(int i=0;i= tol) { - double diff = cp_R[3]-sol; - std::cout << "Error for Species NO2!\n"; - std::cout << "Diff was: " << diff << "\n"; - return 1; - } - - } catch (CanteraError) { - showErrors(cout); - return 1; - } - - // Mark it zero! - return 0; - -} diff --git a/test_problems/statmech_transport/test_stat_trans.xml b/test_problems/statmech_transport/test_stat_trans.xml deleted file mode 100644 index 91673d957..000000000 --- a/test_problems/statmech_transport/test_stat_trans.xml +++ /dev/null @@ -1,100 +0,0 @@ - - - - - - - - - O H C N Na - - H O N NO2 - - 2.165 - - - - - - - - - - - H:1 - - - - - 2.165 - - atom - 80.000 - 2.750 - 0.000 - 0.000 - 0.000 - - - - - - O:1 - - - - - 2.165 - - atom - 80.000 - 2.750 - 0.000 - 0.000 - 0.000 - - - - - - N:1 - - - - - 2.165 - - atom - 80.000 - 2.750 - 0.000 - 0.000 - 0.000 - - - - - - O:2 N:1 - - - - - - - 2.165 - - - atom - 80.000 - 2.750 - 0.000 - 0.000 - 0.000 - - - - - - -