Cantera 2.6.0
TransportBase.h
Go to the documentation of this file.
1/**
2 * @file TransportBase.h Headers for the Transport object, which is the virtual
3 * base class for all transport property evaluators and also includes the
4 * tranprops group definition (see \ref tranprops and \link
5 * Cantera::Transport Transport \endlink) .
6 */
7
8// This file is part of Cantera. See License.txt in the top-level directory or
9// at https://cantera.org/license.txt for license and copyright information.
10
11/**
12 * @defgroup tranprops Transport Properties for Species in Phases
13 *
14 * @ingroup phases
15 *
16 * These classes provide transport properties.
17 */
18
19#ifndef CT_TRANSPORTBASE_H
20#define CT_TRANSPORTBASE_H
21
24
25namespace Cantera
26{
27
28class ThermoPhase;
29class Solution;
30class AnyMap;
31
32/*!
33 * \addtogroup tranprops
34 */
35//! \cond
36
37const int CK_Mode = 10;
38
39//! \endcond
40
41//! The diffusion fluxes must be referenced to a particular reference
42//! fluid velocity.
43/*!
44 * Most typical is to reference the diffusion fluxes to the mass averaged
45 * velocity, but referencing to the mole averaged velocity is suitable for some
46 * liquid flows, and referencing to a single species is suitable for solid phase
47 * transport within a lattice. Currently, the identity of the reference
48 * velocity is coded into each transport object as a typedef named
49 * VelocityBasis, which is equated to an integer. Negative values of this
50 * variable refer to mass or mole-averaged velocities. Zero or positive
51 * quantities refers to the reference velocity being referenced to a particular
52 * species. Below are the predefined constants for its value.
53 *
54 * - VB_MASSAVG Diffusion velocities are based on the mass averaged velocity
55 * - VB_MOLEAVG Diffusion velocities are based on the mole averaged velocities
56 * - VB_SPECIES_0 Diffusion velocities are based on the relative motion wrt species 0
57 * - ...
58 * - VB_SPECIES_3 Diffusion velocities are based on the relative motion wrt species 3
59 *
60 * @ingroup tranprops
61 */
62typedef int VelocityBasis;
63
64/*!
65 * \addtogroup tranprops
66 */
67//! @{
68//! Diffusion velocities are based on the mass averaged velocity
70//! Diffusion velocities are based on the mole averaged velocities
72//! Diffusion velocities are based on the relative motion wrt species 0
74//! Diffusion velocities are based on the relative motion wrt species 1
76//! Diffusion velocities are based on the relative motion wrt species 2
78//! Diffusion velocities are based on the relative motion wrt species 3
80//! @}
81
82//! Base class for transport property managers.
83/*!
84 * All classes that compute transport properties for a single phase derive from
85 * this class. Class Transport is meant to be used as a base class only. It is
86 * possible to instantiate it, but its methods throw exceptions if called.
87 *
88 * ## Relationship of the Transport class to the ThermoPhase Class
89 *
90 * This section describes how calculations are carried out within the Transport
91 * class. The Transport class and derived classes of the the Transport class
92 * necessarily use the ThermoPhase class to obtain the list of species and the
93 * thermodynamic state of the phase.
94 *
95 * No state information is stored within Transport classes. Queries to the
96 * underlying ThermoPhase object must be made to obtain the state of the system.
97 *
98 * An exception to this however is the state information concerning the the
99 * gradients of variables. This information is not stored within the ThermoPhase
100 * objects. It may be collected within the Transport objects. In fact, the
101 * meaning of const operations within the Transport class refers to calculations
102 * which do not change the state of the system nor the state of the first order
103 * gradients of the system.
104 *
105 * When a const operation is evoked within the Transport class, it is also
106 * implicitly assumed that the underlying state within the ThermoPhase object
107 * has not changed its values.
108 *
109 * ## Diffusion Fluxes and their Relationship to Reference Velocities
110 *
111 * The diffusion fluxes must be referenced to a particular reference fluid
112 * velocity. Most typical is to reference the diffusion fluxes to the mass
113 * averaged velocity, but referencing to the mole averaged velocity is suitable
114 * for some liquid flows, and referencing to a single species is suitable for
115 * solid phase transport within a lattice. Currently, the identity of the
116 * reference velocity is coded into each transport object as a typedef named
117 * VelocityBasis, which is equated to an integer. Negative values of this
118 * variable refer to mass or mole-averaged velocities. Zero or positive
119 * quantities refers to the reference velocity being referenced to a particular
120 * species. Below are the predefined constants for its value.
121 *
122 * - VB_MASSAVG Diffusion velocities are based on the mass averaged velocity
123 * - VB_MOLEAVG Diffusion velocities are based on the mole averaged velocities
124 * - VB_SPECIES_0 Diffusion velocities are based on the relative motion wrt species 0
125 * - ...
126 * - VB_SPECIES_3 Diffusion velocities are based on the relative motion wrt species 3
127 *
128 * All transport managers specify a default reference velocity in their default
129 * constructors. All gas phase transport managers by default specify the mass-
130 * averaged velocity as their reference velocities.
131 *
132 * @todo Provide a general mechanism to store the gradients of state variables
133 * within the system.
134 *
135 * @ingroup tranprops
136 */
138{
139public:
140 //! Constructor.
141 /*!
142 * New transport managers should be created using TransportFactory, not by
143 * calling the constructor directly.
144 *
145 * @param thermo Pointer to the ThermoPhase class representing this phase.
146 * @param ndim Dimension of the flux vector used in the calculation.
147 *
148 * @see TransportFactory
149 */
150 Transport(ThermoPhase* thermo=0, size_t ndim = 1);
151
152 virtual ~Transport() {}
153
154 // Transport objects are not copyable or assignable
155 Transport(const Transport&) = delete;
156 Transport& operator=(const Transport&) = delete;
157
158 //! Identifies the Transport object type. Each derived class should override
159 //! this method to return a meaningful identifier.
160 virtual std::string transportType() const {
161 return "None";
162 }
163
164 /*!
165 * Phase object. Every transport manager is designed to compute properties
166 * for a specific phase of a mixture, which might be a liquid solution, a
167 * gas mixture, a surface, etc. This method returns a reference to the
168 * object representing the phase itself.
169 */
171 return *m_thermo;
172 }
173
174 /*!
175 * Returns true if the transport manager is ready for use.
176 */
177 bool ready();
178
179 //! Set the number of dimensions to be expected in flux expressions
180 /*!
181 * @param ndim Number of dimensions in flux expressions
182 */
183 void setNDim(const int ndim);
184
185 //! Return the number of dimensions in flux expressions
186 size_t nDim() const {
187 return m_nDim;
188 }
189
190 //! Check that the specified species index is in range. Throws an exception
191 //! if k is greater than nSpecies()
192 void checkSpeciesIndex(size_t k) const;
193
194 //! Check that an array size is at least nSpecies(). Throws an exception if
195 //! kk is less than nSpecies(). Used before calls which take an array
196 //! pointer.
197 void checkSpeciesArraySize(size_t kk) const;
198
199 /**
200 * @name Transport Properties
201 */
202 //! @{
203
204 /*!
205 * The viscosity in Pa-s.
206 */
207 virtual doublereal viscosity() {
208 throw NotImplementedError("Transport::viscosity",
209 "Not implemented for transport model '{}'.", transportType());
210 }
211
212 //! Returns the pure species viscosities
213 /*!
214 * The units are Pa-s and the length is the number of species
215 *
216 * @param visc Vector of viscosities
217 */
218 virtual void getSpeciesViscosities(doublereal* const visc) {
219 throw NotImplementedError("Transport::getSpeciesViscosities",
220 "Not implemented for transport model '{}'.", transportType());
221 }
222
223 //! The bulk viscosity in Pa-s.
224 /*!
225 * The bulk viscosity is only non-zero in rare cases. Most transport
226 * managers either overload this method to return zero, or do not implement
227 * it, in which case an exception is thrown if called.
228 */
229 virtual doublereal bulkViscosity() {
230 throw NotImplementedError("Transport::bulkViscosity",
231 "Not implemented for transport model '{}'.", transportType());
232 }
233
234 //! The ionic conductivity in 1/ohm/m.
235 virtual doublereal ionConductivity() {
236 throw NotImplementedError("Transport::ionConductivity",
237 "Not implemented for transport model '{}'.", transportType());
238 }
239
240 //! Returns the pure species ionic conductivity
241 /*!
242 * The units are 1/ohm/m and the length is the number of species
243 *
244 * @param ionCond Vector of ionic conductivities
245 */
246 virtual void getSpeciesIonConductivity(doublereal* const ionCond) {
247 throw NotImplementedError("Transport::getSpeciesIonConductivity",
248 "Not implemented for transport model '{}'.", transportType());
249 }
250
251 //! Returns the pointer to the mobility ratios of the species in the phase
252 /*!
253 * @param mobRat Returns a matrix of mobility ratios for the current
254 * problem. The mobility ratio mobRat(i,j) is defined as the
255 * ratio of the mobility of species i to species j.
256 *
257 * mobRat(i,j) = mu_i / mu_j
258 *
259 * It is returned in fortran-ordering format. That is, it is returned as
260 * mobRat[k], where
261 *
262 * k = j * nsp + i
263 *
264 * The size of mobRat must be at least equal to nsp*nsp
265 */
266 virtual void mobilityRatio(double* mobRat) {
267 throw NotImplementedError("Transport::mobilityRatio",
268 "Not implemented for transport model '{}'.", transportType());
269 }
270
271 //! Returns the pure species limit of the mobility ratios
272 /*!
273 * The value is dimensionless and the length is the number of species
274 *
275 * @param mobRat Vector of mobility ratios
276 */
277 virtual void getSpeciesMobilityRatio(double** mobRat) {
278 throw NotImplementedError("Transport::getSpeciesMobilityRatio",
279 "Not implemented for transport model '{}'.", transportType());
280 }
281
282 //! Returns the mixture thermal conductivity in W/m/K.
283 /*!
284 * Units are in W / m K or equivalently kg m / s3 K
285 *
286 * @returns thermal conductivity in W/m/K.
287 */
288 virtual doublereal thermalConductivity() {
289 throw NotImplementedError("Transport::thermalConductivity",
290 "Not implemented for transport model '{}'.", transportType());
291 }
292
293 //! The electrical conductivity (Siemens/m).
294 virtual doublereal electricalConductivity() {
295 throw NotImplementedError("Transport::electricalConductivity",
296 "Not implemented for transport model '{}'.", transportType());
297 }
298
299 //! Get the Electrical mobilities (m^2/V/s).
300 /*!
301 * This function returns the mobilities. In some formulations this is equal
302 * to the normal mobility multiplied by Faraday's constant.
303 *
304 * Frequently, but not always, the mobility is calculated from the diffusion
305 * coefficient using the Einstein relation
306 *
307 * \f[
308 * \mu^e_k = \frac{F D_k}{R T}
309 * \f]
310 *
311 * @param mobil_e Returns the mobilities of the species in array \c
312 * mobil_e. The array must be dimensioned at least as large as
313 * the number of species.
314 */
315 virtual void getMobilities(doublereal* const mobil_e) {
316 throw NotImplementedError("Transport::getMobilities",
317 "Not implemented for transport model '{}'.", transportType());
318 }
319
320 //! Get the fluid mobilities (s kmol/kg).
321 /*!
322 * This function returns the fluid mobilities. Usually, you have to multiply
323 * Faraday's constant into the resulting expression to general a species
324 * flux expression.
325 *
326 * Frequently, but not always, the mobility is calculated from the diffusion
327 * coefficient using the Einstein relation
328 *
329 * \f[
330 * \mu^f_k = \frac{D_k}{R T}
331 * \f]
332 *
333 * @param mobil_f Returns the mobilities of the species in array \c mobil.
334 * The array must be dimensioned at least as large as the
335 * number of species.
336 */
337 virtual void getFluidMobilities(doublereal* const mobil_f) {
338 throw NotImplementedError("Transport::getFluidMobilities",
339 "Not implemented for transport model '{}'.", transportType());
340 }
341
342 //! @}
343
344 //! Compute the mixture electrical conductivity (S m-1) at the current
345 //! conditions of the phase (Siemens m-1)
346 /*!
347 * The electrical conductivity, \f$ \sigma \f$, relates the electric current
348 * density, J, to the electric field, E.
349 *
350 * \f[
351 * \vec{J} = \sigma \vec{E}
352 * \f]
353 *
354 * We assume here that the mixture electrical conductivity is an isotropic
355 * quantity, at this stage. Tensors may be included at a later time.
356 *
357 * The conductivity is the reciprocal of the resistivity.
358 *
359 * The units are Siemens m-1, where 1 S = 1 A / volt = 1 s^3 A^2 /kg /m^2
360 */
361 virtual doublereal getElectricConduct() {
362 throw NotImplementedError("Transport::getElectricConduct",
363 "Not implemented for transport model '{}'.", transportType());
364 }
365
366 //! Compute the electric current density in A/m^2
367 /*!
368 * Calculates the electric current density as a vector, given the gradients
369 * of the field variables.
370 *
371 * @param ndim The number of spatial dimensions (1, 2, or 3).
372 * @param grad_T The temperature gradient (ignored in this model).
373 * @param ldx Leading dimension of the grad_X array.
374 * @param grad_X The gradient of the mole fraction
375 * @param ldf Leading dimension of the grad_V and current vectors.
376 * @param grad_V The electrostatic potential gradient.
377 * @param current The electric current in A/m^2. This is a vector of length ndim
378 */
379 virtual void getElectricCurrent(int ndim,
380 const doublereal* grad_T,
381 int ldx,
382 const doublereal* grad_X,
383 int ldf,
384 const doublereal* grad_V,
385 doublereal* current) {
386 throw NotImplementedError("Transport::getElectricCurrent",
387 "Not implemented for transport model '{}'.", transportType());
388 }
389
390 //! Get the species diffusive mass fluxes wrt to the specified solution
391 //! averaged velocity, given the gradients in mole fraction and temperature
392 /*!
393 * Units for the returned fluxes are kg m-2 s-1.
394 *
395 * Usually the specified solution average velocity is the mass averaged
396 * velocity. This is changed in some subclasses, however.
397 *
398 * @param ndim Number of dimensions in the flux expressions
399 * @param grad_T Gradient of the temperature (length = ndim)
400 * @param ldx Leading dimension of the grad_X array (usually equal to
401 * m_nsp but not always)
402 * @param grad_X Gradients of the mole fraction Flat vector with the
403 * m_nsp in the inner loop. length = ldx * ndim
404 * @param ldf Leading dimension of the fluxes array (usually equal to
405 * m_nsp but not always)
406 * @param fluxes Output of the diffusive mass fluxes. Flat vector with
407 * the m_nsp in the inner loop. length = ldx * ndim
408 */
409 virtual void getSpeciesFluxes(size_t ndim, const doublereal* const grad_T,
410 size_t ldx, const doublereal* const grad_X,
411 size_t ldf, doublereal* const fluxes) {
412 throw NotImplementedError("Transport::getSpeciesFluxes",
413 "Not implemented for transport model '{}'.", transportType());
414 }
415
416 //! Get the species diffusive mass fluxes wrt to the mass averaged velocity,
417 //! given the gradients in mole fraction, temperature and electrostatic
418 //! potential.
419 /*!
420 * Units for the returned fluxes are kg m-2 s-1.
421 *
422 * @param[in] ndim Number of dimensions in the flux expressions
423 * @param[in] grad_T Gradient of the temperature. (length = ndim)
424 * @param[in] ldx Leading dimension of the grad_X array (usually equal to
425 * m_nsp but not always)
426 * @param[in] grad_X Gradients of the mole fraction. Flat vector with the
427 * m_nsp in the inner loop. length = ldx * ndim.
428 * @param[in] ldf Leading dimension of the fluxes array (usually equal to
429 * m_nsp but not always).
430 * @param[in] grad_Phi Gradients of the electrostatic potential (length = ndim)
431 * @param[out] fluxes The diffusive mass fluxes. Flat vector with the m_nsp
432 * in the inner loop. length = ldx * ndim.
433 */
434 virtual void getSpeciesFluxesES(size_t ndim,
435 const doublereal* grad_T,
436 size_t ldx,
437 const doublereal* grad_X,
438 size_t ldf,
439 const doublereal* grad_Phi,
440 doublereal* fluxes) {
441 getSpeciesFluxes(ndim, grad_T, ldx, grad_X, ldf, fluxes);
442 }
443
444 //! Get the species diffusive velocities wrt to the mass averaged velocity,
445 //! given the gradients in mole fraction and temperature
446 /*!
447 * @param[in] ndim Number of dimensions in the flux expressions
448 * @param[in] grad_T Gradient of the temperature (length = ndim)
449 * @param[in] ldx Leading dimension of the grad_X array (usually equal to
450 * m_nsp but not always)
451 * @param[in] grad_X Gradients of the mole fraction. Flat vector with the
452 * m_nsp in the inner loop. length = ldx * ndim
453 * @param[in] ldf Leading dimension of the fluxes array (usually equal to
454 * m_nsp but not always)
455 * @param[out] Vdiff Diffusive velocities wrt the mass- averaged velocity.
456 * Flat vector with the m_nsp in the inner loop.
457 * length = ldx * ndim. units are m / s.
458 */
459 virtual void getSpeciesVdiff(size_t ndim,
460 const doublereal* grad_T,
461 int ldx,
462 const doublereal* grad_X,
463 int ldf,
464 doublereal* Vdiff) {
465 throw NotImplementedError("Transport::getSpeciesVdiff",
466 "Not implemented for transport model '{}'.", transportType());
467 }
468
469 //! Get the species diffusive velocities wrt to the mass averaged velocity,
470 //! given the gradients in mole fraction, temperature, and electrostatic
471 //! potential.
472 /*!
473 * @param[in] ndim Number of dimensions in the flux expressions
474 * @param[in] grad_T Gradient of the temperature (length = ndim)
475 * @param[in] ldx Leading dimension of the grad_X array (usually equal to
476 * m_nsp but not always)
477 * @param[in] grad_X Gradients of the mole fraction. Flat vector with the
478 * m_nsp in the inner loop. length = ldx * ndim.
479 * @param[in] ldf Leading dimension of the fluxes array (usually equal to
480 * m_nsp but not always)
481 * @param[in] grad_Phi Gradients of the electrostatic potential
482 * (length = ndim)
483 * @param[out] Vdiff Diffusive velocities wrt the mass-averaged velocity.
484 * Flat vector with the m_nsp in the inner loop. length = ldx
485 * * ndim. units are m / s.
486 */
487 virtual void getSpeciesVdiffES(size_t ndim,
488 const doublereal* grad_T,
489 int ldx,
490 const doublereal* grad_X,
491 int ldf,
492 const doublereal* grad_Phi,
493 doublereal* Vdiff) {
494 getSpeciesVdiff(ndim, grad_T, ldx, grad_X, ldf, Vdiff);
495 }
496
497 //! Get the molar fluxes [kmol/m^2/s], given the thermodynamic state at two
498 //! nearby points.
499 /*!
500 * @param[in] state1 Array of temperature, density, and mass fractions for
501 * state 1.
502 * @param[in] state2 Array of temperature, density, and mass fractions for
503 * state 2.
504 * @param[in] delta Distance from state 1 to state 2 (m).
505 * @param[out] cfluxes Output array containing the diffusive molar fluxes of
506 * species from state1 to state2. This is a flat vector with
507 * m_nsp in the inner loop. length = ldx * ndim. Units are
508 * [kmol/m^2/s].
509 */
510 virtual void getMolarFluxes(const doublereal* const state1,
511 const doublereal* const state2, const doublereal delta,
512 doublereal* const cfluxes) {
513 throw NotImplementedError("Transport::getMolarFluxes",
514 "Not implemented for transport model '{}'.", transportType());
515 }
516
517 //! Get the mass fluxes [kg/m^2/s], given the thermodynamic state at two
518 //! nearby points.
519 /*!
520 * @param[in] state1 Array of temperature, density, and mass
521 * fractions for state 1.
522 * @param[in] state2 Array of temperature, density, and mass fractions for
523 * state 2.
524 * @param[in] delta Distance from state 1 to state 2 (m).
525 * @param[out] mfluxes Output array containing the diffusive mass fluxes of
526 * species from state1 to state2. This is a flat vector with
527 * m_nsp in the inner loop. length = ldx * ndim. Units are
528 * [kg/m^2/s].
529 */
530 virtual void getMassFluxes(const doublereal* state1,
531 const doublereal* state2, doublereal delta,
532 doublereal* mfluxes) {
533 throw NotImplementedError("Transport::getMassFluxes",
534 "Not implemented for transport model '{}'.", transportType());
535 }
536
537 //! Return a vector of Thermal diffusion coefficients [kg/m/sec].
538 /*!
539 * The thermal diffusion coefficient \f$ D^T_k \f$ is defined so that the
540 * diffusive mass flux of species *k* induced by the local temperature
541 * gradient is given by the following formula:
542 *
543 * \f[
544 * M_k J_k = -D^T_k \nabla \ln T.
545 * \f]
546 *
547 * The thermal diffusion coefficient can be either positive or negative.
548 *
549 * @param dt On return, dt will contain the species thermal diffusion
550 * coefficients. Dimension dt at least as large as the number of
551 * species. Units are kg/m/s.
552 */
553 virtual void getThermalDiffCoeffs(doublereal* const dt) {
554 throw NotImplementedError("Transport::getThermalDiffCoeffs",
555 "Not implemented for transport model '{}'.", transportType());
556 }
557
558 //! Returns the matrix of binary diffusion coefficients [m^2/s].
559 /*!
560 * @param[in] ld Inner stride for writing the two dimension diffusion
561 * coefficients into a one dimensional vector
562 * @param[out] d Diffusion coefficient matrix (must be at least m_k * m_k
563 * in length.
564 */
565 virtual void getBinaryDiffCoeffs(const size_t ld, doublereal* const d) {
566 throw NotImplementedError("Transport::getBinaryDiffCoeffs",
567 "Not implemented for transport model '{}'.", transportType());
568 }
569
570 //! Return the Multicomponent diffusion coefficients. Units: [m^2/s].
571 /*!
572 * If the transport manager implements a multicomponent diffusion
573 * model, then this method returns the array of multicomponent
574 * diffusion coefficients. Otherwise it throws an exception.
575 *
576 * @param[in] ld The dimension of the inner loop of d (usually equal to m_nsp)
577 * @param[out] d flat vector of diffusion coefficients, fortran ordering.
578 * d[ld*j+i] is the D_ij diffusion coefficient (the diffusion
579 * coefficient for species i due to concentration gradients in
580 * species j). Units: m^2/s
581 */
582 virtual void getMultiDiffCoeffs(const size_t ld, doublereal* const d) {
583 throw NotImplementedError("Transport::getMultiDiffCoeffs",
584 "Not implemented for transport model '{}'.", transportType());
585 }
586
587 //! Returns a vector of mixture averaged diffusion coefficients
588 /**
589 * Mixture-averaged diffusion coefficients [m^2/s]. If the transport
590 * manager implements a mixture-averaged diffusion model, then this method
591 * returns the array of mixture-averaged diffusion coefficients. Otherwise
592 * it throws an exception.
593 *
594 * @param d Return vector of mixture averaged diffusion coefficients
595 * Units = m2/s. Length = n_sp
596 */
597 virtual void getMixDiffCoeffs(doublereal* const d) {
598 throw NotImplementedError("Transport::getMixDiffCoeffs",
599 "Not implemented for transport model '{}'.", transportType());
600 }
601
602 //! Returns a vector of mixture averaged diffusion coefficients
603 virtual void getMixDiffCoeffsMole(doublereal* const d) {
604 throw NotImplementedError("Transport::getMixDiffCoeffsMole",
605 "Not implemented for transport model '{}'.", transportType());
606 }
607
608 //! Returns a vector of mixture averaged diffusion coefficients
609 virtual void getMixDiffCoeffsMass(doublereal* const d) {
610 throw NotImplementedError("Transport::getMixDiffCoeffsMass",
611 "Not implemented for transport model '{}'.", transportType());
612 }
613
614 //! Return the polynomial fits to the viscosity of species i
615 virtual void getViscosityPolynomial(size_t i, double* coeffs) const{
616 throw NotImplementedError("Transport::getViscosityPolynomial",
617 "Not implemented for transport model '{}'.", transportType());
618 }
619
620 //! Return the temperature fits of the heat conductivity of species i
621 virtual void getConductivityPolynomial(size_t i, double* coeffs) const{
622 throw NotImplementedError("Transport::getConductivityPolynomial",
623 "Not implemented for transport model '{}'.", transportType());
624 }
625
626 //! Return the polynomial fits to the binary diffusivity of species pair (i, j)
627 virtual void getBinDiffusivityPolynomial(size_t i, size_t j, double* coeffs) const{
628 throw NotImplementedError("Transport::getBinDiffusivityPolynomial",
629 "Not implemented for transport model '{}'.", transportType());
630 }
631
632 //! Return the polynomial fits to the collision integral of species pair (i, j)
633 virtual void getCollisionIntegralPolynomial(size_t i, size_t j,
634 double* astar_coeffs,
635 double* bstar_coeffs,
636 double* cstar_coeffs) const{
637 throw NotImplementedError("Transport::getCollisionIntegralPolynomial",
638 "Not implemented for transport model '{}'.", transportType());
639 }
640
641 //! Modify the polynomial fits to the viscosity of species i
642 virtual void setViscosityPolynomial(size_t i, double* coeffs){
643 throw NotImplementedError("Transport::setViscosityPolynomial",
644 "Not implemented for transport model '{}'.", transportType());
645 }
646
647 //! Modify the temperature fits of the heat conductivity of species i
648 virtual void setConductivityPolynomial(size_t i, double* coeffs){
649 throw NotImplementedError("Transport::setConductivityPolynomial",
650 "Not implemented for transport model '{}'.", transportType());
651 }
652
653 //! Modify the polynomial fits to the binary diffusivity of species pair (i, j)
654 virtual void setBinDiffusivityPolynomial(size_t i, size_t j, double* coeffs){
655 throw NotImplementedError("Transport::setBinDiffusivityPolynomial",
656 "Not implemented for transport model '{}'.", transportType());
657 }
658
659 //! Modify the polynomial fits to the collision integral of species pair (i, j)
660 virtual void setCollisionIntegralPolynomial(size_t i, size_t j,
661 double* astar_coeffs,
662 double* bstar_coeffs,
663 double* cstar_coeffs, bool flag){
664 throw NotImplementedError("Transport::setCollisionIntegralPolynomial",
665 "Not implemented for transport model '{}'.", transportType());
666 }
667
668 //! Set model parameters for derived classes
669 /*!
670 * This method may be derived in subclasses to set model-specific
671 * parameters. The primary use of this class is to set parameters while in
672 * the middle of a calculation without actually having to dynamically cast
673 * the base Transport pointer.
674 *
675 * @param type Specifies the type of parameters to set
676 * 0 : Diffusion coefficient
677 * 1 : Thermal Conductivity
678 * The rest are currently unused.
679 * @param k Species index to set the parameters on
680 * @param p Vector of parameters. The length of the vector varies with
681 * the parameterization
682 */
683 virtual void setParameters(const int type, const int k, const doublereal* const p) {
684 throw NotImplementedError("Transport::setParameters",
685 "Not implemented for transport model '{}'.", transportType());
686 }
687
688 //! Return the parameters for a phase definition which are needed to
689 //! reconstruct an identical object using the newTransport function. This
690 //! excludes the individual species transport properties, which are handled
691 //! separately.
692 AnyMap parameters() const;
693
694 //! Sets the velocity basis
695 /*!
696 * What the transport object does with this parameter is up to the
697 * individual operator. Currently, this is not functional for most transport
698 * operators including all of the gas-phase operators.
699 *
700 * @param ivb Species the velocity basis
701 */
703 m_velocityBasis = ivb;
704 }
705
706 //! Gets the velocity basis
707 /*!
708 * What the transport object does with this parameter is up to the
709 * individual operator. Currently, this is not functional for most transport
710 * operators including all of the gas-phase operators.
711 *
712 * @returns the velocity basis
713 */
715 return m_velocityBasis;
716 }
717
718 /**
719 * @name Transport manager construction
720 * These methods are used during construction.
721 * @{
722 */
723
724 //! Initialize a transport manager
725 /*!
726 * This routine sets up a transport manager. It calculates the collision
727 * integrals and populates species-dependent data structures.
728 *
729 * @param thermo Pointer to the ThermoPhase object
730 * @param mode Chemkin compatible mode or not. This alters the
731 * specification of the collision integrals. defaults to no.
732 * @param log_level Defaults to zero, no logging
733 */
734 virtual void init(ThermoPhase* thermo, int mode=0, int log_level=0) {}
735
736 //! Specifies the ThermoPhase object.
737 /*!
738 * We have relaxed this operation so that it will succeed when the
739 * underlying old and new ThermoPhase objects have the same number of
740 * species and the same names of the species in the same order. The idea
741 * here is to allow copy constructors and duplicators to work. In order for
742 * them to work, we need a method to switch the internal pointer within the
743 * Transport object after the duplication takes place. Also, different
744 * thermodynamic instantiations of the same species should also work.
745 *
746 * @param thermo Reference to the ThermoPhase object that the transport
747 * object will use
748 */
749 virtual void setThermo(ThermoPhase& thermo);
750
751 //! Set root Solution holding all phase information
752 virtual void setRoot(std::shared_ptr<Solution> root);
753
754 //! Boolean indicating the form of the transport properties polynomial fits.
755 //! Returns true if the Chemkin form is used.
756 virtual bool CKMode() const {
757 throw NotImplementedError("Transport::CK_Mode",
758 "Not implemented for transport model '{}'.", transportType());
759 }
760
761protected:
762 //! Enable the transport object for use.
763 /*!
764 * Once finalize() has been called, the transport manager should be ready to
765 * compute any supported transport property, and no further modifications to
766 * the model parameters should be made.
767 */
768 void finalize();
769
770 //! @}
771
772 //! pointer to the object representing the phase
774
775 //! true if finalize has been called
777
778 //! Number of species
779 size_t m_nsp;
780
781 //! Number of dimensions used in flux expressions
782 size_t m_nDim;
783
784 //! Velocity basis from which diffusion velocities are computed.
785 //! Defaults to the mass averaged basis = -2
787
788 //! reference to Solution
789 std::weak_ptr<Solution> m_root;
790};
791
792}
793
794#endif
A map of string keys to values whose type can vary at runtime.
Definition: AnyMap.h:399
An error indicating that an unimplemented function has been called.
Definition: ctexceptions.h:187
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:102
Base class for transport property managers.
virtual void getMobilities(doublereal *const mobil_e)
Get the Electrical mobilities (m^2/V/s).
virtual void setThermo(ThermoPhase &thermo)
Specifies the ThermoPhase object.
ThermoPhase * m_thermo
pointer to the object representing the phase
virtual void getMixDiffCoeffsMole(doublereal *const d)
Returns a vector of mixture averaged diffusion coefficients.
virtual void getMassFluxes(const doublereal *state1, const doublereal *state2, doublereal delta, doublereal *mfluxes)
Get the mass fluxes [kg/m^2/s], given the thermodynamic state at two nearby points.
void setNDim(const int ndim)
Set the number of dimensions to be expected in flux expressions.
virtual void init(ThermoPhase *thermo, int mode=0, int log_level=0)
Initialize a transport manager.
virtual void getBinDiffusivityPolynomial(size_t i, size_t j, double *coeffs) const
Return the polynomial fits to the binary diffusivity of species pair (i, j)
virtual void setCollisionIntegralPolynomial(size_t i, size_t j, double *astar_coeffs, double *bstar_coeffs, double *cstar_coeffs, bool flag)
Modify the polynomial fits to the collision integral of species pair (i, j)
size_t m_nDim
Number of dimensions used in flux expressions.
void checkSpeciesIndex(size_t k) const
Check that the specified species index is in range.
virtual void getFluidMobilities(doublereal *const mobil_f)
Get the fluid mobilities (s kmol/kg).
bool m_ready
true if finalize has been called
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 mass averaged velocity, given the gradients in mole f...
virtual void getThermalDiffCoeffs(doublereal *const dt)
Return a vector of Thermal diffusion coefficients [kg/m/sec].
void finalize()
Enable the transport object for use.
virtual void getSpeciesFluxes(size_t ndim, const doublereal *const grad_T, size_t ldx, const doublereal *const grad_X, size_t ldf, doublereal *const fluxes)
Get the species diffusive mass fluxes wrt to the specified solution averaged velocity,...
virtual void setParameters(const int type, const int k, const doublereal *const p)
Set model parameters for derived classes.
virtual void setRoot(std::shared_ptr< Solution > root)
Set root Solution holding all phase information.
virtual void getViscosityPolynomial(size_t i, double *coeffs) const
Return the polynomial fits to the viscosity of species i.
virtual doublereal bulkViscosity()
The bulk viscosity in Pa-s.
virtual doublereal ionConductivity()
The ionic conductivity in 1/ohm/m.
size_t nDim() const
Return the number of dimensions in flux expressions.
virtual void getConductivityPolynomial(size_t i, double *coeffs) const
Return the temperature fits of the heat conductivity of species i.
virtual void getMolarFluxes(const doublereal *const state1, const doublereal *const state2, const doublereal delta, doublereal *const cfluxes)
Get the molar fluxes [kmol/m^2/s], given the thermodynamic state at two nearby points.
AnyMap parameters() const
Return the parameters for a phase definition which are needed to reconstruct an identical object usin...
virtual void getMixDiffCoeffsMass(doublereal *const d)
Returns a vector of mixture averaged diffusion coefficients.
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)
Get the species diffusive mass fluxes wrt to the mass averaged velocity, given the gradients in mole ...
virtual void getSpeciesIonConductivity(doublereal *const ionCond)
Returns the pure species ionic conductivity.
virtual doublereal electricalConductivity()
The electrical conductivity (Siemens/m).
virtual void setViscosityPolynomial(size_t i, double *coeffs)
Modify the polynomial fits to the viscosity of species i.
virtual void getBinaryDiffCoeffs(const size_t ld, doublereal *const d)
Returns the matrix of binary diffusion coefficients [m^2/s].
virtual void getSpeciesMobilityRatio(double **mobRat)
Returns the pure species limit of the mobility ratios.
virtual void mobilityRatio(double *mobRat)
Returns the pointer to the mobility ratios of the species in the phase.
virtual void setConductivityPolynomial(size_t i, double *coeffs)
Modify the temperature fits of the heat conductivity of species i.
virtual doublereal viscosity()
virtual std::string transportType() const
Identifies the Transport object type.
virtual bool CKMode() const
Boolean indicating the form of the transport properties polynomial fits.
std::weak_ptr< Solution > m_root
reference to Solution
Transport(ThermoPhase *thermo=0, size_t ndim=1)
Constructor.
virtual void getMultiDiffCoeffs(const size_t ld, doublereal *const d)
Return the Multicomponent diffusion coefficients. Units: [m^2/s].
size_t m_nsp
Number of species.
virtual void getSpeciesViscosities(doublereal *const visc)
Returns the pure species viscosities.
void setVelocityBasis(VelocityBasis ivb)
Sets the velocity basis.
ThermoPhase & thermo()
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.
void checkSpeciesArraySize(size_t kk) const
Check that an array size is at least nSpecies().
virtual doublereal thermalConductivity()
Returns the mixture thermal conductivity in W/m/K.
int m_velocityBasis
Velocity basis from which diffusion velocities are computed.
virtual doublereal getElectricConduct()
Compute the mixture electrical conductivity (S m-1) at the current conditions of the phase (Siemens m...
virtual void getMixDiffCoeffs(doublereal *const d)
Returns a vector of mixture averaged diffusion coefficients.
virtual void setBinDiffusivityPolynomial(size_t i, size_t j, double *coeffs)
Modify the polynomial fits to the binary diffusivity of species pair (i, j)
VelocityBasis getVelocityBasis() const
Gets the velocity basis.
virtual void getCollisionIntegralPolynomial(size_t i, size_t j, double *astar_coeffs, double *bstar_coeffs, double *cstar_coeffs) const
Return the polynomial fits to the collision integral of species pair (i, j)
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 mass averaged velocity, given the gradients in mole f...
This file contains definitions of constants, types and terms that are used in internal routines and a...
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
const VelocityBasis VB_SPECIES_1
Diffusion velocities are based on the relative motion wrt species 1.
Definition: TransportBase.h:75
int VelocityBasis
The diffusion fluxes must be referenced to a particular reference fluid velocity.
Definition: TransportBase.h:62
const VelocityBasis VB_MASSAVG
Definition: TransportBase.h:69
const VelocityBasis VB_SPECIES_2
Diffusion velocities are based on the relative motion wrt species 2.
Definition: TransportBase.h:77
const VelocityBasis VB_MOLEAVG
Diffusion velocities are based on the mole averaged velocities.
Definition: TransportBase.h:71
const VelocityBasis VB_SPECIES_3
Diffusion velocities are based on the relative motion wrt species 3.
Definition: TransportBase.h:79
const VelocityBasis VB_SPECIES_0
Diffusion velocities are based on the relative motion wrt species 0.
Definition: TransportBase.h:73
Namespace for the Cantera kernel.
Definition: AnyMap.h:29