From 78a093b485d039abdc820075a3a8469bffe2109c Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Fri, 9 Mar 2012 22:56:11 +0000 Subject: [PATCH] Folded class Constituents into class Phase --- include/cantera/base/ctexceptions.h | 15 +- include/cantera/kinetics/RateCoeffMgr.h | 2 +- include/cantera/thermo/Constituents.h | 427 ----------------- include/cantera/thermo/DebyeHuckel.h | 6 - include/cantera/thermo/Elements.h | 3 +- include/cantera/thermo/HMWSoln.h | 6 - include/cantera/thermo/Phase.h | 292 +++++++++++- include/cantera/thermo/ThermoPhase.h | 2 +- include/cantera/thermo/VPSSMgr_types.h | 3 + src/base/ctexceptions.cpp | 5 +- src/equil/MultiPhaseEquil.cpp | 3 +- src/kinetics/AqueousKinetics.cpp | 1 + src/thermo/Constituents.cpp | 590 ------------------------ src/thermo/DebyeHuckel.cpp | 3 + src/thermo/Elements.cpp | 3 +- src/thermo/GibbsExcessVPSSTP.cpp | 3 + src/thermo/HMWSoln.cpp | 3 +- src/thermo/HMWSoln_input.cpp | 2 + src/thermo/IdealSolidSolnPhase.cpp | 3 + src/thermo/IdealSolnGasVPSS.cpp | 1 + src/thermo/IonsFromNeutralVPSSTP.cpp | 2 +- src/thermo/LatticePhase.cpp | 1 + src/thermo/MargulesVPSSTP.cpp | 2 + src/thermo/MixedSolventElectrolyte.cpp | 7 +- src/thermo/MixtureFugacityTP.cpp | 9 +- src/thermo/MolalityVPSSTP.cpp | 3 + src/thermo/MolarityIonicVPSSTP.cpp | 8 +- src/thermo/PDSS_HKFT.cpp | 1 + src/thermo/PDSS_IonsFromNeutral.cpp | 9 +- src/thermo/PDSS_Water.cpp | 1 + src/thermo/Phase.cpp | 351 ++++++++++++-- src/thermo/PhaseCombo_Interaction.cpp | 7 +- src/thermo/PseudoBinaryVPSSTP.cpp | 1 + src/thermo/PureFluidPhase.cpp | 1 - src/thermo/RedlichKisterVPSSTP.cpp | 7 +- src/thermo/SingleSpeciesTP.cpp | 1 + src/thermo/SurfPhase.cpp | 2 +- src/thermo/ThermoPhase.cpp | 2 + src/thermo/VPStandardStateTP.cpp | 1 + src/thermo/WaterProps.cpp | 1 + src/thermo/WaterSSTP.cpp | 7 +- src/transport/AqueousTransport.cpp | 2 + src/transport/DustyGasTransport.cpp | 1 + src/transport/LiquidTranInteraction.cpp | 8 +- src/transport/LiquidTransport.cpp | 2 +- src/transport/MixTransport.cpp | 1 + src/transport/MultiTransport.cpp | 1 + src/transport/SimpleTransport.cpp | 2 +- src/transport/TransportFactory.cpp | 1 + 49 files changed, 674 insertions(+), 1141 deletions(-) delete mode 100644 include/cantera/thermo/Constituents.h delete mode 100644 src/thermo/Constituents.cpp diff --git a/include/cantera/base/ctexceptions.h b/include/cantera/base/ctexceptions.h index c58c34f21..6b95cc4bf 100644 --- a/include/cantera/base/ctexceptions.h +++ b/include/cantera/base/ctexceptions.h @@ -144,16 +144,16 @@ private: }; -//! An element index is out of range. +//! An array index is out of range. /*! * @ingroup errorhandling */ -class ElementRangeError : public CanteraError +class IndexError : public CanteraError { public: //! Constructor /*! - * This class indicates an out-of-bounds index. + * This class indicates an out-of-bounds array index. * * @param func String name for the function within which the error was * generated. @@ -161,12 +161,15 @@ public: * @param mmax This is the maximum allowed value of the index. The * minimum allowed value is assumed to be 0. */ - ElementRangeError(std::string func, size_t m, size_t mmax) : - CanteraError(func), m_(m), mmax_(mmax) {} + IndexError(std::string func, std::string arrayName, size_t m, size_t mmax) : + CanteraError(func), arrayName_(arrayName), m_(m), mmax_(mmax) {} + + virtual ~IndexError() throw() {}; virtual std::string getMessage() const; - virtual std::string getClass() const { return "ElementRangeError"; } + virtual std::string getClass() const { return "IndexError"; } private: + std::string arrayName_; size_t m_, mmax_; }; diff --git a/include/cantera/kinetics/RateCoeffMgr.h b/include/cantera/kinetics/RateCoeffMgr.h index 8044b7317..168597272 100644 --- a/include/cantera/kinetics/RateCoeffMgr.h +++ b/include/cantera/kinetics/RateCoeffMgr.h @@ -12,7 +12,7 @@ #include "cantera/base/ct_defs.h" #include "cantera/base/ctexceptions.h" - +#include "cantera/base/stringUtils.h" namespace Cantera { diff --git a/include/cantera/thermo/Constituents.h b/include/cantera/thermo/Constituents.h deleted file mode 100644 index 91c7c6521..000000000 --- a/include/cantera/thermo/Constituents.h +++ /dev/null @@ -1,427 +0,0 @@ -/** - * @file Constituents.h - * Header file Class \link Cantera::Constituents Constitutents\endlink which - * manages a set of elements and species (see \ref phases). - */ -// Copyright 2001 California Institute of Technology - - -#ifndef CT_CONSTIT_H -#define CT_CONSTIT_H - - -#include "cantera/base/ct_defs.h" - -#include "SpeciesThermo.h" -#include "cantera/base/ctexceptions.h" -#include "cantera/base/stringUtils.h" -#include "cantera/base/xml.h" -#include "Elements.h" - -namespace Cantera -{ - -class Elements; - -/************** DEFINITIONS OF ERRORS *****************************/ - -//! Specific fatal error indicating that the index of a species is out of range. -/*! - * - * @ingroup errorhandling - */ -class SpeciesRangeError : public CanteraError -{ -public: - //! Constructor - /*! - * @param func Function where the error occurred. - * @param k current species index value - * @param kmax Maximum permissible species index value. The - * minimum permissible species index value is assumed to be 0 - * - */ - SpeciesRangeError(std::string func, size_t k, size_t kmax) : - CanteraError(func, "Species index " + int2str(k) + - " outside valid range of 0 to " + int2str(kmax-1)) {} -}; - -/******************************************************************/ - - -//! Class %Constituents manages a set of elements and species. -/*! - * Class %Constituents is designed to provide information - * about the elements and species in a phase - names, index - * numbers (location in arrays), atomic or molecular weights, - * etc. No computations are performed by the methods of this - * class. The set of elements must include all those that compose - * the species, but may include additional elements. The species - * all must belong to the same phase. - * - * @ingroup phases - */ -class Constituents -{ - -public: - - //! Constructor. - /*! - * Constructor sets all base variable types to zero. Also, it - * sets the pointer to the Elements object for this object. - * - * @param ptr_Elements - * The default is that a new Elements object is created, so this - * Constituents object is independent of any other object. But if - * ptr_Elements is supplied, it will be used. This way, a class - * implementing a multi-phase mixture is responsible for - * maintaining the global elements list for the mixture, and no - * static global element list is required. - */ - Constituents(Elements* ptr_Elements = 0); - - /// Destructor. - ~Constituents(); - - /// This copy constructor just calls the assignment operator - /// for this class. - /*! - * @param right reference to the object to be copied. - */ - Constituents(const Constituents& right); - - /// Assignment operator - /*! - * @param right Reference to the object to be copied. - */ - Constituents& operator=(const Constituents& right); - - /// @name Element Information - // @{ - - /// Name of the element with index m. - /// This is a passthrough routine to the Element object. - /// \param m Element index. - /// \exception If m < 0 or m >= nElements(), the - /// exception, ElementRangeError, is thrown. - std::string elementName(size_t m) const; - - /// Index of element named 'name'. - /// The index is an integer - /// assigned to each element in the order it was added, - /// beginning with 0 for the first element. - /// @param name name of the element - /// - /// If 'name' is not - /// the name of an element in the set, then the value -1 is - /// returned. - size_t elementIndex(std::string name) const; - - - /// Atomic weight of element m. - /*! - * @param m Element index - */ - doublereal atomicWeight(size_t m) const; - - /// Entropy of the element in its standard state at 298 K and 1 bar - /*! - * @param m Element index - */ - doublereal entropyElement298(size_t m) const; - - /// Atomic number of element m. - /*! - * @param m Element index - */ - int atomicNumber(size_t m) const; - - int elementType(size_t m) const; - - /// Return a read-only reference to the vector of element names. - const std::vector& elementNames() const; - - /// Return a read-only reference to the vector of atomic weights. - const vector_fp& atomicWeights() const; - - /// Number of elements. - size_t nElements() const; - - // @} - - - - /// @name Adding Elements and Species - /// These methods are used to add new elements or species. - /// These are not usually called by user programs. - /// - /// Since species are checked to insure that they are only - /// composed of declared elements, it is necessary to first - /// add all elements before adding any species. - - //@{ - - //! Add an element. - /*! - * @param symbol Atomic symbol std::string. - * @param weight Atomic mass in amu. - */ - void addElement(const std::string& symbol, doublereal weight); - - //! Add an element from an XML specification. - /*! - * @param e Reference to the XML_Node where the element is described. - */ - 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. - */ - void addUniqueElement(const std::string& symbol, doublereal weight, - 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. - */ - void addUniqueElement(const XML_Node& e); - - //! Add all elements referenced in an XML_Node tree - /*! - * @param phase Reference to the top XML_Node of 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(); - - //! Add an element after the 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 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. - */ - size_t addUniqueElementAfterFreeze(const std::string& symbol, doublereal weight, int atomicNumber, - doublereal entropy298 = ENTROPY298_UNKNOWN, int elem_type = CT_ELEM_TYPE_ABSPOS); - - //@} - - /// Returns the number of species in the phase - size_t nSpecies() const { - return m_kk; - } - - //! Molecular weight of species \c k. - /*! - * @param k index of species \c k - * @return - * Returns the molecular weight of species \c k. - */ - doublereal molecularWeight(size_t k) const; - - //! Return the Molar mass of species \c k - /*! - * Preferred name for molecular weight. - * - * @param k index for species - * @return - * Return the molar mass of species k kg/kmol. - */ - doublereal molarMass(size_t k) const { - return molecularWeight(k); - } - - /** - * Return a const reference to the vector of molecular weights - * of the species - */ - const vector_fp& molecularWeights() const; - - /*! - * Electrical charge of one species k molecule, divided by - * the magnitude of the electron charge ( \f$ e = 1.602 - * \times 10^{-19}\f$ Coulombs). Dimensionless. - * - * @param k species index - */ - doublereal charge(size_t k) const; - - /** - * @name Adding Species - * These methods are used to add new species. - * They are not usually called by user programs. - */ - //@{ - 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 Double vector 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. - */ - void addUniqueSpecies(const std::string& name, const doublereal* comp, - doublereal charge = 0.0, - doublereal size = 1.0); - - //! Returns the index of a species named 'name' within the Constituents object - /*! - * The first species in the phase will have an index 0, and the last one in the - * phase will have an index of nSpecies() - 1. - * - * @param name String name of the species - * @return Returns the index of the species. If the name is not found, - * the value of -1 is returned. - */ - size_t speciesIndex(std::string name) const; - - //! Name of the species with index k - /*! - * @param k index of the species - */ - std::string speciesName(size_t k) const; - - /// Return a const reference to the vector of species names - const std::vector& speciesNames() const; - - //! This routine returns the size of species k - /*! - * @param k index of the species - * @return - * Returns the size of the species. Units are meters. - */ - doublereal size(size_t k) const { - return m_speciesSize[k]; - } - - /** - * Prohibit addition of more species, and prepare for - * calculations with this set of elements and species. - */ - void freezeSpecies(); - - /// True if freezeSpecies has been called. - bool speciesFrozen() { - return m_speciesFrozen; - } - - /// Remove all elements and species - void clear(); - - //@} - - /// True if both elements and species have been frozen - bool ready() const; - - //! Number of atoms of element \c m in species \c k. - /*! - * @param k species index - * @param m element index - */ - doublereal nAtoms(size_t k, size_t m) const; - - //! Get a vector containing the atomic composition of species k - /*! - * @param k species index - * @param atomArray vector containing the atomic number in the species. - * Length: m_mm - */ - void getAtoms(size_t k, double* atomArray) const; - -protected: - - //! Number of species in the phase. - size_t m_kk; - //! Vector of molecular weights of the species - /*! - * This vector has length m_kk. - * The units of the vector are kg kmol-1. - */ - vector_fp m_weight; - - //! Boolean indicating whether the number of species has been frozen. - /*! - * During the construction of the phase, this is false. After - * construction of the the phase, this is true. - */ - bool m_speciesFrozen; - - /*! - * Pointer to the element object corresponding to this - * phase. Normally, this will be the default Element object - * common to all phases. - */ - Elements* m_Elements; - - //! Vector of the species names - std::vector m_speciesNames; - - //! Atomic composition of the species. - /*! - * the number of atoms of i in species k is equal to - * m_speciesComp[k * m_mm + i] - * The length of this vector is equal to m_kk * m_mm - */ - vector_fp m_speciesComp; - - /** - * m_speciesCharge: Vector of species charges - * length = m_kk - */ - vector_fp m_speciesCharge; - - /** - * m_speciesSize(): Vector of species sizes. - * length m_kk - * This is used in some equations of state - * which employ the constant partial molar - * volume approximation. It's so fundamental - * we've put it at the Constituents class level - */ - vector_fp m_speciesSize; - -private: - -}; - - -} // namespace - -#endif diff --git a/include/cantera/thermo/DebyeHuckel.h b/include/cantera/thermo/DebyeHuckel.h index c852d159e..3804fd0a2 100644 --- a/include/cantera/thermo/DebyeHuckel.h +++ b/include/cantera/thermo/DebyeHuckel.h @@ -1549,12 +1549,6 @@ protected: */ vector_int m_electrolyteSpeciesType; - /** - * Species molar volumes \f$ m^3 kmol^-1 \f$ - * -> m_speciesSize in Constituents.h - */ - //vector_fp m_speciesMolarVolume; - /** * a_k = Size of the ionic species in the DH formulation * units = meters diff --git a/include/cantera/thermo/Elements.h b/include/cantera/thermo/Elements.h index 1bdb7c989..e9269e340 100644 --- a/include/cantera/thermo/Elements.h +++ b/include/cantera/thermo/Elements.h @@ -90,7 +90,6 @@ class ElementRangeError; //! Positive number indicating we don't know the gibbs free energy //! of the element in its most stable state at 298.15 K and 1 bar. -//#define GIBSSFE298_UNKNOWN 123456789. #define ENTROPY298_UNKNOWN -123456789. //! Object containing the elements that make up species in a phase. @@ -410,7 +409,7 @@ public: */ static std::vector Global_Elements_List; - friend class Constituents; + friend class Phase; }; } // namespace diff --git a/include/cantera/thermo/HMWSoln.h b/include/cantera/thermo/HMWSoln.h index e84a1b32d..98f5a8228 100644 --- a/include/cantera/thermo/HMWSoln.h +++ b/include/cantera/thermo/HMWSoln.h @@ -2436,12 +2436,6 @@ private: */ vector_int m_electrolyteSpeciesType; - /** - * Species molar volumes \f$ m^3 kmol^-1 \f$ - * -> m_speciesSize in Constituents.h - */ - //vector_fp m_speciesMolarVolume; - /** * a_k = Size of the ionic species in the DH formulation * units = meters diff --git a/include/cantera/thermo/Phase.h b/include/cantera/thermo/Phase.h index a7b1a4866..37cdd5d24 100644 --- a/include/cantera/thermo/Phase.h +++ b/include/cantera/thermo/Phase.h @@ -11,13 +11,13 @@ #ifndef CT_PHASE_H #define CT_PHASE_H -#include "Constituents.h" #include "cantera/base/vec_functions.h" - #include "cantera/base/ctml.h" +#include "Elements.h" namespace Cantera { +class SpeciesThermo; //! Base class for phases of matter /*! @@ -55,6 +55,14 @@ namespace Cantera * may be advantageous as well, and they need to overload these functions * too. * + * Class %Constituents is designed to provide information + * about the elements and species in a phase - names, index + * numbers (location in arrays), atomic or molecular weights, + * etc. No computations are performed by the methods of this + * class. The set of elements must include all those that compose + * the species, but may include additional elements. The species + * all must belong to the same phase. + * * @ingroup phases * * Class Phase derives from both classes @@ -111,7 +119,7 @@ namespace Cantera * * @ingroup phases */ -class Phase : public Constituents +class Phase { public: /// Default constructor. @@ -185,6 +193,75 @@ public: */ void setName(std::string nm); + /// @name Element Information + // @{ + + /// Name of the element with index m. + /// This is a passthrough routine to the Element object. + /// \param m Element index. + /// \exception If m < 0 or m >= nElements(), the + /// exception, ElementRangeError, is thrown. + std::string elementName(size_t m) const; + + /// Index of element named 'name'. + /// The index is an integer + /// assigned to each element in the order it was added, + /// beginning with 0 for the first element. + /// @param name name of the element + /// + /// If 'name' is not + /// the name of an element in the set, then the value -1 is + /// returned. + size_t elementIndex(std::string name) const; + + /// Return a read-only reference to the vector of element names. + const std::vector& elementNames() const; + + /// Atomic weight of element m. + /*! + * @param m Element index + */ + doublereal atomicWeight(size_t m) const; + + /// Entropy of the element in its standard state at 298 K and 1 bar + /*! + * @param m Element index + */ + doublereal entropyElement298(size_t m) const; + + /// Atomic number of element m. + /*! + * @param m Element index + */ + int atomicNumber(size_t m) const; + + int elementType(size_t m) const; + + + /// Return a read-only reference to the vector of atomic weights. + const vector_fp& atomicWeights() const; + + /// Number of elements. + size_t nElements() const; + + // @} + + + //! Number of atoms of element \c m in species \c k. + /*! + * @param k species index + * @param m element index + */ + doublereal nAtoms(size_t k, size_t m) const; + + //! Get a vector containing the atomic composition of species k + /*! + * @param k species index + * @param atomArray vector containing the atomic number in the species. + * Length: m_mm + */ + void getAtoms(size_t k, double* atomArray) const; + //! Returns the index of a species named 'name' within the Phase object /*! * The first species in the phase will have an index 0, and the last one in the @@ -208,6 +285,12 @@ public: */ size_t speciesIndex(std::string name) const; + //! Name of the species with index k + /*! + * @param k index of the species + */ + std::string speciesName(size_t k) const; + //! Returns the expanded species name of a species, including the phase name /*! * Returns the expanded phase name species name string. @@ -218,6 +301,14 @@ public: */ std::string speciesSPName(int k) const; + /// Return a const reference to the vector of species names + const std::vector& speciesNames() const; + + /// Returns the number of species in the phase + size_t nSpecies() const { + return m_kk; + } + //! Save the current internal state of the phase /*! * Write to vector 'state' the current internal state. @@ -370,6 +461,25 @@ public: */ void setState_RY(doublereal rho, doublereal* y); + //! Molecular weight of species \c k. + /*! + * @param k index of species \c k + * @return Returns the molecular weight of species \c k. + */ + doublereal molecularWeight(size_t k) const; + + //! Return the Molar mass of species \c k + /*! + * Alternate name for molecular weight. + * + * @param k index for species + * @return Return the molar mass of species k kg/kmol. + * @deprecated use molecularWeight instead + */ + doublereal molarMass(size_t k) const { + return molecularWeight(k); + } + /** * Copy the vector of molecular weights into vector weights. * @@ -396,9 +506,20 @@ public: /** * Return a const reference to the internal vector of molecular weights. + * units = kg / kmol */ const vector_fp& molecularWeights() const; + //! This routine returns the size of species k + /*! + * @param k index of the species + * @return + * Returns the size of the species. Units are meters. + */ + doublereal size(size_t k) const { + return m_speciesSize[k]; + } + /** * Get the mole fractions by name. * @@ -551,6 +672,14 @@ public: //@} + /*! + * Electrical charge of one species k molecule, divided by + * the magnitude of the electron charge ( \f$ e = 1.602 + * \times 10^{-19}\f$ Coulombs). Dimensionless. + * + * @param k species index + */ + doublereal charge(size_t k) const; /** * Charge density [C/m^3]. @@ -680,14 +809,131 @@ public: doublereal sum_xlogQ(doublereal* const Q) const; //@} + /// @name Adding Elements and Species + /// These methods are used to add new elements or species. + /// These are not usually called by user programs. + /// + /// Since species are checked to insure that they are only + /// composed of declared elements, it is necessary to first + /// add all elements before adding any species. + //@{ + + //! Add an element. + /*! + * @param symbol Atomic symbol std::string. + * @param weight Atomic mass in amu. + */ + void addElement(const std::string& symbol, doublereal weight); + + //! Add an element from an XML specification. + /*! + * @param e Reference to the XML_Node where the element is described. + */ + 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. + */ + void addUniqueElement(const std::string& symbol, doublereal weight, + 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. + */ + void addUniqueElement(const XML_Node& e); + + //! Add all elements referenced in an XML_Node tree + /*! + * @param phase Reference to the top XML_Node of 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(); + + //! Add an element after the 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 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. + */ + size_t addUniqueElementAfterFreeze(const std::string& symbol, doublereal weight, int atomicNumber, + doublereal entropy298 = ENTROPY298_UNKNOWN, int elem_type = CT_ELEM_TYPE_ABSPOS); + + //@} + + /** + * @name Adding Species + * These methods are used to add new species. + * They are not usually called by user programs. + */ + //@{ + 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 Double vector 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. + */ + void addUniqueSpecies(const std::string& name, const doublereal* comp, + doublereal charge = 0.0, + doublereal size = 1.0); + //@} + /** * Finished adding species, prepare to use them for calculation * of mixture properties. */ virtual void freezeSpecies(); + /// True if freezeSpecies has been called. + bool speciesFrozen() { + return m_speciesFrozen; + } + virtual bool ready() const; + /// Remove all elements and species + void clear(); + //! Return the State Mole Fraction Number DEPRECATED(int stateMFNumber() const) { return m_stateNum; @@ -740,6 +986,29 @@ protected: */ size_t m_ndim; + //! Atomic composition of the species. + /*! + * the number of atoms of i in species k is equal to + * m_speciesComp[k * m_mm + i] + * The length of this vector is equal to m_kk * m_mm + */ + vector_fp m_speciesComp; + + /** + * m_speciesSize(): Vector of species sizes. + * length m_kk + * This is used in some equations of state + * which employ the constant partial molar + * volume approximation. It's so fundamental + * we've put it at the Constituents class level + */ + vector_fp m_speciesSize; + + /** + * m_speciesCharge: Vector of species charges + * length = m_kk + */ + vector_fp m_speciesCharge; private: //! This stores the initial state of the system @@ -824,6 +1093,23 @@ private: * @deprecated */ int m_stateNum; + + //! Boolean indicating whether the number of species has been frozen. + /*! + * During the construction of the phase, this is false. After + * construction of the the phase, this is true. + */ + bool m_speciesFrozen; + + /*! + * Pointer to the element object corresponding to this + * phase. Normally, this will be the default Element object + * common to all phases. + */ + Elements* m_Elements; + + //! Vector of the species names + std::vector m_speciesNames; }; //! typedef for the base Phase class diff --git a/include/cantera/thermo/ThermoPhase.h b/include/cantera/thermo/ThermoPhase.h index e592e284d..65c7f7c48 100644 --- a/include/cantera/thermo/ThermoPhase.h +++ b/include/cantera/thermo/ThermoPhase.h @@ -12,7 +12,7 @@ #define CT_THERMOPHASE_H #include "Phase.h" - +#include "SpeciesThermo.h" namespace Cantera { diff --git a/include/cantera/thermo/VPSSMgr_types.h b/include/cantera/thermo/VPSSMgr_types.h index 66e341dd4..fffce7e05 100644 --- a/include/cantera/thermo/VPSSMgr_types.h +++ b/include/cantera/thermo/VPSSMgr_types.h @@ -13,6 +13,9 @@ * U.S. Government retains certain rights in this software. */ +//! @deprecated remove include when UnknownVPSSMgr is removed +#include "cantera/base/stringUtils.h" + #ifndef VPSSMGR_TYPES_H #define VPSSMGR_TYPES_H diff --git a/src/base/ctexceptions.cpp b/src/base/ctexceptions.cpp index 21659da05..0374cecab 100644 --- a/src/base/ctexceptions.cpp +++ b/src/base/ctexceptions.cpp @@ -58,9 +58,10 @@ std::string ArraySizeError::getMessage() const { return ss.str(); } -std::string ElementRangeError::getMessage() const { +std::string IndexError::getMessage() const { std::stringstream ss; - ss << "Element index " << m_ << " outside valid range of 0 to " << (mmax_-1) << "."; + ss << "IndexError: " << arrayName_ << "[" << m_ << "]" << + " outside valid range of 0 to " << (mmax_-1) << "."; return ss.str(); } diff --git a/src/equil/MultiPhaseEquil.cpp b/src/equil/MultiPhaseEquil.cpp index 684b6182b..84ca9ee10 100644 --- a/src/equil/MultiPhaseEquil.cpp +++ b/src/equil/MultiPhaseEquil.cpp @@ -7,11 +7,12 @@ #include "cantera/thermo/MolalityVPSSTP.h" #endif #include "cantera/base/global.h" +#include "cantera/base/stringUtils.h" #include #include -using namespace std; +using namespace std; namespace Cantera { diff --git a/src/kinetics/AqueousKinetics.cpp b/src/kinetics/AqueousKinetics.cpp index ee9ff1f5d..d772f6e4f 100644 --- a/src/kinetics/AqueousKinetics.cpp +++ b/src/kinetics/AqueousKinetics.cpp @@ -14,6 +14,7 @@ #include "cantera/kinetics/AqueousKinetics.h" #include "ReactionData.h" #include "cantera/kinetics/RateCoeffMgr.h" +#include "cantera/base/stringUtils.h" #include using namespace std; diff --git a/src/thermo/Constituents.cpp b/src/thermo/Constituents.cpp deleted file mode 100644 index 2ef323da9..000000000 --- a/src/thermo/Constituents.cpp +++ /dev/null @@ -1,590 +0,0 @@ -/** - * @file Constituents.cpp - * Header file Class \link Cantera::Constituents Constitutents\endlink which - * manages a set of elements and species (see \ref phases). - */ -// Copyright 2001 California Institute of Technology - -#include "cantera/thermo/Constituents.h" -#include "cantera/thermo/Elements.h" -using namespace std; - -namespace Cantera -{ - -/* - * Constructor sets all base variable types to zero. Also, it - * sets the pointer to the Elements object for this object to the - * default value of BaseElements. If the BaseElements Elements - * object doesn't exist, it creates it. - * - * Input - * -------- - * ptr_Elements: If the Constituents object requires a different - * Elements object than the default one, input - * address here. This argument defaults to null, - * in which case the default Elements Object is - * chosen. - */ - -/* - * DGG: I have reversed the role of ptr_Elements. In this version, - * the default is that a new Elements object is created, so this - * Constituents object is independent of any other object. But if - * ptr_Elements is supplied, it will be used. This way, a class - * implementing a multi-phase mixture is responsible for - * maintaining the global elements list for the mixture, and no - * static global element list is required. - */ -Constituents::Constituents(Elements* ptr_Elements) : - m_kk(0), - m_speciesFrozen(false) , - m_Elements(ptr_Elements) -{ - if (!m_Elements) { - m_Elements = new Elements(); - } - - // Register subscription to Elements object whether or not we - // created it here. - m_Elements->subscribe(); -} - -/** - * Destructor for class Constituents. - * - * Some cleanup of of the Global_Elements_List array is - * effected by unsubscribing to m_Elements. - */ -Constituents::~Constituents() -{ - int ileft = m_Elements->unsubscribe(); - /* - * Here we may delete Elements Objects or not. Right now, we - * will delete them. We also delete the global pointer entry - * to keep everything consistent. - */ - if (ileft <= 0) { - vector::iterator it; - for (it = Elements::Global_Elements_List.begin(); - it != Elements::Global_Elements_List.end(); ++it) { - if (*it == m_Elements) { - Elements::Global_Elements_List.erase(it); - break; - } - } - delete m_Elements; - } -} - -size_t Constituents::nElements() const -{ - return m_Elements->nElements(); -} - -/* - * Return the Atomic weight of element m. - * units = Kg / Kmol - */ -doublereal Constituents::atomicWeight(size_t m) const -{ - return m_Elements->atomicWeight(m); -} - -doublereal Constituents::entropyElement298(size_t m) const -{ - return m_Elements->entropyElement298(m); -} - -/* - * returns a reference to the vector of atomic weights pertinent - * to this constituents object - * units = kg / Kmol - */ -const vector_fp& Constituents::atomicWeights() const -{ - return m_Elements->atomicWeights(); -} - -/* - * Return the atomic number of element m. - */ -int Constituents::atomicNumber(size_t m) const -{ - return m_Elements->atomicNumber(m); -} - -int Constituents::elementType(size_t m) const -{ - return m_Elements->elementType(m); -} - -/* - * Add an element to the set. - * @param symbol symbol string - * @param weight atomic weight in kg/mol. - * - * If weight is not given, then a lookup is performed in the - * element object - * - */ -void Constituents:: -addElement(const std::string& symbol, doublereal weight) -{ - m_Elements->addElement(symbol, weight); -} - -void Constituents:: -addElement(const XML_Node& e) -{ - m_Elements->addElement(e); -} - -/* - * Add a unique element to the set. A check on the symbol is made - * If the symbol is already an element, then a new element is - * not created. - * - * @param symbol symbol string - * @param weight atomic weight in kg/mol. - * - * If weight is not given, then a lookup is performed in the - * element object - * - * -> Passthrough to the Element lvl. - */ -void Constituents:: -addUniqueElement(const std::string& symbol, doublereal weight, - int atomicNumber, doublereal entropy298, int elem_type) -{ - m_Elements->addUniqueElement(symbol, weight, atomicNumber, entropy298, elem_type); -} - -void Constituents:: -addUniqueElement(const XML_Node& e) -{ - m_Elements->addUniqueElement(e); -} - -void Constituents::addElementsFromXML(const XML_Node& phase) -{ - m_Elements->addElementsFromXML(phase); -} - -/* - * -> Passthrough to the Element lvl. - */ -void Constituents::freezeElements() -{ - m_Elements->freezeElements(); -} - -/* - * -> Passthrough to the Element lvl. - */ -bool Constituents::elementsFrozen() -{ - return m_Elements->elementsFrozen(); -} - -/* - * Index of element named \a name. The index is an integer - * assigned to each element in the order it was added, - * beginning with 0 for the first element. If \a name is not - * the name of an element in the set, then the value -1 is - * returned. - * - * - * -> Passthrough to the Element class. - */ -size_t Constituents::elementIndex(std::string name) const -{ - return (m_Elements->elementIndex(name)); -} - -/* - * Name of the element with index m. - * - * This is a passthrough routine to the Element object. - * @param m @{ Element index. @} - * \exception If m < 0 or m >= nElements(), the - * exception, ElementRangeError, is thrown. - */ -string Constituents::elementName(size_t m) const -{ - return (m_Elements->elementName(m)); -} - -/******************************************************************* - * - * elementNames(): - * - * Returns a read-only reference to the vector of element names. - * @code - * Constituents c; - * ... - * const vector& enames = c.elementNames(); - * int n = enames.size(); - * for (int i = 0; i < n; i++) cout << enames[i] << endl; - * @endcode - * - * - * -> Passthrough to the Element lvl. - */ -const vector& Constituents::elementNames() const -{ - return m_Elements->elementNames(); -} - -/* - * molecularWeight() - * - * Returns the molecular weight of a species given the species index - * - * units = kg / kmol. - */ -doublereal Constituents::molecularWeight(size_t k) const -{ - if (k >= nSpecies()) { - throw SpeciesRangeError("Constituents::molecularWeight", - k, nSpecies()); - } - return m_weight[k]; -} - -/* - * molecularWeights() - * - * Returns a const reference to the vector of molecular weights - * for all of the species defined in the object. - * - * units = kg / kmol. - */ -const vector_fp& Constituents::molecularWeights() const -{ - return m_weight; -} - -/* - * charge(): - * - * Electrical charge of one species k molecule, divided by - * \f$ e = 1.602 \times 10^{-19}\f$ Coulombs. - */ -doublereal Constituents::charge(size_t k) const -{ - return m_speciesCharge[k]; -} - -/* - * addSpecies() - * - * Add a species to a Constituents object. Note, no check is made - * as to whether the species has a unique name. - * - * Input - * --------- - * name = string containing the name - * comp[] - * charge = - * weight = weight of the species. Default = 0.0. - * Note, the weight is a bit redundent and potentially - * harmful. If weight is less than or equal to zero, - * the weight is calculated from the element composition - * and it need not be supplied on the command line. - */ -void Constituents:: -addSpecies(const std::string& name, const doublereal* comp, - doublereal charge, doublereal size) -{ - m_Elements->freezeElements(); - m_speciesNames.push_back(name); - m_speciesCharge.push_back(charge); - m_speciesSize.push_back(size); - size_t ne = m_Elements->nElements(); - // Create a changeable copy of the element composition. We now change the charge potentially - vector_fp compNew(ne); - for (size_t m = 0; m < ne; m++) { - compNew[m] = comp[m]; - } - double wt = 0.0; - const vector_fp& aw = m_Elements->atomicWeights(); - if (charge != 0.0) { - size_t eindex = m_Elements->elementIndex("E"); - if (eindex != npos) { - doublereal ecomp = compNew[eindex]; - if (fabs(charge + ecomp) > 0.001) { - if (ecomp != 0.0) { - throw CanteraError("Constituents::addSpecies", - "Input charge and element E compositions differ for species " + name); - } else { - // Just fix up the element E composition based on the input species charge - compNew[eindex] = -charge; - } - } - } else { - addUniqueElementAfterFreeze("E", 0.000545, 0, 0.0, CT_ELEM_TYPE_ELECTRONCHARGE); - ne = m_Elements->nElements(); - eindex = m_Elements->elementIndex("E"); - compNew.resize(ne); - compNew[ne - 1] = - charge; - //comp[eindex] = -charge; - // throw CanteraError("Constituents::addSpecies", - // "Element List doesn't include E, yet this species has charge:" + name); - } - } - for (size_t m = 0; m < ne; m++) { - m_speciesComp.push_back(compNew[m]); - wt += compNew[m] * aw[m]; - } - m_weight.push_back(wt); - m_kk++; -} - -/* - * - * addUniqueSpecies(): - * - * Add a species to a Constituents object. This routine will - * first check to see if the species is already part of the - * phase. It does this via a string comparison with the - * existing species in the phase. - */ -void Constituents:: -addUniqueSpecies(const std::string& name, const doublereal* comp, - doublereal charge, doublereal size) -{ - vector::const_iterator it = m_speciesNames.begin(); - for (size_t k = 0; k < m_kk; k++) { - if (*it == name) { - /* - * We have found a match. At this point we could do some - * compatibility checks. However, let's just return for the - * moment without specifying any error. - */ - size_t m_mm = m_Elements->nElements(); - for (size_t i = 0; i < m_mm; i++) { - if (comp[i] != m_speciesComp[m_kk * m_mm + i]) { - throw CanteraError("addUniqueSpecies", - "Duplicate species have different " - "compositions: " + *it); - } - } - if (charge != m_speciesCharge[m_kk]) { - throw CanteraError("addUniqueSpecies", - "Duplicate species have different " - "charges: " + *it); - } - if (size != m_speciesSize[m_kk]) { - throw CanteraError("addUniqueSpecies", - "Duplicate species have different " - "sizes: " + *it); - } - return; - } - ++it; - } - addSpecies(name, comp, charge, size); -} - -/* - * - * freezeSpecies() - * Set the boolean indicating that we are no longer allowing - * species to be added to the Constituents class object. - */ -void Constituents::freezeSpecies() -{ - m_speciesFrozen = true; -} - -/* - * - * speciesIndex() - * - * Index of species named \c name. The first species added - * will have index 0, and the last one index nSpecies() - 1. - * - * Note, the [] operator shouldn't be used for map's because it - * creates new entries. Here, we use find() to look up entries. - * - * If name isn't in the list, then a -1 is returned. - */ -size_t Constituents::speciesIndex(std::string name) const -{ - vector::const_iterator it = m_speciesNames.begin(); - for (size_t k = 0; k < m_kk; k++) { - if (*it == name) { - /* - * We have found a match. - */ - return k; - } - ++it; - } - return npos; -} - -/* - * - * speciesName() - * - * Name of the species with index k - */ -string Constituents::speciesName(size_t k) const -{ - if (k >= nSpecies()) - throw SpeciesRangeError("Constituents::speciesName", - k, nSpecies()); - return m_speciesNames[k]; -} - -/* - * - * speciesNames() - * - * Return a const reference to the vector of species names - */ -const vector& Constituents::speciesNames() const -{ - return m_speciesNames; -} - -/* - * - * ready(): - * True if both elements and species have been frozen - */ -bool Constituents::ready() const -{ - return (m_Elements->elementsFrozen() && m_speciesFrozen); -} - -/* - * Returns the number of atoms of element \c m in species \c k. - */ -doublereal Constituents::nAtoms(size_t k, size_t m) const -{ - const size_t m_mm = m_Elements->nElements(); - if (m >= m_mm) { - throw ElementRangeError("Constituents::nAtoms",m,nElements()); - } - if (k >= nSpecies()) { - throw SpeciesRangeError("Constituents::nAtoms",k,nSpecies()); - } - return m_speciesComp[m_mm * k + m]; -} - - -//==================================================================================================================== -/* - * - * getAtoms() - * - * Get a vector containing the atomic composition - * of species k - */ -void Constituents::getAtoms(size_t k, double* atomArray) const -{ - const size_t m_mm = m_Elements->nElements(); - for (size_t m = 0; m < m_mm; m++) { - atomArray[m] = (double) m_speciesComp[m_mm * k + m]; - } -} - - - -//==================================================================================================================== -size_t Constituents::addUniqueElementAfterFreeze(const std::string& symbol, doublereal weight, int atomicNumber, - doublereal entropy298, int elem_type) -{ - size_t ii = elementIndex(symbol); - if (ii != npos) { - return ii; - } - // Check to see that the element isn't really in the list - m_Elements->m_elementsFrozen = false; - addUniqueElement(symbol, weight, atomicNumber, entropy298, elem_type); - m_Elements->m_elementsFrozen = true; - size_t m_mm = m_Elements->nElements(); - ii = elementIndex(symbol); - if (ii != m_mm-1) { - throw CanteraError("Constituents::addElementAfterFreeze()", "confused"); - } - if (m_kk > 0) { - vector_fp old(m_speciesComp); - m_speciesComp.resize(m_kk*m_mm, 0.0); - for (size_t k = 0; k < m_kk; k++) { - size_t m_old = m_mm - 1; - for (size_t m = 0; m < m_old; m++) { - m_speciesComp[k * m_mm + m] = old[k * (m_old) + m]; - } - m_speciesComp[k * (m_mm) + (m_mm-1)] = 0.0; - } - } - return ii; -} -//==================================================================================================================== -/* - * This copy constructor just calls the assignment operator - * for this class. - * The assignment operator does a deep copy. - */ -Constituents::Constituents(const Constituents& right) : - m_kk(0), - m_speciesFrozen(false), - m_Elements(0) -{ - *this = right; -} - -/* - * Assignment operator for the Constituents class. - * Right now we pretty much do a straight uncomplicated - * copy of all of the protected data. - */ -Constituents& Constituents::operator=(const Constituents& right) -{ - /* - * Check for self assignment. - */ - if (this == &right) { - return *this; - } - /* - * We do a straight assignment operator on all of the - * data. The vectors are copied. - */ - m_kk = right.m_kk; - m_weight = right.m_weight; - m_speciesFrozen = right.m_speciesFrozen; - if (m_Elements) { - int nleft = m_Elements->unsubscribe(); - if (nleft <= 0) { - vector::iterator it; - for (it = Elements::Global_Elements_List.begin(); - it != Elements::Global_Elements_List.end(); ++it) { - if (*it == m_Elements) { - Elements::Global_Elements_List.erase(it); - break; - } - } - delete m_Elements; - } - } - m_Elements = right.m_Elements; - if (m_Elements) { - m_Elements->subscribe(); - } - m_speciesNames = right.m_speciesNames; - m_speciesComp = right.m_speciesComp; - m_speciesCharge = right.m_speciesCharge; - m_speciesSize = right.m_speciesSize; - /* - * Return the reference to the current object - */ - return *this; -} - - -} diff --git a/src/thermo/DebyeHuckel.cpp b/src/thermo/DebyeHuckel.cpp index d2025f6bc..837102742 100644 --- a/src/thermo/DebyeHuckel.cpp +++ b/src/thermo/DebyeHuckel.cpp @@ -17,6 +17,9 @@ #include "cantera/thermo/ThermoFactory.h" #include "cantera/thermo/WaterProps.h" #include "cantera/thermo/PDSS_Water.h" + +#include "cantera/base/stringUtils.h" + #include #include diff --git a/src/thermo/Elements.cpp b/src/thermo/Elements.cpp index f1669d800..b8d1d8fb9 100644 --- a/src/thermo/Elements.cpp +++ b/src/thermo/Elements.cpp @@ -323,7 +323,8 @@ size_t Elements::elementIndex(std::string name) const string Elements::elementName(size_t m) const { if (m >= nElements()) { - throw ElementRangeError("Elements::elementName", m, nElements()); + throw IndexError("Elements::elementName", "m_elementNames", + m, nElements()); } return m_elementNames[m]; } diff --git a/src/thermo/GibbsExcessVPSSTP.cpp b/src/thermo/GibbsExcessVPSSTP.cpp index d5a043796..f0577da23 100644 --- a/src/thermo/GibbsExcessVPSSTP.cpp +++ b/src/thermo/GibbsExcessVPSSTP.cpp @@ -17,7 +17,10 @@ * U.S. Government retains certain rights in this software. */ #include "cantera/thermo/GibbsExcessVPSSTP.h" +#include "cantera/base/stringUtils.h" + #include + using namespace std; namespace Cantera diff --git a/src/thermo/HMWSoln.cpp b/src/thermo/HMWSoln.cpp index 14abde555..7e65fb7bb 100644 --- a/src/thermo/HMWSoln.cpp +++ b/src/thermo/HMWSoln.cpp @@ -22,6 +22,7 @@ #include "cantera/thermo/ThermoFactory.h" #include "cantera/thermo/WaterProps.h" #include "cantera/thermo/PDSS_Water.h" +#include "cantera/base/stringUtils.h" #include #include @@ -2445,7 +2446,7 @@ s_updatePitzer_lnMolalityActCoeff() const */ const double* molality = DATA_PTR(m_molalitiesCropped); /* - * These are the charges of the species accessed from Constituents.h + * These are the charges of the species accessed from class Phase */ const double* charge = DATA_PTR(m_speciesCharge); diff --git a/src/thermo/HMWSoln_input.cpp b/src/thermo/HMWSoln_input.cpp index 0f3dd1b8e..892500baf 100644 --- a/src/thermo/HMWSoln_input.cpp +++ b/src/thermo/HMWSoln_input.cpp @@ -16,6 +16,8 @@ #include "cantera/thermo/ThermoFactory.h" #include "cantera/thermo/WaterProps.h" #include "cantera/thermo/PDSS_Water.h" +#include "cantera/base/stringUtils.h" + #include #include diff --git a/src/thermo/IdealSolidSolnPhase.cpp b/src/thermo/IdealSolidSolnPhase.cpp index 5d2b95f54..00a7dcbfb 100644 --- a/src/thermo/IdealSolidSolnPhase.cpp +++ b/src/thermo/IdealSolidSolnPhase.cpp @@ -11,7 +11,10 @@ */ #include "cantera/thermo/IdealSolidSolnPhase.h" +#include "cantera/base/stringUtils.h" + #include + using namespace std; namespace Cantera diff --git a/src/thermo/IdealSolnGasVPSS.cpp b/src/thermo/IdealSolnGasVPSS.cpp index ae7092113..7bb21f97a 100644 --- a/src/thermo/IdealSolnGasVPSS.cpp +++ b/src/thermo/IdealSolnGasVPSS.cpp @@ -17,6 +17,7 @@ #include "cantera/thermo/PDSS.h" #include "cantera/thermo/mix_defs.h" #include "cantera/thermo/ThermoFactory.h" +#include "cantera/base/stringUtils.h" using namespace std; diff --git a/src/thermo/IonsFromNeutralVPSSTP.cpp b/src/thermo/IonsFromNeutralVPSSTP.cpp index 10d7039aa..4767d8fde 100644 --- a/src/thermo/IonsFromNeutralVPSSTP.cpp +++ b/src/thermo/IonsFromNeutralVPSSTP.cpp @@ -18,9 +18,9 @@ */ #include "cantera/thermo/IonsFromNeutralVPSSTP.h" #include "cantera/thermo/ThermoFactory.h" - #include "cantera/thermo/PDSS_IonsFromNeutral.h" #include "cantera/thermo/mix_defs.h" +#include "cantera/base/stringUtils.h" #include #include diff --git a/src/thermo/LatticePhase.cpp b/src/thermo/LatticePhase.cpp index fc268fdc5..cef2cecaf 100644 --- a/src/thermo/LatticePhase.cpp +++ b/src/thermo/LatticePhase.cpp @@ -15,6 +15,7 @@ #include "cantera/thermo/LatticePhase.h" #include "cantera/thermo/SpeciesThermo.h" #include "cantera/thermo/ThermoFactory.h" +#include "cantera/base/stringUtils.h" #include diff --git a/src/thermo/MargulesVPSSTP.cpp b/src/thermo/MargulesVPSSTP.cpp index bdb60babe..770ec0c36 100644 --- a/src/thermo/MargulesVPSSTP.cpp +++ b/src/thermo/MargulesVPSSTP.cpp @@ -13,6 +13,8 @@ */ #include "cantera/thermo/MargulesVPSSTP.h" #include "cantera/thermo/ThermoFactory.h" +#include "cantera/base/stringUtils.h" + #include using namespace std; diff --git a/src/thermo/MixedSolventElectrolyte.cpp b/src/thermo/MixedSolventElectrolyte.cpp index 88fc284e6..547f2ac78 100644 --- a/src/thermo/MixedSolventElectrolyte.cpp +++ b/src/thermo/MixedSolventElectrolyte.cpp @@ -11,14 +11,11 @@ * Contract DE-AC04-94AL85000 with Sandia Corporation, the * U.S. Government retains certain rights in this software. */ -/* - * $Date: 2011-04-14 12:24:13 -0600 (Thu, 14 Apr 2011) $ - * $Revision: 713 $ - */ - #include "cantera/thermo/MixedSolventElectrolyte.h" #include "cantera/thermo/ThermoFactory.h" +#include "cantera/base/stringUtils.h" + #include using namespace std; diff --git a/src/thermo/MixtureFugacityTP.cpp b/src/thermo/MixtureFugacityTP.cpp index b2187c9c0..16036f975 100644 --- a/src/thermo/MixtureFugacityTP.cpp +++ b/src/thermo/MixtureFugacityTP.cpp @@ -10,23 +10,16 @@ * Contract DE-AC04-94AL85000 with Sandia Corporation, the * U.S. Government retains certain rights in this software. */ -/* - * $Author: hkmoffa $ - * $Date: 2010-01-17 12:08:00 -0700 (Sun, 17 Jan 2010) $ - * $Revision: 388 $ - */ #include "cantera/thermo/MixtureFugacityTP.h" #include "cantera/thermo/VPSSMgr.h" #include "cantera/thermo/PDSS.h" +#include "cantera/base/stringUtils.h" using namespace std; namespace Cantera { - - - //==================================================================================================================== /* * Default constructor diff --git a/src/thermo/MolalityVPSSTP.cpp b/src/thermo/MolalityVPSSTP.cpp index 948740f54..a0cda144e 100644 --- a/src/thermo/MolalityVPSSTP.cpp +++ b/src/thermo/MolalityVPSSTP.cpp @@ -17,7 +17,10 @@ * U.S. Government retains certain rights in this software. */ #include "cantera/thermo/MolalityVPSSTP.h" +#include "cantera/base/stringUtils.h" + #include + using namespace std; namespace Cantera diff --git a/src/thermo/MolarityIonicVPSSTP.cpp b/src/thermo/MolarityIonicVPSSTP.cpp index eedde4b5a..7dc9c9707 100644 --- a/src/thermo/MolarityIonicVPSSTP.cpp +++ b/src/thermo/MolarityIonicVPSSTP.cpp @@ -16,14 +16,10 @@ * Contract DE-AC04-94AL85000 with Sandia Corporation, the * U.S. Government retains certain rights in this software. */ -/* - * $Date: 2009-11-09 16:36:49 -0700 (Mon, 09 Nov 2009) $ - * $Revision: 255 $ - */ - - #include "cantera/thermo/MolarityIonicVPSSTP.h" #include "cantera/thermo/ThermoFactory.h" +#include "cantera/base/stringUtils.h" + #include using namespace std; diff --git a/src/thermo/PDSS_HKFT.cpp b/src/thermo/PDSS_HKFT.cpp index dede626bd..5ac555f6b 100644 --- a/src/thermo/PDSS_HKFT.cpp +++ b/src/thermo/PDSS_HKFT.cpp @@ -15,6 +15,7 @@ #include "cantera/thermo/PDSS_HKFT.h" #include "cantera/thermo/WaterProps.h" #include "cantera/thermo/PDSS_Water.h" +#include "cantera/base/stringUtils.h" #include diff --git a/src/thermo/PDSS_IonsFromNeutral.cpp b/src/thermo/PDSS_IonsFromNeutral.cpp index 5b0404cbd..1668602dc 100644 --- a/src/thermo/PDSS_IonsFromNeutral.cpp +++ b/src/thermo/PDSS_IonsFromNeutral.cpp @@ -8,14 +8,15 @@ * Contract DE-AC04-94AL85000 with Sandia Corporation, the * U.S. Government retains certain rights in this software. */ -#include "cantera/base/ct_defs.h" -#include "cantera/base/xml.h" -#include "cantera/base/ctml.h" + #include "cantera/thermo/PDSS_IonsFromNeutral.h" #include "cantera/thermo/ThermoFactory.h" #include "cantera/thermo/IonsFromNeutralVPSSTP.h" - #include "cantera/thermo/VPStandardStateTP.h" +#include "cantera/base/stringUtils.h" +#include "cantera/base/ct_defs.h" +#include "cantera/base/xml.h" +#include "cantera/base/ctml.h" using namespace std; diff --git a/src/thermo/PDSS_Water.cpp b/src/thermo/PDSS_Water.cpp index 0f1821445..af76ea4ad 100644 --- a/src/thermo/PDSS_Water.cpp +++ b/src/thermo/PDSS_Water.cpp @@ -17,6 +17,7 @@ #include "cantera/thermo/ThermoFactory.h" #include "cantera/thermo/WaterProps.h" #include "cantera/thermo/VPStandardStateTP.h" +#include "cantera/base/stringUtils.h" #include diff --git a/src/thermo/Phase.cpp b/src/thermo/Phase.cpp index 0a7542601..2c7047165 100644 --- a/src/thermo/Phase.cpp +++ b/src/thermo/Phase.cpp @@ -7,10 +7,10 @@ // Copyright 2001 California Institute of Technology -#include "cantera/base/ct_defs.h" #include "cantera/thermo/Phase.h" #include "cantera/base/vec_functions.h" #include "cantera/base/ctexceptions.h" +#include "cantera/base/stringUtils.h" using namespace std; @@ -18,7 +18,6 @@ namespace Cantera { Phase::Phase() : - Constituents(), m_kk(0), m_ndim(3), m_xml(new XML_Node("phase")), @@ -27,8 +26,11 @@ Phase::Phase() : m_temp(0.0), m_dens(0.001), m_mmw(0.0), - m_stateNum(-1) + m_stateNum(-1), + m_speciesFrozen(false) , + m_Elements(new Elements()) { + m_Elements->subscribe(); } /* @@ -38,7 +40,6 @@ Phase::Phase() : * then calls the assignment operator. */ Phase::Phase(const Phase& right) : - Constituents(), m_kk(0), m_ndim(3), m_xml(new XML_Node("phase")), @@ -47,7 +48,9 @@ Phase::Phase(const Phase& right) : m_temp(0.0), m_dens(0.001), m_mmw(0.0), - m_stateNum(-1) + m_stateNum(-1), + m_speciesFrozen(false) , + m_Elements(0) { /* * Call the assignment operator. @@ -55,30 +58,14 @@ Phase::Phase(const Phase& right) : *this = operator=(right); } -/* - * Assignment operator - * - * This operation is sort of complicated. We have to - * call the assignment operator for the Constituents and - * State operators that Phase inherits from. Then, - * we have to copy our own data, making sure to do a - * deep copy on the XML_Node data owned by this object. - */ Phase& Phase::operator=(const Phase& right) { - /* - * Check for self assignment. - */ + // Check for self assignment. if (this == &right) { return *this; } - /* - * Now call the inherited-classes assignment operators. - */ - (void) Constituents::operator=(right); - /* - * Handle its own data - */ + + // Handle our own data m_kk = right.m_kk; m_ndim = right.m_ndim; m_data = right.m_data; @@ -90,6 +77,29 @@ Phase& Phase::operator=(const Phase& right) m_molwts = right.m_molwts; m_rmolwts = right.m_rmolwts; m_stateNum = -1; + m_speciesFrozen = right.m_speciesFrozen; + if (m_Elements) { + int nleft = m_Elements->unsubscribe(); + if (nleft <= 0) { + vector::iterator it; + for (it = Elements::Global_Elements_List.begin(); + it != Elements::Global_Elements_List.end(); ++it) { + if (*it == m_Elements) { + Elements::Global_Elements_List.erase(it); + break; + } + } + delete m_Elements; + } + } + m_Elements = right.m_Elements; + if (m_Elements) { + m_Elements->subscribe(); + } + m_speciesNames = right.m_speciesNames; + m_speciesComp = right.m_speciesComp; + m_speciesCharge = right.m_speciesCharge; + m_speciesSize = right.m_speciesSize; /* * This is a little complicated. -> Because we delete m_xml @@ -118,6 +128,24 @@ Phase::~Phase() delete m_xml; m_xml = 0; } + + int ileft = m_Elements->unsubscribe(); + /* + * Here we may delete Elements Objects or not. Right now, we + * will delete them. We also delete the global pointer entry + * to keep everything consistent. + */ + if (ileft <= 0) { + vector::iterator it; + for (it = Elements::Global_Elements_List.begin(); + it != Elements::Global_Elements_List.end(); ++it) { + if (*it == m_Elements) { + Elements::Global_Elements_List.erase(it); + break; + } + } + delete m_Elements; + } } inline void Phase::stateMFChangeCalc(bool forcerChange) @@ -155,6 +183,71 @@ void Phase::setName(std::string nm) m_name = nm; } +size_t Phase::nElements() const +{ + return m_Elements->nElements(); +} + +string Phase::elementName(size_t m) const +{ + return m_Elements->elementName(m); +} + +size_t Phase::elementIndex(std::string name) const +{ + return m_Elements->elementIndex(name); +} + +const vector& Phase::elementNames() const +{ + return m_Elements->elementNames(); +} + +doublereal Phase::atomicWeight(size_t m) const +{ + return m_Elements->atomicWeight(m); +} + +doublereal Phase::entropyElement298(size_t m) const +{ + return m_Elements->entropyElement298(m); +} + +const vector_fp& Phase::atomicWeights() const +{ + return m_Elements->atomicWeights(); +} + +int Phase::atomicNumber(size_t m) const +{ + return m_Elements->atomicNumber(m); +} + +int Phase::elementType(size_t m) const +{ + return m_Elements->elementType(m); +} + +doublereal Phase::nAtoms(size_t k, size_t m) const +{ + const size_t m_mm = m_Elements->nElements(); + if (m >= m_mm) { + throw IndexError("Phase::nAtoms", "", m, nElements()); + } + if (k >= nSpecies()) { + throw IndexError("Phase::nAtoms", "", k, nSpecies()); + } + return m_speciesComp[m_mm * k + m]; +} + +void Phase::getAtoms(size_t k, double* atomArray) const +{ + const size_t m_mm = m_Elements->nElements(); + for (size_t m = 0; m < m_mm; m++) { + atomArray[m] = (double) m_speciesComp[m_mm * k + m]; + } +} + // Returns the index of a species named 'name' within the Phase object /* * The first species in the phase will have an index 0, and the last one in the @@ -181,14 +274,33 @@ size_t Phase::speciesIndex(std::string nameStr) const std::string pn; std::string sn = parseSpeciesName(nameStr, pn); if (pn == "" || pn == m_name || pn == m_id) { - return Constituents::speciesIndex(sn); + vector::const_iterator it = m_speciesNames.begin(); + for (size_t k = 0; k < m_kk; k++) { + if (*it == sn) { + return k; + } + ++it; + } + return npos; } return npos; } +string Phase::speciesName(size_t k) const +{ + if (k >= nSpecies()) + throw IndexError("Phase::speciesName", "m_speciesNames", k, nSpecies()); + return m_speciesNames[k]; +} + +const vector& Phase::speciesNames() const +{ + return m_speciesNames; +} + std::string Phase::speciesSPName(int k) const { - std::string sn = Constituents::speciesName(k); + std::string sn = speciesName(k); return(m_name + ":" + sn); } @@ -405,12 +517,20 @@ void Phase::setState_RY(doublereal rho, doublereal* y) setDensity(rho); } +doublereal Phase::molecularWeight(size_t k) const +{ + if (k >= nSpecies()) { + throw IndexError("Phase::molecularWeight", "m_weight", k, nSpecies()); + } + return m_molwts[k]; +} + /* * Copy the vector of molecular weights into vector weights. */ void Phase::getMolecularWeights(vector_fp& weights) const { - const vector_fp& mw = Constituents::molecularWeights(); + const vector_fp& mw = molecularWeights(); if (weights.size() < mw.size()) { weights.resize(mw.size()); } @@ -423,29 +543,21 @@ void Phase::getMolecularWeights(vector_fp& weights) const */ void Phase::getMolecularWeights(int iwt, doublereal* weights) const { - const vector_fp& mw = Constituents::molecularWeights(); + const vector_fp& mw = molecularWeights(); copy(mw.begin(), mw.end(), weights); } -/* - * Copy the vector of molecular weights into array weights. - */ void Phase::getMolecularWeights(doublereal* weights) const { - const vector_fp& mw = Constituents::molecularWeights(); + const vector_fp& mw = molecularWeights(); copy(mw.begin(), mw.end(), weights); } -/** - * Return a const reference to the internal vector of - * molecular weights. - */ const vector_fp& Phase::molecularWeights() const { - return Constituents::molecularWeights(); + return m_molwts; } - /** * Get the mole fractions by name. */ @@ -561,6 +673,11 @@ doublereal Phase::molarVolume() const return 1.0/molarDensity(); } +doublereal Phase::charge(size_t k) const +{ + return m_speciesCharge[k]; +} + doublereal Phase::chargeDensity() const { size_t kk = nSpecies(); @@ -592,28 +709,168 @@ doublereal Phase::sum_xlogQ(doublereal* Q) const return m_mmw * Cantera::sum_xlogQ(m_ym.begin(), m_ym.end(), Q); } -/** - * Finished adding species, prepare to use them for calculation - * of mixture properties. - */ +void Phase::addElement(const std::string& symbol, doublereal weight) +{ + m_Elements->addElement(symbol, weight); +} + +void Phase::addElement(const XML_Node& e) +{ + m_Elements->addElement(e); +} + +void Phase::addUniqueElement(const std::string& symbol, doublereal weight, + int atomicNumber, doublereal entropy298, int elem_type) +{ + m_Elements->addUniqueElement(symbol, weight, atomicNumber, entropy298, elem_type); +} + +void Phase::addUniqueElement(const XML_Node& e) +{ + m_Elements->addUniqueElement(e); +} + +void Phase::addElementsFromXML(const XML_Node& phase) +{ + m_Elements->addElementsFromXML(phase); +} + +void Phase::freezeElements() +{ + m_Elements->freezeElements(); +} + +bool Phase::elementsFrozen() +{ + return m_Elements->elementsFrozen(); +} + +size_t Phase::addUniqueElementAfterFreeze(const std::string& symbol, doublereal weight, int atomicNumber, + doublereal entropy298, int elem_type) +{ + size_t ii = elementIndex(symbol); + if (ii != npos) { + return ii; + } + // Check to see that the element isn't really in the list + m_Elements->m_elementsFrozen = false; + addUniqueElement(symbol, weight, atomicNumber, entropy298, elem_type); + m_Elements->m_elementsFrozen = true; + size_t m_mm = m_Elements->nElements(); + ii = elementIndex(symbol); + if (ii != m_mm-1) { + throw CanteraError("Phase::addElementAfterFreeze()", "confused"); + } + if (m_kk > 0) { + vector_fp old(m_speciesComp); + m_speciesComp.resize(m_kk*m_mm, 0.0); + for (size_t k = 0; k < m_kk; k++) { + size_t m_old = m_mm - 1; + for (size_t m = 0; m < m_old; m++) { + m_speciesComp[k * m_mm + m] = old[k * (m_old) + m]; + } + m_speciesComp[k * (m_mm) + (m_mm-1)] = 0.0; + } + } + return ii; +} + +void Phase::addSpecies(const std::string& name, const doublereal* comp, + doublereal charge, doublereal size) +{ + m_Elements->freezeElements(); + m_speciesNames.push_back(name); + m_speciesCharge.push_back(charge); + m_speciesSize.push_back(size); + size_t ne = m_Elements->nElements(); + // Create a changeable copy of the element composition. We now change the charge potentially + vector_fp compNew(ne); + for (size_t m = 0; m < ne; m++) { + compNew[m] = comp[m]; + } + double wt = 0.0; + const vector_fp& aw = m_Elements->atomicWeights(); + if (charge != 0.0) { + size_t eindex = m_Elements->elementIndex("E"); + if (eindex != npos) { + doublereal ecomp = compNew[eindex]; + if (fabs(charge + ecomp) > 0.001) { + if (ecomp != 0.0) { + throw CanteraError("Phase::addSpecies", + "Input charge and element E compositions differ for species " + name); + } else { + // Just fix up the element E composition based on the input species charge + compNew[eindex] = -charge; + } + } + } else { + addUniqueElementAfterFreeze("E", 0.000545, 0, 0.0, CT_ELEM_TYPE_ELECTRONCHARGE); + ne = m_Elements->nElements(); + eindex = m_Elements->elementIndex("E"); + compNew.resize(ne); + compNew[ne - 1] = - charge; + } + } + for (size_t m = 0; m < ne; m++) { + m_speciesComp.push_back(compNew[m]); + wt += compNew[m] * aw[m]; + } + m_molwts.push_back(wt); + m_kk++; +} + +void Phase::addUniqueSpecies(const std::string& name, const doublereal* comp, + doublereal charge, doublereal size) +{ + vector::const_iterator it = m_speciesNames.begin(); + for (size_t k = 0; k < m_kk; k++) { + if (*it == name) { + /* + * We have found a match. At this point we could do some + * compatibility checks. However, let's just return for the + * moment without specifying any error. + */ + size_t m_mm = m_Elements->nElements(); + for (size_t i = 0; i < m_mm; i++) { + if (comp[i] != m_speciesComp[m_kk * m_mm + i]) { + throw CanteraError("addUniqueSpecies", + "Duplicate species have different " + "compositions: " + *it); + } + } + if (charge != m_speciesCharge[m_kk]) { + throw CanteraError("addUniqueSpecies", + "Duplicate species have different " + "charges: " + *it); + } + if (size != m_speciesSize[m_kk]) { + throw CanteraError("addUniqueSpecies", + "Duplicate species have different " + "sizes: " + *it); + } + return; + } + ++it; + } + addSpecies(name, comp, charge, size); +} + void Phase::freezeSpecies() { - Constituents::freezeSpecies(); - init(Constituents::molecularWeights()); + m_speciesFrozen = true; + init(molecularWeights()); size_t kk = nSpecies(); size_t nv = kk + 2; m_data.resize(nv,0.0); m_data[0] = 300.0; m_data[1] = 0.001; m_data[2] = 1.0; - m_kk = nSpecies(); } void Phase::init(const vector_fp& mw) { m_kk = mw.size(); - m_molwts.resize(m_kk); m_rmolwts.resize(m_kk); m_y.resize(m_kk, 0.0); m_ym.resize(m_kk, 0.0); @@ -650,7 +907,7 @@ void Phase::init(const vector_fp& mw) bool Phase::ready() const { - return (m_kk > 0 && Constituents::ready()); + return (m_kk > 0 && m_Elements->elementsFrozen() && m_speciesFrozen); } } // namespace Cantera diff --git a/src/thermo/PhaseCombo_Interaction.cpp b/src/thermo/PhaseCombo_Interaction.cpp index c0db6e66c..d6d947f3c 100644 --- a/src/thermo/PhaseCombo_Interaction.cpp +++ b/src/thermo/PhaseCombo_Interaction.cpp @@ -7,14 +7,11 @@ * Contract DE-AC04-94AL85000 with Sandia Corporation, the * U.S. Government retains certain rights in this software. */ -/* - * $Date: 2010-11-12 14:37:41 -0700 (Fri, 12 Nov 2010) $ - * $Revision: 641 $ - */ - #include "cantera/thermo/PhaseCombo_Interaction.h" #include "cantera/thermo/ThermoFactory.h" +#include "cantera/base/stringUtils.h" + #include using namespace std; diff --git a/src/thermo/PseudoBinaryVPSSTP.cpp b/src/thermo/PseudoBinaryVPSSTP.cpp index 36618eea8..4be705046 100644 --- a/src/thermo/PseudoBinaryVPSSTP.cpp +++ b/src/thermo/PseudoBinaryVPSSTP.cpp @@ -17,6 +17,7 @@ * U.S. Government retains certain rights in this software. */ #include "cantera/thermo/PseudoBinaryVPSSTP.h" +#include "cantera/base/stringUtils.h" #include diff --git a/src/thermo/PureFluidPhase.cpp b/src/thermo/PureFluidPhase.cpp index a817d7cc4..35b3f48a6 100644 --- a/src/thermo/PureFluidPhase.cpp +++ b/src/thermo/PureFluidPhase.cpp @@ -97,7 +97,6 @@ initThermo() "could not create new substance object."); } m_mw = m_sub->MolWt(); - m_weight[0] = m_mw; setMolecularWeight(0,m_mw); double one = 1.0; setMoleFractions(&one); diff --git a/src/thermo/RedlichKisterVPSSTP.cpp b/src/thermo/RedlichKisterVPSSTP.cpp index b4f7894ce..2189bb925 100644 --- a/src/thermo/RedlichKisterVPSSTP.cpp +++ b/src/thermo/RedlichKisterVPSSTP.cpp @@ -11,14 +11,11 @@ * Contract DE-AC04-94AL85000 with Sandia Corporation, the * U.S. Government retains certain rights in this software. */ -/* - * $Date: 2011-04-14 12:24:13 -0600 (Thu, 14 Apr 2011) $ - * $Revision: 713 $ - */ - #include "RedlichKisterVPSSTP.h" #include "cantera/thermo/ThermoFactory.h" +#include "cantera/base/stringUtils.h" + #include using namespace std; diff --git a/src/thermo/SingleSpeciesTP.cpp b/src/thermo/SingleSpeciesTP.cpp index 547b0f9ed..9c0562c3c 100644 --- a/src/thermo/SingleSpeciesTP.cpp +++ b/src/thermo/SingleSpeciesTP.cpp @@ -11,6 +11,7 @@ * U.S. Government retains certain rights in this software. */ #include "cantera/thermo/SingleSpeciesTP.h" +#include "cantera/base/stringUtils.h" using namespace std; diff --git a/src/thermo/SurfPhase.cpp b/src/thermo/SurfPhase.cpp index 8dc5864c1..4c7a19d96 100644 --- a/src/thermo/SurfPhase.cpp +++ b/src/thermo/SurfPhase.cpp @@ -10,9 +10,9 @@ #include "cantera/thermo/SurfPhase.h" #include "cantera/thermo/EdgePhase.h" #include "cantera/thermo/ThermoFactory.h" +#include "cantera/base/stringUtils.h" using namespace ctml; - using namespace std; /////////////////////////////////////////////////////////// diff --git a/src/thermo/ThermoPhase.cpp b/src/thermo/ThermoPhase.cpp index 480f5f837..38c76ce59 100644 --- a/src/thermo/ThermoPhase.cpp +++ b/src/thermo/ThermoPhase.cpp @@ -9,6 +9,8 @@ #include "cantera/thermo/ThermoPhase.h" #include "cantera/base/mdp_allo.h" +#include "cantera/base/stringUtils.h" + #include using namespace std; diff --git a/src/thermo/VPStandardStateTP.cpp b/src/thermo/VPStandardStateTP.cpp index aa4767ebc..1259dd99d 100644 --- a/src/thermo/VPStandardStateTP.cpp +++ b/src/thermo/VPStandardStateTP.cpp @@ -14,6 +14,7 @@ #include "cantera/thermo/VPStandardStateTP.h" #include "cantera/thermo/VPSSMgr.h" #include "cantera/thermo/PDSS.h" +#include "cantera/base/stringUtils.h" using namespace std; diff --git a/src/thermo/WaterProps.cpp b/src/thermo/WaterProps.cpp index 28dc33d34..a0b1e7d57 100644 --- a/src/thermo/WaterProps.cpp +++ b/src/thermo/WaterProps.cpp @@ -11,6 +11,7 @@ #include "cantera/base/ctml.h" #include "cantera/thermo/PDSS_Water.h" #include "cantera/thermo/WaterPropsIAPWS.h" +#include "cantera/base/stringUtils.h" #include diff --git a/src/thermo/WaterSSTP.cpp b/src/thermo/WaterSSTP.cpp index bd7566211..eaf7ebe2d 100644 --- a/src/thermo/WaterSSTP.cpp +++ b/src/thermo/WaterSSTP.cpp @@ -8,12 +8,14 @@ * Contract DE-AC04-94AL85000 with Sandia Corporation, the * U.S. Government retains certain rights in this software. */ -#include "cantera/base/xml.h" + #include "cantera/thermo/WaterSSTP.h" #include "cantera/thermo/WaterPropsIAPWS.h" -//#include "importCTML.h" #include "cantera/thermo/WaterProps.h" #include "cantera/thermo/ThermoFactory.h" +#include "cantera/base/xml.h" +#include "cantera/base/stringUtils.h" + #include using namespace std; @@ -237,7 +239,6 @@ initThermoXML(XML_Node& phaseNode, std::string id) } double mw_O = atomicWeight(nO); m_mw = 2.0 * mw_H + mw_O; - m_weight[0] = m_mw; setMolecularWeight(0,m_mw); double one = 1.0; setMoleFractions(&one); diff --git a/src/transport/AqueousTransport.cpp b/src/transport/AqueousTransport.cpp index df93a4bb9..37c58bf0a 100644 --- a/src/transport/AqueousTransport.cpp +++ b/src/transport/AqueousTransport.cpp @@ -13,6 +13,8 @@ #include "cantera/numerics/ctlapack.h" +#include "cantera/base/stringUtils.h" + #include using namespace std; diff --git a/src/transport/DustyGasTransport.cpp b/src/transport/DustyGasTransport.cpp index 61e3eb3f4..508b4214b 100644 --- a/src/transport/DustyGasTransport.cpp +++ b/src/transport/DustyGasTransport.cpp @@ -12,6 +12,7 @@ #include "cantera/thermo/ThermoPhase.h" #include "cantera/transport/DustyGasTransport.h" +#include "cantera/base/stringUtils.h" using namespace std; diff --git a/src/transport/LiquidTranInteraction.cpp b/src/transport/LiquidTranInteraction.cpp index 79da5788b..0387bdd3f 100644 --- a/src/transport/LiquidTranInteraction.cpp +++ b/src/transport/LiquidTranInteraction.cpp @@ -2,17 +2,13 @@ * @file LiquidTransportParams.cpp * Source code for liquid mixture transport property evaluations. */ -/* - * Latest Checkin: - * $Author$ - * $Date$ - * $Revision$ - */ #include "cantera/transport/LiquidTransportParams.h" #include #include "cantera/thermo/IonsFromNeutralVPSSTP.h" #include "cantera/thermo/MargulesVPSSTP.h" +#include "cantera/base/stringUtils.h" + #include using namespace std; using namespace ctml; diff --git a/src/transport/LiquidTransport.cpp b/src/transport/LiquidTransport.cpp index 9c5813d7d..a599b8b93 100644 --- a/src/transport/LiquidTransport.cpp +++ b/src/transport/LiquidTransport.cpp @@ -8,8 +8,8 @@ #include "cantera/base/utilities.h" #include "cantera/transport/LiquidTransportParams.h" #include "cantera/transport/TransportFactory.h" - #include "cantera/numerics/ctlapack.h" +#include "cantera/base/stringUtils.h" #include using namespace std; diff --git a/src/transport/MixTransport.cpp b/src/transport/MixTransport.cpp index 6f974bef0..dc8be3f29 100644 --- a/src/transport/MixTransport.cpp +++ b/src/transport/MixTransport.cpp @@ -10,6 +10,7 @@ #include "cantera/base/utilities.h" #include "cantera/transport/TransportParams.h" #include "cantera/transport/TransportFactory.h" +#include "cantera/base/stringUtils.h" #include using namespace std; diff --git a/src/transport/MultiTransport.cpp b/src/transport/MultiTransport.cpp index bd097325b..8babd691a 100644 --- a/src/transport/MultiTransport.cpp +++ b/src/transport/MultiTransport.cpp @@ -20,6 +20,7 @@ #include "cantera/thermo/IdealGasPhase.h" #include "cantera/transport/TransportFactory.h" +#include "cantera/base/stringUtils.h" #include using namespace std; diff --git a/src/transport/SimpleTransport.cpp b/src/transport/SimpleTransport.cpp index 52a85df1c..77f169cc9 100644 --- a/src/transport/SimpleTransport.cpp +++ b/src/transport/SimpleTransport.cpp @@ -8,8 +8,8 @@ #include "cantera/base/utilities.h" #include "cantera/transport/LiquidTransportParams.h" #include "cantera/transport/TransportFactory.h" - #include "cantera/numerics/ctlapack.h" +#include "cantera/base/stringUtils.h" #include using namespace std; diff --git a/src/transport/TransportFactory.cpp b/src/transport/TransportFactory.cpp index 129e81549..0aa13a481 100644 --- a/src/transport/TransportFactory.cpp +++ b/src/transport/TransportFactory.cpp @@ -32,6 +32,7 @@ #include "cantera/base/global.h" #include "cantera/thermo/IdealGasPhase.h" #include "cantera/base/ctml.h" +#include "cantera/base/stringUtils.h" #include #include