From c14ec7268a680612e58d1e7209376b84d60dcb7a Mon Sep 17 00:00:00 2001 From: John Hewson Date: Fri, 20 Nov 2009 04:05:04 +0000 Subject: [PATCH] Created LTPspecies, LTPspecies_Const, LTPspecies_Arrhenius, LTPspecies_Poly classes to hole a single transport property for a single species. The class LiquidTransportData now holds pointers to these LTPspecies classes. It does not need to hold the model type or the coefficients as these are contained in the LTPspecies classes. --- Cantera/src/transport/LiquidTransportData.cpp | 303 ++++++++++++++++++ Cantera/src/transport/LiquidTransportData.h | 271 ++++++++++++++-- Cantera/src/transport/LiquidTransportParams.h | 12 + Cantera/src/transport/Makefile.in | 6 +- 4 files changed, 561 insertions(+), 31 deletions(-) create mode 100644 Cantera/src/transport/LiquidTransportData.cpp diff --git a/Cantera/src/transport/LiquidTransportData.cpp b/Cantera/src/transport/LiquidTransportData.cpp new file mode 100644 index 000000000..baba4c142 --- /dev/null +++ b/Cantera/src/transport/LiquidTransportData.cpp @@ -0,0 +1,303 @@ +/** + * @file LiquidTransportData.cpp + * Source code for liquid transport property evaluations. + */ +/* + * $Author: jchewso $ + * $Date: 2009-11-16 17:34:46 -0700 (Mon, 16 Nov 2009) $ + * $Revision: 261 $ + * + */ + +#include "LiquidTransportData.h" + + +namespace Cantera { + + + + /** + * 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") {} + }; + + + /** + * getArrhenius() parses the xml element called Arrhenius. + * The Arrhenius expression is + * \f[ k = A T^(b) exp (-E_a / RT). \f] + */ + static void getArrhenius(const XML_Node& node, + doublereal& A, doublereal& b, doublereal& E) { + /* parse the children for the A, b, and E conponents. + */ + A = getFloat(node, "A", "toSI"); + b = getFloat(node, "b"); + E = getFloat(node, "E", "actEnergy"); + E /= GasConstant; + } + + + + //! Copy constructor + LiquidTransportData::LiquidTransportData( const LiquidTransportData &right ) + { + *this = right; //use assignment operator to do other work + } + + //! Assignment operator + LiquidTransportData& LiquidTransportData::operator=(const LiquidTransportData& right ) + { + if (&right != this) { + speciesName = right.speciesName; + hydroradius = right.hydroradius; + viscosity = right.viscosity; + thermalCond = right.thermalCond; + electCond = right.electCond; + speciesDiffusivity = right.speciesDiffusivity; + } + return *this; + } + + + + + //! Copy constructor + LTPspecies::LTPspecies( const LTPspecies &right ) + { + *this = right; //use assignment operator to do other work + } + + //! Assignment operator + LTPspecies& LTPspecies::operator=(const LTPspecies& right ) + { + if (&right != this) { + speciesName = right.speciesName; + property = right.property; + model = right.model; + coeffs = right.coeffs; + m_thermo = right.m_thermo; + } + return *this; + } + + + //! Construct an LTPspecies object for a liquid tranport property + //! expressed as a constant value. + /** The transport property is constructed from the XML node, propNode, + * that is a child of the node and specifies a type of + * transport property (like viscosity) + */ + LTPspecies_Const::LTPspecies_Const( const XML_Node &propNode, + std::string name, + TransportPropertyList tp_ind, + thermo_t* thermo ) : + LTPspecies( propNode, name, tp_ind, thermo) + { + model = LTR_MODEL_CONSTANT; + double A_k = getFloatCurrent(propNode, "toSI"); + if (A_k > 0.0) { + coeffs.push_back(A_k); + } else throw LTPError("negative or zero " + propNode.name() ); + } + + //! Copy constructor + LTPspecies_Const::LTPspecies_Const( const LTPspecies_Const &right ) + : LTPspecies() + { + *this = right; //use assignment operator to do other work + } + + //! Assignment operator + LTPspecies_Const& LTPspecies_Const::operator=(const LTPspecies_Const& right ) + { + if (&right != this) { + //LTPspecies::operator=(right); + speciesName = right.speciesName; + property = right.property; + model = right.model; + coeffs = right.coeffs; + m_thermo = right.m_thermo; + } + return *this; + } + + //! Return the (constant) value for this transport property + doublereal LTPspecies_Const::getSpeciesTransProp( ) { + return coeffs[0]; + } + + /////////////////////////////////////////////////////////////// + + //! Construct an LTPspecies object for a liquid tranport property + //! expressed as a constant value. + /** The transport property is constructed from the XML node, propNode, + * that is a child of the node and specifies a type of + * transport property (like viscosity) + */ + LTPspecies_Arrhenius::LTPspecies_Arrhenius( const XML_Node &propNode, + std::string name, + TransportPropertyList tp_ind, + thermo_t* thermo ) : + LTPspecies( propNode, name, tp_ind, thermo) + { + model = LTR_MODEL_ARRHENIUS; + + doublereal A_k, n_k, Tact_k; + getArrhenius(propNode, A_k, n_k, Tact_k); + if (A_k <= 0.0) { + throw LTPError("negative or zero " + propNode.name() ); + } + coeffs.push_back( A_k ); + coeffs.push_back( n_k ); + coeffs.push_back( Tact_k ); + coeffs.push_back( log( A_k ) ); + } + + //! Copy constructor + LTPspecies_Arrhenius::LTPspecies_Arrhenius( const LTPspecies_Arrhenius &right ) + : LTPspecies() + { + *this = right; //use assignment operator to do other work + } + + //! Assignment operator + LTPspecies_Arrhenius& LTPspecies_Arrhenius::operator=(const LTPspecies_Arrhenius& right ) + { + if (&right != this) { + // LTPspecies::operator=(right); + speciesName = right.speciesName; + property = right.property; + model = right.model; + coeffs = right.coeffs; + m_thermo = right.m_thermo; + + m_temp = right.m_temp; + m_logt = right.m_logt; + m_prop = right.m_prop; + m_logProp = right.m_logProp; + } + return *this; + } + + //! Return the value for this transport property evaluated + //! from the Arrhenius expression + /** + * In general the Arrhenius expression is + * + * \f[ + * \mu = A T^n \exp( - E / R T ). + * \f] + * + * Note that for viscosity, the convention is such that + * a positive activation energy corresponds to the typical + * case of a positive argument to the exponential so that + * the Arrhenius expression is + * + * \f[ + * \mu = A T^n \exp( + E / R T ). + * \f] + */ + doublereal LTPspecies_Arrhenius::getSpeciesTransProp( ) { + + doublereal t = m_thermo->temperature(); + //coeffs[0] holds A + //coeffs[1] holds n + //coeffs[2] holds Tact + //coeffs[3] holds log(A) + if (t != m_temp) { + m_temp = t; + m_logt = log(m_temp); + //For viscosity the sign convention on positive activation energy is swithced + if ( property == TP_VISCOSITY ) + m_logProp = coeffs[3] + coeffs[1] * m_logt + coeffs[2] / m_temp ; + else + m_logProp = coeffs[3] + coeffs[1] * m_logt - coeffs[2] / m_temp ; + m_prop = exp( m_logProp ); + } + return m_prop; + } + + + + + + + /////////////////////////////////////////////////////////////// + + //! Construct an LTPspecies object for a liquid tranport property + //! expressed as a constant value. + /** The transport property is constructed from the XML node, propNode, + * that is a child of the node and specifies a type of + * transport property (like viscosity) + */ + LTPspecies_Poly::LTPspecies_Poly( const XML_Node &propNode, + std::string name, + TransportPropertyList tp_ind, + thermo_t* thermo ) : + LTPspecies( propNode, name, tp_ind, thermo) + { + model = LTR_MODEL_POLY; + + + getFloatArray(propNode, coeffs, true); // if units labeled, convert Angstroms -> meters + + if (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 + } + + //! Assignment operator + LTPspecies_Poly& LTPspecies_Poly::operator=(const LTPspecies_Poly& right ) + { + if (&right != this) { + //LTPspecies::operator=(right); + speciesName = right.speciesName; + property = right.property; + model = right.model; + coeffs = right.coeffs; + m_thermo = right.m_thermo; + + m_temp = right.m_temp; + m_prop = right.m_prop; + } + return *this; + } + + //! 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) { + double tempN = 1.0; + for ( int i = 0; i < coeffs.size() ; i++ ) { + m_prop += coeffs[i] * tempN; + tempN *= m_temp; + } + } + return m_prop; + } + + + + + + + + +} diff --git a/Cantera/src/transport/LiquidTransportData.h b/Cantera/src/transport/LiquidTransportData.h index 7b3d28609..bc7894439 100644 --- a/Cantera/src/transport/LiquidTransportData.h +++ b/Cantera/src/transport/LiquidTransportData.h @@ -1,7 +1,6 @@ /** - * @file TransportFactory.h - * Header file defining class TransportFactory - * (see \link Cantera::TransportFactory TransportFactory\endlink) + * @file LiquidTransportData.h + * Header file defining class LiquidTransportData */ /* * $Author$ @@ -19,8 +18,6 @@ // STL includes #include #include -#include -#include @@ -32,6 +29,15 @@ namespace Cantera { + enum TransportPropertyList { + TP_UNKNOWN = -1, + TP_VISCOSITY = 0, + TP_THERMALCOND, + TP_DIFFUSIVITY, + TP_HYDRORADIUS, + TP_ELECTCOND + }; + enum LiquidTR_Model { //! Temperature dependence type for pure (liquid) species properties /*! @@ -46,6 +52,85 @@ namespace Cantera { LTR_MODEL_POLY }; + + //! Class LTPspecies holds transport parameters for a + //! specific liquid-phase species. + /** + * Subclasses handle different means of specifying transport properties + * like constant, Arrhenius or polynomial fits. In its current state, + * it is primarily suitable for specifying temperature dependence, but + * the adjustCoeffsForComposition() method can be implemented to + * adjust for composition dependence. + * Mixing rules for computing mixture transport properties are handled + * separately in + */ + class LTPspecies { + + public: + + //! Construct an LTPspecies object for a liquid tranport property. + /** + * The transport property is constructed from the + * XML node, propNode, that is a child of the + * node and specifies a type of + * transport property (like viscosity). + */ + LTPspecies( const XML_Node &propNode = 0, + std::string name = "-", + TransportPropertyList tp_ind = TP_UNKNOWN, + thermo_t* thermo = 0 ) : + speciesName(name), + model(LTR_MODEL_NOTSET), + property(tp_ind), + m_thermo(thermo) + { + + } + + //! Copy constructor + LTPspecies( const LTPspecies &right ); + + //! Assignment operator + LTPspecies& operator=(const LTPspecies& right ); + + ~LTPspecies( ) { } + + //! Returns the vector of pure species tranport property + /*! + * The pure species transport property (i.e. pure species viscosity) + * is returned. Any temperature and composition dependence will be + * adjusted internally according to the information provided by the + * thermo object. + */ + virtual doublereal getSpeciesTransProp( ) { return 0.0; } + + virtual bool checkPositive( ) { return ( coeffs[0] > 0 ); } + + protected: + std::string speciesName; + + //! Model type for the temperature dependence + LiquidTR_Model model; + + //! enum indicating what property this is (i.e viscosity) + TransportPropertyList property; + + //! Model temperature-dependence ceofficients + vector_fp coeffs; + + //! pointer to thermo object to get current temperature + thermo_t* m_thermo; + + //! Internal model to adjust species-specific properties for composition. + /** Currently just a place holder, but this method could take + * the composition from the thermo object and adjust coefficients + * accoding to some unspecified model. + */ + virtual void adjustCoeffsForComposition() { } + }; + + + //! Class LiquidTransportData holds transport parameters for a //! specific liquid-phase species. class LiquidTransportData { @@ -53,40 +138,170 @@ namespace Cantera { public: LiquidTransportData() : - speciesName("-"), - model_hydroradius(LTR_MODEL_NOTSET), - model_viscosity(LTR_MODEL_NOTSET), - model_thermalCond(LTR_MODEL_NOTSET), - model_speciesDiffusivity(LTR_MODEL_NOTSET) + speciesName("-") { } + //! copy constructor + LiquidTransportData( const LiquidTransportData &right ) ; - std::string speciesName; - + //! Assignment operator + LiquidTransportData& operator=(const LiquidTransportData& right ); + + std::string speciesName; + //! Model type for the hydroradius - LiquidTR_Model model_hydroradius; - - //! Ceofficients for the hydroradius model - vector_fp hydroRadiusCoeffs; + LTPspecies* hydroradius; //! Model type for the viscosity - LiquidTR_Model model_viscosity; - - //! Ceofficients for the viscosity model - vector_fp viscCoeffs; + LTPspecies* viscosity; //! Model type for the thermal conductivity - LiquidTR_Model model_thermalCond; + LTPspecies* thermalCond; + + //! Model type for the electrical conductivity + LTPspecies* electCond; - //! Ceofficients for the thermal conductivity model - vector_fp thermalCondCoeffs; - //! Model type for the speciesDiffusivity - LiquidTR_Model model_speciesDiffusivity; - - //! Ceofficients for the species diffusivity model - vector_fp speciesDiffusivityCoeffs; + LTPspecies* speciesDiffusivity; }; + + + + //! Class LTPspecies_Const holds transport parameters for a + //! specific liquid-phase species when the transport property + //! is just a constant value. + class LTPspecies_Const : public LTPspecies{ + + public: + + LTPspecies_Const( const XML_Node &propNode, + std::string name, + TransportPropertyList tp_ind, + thermo_t* thermo ) ; + + //! Copy constructor + LTPspecies_Const( const LTPspecies_Const &right ); + + //! Assignment operator + LTPspecies_Const& operator=(const LTPspecies_Const& right ); + + //! Returns the pure species tranport property + /*! + * The pure species transport property (i.e. pure species viscosity) + * is returned. Any temperature and composition dependence will be + * adjusted internally according to the information provided by the + * thermo object. + */ + doublereal getSpeciesTransProp( ); + + protected: + + //! Internal model to adjust species-specific properties for composition. + /** Currently just a place holder, but this method could take + * the composition from the thermo object and adjust coefficients + * accoding to some unspecified model. + */ + void adjustCoeffsForComposition( ) { } + }; + + + + //! Class LTPspecies_Arrhenius holds transport parameters for a + //! specific liquid-phase species when the transport property + //! is just a constant value. + class LTPspecies_Arrhenius : public LTPspecies{ + + public: + + LTPspecies_Arrhenius( const XML_Node &propNode, + std::string name, + TransportPropertyList tp_ind, + thermo_t* thermo ); + + //! Copy constructor + LTPspecies_Arrhenius( const LTPspecies_Arrhenius &right ); + + //! Assignment operator + LTPspecies_Arrhenius& operator=(const LTPspecies_Arrhenius& right ); + + //! Returns the pure species tranport property + /*! + * The pure species transport property (i.e. pure species viscosity) + * is returned. Any temperature and composition dependence will be + * adjusted internally according to the information provided by the + * thermo object. + */ + doublereal getSpeciesTransProp( ); + + protected: + + //! temperature from thermo object + doublereal m_temp; + + //! logarithm of current temperature + doublereal m_logt; + + //! most recent evaluation of transport property + doublereal m_prop; + + //! logarithm of most recent evaluation of transport property + doublereal m_logProp; + + //! Internal model to adjust species-specific properties for composition. + /** Currently just a place holder, but this method could take + * the composition from the thermo object and adjust coefficients + * accoding to some unspecified model. + */ + void adjustCoeffsForComposition( ) { } + }; + + + + //! Class LTPspecies_Poly holds transport parameters for a + //! specific liquid-phase species when the transport property + //! is just a constant value. + class LTPspecies_Poly : public LTPspecies{ + + public: + + LTPspecies_Poly( const XML_Node &propNode, + std::string name, + TransportPropertyList tp_ind, + thermo_t* thermo ); + + //! Copy constructor + LTPspecies_Poly( const LTPspecies_Poly &right ); + + //! Assignment operator + LTPspecies_Poly& operator=(const LTPspecies_Poly& right ); + + //! Returns the pure species tranport property + /*! + * The pure species transport property (i.e. pure species viscosity) + * is returned. Any temperature and composition dependence will be + * adjusted internally according to the information provided by the + * thermo object. + */ + doublereal getSpeciesTransProp( ); + + protected: + + //! temperature from thermo object + doublereal m_temp; + + //! most recent evaluation of transport property + doublereal m_prop; + + //! Internal model to adjust species-specific properties for composition. + /** Currently just a place holder, but this method could take + * the composition from the thermo object and adjust coefficients + * accoding to some unspecified model. + */ + void adjustCoeffsForComposition( ){ } + }; + + + } #endif diff --git a/Cantera/src/transport/LiquidTransportParams.h b/Cantera/src/transport/LiquidTransportParams.h index 157c372f1..4e3dc934e 100644 --- a/Cantera/src/transport/LiquidTransportParams.h +++ b/Cantera/src/transport/LiquidTransportParams.h @@ -1,3 +1,15 @@ +/** + * @file LiquidTransportParams.h + * Header file defining class LiquidTransportParams + */ +/* + * $Author$ + * $Date$ + * $Revision$ + * + * + * + */ #ifndef CT_LIQUIDTRANSPORTPARAMS_H #define CT_LIQUIDTRANSPORTPARAMS_H diff --git a/Cantera/src/transport/Makefile.in b/Cantera/src/transport/Makefile.in index 8302e9a54..015f34a6f 100644 --- a/Cantera/src/transport/Makefile.in +++ b/Cantera/src/transport/Makefile.in @@ -41,7 +41,7 @@ TRAN_OBJ = TransportFactory.o MultiTransport.o MixTransport.o MMCollisionInt. TRAN_H = TransportFactory.h MultiTransport.h MixTransport.h \ MMCollisionInt.h SolidTransport.h DustyGasTransport.h \ TransportBase.h L_matrix.h TransportParams.h WaterTransport.h \ - SimpleTransport.h LiquidTransportData.h + SimpleTransport.h ifeq ($(do_electro),1) do_issp = 1 @@ -50,8 +50,8 @@ ELECTRO_H = AqueousTransport.h endif ifeq ($(do_issp),1) -ISSP_OBJ = LiquidTransport.o -ISSP_H = LiquidTransport.h LiquidTransportParams.h +ISSP_OBJ = LiquidTransport.o LiquidTransportData.o +ISSP_H = LiquidTransport.h LiquidTransportParams.h LiquidTransportData.h endif