Cantera 2.6.0
MixTransport.cpp
Go to the documentation of this file.
1/**
2 * @file MixTransport.cpp
3 * Mixture-averaged transport properties for ideal gas mixtures.
4 */
5
6// This file is part of Cantera. See License.txt in the top-level directory or
7// at https://cantera.org/license.txt for license and copyright information.
8
13
14using namespace std;
15
16namespace Cantera
17{
19 m_lambda(0.0),
20 m_spcond_ok(false),
21 m_condmix_ok(false)
22{
23}
24
25void MixTransport::init(ThermoPhase* thermo, int mode, int log_level)
26{
27 GasTransport::init(thermo, mode, log_level);
28 m_cond.resize(m_nsp);
29}
30
31void MixTransport::getMobilities(doublereal* const mobil)
32{
34 doublereal c1 = ElectronCharge / (Boltzmann * m_temp);
35 for (size_t k = 0; k < m_nsp; k++) {
36 mobil[k] = c1 * m_spwork[k];
37 }
38}
39
41{
42 update_T();
43 update_C();
44 if (!m_spcond_ok) {
46 }
47 if (!m_condmix_ok) {
48 doublereal sum1 = 0.0, sum2 = 0.0;
49 for (size_t k = 0; k < m_nsp; k++) {
50 sum1 += m_molefracs[k] * m_cond[k];
51 sum2 += m_molefracs[k] / m_cond[k];
52 }
53 m_lambda = 0.5*(sum1 + 1.0/sum2);
54 m_condmix_ok = true;
55 }
56 return m_lambda;
57}
58
59void MixTransport::getThermalDiffCoeffs(doublereal* const dt)
60{
61 for (size_t k = 0; k < m_nsp; k++) {
62 dt[k] = 0.0;
63 }
64}
65
66void MixTransport::getSpeciesFluxes(size_t ndim, const doublereal* const grad_T,
67 size_t ldx, const doublereal* const grad_X,
68 size_t ldf, doublereal* const fluxes)
69{
70 update_T();
71 update_C();
73 const vector_fp& mw = m_thermo->molecularWeights();
74 const doublereal* y = m_thermo->massFractions();
75 doublereal rhon = m_thermo->molarDensity();
76 vector_fp sum(ndim,0.0);
77 for (size_t n = 0; n < ndim; n++) {
78 for (size_t k = 0; k < m_nsp; k++) {
79 fluxes[n*ldf + k] = -rhon * mw[k] * m_spwork[k] * grad_X[n*ldx + k];
80 sum[n] += fluxes[n*ldf + k];
81 }
82 }
83 // add correction flux to enforce sum to zero
84 for (size_t n = 0; n < ndim; n++) {
85 for (size_t k = 0; k < m_nsp; k++) {
86 fluxes[n*ldf + k] -= y[k]*sum[n];
87 }
88 }
89}
90
92{
93 doublereal t = m_thermo->temperature();
94 if (t == m_temp && m_nsp == m_thermo->nSpecies()) {
95 return;
96 }
97 if (t < 0.0) {
98 throw CanteraError("MixTransport::update_T",
99 "negative temperature {}", t);
100 }
101 GasTransport::update_T();
102 // temperature has changed, so polynomial fits will need to be redone.
103 m_spcond_ok = false;
104 m_bindiff_ok = false;
105 m_condmix_ok = false;
106}
107
109{
110 // signal that concentration-dependent quantities will need to be recomputed
111 // before use, and update the local mole fractions.
112 m_visc_ok = false;
113 m_condmix_ok = false;
115
116 // add an offset to avoid a pure species condition
117 for (size_t k = 0; k < m_nsp; k++) {
118 m_molefracs[k] = std::max(Tiny, m_molefracs[k]);
119 }
120}
121
123{
124 if (m_mode == CK_Mode) {
125 for (size_t k = 0; k < m_nsp; k++) {
126 m_cond[k] = exp(dot4(m_polytempvec, m_condcoeffs[k]));
127 }
128 } else {
129 for (size_t k = 0; k < m_nsp; k++) {
131 }
132 }
133 m_spcond_ok = true;
134 m_condmix_ok = false;
135}
136
137}
Headers for the MixTransport object, which models transport properties in ideal gas solutions using a...
Header file for class ThermoPhase, the base class for phases with thermodynamic properties,...
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:61
vector_fp m_molefracs
Vector of species mole fractions.
Definition: GasTransport.h:296
std::vector< vector_fp > m_condcoeffs
temperature fits of the heat conduction
Definition: GasTransport.h:405
vector_fp m_polytempvec
Powers of the ln temperature, up to fourth order.
Definition: GasTransport.h:356
bool m_visc_ok
Update boolean for mixture rule for the mixture viscosity.
Definition: GasTransport.h:302
bool m_bindiff_ok
Update boolean for the binary diffusivities at unit pressure.
Definition: GasTransport.h:311
doublereal m_temp
Current value of the temperature at which the properties in this object are calculated (Kelvin).
Definition: GasTransport.h:360
int m_mode
Type of the polynomial fits to temperature.
Definition: GasTransport.h:315
virtual void getMixDiffCoeffs(doublereal *const d)
Returns the Mixture-averaged diffusion coefficients [m^2/s].
virtual void init(ThermoPhase *thermo, int mode=0, int log_level=0)
Initialize a transport manager.
vector_fp m_spwork
work space length = m_kk
Definition: GasTransport.h:321
doublereal m_sqrt_t
current value of temperature to 1/2 power
Definition: GasTransport.h:370
virtual void getThermalDiffCoeffs(doublereal *const dt)
Return the thermal diffusion coefficients.
virtual doublereal thermalConductivity()
Returns the mixture thermal conductivity (W/m /K)
virtual void update_T()
Update the internal parameters whenever the temperature has changed.
vector_fp m_cond
vector of species thermal conductivities (W/m /K)
Definition: MixTransport.h:168
bool m_spcond_ok
Update boolean for the species thermal conductivities.
Definition: MixTransport.h:177
virtual void getMobilities(doublereal *const mobil)
Get the Electrical mobilities (m^2/V/s).
void updateCond_T()
Update the temperature dependent parts of the species thermal conductivities.
MixTransport()
Default constructor.
doublereal m_lambda
Internal storage for the calculated mixture thermal conductivity.
Definition: MixTransport.h:174
virtual void init(ThermoPhase *thermo, int mode=0, int log_level=0)
Initialize a transport manager.
virtual void update_C()
Update the internal parameters whenever the concentrations have changed.
bool m_condmix_ok
Update boolean for the mixture rule for the mixture thermal conductivity.
Definition: MixTransport.h:180
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 mass averaged velocity, given the gradients in mole ...
double molarDensity() const
Molar density (kmol/m^3).
Definition: Phase.cpp:671
size_t nSpecies() const
Returns the number of species in the phase.
Definition: Phase.h:273
const vector_fp & molecularWeights() const
Return a const reference to the internal vector of molecular weights.
Definition: Phase.cpp:509
void getMoleFractions(double *const x) const
Get the species mole fraction vector.
Definition: Phase.cpp:543
const double * massFractions() const
Return a const pointer to the mass fraction array.
Definition: Phase.h:532
doublereal temperature() const
Temperature (K).
Definition: Phase.h:654
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:102
ThermoPhase * m_thermo
pointer to the object representing the phase
size_t m_nsp
Number of species.
ThermoPhase & thermo()
Namespace for the Cantera kernel.
Definition: AnyMap.h:29
const double Tiny
Small number to compare differences of mole fractions against.
Definition: ct_defs.h:170
const double Boltzmann
Boltzmann constant [J/K].
Definition: ct_defs.h:69
doublereal dot4(const V &x, const V &y)
Templated Inner product of two vectors of length 4.
Definition: utilities.h:35
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:184
const double ElectronCharge
Elementary charge [C].
Definition: ct_defs.h:75
doublereal dot5(const V &x, const V &y)
Templated Inner product of two vectors of length 5.
Definition: utilities.h:50
Contains declarations for string manipulation functions within Cantera.
Various templated functions that carry out common vector operations (see Templated Utility Functions)...