Changed the name of getdactcoeffdlnN to getdactcoeffdlnN_diag to reflect what it's actually doing.
This commit is contained in:
parent
b6cf6b3139
commit
3b8b18e72d
9 changed files with 86 additions and 71 deletions
|
|
@ -38,7 +38,7 @@ namespace Cantera {
|
|||
lnActCoeff_Scaled_(0),
|
||||
dlnActCoeffdT_Scaled_(0),
|
||||
d2lnActCoeffdT2_Scaled_(0),
|
||||
dlnActCoeffdlnN_Scaled_(0),
|
||||
dlnActCoeffdlnN_diag_(0),
|
||||
dlnActCoeffdlnX_Scaled_(0),
|
||||
dlnActCoeffdN_Scaled_(0,0),
|
||||
m_pp(0)
|
||||
|
|
@ -57,7 +57,7 @@ namespace Cantera {
|
|||
lnActCoeff_Scaled_(0),
|
||||
dlnActCoeffdT_Scaled_(0),
|
||||
d2lnActCoeffdT2_Scaled_(0),
|
||||
dlnActCoeffdlnN_Scaled_(0),
|
||||
dlnActCoeffdlnN_diag_(0),
|
||||
dlnActCoeffdlnX_Scaled_(0),
|
||||
dlnActCoeffdN_Scaled_(0,0),
|
||||
m_pp(0)
|
||||
|
|
@ -84,7 +84,7 @@ namespace Cantera {
|
|||
dlnActCoeffdT_Scaled_ = b.dlnActCoeffdT_Scaled_;
|
||||
d2lnActCoeffdT2_Scaled_ = b.d2lnActCoeffdT2_Scaled_;
|
||||
dlnActCoeffdlnX_Scaled_ = b.dlnActCoeffdlnX_Scaled_;
|
||||
dlnActCoeffdlnN_Scaled_ = b.dlnActCoeffdlnN_Scaled_;
|
||||
dlnActCoeffdlnN_diag_ = b.dlnActCoeffdlnN_diag_;
|
||||
dlnActCoeffdN_Scaled_ = b.dlnActCoeffdN_Scaled_;
|
||||
m_pp = b.m_pp;
|
||||
|
||||
|
|
@ -344,7 +344,7 @@ namespace Cantera {
|
|||
dlnActCoeffdT_Scaled_.resize(m_kk);
|
||||
d2lnActCoeffdT2_Scaled_.resize(m_kk);
|
||||
dlnActCoeffdlnX_Scaled_.resize(m_kk);
|
||||
dlnActCoeffdlnN_Scaled_.resize(m_kk);
|
||||
dlnActCoeffdlnN_diag_.resize(m_kk);
|
||||
dlnActCoeffdN_Scaled_.resize(m_kk, m_kk);
|
||||
m_pp.resize(m_kk);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -319,11 +319,11 @@ namespace Cantera {
|
|||
*
|
||||
* units = dimensionless
|
||||
*
|
||||
* @param dlnActCoeffdlnN Output vector of derivatives of the
|
||||
* @param dlnActCoeffdlnN_diag Output vector of derivatives of the
|
||||
* log Activity Coefficients. length = m_kk
|
||||
*/
|
||||
virtual void getdlnActCoeffdlnN(doublereal *dlnActCoeffdlnN) const {
|
||||
err("getdlnActCoeffdlnN");
|
||||
virtual void getdlnActCoeffdlnN_diag(doublereal *dlnActCoeffdlnN_diag) const {
|
||||
err("getdlnActCoeffdlnN_diag");
|
||||
}
|
||||
|
||||
//! Get the array of log concentration-like derivatives of the
|
||||
|
|
@ -571,7 +571,7 @@ namespace Cantera {
|
|||
//! Storage for the current derivative values of the
|
||||
//! gradients with respect to logarithm of the mole fraction of the
|
||||
//! log of the activity coefficients of the species @deprecated
|
||||
mutable std::vector<doublereal> dlnActCoeffdlnN_Scaled_;
|
||||
mutable std::vector<doublereal> dlnActCoeffdlnN_diag_;
|
||||
|
||||
//! Storage for the current derivative values of the
|
||||
//! gradients with respect to logarithm of the mole fraction of the
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ namespace Cantera {
|
|||
gammaNeutralMolecule_ = b.gammaNeutralMolecule_;
|
||||
dlnActCoeffdT_NeutralMolecule_ = b.dlnActCoeffdT_NeutralMolecule_;
|
||||
dlnActCoeffdlnX_NeutralMolecule_ = b.dlnActCoeffdlnX_NeutralMolecule_;
|
||||
dlnActCoeffdlnN_NeutralMolecule_ = b.dlnActCoeffdlnN_NeutralMolecule_;
|
||||
dlnActCoeffdlnN_diag_NeutralMolecule_ = b.dlnActCoeffdlnN_diag_NeutralMolecule_;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -621,31 +621,31 @@ namespace Cantera {
|
|||
}
|
||||
}
|
||||
|
||||
//! Get the array of log concentration-like derivatives of the
|
||||
//! log activity coefficients
|
||||
/*!
|
||||
* This function is a virtual method. For ideal mixtures
|
||||
* (unity activity coefficients), this can return zero.
|
||||
* Implementations should take the derivative of the
|
||||
* logarithm of the activity coefficient with respect to the
|
||||
* logarithm of the concentration-like variable (i.e. moles)
|
||||
* that represents the standard state.
|
||||
* This quantity is to be used in conjunction with derivatives of
|
||||
* that concentration-like variable when the derivative of the chemical
|
||||
* potential is taken.
|
||||
*
|
||||
* units = dimensionless
|
||||
*
|
||||
* @param dlnActCoeffdlnN Output vector of log(mole fraction)
|
||||
* derivatives of the log Activity Coefficients.
|
||||
* length = m_kk
|
||||
*/
|
||||
void IonsFromNeutralVPSSTP::getdlnActCoeffdlnN(doublereal *dlnActCoeffdlnN) const {
|
||||
// Get the array of log concentration-like derivatives of the
|
||||
// log activity coefficients
|
||||
/*
|
||||
* This function is a virtual method. For ideal mixtures
|
||||
* (unity activity coefficients), this can return zero.
|
||||
* Implementations should take the derivative of the
|
||||
* logarithm of the activity coefficient with respect to the
|
||||
* logarithm of the concentration-like variable (i.e. moles)
|
||||
* that represents the standard state.
|
||||
* This quantity is to be used in conjunction with derivatives of
|
||||
* that concentration-like variable when the derivative of the chemical
|
||||
* potential is taken.
|
||||
*
|
||||
* units = dimensionless
|
||||
*
|
||||
* @param dlnActCoeffdlnN_diag Output vector of log(mole fraction)
|
||||
* derivatives of the log Activity Coefficients.
|
||||
* length = m_kk
|
||||
*/
|
||||
void IonsFromNeutralVPSSTP::getdlnActCoeffdlnN_diag(doublereal *dlnActCoeffdlnN_diag) const {
|
||||
s_update_lnActCoeff();
|
||||
s_update_dlnActCoeff_dlnN();
|
||||
s_update_dlnActCoeff_dlnN_diag();
|
||||
|
||||
for (int k = 0; k < m_kk; k++) {
|
||||
dlnActCoeffdlnN[k] = dlnActCoeffdlnN_Scaled_[k];
|
||||
dlnActCoeffdlnN_diag[k] = dlnActCoeffdlnN_diag_[k];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1193,9 +1193,9 @@ namespace Cantera {
|
|||
gammaNeutralMolecule_.resize(numNeutralMoleculeSpecies_);
|
||||
dlnActCoeffdT_NeutralMolecule_.resize(numNeutralMoleculeSpecies_);
|
||||
dlnActCoeffdlnX_NeutralMolecule_.resize(numNeutralMoleculeSpecies_);
|
||||
dlnActCoeffdlnN_NeutralMolecule_.resize(numNeutralMoleculeSpecies_);
|
||||
dlnActCoeffdlnN_diag_NeutralMolecule_.resize(numNeutralMoleculeSpecies_);
|
||||
}
|
||||
|
||||
//====================================================================================================================
|
||||
static double factorOverlap(const std::vector<std::string>& elnamesVN ,
|
||||
const std::vector<double>& elemVectorN,
|
||||
const int nElementsN,
|
||||
|
|
@ -1640,7 +1640,7 @@ namespace Cantera {
|
|||
* This function will be called to update the internally storred
|
||||
* temperature derivative of the natural logarithm of the activity coefficients
|
||||
*/
|
||||
void IonsFromNeutralVPSSTP::s_update_dlnActCoeff_dlnN() const {
|
||||
void IonsFromNeutralVPSSTP::s_update_dlnActCoeff_dlnN_diag() const {
|
||||
int k, icat, jNeut;
|
||||
doublereal fmij;
|
||||
/*
|
||||
|
|
@ -1648,11 +1648,11 @@ namespace Cantera {
|
|||
*/
|
||||
GibbsExcessVPSSTP *geThermo = dynamic_cast<GibbsExcessVPSSTP *>(neutralMoleculePhase_);
|
||||
if (!geThermo) {
|
||||
fvo_zero_dbl_1(dlnActCoeffdlnN_Scaled_, m_kk);
|
||||
fvo_zero_dbl_1(dlnActCoeffdlnN_diag_, m_kk);
|
||||
return;
|
||||
}
|
||||
|
||||
geThermo->getdlnActCoeffdlnN(DATA_PTR(dlnActCoeffdlnN_NeutralMolecule_));
|
||||
geThermo->getdlnActCoeffdlnN_diag(DATA_PTR(dlnActCoeffdlnN_diag_NeutralMolecule_));
|
||||
|
||||
switch (ionSolnType_) {
|
||||
case cIonSolnType_PASSTHROUGH:
|
||||
|
|
@ -1665,19 +1665,19 @@ namespace Cantera {
|
|||
icat = cationList_[k];
|
||||
jNeut = fm_invert_ionForNeutral[icat];
|
||||
fmij = fm_neutralMolec_ions_[icat + jNeut * m_kk];
|
||||
dlnActCoeffdlnN_Scaled_[icat] = dlnActCoeffdlnN_NeutralMolecule_[jNeut]/fmij;
|
||||
dlnActCoeffdlnN_diag_[icat] = dlnActCoeffdlnN_diag_NeutralMolecule_[jNeut]/fmij;
|
||||
}
|
||||
|
||||
// Do the anion list
|
||||
icat = anionList_[0];
|
||||
jNeut = fm_invert_ionForNeutral[icat];
|
||||
dlnActCoeffdlnN_Scaled_[icat]= 0.0;
|
||||
dlnActCoeffdlnN_diag_[icat]= 0.0;
|
||||
|
||||
// Do the list of neutral molecules
|
||||
for (k = 0; k < numPassThroughSpecies_; k++) {
|
||||
icat = passThroughList_[k];
|
||||
jNeut = fm_invert_ionForNeutral[icat];
|
||||
dlnActCoeffdlnN_Scaled_[icat] = dlnActCoeffdlnN_NeutralMolecule_[jNeut];
|
||||
dlnActCoeffdlnN_diag_[icat] = dlnActCoeffdlnN_diag_NeutralMolecule_[jNeut];
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -440,25 +440,21 @@ namespace Cantera {
|
|||
virtual void getdlnActCoeffdlnX(doublereal *dlnActCoeffdlnX) const;
|
||||
|
||||
//! Get the array of log concentration-like derivatives of the
|
||||
//! log activity coefficients
|
||||
//! log activity coefficients - diagonal components
|
||||
/*!
|
||||
* This function is a virtual method. For ideal mixtures
|
||||
* (unity activity coefficients), this can return zero.
|
||||
* Implementations should take the derivative of the
|
||||
* logarithm of the activity coefficient with respect to the
|
||||
* logarithm of the concentration-like variable (i.e. number of moles)
|
||||
* that represents the standard state.
|
||||
* This quantity is to be used in conjunction with derivatives of
|
||||
* that concentration-like variable when the derivative of the chemical
|
||||
* potential is taken.
|
||||
* logarithm of the species mole numbe. This routine just does the diagonal entries.
|
||||
*
|
||||
* units = dimensionless
|
||||
*
|
||||
* @param dlnActCoeffdlnN Output vector of log(mole fraction)
|
||||
* @param dlnActCoeffdlnN_diag Output vector of diagonal components of the log(mole fraction)
|
||||
* derivatives of the log Activity Coefficients.
|
||||
* length = m_kk
|
||||
*/
|
||||
virtual void getdlnActCoeffdlnN(doublereal *dlnActCoeffdlnN) const;
|
||||
virtual void getdlnActCoeffdlnN_diag(doublereal *dlnActCoeffdlnN_diag) const;
|
||||
|
||||
//! Get the Salt Dissociation Coefficients
|
||||
//! Returns the vector of dissociation coefficients and vector of charges
|
||||
|
|
@ -751,13 +747,13 @@ namespace Cantera {
|
|||
void s_update_dlnActCoeff_dlnX() const;
|
||||
|
||||
//! Update the derivative of the log of the activity coefficients
|
||||
//! wrt log(number of moles)
|
||||
//! wrt log(number of moles) - diagonal components
|
||||
/*!
|
||||
* This function will be called to update the internally storred
|
||||
* derivative of the natural logarithm of the activity coefficients
|
||||
* wrt logarithm of the number of moles of given species.
|
||||
*/
|
||||
void s_update_dlnActCoeff_dlnN() const;
|
||||
void s_update_dlnActCoeff_dlnN_diag() const;
|
||||
|
||||
|
||||
private:
|
||||
|
|
@ -896,7 +892,7 @@ namespace Cantera {
|
|||
mutable std::vector<doublereal> dlnActCoeff_NeutralMolecule_;
|
||||
mutable std::vector<doublereal> dlnActCoeffdT_NeutralMolecule_;
|
||||
mutable std::vector<doublereal> dlnActCoeffdlnX_NeutralMolecule_;
|
||||
mutable std::vector<doublereal> dlnActCoeffdlnN_NeutralMolecule_;
|
||||
mutable std::vector<doublereal> dlnActCoeffdlnN_diag_NeutralMolecule_;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -887,13 +887,13 @@ namespace Cantera {
|
|||
*
|
||||
* he = X_A X_B(B + C X_B)
|
||||
*/
|
||||
void MargulesVPSSTP::s_update_dlnActCoeff_dlnN() const {
|
||||
void MargulesVPSSTP::s_update_dlnActCoeff_dlnN_diag() const {
|
||||
int iA, iB, iK, delAK, delBK;
|
||||
double XA, XB, XK, g0 , g1;
|
||||
double T = temperature();
|
||||
double RT = GasConstant*T;
|
||||
|
||||
fvo_zero_dbl_1(dlnActCoeffdlnN_Scaled_, m_kk);
|
||||
fvo_zero_dbl_1(dlnActCoeffdlnN_diag_, m_kk);
|
||||
|
||||
for ( iK = 0; iK < m_kk; iK++ ){
|
||||
|
||||
|
|
@ -916,9 +916,9 @@ namespace Cantera {
|
|||
g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / RT;
|
||||
g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / RT;
|
||||
|
||||
dlnActCoeffdlnN_Scaled_[iK] += 2*(delBK-XB)*(g0*(delAK-XA)+g1*(2*(delAK-XA)*XB+XA*(delBK-XB)));
|
||||
dlnActCoeffdlnN_diag_[iK] += 2*(delBK-XB)*(g0*(delAK-XA)+g1*(2*(delAK-XA)*XB+XA*(delBK-XB)));
|
||||
}
|
||||
dlnActCoeffdlnN_Scaled_[iK] = XK*dlnActCoeffdlnN_Scaled_[iK]-XK;
|
||||
dlnActCoeffdlnN_diag_[iK] = XK*dlnActCoeffdlnN_diag_[iK]-XK;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1017,10 +1017,10 @@ namespace Cantera {
|
|||
}
|
||||
|
||||
//====================================================================================================================
|
||||
void MargulesVPSSTP::getdlnActCoeffdlnN(doublereal *dlnActCoeffdlnN) const {
|
||||
s_update_dlnActCoeff_dlnN();
|
||||
void MargulesVPSSTP::getdlnActCoeffdlnN_diag(doublereal *dlnActCoeffdlnN_diag) const {
|
||||
s_update_dlnActCoeff_dlnN_diag();
|
||||
for (int k = 0; k < m_kk; k++) {
|
||||
dlnActCoeffdlnN[k] = dlnActCoeffdlnN_Scaled_[k];
|
||||
dlnActCoeffdlnN_diag[k] = dlnActCoeffdlnN_diag_[k];
|
||||
}
|
||||
}
|
||||
//====================================================================================================================
|
||||
|
|
|
|||
|
|
@ -813,7 +813,26 @@ namespace Cantera {
|
|||
* length = m_kk
|
||||
*/
|
||||
virtual void getdlnActCoeffdlnX(doublereal *dlnActCoeffdlnX) const;
|
||||
virtual void getdlnActCoeffdlnN(doublereal *dlnActCoeffdlnN) const;
|
||||
|
||||
//! Get the array of derivatives of the log activity coefficients wrt mole numbers - diagonal only
|
||||
/*!
|
||||
* This function is a virtual method. For ideal mixtures
|
||||
* (unity activity coefficients), this can return zero.
|
||||
* Implementations should take the derivative of the
|
||||
* logarithm of the activity coefficient with respect to the
|
||||
* logarithm of the concentration-like variable (i.e. mole fraction,
|
||||
* molality, etc.) that represents the standard state.
|
||||
* This quantity is to be used in conjunction with derivatives of
|
||||
* that concentration-like variable when the derivative of the chemical
|
||||
* potential is taken.
|
||||
*
|
||||
* units = dimensionless
|
||||
*
|
||||
* @param dlnActCoeffdlnX Output vector of the diagonal entries for the log(mole fraction)
|
||||
* derivatives of the log Activity Coefficients.
|
||||
* length = m_kk
|
||||
*/
|
||||
virtual void getdlnActCoeffdlnN_diag(doublereal *dlnActCoeffdlnN_diag) const;
|
||||
|
||||
|
||||
//! Get the array of derivatives of the log activity coefficients with respect to the species mole numbers
|
||||
|
|
@ -889,13 +908,13 @@ namespace Cantera {
|
|||
void s_update_dlnActCoeff_dlnX() const;
|
||||
|
||||
//! Update the derivative of the log of the activity coefficients
|
||||
//! wrt log(moles)
|
||||
//! wrt log(moles) - diagonal only
|
||||
/*!
|
||||
* This function will be called to update the internally storred
|
||||
* This function will be called to update the internally storred diagonal entries for the
|
||||
* derivative of the natural logarithm of the activity coefficients
|
||||
* wrt logarithm of the moles.
|
||||
*/
|
||||
void s_update_dlnActCoeff_dlnN() const;
|
||||
void s_update_dlnActCoeff_dlnN_diag() const;
|
||||
|
||||
//! Update the derivative of the log of the activity coefficients wrt log(moles_m)
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -2108,11 +2108,11 @@ namespace Cantera {
|
|||
*
|
||||
* units = dimensionless
|
||||
*
|
||||
* @param dlnActCoeffdlnN Output vector of derivatives of the
|
||||
* @param dlnActCoeffdlnN_diag Output vector of derivatives of the
|
||||
* log Activity Coefficients. length = m_kk
|
||||
*/
|
||||
virtual void getdlnActCoeffdlnN(doublereal *dlnActCoeffdlnN) const {
|
||||
err("getdlnActCoeffdlnN");
|
||||
virtual void getdlnActCoeffdlnN_diag(doublereal *dlnActCoeffdlnN_diag) const {
|
||||
err("getdlnActCoeffdlnN_diag");
|
||||
}
|
||||
|
||||
//! Get the array of derivatives of the log activity coefficients with respect to the species mole numbers
|
||||
|
|
|
|||
|
|
@ -135,11 +135,11 @@ namespace Cantera {
|
|||
*
|
||||
* units = dimensionless
|
||||
*
|
||||
* @param dlnActCoeffdlnN Output vector of derivatives of the
|
||||
* @param dlnActCoeffdlnN_diag Output vector of derivatives of the
|
||||
* log Activity Coefficients. length = m_kk
|
||||
*/
|
||||
virtual void getdlnActCoeffdlnN(doublereal *dlnActCoeffdlnN) const {
|
||||
err("getdlnActCoeffdlnN");
|
||||
virtual void getdlnActCoeffdlnN_diag(doublereal *dlnActCoeffdlnN_diag) const {
|
||||
err("getdlnActCoeffdlnN_diag");
|
||||
}
|
||||
|
||||
//! Get the array of log concentration-like derivatives of the
|
||||
|
|
|
|||
|
|
@ -728,14 +728,14 @@ namespace Cantera {
|
|||
int zM = charges[anion[0]];
|
||||
doublereal xA, xB, eps;
|
||||
doublereal inv_vP_vM_MutualDiff;
|
||||
vector_fp dlnActCoeffdlnN;
|
||||
dlnActCoeffdlnN.resize(neut_molefracs.size(),0.0);
|
||||
marg_thermo->getdlnActCoeffdlnN(&dlnActCoeffdlnN[0]);
|
||||
vector_fp dlnActCoeffdlnN_diag;
|
||||
dlnActCoeffdlnN_diag.resize(neut_molefracs.size(),0.0);
|
||||
marg_thermo->getdlnActCoeffdlnN_diag(&dlnActCoeffdlnN_diag[0]);
|
||||
|
||||
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]]);
|
||||
inv_vP_vM_MutualDiff = (xA*(1+dlnActCoeffdlnN_diag[neutMolIndex[cation[1]]])/m_selfDiffMix[cation[1]]+xB*(1+dlnActCoeffdlnN_diag[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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue