Removed repetative functions from transport: now use only customary pass by pointers (not by references to Densematrix or vector_fp)

This commit is contained in:
Christopher Lueth 2010-03-26 16:45:27 +00:00
parent b77a8d7407
commit 5cfd0514d3
8 changed files with 84 additions and 207 deletions

View file

@ -34,7 +34,7 @@ namespace Cantera {
LiquidTransport::LiquidTransport(thermo_t* thermo, int ndim) :
Transport(thermo, ndim),
m_nsp(0),
m_nBinInt(0),
m_nsp2(0),
m_tmin(-1.0),
m_tmax(100000.),
m_viscMixModel(0),
@ -82,7 +82,7 @@ namespace Cantera {
LiquidTransport::LiquidTransport(const LiquidTransport &right) :
Transport(right.m_thermo, right.m_nDim),
m_nsp(0),
m_nBinInt(0),
m_nsp2(0),
m_tmin(-1.0),
m_tmax(100000.),
m_viscMixModel(0),
@ -137,16 +137,14 @@ namespace Cantera {
}
Transport::operator=(right);
m_nsp = right.m_nsp;
m_nBinInt = right.m_nBinInt;
m_nsp2 = right.m_nsp2;
m_tmin = right.m_tmin;
m_tmax = right.m_tmax;
m_mw = right.m_mw;
m_viscTempDep_Ns = right.m_viscTempDep_Ns;
m_ionCondTempDep_Ns = right.m_ionCondTempDep_Ns;
m_mobRatTempDep_Ns = right.m_mobRatTempDep_Ns;
m_mobRatTempDepIndex = right.m_mobRatTempDepIndex;
m_selfDiffTempDep_Ns = right.m_selfDiffTempDep_Ns;
m_selfDiffTempDepIndex = right.m_selfDiffTempDepIndex;
m_lambdaTempDep_Ns = right.m_lambdaTempDep_Ns;
m_diffTempDep_Ns = right.m_diffTempDep_Ns;
m_radiusTempDep_Ns = right.m_radiusTempDep_Ns;
@ -159,17 +157,13 @@ namespace Cantera {
m_viscSpecies = right.m_viscSpecies;
m_ionCondSpecies = right.m_ionCondSpecies;
m_mobRatSpecies = right.m_mobRatSpecies;
m_mobRatSpeciesIndex = right.m_mobRatSpeciesIndex;
m_selfDiffSpecies = right.m_selfDiffSpecies;
m_selfDiffSpeciesIndex = right.m_selfDiffSpeciesIndex;
m_hydrodynamic_radius = right.m_hydrodynamic_radius;
m_lambdaSpecies = right.m_lambdaSpecies;
m_viscMixModel = right.m_viscMixModel;
m_ionCondMixModel = right.m_ionCondMixModel;
m_mobRatMixModel = right.m_mobRatMixModel;
m_mobRatMixModelIndex = right.m_mobRatMixModelIndex;
m_selfDiffMixModel = right.m_selfDiffMixModel;
m_selfDiffMixModelIndex = right.m_selfDiffMixModelIndex;
m_lambdaMixModel = right.m_lambdaMixModel;
m_diffMixModel = right.m_diffMixModel;
m_iStateMF = -1;
@ -191,7 +185,6 @@ namespace Cantera {
m_viscmix = right.m_viscmix;
m_ionCondmix = right.m_ionCondmix;
m_mobRatMix = right.m_mobRatMix;
m_mobRatMixIndex = right.m_mobRatMixIndex;
m_selfDiffMix = right.m_selfDiffMix;
m_spwork = right.m_spwork;
m_visc_mix_ok = false;
@ -237,7 +230,7 @@ namespace Cantera {
delete m_selfDiffTempDep_Ns[l][k];
}
}
for ( int l=0;l < m_nBinInt; l++ ){
for ( int l=0;l < m_nsp2; l++ ){
if ( m_mobRatTempDep_Ns[l][k] ) delete m_mobRatTempDep_Ns[l][k];
}
if ( m_lambdaTempDep_Ns[k] ) delete m_lambdaTempDep_Ns[k];
@ -248,7 +241,7 @@ namespace Cantera {
if ( m_selfDiffMixModel[k] ) delete m_selfDiffMixModel[k];
}
for ( int k = 0; k < m_nBinInt; k++) {
for ( int k = 0; k < m_nsp2; k++) {
if ( m_mobRatMixModel[k] ) delete m_mobRatMixModel[k];
}
@ -279,7 +272,7 @@ namespace Cantera {
tr.thermo = 0;
m_velocityBasis = tr.velocityBasis_;
m_nsp = m_thermo->nSpecies();
m_nBinInt = m_nsp*(m_nsp-1)/2;
m_nsp2 = m_nsp*m_nsp;
m_tmin = m_thermo->minTemp();
m_tmax = m_thermo->maxTemp();
@ -295,25 +288,18 @@ namespace Cantera {
m_viscTempDep_Ns.resize(m_nsp, 0);
m_ionCondSpecies.resize(m_nsp, 0.0);
m_ionCondTempDep_Ns.resize(m_nsp, 0);
m_mobRatTempDepIndex.resize(m_nBinInt);
m_mobRatTempDep_Ns.resize(m_nBinInt);
m_mobRatMixModel.resize(m_nBinInt);
m_mobRatMixModelIndex.resize(m_nBinInt);
m_mobRatSpeciesIndex.resize(m_nBinInt);
m_mobRatSpecies.resize(m_nBinInt, m_nsp, 0.0);
m_mobRatMix.resize(m_nBinInt,0.0);
m_mobRatMixIndex.resize(m_nBinInt);
m_selfDiffTempDepIndex.resize(m_nsp);
m_mobRatTempDep_Ns.resize(m_nsp2);
m_mobRatMixModel.resize(m_nsp2);
m_mobRatSpecies.resize(m_nsp2, m_nsp, 0.0);
m_mobRatMix.resize(m_nsp2,0.0);
m_selfDiffTempDep_Ns.resize(m_nsp);
m_selfDiffMixModel.resize(m_nsp);
m_selfDiffMixModelIndex.resize(m_nsp);
m_selfDiffSpeciesIndex.resize(m_nsp);
m_selfDiffSpecies.resize(m_nsp, m_nsp, 0.0);
m_selfDiffMix.resize(m_nsp,0.0);
for (k=0; k < m_nsp; k++){
m_selfDiffTempDep_Ns[k].resize(m_nsp, 0);
}
for (k=0; k < m_nBinInt; k++){
for (k=0; k < m_nsp2; k++){
m_mobRatTempDep_Ns[k].resize(m_nsp, 0);
}
m_lambdaSpecies.resize(m_nsp, 0.0);
@ -325,12 +311,10 @@ namespace Cantera {
for (k = 0; k < m_nsp; k++) {
m_selfDiffMixModel[k] = tr.selfDiffusion[k];
tr.selfDiffusion[k] = 0;
m_selfDiffMixModelIndex[k] = tr.selfDiffIndex[k];
}
for (k = 0; k < m_nBinInt; k++) {
for (k = 0; k < m_nsp2; k++) {
m_mobRatMixModel[k] = tr.mobilityRatio[k];
tr.mobilityRatio[k] = 0;
m_mobRatMixModelIndex[k] = tr.mobRatIndex[k];
}
//for each species, assign viscosity model and coefficients
@ -340,25 +324,13 @@ namespace Cantera {
ltd.viscosity = 0;
m_ionCondTempDep_Ns[k] = ltd.ionConductivity;
ltd.ionConductivity = 0;
for (int j = 0; j < m_nBinInt; j++){
for (int l=0; l < m_nBinInt; l++){
if (m_mobRatMixModelIndex[j] == ltd.mobRatIndex[l]) {
m_mobRatTempDep_Ns[j][k] = ltd.mobilityRatio[l];
ltd.mobilityRatio[l] = 0;
m_mobRatTempDepIndex[j] = ltd.mobRatIndex[l];
break;
}
}
for (int j = 0; j < m_nsp2; j++){
m_mobRatTempDep_Ns[j][k] = ltd.mobilityRatio[j];
ltd.mobilityRatio[j] = 0;
}
for (int j = 0; j < (int) m_selfDiffMixModelIndex.size(); j++) {
for (int l = 0; l < (int) m_selfDiffMixModelIndex.size(); l++) {
if (m_selfDiffMixModelIndex[j] == ltd.selfDiffIndex[l]) {
m_selfDiffTempDep_Ns[j][k] = ltd.selfDiffusion[l];
ltd.selfDiffusion[l] = 0;
m_selfDiffTempDepIndex[j] = ltd.selfDiffIndex[l];
break;
}
}
for (int j = 0; j < m_nsp; j++){
m_selfDiffTempDep_Ns[j][k] = ltd.selfDiffusion[j];
ltd.selfDiffusion[j] = 0;
}
m_lambdaTempDep_Ns[k] = ltd.thermalCond;
ltd.thermalCond = 0;
@ -571,42 +543,22 @@ namespace Cantera {
* These in turn employ subclasses of LTPspecies to
* determine the individual species mobility ratios.
*/
void LiquidTransport:: mobilityRatio(vector_fp& mobRat, std::vector<std::string>& mobRatIndex) {
void LiquidTransport:: mobilityRatio(doublereal* mobRat) {
update_T();
update_C();
////// LiquidTranInteraction method
if (!m_mobRat_mix_ok){
for (int k = 0; k < m_nBinInt; k++){
if ( m_mobRatMixModelIndex[k] != m_mobRatTempDepIndex[k] )
throw CanteraError("LiquidTransport::mobilityRation","Mobility Ratio Indices Don't Match: Mixture vs. Species");
m_mobRatMix[k] = m_mobRatMixModel[k]->getMixTransProp( m_mobRatTempDep_Ns[k] );
m_mobRatMixIndex[k] = m_mobRatMixModelIndex[k];
for (int k = 0; k < m_nsp2; k++){
if(m_mobRatMixModel[k]){
m_mobRatMix[k] = m_mobRatMixModel[k]->getMixTransProp( m_mobRatTempDep_Ns[k] );
if ( m_mobRatMix[k] > 0 ) m_mobRatMix[k/m_nsp+m_nsp*(k%m_nsp)] = 1.0/m_mobRatMix[k]; // Also must be off diagonal: k%(1+n)!=0, but then m_mobRatMixModel[k] shouldn't be initialized anyway
}
}
}
for (int k = 0; k < m_nBinInt; k++){
for (int k = 0; k < m_nsp2; k++){
mobRat[k] = m_mobRatMix[k];
mobRatIndex[k]= m_mobRatMixIndex[k];
}
}
void LiquidTransport:: mobilityRatio(doublereal* mobRat, std::vector<std::string>& mobRatIndex) {
update_T();
update_C();
////// LiquidTranInteraction method
if (!m_mobRat_mix_ok){
for (int k = 0; k < m_nBinInt; k++){
if ( m_mobRatMixModelIndex[k] != m_mobRatTempDepIndex[k] )
throw CanteraError("LiquidTransport::mobilityRatio","Mobility Ratio Indices Don't Match: Mixture vs. Species");
m_mobRatMix[k] = m_mobRatMixModel[k]->getMixTransProp( m_mobRatTempDep_Ns[k] );
m_mobRatMixIndex[k] = m_mobRatMixModelIndex[k];
}
}
for (int k = 0; k < m_nBinInt; k++){
mobRat[k] = m_mobRatMix[k];
mobRatIndex[k]= m_mobRatMixIndex[k];
}
}
@ -619,26 +571,15 @@ namespace Cantera {
* @param mobRat array of length "number of species"
* to hold returned mobility ratio.
*/
void LiquidTransport::getSpeciesMobilityRatio(DenseMatrix& mobRat, std::vector<std::string>& mobRatIndex) {
void LiquidTransport::getSpeciesMobilityRatio(doublereal** mobRat) {
update_T();
if (!m_mobRat_temp_ok) {
updateMobilityRatio_T();
}
mobRat = m_mobRatSpecies;
for (int k = 0; k < m_nBinInt; k++) {
mobRatIndex[k] = m_mobRatSpeciesIndex[k];
}
}
void LiquidTransport::getSpeciesMobilityRatio(doublereal** mobRat, std::vector<std::string>& mobRatIndex) {
update_T();
if (!m_mobRat_temp_ok) {
updateMobilityRatio_T();
}
for (int k=0; k<m_nBinInt; k++) {
for (int k=0; k<m_nsp2; k++) {
for (int j=0; j < m_nsp; j++) {
mobRat[k][j] = m_mobRatSpecies(k,j);
}
mobRatIndex[k] = m_mobRatSpeciesIndex[k];
}
}
//====================================================================================================================
@ -673,10 +614,6 @@ namespace Cantera {
update_C();
if (!m_selfDiff_mix_ok) {
for (int k = 0; k < m_nsp; k++) {
if (m_selfDiffMixModelIndex[k] != m_selfDiffTempDepIndex[k]) {
throw CanteraError("LiquidTransport::selfDiffusion",
"Self Diffusion Indices Don't Match: Mixture vs. Species");
}
m_selfDiffMix[k] = m_selfDiffMixModel[k]->getMixTransProp(m_selfDiffTempDep_Ns[k]);
}
}
@ -694,16 +631,7 @@ namespace Cantera {
* @param selfDiff array of size "number of species"^2
* to hold returned self diffusion.
*/
void LiquidTransport::getSpeciesSelfDiffusion(DenseMatrix& selfDiff, std::vector<std::string>& selfDiffIndex) {
update_T();
if (!m_selfDiff_temp_ok) {
updateSelfDiffusion_T();
}
selfDiff = m_selfDiffSpecies;
for (int k = 0; k < m_nsp; k++)
selfDiffIndex[k] = m_selfDiffSpeciesIndex[k];
}
void LiquidTransport::getSpeciesSelfDiffusion(doublereal** selfDiff, std::vector<std::string>& selfDiffIndex) {
void LiquidTransport::getSpeciesSelfDiffusion(doublereal** selfDiff) {
update_T();
if (!m_selfDiff_temp_ok) {
updateSelfDiffusion_T();
@ -711,7 +639,6 @@ namespace Cantera {
for (int k=0; k<m_nsp; k++){
for (int j=0; j < m_nsp; j++)
selfDiff[k][j] = m_selfDiffSpecies(k,j);
selfDiffIndex[k] = m_selfDiffSpeciesIndex[k];
}
}
@ -1511,11 +1438,10 @@ namespace Cantera {
int k;
int j;
for (k = 0; k < m_nBinInt; k++) {
for (k = 0; k < m_nsp2; k++) {
for (j = 0; j < m_nsp; j++) {
m_mobRatSpecies(k,j) = m_mobRatTempDep_Ns[k][j]->getSpeciesTransProp() ;
}
m_mobRatSpeciesIndex[k] = m_mobRatTempDepIndex[k];
}
m_mobRat_temp_ok = true;
m_mobRat_mix_ok = false;
@ -1537,11 +1463,10 @@ namespace Cantera {
int k;
int j;
for (k = 0; k < m_nBinInt; k++) {
for (k = 0; k < m_nsp2; k++) {
for (j = 0; j < m_nsp; j++) {
m_selfDiffSpecies(k,j) = m_selfDiffTempDep_Ns[k][j]->getSpeciesTransProp() ;
}
m_selfDiffSpeciesIndex[k] = m_selfDiffTempDepIndex[k];
}
m_selfDiff_temp_ok = true;
m_selfDiff_mix_ok = false;

View file

@ -205,8 +205,7 @@ namespace Cantera {
* These in turn employ subclasses of LTPspecies to
* determine the individual species mobility ratios.
*/
virtual void mobilityRatio(vector_fp& mobRat, std::vector<std::string>& mobRatIndex);
virtual void mobilityRatio(double* mobRat, std::vector<std::string>& mobRatIndex);
virtual void mobilityRatio(double* mobRat);
//! Returns the pure species mobility ratios for all species
/*!
@ -217,8 +216,7 @@ namespace Cantera {
* @param mobRat array of length "number of species"
* to hold returned mobility ratios.
*/
virtual void getSpeciesMobilityRatio(DenseMatrix& mobRat, std::vector<std::string>& mobRatIndex);
virtual void getSpeciesMobilityRatio(double** mobRat, std::vector<std::string>& mobRatIndex);
virtual void getSpeciesMobilityRatio(double** mobRat);
//! Returns the self diffusion coefficients of the species in the phase
/*!
@ -257,8 +255,7 @@ namespace Cantera {
* @param selfDiff array of length "number of species"
* to hold returned self diffusion coeffs.
*/
virtual void getSpeciesSelfDiffusion(DenseMatrix& selfDiff, std::vector<std::string>& selfDiffIndex);
virtual void getSpeciesSelfDiffusion(double** selfDiff, std::vector<std::string>& selfDiffIndex);
virtual void getSpeciesSelfDiffusion(double** selfDiff);
//! Returns the hydrodynamic radius for all species
/*!
@ -885,7 +882,7 @@ namespace Cantera {
int m_nsp;
int m_nBinInt;
int m_nsp2;
//! Minimum temperature applicable to the transport property eval
doublereal m_tmin;
@ -944,7 +941,6 @@ namespace Cantera {
*/
typedef std::vector<LTPspecies*> LTPvector;
std::vector<LTPvector> m_mobRatTempDep_Ns;
std::vector<std::string> m_mobRatTempDepIndex;
//! Mobility ratio of the mixture expressed as a subclass of
//! LiquidTranInteraction
@ -954,7 +950,6 @@ namespace Cantera {
* TransportFactory::getLiquidInteractionsTransportData().
*/
std::vector<LiquidTranInteraction*> m_mobRatMixModel;
std::vector<std::string> m_mobRatMixModelIndex;
//! Self Diffusion for each species expressed as an appropriate subclass
//! of LTPspecies
@ -964,7 +959,6 @@ namespace Cantera {
* TransportFactory::getLiquidSpeciesTransportData().
*/
std::vector<LTPvector> m_selfDiffTempDep_Ns;
std::vector<std::string> m_selfDiffTempDepIndex;
//! Self Diffusion of the mixture expressed as a subclass of
//! LiquidTranInteraction
@ -974,7 +968,6 @@ namespace Cantera {
* TransportFactory::getLiquidInteractionsTransportData().
*/
std::vector<LiquidTranInteraction*> m_selfDiffMixModel;
std::vector<std::string> m_selfDiffMixModelIndex;
//! Thermal conductivity for each species expressed as an
//! appropriate subclass of LTPspecies
@ -1184,7 +1177,6 @@ namespace Cantera {
* controlling update boolean -> m_mobRat_temp_ok
*/
DenseMatrix m_mobRatSpecies;
std::vector<std::string> m_mobRatSpeciesIndex;
//! Internal value of the species self diffusion coefficients
/*!
@ -1196,7 +1188,6 @@ namespace Cantera {
* controlling update boolean -> m_selfDiff_temp_ok
*/
DenseMatrix m_selfDiffSpecies;
std::vector<std::string> m_selfDiffSpeciesIndex;
//! Internal value of the species individual thermal conductivities
/*!
@ -1332,8 +1323,6 @@ namespace Cantera {
//! Saved values of the mixture mobility ratios
vector_fp m_mobRatMix;
//! Saved species index of the mixture correlated to mobility ratios
std::vector<std::string> m_mobRatMixIndex;
//! Saved values of the mixture self diffusion coefficients
vector_fp m_selfDiffMix;

View file

@ -79,9 +79,7 @@ namespace Cantera {
viscosity = right.viscosity;
ionConductivity = right.ionConductivity;
mobilityRatio = right.mobilityRatio;
mobRatIndex = right.mobRatIndex;
selfDiffusion = right.selfDiffusion;
selfDiffIndex = right.selfDiffIndex;
thermalCond = right.thermalCond;
electCond = right.electCond;
speciesDiffusivity = right.speciesDiffusivity;

View file

@ -205,11 +205,9 @@ namespace Cantera {
//! Model type for the mobility ratio
std::vector<LTPspecies*> mobilityRatio;
std::vector<std::string> mobRatIndex;
//! Model type for the self diffusion coefficients
std::vector<LTPspecies*> selfDiffusion;
std::vector<std::string> selfDiffIndex;
//! Model type for the thermal conductivity
LTPspecies* thermalCond;

View file

@ -612,7 +612,7 @@ namespace Cantera {
void LTI_StefanMaxwell_PPN::setParameters( LiquidTransportParams& trParam ) {
int nsp = m_thermo->nSpecies();
int nBinInt = nsp*(nsp-1)/2;
int nsp2 = nsp*nsp;
//vector<std
m_ionCondMix = 0;
@ -620,32 +620,28 @@ namespace Cantera {
//trParam.ionConductivity = 0;
m_ionCondSpecies.resize(nsp,0);
m_mobRatMix.resize(nsp,nsp,0.0);
m_mobRatMixModel.resize(nBinInt);
m_mobRatSpecies.resize(nBinInt);
m_mobRatIndex.resize(nBinInt);
m_mobRatMixModel.resize(nsp2);
m_mobRatSpecies.resize(nsp2);
m_selfDiffMix.resize(nsp,0.0);
m_selfDiffMixModel.resize(nsp);
m_selfDiffSpecies.resize(nsp);
m_selfDiffIndex.resize(nsp);
for ( int k = 0; k < nBinInt; k++ ) {
for ( int k = 0; k < nsp2; k++ ) {
m_mobRatMixModel[k] = trParam.mobilityRatio[k];
//trParam.mobilityRatio[k] = 0;
m_mobRatSpecies[k].resize(nsp,0);
m_mobRatIndex[k] = trParam.mobRatIndex[k];
}
for ( int k = 0; k < nsp; k++ ) {
m_selfDiffMixModel[k] = trParam.selfDiffusion[k];
//trParam.selfDiffusion[k] = 0;
m_selfDiffSpecies[k].resize(nsp,0);
m_selfDiffIndex[k] = trParam.selfDiffIndex[k];
}
for (int k = 0; k < nsp; k++) {
Cantera::LiquidTransportData &ltd = trParam.LTData[k];
m_ionCondSpecies[k] = ltd.ionConductivity;
//ltd.ionConductivity = 0;
for ( int j = 0; j < nBinInt; j++ ){
for ( int j = 0; j < nsp2; j++ ){
m_mobRatSpecies[j][k] = ltd.mobilityRatio[j];
//ltd.mobilityRatio[j] = 0;
}
@ -690,7 +686,7 @@ namespace Cantera {
int i, j, k;
int nsp = m_thermo->nSpecies();
if (nsp != 3) throw CanteraError("LTI_StefanMaxwell_PPN::getMatrixTransProp","Function may only be called with a 3-ion system");
int nBinInt = nsp*(nsp-1)/2;
int nsp2 = nsp*nsp;
doublereal temp = m_thermo->temperature();
doublereal molefracs[nsp];
m_thermo->getMoleFractions( molefracs );
@ -726,42 +722,20 @@ namespace Cantera {
MargulesVPSSTP * marg_thermo = dynamic_cast<MargulesVPSSTP *> (ions_thermo->neutralMoleculePhase_);
doublereal vol = m_thermo->molarVolume();
typedef std::vector<int> intVec;
std::vector<intVec> mobRatIndexMap;
mobRatIndexMap.resize(nsp);
for ( k = 0; k < nsp; k++ )
mobRatIndexMap[k].resize(nsp,0);
for ( k = 0; k < nBinInt; k++ ) {
bool missingIndex = 1;
k = 0;
for ( j = 0; j < nsp; j++ ) {
for ( i = 0; i < nsp; i++ ) {
for ( j = 0; j < i; j++ ) {
if ( (speciesNames[i] + ":" + speciesNames[j]) == m_mobRatIndex[k] ) {
mobRatIndexMap[i][j] = k;
m_mobRatMix(i,j) = m_mobRatMixModel[k]->getMixTransProp( m_mobRatSpecies[k] );
if ( m_mobRatMix(i,j) > 0 ) m_mobRatMix(j,i) = 1.0/m_mobRatMix(i,j);
missingIndex = 0;
break;
}
else if ( (speciesNames[j] + ":" + speciesNames[i]) == m_mobRatIndex[k] ) {
m_mobRatMix(j,i) = m_mobRatMixModel[k]->getMixTransProp( m_mobRatSpecies[k] );
if ( m_mobRatMix(j,i) > 0 ) m_mobRatMix(i,j) = 1.0/m_mobRatMix(j,i);
missingIndex = 0;
break;
}
if (m_mobRatMixModel[k]) {
m_mobRatMix(i,j) = m_mobRatMixModel[k]->getMixTransProp( m_mobRatSpecies[k] );
if ( m_mobRatMix(i,j) > 0 ) m_mobRatMix(j,i) = 1.0/m_mobRatMix(i,j);
}
k++;
}
if ( missingIndex ) throw CanteraError("LTI_StefanMaxwell_PPN::getMixTransProp","Incorrect names for mobility ratio of " + m_mobRatIndex[k] + " rather than i.e. " + speciesNames[0] + ":" + speciesNames[1]);
}
}
for ( k = 0; k < nsp; k++ ){
j = 0;
while (m_selfDiffIndex[k] != speciesNames[j]) {
j++;
if (j == nsp) throw CanteraError("LTI_StefanMaxwell_PPN::getMixTransProp","Incorrect names for self diffusion of " + m_selfDiffIndex[k] + " rather than i.e. " + speciesNames[0]);
}
m_selfDiffMix[j] = m_selfDiffMixModel[k]->getMixTransProp( m_selfDiffSpecies[k] );
m_selfDiffMix[k] = m_selfDiffMixModel[k]->getMixTransProp( m_selfDiffSpecies[k] );
}
/*

View file

@ -221,9 +221,7 @@ namespace Cantera {
LiquidTranInteraction* viscosity;
LiquidTranInteraction* ionConductivity;
std::vector<LiquidTranInteraction*> mobilityRatio;
std::vector<std::string> mobRatIndex;
std::vector<LiquidTranInteraction*> selfDiffusion;
std::vector<std::string> selfDiffIndex;
LiquidTranInteraction* thermalCond;
LiquidTranInteraction* speciesDiffusivity;
LiquidTranInteraction* electCond;
@ -603,12 +601,10 @@ namespace Cantera {
DenseMatrix m_mobRatMix;
std::vector<LiquidTranInteraction*> m_mobRatMixModel;
std::vector<LTPvector> m_mobRatSpecies;
std::vector<std::string> m_mobRatIndex;
std::vector<LiquidTranInteraction*> m_selfDiffMixModel;
vector_fp m_selfDiffMix;
std::vector<LTPvector> m_selfDiffSpecies;
std::vector<std::string> m_selfDiffIndex;
};

View file

@ -79,8 +79,7 @@ namespace Cantera {
* - VB_MASSAVG Diffusion velocities are based on the mass averaged velocity
* - VB_MOLEAVG Diffusion velocities are based on the mole averaged velocities
* - VB_SPECIES_0 Diffusion velocities are based on the relative motion wrt species 0
* - VB_SPECIES_1 Diffusion velocities are based on the relative motion wrt species 1
* - VB_SPECIES_2 Diffusion velocities are based on the relative motion wrt species 2
* - ...
* - VB_SPECIES_3 Diffusion velocities are based on the relative motion wrt species 3
*
* @ingroup tranprops
@ -162,7 +161,8 @@ namespace Cantera {
* - VB_MASSAVG Diffusion velocities are based on the mass averaged velocity
* - VB_MOLEAVG Diffusion velocities are based on the mole averaged velocities
* - VB_SPECIES_0 Diffusion velocities are based on the relative motion wrt species 0
* - VB_SPECIES_1 Diffusion velocities are based on the relative motion wrt species 1
* - ...
* - VB_SPECIES_3 Diffusion velocities are based on the relative motion wrt species 3
*
* All transport managers specify a default reference velocity in their default constructors.
* All gas phase transport managers by default specify the mass-averaged velocity as their
@ -334,9 +334,7 @@ namespace Cantera {
/**
* The mobility ratio.
*/
virtual void mobilityRatio(vector_fp& mobRat, std::vector<std::string>& mobRatIndex)
{ err("mobilityRatio"); }
virtual void mobilityRatio(double* mobRat, std::vector<std::string>& mobRatIndex)
virtual void mobilityRatio(double* mobRat)
{ err("mobilityRatio"); }
//! Returns the pure species limit of the mobility ratios
@ -345,9 +343,7 @@ namespace Cantera {
*
* @param mobRat Vector of mobility ratios
*/
virtual void getSpeciesMobilityRatio(DenseMatrix& mobRat, std::vector<std::string>& mobRatIndex)
{ err("getSpeciesMobilityRatio"); }
virtual void getSpeciesMobilityRatio(double** mobRat, std::vector<std::string>& mobRatIndex)
virtual void getSpeciesMobilityRatio(double** mobRat)
{ err("getSpeciesMobilityRatio"); }
//! Returns the self diffusion coefficients of the species in the phase
@ -389,9 +385,7 @@ namespace Cantera {
* @param selfDiff array of length "number of species"
* to hold returned self diffusion coeffs.
*/
virtual void getSpeciesSelfDiffusion(DenseMatrix& selfDiff, std::vector<std::string>& selfDiffIndex)
{ err("getSpeciesSelfDiffusion"); }
virtual void getSpeciesSelfDiffusion(double** selfDiff, std::vector<std::string>& selfDiffIndex)
virtual void getSpeciesSelfDiffusion(double** selfDiff)
{ err("getSpeciesSelfDiffusion"); }
//! Returns the mixture thermal conductivity in W/m/K.

View file

@ -42,6 +42,7 @@
#include "ctml.h"
#include <cstdio>
#include <cstring>
//using namespace std;
@ -982,10 +983,9 @@ namespace Cantera {
// and then insertion into LiquidTransportData objects below.
LiquidTransportData data;
data.speciesName = name;
data.mobRatIndex.resize(nBinInt,"");
data.mobilityRatio.resize(nBinInt,0);
data.selfDiffIndex.resize(nsp,"");
data.mobilityRatio.resize(nsp*nsp,0);
data.selfDiffusion.resize(nsp,0);
ThermoPhase *temp_thermo = trParam.thermo;
int num = trNode.nChildren();
for (int iChild = 0; iChild < num; iChild++) {
@ -994,18 +994,21 @@ namespace Cantera {
switch (m_tranPropMap[nodeName]) {
case TP_VISCOSITY:
data.viscosity = newLTP(xmlChild, name, m_tranPropMap[nodeName], trParam.thermo );
data.viscosity = newLTP(xmlChild, name, m_tranPropMap[nodeName], temp_thermo );
break;
case TP_IONCONDUCTIVITY:
data.ionConductivity = newLTP(xmlChild, name, m_tranPropMap[nodeName], trParam.thermo);
data.ionConductivity = newLTP(xmlChild, name, m_tranPropMap[nodeName], temp_thermo);
break;
case TP_MOBILITYRATIO:
{
for (int iSpec = 0; iSpec< nBinInt; iSpec++){
XML_Node &propSpecNode = xmlChild.child(iSpec);
std::string specName = propSpecNode.name();
data.mobRatIndex[iSpec] = specName;
data.mobilityRatio[iSpec] = newLTP(propSpecNode, name, m_tranPropMap[nodeName], trParam.thermo);
size_t loc = specName.find(":");
std::string firstSpec = specName.substr(0,loc);
std::string secondSpec = specName.substr(loc+1);
int index = temp_thermo->speciesIndex(firstSpec.c_str())+nsp*temp_thermo->speciesIndex(secondSpec.c_str());
data.mobilityRatio[index] = newLTP(propSpecNode, name, m_tranPropMap[nodeName], temp_thermo);
};
};
break;
@ -1014,8 +1017,8 @@ namespace Cantera {
for (int iSpec = 0; iSpec< nsp; iSpec++){
XML_Node &propSpecNode = xmlChild.child(iSpec);
std::string specName = propSpecNode.name();
data.selfDiffIndex[iSpec] = specName;
data.selfDiffusion[iSpec] = newLTP(propSpecNode, name, m_tranPropMap[nodeName], trParam.thermo);
int index = temp_thermo->speciesIndex(specName.c_str());
data.selfDiffusion[index] = newLTP(propSpecNode, name, m_tranPropMap[nodeName], temp_thermo);
};
};
break;
@ -1023,25 +1026,25 @@ namespace Cantera {
data.thermalCond = newLTP(xmlChild,
name,
m_tranPropMap[nodeName],
trParam.thermo );
temp_thermo );
break;
case TP_DIFFUSIVITY:
data.speciesDiffusivity = newLTP(xmlChild,
name,
m_tranPropMap[nodeName],
trParam.thermo );
temp_thermo );
break;
case TP_HYDRORADIUS:
data.hydroRadius = newLTP(xmlChild,
name,
m_tranPropMap[nodeName],
trParam.thermo );
temp_thermo );
break;
case TP_ELECTCOND:
data.electCond = newLTP(xmlChild,
name,
m_tranPropMap[nodeName],
trParam.thermo );
temp_thermo );
break;
default:
@ -1103,10 +1106,9 @@ namespace Cantera {
XML_Node &tranTypeNode = transportNode.child(iChild);
std::string nodeName = tranTypeNode.name();
trParam.mobRatIndex.resize(nBinInt,"");
trParam.mobilityRatio.resize(nBinInt,0);
trParam.selfDiffIndex.resize(nsp,"");
trParam.mobilityRatio.resize(nsp*nsp,0);
trParam.selfDiffusion.resize(nsp,0);
ThermoPhase *temp_thermo = trParam.thermo;
if (tranTypeNode.hasChild("compositionDependence")) {
//compDepNode contains the interaction model
@ -1123,25 +1125,26 @@ namespace Cantera {
break;
case TP_MOBILITYRATIO:
{
int iSpec;
for (iSpec = 0; iSpec< nBinInt; iSpec++){
for (int iSpec = 0; iSpec< nBinInt; iSpec++){
XML_Node &propSpecNode = compDepNode.child(iSpec);
std::string specName = propSpecNode.name();
trParam.mobRatIndex[iSpec] = specName;
trParam.mobilityRatio[iSpec] = newLTI( propSpecNode,
m_tranPropMap[nodeName],
string specName = propSpecNode.name();
size_t loc = specName.find(":");
string firstSpec = specName.substr(0,loc);
string secondSpec = specName.substr(loc+1);
int index = temp_thermo->speciesIndex(firstSpec.c_str())+nsp*temp_thermo->speciesIndex(secondSpec.c_str());
trParam.mobilityRatio[index] = newLTI( propSpecNode,
m_tranPropMap[nodeName],
trParam );
};
};
break;
case TP_SELFDIFFUSION:
{
int iSpec;
for (iSpec = 0; iSpec< nsp; iSpec++){
for (int iSpec = 0; iSpec< nsp; iSpec++){
XML_Node &propSpecNode = compDepNode.child(iSpec);
std::string specName = propSpecNode.name();
trParam.selfDiffIndex[iSpec] = specName;
trParam.selfDiffusion[iSpec] = newLTI( propSpecNode,
string specName = propSpecNode.name();
int index = temp_thermo->speciesIndex(specName.c_str());
trParam.selfDiffusion[index] = newLTI( propSpecNode,
m_tranPropMap[nodeName],
trParam );
};