Cantera  2.1.2
LiquidTransport.cpp
Go to the documentation of this file.
1 /**
2  * @file LiquidTransport.cpp
3  * Mixture-averaged transport properties for ideal gas mixtures.
4  */
7 
13 
14 #include <cstdio>
15 
16 using namespace std;
17 
18 namespace Cantera
19 {
20 LiquidTransport::LiquidTransport(thermo_t* thermo, int ndim) :
21  Transport(thermo, ndim),
22  m_nsp2(0),
23  m_viscMixModel(0),
24  m_ionCondMixModel(0),
25  m_lambdaMixModel(0),
26  m_diffMixModel(0),
27  m_radiusMixModel(0),
28  m_iStateMF(-1),
29  concTot_(0.0),
30  concTot_tran_(0.0),
31  dens_(0.0),
32  m_temp(-1.0),
33  m_press(-1.0),
34  m_lambda(-1.0),
35  m_viscmix(-1.0),
36  m_ionCondmix(-1.0),
37  m_mobRatMix(0),
38  m_selfDiffMix(0),
39  m_visc_mix_ok(false),
40  m_visc_temp_ok(false),
41  m_visc_conc_ok(false),
42  m_ionCond_mix_ok(false),
43  m_ionCond_temp_ok(false),
44  m_ionCond_conc_ok(false),
45  m_mobRat_mix_ok(false),
46  m_mobRat_temp_ok(false),
47  m_mobRat_conc_ok(false),
48  m_selfDiff_mix_ok(false),
49  m_selfDiff_temp_ok(false),
50  m_selfDiff_conc_ok(false),
51  m_radi_mix_ok(false),
52  m_radi_temp_ok(false),
53  m_radi_conc_ok(false),
54  m_diff_mix_ok(false),
55  m_diff_temp_ok(false),
56  m_lambda_temp_ok(false),
57  m_lambda_mix_ok(false),
58  m_mode(-1000),
59  m_debug(false)
60 {
61 }
62 
64  Transport(right.m_thermo, right.m_nDim),
65  m_nsp2(0),
66  m_viscMixModel(0),
67  m_ionCondMixModel(0),
68  m_lambdaMixModel(0),
69  m_diffMixModel(0),
70  m_radiusMixModel(0),
71  m_iStateMF(-1),
72  concTot_(0.0),
73  concTot_tran_(0.0),
74  dens_(0.0),
75  m_temp(-1.0),
76  m_press(-1.0),
77  m_lambda(-1.0),
78  m_viscmix(-1.0),
79  m_ionCondmix(-1.0),
80  m_mobRatMix(0),
81  m_selfDiffMix(0),
82  m_visc_mix_ok(false),
83  m_visc_temp_ok(false),
84  m_visc_conc_ok(false),
85  m_ionCond_mix_ok(false),
86  m_ionCond_temp_ok(false),
87  m_ionCond_conc_ok(false),
88  m_mobRat_mix_ok(false),
89  m_mobRat_temp_ok(false),
90  m_mobRat_conc_ok(false),
91  m_selfDiff_mix_ok(false),
92  m_selfDiff_temp_ok(false),
93  m_selfDiff_conc_ok(false),
94  m_radi_mix_ok(false),
95  m_radi_temp_ok(false),
96  m_radi_conc_ok(false),
97  m_diff_mix_ok(false),
98  m_diff_temp_ok(false),
99  m_lambda_temp_ok(false),
100  m_lambda_mix_ok(false),
101  m_mode(-1000),
102  m_debug(false)
103 {
104  /*
105  * Use the assignment operator to do the brunt
106  * of the work for the copy constructor.
107  */
108  *this = right;
109 }
110 
111 LiquidTransport& LiquidTransport::operator=(const LiquidTransport& right)
112 {
113  if (&right == this) {
114  return *this;
115  }
116  Transport::operator=(right);
117  m_nsp2 = right.m_nsp2;
118  m_mw = right.m_mw;
119  m_viscTempDep_Ns = right.m_viscTempDep_Ns;
120  m_ionCondTempDep_Ns = right.m_ionCondTempDep_Ns;
121  m_mobRatTempDep_Ns = right.m_mobRatTempDep_Ns;
122  m_selfDiffTempDep_Ns = right.m_selfDiffTempDep_Ns;
123  m_lambdaTempDep_Ns = right.m_lambdaTempDep_Ns;
124  m_diffTempDep_Ns = right.m_diffTempDep_Ns;
125  m_radiusTempDep_Ns = right.m_radiusTempDep_Ns;
126  m_hydrodynamic_radius = right.m_hydrodynamic_radius;
127  m_Grad_X = right.m_Grad_X;
128  m_Grad_T = right.m_Grad_T;
129  m_Grad_V = right.m_Grad_V;
130  m_Grad_mu = right.m_Grad_mu;
131  m_bdiff = right.m_bdiff;
132  m_viscSpecies = right.m_viscSpecies;
133  m_ionCondSpecies = right.m_ionCondSpecies;
134  m_mobRatSpecies = right.m_mobRatSpecies;
135  m_selfDiffSpecies = right.m_selfDiffSpecies;
136  m_hydrodynamic_radius = right.m_hydrodynamic_radius;
137  m_lambdaSpecies = right.m_lambdaSpecies;
138  m_viscMixModel = right.m_viscMixModel;
139  m_ionCondMixModel = right.m_ionCondMixModel;
140  m_mobRatMixModel = right.m_mobRatMixModel;
141  m_selfDiffMixModel = right.m_selfDiffMixModel;
142  m_lambdaMixModel = right.m_lambdaMixModel;
143  m_diffMixModel = right.m_diffMixModel;
144  m_iStateMF = -1;
145  m_massfracs = right.m_massfracs;
146  m_massfracs_tran = right.m_massfracs_tran;
147  m_molefracs = right.m_molefracs;
148  m_molefracs_tran = right.m_molefracs_tran;
149  m_concentrations = right.m_concentrations;
150  m_actCoeff = right.m_actCoeff;
151  m_Grad_lnAC = right.m_Grad_lnAC;
152  m_chargeSpecies = right.m_chargeSpecies;
153  m_B = right.m_B;
154  m_A = right.m_A;
155  m_temp = right.m_temp;
156  m_press = right.m_press;
157  m_flux = right.m_flux;
158  m_Vdiff = right.m_Vdiff;
159  m_lambda = right.m_lambda;
160  m_viscmix = right.m_viscmix;
161  m_ionCondmix = right.m_ionCondmix;
162  m_mobRatMix = right.m_mobRatMix;
163  m_selfDiffMix = right.m_selfDiffMix;
164  m_spwork = right.m_spwork;
165  m_visc_mix_ok = false;
166  m_visc_temp_ok = false;
167  m_visc_conc_ok = false;
168  m_ionCond_mix_ok = false;
169  m_ionCond_temp_ok = false;
170  m_ionCond_conc_ok = false;
171  m_mobRat_mix_ok = false;
172  m_mobRat_temp_ok = false;
173  m_mobRat_conc_ok = false;
174  m_selfDiff_mix_ok = false;
175  m_selfDiff_temp_ok = false;
176  m_selfDiff_conc_ok = false;
177  m_radi_mix_ok = false;
178  m_radi_temp_ok = false;
179  m_radi_conc_ok = false;
180  m_diff_mix_ok = false;
181  m_diff_temp_ok = false;
182  m_lambda_temp_ok = false;
183  m_lambda_mix_ok = false;
184  m_mode = right.m_mode;
185  m_debug = right.m_debug;
186  m_nDim = right.m_nDim;
187 
188  return *this;
189 }
190 
192 {
193  return new LiquidTransport(*this);
194 }
195 
196 LiquidTransport::~LiquidTransport()
197 {
198  //These are constructed in TransportFactory::newLTP
199  for (size_t k = 0; k < m_nsp; k++) {
200  delete m_viscTempDep_Ns[k];
201  delete m_ionCondTempDep_Ns[k];
202  for (size_t l = 0; l < m_nsp; l++) {
203  delete m_selfDiffTempDep_Ns[l][k];
204  }
205  for (size_t l=0; l < m_nsp2; l++) {
206  delete m_mobRatTempDep_Ns[l][k];
207  }
208  delete m_lambdaTempDep_Ns[k];
209  delete m_radiusTempDep_Ns[k];
210  delete m_diffTempDep_Ns[k];
211  //These are constructed in TransportFactory::newLTI
212  delete m_selfDiffMixModel[k];
213  }
214 
215  for (size_t k = 0; k < m_nsp2; k++) {
216  delete m_mobRatMixModel[k];
217  }
218 
219  delete m_viscMixModel;
220  delete m_ionCondMixModel;
221  delete m_lambdaMixModel;
222  delete m_diffMixModel;
223  //if ( m_radiusMixModel ) delete m_radiusMixModel;
224 }
225 
227 {
228 
229  // constant substance attributes
230  m_thermo = tr.thermo;
231  tr.thermo = 0;
233  m_nsp = m_thermo->nSpecies();
234  m_nsp2 = m_nsp*m_nsp;
235 
236  // make a local copy of the molecular weights
237  m_mw.resize(m_nsp, 0.0);
238  copy(m_thermo->molecularWeights().begin(),
239  m_thermo->molecularWeights().end(), m_mw.begin());
240 
241  /*
242  * Get the input Viscosities, and stuff
243  */
244  m_viscSpecies.resize(m_nsp, 0.0);
245  m_viscTempDep_Ns.resize(m_nsp, 0);
246  m_ionCondSpecies.resize(m_nsp, 0.0);
247  m_ionCondTempDep_Ns.resize(m_nsp, 0);
248  m_mobRatTempDep_Ns.resize(m_nsp2);
249  m_mobRatMixModel.resize(m_nsp2);
250  m_mobRatSpecies.resize(m_nsp2, m_nsp, 0.0);
251  m_mobRatMix.resize(m_nsp2,0.0);
252  m_selfDiffTempDep_Ns.resize(m_nsp);
253  m_selfDiffMixModel.resize(m_nsp);
254  m_selfDiffSpecies.resize(m_nsp, m_nsp, 0.0);
255  m_selfDiffMix.resize(m_nsp,0.0);
256  for (size_t k=0; k < m_nsp; k++) {
257  m_selfDiffTempDep_Ns[k].resize(m_nsp, 0);
258  }
259  for (size_t k=0; k < m_nsp2; k++) {
260  m_mobRatTempDep_Ns[k].resize(m_nsp, 0);
261  }
262  m_lambdaSpecies.resize(m_nsp, 0.0);
263  m_lambdaTempDep_Ns.resize(m_nsp, 0);
264  m_hydrodynamic_radius.resize(m_nsp, 0.0);
265  m_radiusTempDep_Ns.resize(m_nsp, 0);
266 
267  //first populate mixing rules and indices
268  for (size_t k = 0; k < m_nsp; k++) {
270  tr.selfDiffusion[k] = 0;
271  }
272  for (size_t k = 0; k < m_nsp2; k++) {
273  m_mobRatMixModel[k] = tr.mobilityRatio[k];
274  tr.mobilityRatio[k] = 0;
275  }
276 
277  //for each species, assign viscosity model and coefficients
278  for (size_t k = 0; k < m_nsp; k++) {
280  m_viscTempDep_Ns[k] = ltd.viscosity;
281  ltd.viscosity = 0;
283  ltd.ionConductivity = 0;
284  for (size_t j = 0; j < m_nsp2; j++) {
285  m_mobRatTempDep_Ns[j][k] = ltd.mobilityRatio[j];
286  ltd.mobilityRatio[j] = 0;
287  }
288  for (size_t j = 0; j < m_nsp; j++) {
289  m_selfDiffTempDep_Ns[j][k] = ltd.selfDiffusion[j];
290  ltd.selfDiffusion[j] = 0;
291  }
293  ltd.thermalCond = 0;
295  ltd.hydroRadius = 0;
296  }
297 
298 
299  /*
300  * Get the input Species Diffusivities
301  * Note that species diffusivities are not what is needed.
302  * Rather the Stefan Boltzmann interaction parameters are
303  * needed for the current model. This section may, therefore,
304  * be extraneous.
305  */
306  m_diffTempDep_Ns.resize(m_nsp, 0);
307  //for each species, assign viscosity model and coefficients
308  for (size_t k = 0; k < m_nsp; k++) {
310  if (ltd.speciesDiffusivity != 0) {
311  cout << "Warning: diffusion coefficient data for "
312  << m_thermo->speciesName(k)
313  << endl
314  << "in the input file is not used for LiquidTransport model."
315  << endl
316  << "LiquidTransport model uses Stefan-Maxwell interaction "
317  << endl
318  << "parameters defined in the <transport> input block."
319  << endl;
320  }
321  }
322 
323  /*
324  * Here we get interaction parameters from LiquidTransportParams
325  * that were filled in TransportFactory::getLiquidInteractionsTransportData
326  * Interaction models are provided here for viscosity, thermal conductivity,
327  * species diffusivity and hydrodynamics radius (perhaps not needed in the
328  * present class).
329  */
330 
331 
333  tr.viscosity = 0;
334 
336  tr.ionConductivity = 0;
337  //m_mobRatMixModel = tr.mobilityRatio;
338 
340  tr.thermalCond = 0;
341 
343  tr.speciesDiffusivity = 0;
344 
345 
346  m_bdiff.resize(m_nsp,m_nsp, 0.0);
347 
348  //Don't really need to update this here.
349  //It is updated in updateDiff_T()
350  m_diffMixModel->getMatrixTransProp(m_bdiff);
351 
352 
353  m_mode = tr.mode_;
354 
355  m_massfracs.resize(m_nsp, 0.0);
356  m_massfracs_tran.resize(m_nsp, 0.0);
357  m_molefracs.resize(m_nsp, 0.0);
358  m_molefracs_tran.resize(m_nsp, 0.0);
359  m_concentrations.resize(m_nsp, 0.0);
360  m_actCoeff.resize(m_nsp, 0.0);
361  m_chargeSpecies.resize(m_nsp, 0.0);
362  for (size_t i = 0; i < m_nsp; i++) {
364  }
365  m_volume_spec.resize(m_nsp, 0.0);
366  m_Grad_lnAC.resize(m_nDim * m_nsp, 0.0);
367  m_spwork.resize(m_nsp, 0.0);
368 
369  // resize the internal gradient variables
370  m_Grad_X.resize(m_nDim * m_nsp, 0.0);
371  m_Grad_T.resize(m_nDim, 0.0);
372  m_Grad_V.resize(m_nDim, 0.0);
373  m_Grad_mu.resize(m_nDim * m_nsp, 0.0);
374 
375  m_flux.resize(m_nsp, m_nDim, 0.0);
376  m_Vdiff.resize(m_nsp, m_nDim, 0.0);
377 
378 
379  // set all flags to false
380  m_visc_mix_ok = false;
381  m_visc_temp_ok = false;
382  m_visc_conc_ok = false;
383  m_ionCond_mix_ok = false;
384  m_ionCond_temp_ok = false;
385  m_ionCond_conc_ok = false;
386  m_mobRat_mix_ok = false;
387  m_mobRat_temp_ok = false;
388  m_mobRat_conc_ok = false;
389  m_selfDiff_mix_ok = false;
390  m_selfDiff_temp_ok = false;
391  m_selfDiff_conc_ok = false;
392  m_radi_temp_ok = false;
393  m_radi_conc_ok = false;
394  m_lambda_temp_ok = false;
395  m_lambda_mix_ok = false;
396  m_diff_temp_ok = false;
397  m_diff_mix_ok = false;
398 
399  return true;
400 }
401 
403 {
404  update_T();
405  update_C();
406 
407  if (m_visc_mix_ok) {
408  return m_viscmix;
409  }
410 
411  ////// LiquidTranInteraction method
413 
414  return m_viscmix;
415 }
416 
417 void LiquidTransport::getSpeciesViscosities(doublereal* const visc)
418 {
419  update_T();
420  if (!m_visc_temp_ok) {
422  }
423  copy(m_viscSpecies.begin(), m_viscSpecies.end(), visc);
424 }
425 
427 {
428  update_T();
429  update_C();
430 
431  if (m_ionCond_mix_ok) {
432  return m_ionCondmix;
433  }
434 
435  ////// LiquidTranInteraction method
437 
438  return m_ionCondmix;
439 
440  /*
441  // update m_ionCondSpecies[] if necessary
442  if (!m_ionCond_temp_ok) {
443  updateIonConductivity_T();
444  }
445 
446  if (!m_ionCond_conc_ok) {
447  updateIonConductivity_C();
448  }
449  */
450 }
451 
453 {
454  update_T();
455  if (!m_ionCond_temp_ok) {
457  }
458  copy(m_ionCondSpecies.begin(), m_ionCondSpecies.end(), ionCond);
459 }
460 
461 void LiquidTransport:: mobilityRatio(doublereal* mobRat)
462 {
463 
464  update_T();
465  update_C();
466 
467  // LiquidTranInteraction method
468  if (!m_mobRat_mix_ok) {
469  for (size_t k = 0; k < m_nsp2; k++) {
470  if (m_mobRatMixModel[k]) {
471  m_mobRatMix[k] = m_mobRatMixModel[k]->getMixTransProp(m_mobRatTempDep_Ns[k]);
472  if (m_mobRatMix[k] > 0.0) {
473  m_mobRatMix[k / m_nsp + m_nsp * (k % m_nsp)] = 1.0 / m_mobRatMix[k]; // Also must be off diagonal: k%(1+n)!=0, but then m_mobRatMixModel[k] shouldn't be initialized anyway
474  }
475  }
476  }
477  }
478  for (size_t k = 0; k < m_nsp2; k++) {
479  mobRat[k] = m_mobRatMix[k];
480  }
481 }
482 
484 {
485  update_T();
486  if (!m_mobRat_temp_ok) {
488  }
489  for (size_t k = 0; k < m_nsp2; k++) {
490  for (size_t j = 0; j < m_nsp; j++) {
491  mobRat[k][j] = m_mobRatSpecies(k,j);
492  }
493  }
494 }
495 
496 void LiquidTransport::selfDiffusion(doublereal* const selfDiff)
497 {
498  update_T();
499  update_C();
500  if (!m_selfDiff_mix_ok) {
501  for (size_t k = 0; k < m_nsp; k++) {
502  m_selfDiffMix[k] = m_selfDiffMixModel[k]->getMixTransProp(m_selfDiffTempDep_Ns[k]);
503  }
504  }
505  for (size_t k = 0; k < m_nsp; k++) {
506  selfDiff[k] = m_selfDiffMix[k];
507  }
508 }
509 
510 void LiquidTransport::getSpeciesSelfDiffusion(doublereal** selfDiff)
511 {
512  update_T();
513  if (!m_selfDiff_temp_ok) {
515  }
516  for (size_t k=0; k<m_nsp; k++) {
517  for (size_t j=0; j < m_nsp; j++) {
518  selfDiff[k][j] = m_selfDiffSpecies(k,j);
519  }
520  }
521 }
522 
523 void LiquidTransport::getSpeciesHydrodynamicRadius(doublereal* const radius)
524 {
525  update_T();
526  if (!m_radi_temp_ok) {
528  }
529  copy(m_hydrodynamic_radius.begin(), m_hydrodynamic_radius.end(), radius);
530 
531 }
532 
534 {
535 
536  update_T();
537  update_C();
538 
539  if (!m_lambda_mix_ok) {
541  m_cond_mix_ok = true;
542  }
543 
544  return m_lambda;
545 }
546 
547 void LiquidTransport::getThermalDiffCoeffs(doublereal* const dt)
548 {
549  for (size_t k = 0; k < m_nsp; k++) {
550  dt[k] = 0.0;
551  }
552 }
553 
554 void LiquidTransport::getBinaryDiffCoeffs(size_t ld, doublereal* d)
555 {
556  if (ld != m_nsp)
557  throw CanteraError("LiquidTransport::getBinaryDiffCoeffs",
558  "First argument does not correspond to number of species in model.\nDiff Coeff matrix may be misdimensioned");
559  update_T();
560 
561  // if necessary, evaluate the binary diffusion coefficients
562  // from the polynomial fits
563  if (!m_diff_temp_ok) {
564  updateDiff_T();
565  }
566 
567  for (size_t i = 0; i < m_nsp; i++) {
568  for (size_t j = 0; j < m_nsp; j++) {
569  //if (!( ( m_bdiff(i,j) > 0.0 ) | ( m_bdiff(i,j) < 0.0 ))){
570  // throw CanteraError("LiquidTransport::getBinaryDiffCoeffs ",
571  // "m_bdiff has zero entry in non-diagonal.");}
572  d[ld*j + i] = 1.0 / m_bdiff(i,j);
573 
574  }
575  }
576 }
577 
578 void LiquidTransport::getMobilities(doublereal* const mobil)
579 {
581  doublereal c1 = ElectronCharge / (Boltzmann * m_temp);
582  for (size_t k = 0; k < m_nsp; k++) {
583  mobil[k] = c1 * m_spwork[k];
584  }
585 }
586 
587 void LiquidTransport::getFluidMobilities(doublereal* const mobil_f)
588 {
590  doublereal c1 = 1.0 / (GasConstant * m_temp);
591  for (size_t k = 0; k < m_nsp; k++) {
592  mobil_f[k] = c1 * m_spwork[k];
593  }
594 }
595 
596 void LiquidTransport::set_Grad_T(const doublereal* grad_T)
597 {
598  for (size_t a = 0; a < m_nDim; a++) {
599  m_Grad_T[a] = grad_T[a];
600  }
601 }
602 
603 void LiquidTransport::set_Grad_V(const doublereal* grad_V)
604 {
605  for (size_t a = 0; a < m_nDim; a++) {
606  m_Grad_V[a] = grad_V[a];
607  }
608 }
609 
610 void LiquidTransport::set_Grad_X(const doublereal* grad_X)
611 {
612  size_t itop = m_nDim * m_nsp;
613  for (size_t i = 0; i < itop; i++) {
614  m_Grad_X[i] = grad_X[i];
615  }
616 }
617 
619 {
620  vector_fp gradT(m_nDim,0.0);
621  vector_fp gradX(m_nDim * m_nsp);
622  vector_fp gradV(m_nDim);
623  for (size_t i = 0; i < m_nDim; i++) {
624  for (size_t k = 0; k < m_nsp; k++) {
625  gradX[ i*m_nDim + k] = 0.0;
626  }
627  gradV[i] = 1.0;
628  }
629 
630  set_Grad_T(&gradT[0]);
631  set_Grad_X(&gradX[0]);
632  set_Grad_V(&gradV[0]);
633 
634  vector_fp fluxes(m_nsp * m_nDim);
635  doublereal current;
636 
637  getSpeciesFluxesExt(m_nDim, &fluxes[0]);
638 
639  //sum over species charges, fluxes, Faraday to get current
640  // Since we want the scalar conductivity, we need only consider one-dim
641  for (size_t i = 0; i < 1; i++) {
642  current = 0.0;
643  for (size_t k = 0; k < m_nsp; k++) {
644  current += m_chargeSpecies[k] * Faraday * fluxes[k] / m_mw[k];
645  }
646  //divide by unit potential gradient
647  current /= - gradV[i];
648  }
649  return current;
650 }
651 
653  const doublereal* grad_T,
654  int ldx,
655  const doublereal* grad_X,
656  int ldf,
657  const doublereal* grad_V,
658  doublereal* current)
659 {
660  set_Grad_T(grad_T);
661  set_Grad_X(grad_X);
662  set_Grad_V(grad_V);
663 
664  vector_fp fluxes(m_nsp * m_nDim);
665 
666  getSpeciesFluxesExt(ldf, &fluxes[0]);
667 
668  //sum over species charges, fluxes, Faraday to get current
669  for (size_t i = 0; i < m_nDim; i++) {
670  current[i] = 0.0;
671  for (size_t k = 0; k < m_nsp; k++) {
672  current[i] += m_chargeSpecies[k] * Faraday * fluxes[k] / m_mw[k];
673  }
674  //divide by unit potential gradient
675  }
676 }
677 
679  const doublereal* grad_T,
680  int ldx, const doublereal* grad_X,
681  int ldf, doublereal* Vdiff)
682 {
683  set_Grad_T(grad_T);
684  set_Grad_X(grad_X);
685  getSpeciesVdiffExt(ldf, Vdiff);
686 }
687 
689  const doublereal* grad_T,
690  int ldx,
691  const doublereal* grad_X,
692  int ldf,
693  const doublereal* grad_V,
694  doublereal* Vdiff)
695 {
696  set_Grad_T(grad_T);
697  set_Grad_X(grad_X);
698  set_Grad_V(grad_V);
699  getSpeciesVdiffExt(ldf, Vdiff);
700 }
701 
703  const doublereal* const grad_T,
704  size_t ldx, const doublereal* const grad_X,
705  size_t ldf, doublereal* const fluxes)
706 {
707  set_Grad_T(grad_T);
708  set_Grad_X(grad_X);
709  getSpeciesFluxesExt(ldf, fluxes);
710 }
711 
713  const doublereal* grad_T,
714  size_t ldx,
715  const doublereal* grad_X,
716  size_t ldf,
717  const doublereal* grad_V,
718  doublereal* fluxes)
719 {
720  set_Grad_T(grad_T);
721  set_Grad_X(grad_X);
722  set_Grad_V(grad_V);
723  getSpeciesFluxesExt(ldf, fluxes);
724 }
725 
726 void LiquidTransport::getSpeciesVdiffExt(size_t ldf, doublereal* Vdiff)
727 {
729 
730  for (size_t n = 0; n < m_nDim; n++) {
731  for (size_t k = 0; k < m_nsp; k++) {
732  Vdiff[n*ldf + k] = m_Vdiff(k,n);
733  }
734  }
735 }
736 
737 void LiquidTransport::getSpeciesFluxesExt(size_t ldf, doublereal* fluxes)
738 {
740 
741  for (size_t n = 0; n < m_nDim; n++) {
742  for (size_t k = 0; k < m_nsp; k++) {
743  fluxes[n*ldf + k] = m_flux(k,n);
744  }
745  }
746 }
747 
748 void LiquidTransport::getMixDiffCoeffs(doublereal* const d)
749 {
751 
752  for (size_t n = 0; n < m_nDim; n++) {
753  for (size_t k = 0; k < m_nsp; k++) {
754  if (m_Grad_X[n*m_nsp + k] != 0.0) {
755  d[n*m_nsp + k] = - m_Vdiff(k,n) * m_molefracs[k]
756  / m_Grad_X[n*m_nsp + k];
757  } else {
758  //avoid divide by zero with nonsensical response
759  d[n*m_nsp + k] = - 1.0;
760  }
761  }
762  }
763 }
764 
766 {
767  // First make a decision about whether we need to recalculate
768  doublereal t = m_thermo->temperature();
769  if (t == m_temp) {
770  return false;
771  }
772 
773  // Next do a reality check on temperature value
774  if (t < 0.0) {
775  throw CanteraError("LiquidTransport::update_T()",
776  "negative temperature "+fp2str(t));
777  }
778 
779  // Compute various direct functions of temperature
780  m_temp = t;
781 
782  // temperature has changed so temp flags are flipped
783  m_visc_temp_ok = false;
784  m_ionCond_temp_ok = false;
785  m_mobRat_temp_ok = false;
786  m_selfDiff_temp_ok = false;
787  m_radi_temp_ok = false;
788  m_diff_temp_ok = false;
789  m_lambda_temp_ok = false;
790 
791  // temperature has changed, so polynomial temperature
792  // interpolations will need to be reevaluated.
793  // This means that many concentration
794  m_visc_conc_ok = false;
795  m_ionCond_conc_ok = false;
796  m_mobRat_conc_ok = false;
797  m_selfDiff_conc_ok = false;
798 
799  // Mixture stuff needs to be evaluated
800  m_visc_mix_ok = false;
801  m_ionCond_mix_ok = false;
802  m_mobRat_mix_ok = false;
803  m_selfDiff_mix_ok = false;
804  m_diff_mix_ok = false;
805  m_lambda_mix_ok = false; //(don't need it because a lower lvl flag is set
806  return true;
807 }
808 
810 {
811  // If the pressure has changed then the concentrations
812  // have changed.
813  doublereal pres = m_thermo->pressure();
814  bool qReturn = true;
815  if (pres != m_press) {
816  qReturn = false;
817  m_press = pres;
818  }
819  int iStateNew = m_thermo->stateMFNumber();
820  if (iStateNew != m_iStateMF) {
821  qReturn = false;
825  concTot_ = 0.0;
826  concTot_tran_ = 0.0;
827  for (size_t k = 0; k < m_nsp; k++) {
828  m_molefracs[k] = std::max(0.0, m_molefracs[k]);
829  m_molefracs_tran[k] = std::max(Tiny, m_molefracs[k]);
830  m_massfracs_tran[k] = std::max(Tiny, m_massfracs[k]);
833  }
834  dens_ = m_thermo->density();
837  }
838  if (qReturn) {
839  return false;
840  }
841 
842  // signal that concentration-dependent quantities will need to
843  // be recomputed before use, and update the local mole
844  // fractions.
845  m_visc_conc_ok = false;
846  m_ionCond_conc_ok = false;
847  m_mobRat_conc_ok = false;
848  m_selfDiff_conc_ok = false;
849 
850  // Mixture stuff needs to be evaluated
851  m_visc_mix_ok = false;
852  m_ionCond_mix_ok = false;
853  m_mobRat_mix_ok = false;
854  m_selfDiff_mix_ok = false;
855  m_diff_mix_ok = false;
856  m_lambda_mix_ok = false;
857 
858  return true;
859 }
860 
862 {
863  for (size_t k = 0; k < m_nsp; k++) {
864  m_lambdaSpecies[k] = m_lambdaTempDep_Ns[k]->getSpeciesTransProp() ;
865  }
866  m_lambda_temp_ok = true;
867  m_lambda_mix_ok = false;
868 }
869 
871 {
872  m_diffMixModel->getMatrixTransProp(m_bdiff);
873  m_diff_temp_ok = true;
874  m_diff_mix_ok = false;
875 }
876 
878 {
879  m_visc_conc_ok = true;
880 }
881 
883 {
884  for (size_t k = 0; k < m_nsp; k++) {
885  m_viscSpecies[k] = m_viscTempDep_Ns[k]->getSpeciesTransProp() ;
886  }
887  m_visc_temp_ok = true;
888  m_visc_mix_ok = false;
889 }
890 
892 {
893  m_ionCond_conc_ok = true;
894 }
895 
897 {
898  for (size_t k = 0; k < m_nsp; k++) {
899  m_ionCondSpecies[k] = m_ionCondTempDep_Ns[k]->getSpeciesTransProp() ;
900  }
901  m_ionCond_temp_ok = true;
902  m_ionCond_mix_ok = false;
903 }
904 
906 {
907  m_mobRat_conc_ok = true;
908 }
909 
911 {
912  for (size_t k = 0; k < m_nsp2; k++) {
913  for (size_t j = 0; j < m_nsp; j++) {
914  m_mobRatSpecies(k,j) = m_mobRatTempDep_Ns[k][j]->getSpeciesTransProp();
915  }
916  }
917  m_mobRat_temp_ok = true;
918  m_mobRat_mix_ok = false;
919 }
920 
922 {
923  m_selfDiff_conc_ok = true;
924 }
925 
927 {
928  for (size_t k = 0; k < m_nsp2; k++) {
929  for (size_t j = 0; j < m_nsp; j++) {
930  m_selfDiffSpecies(k,j) = m_selfDiffTempDep_Ns[k][j]->getSpeciesTransProp() ;
931  }
932  }
933  m_selfDiff_temp_ok = true;
934  m_selfDiff_mix_ok = false;
935 }
936 
938 {
939  m_radi_conc_ok = true;
940 }
941 
943 {
944  for (size_t k = 0; k < m_nsp; k++) {
945  m_hydrodynamic_radius[k] = m_radiusTempDep_Ns[k]->getSpeciesTransProp() ;
946  }
947  m_radi_temp_ok = true;
948  m_radi_mix_ok = false;
949 }
950 
952 {
953  doublereal grad_T;
954  // static vector_fp grad_lnAC(m_nsp), grad_X(m_nsp);
955  // IonsFromNeutralVPSSTP * tempIons = dynamic_cast<IonsFromNeutralVPSSTP *> m_thermo;
956  //MargulesVPSSTP * tempMarg = dynamic_cast<MargulesVPSSTP *> (tempIons->neutralMoleculePhase_);
957 
958 
959  //m_thermo->getdlnActCoeffdlnX( DATA_PTR(grad_lnAC) );
960  for (size_t k = 0; k < m_nDim; k++) {
961  grad_T = m_Grad_T[k];
962  const int start = m_nsp*k;
963  m_thermo->getdlnActCoeffds(grad_T, &(m_Grad_X[start]), &(m_Grad_lnAC[start]));
964  for (size_t i = 0; i < m_nsp; i++)
965  if (m_molefracs[i] < 1.e-15) {
966  m_Grad_lnAC[start+i] = 0;
967  } else {
968  m_Grad_lnAC[start+i] += m_Grad_X[start+i]/m_molefracs[i];
969  }
970  // std::cout << k << " m_Grad_lnAC = " << m_Grad_lnAC[k] << std::endl;
971  }
972 
973  return;
974 }
975 
977 {
978  doublereal tmp;
979  m_B.resize(m_nsp, m_nDim, 0.0);
980  m_A.resize(m_nsp, m_nsp, 0.0);
981 
982  //! grab a local copy of the molecular weights
983  const vector_fp& M = m_thermo->molecularWeights();
984  //! grad a local copy of the ion molar volume (inverse total ion concentration)
985  const doublereal vol = m_thermo->molarVolume();
986 
987  /*
988  * Update the temperature, concentrations and diffusion coefficients in the mixture.
989  */
990  update_T();
991  update_C();
992  if (!m_diff_temp_ok) {
993  updateDiff_T();
994  }
995 
996  double T = m_thermo->temperature();
997 
998  update_Grad_lnAC() ;
999 
1000  //m_thermo->getStandardVolumes(DATA_PTR(m_volume_spec));
1002 
1003  /*
1004  * Calculate the electrochemical potential gradient. This is the
1005  * driving force for relative diffusional transport.
1006  *
1007  * Here we calculate
1008  *
1009  * X_i * (grad (mu_i) + S_i grad T - M_i / dens * grad P
1010  *
1011  * This is Eqn. 13-1 p. 318 Newman. The original equation is from
1012  * Hershfeld, Curtis, and Bird.
1013  *
1014  * S_i is the partial molar entropy of species i. This term will cancel
1015  * out a lot of the grad T terms in grad (mu_i), therefore simplifying
1016  * the expression.
1017  *
1018  * Ok I think there may be many ways to do this. One way is to do it via basis
1019  * functions, at the nodes, as a function of the variables in the problem.
1020  *
1021  * For calculation of molality based thermo systems, we current get
1022  * the molar based values. This may change.
1023  *
1024  * Note, we have broken the symmetry of the matrix here, due to
1025  * considerations involving species concentrations going to zero.
1026  *
1027  */
1028  for (size_t a = 0; a < m_nDim; a++) {
1029  for (size_t i = 0; i < m_nsp; i++) {
1030  m_Grad_mu[a*m_nsp + i] =
1031  m_chargeSpecies[i] * Faraday * m_Grad_V[a]
1032  //+ (m_volume_spec[i] - M[i]/dens_) * m_Grad_P[a]
1033  + GasConstant * T * m_Grad_lnAC[a*m_nsp+i];
1034  }
1035  }
1036 
1038  int iSolvent = 0;
1039  double mwSolvent = m_thermo->molecularWeight(iSolvent);
1040  double mnaught = mwSolvent/ 1000.;
1041  double lnmnaught = log(mnaught);
1042  for (size_t a = 0; a < m_nDim; a++) {
1043  for (size_t i = 1; i < m_nsp; i++) {
1044  m_Grad_mu[a*m_nsp + i] -=
1045  m_molefracs[i] * GasConstant * m_Grad_T[a] * lnmnaught;
1046  }
1047  }
1048  }
1049 
1050  /*
1051  * Just for Note, m_A(i,j) refers to the ith row and jth column.
1052  * They are still fortran ordered, so that i varies fastest.
1053  */
1054 
1055  double condSum1;
1056  const doublereal invRT = 1.0 / (GasConstant * T);
1057  switch (m_nDim) {
1058  case 1: /* 1-D approximation */
1059 
1060  m_B(0,0) = 0.0;
1061  //equation for the reference velocity
1062  for (size_t j = 0; j < m_nsp; j++) {
1063  if (m_velocityBasis == VB_MOLEAVG) {
1064  m_A(0,j) = m_molefracs_tran[j];
1065  } else if (m_velocityBasis == VB_MASSAVG) {
1066  m_A(0,j) = m_massfracs_tran[j];
1067  } else if ((m_velocityBasis >= 0)
1068  && (m_velocityBasis < static_cast<int>(m_nsp)))
1069  // use species number m_velocityBasis as reference velocity
1070  if (m_velocityBasis == static_cast<int>(j)) {
1071  m_A(0,j) = 1.0;
1072  } else {
1073  m_A(0,j) = 0.0;
1074  }
1075  else
1076  throw CanteraError("LiquidTransport::stefan_maxwell_solve",
1077  "Unknown reference velocity provided.");
1078  }
1079  for (size_t i = 1; i < m_nsp; i++) {
1080  m_B(i,0) = m_Grad_mu[i] * invRT;
1081  m_A(i,i) = 0.0;
1082  for (size_t j = 0; j < m_nsp; j++) {
1083  if (j != i) {
1084  //if ( !( m_bdiff(i,j) > 0.0 ) )
1085  //throw CanteraError("LiquidTransport::stefan_maxwell_solve",
1086  // "m_bdiff has zero entry in non-diagonal.");
1087  tmp = m_molefracs_tran[j] * m_bdiff(i,j);
1088  m_A(i,i) -= tmp;
1089  m_A(i,j) = tmp;
1090  }
1091  }
1092  }
1093 
1094  //! invert and solve the system Ax = b. Answer is in m_B
1095  solve(m_A, m_B);
1096 
1097  /*
1098  condSum2 = m_chargeSpecies[1]*m_chargeSpecies[1]*m_molefracs_tran[1]*m_bdiff(2,3) +
1099  m_chargeSpecies[2]*m_chargeSpecies[2]*m_molefracs_tran[2]*m_bdiff(1,3) +
1100  m_chargeSpecies[3]*m_chargeSpecies[3]*m_molefracs_tran[3]*m_bdiff(1,2);
1101  condSum1 = m_molefracs_tran[1]*m_bdiff(1,2)*m_bdiff(1,3) +
1102  m_molefracs_tran[2]*m_bdiff(2,3)*m_bdiff(1,2) +
1103  m_molefracs_tran[3]*m_bdiff(1,3)*m_bdiff(2,3);
1104  condSum2 = condSum2/condSum1*Faraday*Faraday/GasConstant/T/vol;
1105  */
1106 
1107  condSum1 = 0;
1108  for (size_t i = 0; i < m_nsp; i++) {
1109  condSum1 -= Faraday*m_chargeSpecies[i]*m_B(i,0)*m_molefracs_tran[i]/vol;
1110  }
1111 
1112  /*
1113  Check Mobility Ratio of Cations
1114  cout << "mobility ratio = " << m_chargeSpecies[1]*(m_B(1,0)-m_B(2,0))/m_chargeSpecies[0]/(m_B(0,0)-m_B(2,0)) << endl;
1115  */
1116 
1117  // cout << condSum1 << " = " << condSum2 << endl;
1118 
1119 
1120  break;
1121  case 2: /* 2-D approximation */
1122  m_B(0,0) = 0.0;
1123  m_B(0,1) = 0.0;
1124  //equation for the reference velocity
1125  for (size_t j = 0; j < m_nsp; j++) {
1126  if (m_velocityBasis == VB_MOLEAVG) {
1127  m_A(0,j) = m_molefracs_tran[j];
1128  } else if (m_velocityBasis == VB_MASSAVG) {
1129  m_A(0,j) = m_massfracs_tran[j];
1130  } else if ((m_velocityBasis >= 0)
1131  && (m_velocityBasis < static_cast<int>(m_nsp)))
1132  // use species number m_velocityBasis as reference velocity
1133  if (m_velocityBasis == static_cast<int>(j)) {
1134  m_A(0,j) = 1.0;
1135  } else {
1136  m_A(0,j) = 0.0;
1137  }
1138  else
1139  throw CanteraError("LiquidTransport::stefan_maxwell_solve",
1140  "Unknown reference velocity provided.");
1141  }
1142  for (size_t i = 1; i < m_nsp; i++) {
1143  m_B(i,0) = m_Grad_mu[i] * invRT;
1144  m_B(i,1) = m_Grad_mu[m_nsp + i] * invRT;
1145  m_A(i,i) = 0.0;
1146  for (size_t j = 0; j < m_nsp; j++) {
1147  if (j != i) {
1148  //if ( !( m_bdiff(i,j) > 0.0 ) )
1149  //throw CanteraError("LiquidTransport::stefan_maxwell_solve",
1150  // "m_bdiff has zero entry in non-diagonal.");
1151  tmp = m_molefracs_tran[j] * m_bdiff(i,j);
1152  m_A(i,i) -= tmp;
1153  m_A(i,j) = tmp;
1154  }
1155  }
1156  }
1157 
1158  //! invert and solve the system Ax = b. Answer is in m_B
1159  solve(m_A, m_B);
1160 
1161 
1162  break;
1163 
1164  case 3: /* 3-D approximation */
1165  m_B(0,0) = 0.0;
1166  m_B(0,1) = 0.0;
1167  m_B(0,2) = 0.0;
1168  //equation for the reference velocity
1169  for (size_t j = 0; j < m_nsp; j++) {
1170  if (m_velocityBasis == VB_MOLEAVG) {
1171  m_A(0,j) = m_molefracs_tran[j];
1172  } else if (m_velocityBasis == VB_MASSAVG) {
1173  m_A(0,j) = m_massfracs_tran[j];
1174  } else if ((m_velocityBasis >= 0)
1175  && (m_velocityBasis < static_cast<int>(m_nsp)))
1176  // use species number m_velocityBasis as reference velocity
1177  if (m_velocityBasis == static_cast<int>(j)) {
1178  m_A(0,j) = 1.0;
1179  } else {
1180  m_A(0,j) = 0.0;
1181  }
1182  else
1183  throw CanteraError("LiquidTransport::stefan_maxwell_solve",
1184  "Unknown reference velocity provided.");
1185  }
1186  for (size_t i = 1; i < m_nsp; i++) {
1187  m_B(i,0) = m_Grad_mu[i] * invRT;
1188  m_B(i,1) = m_Grad_mu[m_nsp + i] * invRT;
1189  m_B(i,2) = m_Grad_mu[2*m_nsp + i] * invRT;
1190  m_A(i,i) = 0.0;
1191  for (size_t j = 0; j < m_nsp; j++) {
1192  if (j != i) {
1193  //if ( !( m_bdiff(i,j) > 0.0 ) )
1194  //throw CanteraError("LiquidTransport::stefan_maxwell_solve",
1195  // "m_bdiff has zero entry in non-diagonal.");
1196  tmp = m_molefracs_tran[j] * m_bdiff(i,j);
1197  m_A(i,i) -= tmp;
1198  m_A(i,j) = tmp;
1199  }
1200  }
1201  }
1202 
1203  //! invert and solve the system Ax = b. Answer is in m_B
1204  solve(m_A, m_B);
1205 
1206  break;
1207  default:
1208  printf("unimplemented\n");
1209  throw CanteraError("routine", "not done");
1210  break;
1211  }
1212 
1213  for (size_t a = 0; a < m_nDim; a++) {
1214  for (size_t j = 0; j < m_nsp; j++) {
1215  m_Vdiff(j,a) = m_B(j,a);
1216  m_flux(j,a) = concTot_ * M[j] * m_molefracs_tran[j] * m_B(j,a);
1217  }
1218  }
1219 }
1220 
1221 doublereal LiquidTransport::err(const std::string& msg) const
1222 {
1223  throw CanteraError("LiquidTransport::err()",
1224  "\n\n\n**** Method "+ msg +" not implemented in model "
1225  + int2str(model()) + " ****\n"
1226  "(Did you forget to specify a transport model?)\n\n\n");
1227  return 0.0;
1228 }
1229 
1230 }
doublereal err(const std::string &msg) const
Throw an exception if this method is invoked.
bool m_debug
Debugging flags.
virtual doublereal ionConductivity()
Returns the ionic conductivity of the solution.
bool m_lambda_mix_ok
Boolean indicating that mixture conductivity is current.
doublereal molecularWeight(size_t k) const
Molecular weight of species k.
Definition: Phase.cpp:484
vector_fp m_mw
Local copy of the molecular weights of the species.
vector_fp m_lambdaSpecies
Internal value of the species individual thermal conductivities.
size_t m_nsp2
Number of species squared.
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 doublereal viscosity()
Returns the viscosity of the solution.
bool m_ionCond_mix_ok
Boolean indicating that the top-level mixture ionic conductivity is current.
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...
doublereal m_press
Current value of the pressure.
bool m_radi_conc_ok
Flag to indicate that the hydrodynamic radius is current is current wrt the concentration.
bool m_visc_conc_ok
Flag to indicate that the pure species viscosities are current wrt the concentration.
std::vector< LiquidTranInteraction * > mobilityRatio
Vector of pointer to the LiquidTranInteraction object which handles the calculation of each species' ...
bool m_diff_temp_ok
Boolean indicating that binary diffusion coeffs are current.
vector_fp m_Grad_V
Internal value of the gradient of the Electric Voltage.
bool m_cond_mix_ok
Flag to indicate that the mixture conductivity is current.
thermo_t * thermo
Pointer to the ThermoPhase object.
std::vector< LTPvector > m_selfDiffTempDep_Ns
Self Diffusion for each species in each pure species phase expressed as an appropriate subclass of LT...
void resize(size_t n, size_t m, doublereal v=0.0)
Resize the array, and fill the new entries with 'v'.
Definition: Array.h:128
virtual void getSpeciesFluxesExt(size_t ldf, doublereal *fluxes)
Return the species diffusive fluxes relative to the averaged velocity.
void getMassFractions(doublereal *const y) const
Get the species mass fractions.
Definition: Phase.cpp:561
Various templated functions that carry out common vector operations (see Templated Utility Functions)...
virtual void set_Grad_V(const doublereal *const grad_V)
Specify the value of the gradient of the voltage.
LTPspecies * thermalCond
Model type for the thermal conductivity.
void updateIonConductivity_C()
Update the concentration parts of the ionic conductivity.
std::vector< LTPspecies * > m_radiusTempDep_Ns
Hydrodynamic radius for each species expressed as an appropriate subclass of LTPspecies.
size_t m_nDim
Number of dimensions used in flux expressions.
virtual void getBinaryDiffCoeffs(const size_t ld, doublereal *const d)
Returns the binary diffusion coefficients.
virtual void update_Grad_lnAC()
Updates the internal value of the gradient of the logarithm of the activity, which is used in the gra...
doublereal m_ionCondmix
Saved value of the mixture ionic conductivity.
doublereal meanMolecularWeight_
Mean molecular mass.
thermo_t * m_thermo
pointer to the object representing the phase
Class LiquidTransport implements models for transport properties for liquid phases.
vector_fp m_Grad_mu
Gradient of the electrochemical potential.
bool m_mobRat_temp_ok
Boolean indicating that weight factors wrt mobility ratio is current.
virtual void getThermalDiffCoeffs(doublereal *const dt)
Return the thermal diffusion coefficients.
virtual void set_Grad_T(const doublereal *const grad_T)
Specify the value of the gradient of the temperature.
bool m_radi_mix_ok
Boolean indicating that mixture diffusion coeffs are current.
std::vector< LiquidTranInteraction * > m_mobRatMixModel
Mobility ratio for each binary combination of mobile species in the mixture expressed as a subclass o...
Array2D m_Vdiff
Solution of the Stefan Maxwell equation.
Base class for transport property managers.
vector_fp m_ionCondSpecies
Internal value of the species ionic conductivities.
LiquidTranInteraction * viscosity
Object that specifies the viscosity interaction for the mixture.
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 getSpeciesMobilityRatio(doublereal **mobRat)
Returns a double pointer to the mobility ratios of the transported species in each pure species phase...
std::vector< LTPvector > m_mobRatTempDep_Ns
Mobility ratio for the binary cominations of each species in each pure phase expressed as an appropri...
int solve(DenseMatrix &A, double *b)
Solve Ax = b. Array b is overwritten on exit with x.
void updateViscosity_T()
Updates the array of pure species viscosities internally.
void updateDiff_T()
Update the binary Stefan-Maxwell diffusion coefficients wrt T using calls to the appropriate LTPspeci...
LiquidTranInteraction * m_lambdaMixModel
Thermal conductivity of the mixture expressed as a subclass of LiquidTranInteraction.
void updateHydrodynamicRadius_C()
Update the concentration dependence of the hydrodynamic radius.
virtual doublereal getMixTransProp(doublereal *speciesValues, doublereal *weightSpecies=0)
Return the mixture transport property value.
void getMoleFractions(doublereal *const x) const
Get the species mole fraction vector.
Definition: Phase.cpp:519
vector_fp m_molefracs
Local copy of the mole fractions of the species in the phase.
void getConcentrations(doublereal *const c) const
Get the species concentrations (kmol/m^3).
Definition: Phase.cpp:572
LTPspecies * speciesDiffusivity
Model type for the speciesDiffusivity.
bool m_ionCond_conc_ok
Flag to indicate that the pure species ionic conductivities are current wrt the concentration.
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...
int m_mode
Mode indicator for transport models – currently unused.
bool m_visc_temp_ok
Boolean indicating that weight factors wrt viscosity is current.
virtual bool update_T()
Returns true if temperature has changed, in which case flags are set to recompute transport propertie...
virtual void getFluidMobilities(doublereal *const mobil_f)
Get the fluid mobilities (s kmol/kg).
void updateSelfDiffusion_C()
Update the concentration parts of the self diffusion.
virtual int model() const
Transport model.
std::vector< LTPspecies * > m_viscTempDep_Ns
Viscosity for each species expressed as an appropriate subclass of LTPspecies.
virtual void set_Grad_X(const doublereal *const grad_X)
Specify the value of the gradient of the MoleFractions.
Header file defining class TransportFactory (see TransportFactory)
virtual void getElectricCurrent(int ndim, const doublereal *grad_T, int ldx, const doublereal *grad_X, int ldf, const doublereal *grad_V, doublereal *current)
Compute the electric current density in A/m^2.
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:101
vector_fp m_Grad_T
Internal value of the gradient of the Temperature vector.
bool m_mobRat_conc_ok
Flag to indicate that the pure species mobility ratios are current wrt the concentration.
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' ...
Header file defining class LiquidTransportParams.
doublereal m_temp
Current Temperature -> locally stored.
void updateMobilityRatio_C()
Update the concentration parts of the mobility ratio.
LiquidTranInteraction * ionConductivity
Object that specifes the ionic Conductivity of the mixture.
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)
Return the species diffusive mass fluxes wrt to the averaged velocity in [kmol/m^2/s].
void resize(size_t n, size_t m, doublereal v=0.0)
Resize the matrix.
Definition: DenseMatrix.cpp:71
DenseMatrix m_B
RHS to the stefan-maxwell equation.
void updateCond_T()
Update the temperature-dependent parts of the mixture-averaged thermal conductivity internally...
virtual void getSpeciesViscosities(doublereal *const visc)
Returns the pure species viscosities for all species.
bool m_diff_mix_ok
Boolean indicating that mixture diffusion coeffs are current.
VelocityBasis velocityBasis_
A basis for the average velocity can be specified.
doublereal m_viscmix
Saved value of the mixture viscosity.
doublereal molarVolume() const
Molar volume (m^3/kmol).
Definition: Phase.cpp:607
virtual void getSpeciesSelfDiffusion(doublereal **selfDiff)
Returns the self diffusion coefficients in the pure species phases.
vector_fp m_spwork
work space
std::string fp2str(const double x, const std::string &fmt)
Convert a double into a c++ string.
Definition: stringUtils.cpp:29
void updateSelfDiffusion_T()
Updates the array of pure species self diffusion coeffs internally.
int m_iStateMF
State of the mole fraction vector.
void stefan_maxwell_solve()
Solve the stefan_maxell equations for the diffusive fluxes.
std::vector< LTPspecies * > m_ionCondTempDep_Ns
Ionic conductivity for each species expressed as an appropriate subclass of LTPspecies.
bool m_lambda_temp_ok
Flag to indicate that the pure species conductivities are current wrt the temperature.
vector_fp m_Grad_X
Internal value of the gradient of the mole fraction vector.
virtual doublereal thermalConductivity()
Return the thermal conductivity of the solution.
bool m_selfDiff_conc_ok
Flag to indicate that the pure species self diffusion are current wrt the concentration.
virtual void getdlnActCoeffds(const doublereal dTds, const doublereal *const dXds, doublereal *dlnActCoeffds) const
Get the change in activity coefficients wrt changes in state (temp, mole fraction, etc) along a line in parameter space or along a line in physical space.
Definition: ThermoPhase.h:1520
vector_fp m_Grad_lnAC
Gradient of the logarithm of the activity.
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:68
const int cAC_CONVENTION_MOLALITY
Standard state uses the molality convention.
Definition: ThermoPhase.h:26
doublereal dens_
Density.
bool m_selfDiff_temp_ok
Boolean indicating that weight factors wrt self diffusion is current.
std::vector< LiquidTranInteraction * > m_selfDiffMixModel
Self Diffusion for each species in the mixture expressed as a subclass of LiquidTranInteraction.
virtual void getMobilities(doublereal *const mobil_e)
Get the Electrical mobilities (m^2/V/s).
vector_fp m_chargeSpecies
Local copy of the charge of each species.
LiquidTranInteraction * speciesDiffusivity
Pointer to the LiquidTranInteraction object which handles the calculation of the species diffusivity ...
bool m_radi_temp_ok
Boolean indicating that temperature dependence of hydrodynamic radius is current. ...
virtual void selfDiffusion(doublereal *const selfDiff)
Returns the self diffusion coefficients of the species in the phase.
virtual bool initLiquid(LiquidTransportParams &tr)
Initialize the transport object.
bool m_selfDiff_mix_ok
Boolean indicating that the top-level mixture self diffusion is current.
LiquidTranInteraction * m_diffMixModel
Species diffusivity of the mixture expressed as a subclass of LiquidTranInteraction.
vector_fp m_volume_spec
Specific volume for each species. Local copy from thermo object.
std::vector< Cantera::LiquidTransportData > LTData
Species transport parameters.
vector_fp m_mobRatMix
Saved values of the mixture mobility ratios.
size_t nSpecies() const
Returns the number of species in the phase.
Definition: Phase.h:252
vector_fp m_massfracs_tran
Local copy of the mass fractions of the species in the phase.
virtual doublereal pressure() const
Return the thermodynamic pressure (Pa).
Definition: ThermoPhase.h:314
virtual void getSpeciesVdiffExt(size_t ldf, doublereal *Vdiff)
Return the species diffusive velocities relative to the averaged velocity.
std::vector< LTPspecies * > m_lambdaTempDep_Ns
Thermal conductivity for each species expressed as an appropriate subclass of LTPspecies.
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
vector_fp m_actCoeff
Vector of activity coefficients.
bool m_visc_mix_ok
Boolean indicating that the top-level mixture viscosity is current.
doublereal concTot_tran_
Local copy of the total concentration.
int mode_
Mode parameter.
Header file defining class LiquidTransport.
void updateMobilityRatio_T()
Updates the array of pure species mobility ratios internally.
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
virtual Transport * duplMyselfAsTransport() const
Duplication routine for objects which inherit from Transport.
vector_fp m_hydrodynamic_radius
Species hydrodynamic radius.
const doublereal Tiny
Small number to compare differences of mole fractions against.
Definition: ct_defs.h:155
std::vector< LTPspecies * > mobilityRatio
Model type for the mobility ratio.
LiquidTranInteraction * m_ionCondMixModel
Ionic Conductivity of the mixture expressed as a subclass of LiquidTranInteraction.
void updateViscosities_C()
Update the concentration parts of the viscosities.
DenseMatrix m_selfDiffSpecies
Internal value of the species self diffusion coefficients.
virtual void getMixDiffCoeffs(doublereal *const d)
Get the Mixture diffusion coefficients.
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
virtual bool update_C()
Returns true if mixture composition has changed, in which case flags are set to recompute transport p...
LiquidTransport(thermo_t *thermo=0, int ndim=1)
Default constructor.
LTPspecies * hydroRadius
Model type for the hydroradius.
vector_fp m_concentrations
Local copy of the concentrations of the species in the phase.
vector_fp m_selfDiffMix
Saved values of the mixture self diffusion coefficients.
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
Definition: ThermoPhase.h:553
virtual int activityConvention() const
This method returns the convention used in specification of the activities, of which there are curren...
Contains declarations for string manipulation functions within Cantera.
vector_fp m_molefracs_tran
Non-zero mole fraction vector used in transport property calculations.
std::vector< LTPspecies * > selfDiffusion
Model type for the self diffusion coefficients.
#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.
const VelocityBasis VB_MASSAVG
Diffusion velocities are based on the mass averaged velocity.
Definition: TransportBase.h:91
virtual void getSpeciesIonConductivity(doublereal *const ionCond)
Returns the pure species ionic conductivities for all species.
void updateHydrodynamicRadius_T()
Update the temperature-dependent hydrodynamic radius terms for each species internally.
bool m_ionCond_temp_ok
Boolean indicating that weight factors wrt ionic conductivty is current.
void updateIonConductivity_T()
Update the temperature-dependent ionic conductivity terms for each species internally.
virtual void mobilityRatio(doublereal *mobRat)
Returns the pointer to the mobility ratios of the binary combinations of the transported species for ...
DenseMatrix m_A
Matrix for the stefan maxwell equation.
LTPspecies * ionConductivity
Model type for the ionic conductivity.
doublereal m_lambda
Saved value of the mixture thermal conductivity.
virtual doublereal getElectricConduct()
Compute the mixture electrical conductivity from the Stefan-Maxwell equation.
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_massfracs
Local copy of the mass fractions of the species in the phase.
vector_fp m_viscSpecies
Internal value of the species viscosities.
virtual void getSpeciesHydrodynamicRadius(doublereal *const radius)
Returns the hydrodynamic radius for all species.
virtual void getSpeciesFluxesES(size_t ndim, const doublereal *grad_T, size_t ldx, const doublereal *grad_X, size_t ldf, const doublereal *grad_Phi, doublereal *fluxes)
Return the species diffusive mass fluxes wrt to the averaged velocity in [kmol/m^2/s].
LiquidTranInteraction * thermalCond
Pointer to the LiquidTranInteraction object which handles the calculation of the mixture thermal cond...
int m_velocityBasis
Velocity basis from which diffusion velocities are computed.
std::string speciesName(size_t k) const
Name of the species with index k.
Definition: Phase.cpp:246
const doublereal Boltzmann
Boltzmann's constant [J/K].
Definition: ct_defs.h:78
Array2D m_flux
Solution of the Stefan Maxwell equation in terms of flux.
doublereal concTot_
Local copy of the total concentration.
LiquidTranInteraction * m_viscMixModel
Viscosity of the mixture expressed as a subclass of LiquidTranInteraction.
bool m_mobRat_mix_ok
Boolean indicating that the top-level mixture mobility ratio is current.
std::vector< LTPspecies * > m_diffTempDep_Ns
(NOT USED IN LiquidTransport.) Diffusion coefficient model for each species expressed as an appropria...
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
DenseMatrix m_bdiff
Array of Binary Diffusivities.
DenseMatrix m_mobRatSpecies
Internal value of the species mobility ratios.