From 1dad7e320a6abd864d7b75729acd7f3563dbae61 Mon Sep 17 00:00:00 2001 From: John Hewson Date: Thu, 24 Sep 2009 20:46:26 +0000 Subject: [PATCH] LiquidTransport.h LiquidTransport.cpp Removed a number of variables relevant only to the gas-phase transport coefficient models. These include the following: - vector_fp m_cond; - vector_fp m_polytempvec; - vector m_condcoeffs; - std::vector viscCoeffsVector_; - vector_fp m_sqvisc; - vector_fp viscSpecies_; - DenseMatrix m_wratkj1; - DenseMatrix m_phi; - DenseMatrix m_wratjk; Removed much code related to these variables. Added a number of variables relevant to the liquid-phase transport models including: + vector_fp m_condSpecies; + vector_fp m_viscSpecies; + vector_fp m_visc_A; + vector_fp m_visc_n; + vector_fp m_visc_Tact; + vector_fp m_thermCond_A; + vector_fp m_thermCond_n; + vector_fp m_thermCond_Tact; Changed some of the relevant comments to pertain to the liquid-phase models. --- Cantera/src/transport/LiquidTransport.cpp | 113 ++++++----------- Cantera/src/transport/LiquidTransport.h | 148 +++++++++------------- 2 files changed, 104 insertions(+), 157 deletions(-) diff --git a/Cantera/src/transport/LiquidTransport.cpp b/Cantera/src/transport/LiquidTransport.cpp index 7aede695c..bf69d190e 100644 --- a/Cantera/src/transport/LiquidTransport.cpp +++ b/Cantera/src/transport/LiquidTransport.cpp @@ -100,27 +100,26 @@ namespace Cantera { m_tmin = right.m_tmin; m_tmax = right.m_tmax; m_mw = right.m_mw; - viscCoeffsVector_ = right.viscCoeffsVector_; - m_condcoeffs = right.m_condcoeffs; + m_visc_A = right.m_visc_A; + m_visc_n = right.m_visc_n; + m_visc_Tact = right.m_visc_Tact; + m_thermCond_A = right.m_thermCond_A; + m_thermCond_n = right.m_thermCond_n; + m_thermCond_Tact = right.m_thermCond_Tact; m_diffcoeffs = right.m_diffcoeffs; m_Grad_X = right.m_Grad_X; m_Grad_T = right.m_Grad_T; m_Grad_V = right.m_Grad_V; m_ck_Grad_mu = right.m_ck_Grad_mu; m_bdiff = right.m_bdiff; - viscSpecies_ = right.viscSpecies_; - m_sqvisc = right.m_sqvisc; + m_viscSpecies = right.m_viscSpecies; m_cond = right.m_cond; - m_polytempvec = right.m_polytempvec; m_iStateMF = -1; m_molefracs = right.m_molefracs; m_concentrations = right.m_concentrations; m_chargeSpecies = right.m_chargeSpecies; m_DiffCoeff_StefMax = right.m_DiffCoeff_StefMax; viscosityModel_ = right.viscosityModel_; - m_phi = right.m_phi; - m_wratjk = right.m_wratjk; - m_wratkj1 = right.m_wratkj1; m_B = right.m_B; m_A = right.m_A; m_eps = right.m_eps; @@ -173,30 +172,29 @@ namespace Cantera { copy(m_thermo->molecularWeights().begin(), m_thermo->molecularWeights().end(), m_mw.begin()); - // copy polynomials and parameters into local storage - viscCoeffsVector_ = tr.visccoeffs; - m_condcoeffs = tr.condcoeffs; + // copy parameters into local storage + m_visc_A = tr.visc_A ; + m_visc_n = tr.visc_n ; + m_visc_Tact = tr.visc_Tact ; + + m_thermCond_A = tr.thermCond_A ; + m_thermCond_n = tr.thermCond_n ; + m_thermCond_Tact = tr.thermCond_Tact ; + //m_diffcoeffs = tr.diffcoeffs; m_mode = tr.mode_; - m_phi.resize(m_nsp, m_nsp, 0.0); + m_visc_A.resize(m_nsp); + m_visc_n.resize(m_nsp); + m_visc_Tact.resize(m_nsp); + m_thermCond_A.resize(m_nsp); + m_thermCond_n.resize(m_nsp); + m_thermCond_Tact.resize(m_nsp); - m_wratjk.resize(m_nsp, m_nsp, 0.0); - m_wratkj1.resize(m_nsp, m_nsp, 0.0); - int j, k; - for (j = 0; j < m_nsp; j++) - for (k = j; k < m_nsp; k++) { - m_wratjk(j,k) = sqrt(m_mw[j]/m_mw[k]); - m_wratjk(k,j) = sqrt(m_wratjk(j,k)); - m_wratkj1(j,k) = sqrt(1.0 + m_mw[k]/m_mw[j]); - } - - m_polytempvec.resize(5); - viscSpecies_.resize(m_nsp); - m_sqvisc.resize(m_nsp); - m_cond.resize(m_nsp); + m_viscSpecies.resize(m_nsp); + m_condSpecies.resize(m_nsp); m_bdiff.resize(m_nsp, m_nsp); m_molefracs.resize(m_nsp); @@ -247,7 +245,7 @@ namespace Cantera { if (m_visc_mix_ok) return m_viscmix; - // update viscSpecies_[] and m_phi[] if necessary + // update m_viscSpecies[] if necessary if (!m_visc_temp_ok) { updateViscosity_temp(); } @@ -256,16 +254,18 @@ namespace Cantera { updateViscosities_conc(); } + /* We still need to implement interaction parameters */ + /* This constant viscosity model has no input */ if (viscosityModel_ == LVISC_CONSTANT) { - return m_viscmix; + err("constant viscosity not implemented for LiquidTransport."); + //return m_viscmix; } else if (viscosityModel_ == LVISC_MIXTUREAVG) { - m_viscmix = dot_product(viscSpecies_, m_molefracs); + m_viscmix = dot_product(m_viscSpecies, m_molefracs); + } else if (viscosityModel_ == LVISC_INTERACTION) { + m_viscmix = dot_product(m_viscSpecies, m_molefracs); + //now sum over i,j : Gij*Xi*Xj } else if (viscosityModel_ == LVISC_WILKES) { - multiply(m_phi, DATA_PTR(m_molefracs), DATA_PTR(m_spwork)); - m_viscmix = 0.0; - for (int k = 0; k < m_nsp; k++) { - m_viscmix += m_molefracs[k] * viscSpecies_[k]/m_spwork[k]; - } + err("Wilkes method not implemented for LiquidTransport."); } return m_viscmix; @@ -276,7 +276,7 @@ namespace Cantera { if (!m_visc_temp_ok) { updateViscosity_temp(); } - copy(viscSpecies_.begin(), viscSpecies_.end(), visc); + copy(m_viscSpecies.begin(), m_viscSpecies.end(), visc); } @@ -354,8 +354,8 @@ namespace Cantera { if (!m_cond_mix_ok) { doublereal sum1 = 0.0, sum2 = 0.0; for (int k = 0; k < m_nsp; k++) { - sum1 += m_molefracs[k] * m_cond[k]; - sum2 += m_molefracs[k] / m_cond[k]; + sum1 += m_molefracs[k] * m_condSpecies[k]; + sum2 += m_molefracs[k] / m_condSpecies[k]; } m_lambda = 0.5*(sum1 + 1.0/sum2); m_cond_mix_ok = true; @@ -683,11 +683,11 @@ namespace Cantera { /* if (m_mode == CK_Mode) { for (k = 0; k < m_nsp; k++) { - m_cond[k] = exp(m_condcoeffs[k]); + m_condSpecies[k] = exp(m_condcoeffs[k]); } } else { for (k = 0; k < m_nsp; k++) { - m_cond[k] = m_sqrt_t * m_condcoeffs[k]; + m_condSpecies[k] = m_sqrt_t * m_condcoeffs[k]; } } m_cond_temp_ok = true; @@ -747,42 +747,13 @@ namespace Cantera { */ void LiquidTransport::updateViscosity_temp() { int k; - doublereal vratiokj, wratiojk, factor1; - /* - if (m_mode == CK_Mode) { - for (k = 0; k < m_nsp; k++) { - viscSpecies_[k] = exp(viscCoeffsVector_[k]); - m_sqvisc[k] = sqrt(viscSpecies_[k]); - } + for (k = 0; k < m_nsp; k++) { + m_viscSpecies[k] = m_visc_A[k] * exp( m_visc_n[k] * m_logt + - m_visc_Tact[k] / m_temp ); } - else { - for (k = 0; k < m_nsp; k++) { - // the polynomial fit is done for sqrt(visc/sqrt(T)) - m_sqvisc[k] = m_t14 * viscCoeffsVector_[k]; - viscSpecies_[k] = (m_sqvisc[k]*m_sqvisc[k]); - } - } - - // see Eq. (9-5.15) of Reid, Prausnitz, and Poling - int j; - for (j = 0; j < m_nsp; j++) { - for (k = j; k < m_nsp; k++) { - vratiokj = viscSpecies_[k]/viscSpecies_[j]; - wratiojk = m_mw[j]/m_mw[k]; - - // Note that m_wratjk(k,j) holds the square root of - // m_wratjk(j,k)! - factor1 = 1.0 + (m_sqvisc[k]/m_sqvisc[j]) * m_wratjk(k,j); - m_phi(k,j) = factor1*factor1 / - (SqrtEight * m_wratkj1(j,k)); - m_phi(j,k) = m_phi(k,j)/(vratiokj * wratiojk); - } - } - m_visc_temp_ok = true; m_visc_mix_ok = false; - */ } diff --git a/Cantera/src/transport/LiquidTransport.h b/Cantera/src/transport/LiquidTransport.h index e7aa8dd92..424338fbe 100644 --- a/Cantera/src/transport/LiquidTransport.h +++ b/Cantera/src/transport/LiquidTransport.h @@ -137,11 +137,15 @@ namespace Cantera { public: //! default constructor + /*! + * @param thermo ThermoPhase object holding species information. + * @param ndim Number of spatial dimensions. + */ LiquidTransport(thermo_t* thermo = 0, int ndim = 1); //!Copy Constructor for the %LiquidThermo object. /*! - * @param right ThermoPhase to be copied + * @param right %LiquidTransport to be copied */ LiquidTransport(const LiquidTransport &right); @@ -149,8 +153,8 @@ namespace Cantera { /*! * This is NOT a virtual function. * - * @param right Reference to %ThermoPhase object to be copied into the - * current one. + * @param right Reference to %LiquidTransport object to be copied + * into the current one. */ LiquidTransport& operator=(const LiquidTransport& right); @@ -170,6 +174,19 @@ namespace Cantera { //! virtual destructor virtual ~LiquidTransport() {} + //! Initialize the transport object + /*! + * Here we change all of the internal dimensions to be sufficient. + * We get the object ready to do property evaluations. + * + * @param tr Transport parameters for all of the species + * in the phase. + */ + virtual bool initLiquid(LiquidTransportParams& tr); + + friend class TransportFactory; + + //! Return the model id for this transport parameterization virtual int model() { return cLiquidTransport; @@ -179,17 +196,14 @@ namespace Cantera { //! Returns the viscosity of the solution /*! - * The viscosity is computed using the Wilke mixture rule. + * The viscosity is computed using mixture averaging plus + * any information on interaction parameters * \f[ - * \mu = \sum_k \frac{\mu_k X_k}{\sum_j \Phi_{k,j} X_j}. + * \mu = \sum_k {\mu_k X_k} {\sum_j \sum_k {G_{j,k} X_k X_j} }. * \f] * Here \f$ \mu_k \f$ is the viscosity of pure species \e k, - * and - * \f[ - * \Phi_{k,j} = \frac{\left[1 - * + \sqrt{\left(\frac{\mu_k}{\mu_j}\sqrt{\frac{M_j}{M_k}}\right)}\right]^2} - * {\sqrt{8}\sqrt{1 + M_k/M_j}} - * \f] + * and \f$ G_{k,j} \f$ is the interaction parameter. + * @see updateViscosity_T(); * * Controlling update boolean m_viscmix_ok @@ -198,25 +212,11 @@ namespace Cantera { //! Returns the pure species viscosities /*! - * - * + * The pure species viscosities are to be given in an Arrhenius + * form in accordance with activated-jump-process dominated transport. */ virtual void getSpeciesViscosities(doublereal* const visc); - virtual void getThermalDiffCoeffs(doublereal* const dt); - - //! Return the thermal conductivity of the solution - /*! - * The thermal conductivity is computed from the following mixture rule: - * \f[ - * \lambda = 0.5 \left( \sum_k X_k \lambda_k - * + \frac{1}{\sum_k X_k/\lambda_k}\right) - * \f] - * - * Controlling update boolean = m_condmix_ok - */ - virtual doublereal thermalConductivity(); - //! Returns the binary diffusion coefficients /*! * @param ld @@ -232,6 +232,20 @@ namespace Cantera { virtual void getMixDiffCoeffs(doublereal* const d); + virtual void getThermalDiffCoeffs(doublereal* const dt); + + //! Return the thermal conductivity of the solution + /*! + * The thermal conductivity is computed from the following mixture rule: + * \f[ + * \lambda = 0.5 \left( \sum_k X_k \lambda_k + * + \frac{1}{\sum_k X_k/\lambda_k}\right) + * \f] + * + * Controlling update boolean = m_condmix_ok + */ + virtual doublereal thermalConductivity(); + //! Get the Mobilities /*! * @param mobil @@ -332,20 +346,6 @@ namespace Cantera { virtual void getSpeciesFluxesExt(int ldf, doublereal* fluxes); - //! Initialize the transport object - /*! - * Here we change all of the internal dimensions to be sufficient. - * We get the object ready to do property evaluations. - * - * @param tr Transport parameters for all of the species - * in the phase. - */ - virtual bool initLiquid(LiquidTransportParams& tr); - - friend class TransportFactory; - - - //! Solve the stefan_maxell equations for the diffusive fluxes. void stefan_maxwell_solve(); @@ -369,19 +369,16 @@ namespace Cantera { */ vector_fp m_mw; - //! Polynomial coefficients of the viscosity - /*! - * These express the temperature dependendence of the pures - * species viscosities. - */ - std::vector viscCoeffsVector_; + //! Pure species viscosities in Arrhenius temperature-dependent form. + vector_fp m_visc_A; + vector_fp m_visc_n; + vector_fp m_visc_Tact; + + //! Pure species thermal conductivities in Arrhenius temperature-dependent form. + vector_fp m_thermCond_A; + vector_fp m_thermCond_n; + vector_fp m_thermCond_Tact; - //! Polynomial coefficients of the conductivities - /*! - * These express the temperature dependendence of the pures - * species conductivities - */ - vector m_condcoeffs; //! Polynomial coefficients of the binary diffusion coefficients /*! @@ -391,10 +388,6 @@ namespace Cantera { */ vector m_diffcoeffs; - //! Temperature polynomial for transport property temperature fits. - vector_fp m_polytempvec; - - //! Internal value of the gradient of the mole fraction vector /*! * Note, this is the only gradient value that can and perhaps @@ -486,19 +479,7 @@ namespace Cantera { * * controlling update boolean -> m_visc_temp_ok */ - vector_fp viscSpecies_; - - //! Sqrt of the species viscosities - /*! - * The sqrt(visc) is used in the mixing formulas - * Length = m_nsp - * - * Depends on the temperature and perhaps pressure, but - * not the species concentrations - * - * controlling update boolean m_visc_temp_ok - */ - vector_fp m_sqvisc; + vector_fp m_viscSpecies; //! Internal value of the species individual thermal conductivities /*! @@ -509,7 +490,7 @@ namespace Cantera { * * controlling update boolean -> m_cond_temp_ok */ - vector_fp m_cond; + vector_fp m_condSpecies; //! State of the mole fraction vector. int m_iStateMF; @@ -593,21 +574,6 @@ namespace Cantera { */ int viscosityModel_; - //! viscosity weighting functions - DenseMatrix m_phi; - - //! Matrix of the ratios of the species molecular weights - /*! - * m_wratjk(i,j) = (m_mw[j]/m_mw[k])**0.25 - */ - DenseMatrix m_wratjk; - - //! Matrix of the ratios of the species molecular weights - /*! - * m_wratkj1(i,j) = (1.0 + m_mw[k]/m_mw[j])**0.5 - */ - DenseMatrix m_wratkj1; - //! RHS to the stefan-maxwell equation DenseMatrix m_B; @@ -746,6 +712,16 @@ namespace Cantera { * Either 1, 2, or 3 */ int m_nDim; + + private: + + /** + * Throw an exception if this method is invoked. + * This probably indicates something is not yet implemented. + */ + doublereal err(std::string msg) const; + + }; } #endif