Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
8 #include <cstdio>
9 
10 using namespace std;
11 
12 namespace Cantera
13 {
14 LiquidTransport::LiquidTransport(thermo_t* thermo, int ndim) :
15  Transport(thermo, ndim),
16  m_nsp2(0),
17  m_viscMixModel(0),
18  m_ionCondMixModel(0),
19  m_lambdaMixModel(0),
20  m_diffMixModel(0),
21  m_radiusMixModel(0),
22  m_iStateMF(-1),
23  concTot_(0.0),
24  concTot_tran_(0.0),
25  dens_(0.0),
26  m_temp(-1.0),
27  m_press(-1.0),
28  m_lambda(-1.0),
29  m_viscmix(-1.0),
30  m_ionCondmix(-1.0),
31  m_visc_mix_ok(false),
32  m_visc_temp_ok(false),
33  m_visc_conc_ok(false),
34  m_ionCond_mix_ok(false),
35  m_ionCond_temp_ok(false),
36  m_ionCond_conc_ok(false),
37  m_mobRat_mix_ok(false),
38  m_mobRat_temp_ok(false),
39  m_mobRat_conc_ok(false),
40  m_selfDiff_mix_ok(false),
41  m_selfDiff_temp_ok(false),
42  m_selfDiff_conc_ok(false),
43  m_radi_mix_ok(false),
44  m_radi_temp_ok(false),
45  m_radi_conc_ok(false),
46  m_diff_mix_ok(false),
47  m_diff_temp_ok(false),
48  m_lambda_temp_ok(false),
49  m_lambda_mix_ok(false),
50  m_mode(-1000),
51  m_debug(false)
52 {
53 }
54 
56  Transport(right.m_thermo, right.m_nDim),
57  m_nsp2(0),
58  m_viscMixModel(0),
59  m_ionCondMixModel(0),
60  m_lambdaMixModel(0),
61  m_diffMixModel(0),
62  m_radiusMixModel(0),
63  m_iStateMF(-1),
64  concTot_(0.0),
65  concTot_tran_(0.0),
66  dens_(0.0),
67  m_temp(-1.0),
68  m_press(-1.0),
69  m_lambda(-1.0),
70  m_viscmix(-1.0),
71  m_ionCondmix(-1.0),
72  m_visc_mix_ok(false),
73  m_visc_temp_ok(false),
74  m_visc_conc_ok(false),
75  m_ionCond_mix_ok(false),
76  m_ionCond_temp_ok(false),
77  m_ionCond_conc_ok(false),
78  m_mobRat_mix_ok(false),
79  m_mobRat_temp_ok(false),
80  m_mobRat_conc_ok(false),
81  m_selfDiff_mix_ok(false),
82  m_selfDiff_temp_ok(false),
83  m_selfDiff_conc_ok(false),
84  m_radi_mix_ok(false),
85  m_radi_temp_ok(false),
86  m_radi_conc_ok(false),
87  m_diff_mix_ok(false),
88  m_diff_temp_ok(false),
89  m_lambda_temp_ok(false),
90  m_lambda_mix_ok(false),
91  m_mode(-1000),
92  m_debug(false)
93 {
94  /*
95  * Use the assignment operator to do the brunt
96  * of the work for the copy constructor.
97  */
98  *this = right;
99 }
100 
101 LiquidTransport& LiquidTransport::operator=(const LiquidTransport& right)
102 {
103  if (&right == this) {
104  return *this;
105  }
106  Transport::operator=(right);
107  m_nsp2 = right.m_nsp2;
108  m_mw = right.m_mw;
109  m_viscTempDep_Ns = right.m_viscTempDep_Ns;
110  m_ionCondTempDep_Ns = right.m_ionCondTempDep_Ns;
111  m_mobRatTempDep_Ns = right.m_mobRatTempDep_Ns;
112  m_selfDiffTempDep_Ns = right.m_selfDiffTempDep_Ns;
113  m_lambdaTempDep_Ns = right.m_lambdaTempDep_Ns;
114  m_diffTempDep_Ns = right.m_diffTempDep_Ns;
115  m_radiusTempDep_Ns = right.m_radiusTempDep_Ns;
116  m_hydrodynamic_radius = right.m_hydrodynamic_radius;
117  m_Grad_X = right.m_Grad_X;
118  m_Grad_T = right.m_Grad_T;
119  m_Grad_V = right.m_Grad_V;
120  m_Grad_mu = right.m_Grad_mu;
121  m_bdiff = right.m_bdiff;
122  m_viscSpecies = right.m_viscSpecies;
123  m_ionCondSpecies = right.m_ionCondSpecies;
124  m_mobRatSpecies = right.m_mobRatSpecies;
125  m_selfDiffSpecies = right.m_selfDiffSpecies;
126  m_hydrodynamic_radius = right.m_hydrodynamic_radius;
127  m_lambdaSpecies = right.m_lambdaSpecies;
128  m_viscMixModel = right.m_viscMixModel;
129  m_ionCondMixModel = right.m_ionCondMixModel;
130  m_mobRatMixModel = right.m_mobRatMixModel;
131  m_selfDiffMixModel = right.m_selfDiffMixModel;
132  m_lambdaMixModel = right.m_lambdaMixModel;
133  m_diffMixModel = right.m_diffMixModel;
134  m_iStateMF = -1;
135  m_massfracs = right.m_massfracs;
136  m_massfracs_tran = right.m_massfracs_tran;
137  m_molefracs = right.m_molefracs;
138  m_molefracs_tran = right.m_molefracs_tran;
139  m_concentrations = right.m_concentrations;
140  m_actCoeff = right.m_actCoeff;
141  m_Grad_lnAC = right.m_Grad_lnAC;
142  m_chargeSpecies = right.m_chargeSpecies;
143  m_B = right.m_B;
144  m_A = right.m_A;
145  m_temp = right.m_temp;
146  m_press = right.m_press;
147  m_flux = right.m_flux;
148  m_Vdiff = right.m_Vdiff;
149  m_lambda = right.m_lambda;
150  m_viscmix = right.m_viscmix;
151  m_ionCondmix = right.m_ionCondmix;
152  m_mobRatMix = right.m_mobRatMix;
153  m_selfDiffMix = right.m_selfDiffMix;
154  m_spwork = right.m_spwork;
155  m_visc_mix_ok = false;
156  m_visc_temp_ok = false;
157  m_visc_conc_ok = false;
158  m_ionCond_mix_ok = false;
159  m_ionCond_temp_ok = false;
160  m_ionCond_conc_ok = false;
161  m_mobRat_mix_ok = false;
162  m_mobRat_temp_ok = false;
163  m_mobRat_conc_ok = false;
164  m_selfDiff_mix_ok = false;
165  m_selfDiff_temp_ok = false;
166  m_selfDiff_conc_ok = false;
167  m_radi_mix_ok = false;
168  m_radi_temp_ok = false;
169  m_radi_conc_ok = false;
170  m_diff_mix_ok = false;
171  m_diff_temp_ok = false;
172  m_lambda_temp_ok = false;
173  m_lambda_mix_ok = false;
174  m_mode = right.m_mode;
175  m_debug = right.m_debug;
176  m_nDim = right.m_nDim;
177 
178  return *this;
179 }
180 
182 {
183  return new LiquidTransport(*this);
184 }
185 
186 LiquidTransport::~LiquidTransport()
187 {
188  //These are constructed in TransportFactory::newLTP
189  for (size_t k = 0; k < m_nsp; k++) {
190  delete m_viscTempDep_Ns[k];
191  delete m_ionCondTempDep_Ns[k];
192  for (size_t l = 0; l < m_nsp; l++) {
193  delete m_selfDiffTempDep_Ns[l][k];
194  }
195  for (size_t l=0; l < m_nsp2; l++) {
196  delete m_mobRatTempDep_Ns[l][k];
197  }
198  delete m_lambdaTempDep_Ns[k];
199  delete m_radiusTempDep_Ns[k];
200  delete m_diffTempDep_Ns[k];
201  //These are constructed in TransportFactory::newLTI
202  delete m_selfDiffMixModel[k];
203  }
204 
205  for (size_t k = 0; k < m_nsp2; k++) {
206  delete m_mobRatMixModel[k];
207  }
208 
209  delete m_viscMixModel;
210  delete m_ionCondMixModel;
211  delete m_lambdaMixModel;
212  delete m_diffMixModel;
213 }
214 
216 {
217  //
218  // Transfer quantitities from the database to the Transport object
219  //
220  m_thermo = tr.thermo;
222  m_nsp = m_thermo->nSpecies();
223  m_nsp2 = m_nsp*m_nsp;
224  //
225  // Resize the local storage according to the number of species
226  //
227  m_mw.resize(m_nsp, 0.0);
228  m_viscSpecies.resize(m_nsp, 0.0);
229  m_viscTempDep_Ns.resize(m_nsp, 0);
230  m_ionCondSpecies.resize(m_nsp, 0.0);
231  m_ionCondTempDep_Ns.resize(m_nsp, 0);
232  m_mobRatTempDep_Ns.resize(m_nsp2);
233  m_mobRatMixModel.resize(m_nsp2);
234  m_mobRatSpecies.resize(m_nsp2, m_nsp, 0.0);
235  m_mobRatMix.resize(m_nsp2,0.0);
236  m_selfDiffTempDep_Ns.resize(m_nsp);
237  m_selfDiffMixModel.resize(m_nsp);
238  m_selfDiffSpecies.resize(m_nsp, m_nsp, 0.0);
239  m_selfDiffMix.resize(m_nsp,0.0);
240  for (size_t k = 0; k < m_nsp; k++) {
241  m_selfDiffTempDep_Ns[k].resize(m_nsp, 0);
242  }
243  for (size_t k = 0; k < m_nsp2; k++) {
244  m_mobRatTempDep_Ns[k].resize(m_nsp, 0);
245  }
246  m_lambdaSpecies.resize(m_nsp, 0.0);
247  m_lambdaTempDep_Ns.resize(m_nsp, 0);
248  m_hydrodynamic_radius.resize(m_nsp, 0.0);
249  m_radiusTempDep_Ns.resize(m_nsp, 0);
250  //
251  // Make a local copy of the molecular weights
252  //
253  copy(m_thermo->molecularWeights().begin(), m_thermo->molecularWeights().end(), m_mw.begin());
254  //
255  // First populate mixing rules and indices
256  // (NOTE, we transfer pointers of malloced quantities. We zero out pointers so that
257  // we only have one copy of the malloced quantity)
258  //
259  for (size_t k = 0; k < m_nsp; k++) {
261  tr.selfDiffusion[k] = 0;
262  }
263  for (size_t k = 0; k < m_nsp2; k++) {
264  m_mobRatMixModel[k] = tr.mobilityRatio[k];
265  tr.mobilityRatio[k] = 0;
266  }
267 
268  //for each species, assign viscosity model and coefficients
269  for (size_t k = 0; k < m_nsp; k++) {
271  m_viscTempDep_Ns[k] = ltd.viscosity;
272  ltd.viscosity = 0;
274  ltd.ionConductivity = 0;
275  for (size_t j = 0; j < m_nsp2; j++) {
276  m_mobRatTempDep_Ns[j][k] = ltd.mobilityRatio[j];
277  ltd.mobilityRatio[j] = 0;
278  }
279  for (size_t j = 0; j < m_nsp; j++) {
280  m_selfDiffTempDep_Ns[j][k] = ltd.selfDiffusion[j];
281  ltd.selfDiffusion[j] = 0;
282  }
284  ltd.thermalCond = 0;
286  ltd.hydroRadius = 0;
287  }
288 
289 
290  /*
291  * Get the input Species Diffusivities
292  * Note that species diffusivities are not what is needed.
293  * Rather the Stefan Boltzmann interaction parameters are
294  * needed for the current model. This section may, therefore,
295  * be extraneous.
296  */
297  m_diffTempDep_Ns.resize(m_nsp, 0);
298  //for each species, assign viscosity model and coefficients
299  for (size_t k = 0; k < m_nsp; k++) {
301  if (ltd.speciesDiffusivity != 0) {
302  cout << "Warning: diffusion coefficient data for "
303  << m_thermo->speciesName(k)
304  << endl
305  << "in the input file is not used for LiquidTransport model."
306  << endl
307  << "LiquidTransport model uses Stefan-Maxwell interaction "
308  << endl
309  << "parameters defined in the <transport> input block."
310  << endl;
311  }
312  }
313 
314  /*
315  * Here we get interaction parameters from LiquidTransportParams
316  * that were filled in TransportFactory::getLiquidInteractionsTransportData
317  * Interaction models are provided here for viscosity, thermal conductivity,
318  * species diffusivity and hydrodynamics radius (perhaps not needed in the
319  * present class).
320  */
321 
322 
324  tr.viscosity = 0;
325 
327  tr.ionConductivity = 0;
328 
330  tr.thermalCond = 0;
331 
333  tr.speciesDiffusivity = 0;
334  if (! m_diffMixModel) {
335  throw CanteraError("LiquidTransport::initLiquid()",
336  "A speciesDiffusivity model is required in the transport block for the phase, but none was provided");
337  }
338 
339  m_bdiff.resize(m_nsp,m_nsp, 0.0);
340 
341  //Don't really need to update this here.
342  //It is updated in updateDiff_T()
343  m_diffMixModel->getMatrixTransProp(m_bdiff);
344 
345 
346  m_mode = tr.mode_;
347 
348  m_massfracs.resize(m_nsp, 0.0);
349  m_massfracs_tran.resize(m_nsp, 0.0);
350  m_molefracs.resize(m_nsp, 0.0);
351  m_molefracs_tran.resize(m_nsp, 0.0);
352  m_concentrations.resize(m_nsp, 0.0);
353  m_actCoeff.resize(m_nsp, 0.0);
354  m_chargeSpecies.resize(m_nsp, 0.0);
355  for (size_t i = 0; i < m_nsp; i++) {
357  }
358  m_volume_spec.resize(m_nsp, 0.0);
359  m_Grad_lnAC.resize(m_nDim * m_nsp, 0.0);
360  m_spwork.resize(m_nsp, 0.0);
361 
362  // resize the internal gradient variables
363  m_Grad_X.resize(m_nDim * m_nsp, 0.0);
364  m_Grad_T.resize(m_nDim, 0.0);
365  m_Grad_V.resize(m_nDim, 0.0);
366  m_Grad_mu.resize(m_nDim * m_nsp, 0.0);
367 
368  m_flux.resize(m_nsp, m_nDim, 0.0);
369  m_Vdiff.resize(m_nsp, m_nDim, 0.0);
370 
371 
372  // set all flags to false
373  m_visc_mix_ok = false;
374  m_visc_temp_ok = false;
375  m_visc_conc_ok = false;
376  m_ionCond_mix_ok = false;
377  m_ionCond_temp_ok = false;
378  m_ionCond_conc_ok = false;
379  m_mobRat_mix_ok = false;
380  m_mobRat_temp_ok = false;
381  m_mobRat_conc_ok = false;
382  m_selfDiff_mix_ok = false;
383  m_selfDiff_temp_ok = false;
384  m_selfDiff_conc_ok = false;
385  m_radi_temp_ok = false;
386  m_radi_conc_ok = false;
387  m_lambda_temp_ok = false;
388  m_lambda_mix_ok = false;
389  m_diff_temp_ok = false;
390  m_diff_mix_ok = false;
391 
392  return true;
393 }
394 
396 {
397  update_T();
398  update_C();
399 
400  if (m_visc_mix_ok) {
401  return m_viscmix;
402  }
403 
404  ////// LiquidTranInteraction method
406 
407  return m_viscmix;
408 }
409 
410 void LiquidTransport::getSpeciesViscosities(doublereal* const visc)
411 {
412  update_T();
413  if (!m_visc_temp_ok) {
415  }
416  copy(m_viscSpecies.begin(), m_viscSpecies.end(), visc);
417 }
418 
420 {
421  update_T();
422  update_C();
423 
424  if (m_ionCond_mix_ok) {
425  return m_ionCondmix;
426  }
427 
428  ////// LiquidTranInteraction method
430 
431  return m_ionCondmix;
432 }
433 
435 {
436  update_T();
437  if (!m_ionCond_temp_ok) {
439  }
440  copy(m_ionCondSpecies.begin(), m_ionCondSpecies.end(), ionCond);
441 }
442 
443 void LiquidTransport::mobilityRatio(doublereal* mobRat)
444 {
445 
446  update_T();
447  update_C();
448 
449  // LiquidTranInteraction method
450  if (!m_mobRat_mix_ok) {
451  for (size_t k = 0; k < m_nsp2; k++) {
452  if (m_mobRatMixModel[k]) {
453  m_mobRatMix[k] = m_mobRatMixModel[k]->getMixTransProp(m_mobRatTempDep_Ns[k]);
454  if (m_mobRatMix[k] > 0.0) {
455  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
456  }
457  }
458  }
459  }
460  for (size_t k = 0; k < m_nsp2; k++) {
461  mobRat[k] = m_mobRatMix[k];
462  }
463 }
464 
466 {
467  update_T();
468  if (!m_mobRat_temp_ok) {
470  }
471  for (size_t k = 0; k < m_nsp2; k++) {
472  for (size_t j = 0; j < m_nsp; j++) {
473  mobRat[k][j] = m_mobRatSpecies(k,j);
474  }
475  }
476 }
477 
478 void LiquidTransport::selfDiffusion(doublereal* const selfDiff)
479 {
480  update_T();
481  update_C();
482  if (!m_selfDiff_mix_ok) {
483  for (size_t k = 0; k < m_nsp; k++) {
484  m_selfDiffMix[k] = m_selfDiffMixModel[k]->getMixTransProp(m_selfDiffTempDep_Ns[k]);
485  }
486  }
487  for (size_t k = 0; k < m_nsp; k++) {
488  selfDiff[k] = m_selfDiffMix[k];
489  }
490 }
491 
492 void LiquidTransport::getSpeciesSelfDiffusion(doublereal** selfDiff)
493 {
494  update_T();
495  if (!m_selfDiff_temp_ok) {
497  }
498  for (size_t k=0; k<m_nsp; k++) {
499  for (size_t j=0; j < m_nsp; j++) {
500  selfDiff[k][j] = m_selfDiffSpecies(k,j);
501  }
502  }
503 }
504 
505 void LiquidTransport::getSpeciesHydrodynamicRadius(doublereal* const radius)
506 {
507  update_T();
508  if (!m_radi_temp_ok) {
510  }
511  copy(m_hydrodynamic_radius.begin(), m_hydrodynamic_radius.end(), radius);
512 
513 }
514 
516 {
517 
518  update_T();
519  update_C();
520 
521  if (!m_lambda_mix_ok) {
523  m_cond_mix_ok = true;
524  }
525 
526  return m_lambda;
527 }
528 
529 void LiquidTransport::getThermalDiffCoeffs(doublereal* const dt)
530 {
531  for (size_t k = 0; k < m_nsp; k++) {
532  dt[k] = 0.0;
533  }
534 }
535 
536 void LiquidTransport::getBinaryDiffCoeffs(size_t ld, doublereal* d)
537 {
538  if (ld != m_nsp)
539  throw CanteraError("LiquidTransport::getBinaryDiffCoeffs",
540  "First argument does not correspond to number of species in model.\nDiff Coeff matrix may be misdimensioned");
541  update_T();
542 
543  // if necessary, evaluate the binary diffusion coefficients
544  // from the polynomial fits
545  if (!m_diff_temp_ok) {
546  updateDiff_T();
547  }
548 
549  for (size_t i = 0; i < m_nsp; i++) {
550  for (size_t j = 0; j < m_nsp; j++) {
551  d[ld*j + i] = 1.0 / m_bdiff(i,j);
552 
553  }
554  }
555 }
556 
557 void LiquidTransport::getMobilities(doublereal* const mobil)
558 {
560  doublereal c1 = ElectronCharge / (Boltzmann * m_temp);
561  for (size_t k = 0; k < m_nsp; k++) {
562  mobil[k] = c1 * m_spwork[k];
563  }
564 }
565 
566 void LiquidTransport::getFluidMobilities(doublereal* const mobil_f)
567 {
569  doublereal c1 = 1.0 / (GasConstant * m_temp);
570  for (size_t k = 0; k < m_nsp; k++) {
571  mobil_f[k] = c1 * m_spwork[k];
572  }
573 }
574 
575 void LiquidTransport::set_Grad_T(const doublereal* grad_T)
576 {
577  for (size_t a = 0; a < m_nDim; a++) {
578  m_Grad_T[a] = grad_T[a];
579  }
580 }
581 
582 void LiquidTransport::set_Grad_V(const doublereal* grad_V)
583 {
584  for (size_t a = 0; a < m_nDim; a++) {
585  m_Grad_V[a] = grad_V[a];
586  }
587 }
588 
589 void LiquidTransport::set_Grad_X(const doublereal* grad_X)
590 {
591  size_t itop = m_nDim * m_nsp;
592  for (size_t i = 0; i < itop; i++) {
593  m_Grad_X[i] = grad_X[i];
594  }
595 }
596 
598 {
599  vector_fp gradT(m_nDim,0.0);
600  vector_fp gradX(m_nDim * m_nsp);
601  vector_fp gradV(m_nDim);
602  for (size_t i = 0; i < m_nDim; i++) {
603  for (size_t k = 0; k < m_nsp; k++) {
604  gradX[ i*m_nDim + k] = 0.0;
605  }
606  gradV[i] = 1.0;
607  }
608 
609  set_Grad_T(&gradT[0]);
610  set_Grad_X(&gradX[0]);
611  set_Grad_V(&gradV[0]);
612 
613  vector_fp fluxes(m_nsp * m_nDim);
614  doublereal current;
615 
616  getSpeciesFluxesExt(m_nDim, &fluxes[0]);
617 
618  //sum over species charges, fluxes, Faraday to get current
619  // Since we want the scalar conductivity, we need only consider one-dim
620  for (size_t i = 0; i < 1; i++) {
621  current = 0.0;
622  for (size_t k = 0; k < m_nsp; k++) {
623  current += m_chargeSpecies[k] * Faraday * fluxes[k] / m_mw[k];
624  }
625  //divide by unit potential gradient
626  current /= - gradV[i];
627  }
628  return current;
629 }
630 
632  const doublereal* grad_T,
633  int ldx,
634  const doublereal* grad_X,
635  int ldf,
636  const doublereal* grad_V,
637  doublereal* current)
638 {
639  set_Grad_T(grad_T);
640  set_Grad_X(grad_X);
641  set_Grad_V(grad_V);
642 
643  vector_fp fluxes(m_nsp * m_nDim);
644 
645  getSpeciesFluxesExt(ldf, &fluxes[0]);
646 
647  //sum over species charges, fluxes, Faraday to get current
648  for (size_t i = 0; i < m_nDim; i++) {
649  current[i] = 0.0;
650  for (size_t k = 0; k < m_nsp; k++) {
651  current[i] += m_chargeSpecies[k] * Faraday * fluxes[k] / m_mw[k];
652  }
653  //divide by unit potential gradient
654  }
655 }
656 
658  const doublereal* grad_T,
659  int ldx, const doublereal* grad_X,
660  int ldf, doublereal* Vdiff)
661 {
662  set_Grad_T(grad_T);
663  set_Grad_X(grad_X);
664  getSpeciesVdiffExt(ldf, Vdiff);
665 }
666 
668  const doublereal* grad_T,
669  int ldx,
670  const doublereal* grad_X,
671  int ldf,
672  const doublereal* grad_V,
673  doublereal* Vdiff)
674 {
675  set_Grad_T(grad_T);
676  set_Grad_X(grad_X);
677  set_Grad_V(grad_V);
678  getSpeciesVdiffExt(ldf, Vdiff);
679 }
680 
682  const doublereal* const grad_T,
683  size_t ldx, const doublereal* const grad_X,
684  size_t ldf, doublereal* const fluxes)
685 {
686  set_Grad_T(grad_T);
687  set_Grad_X(grad_X);
688  getSpeciesFluxesExt(ldf, fluxes);
689 }
690 
692  const doublereal* grad_T,
693  size_t ldx,
694  const doublereal* grad_X,
695  size_t ldf,
696  const doublereal* grad_V,
697  doublereal* fluxes)
698 {
699  set_Grad_T(grad_T);
700  set_Grad_X(grad_X);
701  set_Grad_V(grad_V);
702  getSpeciesFluxesExt(ldf, fluxes);
703 }
704 
705 void LiquidTransport::getSpeciesVdiffExt(size_t ldf, doublereal* Vdiff)
706 {
708 
709  for (size_t n = 0; n < m_nDim; n++) {
710  for (size_t k = 0; k < m_nsp; k++) {
711  Vdiff[n*ldf + k] = m_Vdiff(k,n);
712  }
713  }
714 }
715 
716 void LiquidTransport::getSpeciesFluxesExt(size_t ldf, doublereal* fluxes)
717 {
719 
720  for (size_t n = 0; n < m_nDim; n++) {
721  for (size_t k = 0; k < m_nsp; k++) {
722  fluxes[n*ldf + k] = m_flux(k,n);
723  }
724  }
725 }
726 
727 void LiquidTransport::getMixDiffCoeffs(doublereal* const d)
728 {
730 
731  for (size_t n = 0; n < m_nDim; n++) {
732  for (size_t k = 0; k < m_nsp; k++) {
733  if (m_Grad_X[n*m_nsp + k] != 0.0) {
734  d[n*m_nsp + k] = - m_Vdiff(k,n) * m_molefracs[k]
735  / m_Grad_X[n*m_nsp + k];
736  } else {
737  //avoid divide by zero with nonsensical response
738  d[n*m_nsp + k] = - 1.0;
739  }
740  }
741  }
742 }
743 
745 {
746  // First make a decision about whether we need to recalculate
747  doublereal t = m_thermo->temperature();
748  if (t == m_temp) {
749  return false;
750  }
751 
752  // Next do a reality check on temperature value
753  if (t < 0.0) {
754  throw CanteraError("LiquidTransport::update_T()",
755  "negative temperature "+fp2str(t));
756  }
757 
758  // Compute various direct functions of temperature
759  m_temp = t;
760 
761  // temperature has changed so temp flags are flipped
762  m_visc_temp_ok = false;
763  m_ionCond_temp_ok = false;
764  m_mobRat_temp_ok = false;
765  m_selfDiff_temp_ok = false;
766  m_radi_temp_ok = false;
767  m_diff_temp_ok = false;
768  m_lambda_temp_ok = false;
769 
770  // temperature has changed, so polynomial temperature
771  // interpolations will need to be reevaluated.
772  // This means that many concentration
773  m_visc_conc_ok = false;
774  m_ionCond_conc_ok = false;
775  m_mobRat_conc_ok = false;
776  m_selfDiff_conc_ok = false;
777 
778  // Mixture stuff needs to be evaluated
779  m_visc_mix_ok = false;
780  m_ionCond_mix_ok = false;
781  m_mobRat_mix_ok = false;
782  m_selfDiff_mix_ok = false;
783  m_diff_mix_ok = false;
784  m_lambda_mix_ok = false; //(don't need it because a lower lvl flag is set
785  return true;
786 }
787 
789 {
790  // If the pressure has changed then the concentrations
791  // have changed.
792  doublereal pres = m_thermo->pressure();
793  bool qReturn = true;
794  if (pres != m_press) {
795  qReturn = false;
796  m_press = pres;
797  }
798  int iStateNew = m_thermo->stateMFNumber();
799  if (iStateNew != m_iStateMF) {
800  qReturn = false;
804  concTot_ = 0.0;
805  concTot_tran_ = 0.0;
806  for (size_t k = 0; k < m_nsp; k++) {
807  m_molefracs[k] = std::max(0.0, m_molefracs[k]);
808  m_molefracs_tran[k] = std::max(Tiny, m_molefracs[k]);
809  m_massfracs_tran[k] = std::max(Tiny, m_massfracs[k]);
812  }
813  dens_ = m_thermo->density();
816  }
817  if (qReturn) {
818  return false;
819  }
820 
821  // signal that concentration-dependent quantities will need to
822  // be recomputed before use, and update the local mole
823  // fractions.
824  m_visc_conc_ok = false;
825  m_ionCond_conc_ok = false;
826  m_mobRat_conc_ok = false;
827  m_selfDiff_conc_ok = false;
828 
829  // Mixture stuff needs to be evaluated
830  m_visc_mix_ok = false;
831  m_ionCond_mix_ok = false;
832  m_mobRat_mix_ok = false;
833  m_selfDiff_mix_ok = false;
834  m_diff_mix_ok = false;
835  m_lambda_mix_ok = false;
836 
837  return true;
838 }
839 
841 {
842  for (size_t k = 0; k < m_nsp; k++) {
843  m_lambdaSpecies[k] = m_lambdaTempDep_Ns[k]->getSpeciesTransProp() ;
844  }
845  m_lambda_temp_ok = true;
846  m_lambda_mix_ok = false;
847 }
848 
850 {
851  m_diffMixModel->getMatrixTransProp(m_bdiff);
852  m_diff_temp_ok = true;
853  m_diff_mix_ok = false;
854 }
855 
857 {
858  m_visc_conc_ok = true;
859 }
860 
862 {
863  for (size_t k = 0; k < m_nsp; k++) {
864  m_viscSpecies[k] = m_viscTempDep_Ns[k]->getSpeciesTransProp() ;
865  }
866  m_visc_temp_ok = true;
867  m_visc_mix_ok = false;
868 }
869 
871 {
872  m_ionCond_conc_ok = true;
873 }
874 
876 {
877  for (size_t k = 0; k < m_nsp; k++) {
878  m_ionCondSpecies[k] = m_ionCondTempDep_Ns[k]->getSpeciesTransProp() ;
879  }
880  m_ionCond_temp_ok = true;
881  m_ionCond_mix_ok = false;
882 }
883 
885 {
886  m_mobRat_conc_ok = true;
887 }
888 
890 {
891  for (size_t k = 0; k < m_nsp2; k++) {
892  for (size_t j = 0; j < m_nsp; j++) {
893  m_mobRatSpecies(k,j) = m_mobRatTempDep_Ns[k][j]->getSpeciesTransProp();
894  }
895  }
896  m_mobRat_temp_ok = true;
897  m_mobRat_mix_ok = false;
898 }
899 
901 {
902  m_selfDiff_conc_ok = true;
903 }
904 
906 {
907  for (size_t k = 0; k < m_nsp2; k++) {
908  for (size_t j = 0; j < m_nsp; j++) {
909  m_selfDiffSpecies(k,j) = m_selfDiffTempDep_Ns[k][j]->getSpeciesTransProp() ;
910  }
911  }
912  m_selfDiff_temp_ok = true;
913  m_selfDiff_mix_ok = false;
914 }
915 
917 {
918  m_radi_conc_ok = true;
919 }
920 
922 {
923  for (size_t k = 0; k < m_nsp; k++) {
924  m_hydrodynamic_radius[k] = m_radiusTempDep_Ns[k]->getSpeciesTransProp() ;
925  }
926  m_radi_temp_ok = true;
927  m_radi_mix_ok = false;
928 }
929 
931 {
932  doublereal grad_T;
933  for (size_t k = 0; k < m_nDim; k++) {
934  grad_T = m_Grad_T[k];
935  size_t start = m_nsp*k;
936  m_thermo->getdlnActCoeffds(grad_T, &(m_Grad_X[start]), &(m_Grad_lnAC[start]));
937  for (size_t i = 0; i < m_nsp; i++)
938  if (m_molefracs[i] < 1.e-15) {
939  m_Grad_lnAC[start+i] = 0;
940  } else {
941  m_Grad_lnAC[start+i] += m_Grad_X[start+i]/m_molefracs[i];
942  }
943  }
944 
945  return;
946 }
947 
949 {
950  doublereal tmp;
951  m_B.resize(m_nsp, m_nDim, 0.0);
952  m_A.resize(m_nsp, m_nsp, 0.0);
953 
954  //! grab a local copy of the molecular weights
955  const vector_fp& M = m_thermo->molecularWeights();
956  //! grad a local copy of the ion molar volume (inverse total ion concentration)
957  const doublereal vol = m_thermo->molarVolume();
958 
959  /*
960  * Update the temperature, concentrations and diffusion coefficients in the mixture.
961  */
962  update_T();
963  update_C();
964  if (!m_diff_temp_ok) {
965  updateDiff_T();
966  }
967 
968  double T = m_thermo->temperature();
969 
970  update_Grad_lnAC() ;
971 
973 
974  /*
975  * Calculate the electrochemical potential gradient. This is the
976  * driving force for relative diffusional transport.
977  *
978  * Here we calculate
979  *
980  * X_i * (grad (mu_i) + S_i grad T - M_i / dens * grad P
981  *
982  * This is Eqn. 13-1 p. 318 Newman. The original equation is from
983  * Hershfeld, Curtis, and Bird.
984  *
985  * S_i is the partial molar entropy of species i. This term will cancel
986  * out a lot of the grad T terms in grad (mu_i), therefore simplifying
987  * the expression.
988  *
989  * Ok I think there may be many ways to do this. One way is to do it via basis
990  * functions, at the nodes, as a function of the variables in the problem.
991  *
992  * For calculation of molality based thermo systems, we current get
993  * the molar based values. This may change.
994  *
995  * Note, we have broken the symmetry of the matrix here, due to
996  * considerations involving species concentrations going to zero.
997  *
998  */
999  for (size_t a = 0; a < m_nDim; a++) {
1000  for (size_t i = 0; i < m_nsp; i++) {
1001  m_Grad_mu[a*m_nsp + i] =
1002  m_chargeSpecies[i] * Faraday * m_Grad_V[a]
1003  + GasConstant * T * m_Grad_lnAC[a*m_nsp+i];
1004  }
1005  }
1006 
1008  int iSolvent = 0;
1009  double mwSolvent = m_thermo->molecularWeight(iSolvent);
1010  double mnaught = mwSolvent/ 1000.;
1011  double lnmnaught = log(mnaught);
1012  for (size_t a = 0; a < m_nDim; a++) {
1013  for (size_t i = 1; i < m_nsp; i++) {
1014  m_Grad_mu[a*m_nsp + i] -=
1015  m_molefracs[i] * GasConstant * m_Grad_T[a] * lnmnaught;
1016  }
1017  }
1018  }
1019 
1020  /*
1021  * Just for Note, m_A(i,j) refers to the ith row and jth column.
1022  * They are still fortran ordered, so that i varies fastest.
1023  */
1024 
1025  double condSum1;
1026  const doublereal invRT = 1.0 / (GasConstant * T);
1027  switch (m_nDim) {
1028  case 1: /* 1-D approximation */
1029 
1030  m_B(0,0) = 0.0;
1031  //equation for the reference velocity
1032  for (size_t j = 0; j < m_nsp; j++) {
1033  if (m_velocityBasis == VB_MOLEAVG) {
1034  m_A(0,j) = m_molefracs_tran[j];
1035  } else if (m_velocityBasis == VB_MASSAVG) {
1036  m_A(0,j) = m_massfracs_tran[j];
1037  } else if ((m_velocityBasis >= 0)
1038  && (m_velocityBasis < static_cast<int>(m_nsp)))
1039  // use species number m_velocityBasis as reference velocity
1040  if (m_velocityBasis == static_cast<int>(j)) {
1041  m_A(0,j) = 1.0;
1042  } else {
1043  m_A(0,j) = 0.0;
1044  }
1045  else
1046  throw CanteraError("LiquidTransport::stefan_maxwell_solve",
1047  "Unknown reference velocity provided.");
1048  }
1049  for (size_t i = 1; i < m_nsp; i++) {
1050  m_B(i,0) = m_Grad_mu[i] * invRT;
1051  m_A(i,i) = 0.0;
1052  for (size_t j = 0; j < m_nsp; j++) {
1053  if (j != i) {
1054  tmp = m_molefracs_tran[j] * m_bdiff(i,j);
1055  m_A(i,i) -= tmp;
1056  m_A(i,j) = tmp;
1057  }
1058  }
1059  }
1060 
1061  //! invert and solve the system Ax = b. Answer is in m_B
1062  solve(m_A, m_B);
1063 
1064  condSum1 = 0;
1065  for (size_t i = 0; i < m_nsp; i++) {
1066  condSum1 -= Faraday*m_chargeSpecies[i]*m_B(i,0)*m_molefracs_tran[i]/vol;
1067  }
1068  break;
1069  case 2: /* 2-D approximation */
1070  m_B(0,0) = 0.0;
1071  m_B(0,1) = 0.0;
1072  //equation for the reference velocity
1073  for (size_t j = 0; j < m_nsp; j++) {
1074  if (m_velocityBasis == VB_MOLEAVG) {
1075  m_A(0,j) = m_molefracs_tran[j];
1076  } else if (m_velocityBasis == VB_MASSAVG) {
1077  m_A(0,j) = m_massfracs_tran[j];
1078  } else if ((m_velocityBasis >= 0)
1079  && (m_velocityBasis < static_cast<int>(m_nsp)))
1080  // use species number m_velocityBasis as reference velocity
1081  if (m_velocityBasis == static_cast<int>(j)) {
1082  m_A(0,j) = 1.0;
1083  } else {
1084  m_A(0,j) = 0.0;
1085  }
1086  else
1087  throw CanteraError("LiquidTransport::stefan_maxwell_solve",
1088  "Unknown reference velocity provided.");
1089  }
1090  for (size_t i = 1; i < m_nsp; i++) {
1091  m_B(i,0) = m_Grad_mu[i] * invRT;
1092  m_B(i,1) = m_Grad_mu[m_nsp + i] * invRT;
1093  m_A(i,i) = 0.0;
1094  for (size_t j = 0; j < m_nsp; j++) {
1095  if (j != i) {
1096  tmp = m_molefracs_tran[j] * m_bdiff(i,j);
1097  m_A(i,i) -= tmp;
1098  m_A(i,j) = tmp;
1099  }
1100  }
1101  }
1102 
1103  //! invert and solve the system Ax = b. Answer is in m_B
1104  solve(m_A, m_B);
1105 
1106 
1107  break;
1108 
1109  case 3: /* 3-D approximation */
1110  m_B(0,0) = 0.0;
1111  m_B(0,1) = 0.0;
1112  m_B(0,2) = 0.0;
1113  //equation for the reference velocity
1114  for (size_t j = 0; j < m_nsp; j++) {
1115  if (m_velocityBasis == VB_MOLEAVG) {
1116  m_A(0,j) = m_molefracs_tran[j];
1117  } else if (m_velocityBasis == VB_MASSAVG) {
1118  m_A(0,j) = m_massfracs_tran[j];
1119  } else if ((m_velocityBasis >= 0)
1120  && (m_velocityBasis < static_cast<int>(m_nsp)))
1121  // use species number m_velocityBasis as reference velocity
1122  if (m_velocityBasis == static_cast<int>(j)) {
1123  m_A(0,j) = 1.0;
1124  } else {
1125  m_A(0,j) = 0.0;
1126  }
1127  else
1128  throw CanteraError("LiquidTransport::stefan_maxwell_solve",
1129  "Unknown reference velocity provided.");
1130  }
1131  for (size_t i = 1; i < m_nsp; i++) {
1132  m_B(i,0) = m_Grad_mu[i] * invRT;
1133  m_B(i,1) = m_Grad_mu[m_nsp + i] * invRT;
1134  m_B(i,2) = m_Grad_mu[2*m_nsp + i] * invRT;
1135  m_A(i,i) = 0.0;
1136  for (size_t j = 0; j < m_nsp; j++) {
1137  if (j != i) {
1138  tmp = m_molefracs_tran[j] * m_bdiff(i,j);
1139  m_A(i,i) -= tmp;
1140  m_A(i,j) = tmp;
1141  }
1142  }
1143  }
1144 
1145  //! invert and solve the system Ax = b. Answer is in m_B
1146  solve(m_A, m_B);
1147 
1148  break;
1149  default:
1150  printf("unimplemented\n");
1151  throw CanteraError("routine", "not done");
1152  break;
1153  }
1154 
1155  for (size_t a = 0; a < m_nDim; a++) {
1156  for (size_t j = 0; j < m_nsp; j++) {
1157  m_Vdiff(j,a) = m_B(j,a);
1158  m_flux(j,a) = concTot_ * M[j] * m_molefracs_tran[j] * m_B(j,a);
1159  }
1160  }
1161 }
1162 
1163 }
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:494
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:608
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 the mobility r...
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: shallow pointer.
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:121
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:598
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.
int solve(DenseMatrix &A, double *b, size_t nrhs, size_t ldb)
Solve Ax = b. Array b is overwritten on exit with x.
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:823
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 combinations of each species in each pure phase expressed as an appropr...
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:556
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:609
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.
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.
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:97
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' ...
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:64
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:673
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:28
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-Maxwell 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:1500
vector_fp m_Grad_lnAC
Gradient of the logarithm of the activity.
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:99
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:265
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:278
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:515
const VelocityBasis VB_MOLEAVG
Diffusion velocities are based on the mole averaged velocities.
Definition: TransportBase.h:88
doublereal temperature() const
Temperature (K).
Definition: Phase.h:602
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:157
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:142
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:669
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
Definition: ct_defs.h:64
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:512
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:86
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 conductivity 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.
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:272
const doublereal Boltzmann
Boltzmann's constant [J/K].
Definition: ct_defs.h:76
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:578
DenseMatrix m_bdiff
Array of Binary Diffusivities.
DenseMatrix m_mobRatSpecies
Internal value of the species mobility ratios.