diff --git a/Cantera/src/transport/LTPspecies.cpp b/Cantera/src/transport/LTPspecies.cpp index 17c74db7e..7ca7704b5 100644 --- a/Cantera/src/transport/LTPspecies.cpp +++ b/Cantera/src/transport/LTPspecies.cpp @@ -8,22 +8,23 @@ * $Revision: 427 $ * */ - #include "LTPspecies.h" using namespace std; namespace Cantera { - //==================================================================================================================== - /* - * Exception thrown if an error is encountered while reading the transport database. - */ + //! Exception thrown if an error is encountered while reading the transport database. class LTPError : public CanteraError { public: - LTPError(std::string msg) - : CanteraError("LTPspecies", - "error parsing transport data: " - + msg + "\n") {} + + //! Constructor is a wrapper around CanteraError + /*! + * @param msg Informative message + */ + LTPError(std::string msg) : + CanteraError("LTPspecies", "error parsing transport data: " + msg + "\n") + { + } }; //==================================================================================================================== //! getArrhenius() parses the xml element called Arrhenius. @@ -64,7 +65,7 @@ namespace Cantera { LTPspecies::LTPspecies(const XML_Node * const propNode, std::string name, TransportPropertyType tp_ind, const thermo_t * thermo) : m_speciesName(name), - m_model(LTR_MODEL_NOTSET), + m_model(LTP_TD_NOTSET), m_property(tp_ind), m_thermo(thermo), m_mixWeight(1.0) @@ -79,7 +80,7 @@ namespace Cantera { // Copy constructor LTPspecies::LTPspecies(const LTPspecies &right) { - *this = right; //use assignment operator to do other work + *this = right; } //==================================================================================================================== // Assignment operator @@ -154,7 +155,7 @@ namespace Cantera { TransportPropertyType tp_ind, const thermo_t * const thermo) : LTPspecies(&propNode, name, tp_ind, thermo) { - m_model = LTR_MODEL_CONSTANT; + m_model = LTP_TD_CONSTANT; double A_k = getFloatCurrent(propNode, "toSI"); if (A_k > 0.0) { m_coeffs.push_back(A_k); @@ -218,7 +219,7 @@ namespace Cantera { TransportPropertyType tp_ind, const thermo_t* thermo) : LTPspecies(&propNode, name, tp_ind, thermo) { - m_model = LTR_MODEL_ARRHENIUS; + m_model = LTP_TD_ARRHENIUS; m_temp = 0.0; m_prop = 0.0; @@ -237,21 +238,14 @@ namespace Cantera { LTPspecies_Arrhenius::LTPspecies_Arrhenius(const LTPspecies_Arrhenius &right) : LTPspecies() { - *this = right; //use assignment operator to do other work + *this = right; } //==================================================================================================================== // Assignment operator LTPspecies_Arrhenius& LTPspecies_Arrhenius::operator=(const LTPspecies_Arrhenius& right) { if (&right != this) { - // LTPspecies::operator=(right); - m_speciesName = right.m_speciesName; - m_property = right.m_property; - m_model = right.m_model; - m_coeffs = right.m_coeffs; - m_thermo = right.m_thermo; - m_mixWeight = right.m_mixWeight; - + LTPspecies::operator=(right); m_temp = right.m_temp; m_logt = right.m_logt; m_prop = right.m_prop; @@ -318,54 +312,52 @@ namespace Cantera { return m_prop; } //==================================================================================================================== - // Construct an LTPspecies object for a liquid tranport property - // expressed as a polynomial in temperature. - /* The transport property is constructed from the XML node, - * \verbatim , \endverbatim that is a child of the - * \verbatim \endverbatim node and specifies a type of - * transport property (like viscosity) + // Construct an LTPspecies object for a liquid tranport property expressed as a polynomial in temperature. + /* + * The transport property is constructed from the XML node, \verbatim , \endverbatim that is a child of the + * \verbatim \endverbatim node and specifies a type of transport property (like viscosity). + * + * + * @param propNode Referenc to the XML node that contains the property information. This class + * must be parameterized by reading XML_Node information. + * @param name String containing the species name + * @param tp_ind enum TransportPropertyType containing the property id that this object + * is creating a parameterization for (e.g., viscosity) + * @param thermo const pointer to the ThermoPhase object, which is used to find the temperature. + * */ LTPspecies_Poly::LTPspecies_Poly(const XML_Node &propNode, std::string name, TransportPropertyType tp_ind, const thermo_t* thermo) : - LTPspecies(&propNode, name, tp_ind, thermo) + LTPspecies(&propNode, name, tp_ind, thermo), + m_temp(-1.0), + m_prop(0.0) { - m_model = LTR_MODEL_POLY; - m_temp = 0.0; - m_prop = 0.0; - - + m_model = LTP_TD_POLY; getFloatArray(propNode, m_coeffs, "true", "toSI"); - - /* if (m_coeffs[0] <= 0.0) { - throw LTPError("negative or zero " + propNode.name()); - }*/ } //==================================================================================================================== // Copy constructor LTPspecies_Poly::LTPspecies_Poly(const LTPspecies_Poly &right) : LTPspecies() { - *this = right; //use assignment operator to do other work + *this = right; } //==================================================================================================================== // Assignment operator LTPspecies_Poly& LTPspecies_Poly::operator=(const LTPspecies_Poly& right) { if (&right != this) { - //LTPspecies::operator=(right); - m_speciesName = right.m_speciesName; - m_property = right.m_property; - m_model = right.m_model; - m_coeffs = right.m_coeffs; - m_thermo = right.m_thermo; - m_mixWeight = right.m_mixWeight; - + LTPspecies::operator=(right); m_temp = right.m_temp; m_prop = right.m_prop; } return *this; } //==================================================================================================================== + LTPspecies_Poly::~LTPspecies_Poly() + { + } + //==================================================================================================================== // Duplication routine /* * @return Returns a copy of this routine as a pointer to LTPspecies @@ -376,44 +368,44 @@ namespace Cantera { return (dynamic_cast(prp)); } //==================================================================================================================== - // Return the value for this transport property evaluated - // from the polynomial expression + // Return the value for this transport property evaluated from the polynomial expression doublereal LTPspecies_Poly::getSpeciesTransProp() { - doublereal t = m_thermo->temperature(); if (t != m_temp) { - m_prop = 0; - m_temp=t; + m_prop = 0.0; + m_temp = t; double tempN = 1.0; for (int i = 0; i < (int) m_coeffs.size() ; i++) { m_prop += m_coeffs[i] * tempN; - //cout << "m_coeff = " <temperature(); if (t != m_temp) { - m_prop = 0.0; m_temp=t; - m_prop=m_coeffs[0]; - double tempN = 1.0; + m_prop = m_coeffs[0]; + doublereal tempN = 1.0; + doublereal tmp = 0.0; for (int i = 1; i < (int) m_coeffs.size() ; i++) { tempN *= m_temp; - m_prop *= exp(m_coeffs[i] * tempN); + tmp += m_coeffs[i] * tempN; } + m_prop *= exp(tmp); } - //cout << "m_prop = " << m_prop << endl; return m_prop; } //==================================================================================================================== diff --git a/Cantera/src/transport/LTPspecies.h b/Cantera/src/transport/LTPspecies.h index b0be5b6f1..d8945af6d 100644 --- a/Cantera/src/transport/LTPspecies.h +++ b/Cantera/src/transport/LTPspecies.h @@ -61,13 +61,14 @@ namespace Cantera { * 0 - Independent of temperature * 1 - extended arrhenius form * 2 - polynomial in temperature form + * 3 - exponential temperature polynomial */ - enum LiquidTR_Model { - LTR_MODEL_NOTSET=-1, - LTR_MODEL_CONSTANT, - LTR_MODEL_ARRHENIUS, - LTR_MODEL_POLY, - LTR_MODEL_EXPT + enum LTPTemperatureDependenceType { + LTP_TD_NOTSET=-1, + LTP_TD_CONSTANT, + LTP_TD_ARRHENIUS, + LTP_TD_POLY, + LTP_TD_EXPT }; //==================================================================================================================== @@ -139,13 +140,13 @@ namespace Cantera { //! Check to see if the property evaluation will be positive /*! - * @return returns a boolean + * @return Returns a boolean */ virtual bool checkPositive() const; - //! return the weight mixture + //! Return the weight mixture /*! - * @return returns a single double which is used as a weight + * @return Returns a single double which is used as a weight */ doublereal getMixWeight() const; @@ -164,7 +165,7 @@ namespace Cantera { std::string m_speciesName; //! Model type for the temperature dependence - LiquidTR_Model m_model; + LTPTemperatureDependenceType m_model; //! enum indicating which property this is (i.e viscosity) TransportPropertyType m_property; @@ -291,7 +292,7 @@ namespace Cantera { * * \endverbatim */ - class LTPspecies_Arrhenius : public LTPspecies{ + class LTPspecies_Arrhenius : public LTPspecies { public: @@ -316,13 +317,13 @@ namespace Cantera { //! Copy constructor /*! - * @param Object to be copied + * @param right Object to be copied */ LTPspecies_Arrhenius(const LTPspecies_Arrhenius &right); //! Assignment operator /*! - * @param Object to be copied + * @param right Object to be copied */ LTPspecies_Arrhenius& operator=(const LTPspecies_Arrhenius& right); @@ -403,26 +404,36 @@ namespace Cantera { public: - //! Construct an LTPspecies object for a liquid tranport property - //! expressed as a polynomial in temperature. - /** The transport property is constructed from the XML node, - * \verbatim , \endverbatim that is a child of the - * \verbatim \endverbatim node and specifies a type of - * transport property (like viscosity) - */ - LTPspecies_Poly(const XML_Node &propNode, - std::string name, - TransportPropertyType tp_ind, - const thermo_t * thermo); + //! Construct an LTPspecies object for a liquid tranport property expressed as a polynomial in temperature. + /*! + * The transport property is constructed from the XML node, \verbatim , \endverbatim that is a child of the + * \verbatim \endverbatim node and specifies a type of transport property (like viscosity). + * + * + * @param propNode Referenc to the XML node that contains the property information. This class + * must be parameterized by reading XML_Node information. + * @param name String containing the species name + * @param tp_ind enum TransportPropertyType containing the property id that this object + * is creating a parameterization for (e.g., viscosity) + * @param thermo const pointer to the ThermoPhase object, which is used to find the temperature. + * + */ + LTPspecies_Poly(const XML_Node &propNode, std::string name, TransportPropertyType tp_ind, const thermo_t * thermo); //! Copy constructor + /*! + * @param right Object to be copied + */ LTPspecies_Poly(const LTPspecies_Poly &right); //! Assignment operator - LTPspecies_Poly& operator=(const LTPspecies_Poly& right); + /*! + * @param right Object to be copied + */ + LTPspecies_Poly& operator=(const LTPspecies_Poly& right); //! Destructor - virtual ~LTPspecies_Poly() { } + virtual ~LTPspecies_Poly(); //! Duplication routine /*! @@ -450,8 +461,8 @@ namespace Cantera { //==================================================================================================================== //! Class LTPspecies_ExpT holds transport parameters for a specific liquid-phase species (LTPspecies) - //! when the transport property is expressed as a exponential in temperature. - /** + //! when the transport property is expressed as an exponential in temperature. + /*! * Used for pure species properties with equations of the form * * \f[ @@ -479,18 +490,23 @@ namespace Cantera { public: - //! Construct an LTPspecies object for a liquid tranport property - //! expressed as an exponential in temperature. - /*! - * The transport property is constructed from the XML node, \verbatim , \endverbatim that is a child of the - * \verbatim \endverbatim node and specifies a type of transport property (like viscosity). - * - * @param propNode - */ - LTPspecies_ExpT(const XML_Node &propNode, - std::string name, - TransportPropertyType tp_ind, - const thermo_t* thermo); + //! Construct an LTPspecies object for a liquid tranport property + //! expressed as an exponential in temperature. + /*! + * The transport property is constructed from the XML node, \verbatim , \endverbatim that is a child of the + * \verbatim \endverbatim node and specifies a type of transport property (like viscosity). + * + * + * @param propNode Referenc to the XML node that contains the property information. This class + * must be parameterized by reading XML_Node information. + * @param name String containing the species name + * @param tp_ind enum TransportPropertyType containing the property id that this object + * is creating a parameterization for (e.g., viscosity) + * @param thermo const pointer to the ThermoPhase object, which is used to find the temperature. + * + */ + LTPspecies_ExpT(const XML_Node &propNode, std::string name, + TransportPropertyType tp_ind, const thermo_t* thermo); //! Copy constructor /*! @@ -499,11 +515,15 @@ namespace Cantera { LTPspecies_ExpT(const LTPspecies_ExpT &right); //! Assignment operator + /*! + * @param right Object to be copied + */ LTPspecies_ExpT& operator=(const LTPspecies_ExpT& right); - virtual ~LTPspecies_ExpT() { } + //! Destructor + virtual ~LTPspecies_ExpT(); - //! duplication routine + //! Duplication routine /*! * @return Returns a copy of this routine as a pointer to LTPspecies */ diff --git a/Cantera/src/transport/TransportFactory.cpp b/Cantera/src/transport/TransportFactory.cpp index 79b07a415..4ddb1ce7a 100644 --- a/Cantera/src/transport/TransportFactory.cpp +++ b/Cantera/src/transport/TransportFactory.cpp @@ -253,11 +253,11 @@ namespace Cantera { m_tranPropMap["hydrodynamicRadius"] = TP_HYDRORADIUS; m_tranPropMap["electricalConductivity"] = TP_ELECTCOND; - m_LTRmodelMap[""] = LTR_MODEL_CONSTANT; - m_LTRmodelMap["constant"] = LTR_MODEL_CONSTANT; - m_LTRmodelMap["arrhenius"] = LTR_MODEL_ARRHENIUS; - m_LTRmodelMap["coeffs"] = LTR_MODEL_POLY; - m_LTRmodelMap["exptemp"] = LTR_MODEL_EXPT; + m_LTRmodelMap[""] = LTP_TD_CONSTANT; + m_LTRmodelMap["constant"] = LTP_TD_CONSTANT; + m_LTRmodelMap["arrhenius"] = LTP_TD_ARRHENIUS; + m_LTRmodelMap["coeffs"] = LTP_TD_POLY; + m_LTRmodelMap["exptemp"] = LTP_TD_EXPT; m_LTImodelMap[""] = LTI_MODEL_NOTSET; m_LTImodelMap["none"] = LTI_MODEL_NONE; @@ -309,16 +309,16 @@ namespace Cantera { LTPspecies* ltps = 0; std::string model = lowercase(trNode["model"]); switch (m_LTRmodelMap[model]) { - case LTR_MODEL_CONSTANT: + case LTP_TD_CONSTANT: ltps = new LTPspecies_Const(trNode, name, tp_ind, thermo); break; - case LTR_MODEL_ARRHENIUS: + case LTP_TD_ARRHENIUS: ltps = new LTPspecies_Arrhenius(trNode, name, tp_ind, thermo); break; - case LTR_MODEL_POLY: + case LTP_TD_POLY: ltps = new LTPspecies_Poly(trNode, name, tp_ind, thermo); break; - case LTR_MODEL_EXPT: + case LTP_TD_EXPT: ltps = new LTPspecies_ExpT(trNode, name, tp_ind, thermo); break; default: @@ -1202,7 +1202,7 @@ namespace Cantera { else if (trParam.thermo->speciesIndex(velocityBasis) > 0) trParam.velocityBasis_ = trParam.thermo->speciesIndex(velocityBasis) ; else { - int linenum; + int linenum = __LINE__; throw TransportDBError(linenum, "Unknown attribute \"" + velocityBasis + "\" for node. "); } } diff --git a/Cantera/src/transport/TransportFactory.h b/Cantera/src/transport/TransportFactory.h index ec6ccd973..d69e9519a 100644 --- a/Cantera/src/transport/TransportFactory.h +++ b/Cantera/src/transport/TransportFactory.h @@ -448,7 +448,7 @@ namespace Cantera { //! Mapping between between the string name for a //! species-specific transport property model and the integer name. - std::map m_LTRmodelMap; + std::map m_LTRmodelMap; //! Mapping between between the string name for a //! liquid mixture transport property model and the integer name.