Some changes to make XML sections of liquid transport more orderly, uniform, and processed in
only one place.
This commit is contained in:
parent
3df834565b
commit
f1863b103a
7 changed files with 158 additions and 129 deletions
|
|
@ -72,7 +72,6 @@ namespace Cantera
|
|||
*/
|
||||
enum LiquidTranMixingModel {
|
||||
LTI_MODEL_NOTSET=-1,
|
||||
LTI_MODEL_NONE,
|
||||
LTI_MODEL_SOLVENT,
|
||||
LTI_MODEL_MOLEFRACS,
|
||||
LTI_MODEL_MASSFRACS,
|
||||
|
|
@ -80,7 +79,9 @@ enum LiquidTranMixingModel {
|
|||
LTI_MODEL_PAIRWISE_INTERACTION,
|
||||
LTI_MODEL_STEFANMAXWELL_PPN,
|
||||
LTI_MODEL_STOKES_EINSTEIN,
|
||||
LTI_MODEL_MOLEFRACS_EXPT
|
||||
LTI_MODEL_MOLEFRACS_EXPT,
|
||||
LTI_MODEL_NONE,
|
||||
LTI_MODEL_MULTIPLE
|
||||
};
|
||||
|
||||
//! Base class to handle transport property evaluation in a mixture.
|
||||
|
|
|
|||
|
|
@ -126,6 +126,16 @@ public:
|
|||
* Not yet implemented
|
||||
*/
|
||||
DenseMatrix radius_Aij;
|
||||
|
||||
//! Default composition dependence of the transport properties
|
||||
/*!
|
||||
*
|
||||
* Permissible types of composition dependencies
|
||||
* 0 - Solvent values (i.e., species 0) contributes only
|
||||
* 1 - linear combination of mole fractions;
|
||||
*/
|
||||
LiquidTranMixingModel compositionDepTypeDefault_;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -508,16 +508,16 @@ private:
|
|||
|
||||
//! Composition dependence of the transport properties
|
||||
/*!
|
||||
* The following coefficients are allowed to have simple
|
||||
* composition dependencies
|
||||
* The following coefficients are allowed to have simple composition dependencies
|
||||
*
|
||||
* mixture viscosity
|
||||
* mixture thermal conductivity
|
||||
*
|
||||
* Types of composition dependencies
|
||||
* Permissible types of composition dependencies
|
||||
* 0 - Solvent values (i.e., species 0) contributes only
|
||||
* 1 - linear combination of mole fractions;
|
||||
*/
|
||||
int compositionDepType_;
|
||||
enum LiquidTranMixingModel compositionDepType_;
|
||||
|
||||
//! Boolean indicating whether to use the hydrodynamic radius formulation
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ LiquidTransportParams::LiquidTransportParams() :
|
|||
hydroRadius(0),
|
||||
model_viscosity(LTI_MODEL_NOTSET),
|
||||
model_speciesDiffusivity(LTI_MODEL_NOTSET),
|
||||
model_hydroradius(LTI_MODEL_NOTSET)
|
||||
model_hydroradius(LTI_MODEL_NOTSET),
|
||||
compositionDepTypeDefault_(LTI_MODEL_NOTSET)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -56,7 +57,8 @@ LiquidTransportParams::LiquidTransportParams(const LiquidTransportParams& right)
|
|||
hydroRadius(0),
|
||||
model_viscosity(LTI_MODEL_NOTSET),
|
||||
model_speciesDiffusivity(LTI_MODEL_NOTSET),
|
||||
model_hydroradius(LTI_MODEL_NOTSET)
|
||||
model_hydroradius(LTI_MODEL_NOTSET),
|
||||
compositionDepTypeDefault_(LTI_MODEL_NOTSET)
|
||||
{
|
||||
operator=(right);
|
||||
}
|
||||
|
|
@ -106,6 +108,7 @@ LiquidTransportParams& LiquidTransportParams::operator=(const LiquidTransportPa
|
|||
diff_Dij = right.diff_Dij;
|
||||
model_hydroradius = right.model_hydroradius;
|
||||
radius_Aij = right.radius_Aij;
|
||||
compositionDepTypeDefault_ = right.compositionDepTypeDefault_;
|
||||
|
||||
throw CanteraError("LiquidTransportParams(const LiquidTransportParams &right)", "not tested");
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace Cantera
|
|||
SimpleTransport::SimpleTransport(thermo_t* thermo, int ndim) :
|
||||
Transport(thermo, ndim),
|
||||
tempDepType_(0),
|
||||
compositionDepType_(0),
|
||||
compositionDepType_(LTI_MODEL_SOLVENT),
|
||||
useHydroRadius_(false),
|
||||
doMigration_(0),
|
||||
m_iStateMF(-1),
|
||||
|
|
@ -39,7 +39,7 @@ SimpleTransport::SimpleTransport(thermo_t* thermo, int ndim) :
|
|||
SimpleTransport::SimpleTransport(const SimpleTransport& right) :
|
||||
Transport(),
|
||||
tempDepType_(0),
|
||||
compositionDepType_(0),
|
||||
compositionDepType_(LTI_MODEL_SOLVENT),
|
||||
useHydroRadius_(false),
|
||||
doMigration_(0),
|
||||
m_iStateMF(-1),
|
||||
|
|
@ -172,30 +172,18 @@ bool SimpleTransport::initLiquid(LiquidTransportParams& tr)
|
|||
XML_Node& transportNode = phaseNode.child("transport");
|
||||
string transportModel = transportNode.attrib("model");
|
||||
if (transportModel == "Simple") {
|
||||
/*
|
||||
* <compositionDependence model="Solvent_Only"/>
|
||||
* or
|
||||
* <compositionDependence model="Mixture_Averaged"/>
|
||||
*/
|
||||
std::string modelName = "";
|
||||
if (ctml::getOptionalModel(transportNode, "compositionDependence",
|
||||
modelName)) {
|
||||
modelName = lowercase(modelName);
|
||||
if (modelName == "solvent_only") {
|
||||
compositionDepType_ = 0;
|
||||
} else if (modelName == "mixture_averaged") {
|
||||
compositionDepType_ = 1;
|
||||
} else {
|
||||
throw CanteraError("SimpleTransport::initLiquid", "Unknown compositionDependence Model: " + modelName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
compositionDepType_ = tr.compositionDepTypeDefault_;
|
||||
|
||||
} else {
|
||||
throw CanteraError("SimpleTransport::initLiquid()",
|
||||
"transport model isn't the correct type: " + transportModel);
|
||||
}
|
||||
}
|
||||
|
||||
// make a local copy of the molecular weights
|
||||
m_mw.resize(m_nsp);
|
||||
copy(m_thermo->molecularWeights().begin(),
|
||||
m_thermo->molecularWeights().end(), m_mw.begin());
|
||||
copy(m_thermo->molecularWeights().begin(), m_thermo->molecularWeights().end(), m_mw.begin());
|
||||
|
||||
/*
|
||||
* Get the input Viscosities
|
||||
|
|
@ -382,13 +370,16 @@ doublereal SimpleTransport::viscosity()
|
|||
updateViscosity_T();
|
||||
}
|
||||
|
||||
if (compositionDepType_ == 0) {
|
||||
if (compositionDepType_ == LTI_MODEL_SOLVENT) {
|
||||
m_viscmix = m_viscSpecies[0];
|
||||
} else if (compositionDepType_ == 1) {
|
||||
} else if (compositionDepType_ == LTI_MODEL_MOLEFRACS) {
|
||||
m_viscmix = 0.0;
|
||||
for (size_t k = 0; k < m_nsp; k++) {
|
||||
m_viscmix += m_viscSpecies[k] * m_molefracs[k];
|
||||
}
|
||||
} else {
|
||||
throw CanteraError("SimpleTransport::viscosity()",
|
||||
"Unknowns compositionDepType");
|
||||
}
|
||||
m_visc_mix_ok = true;
|
||||
return m_viscmix;
|
||||
|
|
@ -474,13 +465,16 @@ doublereal SimpleTransport::thermalConductivity()
|
|||
updateCond_T();
|
||||
}
|
||||
if (!m_cond_mix_ok) {
|
||||
if (compositionDepType_ == 0) {
|
||||
if (compositionDepType_ == LTI_MODEL_SOLVENT) {
|
||||
m_lambda = m_condSpecies[0];
|
||||
} else if (compositionDepType_ == 1) {
|
||||
} else if (compositionDepType_ == LTI_MODEL_MOLEFRACS) {
|
||||
m_lambda = 0.0;
|
||||
for (size_t k = 0; k < m_nsp; k++) {
|
||||
m_lambda += m_condSpecies[k] * m_molefracs[k];
|
||||
}
|
||||
} else {
|
||||
throw CanteraError("SimpleTransport::thermalConductivity()",
|
||||
"Unknown compositionDepType");
|
||||
}
|
||||
m_cond_mix_ok = true;
|
||||
}
|
||||
|
|
@ -683,7 +677,7 @@ bool SimpleTransport::update_C()
|
|||
|
||||
void SimpleTransport::updateCond_T()
|
||||
{
|
||||
if (compositionDepType_ == 0) {
|
||||
if (compositionDepType_ == LTI_MODEL_SOLVENT) {
|
||||
m_condSpecies[0] = m_coeffLambda_Ns[0]->getSpeciesTransProp();
|
||||
} else {
|
||||
for (size_t k = 0; k < m_nsp; k++) {
|
||||
|
|
@ -718,7 +712,7 @@ void SimpleTransport::updateViscosities_C()
|
|||
|
||||
void SimpleTransport::updateViscosity_T()
|
||||
{
|
||||
if (compositionDepType_ == 0) {
|
||||
if (compositionDepType_ == LTI_MODEL_SOLVENT) {
|
||||
m_viscSpecies[0] = m_coeffVisc_Ns[0]->getSpeciesTransProp();
|
||||
} else {
|
||||
for (size_t k = 0; k < m_nsp; k++) {
|
||||
|
|
|
|||
|
|
@ -203,7 +203,6 @@ TransportFactory::TransportFactory() :
|
|||
m_LTRmodelMap["exptemp"] = LTP_TD_EXPT;
|
||||
|
||||
m_LTImodelMap[""] = LTI_MODEL_NOTSET;
|
||||
m_LTImodelMap["none"] = LTI_MODEL_NONE;
|
||||
m_LTImodelMap["solvent"] = LTI_MODEL_SOLVENT;
|
||||
m_LTImodelMap["moleFractions"] = LTI_MODEL_MOLEFRACS;
|
||||
m_LTImodelMap["massFractions"] = LTI_MODEL_MASSFRACS;
|
||||
|
|
@ -211,6 +210,8 @@ TransportFactory::TransportFactory() :
|
|||
m_LTImodelMap["pairwiseInteraction"] = LTI_MODEL_PAIRWISE_INTERACTION;
|
||||
m_LTImodelMap["stefanMaxwell_PPN"] = LTI_MODEL_STEFANMAXWELL_PPN;
|
||||
m_LTImodelMap["moleFractionsExpT"] = LTI_MODEL_MOLEFRACS_EXPT;
|
||||
m_LTImodelMap["none"] = LTI_MODEL_NONE;
|
||||
m_LTImodelMap["multiple"] = LTI_MODEL_MULTIPLE;
|
||||
}
|
||||
|
||||
void TransportFactory::deleteFactory()
|
||||
|
|
@ -301,10 +302,20 @@ LiquidTranInteraction* TransportFactory::newLTI(const XML_Node& trNode,
|
|||
lti = new LTI_MoleFracs_ExpT(tp_ind);
|
||||
lti->init(trNode, thermo);
|
||||
break;
|
||||
default:
|
||||
// throw CanteraError("newLTI","unknown transport model: " + model );
|
||||
case LTI_MODEL_NOTSET:
|
||||
case LTI_MODEL_NONE:
|
||||
case LTI_MODEL_MULTIPLE:
|
||||
lti = new LiquidTranInteraction(tp_ind);
|
||||
lti->init(trNode, thermo);
|
||||
break;
|
||||
default:
|
||||
//
|
||||
// @TODO make sure we can throw an error here with existing datasets and tests before changing code
|
||||
//
|
||||
lti = new LiquidTranInteraction(tp_ind);
|
||||
lti->init(trNode, thermo);
|
||||
// throw CanteraError("TransportFactory::newLTI()",
|
||||
// "unknown Liquid Transport Interaction submodel: " + model );
|
||||
}
|
||||
return lti;
|
||||
}
|
||||
|
|
@ -999,9 +1010,9 @@ void TransportFactory::getLiquidSpeciesTransportData(const std::vector<const XML
|
|||
these species read from the file.
|
||||
*/
|
||||
void TransportFactory::getLiquidInteractionsTransportData(const XML_Node& transportNode,
|
||||
XML_Node& log,
|
||||
const std::vector<std::string> &names,
|
||||
LiquidTransportParams& trParam)
|
||||
XML_Node& log,
|
||||
const std::vector<std::string> &names,
|
||||
LiquidTransportParams& trParam)
|
||||
{
|
||||
try {
|
||||
|
||||
|
|
@ -1018,93 +1029,103 @@ void TransportFactory::getLiquidInteractionsTransportData(const XML_Node& transp
|
|||
trParam.selfDiffusion.resize(nsp,0);
|
||||
ThermoPhase* temp_thermo = trParam.thermo;
|
||||
|
||||
if (tranTypeNode.name() == "compositionDependence") {
|
||||
std::string modelName = tranTypeNode.attrib("model");
|
||||
std::map<string, LiquidTranMixingModel>::iterator it = m_LTImodelMap.find(modelName);
|
||||
if (it == m_LTImodelMap.end()) {
|
||||
throw CanteraError("TransportFactory::getLiquidInteractionsTransportData",
|
||||
"Unknown compositionDependence string: " + modelName);
|
||||
} else {
|
||||
trParam.compositionDepTypeDefault_ = (*it).second;
|
||||
}
|
||||
} else {
|
||||
if (tranTypeNode.hasChild("compositionDependence")) {
|
||||
//compDepNode contains the interaction model
|
||||
XML_Node& compDepNode = tranTypeNode.child("compositionDependence");
|
||||
switch (m_tranPropMap[nodeName]) {
|
||||
break;
|
||||
case TP_VISCOSITY:
|
||||
trParam.viscosity = newLTI(compDepNode, m_tranPropMap[nodeName], trParam);
|
||||
break;
|
||||
case TP_IONCONDUCTIVITY:
|
||||
trParam.ionConductivity = newLTI(compDepNode,
|
||||
m_tranPropMap[nodeName],
|
||||
trParam);
|
||||
break;
|
||||
case TP_MOBILITYRATIO: {
|
||||
for (size_t iSpec = 0; iSpec< nBinInt; iSpec++) {
|
||||
XML_Node& propSpecNode = compDepNode.child(iSpec);
|
||||
string specName = propSpecNode.name();
|
||||
size_t loc = specName.find(":");
|
||||
string firstSpec = specName.substr(0,loc);
|
||||
string secondSpec = specName.substr(loc+1);
|
||||
size_t 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: {
|
||||
for (size_t iSpec = 0; iSpec< nsp; iSpec++) {
|
||||
XML_Node& propSpecNode = compDepNode.child(iSpec);
|
||||
string specName = propSpecNode.name();
|
||||
size_t index = temp_thermo->speciesIndex(specName.c_str());
|
||||
trParam.selfDiffusion[index] = newLTI(propSpecNode,
|
||||
m_tranPropMap[nodeName],
|
||||
trParam);
|
||||
};
|
||||
};
|
||||
break;
|
||||
case TP_THERMALCOND:
|
||||
trParam.thermalCond = newLTI(compDepNode,
|
||||
m_tranPropMap[nodeName],
|
||||
trParam);
|
||||
break;
|
||||
case TP_DIFFUSIVITY:
|
||||
trParam.speciesDiffusivity = newLTI(compDepNode,
|
||||
m_tranPropMap[nodeName],
|
||||
trParam);
|
||||
break;
|
||||
case TP_HYDRORADIUS:
|
||||
trParam.hydroRadius = newLTI(compDepNode,
|
||||
m_tranPropMap[nodeName],
|
||||
trParam);
|
||||
break;
|
||||
case TP_ELECTCOND:
|
||||
trParam.electCond = newLTI(compDepNode,
|
||||
m_tranPropMap[nodeName],
|
||||
trParam);
|
||||
break;
|
||||
default:
|
||||
throw CanteraError("getLiquidInteractionsTransportData","unknown transport property: " + nodeName);
|
||||
|
||||
if (tranTypeNode.hasChild("compositionDependence")) {
|
||||
//compDepNode contains the interaction model
|
||||
XML_Node& compDepNode = tranTypeNode.child("compositionDependence");
|
||||
switch (m_tranPropMap[nodeName]) {
|
||||
break;
|
||||
case TP_VISCOSITY:
|
||||
trParam.viscosity = newLTI(compDepNode, m_tranPropMap[nodeName], trParam);
|
||||
break;
|
||||
case TP_IONCONDUCTIVITY:
|
||||
trParam.ionConductivity = newLTI(compDepNode,
|
||||
m_tranPropMap[nodeName],
|
||||
trParam);
|
||||
break;
|
||||
case TP_MOBILITYRATIO: {
|
||||
for (size_t iSpec = 0; iSpec< nBinInt; iSpec++) {
|
||||
XML_Node& propSpecNode = compDepNode.child(iSpec);
|
||||
string specName = propSpecNode.name();
|
||||
size_t loc = specName.find(":");
|
||||
string firstSpec = specName.substr(0,loc);
|
||||
string secondSpec = specName.substr(loc+1);
|
||||
size_t 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: {
|
||||
for (size_t iSpec = 0; iSpec< nsp; iSpec++) {
|
||||
XML_Node& propSpecNode = compDepNode.child(iSpec);
|
||||
string specName = propSpecNode.name();
|
||||
size_t index = temp_thermo->speciesIndex(specName.c_str());
|
||||
trParam.selfDiffusion[index] = newLTI(propSpecNode,
|
||||
m_tranPropMap[nodeName],
|
||||
trParam);
|
||||
};
|
||||
};
|
||||
break;
|
||||
case TP_THERMALCOND:
|
||||
trParam.thermalCond = newLTI(compDepNode,
|
||||
m_tranPropMap[nodeName],
|
||||
trParam);
|
||||
break;
|
||||
case TP_DIFFUSIVITY:
|
||||
trParam.speciesDiffusivity = newLTI(compDepNode,
|
||||
m_tranPropMap[nodeName],
|
||||
trParam);
|
||||
break;
|
||||
case TP_HYDRORADIUS:
|
||||
trParam.hydroRadius = newLTI(compDepNode,
|
||||
m_tranPropMap[nodeName],
|
||||
trParam);
|
||||
break;
|
||||
case TP_ELECTCOND:
|
||||
trParam.electCond = newLTI(compDepNode,
|
||||
m_tranPropMap[nodeName],
|
||||
trParam);
|
||||
break;
|
||||
default:
|
||||
throw CanteraError("getLiquidInteractionsTransportData","unknown transport property: " + nodeName);
|
||||
|
||||
}
|
||||
}
|
||||
/* Allow a switch between mass-averaged, mole-averaged
|
||||
* and solvent specified reference velocities.
|
||||
* XML code within the transportProperty node
|
||||
* (i.e. within <viscosity>) should read as follows
|
||||
* <velocityBasis basis="mass"> <!-- mass averaged -->
|
||||
* <velocityBasis basis="mole"> <!-- mole averaged -->
|
||||
* <velocityBasis basis="H2O"> <!-- H2O solvent -->
|
||||
*/
|
||||
if (tranTypeNode.hasChild("velocityBasis")) {
|
||||
std::string velocityBasis =
|
||||
tranTypeNode.child("velocityBasis").attrib("basis");
|
||||
if (velocityBasis == "mass") {
|
||||
trParam.velocityBasis_ = VB_MASSAVG;
|
||||
} else if (velocityBasis == "mole") {
|
||||
trParam.velocityBasis_ = VB_MOLEAVG;
|
||||
} else if (trParam.thermo->speciesIndex(velocityBasis) > 0) {
|
||||
trParam.velocityBasis_ = static_cast<int>(trParam.thermo->speciesIndex(velocityBasis));
|
||||
} else {
|
||||
int linenum = __LINE__;
|
||||
throw TransportDBError(linenum, "Unknown attribute \"" + velocityBasis + "\" for <velocityBasis> node. ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Allow a switch between mass-averaged, mole-averaged
|
||||
* and solvent specified reference velocities.
|
||||
* XML code within the transportProperty node
|
||||
* (i.e. within <viscosity>) should read as follows
|
||||
* <velocityBasis basis="mass"> <!-- mass averaged -->
|
||||
* <velocityBasis basis="mole"> <!-- mole averaged -->
|
||||
* <velocityBasis basis="H2O"> <!-- H2O solvent -->
|
||||
*/
|
||||
if (tranTypeNode.hasChild("velocityBasis")) {
|
||||
std::string velocityBasis =
|
||||
tranTypeNode.child("velocityBasis").attrib("basis");
|
||||
if (velocityBasis == "mass") {
|
||||
trParam.velocityBasis_ = VB_MASSAVG;
|
||||
} else if (velocityBasis == "mole") {
|
||||
trParam.velocityBasis_ = VB_MOLEAVG;
|
||||
} else if (trParam.thermo->speciesIndex(velocityBasis) > 0) {
|
||||
trParam.velocityBasis_ = static_cast<int>(trParam.thermo->speciesIndex(velocityBasis));
|
||||
} else {
|
||||
int linenum = __LINE__;
|
||||
throw TransportDBError(linenum, "Unknown attribute \"" + velocityBasis + "\" for <velocityBasis> node. ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CanteraError& err) {
|
||||
std::cout << err.what() << std::endl;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@
|
|||
<kinetics model="none" >
|
||||
</kinetics>
|
||||
<transport model="Simple">
|
||||
<compositionDependence model="Solvent_Only"/>
|
||||
<compositionDependence model="solvent"/>
|
||||
<!--
|
||||
<compositionDependence model="Mixture_Averaged"/>
|
||||
-->
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue