diff --git a/Cantera/src/transport/SolidTransport.cpp b/Cantera/src/transport/SolidTransport.cpp index ee20c52b6..de1925eb1 100644 --- a/Cantera/src/transport/SolidTransport.cpp +++ b/Cantera/src/transport/SolidTransport.cpp @@ -1,14 +1,15 @@ /** - * * @file SolidTransport.cpp + * Definition file for the class SolidTransport, which handles transport + * of ions within solid phases + * (see \ref tranprops and \link Cantera::SolidTransport SolidTransport \endlink). */ - /* $Author$ * $Revision$ * $Date$ */ -// copyright 2008 California Institute of Technology +// Copyright 2008 California Institute of Technology // turn off warnings under Windows @@ -27,92 +28,152 @@ using namespace std; namespace Cantera { - SolidTransport::SolidTransport() {} + //==================================================================================================================== + SolidTransport::SolidTransport() : + Transport() , + m_nmobile(0.0), + m_Adiff(0), + m_Ndiff(0), + m_Ediff(0), + m_sp(0), + m_Alam(0), + m_Nlam(0), + m_Elam(0) + { + } + //==================================================================================================================== + SolidTransport::~SolidTransport() + { + } + //==================================================================================================================== + SolidTransport::SolidTransport(const SolidTransport &right) : + Transport(), + m_nmobile(0.0), + m_Adiff(0), + m_Ndiff(0), + m_Ediff(0), + m_sp(0), + m_Alam(0), + m_Nlam(0), + m_Elam(0) + { + /* + * Use the assignment operator to do the brunt + * of the work for the copy construtor. + */ + *this = right; + } + //==================================================================================================================== + SolidTransport& SolidTransport::operator=(const SolidTransport& b) + { + if (&b != this) { + return *this; + } + Transport::operator=(b); - void SolidTransport::setParameters(const int n, const int k, const double* const p) { - switch (n) { + m_nmobile = b.m_nmobile; + m_Adiff = b.m_Adiff; + m_Ndiff = b.m_Ndiff; + m_Ediff = b.m_Ediff; + m_sp = b.m_sp; + m_Alam = b.m_Alam; + m_Nlam = b.m_Nlam; + m_Elam = b.m_Elam; + + return *this; + } + //==================================================================================================================== + Transport *SolidTransport::duplMyselfAsTransport() const + { + SolidTransport* tr = new SolidTransport(*this); + return (dynamic_cast(tr)); + } + //==================================================================================================================== + void SolidTransport::setParameters(const int n, const int k, const double* const p) { + switch (n) { - case 0: - // set the Arrhenius parameters for the diffusion coefficient - // of species k. - m_sp.push_back(k); - m_Adiff.push_back(p[0]); - m_Ndiff.push_back(p[1]); - m_Ediff.push_back(p[2]); - m_nmobile = m_sp.size(); - break; + case 0: + // set the Arrhenius parameters for the diffusion coefficient + // of species k. + m_sp.push_back(k); + m_Adiff.push_back(p[0]); + m_Ndiff.push_back(p[1]); + m_Ediff.push_back(p[2]); + m_nmobile = m_sp.size(); + break; - case 1: - // set the thermal conductivity Arrhenius parameters. - m_Alam = p[0]; - m_Nlam = p[2]; - m_Elam = p[2]; - break; + case 1: + // set the thermal conductivity Arrhenius parameters. + m_Alam = p[0]; + m_Nlam = p[2]; + m_Elam = p[2]; + break; - default: - ; - } + default: + ; } - - /** - * Compute the mobilities of the species from the diffusion coefficients, - * using the Einstein relation. - */ - void SolidTransport::getMobilities(doublereal* const mobil) { - int k; - getMixDiffCoeffs(mobil); - doublereal t = m_thermo->temperature(); - int nsp = m_thermo->nSpecies(); - doublereal c1 = ElectronCharge / (Boltzmann * t); - for (k = 0; k < nsp; k++) { - mobil[k] *= c1 * fabs(m_thermo->charge(k)); - } - } - - /** - * Thermal Conductivity. - * \f[ - * \lambda = A T^n \exp(-E/RT) - * \f] - */ - doublereal SolidTransport::thermalConductivity() { - doublereal t = m_thermo->temperature(); - return m_Alam *pow(t, m_Nlam) * exp(-m_Elam/t); + m_work.resize(m_thermo->nSpecies()); + } + //==================================================================================================================== + /* + * Compute the mobilities of the species from the diffusion coefficients, + * using the Einstein relation. + */ + void SolidTransport::getMobilities(doublereal* const mobil) { + int k; + getMixDiffCoeffs(mobil); + doublereal t = m_thermo->temperature(); + int nsp = m_thermo->nSpecies(); + doublereal c1 = ElectronCharge / (Boltzmann * t); + for (k = 0; k < nsp; k++) { + mobil[k] *= c1 * fabs(m_thermo->charge(k)); } + } + //==================================================================================================================== + /** + * Thermal Conductivity. + * \f[ + * \lambda = A T^n \exp(-E/RT) + * \f] + */ + doublereal SolidTransport::thermalConductivity() { + doublereal t = m_thermo->temperature(); + return m_Alam *pow(t, m_Nlam) * exp(-m_Elam/t); + } + //==================================================================================================================== - - /** - * The diffusion coefficients are computed from - * - * \f[ - * D_k = A_k T^{n_k} \exp(-E_k/RT). - * \f] - * - * The diffusion coefficients are only non-zero for species for - * which parameters have been specified using method - * setParameters. - */ - void SolidTransport::getMixDiffCoeffs(doublereal* const d) { - doublereal temp = m_thermo->temperature(); - int nsp = m_thermo->nSpecies(); - int k; - for (k = 0; k < nsp; k++) d[k] = 0.0; - for (k = 0; k < m_nmobile; k++) { - d[m_sp[k]] = - m_Adiff[k] * pow(temp, m_Ndiff[k]) * exp(-m_Ediff[k]/temp); - } + /** + * The diffusion coefficients are computed from + * + * \f[ + * D_k = A_k T^{n_k} \exp(-E_k/RT). + * \f] + * + * The diffusion coefficients are only non-zero for species for + * which parameters have been specified using method + * setParameters. + */ + void SolidTransport::getMixDiffCoeffs(doublereal* const d) { + doublereal temp = m_thermo->temperature(); + int nsp = m_thermo->nSpecies(); + int k; + for (k = 0; k < nsp; k++) d[k] = 0.0; + for (k = 0; k < m_nmobile; k++) { + d[m_sp[k]] = + m_Adiff[k] * pow(temp, m_Ndiff[k]) * exp(-m_Ediff[k]/temp); } - -// void SolidTransport::electricalConductivity() { -// getMobilities(m_work.begin()); -// int nsp = m_thermo->nSpecies(); -// int k; -// doublereal sum = 0.0; -// for (k = 0; k < nsp; n++) { -// sum += m_thermo->charge(k)*m_thermo->moleFraction(k)*m_work[k]; -// } -// return sum * m_thermo->molarDensity(); -// } - + } + //==================================================================================================================== + doublereal SolidTransport::electricalConductivity() + { + getMobilities(&m_work[0]); + int nsp = m_thermo->nSpecies(); + doublereal sum = 0.0; + for (int k = 0; k < nsp; k++) { + sum += m_thermo->charge(k) * m_thermo->moleFraction(k) * m_work[k]; + } + return sum * m_thermo->molarDensity(); + } + //==================================================================================================================== } diff --git a/Cantera/src/transport/SolidTransport.h b/Cantera/src/transport/SolidTransport.h index 31e5fe0a1..8c6be50d2 100644 --- a/Cantera/src/transport/SolidTransport.h +++ b/Cantera/src/transport/SolidTransport.h @@ -1,10 +1,11 @@ /** - * * @file SolidTransport.h - * Header file defining class SolidTransport + * Header file for defining the class SolidTransport, which handles transport + * of ions within solid phases + * (see \ref tranprops and \link Cantera::SolidTransport SolidTransport \endlink). */ -/* $Author$ +/* * $Revision$ * $Date$ */ @@ -37,40 +38,95 @@ namespace Cantera { - /** - * Class SolidTransport implements transport - * properties for solids. + + //! Class SolidTransport implements transport properties for solids. + /*! + * + * + * + */ + class SolidTransport : public Transport { + + public: + + //! Default constructor + SolidTransport(); + + //! Copy Constructor + /*! + * @param right Object to be copied */ - class SolidTransport : public Transport { + SolidTransport(const SolidTransport &right); - public: -virtual ~SolidTransport() {} + //! Destructor + virtual ~SolidTransport(); - virtual int model() const { return cSolidTransport; } + //! Assignment operator + /*! + * This is NOT a virtual function. + * + * @param right Reference to Transport object to be copied into the + * current one. + */ + SolidTransport& operator=(const SolidTransport& right); - virtual doublereal thermalConductivity(); - virtual void getMixDiffCoeffs(doublereal* const d); - virtual void getMobilities(doublereal* const mobil); - virtual void setParameters(const int n, const int k, const doublereal* const p); + //! Duplication routine for objects which inherit from + //! %Transport + /*! + * This virtual routine can be used to duplicate %Transport objects + * inherited from %Transport even if the application only has + * a pointer to %Transport to work with. + * + * These routines are basically wrappers around the derived copy + * constructor. + */ + virtual Transport *duplMyselfAsTransport() const; - friend class TransportFactory; - protected: + virtual int model() const { return cSolidTransport; } - /// default constructor - SolidTransport(); + virtual doublereal thermalConductivity(); + virtual void getMixDiffCoeffs(doublereal* const d); - private: + //! Compute the electrical mobilities of the species from the diffusion coefficients, + //! using the Einstein relation. + /*! + * Frequently, but not always, the mobility is calculated from the + * diffusion coefficient using the Einstein relation + * + * \f[ + * \mu^e_k = \frac{F D_k}{R T} + * \f] + * + * units (m^2/V/s). + * @param mobil Returns the mobilities of + * the species in array \c mobil_e. The array must be + * dimensioned at least as large as the number of species. + */ + virtual void getMobilities(doublereal* const mobil); - int m_nmobile; // number of mobile species - vector_fp m_Adiff; - vector_fp m_Ndiff; - vector_fp m_Ediff; - vector_int m_sp; - doublereal m_Alam; - doublereal m_Nlam; - doublereal m_Elam; - }; + virtual void setParameters(const int n, const int k, const doublereal* const p); + + friend class TransportFactory; + + /** + * The electrical conductivity (Siemens/m). + */ + virtual doublereal electricalConductivity(); + + + private: + + int m_nmobile; // number of mobile species + vector_fp m_Adiff; + vector_fp m_Ndiff; + vector_fp m_Ediff; + vector_int m_sp; + doublereal m_Alam; + doublereal m_Nlam; + doublereal m_Elam; + vector_fp m_work; + }; } #endif