diff --git a/Cantera/src/thermo/IonsFromNeutralVPSSTP.cpp b/Cantera/src/thermo/IonsFromNeutralVPSSTP.cpp index aeabd53ee..601a937e8 100644 --- a/Cantera/src/thermo/IonsFromNeutralVPSSTP.cpp +++ b/Cantera/src/thermo/IonsFromNeutralVPSSTP.cpp @@ -334,9 +334,10 @@ namespace Cantera { getActivities(c); } - void IonsFromNeutralVPSSTP::getDissociationCoeffs(vector_fp& coeffs,vector_fp& charges){ + void IonsFromNeutralVPSSTP::getDissociationCoeffs(vector_fp& coeffs,vector_fp& charges, std::vector& neutMolIndex){ coeffs = fm_neutralMolec_ions_; charges = m_speciesCharge; + neutMolIndex = fm_invert_ionForNeutral; //for ( int k = 0; k < fm_neutralMolec_ions_[k]; k++ ) // coeffs.push_back(fm_neutralMolec_ions_[k]); } @@ -1297,9 +1298,12 @@ namespace Cantera { std::vector elemVectorI(nElementsI); vector fm_tmp(m_kk); - for (int jNeut = 0; jNeut < numNeutralMoleculeSpecies_; jNeut++) { - fm_invert_ionForNeutral[jNeut] = -1; + for (int k = 0; k < m_kk; k++) { + fm_invert_ionForNeutral[k] = -1; } + /* for (int jNeut = 0; jNeut < numNeutralMoleculeSpecies_; jNeut++) { + fm_invert_ionForNeutral[jNeut] = -1; + }*/ for (int jNeut = 0; jNeut < numNeutralMoleculeSpecies_; jNeut++) { for (int m = 0; m < nElementsN; m++) { elemVectorN[m] = neutralMoleculePhase_->nAtoms(jNeut, m); @@ -1346,12 +1350,16 @@ namespace Cantera { } bool notTaken = true; for (int iNeut = 0; iNeut < jNeut; iNeut++) { - if (fm_invert_ionForNeutral[iNeut] == k) { + if (fm_invert_ionForNeutral[k] == iNeut) { notTaken = false; } } if (notTaken) { - fm_invert_ionForNeutral[jNeut] = k; + fm_invert_ionForNeutral[k] = jNeut; + } + else{ + throw CanteraError("IonsFromNeutralVPSSTP::initThermoXML", + "Simple formula matrix generation failed, one cation is shared between two salts"); } } fm_neutralMolec_ions_[k + jNeut * m_kk] += fac; diff --git a/Cantera/src/thermo/IonsFromNeutralVPSSTP.h b/Cantera/src/thermo/IonsFromNeutralVPSSTP.h index 712ae622a..ffaed580d 100644 --- a/Cantera/src/thermo/IonsFromNeutralVPSSTP.h +++ b/Cantera/src/thermo/IonsFromNeutralVPSSTP.h @@ -461,8 +461,9 @@ namespace Cantera { */ virtual void getdlnActCoeffdlnN(doublereal *dlnActCoeffdlnN) const; - - virtual void getDissociationCoeffs(vector_fp& coeffs, vector_fp& charges); + //! Get the Salt Dissociation Coefficients + //! Returns the vector of dissociation coefficients and vector of charges + virtual void getDissociationCoeffs(vector_fp& coeffs, vector_fp& charges, std::vector& neutMolIndex); virtual void getNeutralMolecMoleFractions(vector_fp& fracs){fracs=NeutralMolecMoleFractions_;} @@ -804,7 +805,7 @@ namespace Cantera { //! Formula Matrix for composition of neutral molecules //! in terms of the molecules in this ThermoPhase /*! - * fm_neutralMolec_ions[ i + jNeut * NumNeut ] + * fm_neutralMolec_ions[ i + jNeut * m_kk ] * * This is the number of ions of type i in the neutral * molecule jNeut. @@ -813,6 +814,11 @@ namespace Cantera { //! Mapping between ion species and neutral molecule for quick invert. /*! + * + * fm_invert_ionForNeutral returns vector of int. Each element represents + * an ionic species and stores the value of the corresponding neutral + * molecule + * * For the case of fm_invert_simple_ = true, we assume that there * is a quick way to invert the formula matrix so that we can * quickly calculate the neutral molecule mole fraction diff --git a/Cantera/src/transport/LiquidTransport.cpp b/Cantera/src/transport/LiquidTransport.cpp index 6868d0393..929a23a39 100644 --- a/Cantera/src/transport/LiquidTransport.cpp +++ b/Cantera/src/transport/LiquidTransport.cpp @@ -686,8 +686,8 @@ namespace Cantera { /****************** thermal diffusion coefficients ************/ - //! Return the thermal diffusion coefficients - /*! + // Return the thermal diffusion coefficients + /* * These are all zero for this simple implementaion * * @param dt thermal diffusion coefficients @@ -813,8 +813,8 @@ namespace Cantera { } } //============================================================== - //! Specify the value of the gradient of the temperature - /*! + // Specify the value of the gradient of the temperature + /* * @param grad_T Gradient of the temperature (length num dimensions); */ void LiquidTransport::set_Grad_T(const doublereal* const grad_T) { @@ -823,8 +823,8 @@ namespace Cantera { } } //============================================================== - //! Specify the value of the gradient of the voltage - /*! + // Specify the value of the gradient of the voltage + /* * * @param grad_V Gradient of the voltage (length num dimensions); */ @@ -834,8 +834,8 @@ namespace Cantera { } } //============================================================== - //! Specify the value of the gradient of the MoleFractions - /*! + // Specify the value of the gradient of the MoleFractions + /* * * @param grad_X Gradient of the mole fractions(length nsp * num dimensions); */ @@ -981,7 +981,7 @@ namespace Cantera { getSpeciesVdiffExt(ldf, Vdiff); } - /** + /* * @param ndim The number of spatial dimensions (1, 2, or 3). * @param grad_T The temperature gradient (ignored in this model). * @param ldx Leading dimension of the grad_X array. @@ -1361,8 +1361,8 @@ namespace Cantera { } - //! Update the binary Stefan-Maxwell diffusion coefficients - //! wrt T using calls to the appropriate LTPspecies subclass + // Update the binary Stefan-Maxwell diffusion coefficients + // wrt T using calls to the appropriate LTPspecies subclass void LiquidTransport::updateDiff_T() { m_diffMixModel->getMatrixTransProp( m_bdiff ); @@ -1371,13 +1371,13 @@ namespace Cantera { } - //! Update the pure-species viscosities functional dependence on concentration. + // Update the pure-species viscosities functional dependence on concentration. void LiquidTransport::updateViscosities_C() { m_visc_conc_ok = true; } - /** + /* * Updates the array of pure species viscosities internally * using calls to the appropriate LTPspecies subclass. * The flag m_visc_ok is set to true. @@ -1401,13 +1401,13 @@ namespace Cantera { } - //! Update the pure-species ionic conductivities functional dependence on concentration. + // Update the pure-species ionic conductivities functional dependence on concentration. void LiquidTransport::updateIonConductivity_C() { m_ionCond_conc_ok = true; } - /** + /* * Updates the array of pure species ionic conductivities internally * using calls to the appropriate LTPspecies subclass. * The flag m_ionCond_ok is set to true. @@ -1423,13 +1423,12 @@ namespace Cantera { } - //! Update the pure-species mobility ratios functional dependence on concentration. + // Update the pure-species mobility ratios functional dependence on concentration. void LiquidTransport::updateMobilityRatio_C() { m_mobRat_conc_ok = true; } - - /** + /* * Updates the array of pure species mobility ratios internally * using calls to the appropriate LTPspecies subclass. * The flag m_mobRat_ok is set to true. @@ -1448,13 +1447,13 @@ namespace Cantera { } - //! Update the pure-species self diffusion functional dependence on concentration. + // Update the pure-species self diffusion functional dependence on concentration. void LiquidTransport::updateSelfDiffusion_C() { m_selfDiff_conc_ok = true; } - /** + /* * Updates the array of pure species self diffusion internally * using calls to the appropriate LTPspecies subclass. * The flag m_selfDiff_ok is set to true. @@ -1472,15 +1471,14 @@ namespace Cantera { m_selfDiff_mix_ok = false; } - //! Update the pure-species viscosities functional dependence on concentration. void LiquidTransport::updateHydrodynamicRadius_C() { m_radi_conc_ok = true; } - //! Update the temperature-dependent hydrodynamic radius terms - //! for each species internally using calls to the - //! appropriate LTPspecies subclass + // Update the temperature-dependent hydrodynamic radius terms + // for each species internally using calls to the + // appropriate LTPspecies subclass void LiquidTransport::updateHydrodynamicRadius_T() { int k; @@ -1491,35 +1489,6 @@ namespace Cantera { m_radi_mix_ok = false; } - //! Updates the internal value of the gradient of the - //! logarithm of the activity coefficients, which is - //! used in the gradient of the chemical potential. - /** - * Evaluate the gradients of the activity coefficients - * as they alter the diffusion coefficient. - * - * The gradient of the chemical potential can be written in terms of - * gradient of the logarithm of the mole fraction times a correction - * associated with the gradient of the activity coefficient relative to - * that of the mole fraction. Specifically, the gradients of the - * logarithms of each are involved according to the formula - - * \f[ - * \nabla \mu_k = RT \nabla ( \ln X_k ) - * \left[ 1 + \nabla ( \ln \gamma_k ) / \nabla ( \ln X_k ) \right] - * \f] - * - * The required quantity is the derivitive of the logarithm of the - * activity coefficient with respect to the derivative of the - * logarithm of the mole fraction (or whatever concentration - * variable we are using to express chemical potential. - * - * Updates the vector over species i: - * \[ - * \partial \left[ \ln ( \gamma_i ) \right] - * / \partial \left[ \ln ( \X_i ) \right] - * \] - */ void LiquidTransport::update_Grad_lnAC() { int k; @@ -1553,7 +1522,7 @@ namespace Cantera { * Solve for the diffusional velocities in the Stefan-Maxwell equations * */ - //! Solve the stefan_maxell equations for the diffusive fluxes. + // Solve the stefan_maxell equations for the diffusive fluxes. /* * The diffusive mass flux of species \e k is computed * using the Stefan-Maxwell equation diff --git a/Cantera/src/transport/LiquidTransport.h b/Cantera/src/transport/LiquidTransport.h index 7fd7c4a86..c2253d2a9 100644 --- a/Cantera/src/transport/LiquidTransport.h +++ b/Cantera/src/transport/LiquidTransport.h @@ -50,30 +50,36 @@ namespace Cantera { * The class LiquidTransport has several roles. * -# It brings together the individual species transport * properties, expressed as subclasses of LTPspecies - * (Liquid Transport Properties of Species), with - * models for the composition dependence of liquid - * transport properties expressed as subclasses of - * LiquidTranInteraction. - * + * (Liquid Transport Properties of Species) through + * LiquidTransportData, with models for + * the composition dependence of liquid transport properties + * expressed as subclasses of LiquidTranInteraction + * (mixing rules) through LiquidTransportParams. Calculating + * mixture properties generally consists of calling the + * getMixTansProp member of LiquidTranInteraction by passing + * a vector of LTPSpecies * -# It calculates the bulk velocity \f$ \vec{v} \f$ and * individual species diffusion velocities, \f$ \vec{V_i} \f$ - * using the Stefan-Maxwell equations. It is - * possible to set a flag to calculate relative to a - * mass-averaged bulk velocity, relative to a mole-averaged - * bulk velocity or relative to a single species velocity - * using the keyword. - * Mass-averaged velocities are the default for which the - * diffusion velocities satisfy + * using the Stefan-Maxwell equations. It is possible to set a + * flag to calculate relative to a mass-averaged bulk velocity, + * relative to a mole-averaged bulk velocity or relative to a + * single species velocity using the , + * , or + * keyword. Mass-averaged velocities are the default for which + * the diffusion velocities satisfy * \f[ * \sum_{i} Y_i \vec{V_i} = 0 * \f] * for mass fraction \f$ Y_i \f$. For mole-averaged velocities * \f[ - * \sum_{i} X_i \vec{V_i} = 0 + * \sum_{i} X_i \vec{V_i} = 0 * \f] - * for mole fraction \f$ X_i \f$. - * - * -# It provides acccess to a number of derived quantities + * for mole fraction \f$ X_i \f$. or + * \f[ + * \vec{V_i} = 0 + * \f] + * for reference species \f$ i \f$. + * -# It provides access to a number of derived quantities * related to transport properties as described in the * various methods below. * @@ -198,16 +204,21 @@ namespace Cantera { */ virtual void getSpeciesIonConductivity(doublereal* const ionCond); - //! Returns the mobility ratio of the solution + //! Returns the pointer to the mobility ratios of the binary + //! combinations of the transported species for the solution + //! Has size of the number of binary interactions = nsp*nsp /*! * The mobility ratio calculation is handled by subclasses of * LiquidTranInteraction as specified in the input file. * These in turn employ subclasses of LTPspecies to - * determine the individual species mobility ratios. + * determine the mobility ratios in the pure species. */ virtual void mobilityRatio(double* mobRat); - //! Returns the pure species mobility ratios for all species + //! Returns a double pointer to the mobility ratios of the + //! transported species in each pure species phase. + //! Has size of the number of binary interactions by the number + //! of species (nsp*nsp X nsp) /*! * The pure species mobility ratios are evaluated using the * appropriate subclasses of LTPspecies as specified in the @@ -218,7 +229,8 @@ namespace Cantera { */ virtual void getSpeciesMobilityRatio(double** mobRat); - //! Returns the self diffusion coefficients of the species in the phase + //! Returns the self diffusion coefficients of the species in the phase. + //! Has size of nsp(coeffs) /*! * The self diffusion coefficient is the diffusion coefficient of a tracer species * at the current temperature and composition of the species. Therefore, @@ -246,7 +258,8 @@ namespace Cantera { */ virtual void selfDiffusion(doublereal * const selfDiff); - //! Returns the pure species self diffusion in solution of each species + //! Returns the self diffusion coefficients in the pure species phases. + //! Has size of nsp(coeffs) x nsp(phases) /*! * The pure species molar volumes are evaluated using the * appropriate subclasses of LTPspecies as specified in the @@ -713,10 +726,10 @@ namespace Cantera { //! Updates the internal value of the gradient of the - //! logarithm of the activity coefficients, which is + //! logarithm of the activity, which is //! used in the gradient of the chemical potential. /** - * Evaluate the gradients of the activity coefficients + * Evaluate the gradients of the activity * as they alter the diffusion coefficient. * * The gradient of the chemical potential can be written in terms of @@ -724,22 +737,17 @@ namespace Cantera { * associated with the gradient of the activity coefficient relative to * that of the mole fraction. Specifically, the gradients of the * logarithms of each are involved according to the formula - + * * \f[ - * \nabla \mu_k = RT \nabla ( \ln X_k ) - * \left[ 1 + \nabla ( \ln \gamma_k ) / \nabla ( \ln X_k ) \right] + * \nabla \mu_k = RT \left[ \nabla ( \ln X_k ) + + * \nabla ( \ln \gamma_k ) \right] = RT \left[ + * \nabla ( \ln a_k ) \right] * \f] * - * The required quantity is the derivitive of the logarithm of the - * activity coefficient with respect to the derivative of the - * logarithm of the mole fraction (or whatever concentration - * variable we are using to express chemical potential. - * - * Updates the vector over species i: - * \[ - * \partial \left[ \ln ( \gamma_i ) \right] - * / \partial \left[ \ln ( \X_i ) \right] - * \] + * The gradient in the activity coefficient requires the use of thermophase + * getdlnActCoeff that calculates its change based on a chane in the state + * (i.e. temperature and composition of each species) which was first + * implemented in MargulesVPSSTP.cpp (LiquidTransport.h doxygen) */ virtual void update_Grad_lnAC(); @@ -768,7 +776,11 @@ namespace Cantera { * or mass-weighted basis, or the diffusion velocities may * be specified as relative to a specific species (i.e. a * solvent) all according to the \verbatim - * \endverbatim input parameter. + * \endverbatim input para + * The gradient in the activity coefficient requires the use of thermophase + * getdlnActCoeff that calculates its change based on a change in the state + * i.e. temperature and composition of each species. + * First implemented in MargulesVPSSTP.cppmeter. * * One of the Stefan Maxwell equations is replaced by the appropriate * definition of the mass-averaged velocity, the mole-averaged velocity @@ -932,18 +944,18 @@ namespace Cantera { */ LiquidTranInteraction *m_ionCondMixModel; - //! Mobility ratio for each species expressed as an appropriate subclass - //! of LTPspecies + typedef std::vector LTPvector; + //! Mobility ratio for the binary cominations of each species in each + //! pure phase expressed as an appropriate subclass of LTPspecies /*! * These subclasses of LTPspecies evaluate the species-specific * transport properties according to the parameters parsed in * TransportFactory::getLiquidSpeciesTransportData(). */ - typedef std::vector LTPvector; std::vector m_mobRatTempDep_Ns; - //! Mobility ratio of the mixture expressed as a subclass of - //! LiquidTranInteraction + //! Mobility ratio for each binary combination of mobile species in the mixture + //! expressed as a subclass of LiquidTranInteraction /*! * These subclasses of LiquidTranInteraction evaluate the * mixture transport properties according to the parameters parsed in @@ -951,8 +963,8 @@ namespace Cantera { */ std::vector m_mobRatMixModel; - //! Self Diffusion for each species expressed as an appropriate subclass - //! of LTPspecies + //! Self Diffusion for each species in each pure species phase + //! expressed as an appropriate subclass of LTPspecies /*! * These subclasses of LTPspecies evaluate the species-specific * transport properties according to the parameters parsed in @@ -960,7 +972,7 @@ namespace Cantera { */ std::vector m_selfDiffTempDep_Ns; - //! Self Diffusion of the mixture expressed as a subclass of + //! Self Diffusion for each species in the mixture expressed as a subclass of //! LiquidTranInteraction /*! * These subclasses of LiquidTranInteraction evaluate the @@ -1058,19 +1070,16 @@ namespace Cantera { */ vector_fp m_Grad_X; - //! Gradient of the logarithm of the activity coefficients + //! Gradient of the logarithm of the activity /*! * This quantity appears in the gradient of the chemical potential. - * It multiplies the gradient of the mole fraction, and in this way + * It replaces the gradient of the mole fraction, and in this way * serves to "modify" the diffusion coefficient. * - * m_Grad_lnAC[k] = \nabla \ln ( \gamma_i ) + \nabla \ln ( \X_i ) - * - * Note that where "mole fraction" is used here, whatever - * concentration-related variable applies, so that if - * molality is the concentration variable, the gradient of the - * activity coefficient should be with respect to the molality. - * m_nsp is the number of species in the fluid + * \f[ + * m\_Grad\_lnAC[k] = \nabla ( \ln X_k ) + + * \nabla ( \ln \gamma_k ) + * \f] * * k is the species index * n is the dimensional index (x, y, or z). It has a length @@ -1124,7 +1133,7 @@ namespace Cantera { * n is the dimensional index (x, y, or z) * * \f[ - * m_Grad_mu[n*m_nsp + k] + * m\_Grad\_mu[n*m_nsp + k] * \f] */ vector_fp m_Grad_mu; diff --git a/Cantera/src/transport/LiquidTransportData.cpp b/Cantera/src/transport/LiquidTransportData.cpp index 416072452..1b0625f7b 100644 --- a/Cantera/src/transport/LiquidTransportData.cpp +++ b/Cantera/src/transport/LiquidTransportData.cpp @@ -90,13 +90,13 @@ namespace Cantera { - //! Copy constructor + // Copy constructor LTPspecies::LTPspecies( const LTPspecies &right ) { *this = right; //use assignment operator to do other work } - //! Assignment operator + // Assignment operator LTPspecies& LTPspecies::operator=(const LTPspecies& right ) { if (&right != this) { @@ -111,9 +111,9 @@ namespace Cantera { } - //! Construct an LTPspecies object for a liquid tranport property - //! expressed as a constant value. - /** The transport property is constructed from the XML node, + // Construct an LTPspecies object for a liquid tranport property + // expressed as a constant value. + /* 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) @@ -131,14 +131,14 @@ namespace Cantera { } else throw LTPError("negative or zero " + propNode.name() ); } - //! Copy constructor + // Copy constructor LTPspecies_Const::LTPspecies_Const( const LTPspecies_Const &right ) : LTPspecies() { *this = right; //use assignment operator to do other work } - //! Assignment operator + // Assignment operator LTPspecies_Const& LTPspecies_Const::operator=(const LTPspecies_Const& right ) { if (&right != this) { @@ -153,16 +153,16 @@ namespace Cantera { return *this; } - //! Return the (constant) value for this transport property + // Return the (constant) value for this transport property doublereal LTPspecies_Const::getSpeciesTransProp( ) { return m_coeffs[0]; } /////////////////////////////////////////////////////////////// - //! Construct an LTPspecies object for a liquid tranport property - //! expressed in extended Arrhenius form. - /** The transport property is constructed from the XML node, + // Construct an LTPspecies object for a liquid tranport property + // expressed in extended Arrhenius form. + /* 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) @@ -188,14 +188,14 @@ namespace Cantera { m_coeffs.push_back( log( A_k ) ); } - //! Copy constructor + // Copy constructor LTPspecies_Arrhenius::LTPspecies_Arrhenius( const LTPspecies_Arrhenius &right ) : LTPspecies() { *this = right; //use assignment operator to do other work } - //! Assignment operator + // Assignment operator LTPspecies_Arrhenius& LTPspecies_Arrhenius::operator=(const LTPspecies_Arrhenius& right ) { if (&right != this) { @@ -215,9 +215,9 @@ namespace Cantera { return *this; } - //! Return the pure species value for this transport property evaluated - //! from the Arrhenius expression - /** + // Return the pure species value for this transport property evaluated + // from the Arrhenius expression + /* * In general the Arrhenius expression is * * \f[ @@ -265,9 +265,9 @@ namespace Cantera { /////////////////////////////////////////////////////////////// - //! Construct an LTPspecies object for a liquid tranport property - //! expressed as a polynomial in temperature. - /** The transport property is constructed from the XML node, + // 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) @@ -290,14 +290,14 @@ namespace Cantera { }*/ } - //! Copy constructor + // Copy constructor LTPspecies_Poly::LTPspecies_Poly( const LTPspecies_Poly &right ) : LTPspecies() { *this = right; //use assignment operator to do other work } - //! Assignment operator + // Assignment operator LTPspecies_Poly& LTPspecies_Poly::operator=(const LTPspecies_Poly& right ) { if (&right != this) { @@ -315,8 +315,8 @@ namespace Cantera { return *this; } - //! 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(); @@ -338,9 +338,9 @@ namespace Cantera { /////////////////////////////////////////////////////////////// - //! Construct an LTPspecies object for a liquid tranport property - //! expressed as an exponential in temperature. - /** The transport property is constructed from the XML node, + // 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) @@ -363,14 +363,14 @@ namespace Cantera { }*/ } - //! Copy constructor + // Copy constructor LTPspecies_ExpT::LTPspecies_ExpT( const LTPspecies_ExpT &right ) : LTPspecies() { *this = right; //use assignment operator to do other work } - //! Assignment operator + // Assignment operator LTPspecies_ExpT& LTPspecies_ExpT::operator=(const LTPspecies_ExpT& right ) { if (&right != this) { @@ -388,8 +388,8 @@ namespace Cantera { return *this; } - //! Return the value for this transport property evaluated - //! from the exponential in temperature expression + // Return the value for this transport property evaluated + // from the exponential in temperature expression doublereal LTPspecies_ExpT::getSpeciesTransProp( ) { doublereal t = m_thermo->temperature(); diff --git a/Cantera/src/transport/LiquidTransportData.h b/Cantera/src/transport/LiquidTransportData.h index 78d7a80b8..276d32409 100644 --- a/Cantera/src/transport/LiquidTransportData.h +++ b/Cantera/src/transport/LiquidTransportData.h @@ -223,8 +223,8 @@ namespace Cantera { //! Class LTPspecies_Const holds transport parameters for a - //! specific liquid-phase species when the transport property - //! is just a constant value. + //! specific liquid-phase species (LTPspecies) when the + //! transport property is just a constant value. /*! * As an example of the input required for LTPspecies_Const * consider the following XML fragment @@ -245,6 +245,13 @@ namespace Cantera { public: + //! Construct an LTPspecies object for a liquid tranport property + //! expressed as a constant value. + /** 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_Const( const XML_Node &propNode, std::string name, TransportPropertyList tp_ind, @@ -279,9 +286,15 @@ namespace Cantera { //! Class LTPspecies_Arrhenius holds transport parameters for a - //! specific liquid-phase species when the transport property - //! is expressed in Arrhenius form. + //! specific liquid-phase species (LTPspecies) when the + //! transport property is expressed in Arrhenius form. /*! + * Used for pure species properties with equations of the form + * \f[ + * x = A T^b \exp( - E / RT ) + * \f] + * where A, b, and E are passed in the xml input file. + * * As an example of the input required for LTPspecies_Arrhenius * consider the following XML fragment * @@ -304,6 +317,13 @@ namespace Cantera { public: + //! Construct an LTPspecies object for a liquid tranport property + //! expressed in extended Arrhenius form. + /** 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_Arrhenius( const XML_Node &propNode, std::string name, TransportPropertyList tp_ind, @@ -366,9 +386,15 @@ namespace Cantera { //! Class LTPspecies_Poly holds transport parameters for a - //! specific liquid-phase species when the transport property - //! is expressed as a polynomial in temperature. + //! specific liquid-phase species (LTPspecies) when the transport + //! property is expressed as a polynomial in temperature. /*! + * Used for pure species properties with equations of the form + * \f[ + * x = f[0] + f[1] T + ... + f[N] T^N + * \f] + * where f[i] are elements of the float array passed in. + * * As an example of the input required for LTPspecies_Poly * consider the following XML fragment * @@ -388,6 +414,13 @@ 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, TransportPropertyList tp_ind, @@ -428,9 +461,15 @@ namespace Cantera { //! Class LTPspecies_ExpT holds transport parameters for a - //! specific liquid-phase species when the transport property - //! is expressed as a exponential in temperature. + //! specific liquid-phase species (LTPspecies) when the transport + //! property is expressed as a exponential in temperature. /** + * Used for pure species properties with equations of the form + * \f[ + * x = f[0] \exp( f[1] T + ... + f[N] T ) + * \f] + * where f[i] are elements of the float array passed in. + * * As an example of the input required for LTPspecies_ExpT * consider the following XML fragment * @@ -450,6 +489,13 @@ 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) + */ LTPspecies_ExpT( const XML_Node &propNode, std::string name, TransportPropertyList tp_ind, diff --git a/Cantera/src/transport/LiquidTransportParams.cpp b/Cantera/src/transport/LiquidTransportParams.cpp index 48ee0ca72..53723e68d 100644 --- a/Cantera/src/transport/LiquidTransportParams.cpp +++ b/Cantera/src/transport/LiquidTransportParams.cpp @@ -44,8 +44,8 @@ namespace Cantera { }; - //!Constructor - /** + // Constructor + /* * @param tp_ind Index indicating transport property type (i.e. viscosity) */ LiquidTranInteraction::LiquidTranInteraction( TransportPropertyList tp_ind ) : @@ -199,12 +199,12 @@ namespace Cantera { } } - //! Copy constructor + // Copy constructor LiquidTranInteraction::LiquidTranInteraction( const LiquidTranInteraction &right ) { *this = right; //use assignment operator to do other work } - //! Assignment operator + // Assignment operator LiquidTranInteraction& LiquidTranInteraction::operator=( const LiquidTranInteraction &right ) { if (&right != this) { @@ -702,20 +702,15 @@ namespace Cantera { // Reaction Coeffs and Charges std::vector viS(6); std::vector charges(3); - ions_thermo->getDissociationCoeffs(viS,charges); + std::vector neutMolIndex(3); + ions_thermo->getDissociationCoeffs(viS,charges,neutMolIndex); if ((int)anion.size() != 1) throw CanteraError("LTI_StefanMaxwell_PPN::getMatrixTransProp","Must have one anion only for StefanMaxwell_PPN"); if ((int)cation.size() != 2) throw CanteraError("LTI_StefanMaxwell_PPN::getMatrixTransProp","Must have two cations of equal charge for StefanMaxwell_PPN"); if (charges[cation[0]] != charges[cation[1]]) - throw CanteraError("LTI_StefanMaxwell_PPN::getMatrixTransProp","Cations must be of equal charge for StefanMaxwell_PPN"); - - /* - cout << "cation 0: " << speciesNames[cation[0]] << endl; - cout << "cation 1: " << speciesNames[cation[1]] << endl; - cout << "anion 0: " << speciesNames[anion[0]] << endl; - */ + throw CanteraError("LTI_StefanMaxwell_PPN::getMatrixTransProp","Cations must be of equal charge for StefanMaxwell_PPN") m_ionCondMix = m_ionCondMixModel->getMixTransProp(m_ionCondSpecies); @@ -738,15 +733,6 @@ namespace Cantera { m_selfDiffMix[k] = m_selfDiffMixModel[k]->getMixTransProp( m_selfDiffSpecies[k] ); } - /* - for ( i = 0; i < nsp; i++ ) { - cout << "D" << i << "* = " << m_selfDiffMix[i] << endl; - for ( j = 0; j < nsp; j++ ) { - cout << "ratio" << i << j << " = " << m_mobRatMix(i,j) << endl; - } - } - */ - int vP = max(viS[cation[0]],viS[cation[1]]); int vM = viS[anion[0]]; int zP = charges[cation[0]]; @@ -755,38 +741,18 @@ namespace Cantera { doublereal inv_vP_vM_MutualDiff; vector_fp dlnActCoeffdlnN; dlnActCoeffdlnN.resize(neut_molefracs.size(),0.0); + marg_thermo->getdlnActCoeffdlnN(&dlnActCoeffdlnN[0]); - std::string cationIndex (4,'0'); - for ( i = 0; i < 2; i++ ) - for ( j = 0; j < 2; j++ ) - if ( viS[i*nsp+cation[j]] > 0 ) - cationIndex[i*2+j] = '1'; - - if ( (cationIndex == "1001") | (cationIndex == "0110") ) { - xA = neut_molefracs[cation[0]]; - xB = neut_molefracs[cation[1]]; - eps = (1-m_mobRatMix(cation[1],cation[0]))/(xA+xB*m_mobRatMix(cation[1],cation[0])); - marg_thermo->getdlnActCoeffdlnN(&dlnActCoeffdlnN[0]); - inv_vP_vM_MutualDiff = (xA*(1+dlnActCoeffdlnN[cation[1]])/m_selfDiffMix[cation[1]]+xB*(1+dlnActCoeffdlnN[cation[0]])/m_selfDiffMix[cation[0]]); - //marg_thermo->getdlnActCoeffdlnX(&dlnActCoeffdlnN[0]); - //inv_vP_vM_MutualDiff = (xA*(1+dlnActCoeffdlnN[cation[1]])/m_selfDiffMix[cation[1]]+xB*(1+dlnActCoeffdlnN[cation[0]])/m_selfDiffMix[cation[0]]); - } - else - throw CanteraError("LTI_StefanMaxwell_PPN::getMixTransProp","Dissociation reactions don't make sense: cationIndex = " + cationIndex); + xA = neut_molefracs[neutMolIndex[cation[0]]]; + xB = neut_molefracs[neutMolIndex[cation[1]]]; + eps = (1-m_mobRatMix(cation[1],cation[0]))/(xA+xB*m_mobRatMix(cation[1],cation[0])); + inv_vP_vM_MutualDiff = (xA*(1+dlnActCoeffdlnN[neutMolIndex[cation[1]]])/m_selfDiffMix[cation[1]]+xB*(1+dlnActCoeffdlnN[neutMolIndex[cation[0]]])/m_selfDiffMix[cation[0]]); mat.resize( nsp, nsp, 0.0 ); mat(cation[0],cation[1]) = mat(cation[1],cation[0]) = (1+vM/vP)*(1+eps*xB)*(1-eps*xA)*inv_vP_vM_MutualDiff-zP*zP*Faraday*Faraday/GasConstant/temp/m_ionCondMix/vol; mat(cation[0],anion[0]) = mat(anion[0],cation[0]) = (1+vP/vM)*(-eps*xB*(1-eps*xA)*inv_vP_vM_MutualDiff)-zP*zM*Faraday*Faraday/GasConstant/temp/m_ionCondMix/vol; mat(cation[1],anion[0]) = mat(anion[0],cation[1]) = (1+vP/vM)*(eps*xA*(1+eps*xB)*inv_vP_vM_MutualDiff)-zP*zM*Faraday*Faraday/GasConstant/temp/m_ionCondMix/vol; -/* - for ( i = 0; i < nsp; i++ ) { - for ( j = 0; j < nsp; j++ ) { - mat(i,j) = 1.0/mat(i,j); - //cout << "D" << i << j << " = " << mat(i,j) << endl; - } - } -*/ } diff --git a/Cantera/src/transport/LiquidTransportParams.h b/Cantera/src/transport/LiquidTransportParams.h index 860ee96b1..ba68fcd2a 100644 --- a/Cantera/src/transport/LiquidTransportParams.h +++ b/Cantera/src/transport/LiquidTransportParams.h @@ -117,6 +117,7 @@ namespace Cantera { * obtained through some mixing rule. These are obtained using the * method getMixTransProp(). Viscosity is typical of this. * Second there are properties for which a matrix of properties may + * @param tp_ind * exist. This matrix of properties is obtained from the method * getMatrixTransProp(). Diffusion coefficients are of this type. * Subclasses should implement the appropriate one or both of @@ -201,9 +202,8 @@ namespace Cantera { }; /** - * Holds transport model parameters relevant to transport in - * liquids for which activated jump processes limit transport - * (giving Arrhenius type transport properties). + * Class LiquidTransportParams holds transport model parameters + * relevant to transport in mixtures. * Used by TransportFactory. */ class LiquidTransportParams : public TransportParams { @@ -313,6 +313,11 @@ namespace Cantera { doublereal getMixTransProp( doublereal *valueSpecies, doublereal *weightSpecies = 0 ); doublereal getMixTransProp( std::vector LTPptrs ) ; + //! Return the matrix of binary interaction parameters. + /** + * Takes the proper mixing rule for the binary interaction parameters + * and calculates them: Not implemented for this mixing rule. + */ void getMatrixTransProp( DenseMatrix &mat, doublereal* speciesValues = 0 ) { mat = (*m_Aij[0]); } protected: @@ -355,6 +360,11 @@ namespace Cantera { doublereal getMixTransProp( doublereal *valueSpecies, doublereal *weightSpecies = 0 ); doublereal getMixTransProp( std::vector LTPptrs ) ; + //! Return the matrix of binary interaction parameters. + /** + * Takes the proper mixing rule for the binary interaction parameters + * and calculates them: Not Implemented for this Mixing rule; + */ void getMatrixTransProp( DenseMatrix &mat, doublereal* speciesValues = 0 ) { mat = (*m_Aij[0]); } protected: @@ -398,6 +408,11 @@ namespace Cantera { doublereal getMixTransProp( doublereal *valueSpecies, doublereal *weightSpecies = 0 ); doublereal getMixTransProp( std::vector LTPptrs ) ; + //! Return the matrix of binary interaction parameters. + /** + * Takes the proper mixing rule for the binary interaction parameters + * and calculates them: Not implemented for this mixing rule. + */ void getMatrixTransProp( DenseMatrix &mat, doublereal* speciesValues = 0 ) { mat = (*m_Aij[0]); } protected: @@ -472,6 +487,11 @@ namespace Cantera { doublereal getMixTransProp( doublereal *valueSpecies, doublereal *weightSpecies = 0 ); doublereal getMixTransProp( std::vector LTPptrs ) ; + //! Return the matrix of binary interaction parameters. + /** + * Takes the proper mixing rule for the binary interaction parameters + * and calculates them: Not implemented for this mixing rule. + */ void getMatrixTransProp( DenseMatrix &mat, doublereal* speciesValues = 0 ) { mat = m_Eij; } protected: @@ -531,6 +551,11 @@ namespace Cantera { doublereal getMixTransProp( doublereal *valueSpecies, doublereal *weightSpecies = 0 ); doublereal getMixTransProp( std::vector LTPptrs ) ; + //! Return the matrix of binary interaction parameters. + /** + * Takes the proper mixing rule for the binary interaction parameters + * and calculates them + */ void getMatrixTransProp( DenseMatrix &mat, doublereal* speciesValues = 0 ) ; protected: @@ -540,14 +565,62 @@ namespace Cantera { //! Stefan Maxwell Diffusion Coefficients can be solved for given //! ion conductivity, mobility ratios, and self diffusion coeffs. - //! This method is only valid for a common anion mixture of two - //! salts with cations of equal charge. + //! This class is only valid for a common anion mixture of two + //! salts with cations of equal charge. Hence the name _PPN. /** + * * This class requres you specify + * * 1 - ion conductivity - * 2 - mobility ratio of the two cations - * 3 - mutual diffusion coefficient (can be approximated using - * the self diffusion coefficients of the cations + * + * 2 - mobility ratio of the two cations (set all other ratios to zero) + * + * 3 - Self diffusion coefficients of the cations (set others to zero) + * is used to calculate the "mutual diffusion coefficient". The + * approximation needed to do so requires the cations have equal charge. + * + * We than calculate the Stefan Maxwell Diffusion Coefficients by + * \f[ + * \frac{1}{D_{12}} = (1-\epsilon X_A)(1+\epsilon X_B) + * \frac{\nu_- + \nu_+}{\nu_-\nu_+^2D} + * + \frac{z_-z_+ F^2}{\kappa V R T} + * \f] + * \f[ + * \frac{1}{D_{12}} = -\epsilon X_B(1-\epsilon X_A) + * \frac{\nu_- + \nu_+}{\nu_-^2\nu_+D} + * - \frac{z_-z_+ F^2}{\kappa V R T} + * \f] + * \f[ + * \frac{1}{D_{23}} = \epsilon X_A(1+\epsilon X_B) + * \frac{\nu_- + \nu_+}{\nu_-^2\nu_+D} + * - \frac{z_-z_+ F^2}{\kappa V R T} + * \f] + * where F is Faraday's constant, RT is the gas constant times the + * tempurature, and V is the molar volume (basis is moles of ions) that is + * calculated by the thermophase member. X_A and X_B are the mole fractions + * of the salts composed of cation(1) and cation(2), respectively, that share + * a common anion(3). \f$\nu_{+,-}\f$ are the stoichiometric coefficients in + * the dissociation reaction of the salts to the ions with charges of + * \f$z_{+,-}\f$. Assuming that the cations have equal charge, the "mutual + * diffusion coefficient" is calculated using the cation self diffusion + * coefficients. + * \f[ + * \frac{1}{\nu_-\nu_+D} = \left(1+\frac{\partial \gamma_B}{\partial N_B} + * \right)\frac{X_A}{D_2^*}+\left(1+\frac{\partial \gamma_A}{\partial N_A} + * \right)\frac{X_B}{D_1^*} + * \f] + * where the self diffusion coefficients, \f$D_i^*\f$, are temperature and + * composition parameterized inputs and the derivative of the activity + * coefficient, \f$\frac{\partial \gamma_B}{\partial N_B}\f$, is calculated + * by the thermophase member using the excess enthalpy and entropy upon mixing. + * + * Finally, the deviation of the transferrence numbers from ideality, + * \f$\epsilon\f$, is calculated from the mobility ratio of the cations. + * \f[ + * \epsilon = \frac{1-b_2/b_1}{X_A+X_Bb_2/b_1} + * \f] + * Where \f$b_i\f$ are the mobilities of the two cations. Everywhere, + * cation 1 corresponds with salt A and cation 2 with salt B. * * Sample input for this method is * \verbatim @@ -589,8 +662,12 @@ namespace Cantera { doublereal getMixTransProp( doublereal *valueSpecies, doublereal *weightSpecies = 0 ); doublereal getMixTransProp( std::vector LTPptrs ) ; + //! Return the matrix of binary interaction parameters. + /** + * Takes the proper mixing rule for the binary interaction parameters + * and calculates them + */ void getMatrixTransProp( DenseMatrix &mat, doublereal* speciesValues = 0 ) ; - //CAL void getMatrixTransProp( DenseMatrix &mat, LiquidTransport* lt, doublereal* speciesValues = 0 ) ; protected: @@ -637,6 +714,11 @@ namespace Cantera { doublereal getMixTransProp( doublereal *valueSpecies, doublereal *weightSpecies = 0 ); doublereal getMixTransProp( std::vector LTPptrs ) ; + //! Return the matrix of binary interaction parameters. + /** + * Takes the proper mixing rule for the binary interaction parameters + * and calculates them + */ void getMatrixTransProp( DenseMatrix &mat, doublereal* speciesValues = 0 ) ; protected: @@ -681,6 +763,11 @@ namespace Cantera { doublereal getMixTransProp( doublereal *valueSpecies, doublereal *weightSpecies = 0 ); doublereal getMixTransProp( std::vector LTPptrs ) ; + //! Return the matrix of binary interaction parameters. + /** + * Takes the proper mixing rule for the binary interaction parameters + * and calculates them: Not Implemented for this mixing rule + */ void getMatrixTransProp( DenseMatrix &mat, doublereal* speciesValues = 0 ) { mat = (*m_Aij[0]); } //CAL void getMatrixTransProp( DenseMatrix &mat, LiquidTransport* lt, doublereal* speciesValues = 0 ) { mat = (*m_Aij[0]); } diff --git a/Cantera/src/transport/TransportBase.cpp b/Cantera/src/transport/TransportBase.cpp index dcd317875..1bb18c2e3 100644 --- a/Cantera/src/transport/TransportBase.cpp +++ b/Cantera/src/transport/TransportBase.cpp @@ -84,17 +84,15 @@ namespace Cantera { return m_index; } - /* - * Set an integer index number. This is for internal use of + /* Set an integer index number. This is for internal use of * Cantera, and may be removed in the future. */ void Transport::setIndex(int i) { m_index = i; } - //! Set the number of dimensions to be expected in flux expressions - /*! - * Internal memory will be set with this value + // Set the number of dimensions to be expected in flux expressions + /* Internal memory will be set with this value */ void Transport::setNDim(const int ndim) { m_nDim = ndim; @@ -103,8 +101,7 @@ namespace Cantera { - /* - * Set transport model parameters. This method may be + /* Set transport model parameters. This method may be * overloaded in subclasses to set model-specific parameters. */ void Transport::setParameters(const int type, const int k, diff --git a/Cantera/src/transport/TransportFactory.cpp b/Cantera/src/transport/TransportFactory.cpp index 6e61559a6..c34d401d5 100644 --- a/Cantera/src/transport/TransportFactory.cpp +++ b/Cantera/src/transport/TransportFactory.cpp @@ -87,29 +87,30 @@ namespace Cantera { //////////////////// class TransportFactory methods ////////////// - /** - * Calculate second-order corrections to binary diffusion - * coefficient pair (dkj, djk). At first order, the binary - * diffusion coefficients are independent of composition, and - * d(k,j) = d(j,k). But at second order, there is a weak - * dependence on composition, with the result that d(k,j) != - * d(j,k). This method computes the multiplier by which the - * first-order binary diffusion coefficient should be multiplied - * to produce the value correct to second order. The expressions - * here are taken from Marerro and Mason, - * J. Phys. Chem. Ref. Data, vol. 1, p. 3 (1972). - * - * @param t Temperature (K) - * @param tr Transport parameters - * @param k index of first species - * @param j index of second species - * @param xmk mole fraction of species k - * @param xmj mole fraction of species j - * @param fkj multiplier for d(k,j) - * @param fjk multiplier for d(j,k) - * - * @note This method is not used currently. - */ + // Second-order correction to the binary diffusion coefficients + /* + Calculate second-order corrections to binary diffusion + coefficient pair (dkj, djk). At first order, the binary + diffusion coefficients are independent of composition, and + d(k,j) = d(j,k). But at second order, there is a weak + dependence on composition, with the result that d(k,j) != + d(j,k). This method computes the multiplier by which the + first-order binary diffusion coefficient should be multiplied + to produce the value correct to second order. The expressions + here are taken from Marerro and Mason, + J. Phys. Chem. Ref. Data, vol. 1, p. 3 (1972). + + @param t Temperature (K) + @param tr Transport parameters + @param k index of first species + @param j index of second species + @param xmk mole fraction of species k + @param xmj mole fraction of species j + @param fkj multiplier for d(k,j) + @param fjk multiplier for d(j,k) + + @note This method is not used currently. + */ void TransportFactory::getBinDiffCorrection(doublereal t, const GasTransportParams& tr, int k, int j, doublereal xk, doublereal xj, doublereal& fkj, doublereal& fjk) { @@ -176,12 +177,13 @@ namespace Cantera { } - /** - * Calculate corrections to the well depth parameter and the - * diamter for use in computing the binary diffusion coefficient - * of polar-nonpolar pairs. For more information about this - * correction, see Dixon-Lewis, Proc. Royal Society (1968). - */ + // Corrections for polar-nonpolar binary diffusion coefficients + /* + Calculate corrections to the well depth parameter and the + diamter for use in computing the binary diffusion coefficient + of polar-nonpolar pairs. For more information about this + correction, see Dixon-Lewis, Proc. Royal Society (1968). + */ void TransportFactory::makePolarCorrections(int i, int j, const GasTransportParams& tr, doublereal& f_eps, doublereal& f_sigma) { @@ -207,13 +209,13 @@ namespace Cantera { f_eps = xi*xi; } - /** - * TransportFactory(): default constructor - * - * The default constructor for this class sets up - * m_models[], a mapping between the string name - * for a transport model and the integer name. - */ + /* + TransportFactory(): default constructor + + The default constructor for this class sets up + m_models[], a mapping between the string name + for a transport model and the integer name. + */ TransportFactory::TransportFactory() : m_verbose(false), m_integrals(0) @@ -258,15 +260,15 @@ namespace Cantera { m_LTImodelMap["moleFractionsExpT"] = LTI_MODEL_MOLEFRACS_EXPT; } - /** - * Destructor - * - * We do not delete statically created single instance of this - * class here, because it would create an infinite loop if - * destructor is called for that single instance. However, we do - * have a pointer to m_integrals that does need to be - * explicitly deleted. - */ + /* + Destructor + + We do not delete statically created single instance of this + class here, because it would create an infinite loop if + destructor is called for that single instance. However, we do + have a pointer to m_integrals that does need to be + explicitly deleted. + */ TransportFactory::~TransportFactory() { if (m_integrals) { delete m_integrals; @@ -274,9 +276,7 @@ namespace Cantera { } } - /** - * This static function deletes the statically allocated instance. - */ + // This static function deletes the statically allocated instance. void TransportFactory::deleteFactory() { #if defined(THREAD_SAFE_CANTERA) boost::mutex::scoped_lock lock(transport_mutex) ; @@ -287,12 +287,12 @@ namespace Cantera { } } - /** - * make one of several transport models, and return a base class - * pointer to it. This method operates at the level of a - * single transport property as a function of temperature - * and possibly composition. - */ + /* + make one of several transport models, and return a base class + pointer to it. This method operates at the level of a + single transport property as a function of temperature + and possibly composition. + */ LTPspecies* TransportFactory::newLTP( const XML_Node &trNode, std::string &name, TransportPropertyList tp_ind, @@ -335,13 +335,13 @@ namespace Cantera { return ltps; } - /** - * make one of several transport models, and return a base class - * pointer to it. This method operates at the level of a - * single mixture transport property. Individual species - * transport properties are addressed by the LTPspecies - * returned by newLTP - */ + /* + make one of several transport models, and return a base class + pointer to it. This method operates at the level of a + single mixture transport property. Individual species + transport properties are addressed by the LTPspecies + returned by newLTP + */ LiquidTranInteraction* TransportFactory::newLTI( const XML_Node &trNode, TransportPropertyList tp_ind, LiquidTransportParams& trParam) { @@ -394,10 +394,10 @@ namespace Cantera { return lti; } - /** - * make one of several transport models, and return a base class - * pointer to it. - */ + /* + make one of several transport models, and return a base class + pointer to it. + */ Transport* TransportFactory::newTransport(std::string transportModel, thermo_t* phase, int log_level) { @@ -465,10 +465,10 @@ namespace Cantera { return tr; } - /** - * make one of several transport models, and return a base class - * pointer to it. - */ + /* + make one of several transport models, and return a base class + pointer to it. + */ Transport* TransportFactory::newTransport(thermo_t* phase, int log_level) { XML_Node &phaseNode=phase->xml(); /* @@ -488,11 +488,11 @@ namespace Cantera { } - /** - * Prepare to build a new kinetic-theory-based transport manager - * for low-density gases. Uses polynomial fits to Monchick & Mason - * collision integrals. - */ + /* + Prepare to build a new kinetic-theory-based transport manager + for low-density gases. Uses polynomial fits to Monchick & Mason + collision integrals. + */ void TransportFactory::setupMM(std::ostream &flog, const std::vector &transport_database, thermo_t* thermo, int mode, int log_level, GasTransportParams& tr) { @@ -619,10 +619,10 @@ namespace Cantera { - /** - * Prepare to build a new transport manager for liquids assuming that - * viscosity transport data is provided in Arhennius form. - */ + /* + Prepare to build a new transport manager for liquids assuming that + viscosity transport data is provided in Arhennius form. + */ void TransportFactory::setupLiquidTransport(std::ostream &flog, thermo_t* thermo, int log_level, LiquidTransportParams& trParam) { @@ -701,9 +701,9 @@ namespace Cantera { } - /** Similar to initTransport except uses LiquidTransportParams - * class and calls setupLiquidTransport(). - */ + /* Similar to initTransport except uses LiquidTransportParams + class and calls setupLiquidTransport(). + */ void TransportFactory::initLiquidTransport(Transport* tran, thermo_t* thermo, int log_level) { @@ -817,13 +817,13 @@ namespace Cantera { * *********************************************************/ - /** - * Read transport property data from a file for a list of species. - * Given the name of a file containing transport property - * parameters and a list of species names, this method returns an - * instance of TransportParams containing the transport data for - * these species read from the file. - */ + /* + Read transport property data from a file for a list of species. + Given the name of a file containing transport property + parameters and a list of species names, this method returns an + instance of TransportParams containing the transport data for + these species read from the file. + */ void TransportFactory::getTransportData(const std::vector &xspecies, XML_Node& log, const std::vector &names, GasTransportParams& tr) { @@ -940,13 +940,13 @@ namespace Cantera { } } - /** - * Read transport property data from a file for a list of species. - * Given the name of a file containing transport property - * parameters and a list of species names, this method returns an - * instance of TransportParams containing the transport data for - * these species read from the file. - */ + /* + Read transport property data from a file for a list of species. + Given the name of a file containing transport property + parameters and a list of species names, this method returns an + instance of TransportParams containing the transport data for + these species read from the file. + */ void TransportFactory::getLiquidSpeciesTransportData(const std::vector &xspecies, XML_Node& log, const std::vector &names, @@ -954,8 +954,8 @@ namespace Cantera { { std::string name; /* - * Create a map of species names versus liquid transport data parameters - */ + Create a map of species names versus liquid transport data parameters + */ std::map datatable; std::map::iterator it; @@ -1063,9 +1063,9 @@ namespace Cantera { trParam.LTData.clear(); for (int i = 0; i < trParam.nsp_; i++) { /* - * Check to see that we have a LiquidTransportData object for all of the - * species in the phase. If not, throw an error. - */ + Check to see that we have a LiquidTransportData object for all of the + species in the phase. If not, throw an error. + */ it = datatable.find(names[i]); if (it == datatable.end()) { throw TransportDBError(0,"No transport data found for species " + names[i]); @@ -1073,24 +1073,23 @@ namespace Cantera { LiquidTransportData& trdat = it->second; /* - * Now, transfer these objects into LTData in the correct phase index order by - * calling the default copy constructor for LiquidTransportData. - */ + Now, transfer these objects into LTData in the correct phase index order by + calling the default copy constructor for LiquidTransportData. + */ trParam.LTData.push_back(trdat); } } - /** - * Read transport property data from a file for interactions - * between species in a liquid. - * Given the name of a file containing transport property - * parameters and a list of species names, this method returns an - * instance of TransportParams containing the transport data for - * these species read from the file. - */ - void - TransportFactory::getLiquidInteractionsTransportData(const XML_Node &transportNode, + /* + Read transport property data from a file for interactions + between species in a liquid. + Given the name of a file containing transport property + parameters and a list of species names, this method returns an + instance of TransportParams containing the transport data for + these species read from the file. + */ + void TransportFactory::getLiquidInteractionsTransportData(const XML_Node &transportNode, XML_Node& log, const std::vector &names, LiquidTransportParams& trParam) @@ -1218,8 +1217,7 @@ namespace Cantera { /***************** fitProperties ***************/ - /** - * Generate polynomial fits for the pure-species viscosities and + /* Generate polynomial fits for the pure-species viscosities and * for the binary diffusion coefficients. If * CK_mode, then the fits are of the * form \f[ diff --git a/Cantera/src/transport/TransportFactory.h b/Cantera/src/transport/TransportFactory.h index ae85d414f..3ff192322 100644 --- a/Cantera/src/transport/TransportFactory.h +++ b/Cantera/src/transport/TransportFactory.h @@ -112,17 +112,18 @@ namespace Cantera { /** - * Deletes the statically malloced instance. + * This static function deletes the statically malloced instance. */ virtual void deleteFactory(); - /** + /*! * Destructor * - * We do not delete statically - * created single instance of this class here, because it would - * create an infinite loop if destructor is called for that - * single instance. + * We do not delete statically created single instance of this + * class here, because it would create an infinite loop if + * destructor is called for that single instance. However, we do + * have a pointer to m_integrals that does need to be + * explicitly deleted. */ virtual ~TransportFactory(); @@ -152,6 +153,7 @@ namespace Cantera { //! Build a new transport manager using a transport manager //! that may not be the same as in the phase description + //! and return a base class pointer to it /*! * @param model String name for the transport manager * @param thermo ThermoPhase object @@ -161,7 +163,7 @@ namespace Cantera { newTransport(std::string model, thermo_t* thermo, int log_level=0); //! Build a new transport manager using the default transport manager - //! in the phase description + //! in the phase description and return a base class pointer to it /*! * @param thermo ThermoPhase object * @param log_level log level @@ -169,11 +171,14 @@ namespace Cantera { virtual Transport* newTransport(thermo_t* thermo, int log_level=0); - /// Initialize an existing transport manager + //! Initialize an existing transport manager virtual void initTransport(Transport* tr, thermo_t* thermo, int mode=0, int log_level=0); - /// Initialize an existing transport manager for liquid phase + //! Initialize an existing transport manager for liquid phase + /*! Similar to initTransport except uses LiquidTransportParams + * class and calls setupLiquidTransport(). + */ virtual void initLiquidTransport(Transport* tr, thermo_t* thermo, int log_level=0); @@ -197,6 +202,14 @@ namespace Cantera { */ TransportFactory(); + //! Read Transport Database + /*! + * Read transport property data from a file for a list of species. + * Given the name of a file containing transport property + * parameters and a list of species names, this method returns an + * instance of TransportParams containing the transport data for + * these species read from the file. + */ void getTransportData(const std::vector &db, XML_Node& log, const std::vector& names, GasTransportParams& tr); @@ -236,33 +249,84 @@ namespace Cantera { XML_Node& log, const std::vector& names, LiquidTransportParams& tr); - /** Generate polynomial fits to viscosity, conductivity, and - * binary diffusion coefficients */ + //! Generate polynomial fits to viscosity, conductivity, and + //! binary diffusion coefficients */ + /*! If CK_mode, then the fits are of the form + * \f[ + * \log(\eta(i)) = \sum_{n = 0}^3 a_n(i) (\log T)^n + * \f] + * and \f[ + * \log(D(i,j)) = \sum_{n = 0}^3 a_n(i,j) (\log T)^n + * \f] + * Otherwise the fits are of the form + * \f[ + * \eta(i)/sqrt(k_BT) = \sum_{n = 0}^4 a_n(i) (\log T)^n + * \f] + * and \f[ + * D(i,j)/sqrt(k_BT)) = \sum_{n = 0}^4 a_n(i,j) (\log T)^n + * \f] + */ void fitProperties(GasTransportParams& tr, std::ostream & logfile); - /// Generate polynomial fits to collision integrals + //! Generate polynomial fits to collision integrals void fitCollisionIntegrals(std::ostream & logfile, GasTransportParams& tr); - + /** + * Prepare to build a new kinetic-theory-based transport manager + * for low-density gases. Uses polynomial fits to Monchick & Mason + * collision integrals. + */ void setupMM(std::ostream &flog, const std::vector &transport_database, thermo_t* thermo, int mode, int log_level, GasTransportParams& tr); - + /** + * Prepare to build a new transport manager for liquids assuming that + * viscosity transport data is provided in Arhennius form. + */ void setupLiquidTransport(std::ostream &flog, thermo_t* thermo, int log_level, LiquidTransportParams& tr); - /// Second-order correction to the binary diffusion coefficients + //! Second-order correction to the binary diffusion coefficients + /*! + * Calculate second-order corrections to binary diffusion + * coefficient pair (dkj, djk). At first order, the binary + * diffusion coefficients are independent of composition, and + * d(k,j) = d(j,k). But at second order, there is a weak + * dependence on composition, with the result that d(k,j) != + * d(j,k). This method computes the multiplier by which the + * first-order binary diffusion coefficient should be multiplied + * to produce the value correct to second order. The expressions + * here are taken from Marerro and Mason, + * J. Phys. Chem. Ref. Data, vol. 1, p. 3 (1972). + * + * @param t Temperature (K) + * @param tr Transport parameters + * @param k index of first species + * @param j index of second species + * @param xmk mole fraction of species k + * @param xmj mole fraction of species j + * @param fkj multiplier for d(k,j) + * @param fjk multiplier for d(j,k) + * + * @note This method is not used currently. + */ void getBinDiffCorrection(doublereal t, const GasTransportParams& tr, int k, int j, doublereal xk, doublereal xj, doublereal& fkj, doublereal& fjk); - /// Corrections for polar-nonpolar binary diffusion coefficients + //! Corrections for polar-nonpolar binary diffusion coefficients + /*! + * Calculate corrections to the well depth parameter and the + * diamter for use in computing the binary diffusion coefficient + * of polar-nonpolar pairs. For more information about this + * correction, see Dixon-Lewis, Proc. Royal Society (1968). + */ void makePolarCorrections(int i, int j, const GasTransportParams& tr, doublereal& f_eps, doublereal& f_sigma);