28 TransportFactory* TransportFactory::s_factory = 0;
31 mutex_t TransportFactory::transport_mutex;
43 CanteraError(
"getTransportData",
"error reading transport data: " + msg +
"\n") {
49 TransportFactory::TransportFactory()
51 m_models[
"Mix"] = cMixtureAveraged;
52 m_models[
"Multi"] = cMulticomponent;
53 m_models[
"Solid"] = cSolidTransport;
54 m_models[
"DustyGas"] = cDustyGasTransport;
55 m_models[
"CK_Multi"] = CK_Multicomponent;
56 m_models[
"CK_Mix"] = CK_MixtureAveraged;
57 m_models[
"Liquid"] = cLiquidTransport;
58 m_models[
"Aqueous"] = cAqueousTransport;
59 m_models[
"Simple"] = cSimpleTransport;
60 m_models[
"User"] = cUserTransport;
61 m_models[
"HighP"] = cHighP;
62 m_models[
"Pecos"] = cPecosTransport;
63 m_models[
"None"] = None;
64 for (map<string, int>::iterator iter = m_models.begin();
65 iter != m_models.end();
67 m_modelNames[iter->second] = iter->first;
70 m_tranPropMap[
"viscosity"] = TP_VISCOSITY;
71 m_tranPropMap[
"ionConductivity"] = TP_IONCONDUCTIVITY;
72 m_tranPropMap[
"mobilityRatio"] = TP_MOBILITYRATIO;
73 m_tranPropMap[
"selfDiffusion"] = TP_SELFDIFFUSION;
74 m_tranPropMap[
"thermalConductivity"] = TP_THERMALCOND;
75 m_tranPropMap[
"speciesDiffusivity"] = TP_DIFFUSIVITY;
76 m_tranPropMap[
"hydrodynamicRadius"] = TP_HYDRORADIUS;
77 m_tranPropMap[
"electricalConductivity"] = TP_ELECTCOND;
78 m_tranPropMap[
"defectDiffusivity"] = TP_DEFECTDIFF;
79 m_tranPropMap[
"defectActivity"] = TP_DEFECTCONC;
81 m_LTRmodelMap[
""] = LTP_TD_CONSTANT;
82 m_LTRmodelMap[
"constant"] = LTP_TD_CONSTANT;
83 m_LTRmodelMap[
"arrhenius"] = LTP_TD_ARRHENIUS;
84 m_LTRmodelMap[
"coeffs"] = LTP_TD_POLY;
85 m_LTRmodelMap[
"exptemp"] = LTP_TD_EXPT;
87 m_LTImodelMap[
""] = LTI_MODEL_NOTSET;
88 m_LTImodelMap[
"solvent"] = LTI_MODEL_SOLVENT;
89 m_LTImodelMap[
"moleFractions"] = LTI_MODEL_MOLEFRACS;
90 m_LTImodelMap[
"massFractions"] = LTI_MODEL_MASSFRACS;
91 m_LTImodelMap[
"logMoleFractions"] = LTI_MODEL_LOG_MOLEFRACS;
92 m_LTImodelMap[
"pairwiseInteraction"] = LTI_MODEL_PAIRWISE_INTERACTION;
93 m_LTImodelMap[
"stefanMaxwell_PPN"] = LTI_MODEL_STEFANMAXWELL_PPN;
94 m_LTImodelMap[
"moleFractionsExpT"] = LTI_MODEL_MOLEFRACS_EXPT;
95 m_LTImodelMap[
"none"] = LTI_MODEL_NONE;
96 m_LTImodelMap[
"multiple"] = LTI_MODEL_MULTIPLE;
99 void TransportFactory::deleteFactory()
101 ScopedLock transportLock(transport_mutex);
106 std::string TransportFactory::modelName(
int model)
108 return getValue<int,string>(factory()->m_modelNames, model,
"");
115 std::string model =
lowercase(trNode[
"model"]);
116 switch (m_LTRmodelMap[model]) {
117 case LTP_TD_CONSTANT:
120 case LTP_TD_ARRHENIUS:
130 throw CanteraError(
"TransportFactory::newLTP",
"unknown transport model: " + model);
131 ltps =
new LTPspecies(&trNode, name, tp_ind, thermo);
144 std::string model = trNode[
"model"];
145 switch (m_LTImodelMap[model]) {
146 case LTI_MODEL_SOLVENT:
147 lti =
new LTI_Solvent(tp_ind);
148 lti->
init(trNode, thermo);
150 case LTI_MODEL_MOLEFRACS:
152 lti->
init(trNode, thermo);
154 case LTI_MODEL_MASSFRACS:
156 lti->
init(trNode, thermo);
158 case LTI_MODEL_LOG_MOLEFRACS:
160 lti->
init(trNode, thermo);
162 case LTI_MODEL_PAIRWISE_INTERACTION:
164 lti->
init(trNode, thermo);
165 lti->setParameters(trParam);
167 case LTI_MODEL_STEFANMAXWELL_PPN:
169 lti->
init(trNode, thermo);
170 lti->setParameters(trParam);
172 case LTI_MODEL_STOKES_EINSTEIN:
173 lti =
new LTI_StokesEinstein(tp_ind);
174 lti->
init(trNode, thermo);
175 lti->setParameters(trParam);
177 case LTI_MODEL_MOLEFRACS_EXPT:
179 lti->
init(trNode, thermo);
181 case LTI_MODEL_NOTSET:
183 case LTI_MODEL_MULTIPLE:
185 lti->
init(trNode, thermo);
192 lti->
init(trNode, thermo);
197 Transport* TransportFactory::newTransport(
const std::string& transportModel,
198 thermo_t* phase,
int log_level,
int ndim)
201 if (transportModel ==
"") {
211 switch (m_models[transportModel]) {
215 case cMulticomponent:
217 tr->
init(phase, 0, log_level);
219 case CK_Multicomponent:
221 tr->
init(phase, CK_Mode, log_level);
223 case cMixtureAveraged:
225 tr->
init(phase, 0, log_level);
227 case CK_MixtureAveraged:
229 tr->
init(phase, CK_Mode, log_level);
233 tr->
init(phase, 0, log_level);
235 case cSolidTransport:
238 initSolidTransport(tr, phase, log_level);
241 case cDustyGasTransport:
244 gastr->
init(phase, 0, log_level);
248 case cSimpleTransport:
250 initLiquidTransport(tr, phase, log_level);
253 case cLiquidTransport:
255 initLiquidTransport(tr, phase, log_level);
258 case cAqueousTransport:
260 initLiquidTransport(tr, phase, log_level);
264 throw CanteraError(
"newTransport",
"unknown transport model: " + transportModel);
272 std::string transportModel =
"None";
274 if (phaseNode.
hasChild(
"transport")) {
275 transportModel = phaseNode.
child(
"transport").
attrib(
"model");
277 return newTransport(transportModel, phase,log_level);
281 int mode,
int log_level)
284 "To be removed after Cantera 2.2. This initialization is "
285 "now handled directly by GasTransport::init");
289 void TransportFactory::setupLiquidTransport(
thermo_t* thermo,
int log_level,
293 const std::vector<const XML_Node*> & species_database = thermo->
speciesData();
299 size_t nsp = trParam.
nsp_;
306 trParam.
mw.resize(nsp);
311 trParam.
LTData.resize(nsp);
321 getLiquidSpeciesTransportData(species_database, log, trParam.
thermo->
speciesNames(), trParam);
326 if (phase_database->
hasChild(
"transport")) {
327 XML_Node& transportNode = phase_database->
child(
"transport");
328 getLiquidInteractionsTransportData(transportNode, log, trParam.
thermo->
speciesNames(), trParam);
333 void TransportFactory::setupSolidTransport(
thermo_t* thermo,
int log_level,
341 size_t nsp = trParam.
nsp_;
348 trParam.
mw.resize(nsp);
357 if (phase_database->
hasChild(
"transport")) {
358 XML_Node& transportNode = phase_database->
child(
"transport");
359 getSolidTransportData(transportNode, log, thermo->
name(), trParam);
363 void TransportFactory::initLiquidTransport(
Transport* tran,
368 setupLiquidTransport(thermo, log_level, trParam);
373 void TransportFactory::initSolidTransport(
Transport* tran,
378 setupSolidTransport(thermo, log_level, trParam);
383 void TransportFactory::getLiquidSpeciesTransportData(
const std::vector<const XML_Node*> &xspecies,
385 const std::vector<std::string> &names,
392 std::map<std::string, LiquidTransportData> datatable;
393 std::map<std::string, LiquidTransportData>::iterator it;
396 size_t nsp = trParam.
nsp_;
399 size_t nBinInt = nsp*(nsp-1)/2;
404 for (
size_t i = 0; i < nsp; i++) {
424 for (
size_t iChild = 0; iChild < num; iChild++) {
426 std::string nodeName = xmlChild.
name();
428 switch (m_tranPropMap[nodeName]) {
430 data.
viscosity = newLTP(xmlChild, name, m_tranPropMap[nodeName], temp_thermo);
432 case TP_IONCONDUCTIVITY:
433 data.
ionConductivity = newLTP(xmlChild, name, m_tranPropMap[nodeName], temp_thermo);
435 case TP_MOBILITYRATIO: {
436 for (
size_t iSpec = 0; iSpec< nBinInt; iSpec++) {
438 std::string specName = propSpecNode.
name();
439 size_t loc = specName.find(
":");
440 std::string firstSpec = specName.substr(0,loc);
441 std::string secondSpec = specName.substr(loc+1);
443 data.
mobilityRatio[index] = newLTP(propSpecNode, name, m_tranPropMap[nodeName], temp_thermo);
447 case TP_SELFDIFFUSION: {
448 for (
size_t iSpec = 0; iSpec< nsp; iSpec++) {
450 std::string specName = propSpecNode.
name();
451 size_t index = temp_thermo->
speciesIndex(specName.c_str());
452 data.
selfDiffusion[index] = newLTP(propSpecNode, name, m_tranPropMap[nodeName], temp_thermo);
459 m_tranPropMap[nodeName],
465 m_tranPropMap[nodeName],
471 m_tranPropMap[nodeName],
477 m_tranPropMap[nodeName],
482 throw CanteraError(
"getLiquidSpeciesTransportData",
"unknown transport property: " + nodeName);
486 datatable.insert(pair<std::string, LiquidTransportData>(name,data));
495 for (
size_t i = 0; i < trParam.
nsp_; i++) {
500 it = datatable.find(names[i]);
501 if (it == datatable.end()) {
502 throw TransportDBError(0,
"No transport data found for species " + names[i]);
510 trParam.
LTData.push_back(trdat);
523 void TransportFactory::getLiquidInteractionsTransportData(
const XML_Node& transportNode,
525 const std::vector<std::string> &names,
530 size_t nsp = trParam.
nsp_;
531 size_t nBinInt = nsp*(nsp-1)/2;
534 for (
size_t iChild = 0; iChild < num; iChild++) {
537 std::string nodeName = tranTypeNode.
name();
543 if (tranTypeNode.
name() ==
"compositionDependence") {
544 std::string modelName = tranTypeNode.
attrib(
"model");
545 std::map<string, LiquidTranMixingModel>::iterator it = m_LTImodelMap.find(modelName);
546 if (it == m_LTImodelMap.end()) {
547 throw CanteraError(
"TransportFactory::getLiquidInteractionsTransportData",
548 "Unknown compositionDependence string: " + modelName);
553 if (tranTypeNode.
hasChild(
"compositionDependence")) {
555 XML_Node& compDepNode = tranTypeNode.
child(
"compositionDependence");
556 switch (m_tranPropMap[nodeName]) {
559 trParam.
viscosity = newLTI(compDepNode, m_tranPropMap[nodeName], trParam);
561 case TP_IONCONDUCTIVITY:
563 m_tranPropMap[nodeName],
566 case TP_MOBILITYRATIO: {
567 for (
size_t iSpec = 0; iSpec< nBinInt; iSpec++) {
569 string specName = propSpecNode.
name();
570 size_t loc = specName.find(
":");
571 string firstSpec = specName.substr(0,loc);
572 string secondSpec = specName.substr(loc+1);
575 m_tranPropMap[nodeName],
580 case TP_SELFDIFFUSION: {
581 for (
size_t iSpec = 0; iSpec< nsp; iSpec++) {
583 string specName = propSpecNode.
name();
584 size_t index = temp_thermo->
speciesIndex(specName.c_str());
586 m_tranPropMap[nodeName],
593 m_tranPropMap[nodeName],
598 m_tranPropMap[nodeName],
603 m_tranPropMap[nodeName],
608 m_tranPropMap[nodeName],
612 throw CanteraError(
"getLiquidInteractionsTransportData",
"unknown transport property: " + nodeName);
624 if (tranTypeNode.
hasChild(
"velocityBasis")) {
625 std::string velocityBasis =
626 tranTypeNode.
child(
"velocityBasis").
attrib(
"basis");
627 if (velocityBasis ==
"mass") {
629 }
else if (velocityBasis ==
"mole") {
634 int linenum = __LINE__;
635 throw TransportDBError(linenum,
"Unknown attribute \"" + velocityBasis +
"\" for <velocityBasis> node. ");
641 std::cout << err.
what() << std::endl;
646 void TransportFactory::getSolidTransportData(
const XML_Node& transportNode,
648 const std::string phaseName,
654 for (
size_t iChild = 0; iChild < num; iChild++) {
657 std::string nodeName = tranTypeNode.
name();
662 switch (m_tranPropMap[nodeName]) {
663 case TP_IONCONDUCTIVITY:
665 m_tranPropMap[nodeName],
670 m_tranPropMap[nodeName],
675 m_tranPropMap[nodeName],
680 m_tranPropMap[nodeName],
685 m_tranPropMap[nodeName],
689 throw CanteraError(
"getSolidTransportData",
"unknown transport property: " + nodeName);
703 f = TransportFactory::factory();
705 return f->
newTransport(transportModel, thermo, loglevel, ndim);
711 f = TransportFactory::factory();
LTPspecies * defectDiffusivity
Model type for the defectDiffusivity – or more like a defect diffusivity in the context of the solid ...
doublereal tmin
Minimum temperatures for parameter fits.
Headers for the DustyGasTransport object, which models transport properties in porous media using the...
TransportPropertyType
Enumeration of the types of transport properties that can be handled by the variables in the various ...
void restoreState(const vector_fp &state)
Restore a state saved on a previous call to saveState.
DenseMatrix radius_Aij
Interaction associated with hydrodynamic radius.
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
std::vector< LiquidTranInteraction * > mobilityRatio
Vector of pointer to the LiquidTranInteraction object which handles the calculation of the mobility r...
thermo_t * thermo
Pointer to the ThermoPhase object: shallow pointer.
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
virtual Transport * newTransport(const std::string &model, thermo_t *thermo, int log_level=0, int ndim=1)
Build a new transport manager using a transport manager that may not be the same as in the phase desc...
Various templated functions that carry out common vector operations (see Templated Utility Functions)...
LTPspecies * thermalCond
Model type for the thermal conductivity.
Simple mass fraction weighting of transport properties.
void showErrors(std::ostream &f)
Prints all of the error messages to an ostream.
Factory class for creating new instances of classes derived from Transport.
Interface for class MultiTransport.
LTPspecies * defectActivity
Model type for the defectActivity.
size_t nsp_
Local storage of the number of species.
doublereal tmax
Maximum temperatures for parameter fits.
Transport * newTransportMgr(const std::string &transportModel, thermo_t *thermo, int loglevel, TransportFactory *f, int ndim)
Create a new transport manager instance.
Class LiquidTransport implements models for transport properties for liquid phases.
Class DustyGasTransport implements the Dusty Gas model for transport in porous media.
Class XML_Node is a tree-based representation of the contents of an XML file.
Header file defining class SolidTransportData.
Transport properties that act like pairwise interactions as in binary diffusion coefficients.
Base class for transport property managers.
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
LiquidTranInteraction * viscosity
Object that specifies the viscosity interaction for the mixture.
Class LiquidTransportData holds transport parameters for a specific liquid-phase species.
virtual bool initSolid(SolidTransportData &tr)
Called by TransportFactory to set parameters.
Class LTPspecies_Arrhenius holds transport parameters for a specific liquid-phase species (LTPspecies...
std::string lowercase(const std::string &s)
Cast a copy of a string to lower case.
TransportDBError(size_t linenum, const std::string &msg)
Default constructor.
Header file defining class PecosTransport.
virtual void init(thermo_t *thermo, int mode=0, int log_level=0)
Initialize a transport manager.
std::string name() const
Return the name of the phase.
LTPspecies * electConductivity
Model type for the electrical conductivity.
LTPspecies * speciesDiffusivity
Model type for the speciesDiffusivity.
Header file for defining the class SolidTransport, which handles transport of ions within solid phase...
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
Header file defining class TransportFactory (see TransportFactory)
Class SolidTransport implements transport properties for solids.
Base class for a phase with thermodynamic properties.
Class LiquidTransportParams holds transport model parameters relevant to transport in mixtures...
std::vector< LiquidTranInteraction * > selfDiffusion
Vector of pointer to the LiquidTranInteraction object which handles the calculation of each species' ...
Class MultiTransport implements transport properties for high pressure gas mixtures.
size_t speciesIndex(const std::string &name) const
Returns the index of a species named 'name' within the Phase object.
virtual void init(ThermoPhase *thermo, int mode=0, int log_level=0)
Initialize a transport manager.
LiquidTranInteraction * ionConductivity
Object that specifes the ionic Conductivity of the mixture.
void resize(size_t n, size_t m, doublereal v=0.0)
Resize the matrix.
VelocityBasis velocityBasis_
A basis for the average velocity can be specified.
Mixing rule using logarithms of the mole fractions.
const char * what() const
Get a description of the error.
virtual doublereal maxTemp(size_t k=npos) const
Maximum temperature for which the thermodynamic data for the species are valid.
std::string name() const
Returns the name of the XML node.
Header file for the class SimpleTransport which provides simple transport properties for liquids and ...
void initialize(ThermoPhase *phase, Transport *gastr)
Initialization routine called by TransportFactory.
DenseMatrix thermalCond_Aij
Interaction associated with linear weighting of thermal conductivity.
Base class for exceptions thrown by Cantera classes.
Header file defining class AqueousTransport.
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
LiquidTranMixingModel compositionDepTypeDefault_
Default composition dependence of the transport properties.
Class LTPspecies_Const holds transport parameters for a specific liquid-phase species (LTPspecies) wh...
Interface for class HighPressureGasTransport.
LiquidTranInteraction * speciesDiffusivity
Pointer to the LiquidTranInteraction object which handles the calculation of the species diffusivity ...
Class LTPspecies holds transport parameterizations for a specific liquid-phase species.
vector_fp mw
Local storage of the molecular weights of the species.
Simple mole fraction weighting of transport properties.
std::vector< Cantera::LiquidTransportData > LTData
Species transport parameters.
size_t nSpecies() const
Returns the number of species in the phase.
Class MultiTransport implements multicomponent transport properties for ideal gas mixtures...
const std::vector< std::string > & speciesNames() const
Return a const reference to the vector of species names.
const vector_fp & molecularWeights() const
Return a const reference to the internal vector of molecular weights.
const VelocityBasis VB_MOLEAVG
Diffusion velocities are based on the mole averaged velocities.
LTPspecies * electCond
Model type for the electrical conductivity.
Class LTPspecies_ExpT holds transport parameters for a specific liquid- phase species (LTPspecies) wh...
Header file defining class LiquidTransport.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
virtual bool initLiquid(LiquidTransportParams &tr)
Called by TransportFactory to set parameters.
XML_Node & xml() const
Returns a const reference to the XML_Node that describes the phase.
std::string speciesName
A LiquidTransportData object is instantiated for each species.
std::vector< LTPspecies * > mobilityRatio
Model type for the mobility ratio.
LTPspecies * ionConductivity
Model type for the ionic conductivity.
Exception thrown if an error is encountered while reading the transport database. ...
LTPspecies * hydroRadius
Model type for the hydroradius.
Stefan Maxwell Diffusion Coefficients can be solved for given ion conductivity, mobility ratios...
DenseMatrix diff_Dij
Interaction associated with linear weighting of thermal conductivity.
const std::vector< const XML_Node * > & speciesData() const
Return a pointer to the vector of XML nodes containing the species data for this phase.
Contains declarations for string manipulation functions within Cantera.
std::vector< LTPspecies * > selfDiffusion
Model type for the self diffusion coefficients.
LTPspecies * viscosity
Model type for the viscosity.
Simple mole fraction weighting of transport properties.
void saveState(vector_fp &state) const
Save the current internal state of the phase Write to vector 'state' the current internal state...
LiquidTranInteraction * hydroRadius
Pointer to the LiquidTranInteraction object which handles the calculation of the hydrodynamic radius ...
const VelocityBasis VB_MASSAVG
Diffusion velocities are based on the mass averaged velocity.
virtual void setThermo(thermo_t &thermo)
Specifies the ThermoPhase object.
virtual void init(const XML_Node &compModelNode=XML_Node(), thermo_t *thermo=0)
initialize LiquidTranInteraction objects with thermo and XML node
LTPspecies * thermalConductivity
Model type for the thermal conductivity.
Transport * newDefaultTransportMgr(thermo_t *thermo, int loglevel, TransportFactory *f)
Create a new transport manager instance.
Class MixTransport implements mixture-averaged transport properties for ideal gas mixtures...
LTPspecies * ionConductivity
Model type for the ionic conductivity.
Class LTPspecies_Poly holds transport parameters for a specific liquid-phase species (LTPspecies) whe...
Class SolidTransportData holds transport parameters for a specific solid-phase species.
Headers for the MixTransport object, which models transport properties in ideal gas solutions using a...
Base class to handle transport property evaluation in a mixture.
LiquidTranInteraction * thermalCond
Pointer to the LiquidTranInteraction object which handles the calculation of the mixture thermal cond...
Class SimpleTransport implements mixture-averaged transport properties for liquid phases...
size_t nChildren(bool discardComments=false) const
Return the number of children.
virtual doublereal minTemp(size_t k=npos) const
Minimum temperature for which the thermodynamic data for the species or phase are valid...
LiquidTranInteraction * electCond
Pointer to the LiquidTranInteraction object which handles the calculation of the electrical conductiv...
Class AqueousTransport implements mixture-averaged transport properties for brine phases...
void save()
Function to put this error onto Cantera's error stack.