Cantera  2.1.2
SimpleTransport.cpp
Go to the documentation of this file.
1 /**
2  * @file SimpleTransport.cpp
3  * Simple mostly constant transport properties
4  */
7 
13 
14 using namespace std;
15 
16 namespace Cantera
17 {
18 SimpleTransport::SimpleTransport(thermo_t* thermo, int ndim) :
19  Transport(thermo, ndim),
20  tempDepType_(0),
21  compositionDepType_(0),
22  useHydroRadius_(false),
23  doMigration_(0),
24  concTot_(0.0),
25  m_temp(-1.0),
26  m_press(-1.0),
27  m_lambda(-1.0),
28  m_viscmix(-1.0),
29  m_visc_mix_ok(false),
30  m_visc_temp_ok(false),
31  m_diff_mix_ok(false),
32  m_diff_temp_ok(false),
33  m_cond_temp_ok(false),
34  m_cond_mix_ok(false),
35  m_nDim(1)
36 {
37 }
38 
40  Transport(),
41  tempDepType_(0),
42  compositionDepType_(0),
43  useHydroRadius_(false),
44  doMigration_(0),
45  m_iStateMF(-1),
46  m_temp(-1.0),
47  m_press(-1.0),
48  m_lambda(-1.0),
49  m_viscmix(-1.0),
50  m_visc_mix_ok(false),
51  m_visc_temp_ok(false),
52  m_diff_mix_ok(false),
53  m_diff_temp_ok(false),
54  m_cond_temp_ok(false),
55  m_cond_mix_ok(false),
56  m_nDim(1)
57 {
58  /*
59  * Use the assignment operator to do the brunt
60  * of the work for the copy constructor.
61  */
62  *this = right;
63 }
64 
65 SimpleTransport& SimpleTransport::operator=(const SimpleTransport& right)
66 {
67  if (&right == this) {
68  return *this;
69  }
70  Transport::operator=(right);
71 
72  tempDepType_ = right.tempDepType_;
73  compositionDepType_ = right.compositionDepType_;
74  useHydroRadius_ = right.useHydroRadius_;
75  doMigration_ = right.doMigration_;
76  m_mw = right.m_mw;
77 
78  m_coeffVisc_Ns = right.m_coeffVisc_Ns;
79  for (size_t k = 0; k <right.m_coeffVisc_Ns.size() ; k++) {
80  if (right.m_coeffVisc_Ns[k]) {
81  m_coeffVisc_Ns[k] = (right.m_coeffVisc_Ns[k])->duplMyselfAsLTPspecies();
82  }
83  }
84 
85  m_coeffLambda_Ns = right.m_coeffLambda_Ns;
86  for (size_t k = 0; k < right.m_coeffLambda_Ns.size(); k++) {
87  if (right.m_coeffLambda_Ns[k]) {
88  m_coeffLambda_Ns[k] = (right.m_coeffLambda_Ns[k])->duplMyselfAsLTPspecies();
89  }
90  }
91 
92  m_coeffDiff_Ns = right.m_coeffDiff_Ns;
93  for (size_t k = 0; k < right.m_coeffDiff_Ns.size(); k++) {
94  if (right.m_coeffDiff_Ns[k]) {
95  m_coeffDiff_Ns[k] = (right.m_coeffDiff_Ns[k])->duplMyselfAsLTPspecies();
96  }
97  }
98 
99  m_coeffHydroRadius_Ns = right.m_coeffHydroRadius_Ns;
100  for (size_t k = 0; k < right.m_coeffHydroRadius_Ns.size(); k++) {
101  if (right.m_coeffHydroRadius_Ns[k]) {
102  m_coeffHydroRadius_Ns[k] = (right.m_coeffHydroRadius_Ns[k])->duplMyselfAsLTPspecies();
103  }
104  }
105 
106  m_Grad_X = right.m_Grad_X;
107  m_Grad_T = right.m_Grad_T;
108  m_Grad_P = right.m_Grad_P;
109  m_Grad_V = right.m_Grad_V;
110 
111  m_diffSpecies = right.m_diffSpecies;
112  m_viscSpecies = right.m_viscSpecies;
113  m_condSpecies = right.m_condSpecies;
114  m_iStateMF = -1;
115  m_molefracs = right.m_molefracs;
116  m_concentrations = right.m_concentrations;
117  concTot_ = right.concTot_;
118  meanMolecularWeight_ = right.meanMolecularWeight_;
119  dens_ = right.dens_;
120  m_chargeSpecies = right.m_chargeSpecies;
121 
122  m_temp = right.m_temp;
123  m_press = right.m_press;
124  m_lambda = right.m_lambda;
125  m_viscmix = right.m_viscmix;
126  m_spwork = right.m_spwork;
127  m_visc_mix_ok = false;
128  m_visc_temp_ok = false;
129  m_diff_mix_ok = false;
130  m_diff_temp_ok = false;
131  m_cond_temp_ok = false;
132  m_cond_mix_ok = false;
133  m_nDim = right.m_nDim;
134 
135  return *this;
136 }
137 
139 {
140  return new SimpleTransport(*this);
141 }
142 
143 SimpleTransport::~SimpleTransport()
144 {
145  for (size_t k = 0; k < m_coeffVisc_Ns.size() ; k++) {
146  delete m_coeffVisc_Ns[k];
147  }
148  for (size_t k = 0; k < m_coeffLambda_Ns.size(); k++) {
149  delete m_coeffLambda_Ns[k];
150  }
151  for (size_t k = 0; k < m_coeffDiff_Ns.size(); k++) {
152  delete m_coeffDiff_Ns[k];
153  }
154  for (size_t k = 0; k < m_coeffHydroRadius_Ns.size(); k++) {
155  delete m_coeffHydroRadius_Ns[k];
156  }
157 }
158 
160 {
161  // constant substance attributes
162  m_thermo = tr.thermo;
163  m_nsp = m_thermo->nSpecies();
164 
165  /*
166  * Read the transport block in the phase XML Node
167  * It's not an error if this block doesn't exist. Just use the defaults
168  */
169  XML_Node& phaseNode = m_thermo->xml();
170  if (phaseNode.hasChild("transport")) {
171  XML_Node& transportNode = phaseNode.child("transport");
172  string transportModel = transportNode.attrib("model");
173  if (transportModel == "Simple") {
174  /*
175  * <compositionDependence model="Solvent_Only"/>
176  * or
177  * <compositionDependence model="Mixture_Averaged"/>
178  */
179  std::string modelName = "";
180  if (ctml::getOptionalModel(transportNode, "compositionDependence",
181  modelName)) {
182  modelName = lowercase(modelName);
183  if (modelName == "solvent_only") {
185  } else if (modelName == "mixture_averaged") {
187  } else {
188  throw CanteraError("SimpleTransport::initLiquid", "Unknown compositionDependence Model: " + modelName);
189  }
190  }
191  }
192  }
193 
194  // make a local copy of the molecular weights
195  m_mw.resize(m_nsp);
196  copy(m_thermo->molecularWeights().begin(),
197  m_thermo->molecularWeights().end(), m_mw.begin());
198 
199  /*
200  * Get the input Viscosities
201  */
202  m_viscSpecies.resize(m_nsp);
203  m_coeffVisc_Ns.clear();
204  m_coeffVisc_Ns.resize(m_nsp);
205 
206  //Cantera::LiquidTransportData &ltd0 = tr.LTData[0];
207  std::string spName = m_thermo->speciesName(0);
208  /*
209  LiquidTR_Model vm0 = ltd0.model_viscosity;
210  std::string spName0 = m_thermo->speciesName(0);
211  if (vm0 == LTR_MODEL_CONSTANT) {
212  tempDepType_ = 0;
213  } else if (vm0 == LTR_MODEL_ARRHENIUS) {
214  tempDepType_ = 1;
215  } else if (vm0 == LTR_MODEL_NOTSET) {
216  throw CanteraError("SimpleTransport::initLiquid",
217  "Viscosity Model is not set for species " + spName0 + " in the input file");
218  } else {
219  throw CanteraError("SimpleTransport::initLiquid",
220  "Viscosity Model for species " + spName0 + " is not handled by this object");
221  }
222  */
223 
224  for (size_t k = 0; k < m_nsp; k++) {
225  spName = m_thermo->speciesName(k);
227  //LiquidTR_Model vm = ltd.model_viscosity;
228  //vector_fp &kentry = m_coeffVisc_Ns[k];
229  /*
230  if (vm != vm0) {
231  if (compositionDepType_ != 0) {
232  throw CanteraError(" SimpleTransport::initLiquid",
233  "different viscosity models for species " + spName + " and " + spName0 );
234  } else {
235  kentry = m_coeffVisc_Ns[0];
236  }
237  }
238  */
239  m_coeffVisc_Ns[k] = ltd.viscosity;
240  ltd.viscosity = 0;
241  }
242 
243  /*
244  * Get the input thermal conductivities
245  */
246  m_condSpecies.resize(m_nsp);
247  m_coeffLambda_Ns.clear();
248  m_coeffLambda_Ns.resize(m_nsp);
249  //LiquidTR_Model cm0 = ltd0.model_thermalCond;
250  //if (cm0 != vm0) {
251  // throw CanteraError("SimpleTransport::initLiquid",
252  // "Conductivity model is not the same as the viscosity model for species " + spName0);
253  // }
254 
255  for (size_t k = 0; k < m_nsp; k++) {
256  spName = m_thermo->speciesName(k);
258  //LiquidTR_Model cm = ltd.model_thermalCond;
259  //vector_fp &kentry = m_coeffLambda_Ns[k];
260  /*
261  if (cm != cm0) {
262  if (compositionDepType_ != 0) {
263  throw CanteraError(" SimpleTransport::initLiquid",
264  "different thermal conductivity models for species " + spName + " and " + spName0);
265  } else {
266  kentry = m_coeffLambda_Ns[0];
267  }
268  }
269  */
270  m_coeffLambda_Ns[k] = ltd.thermalCond;
271  ltd.thermalCond = 0;
272  }
273 
274  /*
275  * Get the input species diffusivities
276  */
277  useHydroRadius_ = false;
278 
279  m_diffSpecies.resize(m_nsp);
280  m_coeffDiff_Ns.clear();
281  m_coeffDiff_Ns.resize(m_nsp);
282  //LiquidTR_Model dm0 = ltd0.model_speciesDiffusivity;
283  /*
284  if (dm0 != vm0) {
285  if (dm0 == LTR_MODEL_NOTSET) {
286  LiquidTR_Model rm0 = ltd0.model_hydroradius;
287  if (rm0 != vm0) {
288  throw CanteraError("SimpleTransport::initLiquid",
289  "hydroradius model is not the same as the viscosity model for species " + spName0);
290  } else {
291  useHydroRadius_ = true;
292  }
293  }
294  }
295  */
296 
297  for (size_t k = 0; k < m_nsp; k++) {
298  spName = m_thermo->speciesName(k);
300  /*
301  LiquidTR_Model dm = ltd.model_speciesDiffusivity;
302  if (dm == LTR_MODEL_NOTSET) {
303  LiquidTR_Model rm = ltd.model_hydroradius;
304  if (rm == LTR_MODEL_NOTSET) {
305  throw CanteraError("SimpleTransport::initLiquid",
306  "Neither diffusivity nor hydroradius is set for species " + spName);
307  }
308  if (rm != vm0) {
309  throw CanteraError("SimpleTransport::initLiquid",
310  "hydroradius model is not the same as the viscosity model for species " + spName);
311  }
312  if (rm != LTR_MODEL_CONSTANT) {
313  throw CanteraError("SimpleTransport::initLiquid",
314  "hydroradius model is not constant for species " + spName0);
315  }
316  vector_fp &kentry = m_coeffHydroRadius_Ns[k];
317  kentry = ltd.hydroradius;
318  } else {
319  if (dm != dm0) {
320  throw CanteraError(" SimpleTransport::initLiquid",
321  "different diffusivity models for species " + spName + " and " + spName0 );
322  }
323  vector_fp &kentry = m_coeffDiff_Ns[k];
324  kentry = ltd.speciesDiffusivity;
325  }
326  */
327 
329  ltd.speciesDiffusivity = 0;
330 
331  if (!(m_coeffDiff_Ns[k])) {
332  if (ltd.hydroRadius) {
333  m_coeffHydroRadius_Ns[k] = (ltd.hydroRadius)->duplMyselfAsLTPspecies();
334  }
335  if (!(m_coeffHydroRadius_Ns[k])) {
336  throw CanteraError("SimpleTransport::initLiquid",
337  "Neither diffusivity nor hydroradius is set for species " + spName);
338  }
339  }
340  }
341 
342  m_molefracs.resize(m_nsp);
343  m_concentrations.resize(m_nsp);
344 
345  m_chargeSpecies.resize(m_nsp);
346  for (size_t k = 0; k < m_nsp; k++) {
348  }
349  m_spwork.resize(m_nsp);
350 
351  // resize the internal gradient variables
352  m_Grad_X.resize(m_nDim * m_nsp, 0.0);
353  m_Grad_T.resize(m_nDim, 0.0);
354  m_Grad_P.resize(m_nDim, 0.0);
355  m_Grad_V.resize(m_nDim, 0.0);
356 
357  // set all flags to false
358  m_visc_mix_ok = false;
359  m_visc_temp_ok = false;
360 
361  m_cond_temp_ok = false;
362  m_cond_mix_ok = false;
363 
364  m_diff_temp_ok = false;
365  m_diff_mix_ok = false;
366 
367  return true;
368 }
369 
371 {
372  update_T();
373  update_C();
374 
375  if (m_visc_mix_ok) {
376  return m_viscmix;
377  }
378 
379  // update m_viscSpecies[] if necessary
380  if (!m_visc_temp_ok) {
382  }
383 
384  if (compositionDepType_ == 0) {
386  } else if (compositionDepType_ == 1) {
387  m_viscmix = 0.0;
388  for (size_t k = 0; k < m_nsp; k++) {
390  }
391  }
392  m_visc_mix_ok = true;
393  return m_viscmix;
394 }
395 
396 void SimpleTransport::getSpeciesViscosities(doublereal* const visc)
397 {
398  update_T();
399  if (!m_visc_temp_ok) {
401  }
402  copy(m_viscSpecies.begin(), m_viscSpecies.end(), visc);
403 }
404 
405 void SimpleTransport::getBinaryDiffCoeffs(size_t ld, doublereal* d)
406 {
407  double bdiff;
408  update_T();
409 
410  // if necessary, evaluate the species diffusion coefficients
411  // from the polynomial fits
412  if (!m_diff_temp_ok) {
413  updateDiff_T();
414  }
415 
416  for (size_t i = 0; i < m_nsp; i++) {
417  for (size_t j = 0; j < m_nsp; j++) {
418  bdiff = 0.5 * (m_diffSpecies[i] + m_diffSpecies[j]);
419  d[i*m_nsp+j] = bdiff;
420  }
421  }
422 }
423 
424 void SimpleTransport::getMobilities(doublereal* const mobil)
425 {
427  doublereal c1 = ElectronCharge / (Boltzmann * m_temp);
428  for (size_t k = 0; k < m_nsp; k++) {
429  mobil[k] = c1 * m_spwork[k];
430  }
431 }
432 
433 void SimpleTransport::getFluidMobilities(doublereal* const mobil_f)
434 {
436  doublereal c1 = 1.0 / (GasConstant * m_temp);
437  for (size_t k = 0; k < m_nsp; k++) {
438  mobil_f[k] = c1 * m_spwork[k];
439  }
440 }
441 
442 void SimpleTransport::set_Grad_V(const doublereal* const grad_V)
443 {
444  doMigration_ = false;
445  for (size_t a = 0; a < m_nDim; a++) {
446  m_Grad_V[a] = grad_V[a];
447  if (fabs(grad_V[a]) > 1.0E-13) {
448  doMigration_ = true;
449  }
450  }
451 }
452 
453 void SimpleTransport::set_Grad_T(const doublereal* const grad_T)
454 {
455  for (size_t a = 0; a < m_nDim; a++) {
456  m_Grad_T[a] = grad_T[a];
457  }
458 }
459 
460 void SimpleTransport::set_Grad_X(const doublereal* const grad_X)
461 {
462  size_t itop = m_nDim * m_nsp;
463  for (size_t i = 0; i < itop; i++) {
464  m_Grad_X[i] = grad_X[i];
465  }
466 }
467 
469 {
470  update_T();
471  update_C();
472  if (!m_cond_temp_ok) {
473  updateCond_T();
474  }
475  if (!m_cond_mix_ok) {
476  if (compositionDepType_ == 0) {
477  m_lambda = m_condSpecies[0];
478  } else if (compositionDepType_ == 1) {
479  m_lambda = 0.0;
480  for (size_t k = 0; k < m_nsp; k++) {
482  }
483  }
484  m_cond_mix_ok = true;
485  }
486  return m_lambda;
487 }
488 
489 void SimpleTransport::getThermalDiffCoeffs(doublereal* const dt)
490 {
491  for (size_t k = 0; k < m_nsp; k++) {
492  dt[k] = 0.0;
493  }
494 }
495 
497  const doublereal* grad_T,
498  int ldx,
499  const doublereal* grad_X,
500  int ldf,
501  doublereal* Vdiff)
502 {
503  set_Grad_T(grad_T);
504  set_Grad_X(grad_X);
505  const doublereal* y = m_thermo->massFractions();
506  const doublereal rho = m_thermo->density();
507 
509 
510  for (size_t n = 0; n < m_nDim; n++) {
511  for (size_t k = 0; k < m_nsp; k++) {
512  if (y[k] > 1.0E-200) {
513  Vdiff[n * m_nsp + k] *= 1.0 / (rho * y[k]);
514  } else {
515  Vdiff[n * m_nsp + k] = 0.0;
516  }
517  }
518  }
519 }
520 
521 void SimpleTransport::getSpeciesVdiffES(size_t ndim, const doublereal* grad_T,
522  int ldx, const doublereal* grad_X,
523  int ldf, const doublereal* grad_Phi,
524  doublereal* Vdiff)
525 {
526  set_Grad_T(grad_T);
527  set_Grad_X(grad_X);
528  set_Grad_V(grad_Phi);
529  const doublereal* y = m_thermo->massFractions();
530  const doublereal rho = m_thermo->density();
531 
533 
534  for (size_t n = 0; n < m_nDim; n++) {
535  for (size_t k = 0; k < m_nsp; k++) {
536  if (y[k] > 1.0E-200) {
537  Vdiff[n * m_nsp + k] *= 1.0 / (rho * y[k]);
538  } else {
539  Vdiff[n * m_nsp + k] = 0.0;
540  }
541  }
542  }
543 }
544 
545 void SimpleTransport::getSpeciesFluxes(size_t ndim, const doublereal* const grad_T,
546  size_t ldx, const doublereal* const grad_X,
547  size_t ldf, doublereal* const fluxes)
548 {
549  set_Grad_T(grad_T);
550  set_Grad_X(grad_X);
551  getSpeciesFluxesExt(ldf, fluxes);
552 }
553 
554 void SimpleTransport::getSpeciesFluxesExt(size_t ldf, doublereal* fluxes)
555 {
556  AssertThrow(ldf >= m_nsp ,"SimpleTransport::getSpeciesFluxesExt: Stride must be greater than m_nsp");
557  update_T();
558  update_C();
559 
561 
562  const vector_fp& mw = m_thermo->molecularWeights();
563  const doublereal* y = m_thermo->massFractions();
564 
565  doublereal concTotal = m_thermo->molarDensity();
566 
567  // Unroll wrt ndim
568 
569 
570  if (doMigration_) {
571  double FRT = ElectronCharge / (Boltzmann * m_temp);
572  for (size_t n = 0; n < m_nDim; n++) {
573  rhoVc[n] = 0.0;
574  for (size_t k = 0; k < m_nsp; k++) {
575  fluxes[n*ldf + k] = - concTotal * mw[k] * m_spwork[k] *
576  (m_Grad_X[n*m_nsp + k] + FRT * m_molefracs[k] * m_chargeSpecies[k] * m_Grad_V[n]);
577  rhoVc[n] += fluxes[n*ldf + k];
578  }
579  }
580  } else {
581  for (size_t n = 0; n < m_nDim; n++) {
582  rhoVc[n] = 0.0;
583  for (size_t k = 0; k < m_nsp; k++) {
584  fluxes[n*ldf + k] = - concTotal * mw[k] * m_spwork[k] * m_Grad_X[n*m_nsp + k];
585  rhoVc[n] += fluxes[n*ldf + k];
586  }
587  }
588  }
589 
590  if (m_velocityBasis == VB_MASSAVG) {
591  for (size_t n = 0; n < m_nDim; n++) {
592  rhoVc[n] = 0.0;
593  for (size_t k = 0; k < m_nsp; k++) {
594  rhoVc[n] += fluxes[n*ldf + k];
595  }
596  }
597  for (size_t n = 0; n < m_nDim; n++) {
598  for (size_t k = 0; k < m_nsp; k++) {
599  fluxes[n*ldf + k] -= y[k] * rhoVc[n];
600  }
601  }
602  } else if (m_velocityBasis == VB_MOLEAVG) {
603  for (size_t n = 0; n < m_nDim; n++) {
604  rhoVc[n] = 0.0;
605  for (size_t k = 0; k < m_nsp; k++) {
606  rhoVc[n] += fluxes[n*ldf + k] / mw[k];
607  }
608  }
609  for (size_t n = 0; n < m_nDim; n++) {
610  for (size_t k = 0; k < m_nsp; k++) {
611  fluxes[n*ldf + k] -= m_molefracs[k] * rhoVc[n] * mw[k];
612  }
613  }
614  } else if (m_velocityBasis >= 0) {
615  for (size_t n = 0; n < m_nDim; n++) {
616  rhoVc[n] = - fluxes[n*ldf + m_velocityBasis] / mw[m_velocityBasis];
617  for (size_t k = 0; k < m_nsp; k++) {
618  rhoVc[n] += fluxes[n*ldf + k] / mw[k];
619  }
620  }
621  for (size_t n = 0; n < m_nDim; n++) {
622  for (size_t k = 0; k < m_nsp; k++) {
623  fluxes[n*ldf + k] -= m_molefracs[k] * rhoVc[n] * mw[k];
624  }
625  fluxes[n*ldf + m_velocityBasis] = 0.0;
626  }
627 
628  } else {
629  throw CanteraError("SimpleTransport::getSpeciesFluxesExt()",
630  "unknown velocity basis");
631  }
632 }
633 
634 void SimpleTransport::getMixDiffCoeffs(doublereal* const d)
635 {
636  update_T();
637  update_C();
638  // update the binary diffusion coefficients if necessary
639  if (!m_diff_temp_ok) {
640  updateDiff_T();
641  }
642  for (size_t k = 0; k < m_nsp; k++) {
643  d[k] = m_diffSpecies[k];
644  }
645 }
646 
648 {
649  // If the pressure has changed then the concentrations
650  // have changed.
651  doublereal pres = m_thermo->pressure();
652  bool qReturn = true;
653  if (pres != m_press) {
654  qReturn = false;
655  m_press = pres;
656  }
657  int iStateNew = m_thermo->stateMFNumber();
658  if (iStateNew != m_iStateMF) {
659  qReturn = false;
662  concTot_ = 0.0;
663  for (size_t k = 0; k < m_nsp; k++) {
664  m_molefracs[k] = std::max(0.0, m_molefracs[k]);
666  }
667  dens_ = m_thermo->density();
669  }
670  if (qReturn) {
671  return false;
672  }
673 
674 
675  // Mixture stuff needs to be evaluated
676  m_visc_mix_ok = false;
677  m_diff_mix_ok = false;
678  m_cond_mix_ok = false;
679 
680  return true;
681 }
682 
684 {
685  if (compositionDepType_ == 0) {
686  m_condSpecies[0] = m_coeffLambda_Ns[0]->getSpeciesTransProp();
687  } else {
688  for (size_t k = 0; k < m_nsp; k++) {
689  m_condSpecies[k] = m_coeffLambda_Ns[k]->getSpeciesTransProp();
690  }
691  }
692  m_cond_temp_ok = true;
693  m_cond_mix_ok = false;
694 }
695 
697 {
698  if (useHydroRadius_) {
699  double visc = viscosity();
700  double RT = GasConstant * m_temp;
701  for (size_t k = 0; k < m_nsp; k++) {
702  double rad = m_coeffHydroRadius_Ns[k]->getSpeciesTransProp() ;
703  m_diffSpecies[k] = RT / (6.0 * Pi * visc * rad);
704  }
705  } else {
706  for (size_t k = 0; k < m_nsp; k++) {
707  m_diffSpecies[k] = m_coeffDiff_Ns[k]->getSpeciesTransProp();
708  }
709  }
710  m_diff_temp_ok = true;
711  m_diff_mix_ok = false;
712 }
713 
715 {
716 }
717 
719 {
720  if (compositionDepType_ == 0) {
721  m_viscSpecies[0] = m_coeffVisc_Ns[0]->getSpeciesTransProp();
722  } else {
723  for (size_t k = 0; k < m_nsp; k++) {
724  m_viscSpecies[k] = m_coeffVisc_Ns[k]->getSpeciesTransProp();
725  }
726  }
727  m_visc_temp_ok = true;
728  m_visc_mix_ok = false;
729 }
730 
732 {
733  doublereal t = m_thermo->temperature();
734  if (t == m_temp) {
735  return false;
736  }
737  if (t < 0.0) {
738  throw CanteraError("SimpleTransport::update_T",
739  "negative temperature "+fp2str(t));
740  }
741 
742  // Compute various functions of temperature
743  m_temp = t;
744 
745  // temperature has changed, so polynomial temperature
746  // interpolations will need to be reevaluated.
747  // Set all of these flags to false
748  m_visc_mix_ok = false;
749  m_visc_temp_ok = false;
750 
751  m_cond_temp_ok = false;
752  m_cond_mix_ok = false;
753 
754  m_diff_mix_ok = false;
755  m_diff_temp_ok = false;
756 
757  return true;
758 }
759 
760 doublereal SimpleTransport::err(const std::string& msg) const
761 {
762  throw CanteraError("SimpleTransport Class",
763  "\n\n\n**** Method "+ msg +" not implemented in model "
764  + int2str(model()) + " ****\n"
765  "(Did you forget to specify a transport model?)\n\n\n");
766 
767  return 0.0;
768 }
769 
770 }
bool m_visc_temp_ok
Boolean indicating that weight factors wrt viscosity is current.
vector_fp m_Grad_T
Internal value of the gradient of the Temperature vector.
vector_fp m_Grad_V
Internal value of the gradient of the Electric Voltage.
vector_fp m_Grad_P
Internal value of the gradient of the Pressure vector.
virtual doublereal density() const
Density (kg/m^3).
Definition: Phase.h:534
std::string int2str(const int n, const std::string &fmt)
Convert an int to a string using a format converter.
Definition: stringUtils.cpp:40
virtual int model() const
Transport model.
virtual bool initLiquid(LiquidTransportParams &tr)
Initialize the transport object.
vector_fp m_spwork
work space
bool m_visc_mix_ok
Boolean indicating that the top-level mixture viscosity is current.
thermo_t * thermo
Pointer to the ThermoPhase object.
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
Definition: xml.cpp:534
virtual void getBinaryDiffCoeffs(const size_t ld, doublereal *const d)
Returns the binary diffusion coefficients.
Various templated functions that carry out common vector operations (see Templated Utility Functions)...
LTPspecies * thermalCond
Model type for the thermal conductivity.
virtual void getSpeciesFluxes(size_t ndim, const doublereal *const grad_T, size_t ldx, const doublereal *const grad_X, size_t ldf, doublereal *const fluxes)
Get the species diffusive mass fluxes wrt to the specified solution averaged velocity, given the gradients in mole fraction and temperature.
doublereal m_viscmix
Saved value of the mixture viscosity.
bool getOptionalModel(const Cantera::XML_Node &parent, const std::string &nodeName, std::string &modelName)
Get an optional model name from a named child node.
Definition: ctml.cpp:376
double rhoVc[3]
Temporary variable that stores the rho Vc value.
thermo_t * m_thermo
pointer to the object representing the phase
virtual bool update_T()
Handles the effects of changes in the Temperature, internally within the object.
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
void updateViscosities_C()
Update the concentration parts of the viscosities.
bool m_cond_mix_ok
Boolean indicating that mixture conductivity is current.
Base class for transport property managers.
void updateDiff_T()
Update the binary diffusion coefficients wrt T.
Class LiquidTransportData holds transport parameters for a specific liquid-phase species.
int stateMFNumber() const
Return the State Mole Fraction Number.
Definition: Phase.h:697
virtual void getMobilities(doublereal *const mobil_e)
Get the Electrical mobilities (m^2/V/s).
virtual bool update_C()
Handles the effects of changes in the mixture concentration.
const doublereal Pi
Pi.
Definition: ct_defs.h:51
doublereal molarDensity() const
Molar density (kmol/m^3).
Definition: Phase.cpp:597
std::string lowercase(const std::string &s)
Cast a copy of a string to lower case.
Definition: stringUtils.cpp:58
void getMoleFractions(doublereal *const x) const
Get the species mole fraction vector.
Definition: Phase.cpp:519
doublereal m_lambda
Saved value of the mixture thermal conductivity.
vector_fp m_Grad_X
Internal value of the gradient of the mole fraction vector.
void getConcentrations(doublereal *const c) const
Get the species concentrations (kmol/m^3).
Definition: Phase.cpp:572
LTPspecies * speciesDiffusivity
Model type for the speciesDiffusivity.
void updateCond_T()
Update the temperature-dependent parts of the mixture-averaged thermal conductivity.
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
Definition: xml.cpp:584
Header file defining class TransportFactory (see TransportFactory)
int m_iStateMF
State of the mole fraction vector.
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:101
Class LiquidTransportParams holds transport model parameters relevant to transport in mixtures...
Header file defining class LiquidTransportParams.
doublereal meanMolecularWeight_
Mean molecular weight.
bool m_diff_temp_ok
Boolean indicating that binary diffusion coeffs are current.
virtual void getFluidMobilities(doublereal *const mobil_f)
Get the fluid mobilities (s kmol/kg).
std::vector< LTPspecies * > m_coeffVisc_Ns
Pure species viscosities in Arrhenius temperature-dependent form.
std::string fp2str(const double x, const std::string &fmt)
Convert a double into a c++ string.
Definition: stringUtils.cpp:29
virtual void getMixDiffCoeffs(doublereal *const d)
Get the Mixture diffusion coefficients.
const doublereal * massFractions() const
Return a const pointer to the mass fraction array.
Definition: Phase.h:454
virtual void getSpeciesVdiffES(size_t ndim, const doublereal *grad_T, int ldx, const doublereal *grad_X, int ldf, const doublereal *grad_Phi, doublereal *Vdiff)
Get the species diffusive velocities wrt to the averaged velocity, given the gradients in mole fracti...
Header file for the class SimpleTransport which provides simple transport properties for liquids and ...
vector_fp m_diffSpecies
Vector of Species Diffusivities.
vector_fp m_viscSpecies
Species viscosities.
int tempDepType_
Temperature dependence type.
std::vector< LTPspecies * > m_coeffLambda_Ns
Pure species thermal conductivities in Arrhenius temperature-dependent form.
#define AssertThrow(expr, procedure)
Assertion must be true or an error is thrown.
Definition: ctexceptions.h:229
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:68
SimpleTransport(thermo_t *thermo=0, int ndim=1)
Default constructor.
doublereal m_press
Current value of the pressure.
std::vector< LTPspecies * > m_coeffHydroRadius_Ns
Hydrodynamic radius in LTPspecies form.
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
Definition: xml.cpp:574
virtual void set_Grad_X(const doublereal *const grad_X)
Specify the value of the gradient of the MoleFractions.
virtual void getSpeciesVdiff(size_t ndim, const doublereal *grad_T, int ldx, const doublereal *grad_X, int ldf, doublereal *Vdiff)
Get the species diffusive velocities wrt to the averaged velocity, given the gradients in mole fracti...
virtual doublereal thermalConductivity()
Returns the mixture thermal conductivity of the solution.
virtual void set_Grad_V(const doublereal *const grad_V)
Specify the value of the gradient of the voltage.
doublereal concTot_
Local copy of the total concentration.
doublereal err(const std::string &msg) const
Throw an exception if this method is invoked.
vector_fp m_concentrations
Local copy of the concentrations of the species in the phase.
void updateViscosity_T()
Update the temperature-dependent viscosity terms.
virtual void getThermalDiffCoeffs(doublereal *const dt)
Return the thermal diffusion coefficients.
doublereal dens_
Density.
std::vector< Cantera::LiquidTransportData > LTData
Species transport parameters.
size_t nSpecies() const
Returns the number of species in the phase.
Definition: Phase.h:252
virtual doublereal viscosity()
Returns the mixture viscosity of the solution.
virtual doublereal pressure() const
Return the thermodynamic pressure (Pa).
Definition: ThermoPhase.h:314
const vector_fp & molecularWeights() const
Return a const reference to the internal vector of molecular weights.
Definition: Phase.cpp:505
const VelocityBasis VB_MOLEAVG
Diffusion velocities are based on the mole averaged velocities.
Definition: TransportBase.h:93
doublereal temperature() const
Temperature (K).
Definition: Phase.h:528
doublereal m_temp
Current Temperature -> locally stored.
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:165
vector_fp m_condSpecies
Internal value of the species individual thermal conductivities.
bool doMigration_
Boolean indicating whether electro-migration term should be added.
bool useHydroRadius_
Boolean indicating whether to use the hydrodynamic radius formulation.
virtual void getSpeciesFluxesExt(size_t ldf, doublereal *fluxes)
Return the species diffusive mass fluxes wrt to the mass averaged velocity,.
doublereal meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
Definition: Phase.h:588
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
Definition: ct_defs.h:66
LTPspecies * hydroRadius
Model type for the hydroradius.
Contains declarations for string manipulation functions within Cantera.
virtual Transport * duplMyselfAsTransport() const
Duplication routine for objects which inherit from Transport.
int compositionDepType_
Composition dependence of the transport properties.
#define DATA_PTR(vec)
Creates a pointer to the start of the raw data for a vector.
Definition: ct_defs.h:36
LTPspecies * viscosity
Model type for the viscosity.
size_t m_nsp
Number of species.
XML_Node & xml()
Returns a reference to the XML_Node stored for the phase.
Definition: Phase.cpp:114
const VelocityBasis VB_MASSAVG
Diffusion velocities are based on the mass averaged velocity.
Definition: TransportBase.h:91
size_t m_nDim
Number of dimensions.
vector_fp m_chargeSpecies
Local copy of the charge of each species.
bool m_cond_temp_ok
Flag to indicate that the pure species conductivities are current wrt the temperature.
Header file for class ThermoPhase, the base class for phases with thermodynamic properties, and the text for the Module thermoprops (see Thermodynamic Properties and class ThermoPhase).
vector_fp m_molefracs
Local copy of the mole fractions of the species in the phase.
virtual void getSpeciesViscosities(doublereal *const visc)
Returns the pure species viscosities.
int m_velocityBasis
Velocity basis from which diffusion velocities are computed.
virtual void set_Grad_T(const doublereal *const grad_T)
Specify the value of the gradient of the temperature.
std::vector< LTPspecies * > m_coeffDiff_Ns
Pure species viscosities in Arrhenius temperature-dependent form.
std::string speciesName(size_t k) const
Name of the species with index k.
Definition: Phase.cpp:246
Class SimpleTransport implements mixture-averaged transport properties for liquid phases...
const doublereal Boltzmann
Boltzmann's constant [J/K].
Definition: ct_defs.h:78
doublereal charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...
Definition: Phase.h:504
bool m_diff_mix_ok
Boolean indicating that mixture diffusion coeffs are current.
vector_fp m_mw
Local Copy of the molecular weights of the species.