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