diff --git a/include/cantera/thermo/Phase.h b/include/cantera/thermo/Phase.h index 37cdd5d24..04af40c9f 100644 --- a/include/cantera/thermo/Phase.h +++ b/include/cantera/thermo/Phase.h @@ -1,10 +1,6 @@ /** - * @file Phase.h - * - * Header file for class, Phase, which manages the independent variables - * of temperature, mass density, and species mass/mole fraction that define - * the thermodynamic state. Also contains functions for managing the species - * and elements in the phase. (see \ref phases) + * @file Phase.h + * Header file for class Phase. */ // Copyright 2001 California Institute of Technology @@ -21,917 +17,619 @@ class SpeciesThermo; //! Base class for phases of matter /*! - * Base class for phases of matter. Class Phase derives from both - * Constituents and State. In addition to the methods of those two - * classes, it implements methods that allow referencing a species - * by name. + * Class Phase manages the species and elements in a phase, as well as the + * independent variables of temperature, mass density, and species mass/mole + * fraction that define the thermodynamic state. * - * Manages the independent variables of temperature, mass density, - * and species mass/mole fraction that define the thermodynamic - * state. - * Class State stores just enough information about a - * multicomponent solution to specify its intensive thermodynamic - * state. It stores values for the temperature, mass density, and - * an array of species mass fractions. It also stores an array of - * species molecular weights, which are used to convert between - * mole and mass representations of the composition. These are the - * \e only properties of the species that class State knows about. - * For efficiency in mass/mole conversion, the vector of mass - * fractions divided by molecular weight \f$ Y_k/M_k \f$ is also - * stored. + * Class Phase provides information about the elements and species in a + * phase - names, index numbers (location in arrays), atomic or molecular + * weights, etc. The set of elements must include all those that compose the + * species, but may include additional elements. * - * Class State is not usually used directly in application - * programs. Its primary use is as a base class for class - * Phase. Class State has no virtual methods, and none of its - * methods are meant to be overloaded. However, this is one exception. - * If the phase is incompressible, then the density must be replaced - * by the pressure as the independent variable. In this case, functions - * such as setMassFraction within the class %State must actually now - * calculate the density (at constant T and P) instead of leaving - * it alone as befits an independent variable. Threfore, these type - * of functions are virtual functions and need to be overloaded - * for incompressible phases. Note, for almost incompressible phases - * (or phases which utilize standard states based on a T and P) this - * may be advantageous as well, and they need to overload these functions - * too. + * It also stores an array of species molecular weights, which are used to + * convert between mole and mass representations of the composition. For + * efficiency in mass/mole conversion, the vector of mass fractions divided + * by molecular weight \f$ Y_k/M_k \f$ is also stored. * - * 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. + * Class Phase is not usually used directly. Its primary use is as a base class + * for class ThermoPhase. It is not generally necessary to overloaded any of + * class Phase's methods, with the exception of incompressible phases. In that + * case, the density must be replaced by the pressure as the independent + * variable and functions such as setMassFraction within class Phase must + * actually now calculate the density (at constant T and P) instead of leaving + * it alone as befits an independent variable. This also applies for nearly- + * incompressible phases or phases which utilize standard states based on a + * T and P, in which case they need to overload these functions too. * - * @ingroup phases + * Class Phase contains a number of utility functions that will set the state + * of the phase in its entirety, by first setting the composition, then the + * temperature and then the density. An example of this is the function + * Phase::setState_TRY(double t, double dens, const double* y). * - * Class Phase derives from both classes - * Constituents and State. In addition to the methods of those two - * classes, it implements methods that allow referencing a species - * by name. And, it contains a lot of utility functions that will - * set the %State of the phase in its entirety, by first setting - * the composition, then the temperature and then the density. - * An example of this is the function, - * Phase::setState_TRY(doublereal t, doublereal dens, const doublereal* y). + * Class Phase contains method for saving and restoring the full internal + * states of each phase. These are saveState() and restoreState(). These + * functions operate on a state vector, which is in general of length + * (2 + nSpecies()). The first two entries of the state vector are temperature + * and density. * - * Class Phase contains method for saving and restoring the - * full internal states of each phase. These are called Phase::saveState() - * and Phase::restoreState(). These functions operate on a state - * vector, which is in general of length (2 + nSpecies()). The first - * two entries of the state vector is temperature and density. - * - * The class Phase contains two strings that identify a phase. - * The string id() is the value of the ID attribute of the XML phase node - * that is used to initialize a phase when it is read it. - * The id() field will stay that way even if the name is changed. - * The name field is also set to the value of the ID attribute of - * the XML phase node. - * - * However, the name field may be changed to another value during the course of a calculation. - * For example, if a phase is located in two places, but has the same - * constitutive input, the id's of the two phases will be the same, - * but the names of the two phases may be different. - * - * The name of a phase can be the same as the id of that same phase. - * Actually, this is the default and normal condition to have the name and - * the id for each phase to be the same. However, it is expected that - * it's an error to have two phases in a single problem with the same name. - * or the same id (or the name from one phase being the same as the id - * of another phase). - * Thus, it is expected that there is a 1-1 correspondence between - * names and unique phases within a Cantera problem. - * - * A species name may be referred to via three methods: + * A species name may be referred to via three methods: * * - "speciesName" * - "PhaseId:speciesName" * - "phaseName:speciesName" * . * - * The first two methods of naming may not yield a unique species within - * complicated assemblies of Cantera Phases. + * The first two methods of naming may not yield a unique species within + * complicated assemblies of %Cantera Phases. * - * - * @todo - * Make the concept of saving state vectors more general, so that - * it can handle other cases where there are additional internal state - * variables, such as the voltage, a potential energy, or a strain field. + * @todo Make the concept of saving state vectors more general, so that it can + * handle other cases where there are additional internal state variables, such + * as the voltage, a potential energy, or a strain field. * * @ingroup phases */ class Phase { public: - /// Default constructor. - Phase(); + Phase(); //!< Default constructor. - /// Destructor. - virtual ~Phase(); + virtual ~Phase(); //!< Destructor. - /** - * Copy Constructor - * - * @param right Reference to the class to be used in the copy - */ + //! Copy Constructor + //! @param right Reference to the class to be used in the copy Phase(const Phase& right); - /** - * Assignment operator - * - * @param right Reference to the class to be used in the copy - */ + //! Assignment operator + //! @param right Reference to the class to be used in the copy Phase& operator=(const Phase& right); - //! Returns a reference to the XML_Node stored for the phase - /*! - * The XML_Node for the phase contains all of the input data used - * to set up the model for the phase, during its initialization. - */ + //! Returns a reference to the XML_Node stored for the phase. + //! The XML_Node for the phase contains all of the input data used to set + //! up the model for the phase, during its initialization. XML_Node& xml(); - //! Return the string id for the phase - /*! - * Returns the id of the phase. The ID of the phase - * is set to the string name of the phase within the XML file - * Generally, it refers to the individual model name that - * denotes the species, the thermo, and the reaction rate info. + /*! @name Name and ID + * Class Phase contains two strings that identify a phase. The ID is the + * value of the ID attribute of the XML phase node that is used to + * initialize a phase when it is read. The name field is also initialized + * to the value of the ID attribute of the XML phase node. + * + * However, the name field may be changed to another value during the + * course of a calculation. For example, if a phase is located in two + * places, but has the same constitutive input, the ids of the two phases + * will be the same, but the names of the two phases may be different. + * + * It is an error to have two phases in a single problem with the same name + * or the same id (or the name from one phase being the same as the id of + * another phase). Thus, it is expected that there is a 1-1 correspondence + * between names and unique phases within a Cantera problem. */ + //!@{ + + //! Return the string id for the phase. std::string id() const; - //! Set the string id for the phase - /*! - * Sets the id of the phase. The ID of the phase - * is originally set to the string name of the phase within the XML file. - * Generally, it refers to the individual model name that - * denotes the species, the thermo, and the reaction rate info. - * - * @param id String id of the phase - */ + //! Set the string id for the phase. + //! @param id String id of the phase void setID(std::string id); - //! Return the name of the phase - /*! - * Returns the name of the phase. The name of the phase - * is set to the string name of the phase within the XML file - * Generally, it refers to the individual model name that - * denotes the species, the thermo, and the reaction rate info. - * It may also refer more specifically to a location within - * the domain. - */ + //! Return the name of the phase. std::string name() const; - //! Sets the string name for the phase - /*! - * Sets the name of the phase. The name of the phase - * is originally set to the string name of the phase within the XML file. - * Generally, it refers to the individual model name that - * denotes the species, the thermo, and the reaction rate info. - * It may also refer more specifically to a location within - * the domain. - * - * @param nm String name of the phase - */ + //! Sets the string name for the phase. + //! @param nm String name of the phase void setName(std::string nm); + //!@} end group Name and ID - /// @name Element Information - // @{ + //! @name Element and Species 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. + //! Name of the element with index m. + //! @param m Element index. 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. + //! Return the index of element named 'name'. The index is an integer + //! assigned to each element in the order it was added. Returns \ref npos + //! if the specified element is not found. + //! @param name Name of the element size_t elementIndex(std::string name) const; - /// Return a read-only reference to the vector of element names. + //! 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 - */ + //! 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 - */ + //! 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 - */ + //! 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. + //! Return a read-only reference to the vector of atomic weights. const vector_fp& atomicWeights() const; - /// Number of elements. + //! 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 - */ + //! @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 - */ + //! @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 - * phase will have an index of nSpecies() - 1. - * - * A species name may be referred to via three methods: - * - * - "speciesName" - * - "PhaseId:speciesName" - * - "phaseName:speciesName" - * . - * - * The first two methods of naming may not yield a unique species within - * complicated assemblies of Cantera phases. The last method is guarranteed - * to be unique within a collection of Cantera phases. - * - * @param name String name of the species. It may also be the phase name - * species name combination, separated by a colon. - * @return Returns the index of the species. If the name is not found, - * the value of -1 is returned. - */ + //! 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 + //! will have an index of nSpecies() - 1. + //! @param name String name of the species. It may also be in the form + //! phaseName:speciesName + //! @return The index of the species. If the name is not found, + //! the value \ref npos is returned. size_t speciesIndex(std::string name) const; //! Name of the species with index k - /*! - * @param k index of the species - */ + //! @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. - * This is guarranteed to be unique within a Cantera problem. - * - * @param k Species index within the phase - * @return Returns the "phaseName:speciesName" string - */ + //! This is guaranteed to be unique within a Cantera problem. + //! @param k Species index within the phase + //! @return The "phaseName:speciesName" string std::string speciesSPName(int k) const; - /// Return a const reference to the vector of species names + //! 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; } + //!@} end group Element and Species Information //! Save the current internal state of the phase - /*! - * Write to vector 'state' the current internal state. - * - * @param state output vector. Will be resized to nSpecies() + 2 on return. - */ + //! Write to vector 'state' the current internal state. + //! @param state output vector. Will be resized to nSpecies() + 2. void saveState(vector_fp& state) const; //! Write to array 'state' the current internal state. - /*! - * @param lenstate length of the state array. Must be >= nSpecies() + 2 - * @param state output vector. Must be of length nSpecies() + 2 or - * greater. - */ + //! @param lenstate length of the state array. Must be >= nSpecies()+2 + //! @param state output vector. Must be of length nSpecies() + 2 or + //! greater. void saveState(size_t lenstate, doublereal* state) const; - //!Restore a state saved on a previous call to saveState. - /*! - * @param state State vector containing the previously saved state. - */ + //! Restore a state saved on a previous call to saveState. + //! @param state State vector containing the previously saved state. void restoreState(const vector_fp& state); //! Restore the state of the phase from a previously saved state vector. - /*! - * @param lenstate Length of the state vector - * @param state Vector of state conditions. - */ + //! @param lenstate Length of the state vector + //! @param state Vector of state conditions. void restoreState(size_t lenstate, const doublereal* state); - /** - * Set the species mole fractions by name. - * @param xMap map from species names to mole fraction values. - * Species not listed by name in \c xMap are set to zero. + /*! @name Set thermodynamic state + * Set the internal thermodynamic state by setting the internally stored + * temperature, density and species composition. Note that the composition + * is always set first. + * + * Temperature and density are held constant if not explicitly set. */ + //!@{ + + //! Set the species mole fractions by name. + //! @param xMap map from species names to mole fraction values. + //! Species not listed by name in \c xMap are set to zero. void setMoleFractionsByName(compositionMap& xMap); - //! Set the mole fractions of a group of species by name - /*! - * The string x is in the form of a composition map - * Species which are not listed by name in the composition - * map are set to zero. - * - * @param x string x in the form of a composition map - */ + //! Set the mole fractions of a group of species by name. Species which + //! are not listed by name in the composition map are set to zero. + //! @param x string x in the form of a composition map void setMoleFractionsByName(const std::string& x); - /** - * Set the species mass fractions by name. - * @param yMap map from species names to mass fraction values. - * Species not listed by name in \c yMap are set to zero. - */ + //! Set the species mass fractions by name. + //! @param yMap map from species names to mass fraction values. + //! Species not listed by name in \c yMap are set to zero. void setMassFractionsByName(compositionMap& yMap); - //! Set the species mass fractions by name. - /*! - * Species not listed by name in \c x are set to zero. - * - * @param x String containing a composition map - */ + //! Species not listed by name in \c x are set to zero. + //! @param x String containing a composition map void setMassFractionsByName(const std::string& x); //! Set the internally stored temperature (K), density, and mole fractions. - /*! - * Note, the mole fractions are always set first, before the density - * - * @param t Temperature in kelvin - * @param dens Density (kg/m^3) - * @param x vector of species mole fractions, length m_kk - */ + //! @param t Temperature in kelvin + //! @param dens Density (kg/m^3) + //! @param x vector of species mole fractions, length m_kk void setState_TRX(doublereal t, doublereal dens, const doublereal* x); - //! Set the internally stored temperature (K), density, and mole fractions. - /*! - * Note, the mole fractions are always set first, before the density - * - * @param t Temperature in kelvin - * @param dens Density (kg/m^3) - * @param x Composition Map containing the mole fractions. - * Species not included in the map are assumed to have - * a zero mole fraction. - */ + //! @param t Temperature in kelvin + //! @param dens Density (kg/m^3) + //! @param x Composition Map containing the mole fractions. + //! Species not included in the map are assumed to have + //! a zero mole fraction. void setState_TRX(doublereal t, doublereal dens, compositionMap& x); //! Set the internally stored temperature (K), density, and mass fractions. - /*! - * Note, the mass fractions are always set first, before the density - * - * @param t Temperature in kelvin - * @param dens Density (kg/m^3) - * @param y vector of species mass fractions, length m_kk - */ + //! @param t Temperature in kelvin + //! @param dens Density (kg/m^3) + //! @param y vector of species mass fractions, length m_kk void setState_TRY(doublereal t, doublereal dens, const doublereal* y); //! Set the internally stored temperature (K), density, and mass fractions. - /*! - * Note, the mass fractions are always set first, before the density - * - * @param t Temperature in kelvin - * @param dens Density (kg/m^3) - * @param y Composition Map containing the mass fractions. - * Species not included in the map are assumed to have - * a zero mass fraction. - */ + //! @param t Temperature in kelvin + //! @param dens Density (kg/m^3) + //! @param y Composition Map containing the mass fractions. + //! Species not included in the map are assumed to have + //! a zero mass fraction. void setState_TRY(doublereal t, doublereal dens, compositionMap& y); //! Set the internally stored temperature (K), molar density (kmol/m^3), and mole fractions. - /*! - * Note, the mole fractions are always set first, before the molar density - * - * @param t Temperature in kelvin - * @param n molar density (kmol/m^3) - * @param x vector of species mole fractions, length m_kk - */ + //! @param t Temperature in kelvin + //! @param n molar density (kmol/m^3) + //! @param x vector of species mole fractions, length m_kk void setState_TNX(doublereal t, doublereal n, const doublereal* x); //! Set the internally stored temperature (K) and density (kg/m^3) - /*! - * @param t Temperature in kelvin - * @param rho Density (kg/m^3) - */ + //! @param t Temperature in kelvin + //! @param rho Density (kg/m^3) void setState_TR(doublereal t, doublereal rho); //! Set the internally stored temperature (K) and mole fractions. - /*! - * @param t Temperature in kelvin - * @param x vector of species mole fractions, length m_kk - */ + //! @param t Temperature in kelvin + //! @param x vector of species mole fractions, length m_kk void setState_TX(doublereal t, doublereal* x); //! Set the internally stored temperature (K) and mass fractions. - /*! - * @param t Temperature in kelvin - * @param y vector of species mass fractions, length m_kk - */ + //! @param t Temperature in kelvin + //! @param y vector of species mass fractions, length m_kk void setState_TY(doublereal t, doublereal* y); //! Set the density (kg/m^3) and mole fractions. - /*! - * @param rho Density (kg/m^3) - * @param x vector of species mole fractions, length m_kk - */ + //! @param rho Density (kg/m^3) + //! @param x vector of species mole fractions, length m_kk void setState_RX(doublereal rho, doublereal* x); //! Set the density (kg/m^3) and mass fractions. - /*! - * @param rho Density (kg/m^3) - * @param y vector of species mass fractions, length m_kk - */ + //! @param rho Density (kg/m^3) + //! @param y vector of species mass fractions, length m_kk void setState_RY(doublereal rho, doublereal* y); + //!@} end group set thermo state + //! Molecular weight of species \c k. - /*! - * @param k index of species \c k - * @return Returns the 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 - */ + //! 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. - * - * @param weights Output vector of molecular weights (kg/kmol) - */ + //! Copy the vector of molecular weights into vector weights. + //! @param weights Output vector of molecular weights (kg/kmol) void getMolecularWeights(vector_fp& weights) const; - /** - * Copy the vector of molecular weights into array weights. - * - * @param iwt Unused. - * @param weights Output array of molecular weights (kg/kmol) - * - * @deprecated - */ + //! Copy the vector of molecular weights into array weights. + //! @param iwt Unused. + //! @param weights Output array of molecular weights (kg/kmol) + //! @deprecated DEPRECATED(void getMolecularWeights(int iwt, doublereal* weights) const); - /** - * Copy the vector of molecular weights into array weights. - * - * @param weights Output array of molecular weights (kg/kmol) - */ + //! Copy the vector of molecular weights into array weights. + //! @param weights Output array of molecular weights (kg/kmol) void getMolecularWeights(doublereal* weights) const; - /** - * Return a const reference to the internal vector of molecular weights. - * units = kg / kmol - */ + //! 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. - */ + //! This routine returns the size of species k + //! @param k index of the species + //! @return The size of the species. Units are meters. doublereal size(size_t k) const { return m_speciesSize[k]; } - /** - * Get the mole fractions by name. - * - * @param x Output composition map containing the - * species mole fractions. - */ - void getMoleFractionsByName(compositionMap& x) const; - - //! Return the mole fraction of a single species - /*! - * @param k species index - * @return Mole fraction of the species - */ - doublereal moleFraction(size_t k) const; - - //! Return the mole fraction of a single species - /*! - * @param name String name of the species - * @return Mole fraction of the species - */ - doublereal moleFraction(std::string name) const; - - //! Return the mass fraction of a single species - /*! - * @param k species index - * @return Mass fraction of the species - */ - doublereal massFraction(size_t k) const; - - //! Return the mass fraction of a single species - /*! - * @param name String name of the species - * @return Mass Fraction of the species - */ - doublereal massFraction(std::string name) const; - - //@} /// @name Composition //@{ + //! Get the mole fractions by name. + //! @param[out] x composition map containing the species mole fractions. + void getMoleFractionsByName(compositionMap& x) const; + + //! Return the mole fraction of a single species + //! @param k species index + //! @return Mole fraction of the species + doublereal moleFraction(size_t k) const; + + //! Return the mole fraction of a single species + //! @param name String name of the species + //! @return Mole fraction of the species + doublereal moleFraction(std::string name) const; + + //! Return the mass fraction of a single species + //! @param k species index + //! @return Mass fraction of the species + doublereal massFraction(size_t k) const; + + //! Return the mass fraction of a single species + //! @param name String name of the species + //! @return Mass Fraction of the species + doublereal massFraction(std::string name) const; + //! Get the species mole fraction vector. - /*! - * @param x On return, x contains the mole fractions. Must have a - * length greater than or equal to the number of species. - */ + //! @param x On return, x contains the mole fractions. Must have a + //! length greater than or equal to the number of species. void getMoleFractions(doublereal* const x) const; - //! Set the mole fractions to the specified values, and then - //! normalize them so that they sum to 1.0. - /*! - * @param x Array of unnormalized mole fraction values (input). - * Must have a length greater than or equal to the number of - * species, m_kk. There is no restriction - * on the sum of the mole fraction vector. Internally, - * the State object will normalize this vector before - * storing its contents. - */ + //! Set the mole fractions to the specified values + //! There is no restriction on the sum of the mole fraction vector. + //! Internally, the Phase object will normalize this vector before storing + //! its contents. + //! @param x Array of unnormalized mole fraction values (input). Must + //! have a length greater than or equal to the number of species, m_kk. virtual void setMoleFractions(const doublereal* const x); - /** - * Set the mole fractions to the specified values without - * normalizing. This is useful when the normalization - * condition is being handled by some other means, for example - * by a constraint equation as part of a larger set of - * equations. - * - * @param x Input vector of mole fractions. - * Length is m_kk. - */ + //! Set the mole fractions to the specified values without normalizing. + //! This is useful when the normalization condition is being handled by + //! some other means, for example by a constraint equation as part of a + //! larger set of equations. + //! @param x Input vector of mole fractions. Length is m_kk. virtual void setMoleFractions_NoNorm(const doublereal* const x); //! Get the species mass fractions. - /*! - * @param y On return, y contains the mass fractions. Array \a y must have a length - * greater than or equal to the number of species. - */ + //! @param[out] y Array of mass fractions, length nSpecies() void getMassFractions(doublereal* const y) const; - //! Returns a read-only pointer to the start of the massFraction array - /*! - * @return returns a pointer to a vector of doubles of length m_kk. - */ + //! Return a const pointer to the mass fraction array const doublereal* massFractions() const { return &m_y[0]; } - //! Set the mass fractions to the specified values, and then - //! normalize them so that they sum to 1.0. - /*! - * @param y Array of unnormalized mass fraction values (input). - * Must have a length greater than or equal to the number of species. - * Input vector of mass fractions. There is no restriction - * on the sum of the mass fraction vector. Internally, - * the State object will normalize this vector before - * storing its contents. - * Length is m_kk. - */ + //! Set the mass fractions to the specified values and normalize them. + //! @param[in] y Array of unnormalized mass fraction values. Length + //! must be greater than or equal to the number of species. The Ptate + //! object will normalize this vector before storing its contents. virtual void setMassFractions(const doublereal* const y); //! Set the mass fractions to the specified values without normalizing. - /*! - * This is useful when the normalization - * condition is being handled by some other means, for example - * by a constraint equation as part of a larger set of equations. - * - * @param y Input vector of mass fractions. - * Length is m_kk. - */ + //! This is useful when the normalization condition is being handled by + //! some other means, for example by a constraint equation as part of a + //! larger set of equations. + //! @param y Input vector of mass fractions. Length is m_kk. virtual void setMassFractions_NoNorm(const doublereal* const y); - /** - * Get the species concentrations (kmol/m^3). @param c On - * return, \a c contains the concentrations for all species. - * Array \a c must have a length greater than or equal to the - * number of species. - */ + //! Get the species concentrations (kmol/m^3). + //! @param[out] c Array of species concentrations Length must be + //! greater than or equal to the number of species. void getConcentrations(doublereal* const c) const; - /** - * Concentration of species k. If k is outside the valid - * range, an exception will be thrown. - * - * @param k Index of species - */ + //! Concentration of species k. + //! If k is outside the valid range, an exception will be thrown. + //! @param k Index of species doublereal concentration(const size_t k) const; - //! Set the concentrations to the specified values within the - //! phase. - /*! - * We set the concentrations here and therefore we set the - * overall density of the phase. We hold the temperature constant - * during this operation. Therefore, we have possibly changed - * the pressure of the phase by calling this routine. - * - * @param conc The input vector to this routine is in dimensional - * units. For volumetric phases c[k] is the - * concentration of the kth species in kmol/m3. - * For surface phases, c[k] is the concentration - * in kmol/m2. The length of the vector is the number - * of species in the phase. - */ + //! Set the concentrations to the specified values within the phase. + //! We set the concentrations here and therefore we set the overall density + //! of the phase. We hold the temperature constant during this operation. + //! Therefore, we have possibly changed the pressure of the phase by + //! calling this routine. + //! @param conc[in] Array of concentrations in dimensional units. For + //! bulk phases c[k] is the concentration of the kth species in kmol/m3. + //! For surface phases, c[k] is the concentration in kmol/m2. The length of + //! the vector is the numberof species in the phase. virtual void setConcentrations(const doublereal* const conc); - /** - * Returns a read-only pointer to the start of the - * moleFraction/MW array. This array is the array of mole - * fractions, each divided by the mean molecular weight. - */ + //! Returns a const pointer to the start of the moleFraction/MW array. + //! This array is the array of mole fractions, each divided by the mean + //! molecular weight. const doublereal* moleFractdivMMW() 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 - */ + //! Dimensionless electrical charge of a single molecule of species k + //! The charge is normalized by the the magnitude of the electron charge + //! ( \f$ e = 1.602\times 10^{-19}\f$ Coulombs). + //! @param k species index doublereal charge(size_t k) const; - /** - * Charge density [C/m^3]. - */ + //! Charge density [C/m^3]. doublereal chargeDensity() const; - /// Returns the number of spatial dimensions (1, 2, or 3) + //! Returns the number of spatial dimensions (1, 2, or 3) size_t nDim() const { return m_ndim; } - //! Set the number of spatial dimensions (1, 2, or 3) - /*! - * The number of spatial dimensions is used for vector involving - * directions. - * - * @param ndim Input number of dimensions. - */ + //! Set the number of spatial dimensions (1, 2, or 3). The number of + //! spatial dimensions is used for vector involving directions. + //! @param ndim Input number of dimensions. void setNDim(size_t ndim) { m_ndim = ndim; } - /// @name Thermodynamic Properties - /// Class Phase only stores enough thermodynamic data to - /// specify the state. In addition to composition information, - /// it stores the temperature and mass density. - //@{ + //! @name Thermodynamic Properties + //!@{ //! Temperature (K). - /*! - * @return Returns the temperature of the phase - */ + //! @return The temperature of the phase doublereal temperature() const { return m_temp; } //! Density (kg/m^3). - /*! - * @return Returns the density of the phase - */ + //! @return The density of the phase virtual doublereal density() const { return m_dens; } //! Molar density (kmol/m^3). - /*! - * @return Returns the molar density of the phase - */ + //! @return The molar density of the phase doublereal molarDensity() const; //! Molar volume (m^3/kmol). - /*! - * @return Returns the molar volume of the phase - */ + //! @return The molar volume of the phase doublereal molarVolume() const; //! Set the internally stored density (kg/m^3) of the phase - /*! - * Note the density of a phase is an indepedent variable. - * - * @param density Input density (kg/m^3). - */ + //! Note the density of a phase is an independent variable. + //! @param[in] density density (kg/m^3). virtual void setDensity(const doublereal density) { m_dens = density; } //! Set the internally stored molar density (kmol/m^3) of the phase. - /*! - * @param molarDensity Input molar density (kmol/m^3). - */ + //! @param[in] molarDensity Input molar density (kmol/m^3). virtual void setMolarDensity(const doublereal molarDensity); - //! Set the temperature (K). - /*! - * This function sets the internally stored temperature of the phase. - * - * @param temp Temperature in kelvin - */ + //! Set the internally stored temperature of the phase (K). + //! @param temp Temperature in Kelvin virtual void setTemperature(const doublereal temp) { m_temp = temp; } //@} - /// @name Mean Properties - //@{ - /** - * Evaluate the mole-fraction-weighted mean of Q: - * \f[ \sum_k X_k Q_k. \f] - * Array Q should contain pure-species molar property - * values. - * - * @param Q input vector of length m_kk that is to be averaged. - * @return - * mole-freaction-weighted mean of Q - */ + //! @name Mean Properties + //!@{ + + //! Evaluate the mole-fraction-weighted mean of an array \ref Q. + //! \f[ \sum_k X_k Q_k. \f] + //! Q should contain pure-species molar property values. + //! @param[in] Q Array of length m_kk that is to be averaged. + //! @return mole-fraction-weighted mean of Q doublereal mean_X(const doublereal* const Q) const; - /** - * Evaluate the mass-fraction-weighted mean of Q: - * \f[ \sum_k Y_k Q_k \f] - * - * @param Q Array Q contains a vector of species property values in mass units. - * @return - * Return value containing the mass-fraction-weighted mean of Q. - */ + //! Evaluate the mass-fraction-weighted mean of an array \ref Q. + //! \f[ \sum_k Y_k Q_k \f] + //! @param[in] Q Array of species property values in mass units. + //! @return The mass-fraction-weighted mean of Q. doublereal mean_Y(const doublereal* const Q) const; - /** - * The mean molecular weight. Units: (kg/kmol) - */ + //! The mean molecular weight. Units: (kg/kmol) doublereal meanMolecularWeight() const { return m_mmw; } //! Evaluate \f$ \sum_k X_k \log X_k \f$. - /*! - * @return - * returns the indicated sum. units are dimensionless. - */ + //! @return The indicated sum. Dimensionless. doublereal sum_xlogx() const; //! Evaluate \f$ \sum_k X_k \log Q_k \f$. - /*! - * @param Q Vector of length m_kk to take the log average of - * @return Returns the indicated sum. - */ + //! @param Q Vector of length m_kk to take the log average of + //! @return The indicated sum. 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. - //@{ + //! @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. - */ + //! @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. - */ + //! @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. - */ + //! 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); + 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. - */ + //! 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 - */ + //! @param phase Reference to the root XML_Node of a phase void addElementsFromXML(const XML_Node& phase); - /// Prohibit addition of more elements, and prepare to add species. + //! Prohibit addition of more elements, and prepare to add species. void freezeElements(); - /// True if freezeElements has been called. + //! 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); + //! 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. + 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. - */ + //! 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. void addUniqueSpecies(const std::string& name, const doublereal* comp, doublereal charge = 0.0, doublereal size = 1.0); - //@} + //!@} end group adding species and elements - /** - * Finished adding species, prepare to use them for calculation - * of mixture properties. - */ + //! Call when finished adding species. + //! Prepare to use them for calculation of mixture properties. virtual void freezeSpecies(); - /// True if freezeSpecies has been called. + //! True if freezeSpecies has been called. bool speciesFrozen() { return m_speciesFrozen; } virtual bool ready() const; - /// Remove all elements and species + //! Remove all elements and species void clear(); //! Return the State Mole Fraction Number @@ -939,173 +637,88 @@ public: return m_stateNum; } - //! Every time the mole fractions have changed, this routine - //! will increment the stateMFNumber - /*! - * @param forceChange If this is true then the stateMFNumber always - * changes. This defaults to false. - * @deprecated - */ + //! Every time the mole fractions have changed, this routine will increment + //! the stateMFNumber + //! @param forceChange If this is true then the stateMFNumber always + //! changes. This defaults to false. + //! @deprecated DEPRECATED(void stateMFChangeCalc(bool forceChange = false)); protected: - /** - * @internal - * Initialize. Make a local copy of the vector of - * molecular weights, and resize the composition arrays to - * the appropriate size. The only information an instance of - * State has about the species is their molecular weights. - * - * @param mw Vector of molecular weights of the species. - */ + //! @internal Initialize. + //! Make a local copy of the vector of molecular weights, and resize the + //! composition arrays to the appropriate size. + //! @param mw Vector of molecular weights of the species. void init(const vector_fp& mw); //! Set the molecular weight of a single species to a given value - /*! - * @param k id of the species - * @param mw Molecular Weight (kg kmol-1) - */ + //! @param k id of the species + //! @param mw Molecular Weight (kg kmol-1) void setMolecularWeight(const int k, const double mw) { m_molwts[k] = mw; m_rmolwts[k] = 1.0/mw; } - /** - * m_kk = Number of species in the phase. @internal m_kk is a - * member of both the State and Constituents classes. - * Therefore, to avoid multiple inheritance problems, we need - * to restate it in here, so that the declarations in the two - * base classes become hidden. - */ - size_t m_kk; + size_t m_kk; //!< Number of species in the phase. - /** - * m_ndim is the dimensionality of the phase. Volumetric - * phases have dimensionality 3 and surface phases have - * dimensionality 2. - */ + //! Dimensionality of the phase. Volumetric phases have dimensionality 3 + //! and surface phases have dimensionality 2. 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 - */ + //! Atomic composition of the species. The number of atoms of element 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 of species sizes. length m_kk. Used in some equations of state + //! which employ the constant partial molar volume approximation. vector_fp m_speciesSize; - /** - * m_speciesCharge: Vector of species charges - * length = m_kk - */ - vector_fp m_speciesCharge; + vector_fp m_speciesCharge; //!< Vector of species charges. length m_kk. private: - //! This stores the initial state of the system - /*! - * @deprecated - * This doesn't seem to be used much anymore. - */ - vector_fp m_data; + XML_Node* m_xml; //!< XML node containing the XML info for this phase - //! Pointer to the XML node containing the XML info for this phase - XML_Node* m_xml; - - //! ID of the phase. - /*! - * This is the value of the ID attribute of the XML phase node. - * The field will stay that way even if the name is changed. - */ + //! ID of the phase. This is the value of the ID attribute of the XML + //! phase node. The field will stay that way even if the name is changed. std::string m_id; //! Name of the phase. - /*! - * Initially, this is the value of the ID attribute of the XML phase node. - * - * It may be changed to another value during the course of a calculation. - * for example, if a phase is located in two places, but has the same - * constituitive input, the id's of the two phases will be the same, - * but the names of the two phases may be different. - * - * The name can be the same as the id, within a phase. However, besides - * that case, it is expected that there is a 1-1 correspondence between - * names and unique phases within a Cantera problem. - */ + //! Initially, this is the value of the ID attribute of the XML phase node. + //! It may be changed to another value during the course of a calculation. std::string m_name; - /** - * Temperature. This is an independent variable - * units = Kelvin - */ - doublereal m_temp; + doublereal m_temp; //!< Temperature (K). This is an independent variable - /** - * Density. This is an independent variable except in - * the incompressible degenerate case. Thus, - * the pressure is determined from this variable - * not the other way round. - * units = kg m-3 - */ + //! Density (kg m-3). This is an independent variable except in the + //! incompressible degenerate case. Thus, the pressure is determined from + //! this variable rather than other way round. doublereal m_dens; - /** - * m_mmw is the mean molecular weight of the mixture - * (kg kmol-1) - */ - doublereal m_mmw; + doublereal m_mmw; //!< mean molecular weight of the mixture (kg kmol-1) - /** - * m_ym[k] = mole fraction of species k divided by the - * mean molecular weight of mixture. - */ + //! m_ym[k] = mole fraction of species k divided by the mean molecular + //! weight of mixture. mutable vector_fp m_ym; - /** - * m_y[k] = mass fraction of species k - */ - mutable vector_fp m_y; + mutable vector_fp m_y; //!< species mass fractions - /** - * m_molwts[k] = molecular weight of species k (kg kmol-1) - */ - vector_fp m_molwts; + vector_fp m_molwts; //!< species molecular weights (kg kmol-1) - /** - * m_rmolwts[k] = inverse of the molecular weight of species k - * units = kmol kg-1. - */ - vector_fp m_rmolwts; + vector_fp m_rmolwts; //!< inverse of species molecular weights (kmol kg-1) - //! State Change variable - /*! - * Whenever the mole fraction vector changes, this int is - * incremented. - * @deprecated - */ + //! State Change variable. Whenever the mole fraction vector changes, + //! this int is incremented. + //! @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. - */ + //! 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. - */ + //! 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 diff --git a/src/thermo/Phase.cpp b/src/thermo/Phase.cpp index 2c7047165..bb2086c49 100644 --- a/src/thermo/Phase.cpp +++ b/src/thermo/Phase.cpp @@ -1,8 +1,6 @@ /** * @file Phase.cpp - * Definition file for class, Phase, which contains functions for setting the - * state of a phase, and for referencing species by name - * (see \ref phases and class \link Cantera::Phase Phase\endlink). + * Definition file for class Phase. */ // Copyright 2001 California Institute of Technology @@ -33,16 +31,10 @@ Phase::Phase() : m_Elements->subscribe(); } -/* - * Copy Constructor - * - * This function just does the default initialization, and - * then calls the assignment operator. - */ Phase::Phase(const Phase& right) : m_kk(0), m_ndim(3), - m_xml(new XML_Node("phase")), + m_xml(0), m_id(""), m_name(""), m_temp(0.0), @@ -52,9 +44,7 @@ Phase::Phase(const Phase& right) : m_speciesFrozen(false) , m_Elements(0) { - /* - * Call the assignment operator. - */ + // Use the assignment operator to do the actual copying *this = operator=(right); } @@ -66,18 +56,17 @@ Phase& Phase::operator=(const Phase& right) } // Handle our own data - m_kk = right.m_kk; - m_ndim = right.m_ndim; - m_data = right.m_data; - m_temp = right.m_temp; - m_dens = right.m_dens; - m_mmw = right.m_mmw; - m_ym = right.m_ym; - m_y = right.m_y; - m_molwts = right.m_molwts; - m_rmolwts = right.m_rmolwts; + m_kk = right.m_kk; + m_ndim = right.m_ndim; + m_temp = right.m_temp; + m_dens = right.m_dens; + m_mmw = right.m_mmw; + m_ym = right.m_ym; + m_y = right.m_y; + m_molwts = right.m_molwts; + m_rmolwts = right.m_rmolwts; m_stateNum = -1; - m_speciesFrozen = right.m_speciesFrozen; + m_speciesFrozen = right.m_speciesFrozen; if (m_Elements) { int nleft = m_Elements->unsubscribe(); if (nleft <= 0) { @@ -92,14 +81,14 @@ Phase& Phase::operator=(const Phase& right) delete m_Elements; } } - m_Elements = right.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; + 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 @@ -112,7 +101,7 @@ Phase& Phase::operator=(const Phase& right) m_xml = 0; } if (right.m_xml) { - m_xml = new XML_Node(); + m_xml = new XML_Node(); (right.m_xml)->copy(m_xml); } m_id = right.m_id; @@ -248,27 +237,6 @@ void Phase::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 - * phase will have an index of nSpecies() - 1. - * - * - * A species name may be referred to via three methods: - * - * - "speciesName" - * - "PhaseId:speciesName" - * - "phaseName:speciesName" - * . - * - * The first two methods of naming may not yield a unique species within - * complicated assemblies of Cantera Phases. - * - * @param nameStr String name of the species. It may also be the phase name - * species name combination, separated by a colon. - * @return Returns the index of the species. If the name is not found, - * the value of -1 is returned. - */ size_t Phase::speciesIndex(std::string nameStr) const { std::string pn; @@ -438,79 +406,65 @@ void Phase::setMassFractionsByName(const std::string& y) setMassFractionsByName(yy); } -/** Set the temperature (K), density (kg/m^3), and mole fractions. */ -void Phase::setState_TRX(doublereal t, doublereal dens, - const doublereal* x) +void Phase::setState_TRX(doublereal t, doublereal dens, const doublereal* x) { setMoleFractions(x); setTemperature(t); setDensity(dens); } -void Phase::setState_TNX(doublereal t, doublereal n, - const doublereal* x) +void Phase::setState_TNX(doublereal t, doublereal n, const doublereal* x) { setMoleFractions(x); setTemperature(t); setMolarDensity(n); } -/** Set the temperature (K), density (kg/m^3), and mole fractions. */ -void Phase::setState_TRX(doublereal t, doublereal dens, - compositionMap& x) +void Phase::setState_TRX(doublereal t, doublereal dens, compositionMap& x) { setMoleFractionsByName(x); setTemperature(t); setDensity(dens); } -/** Set the temperature (K), density (kg/m^3), and mass fractions. */ -void Phase::setState_TRY(doublereal t, doublereal dens, - const doublereal* y) +void Phase::setState_TRY(doublereal t, doublereal dens, const doublereal* y) { setMassFractions(y); setTemperature(t); setDensity(dens); } -/** Set the temperature (K), density (kg/m^3), and mass fractions. */ -void Phase::setState_TRY(doublereal t, doublereal dens, - compositionMap& y) +void Phase::setState_TRY(doublereal t, doublereal dens, compositionMap& y) { setMassFractionsByName(y); setTemperature(t); setDensity(dens); } -/** Set the temperature (K) and density (kg/m^3) */ void Phase::setState_TR(doublereal t, doublereal rho) { setTemperature(t); setDensity(rho); } -/** Set the temperature (K) and mole fractions. */ void Phase::setState_TX(doublereal t, doublereal* x) { setTemperature(t); setMoleFractions(x); } -/** Set the temperature (K) and mass fractions. */ void Phase::setState_TY(doublereal t, doublereal* y) { setTemperature(t); setMassFractions(y); } -/** Set the density (kg/m^3) and mole fractions. */ void Phase::setState_RX(doublereal rho, doublereal* x) { setMoleFractions(x); setDensity(rho); } -/** Set the density (kg/m^3) and mass fractions. */ void Phase::setState_RY(doublereal rho, doublereal* y) { setMassFractions(y); @@ -525,9 +479,6 @@ doublereal Phase::molecularWeight(size_t k) const return m_molwts[k]; } -/* - * Copy the vector of molecular weights into vector weights. - */ void Phase::getMolecularWeights(vector_fp& weights) const { const vector_fp& mw = molecularWeights(); @@ -537,10 +488,6 @@ void Phase::getMolecularWeights(vector_fp& weights) const copy(mw.begin(), mw.end(), weights.begin()); } -/* - * Copy the vector of molecular weights into array weights. - * @deprecated - */ void Phase::getMolecularWeights(int iwt, doublereal* weights) const { const vector_fp& mw = molecularWeights(); @@ -558,9 +505,6 @@ const vector_fp& Phase::molecularWeights() const return m_molwts; } -/** - * Get the mole fractions by name. - */ void Phase::getMoleFractionsByName(compositionMap& x) const { x.clear(); @@ -720,9 +664,11 @@ void Phase::addElement(const XML_Node& e) } void Phase::addUniqueElement(const std::string& symbol, doublereal weight, - int atomicNumber, doublereal entropy298, int elem_type) + int atomicNumber, doublereal entropy298, + int elem_type) { - m_Elements->addUniqueElement(symbol, weight, atomicNumber, entropy298, elem_type); + m_Elements->addUniqueElement(symbol, weight, atomicNumber, + entropy298, elem_type); } void Phase::addUniqueElement(const XML_Node& e) @@ -745,7 +691,8 @@ bool Phase::elementsFrozen() return m_Elements->elementsFrozen(); } -size_t Phase::addUniqueElementAfterFreeze(const std::string& symbol, doublereal weight, int atomicNumber, +size_t Phase::addUniqueElementAfterFreeze(const std::string& symbol, + doublereal weight, int atomicNumber, doublereal entropy298, int elem_type) { size_t ii = elementIndex(symbol); @@ -783,7 +730,8 @@ void Phase::addSpecies(const std::string& name, const doublereal* comp, 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 + // 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]; @@ -797,14 +745,17 @@ void Phase::addSpecies(const std::string& name, const doublereal* comp, if (fabs(charge + ecomp) > 0.001) { if (ecomp != 0.0) { throw CanteraError("Phase::addSpecies", - "Input charge and element E compositions differ for species " + name); + "Input charge and element E compositions differ " + "for species " + name); } else { - // Just fix up the element E composition based on the input species charge + // 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); + addUniqueElementAfterFreeze("E", 0.000545, 0, 0.0, + CT_ELEM_TYPE_ELECTRONCHARGE); ne = m_Elements->nElements(); eindex = m_Elements->elementIndex("E"); compNew.resize(ne); @@ -825,11 +776,9 @@ void Phase::addUniqueSpecies(const std::string& name, const doublereal* comp, 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. - */ + // 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]) { @@ -861,10 +810,6 @@ void Phase::freezeSpecies() 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(); } @@ -881,25 +826,21 @@ void Phase::init(const vector_fp& mw) "negative molecular weight for species number " + int2str(k)); } - /* - * Some surface phases may define species representing - * empty sites that have zero molecular weight. Give them - * a very small molecular weight to avoid dividing by - * zero. - */ + + // Some surface phases may define species representing empty sites + // hat have zero molecular weight. Give them a very small molecular + // weight to avoid dividing by zero. if (m_molwts[k] < Tiny) { m_molwts[k] = Tiny; } m_rmolwts[k] = 1.0/m_molwts[k]; } - /* - * Now that we have resized the State object, let's fill it with - * a valid mass fraction vector that sums to one. The State object - * should never have a mass fraction vector that doesn't sum to one. - * We will assume that species 0 has a mass fraction of 1.0 and - * mass fraction of all other species is 0.0. - */ + // Now that we have resized the State object, let's fill it with a valid + // mass fraction vector that sums to one. The Phase object should never + // have a mass fraction vector that doesn't sum to one. We will assume that + // species 0 has a mass fraction of 1.0 and mass fraction of all other + // species is 0.0. m_y[0] = 1.0; m_ym[0] = m_y[0] * m_rmolwts[0]; m_mmw = 1.0 / m_ym[0];