Changed the signature of LiquidTranInteraction::getMatrixTransProp(
DenseMatrix &mat, doublereal* speciesValues = 0 ) so that now it takes a reference to the matrix that needs to be filled, avoiding an extra copy construction. For vector and DenseMatrix resize operations, added 0.0 or 0 as initialization value so that we don't have garbage in these. This is most relevant for vectors of pointers where we need NULL values to test against.
This commit is contained in:
parent
b41d72bf4c
commit
4b676b388c
3 changed files with 50 additions and 56 deletions
|
|
@ -195,15 +195,15 @@ namespace Cantera {
|
|||
m_tmax = m_thermo->maxTemp();
|
||||
|
||||
// make a local copy of the molecular weights
|
||||
m_mw.resize(m_nsp);
|
||||
m_mw.resize(m_nsp, 0.0);
|
||||
copy(m_thermo->molecularWeights().begin(),
|
||||
m_thermo->molecularWeights().end(), m_mw.begin());
|
||||
|
||||
/*
|
||||
* Get the input Viscosities
|
||||
*/
|
||||
m_viscSpecies.resize(m_nsp);
|
||||
m_viscTempDep_Ns.resize(m_nsp);
|
||||
m_viscSpecies.resize(m_nsp, 0.0);
|
||||
m_viscTempDep_Ns.resize(m_nsp, 0);
|
||||
//for each species, assign viscosity model and coefficients
|
||||
for (k = 0; k < m_nsp; k++) {
|
||||
Cantera::LiquidTransportData <d = tr.LTData[k];
|
||||
|
|
@ -213,8 +213,8 @@ namespace Cantera {
|
|||
/*
|
||||
* Get the input Thermal Conductivities
|
||||
*/
|
||||
m_lambdaSpecies.resize(m_nsp);
|
||||
m_lambdaTempDep_Ns.resize(m_nsp);
|
||||
m_lambdaSpecies.resize(m_nsp, 0.0);
|
||||
m_lambdaTempDep_Ns.resize(m_nsp, 0);
|
||||
//for each species, assign thermal conductivity model
|
||||
for (k = 0; k < m_nsp; k++) {
|
||||
Cantera::LiquidTransportData <d = tr.LTData[k];
|
||||
|
|
@ -224,8 +224,8 @@ namespace Cantera {
|
|||
/*
|
||||
* Get the input Hydrodynamic Radii
|
||||
*/
|
||||
m_hydrodynamic_radius.resize(m_nsp);
|
||||
m_radiusTempDep_Ns.resize(m_nsp);
|
||||
m_hydrodynamic_radius.resize(m_nsp, 0.0);
|
||||
m_radiusTempDep_Ns.resize(m_nsp, 0);
|
||||
//for each species, assign model for hydrodynamic radius
|
||||
for (k = 0; k < m_nsp; k++) {
|
||||
Cantera::LiquidTransportData <d = tr.LTData[k];
|
||||
|
|
@ -239,7 +239,7 @@ namespace Cantera {
|
|||
* needed for the current model. This section may, therefore,
|
||||
* be extraneous.
|
||||
*/
|
||||
m_diffTempDep_Ns.resize(m_nsp);
|
||||
m_diffTempDep_Ns.resize(m_nsp, 0);
|
||||
//for each species, assign viscosity model and coefficients
|
||||
for (k = 0; k < m_nsp; k++) {
|
||||
Cantera::LiquidTransportData <d = tr.LTData[k];
|
||||
|
|
@ -267,25 +267,25 @@ namespace Cantera {
|
|||
m_lambdaMixModel = tr.thermalCond;
|
||||
//m_radiusMixModel = tr.hydroRadius;
|
||||
m_diffMixModel = tr.speciesDiffusivity;
|
||||
m_bdiff.resize(m_nsp,m_nsp);
|
||||
m_bdiff.resize(m_nsp,m_nsp, 0.0);
|
||||
//Don't really need to update this here.
|
||||
//It is updated in updateDiff_T()
|
||||
m_bdiff = m_diffMixModel->getMatrixTransProp();
|
||||
m_diffMixModel->getMatrixTransProp( m_bdiff );
|
||||
|
||||
m_mode = tr.mode_;
|
||||
|
||||
m_massfracs.resize(m_nsp);
|
||||
m_massfracs_tran.resize(m_nsp);
|
||||
m_molefracs.resize(m_nsp);
|
||||
m_molefracs_tran.resize(m_nsp);
|
||||
m_concentrations.resize(m_nsp);
|
||||
m_actCoeff.resize(m_nsp);
|
||||
m_chargeSpecies.resize(m_nsp);
|
||||
m_massfracs.resize(m_nsp, 0.0);
|
||||
m_massfracs_tran.resize(m_nsp, 0.0);
|
||||
m_molefracs.resize(m_nsp, 0.0);
|
||||
m_molefracs_tran.resize(m_nsp, 0.0);
|
||||
m_concentrations.resize(m_nsp, 0.0);
|
||||
m_actCoeff.resize(m_nsp, 0.0);
|
||||
m_chargeSpecies.resize(m_nsp, 0.0);
|
||||
for ( int i = 0; i < m_nsp; i++ )
|
||||
m_chargeSpecies[i] = m_thermo->charge( i );
|
||||
m_volume_spec.resize(m_nsp);
|
||||
m_Grad_lnAC.resize(m_nsp);
|
||||
m_spwork.resize(m_nsp);
|
||||
m_volume_spec.resize(m_nsp, 0.0);
|
||||
m_Grad_lnAC.resize(m_nsp, 0.0);
|
||||
m_spwork.resize(m_nsp, 0.0);
|
||||
|
||||
// resize the internal gradient variables
|
||||
m_Grad_X.resize(m_nDim * m_nsp, 0.0);
|
||||
|
|
@ -293,8 +293,8 @@ namespace Cantera {
|
|||
m_Grad_V.resize(m_nDim, 0.0);
|
||||
m_Grad_mu.resize(m_nDim * m_nsp, 0.0);
|
||||
|
||||
m_flux.resize(m_nsp, m_nDim);
|
||||
m_Vdiff.resize(m_nsp, m_nDim);
|
||||
m_flux.resize(m_nsp, m_nDim, 0.0);
|
||||
m_Vdiff.resize(m_nsp, m_nDim, 0.0);
|
||||
|
||||
|
||||
// set all flags to false
|
||||
|
|
@ -1082,7 +1082,7 @@ namespace Cantera {
|
|||
//! wrt T using calls to the appropriate LTPspecies subclass
|
||||
void LiquidTransport::updateDiff_T() {
|
||||
|
||||
m_bdiff = m_diffMixModel->getMatrixTransProp();
|
||||
m_diffMixModel->getMatrixTransProp( m_bdiff );
|
||||
m_diff_temp_ok = true;
|
||||
m_diff_mix_ok = false;
|
||||
}
|
||||
|
|
@ -1221,8 +1221,8 @@ namespace Cantera {
|
|||
void LiquidTransport::stefan_maxwell_solve() {
|
||||
int i, j, a;
|
||||
doublereal tmp;
|
||||
m_B.resize(m_nsp, m_nDim);
|
||||
m_A.resize(m_nsp, m_nsp);
|
||||
m_B.resize(m_nsp, m_nDim, 0.0);
|
||||
m_A.resize(m_nsp, m_nsp, 0.0);
|
||||
|
||||
//! grab a local copy of the molecular weights
|
||||
const vector_fp& M = m_thermo->molecularWeights();
|
||||
|
|
|
|||
|
|
@ -58,10 +58,10 @@ namespace Cantera {
|
|||
m_thermo = thermo;
|
||||
|
||||
int nsp = thermo->nSpecies();
|
||||
m_Aij.resize(nsp,nsp);
|
||||
m_Dij.resize(nsp,nsp);
|
||||
m_Eij.resize(nsp,nsp);
|
||||
m_Sij.resize(nsp,nsp);
|
||||
m_Aij.resize( nsp, nsp, 0.0 );
|
||||
m_Dij.resize( nsp, nsp, 0.0 );
|
||||
m_Eij.resize( nsp, nsp, 0.0 );
|
||||
m_Sij.resize( nsp, nsp, 0.0 );
|
||||
|
||||
std::string speciesA;
|
||||
std::string speciesB;
|
||||
|
|
@ -350,7 +350,7 @@ namespace Cantera {
|
|||
|
||||
void LTI_Pairwise_Interaction::setParameters( LiquidTransportParams& trParam ) {
|
||||
int nsp = m_thermo->nSpecies();
|
||||
m_diagonals.resize(nsp);
|
||||
m_diagonals.resize(nsp, 0);
|
||||
|
||||
for (int k = 0; k < nsp; k++) {
|
||||
Cantera::LiquidTransportData <d = trParam.LTData[k];
|
||||
|
|
@ -386,24 +386,21 @@ namespace Cantera {
|
|||
return value;
|
||||
}
|
||||
|
||||
DenseMatrix LTI_Pairwise_Interaction::getMatrixTransProp( doublereal *speciesValues ) {
|
||||
void LTI_Pairwise_Interaction::getMatrixTransProp( DenseMatrix &mat, doublereal *speciesValues ) {
|
||||
|
||||
int nsp = m_thermo->nSpecies();
|
||||
doublereal temp = m_thermo->temperature();
|
||||
doublereal molefracs[nsp];
|
||||
m_thermo->getMoleFractions(molefracs);
|
||||
m_thermo->getMoleFractions( molefracs );
|
||||
|
||||
DenseMatrix tmp;
|
||||
tmp.resize(nsp,nsp);
|
||||
mat.resize( nsp, nsp, 0.0 );
|
||||
for ( int i = 0; i < nsp; i++ )
|
||||
for ( int j = 0; j < i; j++ )
|
||||
tmp(i,j) = tmp(j,i) = m_Dij(i,j) * exp( - m_Eij(i,j) / temp );
|
||||
mat(i,j) = mat(j,i) = m_Dij(i,j) * exp( - m_Eij(i,j) / temp );
|
||||
|
||||
for ( int i = 0; i < nsp; i++ )
|
||||
if ( tmp(i,i) == 0.0 && m_diagonals[i] )
|
||||
tmp(i,i) = m_diagonals[i]->getSpeciesTransProp() ;
|
||||
|
||||
return tmp;
|
||||
if ( mat(i,i) == 0.0 && m_diagonals[i] )
|
||||
mat(i,i) = m_diagonals[i]->getSpeciesTransProp() ;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -438,8 +435,8 @@ namespace Cantera {
|
|||
|
||||
void LTI_StokesEinstein::setParameters( LiquidTransportParams& trParam ) {
|
||||
int nsp = m_thermo->nSpecies();
|
||||
m_viscosity.resize(nsp);
|
||||
m_hydroRadius.resize(nsp);
|
||||
m_viscosity.resize( nsp, 0 );
|
||||
m_hydroRadius.resize( nsp, 0 );
|
||||
for (int k = 0; k < nsp; k++) {
|
||||
Cantera::LiquidTransportData <d = trParam.LTData[k];
|
||||
m_viscosity[k] = ltd.viscosity;
|
||||
|
|
@ -447,7 +444,7 @@ namespace Cantera {
|
|||
}
|
||||
}
|
||||
|
||||
DenseMatrix LTI_StokesEinstein::getMatrixTransProp( doublereal *speciesValues ) {
|
||||
void LTI_StokesEinstein::getMatrixTransProp( DenseMatrix &mat, doublereal *speciesValues ) {
|
||||
|
||||
int nsp = m_thermo->nSpecies();
|
||||
doublereal temp = m_thermo->temperature();
|
||||
|
|
@ -460,17 +457,14 @@ namespace Cantera {
|
|||
radiusSpec[k] = m_hydroRadius[k]->getSpeciesTransProp() ;
|
||||
}
|
||||
|
||||
DenseMatrix tmp;
|
||||
tmp.resize(nsp,nsp);
|
||||
mat.resize(nsp,nsp, 0.0);
|
||||
for (int i = 0; i < nsp; i++)
|
||||
for (int j = 0; j < nsp; j++) {
|
||||
tmp(i,j) = GasConstant * temp
|
||||
mat(i,j) = GasConstant * temp
|
||||
/ ( 6.0 * Pi * radiusSpec[i] * viscSpec[j] ) ;
|
||||
}
|
||||
delete radiusSpec;
|
||||
delete viscSpec;
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -154,8 +154,8 @@ namespace Cantera {
|
|||
throw NotImplemented("LiquidTranInteraction::getMixTransProp");
|
||||
}
|
||||
|
||||
virtual DenseMatrix getMatrixTransProp( doublereal* speciesValues = 0 ) {
|
||||
//return m_Dij;
|
||||
virtual void getMatrixTransProp( DenseMatrix &mat, doublereal* speciesValues = 0 ) {
|
||||
//mat = m_Dij;
|
||||
throw NotImplemented("LiquidTranInteraction::getMixTransProp");
|
||||
}
|
||||
|
||||
|
|
@ -276,12 +276,12 @@ namespace Cantera {
|
|||
/**
|
||||
* Takes the separate species transport properties
|
||||
* as input (this method does not know what
|
||||
* transport property it is at this point.
|
||||
* transport property it is at this point).
|
||||
*/
|
||||
doublereal getMixTransProp( doublereal *valueSpecies, doublereal *weightSpecies = 0 );
|
||||
doublereal getMixTransProp( std::vector<LTPspecies*> LTPptrs ) ;
|
||||
|
||||
DenseMatrix getMatrixTransProp( doublereal* speciesValues = 0 ) { return m_Aij; }
|
||||
void getMatrixTransProp( DenseMatrix &mat, doublereal* speciesValues = 0 ) { mat = m_Aij; }
|
||||
|
||||
protected:
|
||||
|
||||
|
|
@ -323,7 +323,7 @@ namespace Cantera {
|
|||
doublereal getMixTransProp( doublereal *valueSpecies, doublereal *weightSpecies = 0 );
|
||||
doublereal getMixTransProp( std::vector<LTPspecies*> LTPptrs ) ;
|
||||
|
||||
DenseMatrix getMatrixTransProp( doublereal* speciesValues = 0 ) { return m_Aij; }
|
||||
void getMatrixTransProp( DenseMatrix &mat, doublereal* speciesValues = 0 ) { mat = m_Aij; }
|
||||
|
||||
protected:
|
||||
|
||||
|
|
@ -366,7 +366,7 @@ namespace Cantera {
|
|||
doublereal getMixTransProp( doublereal *valueSpecies, doublereal *weightSpecies = 0 );
|
||||
doublereal getMixTransProp( std::vector<LTPspecies*> LTPptrs ) ;
|
||||
|
||||
DenseMatrix getMatrixTransProp( doublereal* speciesValues = 0 ) { return m_Aij; }
|
||||
void getMatrixTransProp( DenseMatrix &mat, doublereal* speciesValues = 0 ) { mat = m_Aij; }
|
||||
|
||||
protected:
|
||||
|
||||
|
|
@ -440,7 +440,7 @@ namespace Cantera {
|
|||
doublereal getMixTransProp( doublereal *valueSpecies, doublereal *weightSpecies = 0 );
|
||||
doublereal getMixTransProp( std::vector<LTPspecies*> LTPptrs ) ;
|
||||
|
||||
DenseMatrix getMatrixTransProp( doublereal* speciesValues = 0 ) { return m_Eij; }
|
||||
void getMatrixTransProp( DenseMatrix &mat, doublereal* speciesValues = 0 ) { mat = m_Eij; }
|
||||
|
||||
protected:
|
||||
|
||||
|
|
@ -499,7 +499,7 @@ namespace Cantera {
|
|||
doublereal getMixTransProp( doublereal *valueSpecies, doublereal *weightSpecies = 0 );
|
||||
doublereal getMixTransProp( std::vector<LTPspecies*> LTPptrs ) ;
|
||||
|
||||
DenseMatrix getMatrixTransProp( doublereal* speciesValues = 0 ) ;
|
||||
void getMatrixTransProp( DenseMatrix &mat, doublereal* speciesValues = 0 ) ;
|
||||
|
||||
protected:
|
||||
|
||||
|
|
@ -536,7 +536,7 @@ namespace Cantera {
|
|||
doublereal getMixTransProp( doublereal *valueSpecies, doublereal *weightSpecies = 0 );
|
||||
doublereal getMixTransProp( std::vector<LTPspecies*> LTPptrs ) ;
|
||||
|
||||
DenseMatrix getMatrixTransProp( doublereal* speciesValues = 0 ) ;
|
||||
void getMatrixTransProp( DenseMatrix &mat, doublereal* speciesValues = 0 ) ;
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue