Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TransportFactory.cpp
Go to the documentation of this file.
1 /**
2  * @file TransportFactory.cpp
3  *
4  * Implementation file for class TransportFactory.
5  */
6 
7 // known transport models
19 
20 #include "cantera/base/ctml.h"
22 #include "cantera/base/utilities.h"
23 
24 using namespace std;
25 
26 namespace Cantera
27 {
28 TransportFactory* TransportFactory::s_factory = 0;
29 
30 // declaration of static storage for the mutex
31 mutex_t TransportFactory::transport_mutex;
32 
33 //! Exception thrown if an error is encountered while reading the transport database
35 {
36 public:
37  //! Default constructor
38  /*!
39  * @param linenum inputs the line number
40  * @param msg String message to be sent to the user
41  */
42  TransportDBError(size_t linenum, const std::string& msg) :
43  CanteraError("getTransportData", "error reading transport data: " + msg + "\n") {
44  }
45 };
46 
47 //////////////////// class TransportFactory methods //////////////
48 
49 TransportFactory::TransportFactory()
50 {
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();
66  iter++) {
67  m_modelNames[iter->second] = iter->first;
68  }
69 
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;
80 
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;
86 
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;
97 }
98 
99 void TransportFactory::deleteFactory()
100 {
101  ScopedLock transportLock(transport_mutex);
102  delete s_factory;
103  s_factory = 0;
104 }
105 
106 std::string TransportFactory::modelName(int model)
107 {
108  return getValue<int,string>(factory()->m_modelNames, model, "");
109 }
110 
111 LTPspecies* TransportFactory::newLTP(const XML_Node& trNode, const std::string& name,
112  TransportPropertyType tp_ind, thermo_t* thermo)
113 {
114  LTPspecies* ltps = 0;
115  std::string model = lowercase(trNode["model"]);
116  switch (m_LTRmodelMap[model]) {
117  case LTP_TD_CONSTANT:
118  ltps = new LTPspecies_Const(trNode, name, tp_ind, thermo);
119  break;
120  case LTP_TD_ARRHENIUS:
121  ltps = new LTPspecies_Arrhenius(trNode, name, tp_ind, thermo);
122  break;
123  case LTP_TD_POLY:
124  ltps = new LTPspecies_Poly(trNode, name, tp_ind, thermo);
125  break;
126  case LTP_TD_EXPT:
127  ltps = new LTPspecies_ExpT(trNode, name, tp_ind, thermo);
128  break;
129  default:
130  throw CanteraError("TransportFactory::newLTP","unknown transport model: " + model);
131  ltps = new LTPspecies(&trNode, name, tp_ind, thermo);
132  }
133  return ltps;
134 }
135 
136 LiquidTranInteraction* TransportFactory::newLTI(const XML_Node& trNode,
137  TransportPropertyType tp_ind,
138  LiquidTransportParams& trParam)
139 {
140  LiquidTranInteraction* lti = 0;
141 
142  thermo_t* thermo = trParam.thermo;
143 
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);
149  break;
150  case LTI_MODEL_MOLEFRACS:
151  lti = new LTI_MoleFracs(tp_ind);
152  lti->init(trNode, thermo);
153  break;
154  case LTI_MODEL_MASSFRACS:
155  lti = new LTI_MassFracs(tp_ind);
156  lti->init(trNode, thermo);
157  break;
158  case LTI_MODEL_LOG_MOLEFRACS:
159  lti = new LTI_Log_MoleFracs(tp_ind);
160  lti->init(trNode, thermo);
161  break;
162  case LTI_MODEL_PAIRWISE_INTERACTION:
163  lti = new LTI_Pairwise_Interaction(tp_ind);
164  lti->init(trNode, thermo);
165  lti->setParameters(trParam);
166  break;
167  case LTI_MODEL_STEFANMAXWELL_PPN:
168  lti = new LTI_StefanMaxwell_PPN(tp_ind);
169  lti->init(trNode, thermo);
170  lti->setParameters(trParam);
171  break;
172  case LTI_MODEL_STOKES_EINSTEIN:
173  lti = new LTI_StokesEinstein(tp_ind);
174  lti->init(trNode, thermo);
175  lti->setParameters(trParam);
176  break;
177  case LTI_MODEL_MOLEFRACS_EXPT:
178  lti = new LTI_MoleFracs_ExpT(tp_ind);
179  lti->init(trNode, thermo);
180  break;
181  case LTI_MODEL_NOTSET:
182  case LTI_MODEL_NONE:
183  case LTI_MODEL_MULTIPLE:
184  lti = new LiquidTranInteraction(tp_ind);
185  lti->init(trNode, thermo);
186  break;
187  default:
188  //
189  // @TODO make sure we can throw an error here with existing datasets and tests before changing code
190  //
191  lti = new LiquidTranInteraction(tp_ind);
192  lti->init(trNode, thermo);
193  }
194  return lti;
195 }
196 
197 Transport* TransportFactory::newTransport(const std::string& transportModel,
198  thermo_t* phase, int log_level, int ndim)
199 {
200 
201  if (transportModel == "") {
202  return new Transport;
203  }
204 
205 
206  vector_fp state;
207  Transport* tr = 0, *gastr = 0;
208  DustyGasTransport* dtr = 0;
209  phase->saveState(state);
210 
211  switch (m_models[transportModel]) {
212  case None:
213  tr = new Transport;
214  break;
215  case cMulticomponent:
216  tr = new MultiTransport;
217  tr->init(phase, 0, log_level);
218  break;
219  case CK_Multicomponent:
220  tr = new MultiTransport;
221  tr->init(phase, CK_Mode, log_level);
222  break;
223  case cMixtureAveraged:
224  tr = new MixTransport;
225  tr->init(phase, 0, log_level);
226  break;
227  case CK_MixtureAveraged:
228  tr = new MixTransport;
229  tr->init(phase, CK_Mode, log_level);
230  break;
231  case cHighP:
232  tr = new HighPressureGasTransport;
233  tr->init(phase, 0, log_level);
234  break;
235  case cSolidTransport:
236 
237  tr = new SolidTransport;
238  initSolidTransport(tr, phase, log_level);
239  tr->setThermo(*phase);
240  break;
241  case cDustyGasTransport:
242  tr = new DustyGasTransport;
243  gastr = new MultiTransport;
244  gastr->init(phase, 0, log_level);
245  dtr = (DustyGasTransport*)tr;
246  dtr->initialize(phase, gastr);
247  break;
248  case cSimpleTransport:
249  tr = new SimpleTransport();
250  initLiquidTransport(tr, phase, log_level);
251  tr->setThermo(*phase);
252  break;
253  case cLiquidTransport:
254  tr = new LiquidTransport(phase, ndim);
255  initLiquidTransport(tr, phase, log_level);
256  tr->setThermo(*phase);
257  break;
258  case cAqueousTransport:
259  tr = new AqueousTransport;
260  initLiquidTransport(tr, phase, log_level);
261  tr->setThermo(*phase);
262  break;
263  default:
264  throw CanteraError("newTransport","unknown transport model: " + transportModel);
265  }
266  phase->restoreState(state);
267  return tr;
268 }
269 
270 Transport* TransportFactory::newTransport(thermo_t* phase, int log_level)
271 {
272  std::string transportModel = "None";
273  XML_Node& phaseNode = phase->xml();
274  if (phaseNode.hasChild("transport")) {
275  transportModel = phaseNode.child("transport").attrib("model");
276  }
277  return newTransport(transportModel, phase,log_level);
278 }
279 
280 void TransportFactory::initTransport(Transport* tr, thermo_t* thermo,
281  int mode, int log_level)
282 {
283  warn_deprecated("TransportFactory::initTransport",
284  "To be removed after Cantera 2.2. This initialization is "
285  "now handled directly by GasTransport::init");
286  tr->init(thermo);
287 }
288 
289 void TransportFactory::setupLiquidTransport(thermo_t* thermo, int log_level,
290  LiquidTransportParams& trParam)
291 {
292 
293  const std::vector<const XML_Node*> & species_database = thermo->speciesData();
294  const XML_Node* phase_database = &thermo->xml();
295 
296  // constant mixture attributes
297  trParam.thermo = thermo;
298  trParam.nsp_ = trParam.thermo->nSpecies();
299  size_t nsp = trParam.nsp_;
300 
301  trParam.tmin = thermo->minTemp();
302  trParam.tmax = thermo->maxTemp();
303  trParam.log_level = log_level;
304 
305  // Get the molecular weights and load them into trParam
306  trParam.mw.resize(nsp);
307  copy(trParam.thermo->molecularWeights().begin(),
308  trParam.thermo->molecularWeights().end(), trParam.mw.begin());
309 
310  // Resize all other vectors in trParam
311  trParam.LTData.resize(nsp);
312 
313  // Need to identify a method to obtain interaction matrices.
314  // This will fill LiquidTransportParams members visc_Eij, visc_Sij
315  trParam.thermalCond_Aij.resize(nsp,nsp);
316  trParam.diff_Dij.resize(nsp,nsp);
317  trParam.radius_Aij.resize(nsp,nsp);
318 
319  XML_Node root, log;
320  // Note that getLiquidSpeciesTransportData just populates the pure species transport data.
321  getLiquidSpeciesTransportData(species_database, log, trParam.thermo->speciesNames(), trParam);
322 
323  // getLiquidInteractionsTransportData() populates the
324  // species-species interaction models parameters
325  // like visc_Eij
326  if (phase_database->hasChild("transport")) {
327  XML_Node& transportNode = phase_database->child("transport");
328  getLiquidInteractionsTransportData(transportNode, log, trParam.thermo->speciesNames(), trParam);
329  }
330 
331 }
332 
333 void TransportFactory::setupSolidTransport(thermo_t* thermo, int log_level,
334  SolidTransportData& trParam)
335 {
336  const XML_Node* phase_database = &thermo->xml();
337 
338  // constant mixture attributes
339  trParam.thermo = thermo;
340  trParam.nsp_ = trParam.thermo->nSpecies();
341  size_t nsp = trParam.nsp_;
342 
343  trParam.tmin = thermo->minTemp();
344  trParam.tmax = thermo->maxTemp();
345  trParam.log_level = log_level;
346 
347  // Get the molecular weights and load them into trParam
348  trParam.mw.resize(nsp);
349  copy(trParam.thermo->molecularWeights().begin(),
350  trParam.thermo->molecularWeights().end(), trParam.mw.begin());
351 
352  XML_Node root, log;
353 
354  // getSolidTransportData() populates the
355  // phase transport models like electronic conductivity
356  // thermal conductivity, interstitial diffusion
357  if (phase_database->hasChild("transport")) {
358  XML_Node& transportNode = phase_database->child("transport");
359  getSolidTransportData(transportNode, log, thermo->name(), trParam);
360  }
361 }
362 
363 void TransportFactory::initLiquidTransport(Transport* tran,
364  thermo_t* thermo,
365  int log_level)
366 {
367  LiquidTransportParams trParam;
368  setupLiquidTransport(thermo, log_level, trParam);
369  // do model-specific initialization
370  tran->initLiquid(trParam);
371 }
372 
373 void TransportFactory::initSolidTransport(Transport* tran,
374  thermo_t* thermo,
375  int log_level)
376 {
377  SolidTransportData trParam;
378  setupSolidTransport(thermo, log_level, trParam);
379  // do model-specific initialization
380  tran->initSolid(trParam);
381 }
382 
383 void TransportFactory::getLiquidSpeciesTransportData(const std::vector<const XML_Node*> &xspecies,
384  XML_Node& log,
385  const std::vector<std::string> &names,
386  LiquidTransportParams& trParam)
387 {
388  std::string name;
389  /*
390  Create a map of species names versus liquid transport data parameters
391  */
392  std::map<std::string, LiquidTransportData> datatable;
393  std::map<std::string, LiquidTransportData>::iterator it;
394 
395  // Store the number of species in the phase
396  size_t nsp = trParam.nsp_;
397 
398  // Store the number of off-diagonal symmetric interactions between species in the phase
399  size_t nBinInt = nsp*(nsp-1)/2;
400 
401  // read all entries in database into 'datatable' and check for
402  // errors. Note that this procedure validates all entries, not
403  // only those for the species listed in 'names'.
404  for (size_t i = 0; i < nsp; i++) {
405  const XML_Node& sp = *xspecies[i];
406  name = sp["name"];
407  vector_fp vCoeff;
408 
409  // Species with no 'transport' child are skipped. However, if that species is in the list,
410  // it will throw an exception below.
411  try {
412  if (sp.hasChild("transport")) {
413  XML_Node& trNode = sp.child("transport");
414 
415  // Fill datatable with LiquidTransportData objects for error checking
416  // and then insertion into LiquidTransportData objects below.
417  LiquidTransportData data;
418  data.speciesName = name;
419  data.mobilityRatio.resize(nsp*nsp,0);
420  data.selfDiffusion.resize(nsp,0);
421  ThermoPhase* temp_thermo = trParam.thermo;
422 
423  size_t num = trNode.nChildren();
424  for (size_t iChild = 0; iChild < num; iChild++) {
425  XML_Node& xmlChild = trNode.child(iChild);
426  std::string nodeName = xmlChild.name();
427 
428  switch (m_tranPropMap[nodeName]) {
429  case TP_VISCOSITY:
430  data.viscosity = newLTP(xmlChild, name, m_tranPropMap[nodeName], temp_thermo);
431  break;
432  case TP_IONCONDUCTIVITY:
433  data.ionConductivity = newLTP(xmlChild, name, m_tranPropMap[nodeName], temp_thermo);
434  break;
435  case TP_MOBILITYRATIO: {
436  for (size_t iSpec = 0; iSpec< nBinInt; iSpec++) {
437  XML_Node& propSpecNode = xmlChild.child(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);
442  size_t index = temp_thermo->speciesIndex(firstSpec.c_str())+nsp*temp_thermo->speciesIndex(secondSpec.c_str());
443  data.mobilityRatio[index] = newLTP(propSpecNode, name, m_tranPropMap[nodeName], temp_thermo);
444  };
445  };
446  break;
447  case TP_SELFDIFFUSION: {
448  for (size_t iSpec = 0; iSpec< nsp; iSpec++) {
449  XML_Node& propSpecNode = xmlChild.child(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);
453  };
454  };
455  break;
456  case TP_THERMALCOND:
457  data.thermalCond = newLTP(xmlChild,
458  name,
459  m_tranPropMap[nodeName],
460  temp_thermo);
461  break;
462  case TP_DIFFUSIVITY:
463  data.speciesDiffusivity = newLTP(xmlChild,
464  name,
465  m_tranPropMap[nodeName],
466  temp_thermo);
467  break;
468  case TP_HYDRORADIUS:
469  data.hydroRadius = newLTP(xmlChild,
470  name,
471  m_tranPropMap[nodeName],
472  temp_thermo);
473  break;
474  case TP_ELECTCOND:
475  data.electCond = newLTP(xmlChild,
476  name,
477  m_tranPropMap[nodeName],
478  temp_thermo);
479 
480  break;
481  default:
482  throw CanteraError("getLiquidSpeciesTransportData","unknown transport property: " + nodeName);
483  }
484 
485  }
486  datatable.insert(pair<std::string, LiquidTransportData>(name,data));
487  }
488  } catch (CanteraError& err) {
489  err.save();
490  throw err;
491  }
492  }
493 
494  trParam.LTData.clear();
495  for (size_t i = 0; i < trParam.nsp_; i++) {
496  /*
497  Check to see that we have a LiquidTransportData object for all of the
498  species in the phase. If not, throw an error.
499  */
500  it = datatable.find(names[i]);
501  if (it == datatable.end()) {
502  throw TransportDBError(0,"No transport data found for species " + names[i]);
503  }
504  LiquidTransportData& trdat = it->second;
505 
506  /*
507  Now, transfer these objects into LTData in the correct phase index order by
508  calling the default copy constructor for LiquidTransportData.
509  */
510  trParam.LTData.push_back(trdat);
511  }
512 }
513 
514 
515 /*
516  Read transport property data from a file for interactions
517  between species in a liquid.
518  Given the name of a file containing transport property
519  parameters and a list of species names, this method returns an
520  instance of TransportParams containing the transport data for
521  these species read from the file.
522 */
523 void TransportFactory::getLiquidInteractionsTransportData(const XML_Node& transportNode,
524  XML_Node& log,
525  const std::vector<std::string> &names,
526  LiquidTransportParams& trParam)
527 {
528  try {
529 
530  size_t nsp = trParam.nsp_;
531  size_t nBinInt = nsp*(nsp-1)/2;
532 
533  size_t num = transportNode.nChildren();
534  for (size_t iChild = 0; iChild < num; iChild++) {
535  //tranTypeNode is a type of transport property like viscosity
536  XML_Node& tranTypeNode = transportNode.child(iChild);
537  std::string nodeName = tranTypeNode.name();
538 
539  trParam.mobilityRatio.resize(nsp*nsp,0);
540  trParam.selfDiffusion.resize(nsp,0);
541  ThermoPhase* temp_thermo = trParam.thermo;
542 
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);
549  } else {
550  trParam.compositionDepTypeDefault_ = it->second;
551  }
552  } else {
553  if (tranTypeNode.hasChild("compositionDependence")) {
554  //compDepNode contains the interaction model
555  XML_Node& compDepNode = tranTypeNode.child("compositionDependence");
556  switch (m_tranPropMap[nodeName]) {
557  break;
558  case TP_VISCOSITY:
559  trParam.viscosity = newLTI(compDepNode, m_tranPropMap[nodeName], trParam);
560  break;
561  case TP_IONCONDUCTIVITY:
562  trParam.ionConductivity = newLTI(compDepNode,
563  m_tranPropMap[nodeName],
564  trParam);
565  break;
566  case TP_MOBILITYRATIO: {
567  for (size_t iSpec = 0; iSpec< nBinInt; iSpec++) {
568  XML_Node& propSpecNode = compDepNode.child(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);
573  size_t index = temp_thermo->speciesIndex(firstSpec.c_str())+nsp*temp_thermo->speciesIndex(secondSpec.c_str());
574  trParam.mobilityRatio[index] = newLTI(propSpecNode,
575  m_tranPropMap[nodeName],
576  trParam);
577  };
578  };
579  break;
580  case TP_SELFDIFFUSION: {
581  for (size_t iSpec = 0; iSpec< nsp; iSpec++) {
582  XML_Node& propSpecNode = compDepNode.child(iSpec);
583  string specName = propSpecNode.name();
584  size_t index = temp_thermo->speciesIndex(specName.c_str());
585  trParam.selfDiffusion[index] = newLTI(propSpecNode,
586  m_tranPropMap[nodeName],
587  trParam);
588  };
589  };
590  break;
591  case TP_THERMALCOND:
592  trParam.thermalCond = newLTI(compDepNode,
593  m_tranPropMap[nodeName],
594  trParam);
595  break;
596  case TP_DIFFUSIVITY:
597  trParam.speciesDiffusivity = newLTI(compDepNode,
598  m_tranPropMap[nodeName],
599  trParam);
600  break;
601  case TP_HYDRORADIUS:
602  trParam.hydroRadius = newLTI(compDepNode,
603  m_tranPropMap[nodeName],
604  trParam);
605  break;
606  case TP_ELECTCOND:
607  trParam.electCond = newLTI(compDepNode,
608  m_tranPropMap[nodeName],
609  trParam);
610  break;
611  default:
612  throw CanteraError("getLiquidInteractionsTransportData","unknown transport property: " + nodeName);
613 
614  }
615  }
616  /* Allow a switch between mass-averaged, mole-averaged
617  * and solvent specified reference velocities.
618  * XML code within the transportProperty node
619  * (i.e. within <viscosity>) should read as follows
620  * <velocityBasis basis="mass"> <!-- mass averaged -->
621  * <velocityBasis basis="mole"> <!-- mole averaged -->
622  * <velocityBasis basis="H2O"> <!-- H2O solvent -->
623  */
624  if (tranTypeNode.hasChild("velocityBasis")) {
625  std::string velocityBasis =
626  tranTypeNode.child("velocityBasis").attrib("basis");
627  if (velocityBasis == "mass") {
628  trParam.velocityBasis_ = VB_MASSAVG;
629  } else if (velocityBasis == "mole") {
630  trParam.velocityBasis_ = VB_MOLEAVG;
631  } else if (trParam.thermo->speciesIndex(velocityBasis) > 0) {
632  trParam.velocityBasis_ = static_cast<int>(trParam.thermo->speciesIndex(velocityBasis));
633  } else {
634  int linenum = __LINE__;
635  throw TransportDBError(linenum, "Unknown attribute \"" + velocityBasis + "\" for <velocityBasis> node. ");
636  }
637  }
638  }
639  }
640  } catch (CanteraError& err) {
641  std::cout << err.what() << std::endl;
642  }
643  return;
644 }
645 
646 void TransportFactory::getSolidTransportData(const XML_Node& transportNode,
647  XML_Node& log,
648  const std::string phaseName,
649  SolidTransportData& trParam)
650 {
651  try {
652 
653  size_t num = transportNode.nChildren();
654  for (size_t iChild = 0; iChild < num; iChild++) {
655  //tranTypeNode is a type of transport property like viscosity
656  XML_Node& tranTypeNode = transportNode.child(iChild);
657  std::string nodeName = tranTypeNode.name();
658 
659  ThermoPhase* temp_thermo = trParam.thermo;
660 
661  //tranTypeNode contains the interaction model
662  switch (m_tranPropMap[nodeName]) {
663  case TP_IONCONDUCTIVITY:
664  trParam.ionConductivity = newLTP(tranTypeNode, phaseName,
665  m_tranPropMap[nodeName],
666  temp_thermo);
667  break;
668  case TP_THERMALCOND:
669  trParam.thermalConductivity = newLTP(tranTypeNode, phaseName,
670  m_tranPropMap[nodeName],
671  temp_thermo);
672  break;
673  case TP_DEFECTDIFF:
674  trParam.defectDiffusivity = newLTP(tranTypeNode, phaseName,
675  m_tranPropMap[nodeName],
676  temp_thermo);
677  break;
678  case TP_DEFECTCONC:
679  trParam.defectActivity = newLTP(tranTypeNode, phaseName,
680  m_tranPropMap[nodeName],
681  temp_thermo);
682  break;
683  case TP_ELECTCOND:
684  trParam.electConductivity = newLTP(tranTypeNode, phaseName,
685  m_tranPropMap[nodeName],
686  temp_thermo);
687  break;
688  default:
689  throw CanteraError("getSolidTransportData","unknown transport property: " + nodeName);
690 
691  }
692  }
693  } catch (CanteraError) {
694  showErrors(std::cout);
695  }
696  return;
697 }
698 
699 
700 Transport* newTransportMgr(const std::string& transportModel, thermo_t* thermo, int loglevel, TransportFactory* f, int ndim)
701 {
702  if (f == 0) {
703  f = TransportFactory::factory();
704  }
705  return f->newTransport(transportModel, thermo, loglevel, ndim);
706 }
707 
709 {
710  if (f == 0) {
711  f = TransportFactory::factory();
712  }
713  return f->newTransport(thermo, loglevel);
714 }
715 }
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 ...
Definition: LTPspecies.h:31
void restoreState(const vector_fp &state)
Restore a state saved on a previous call to saveState.
Definition: Phase.cpp:314
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.
Definition: xml.cpp:527
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.
Definition: global.cpp:136
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.
Definition: xml.h:100
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.
Definition: global.cpp:78
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...
Definition: LTPspecies.h:271
std::string lowercase(const std::string &s)
Cast a copy of a string to lower case.
Definition: stringUtils.cpp:73
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.
Definition: Phase.cpp:157
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.
Definition: xml.cpp:573
Header file defining class TransportFactory (see TransportFactory)
Class SolidTransport implements transport properties for solids.
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:97
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.
Definition: Phase.cpp:257
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.
Definition: DenseMatrix.cpp:64
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.
Definition: ThermoPhase.h:207
std::string name() const
Returns the name of the XML node.
Definition: xml.h:394
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.
Definition: ctexceptions.h:99
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.
Definition: xml.cpp:563
LiquidTranMixingModel compositionDepTypeDefault_
Default composition dependence of the transport properties.
Class LTPspecies_Const holds transport parameters for a specific liquid-phase species (LTPspecies) wh...
Definition: LTPspecies.h:195
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.
Definition: LTPspecies.h:72
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.
Definition: Phase.h:265
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.
Definition: Phase.cpp:278
const vector_fp & molecularWeights() const
Return a const reference to the internal vector of molecular weights.
Definition: Phase.cpp:515
const VelocityBasis VB_MOLEAVG
Diffusion velocities are based on the mole averaged velocities.
Definition: TransportBase.h:88
LTPspecies * electCond
Model type for the electrical conductivity.
Class LTPspecies_ExpT holds transport parameters for a specific liquid- phase species (LTPspecies) wh...
Definition: LTPspecies.h:455
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.
Definition: ct_defs.h:157
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.
Definition: Phase.cpp:123
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...
Definition: Phase.cpp:302
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.
Definition: TransportBase.h:86
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...
Definition: MixTransport.h:54
LTPspecies * ionConductivity
Model type for the ionic conductivity.
Class LTPspecies_Poly holds transport parameters for a specific liquid-phase species (LTPspecies) whe...
Definition: LTPspecies.h:373
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.
Definition: xml.cpp:583
virtual doublereal minTemp(size_t k=npos) const
Minimum temperature for which the thermodynamic data for the species or phase are valid...
Definition: ThermoPhase.h:166
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.