Cantera  2.1.2
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 // copyright 2001 California Institute of Technology
6 
9 
10 #include "cantera/base/utilities.h"
14 
15 using namespace std;
16 
17 namespace Cantera
18 {
19 MixTransport::MixTransport() :
20  m_condcoeffs(0),
21  m_cond(0),
22  m_lambda(0.0),
23  m_spcond_ok(false),
24  m_condmix_ok(false),
25  m_debug(false)
26 {
27 }
28 
30  GasTransport(right),
31  m_condcoeffs(0),
32  m_cond(0),
33  m_lambda(0.0),
34  m_spcond_ok(false),
35  m_condmix_ok(false),
36  m_debug(false)
37 {
38  *this = right;
39 }
40 
41 MixTransport& MixTransport::operator=(const MixTransport& right)
42 {
43  if (&right == this) {
44  return *this;
45  }
46  GasTransport::operator=(right);
47 
48  m_condcoeffs = right.m_condcoeffs;
49  m_cond = right.m_cond;
50  m_lambda = right.m_lambda;
51  m_spcond_ok = right.m_spcond_ok;
52  m_condmix_ok = right.m_condmix_ok;
53  m_debug = right.m_debug;
54 
55  return *this;
56 }
57 
59 {
60  return new MixTransport(*this);
61 }
62 
64 {
66 
67  m_eps = tr.eps;
68  m_sigma = tr.sigma;
69  m_alpha = tr.alpha;
70  m_dipole = tr.dipole;
71  m_zrot = tr.zrot;
72  m_crot = tr.crot;
73 
74  // copy polynomials and parameters into local storage
76 
77  m_cond.resize(m_nsp);
78 
79  // set flags all false
80  m_spcond_ok = false;
81  m_condmix_ok = false;
82 
83  return true;
84 }
85 
86 void MixTransport::getMobilities(doublereal* const mobil)
87 {
89  doublereal c1 = ElectronCharge / (Boltzmann * m_temp);
90  for (size_t k = 0; k < m_nsp; k++) {
91  mobil[k] = c1 * m_spwork[k];
92  }
93 }
94 
96 {
97  update_T();
98  update_C();
99 
100  if (!m_spcond_ok) {
101  updateCond_T();
102  }
103  if (!m_condmix_ok) {
104  doublereal sum1 = 0.0, sum2 = 0.0;
105  for (size_t k = 0; k < m_nsp; k++) {
106  sum1 += m_molefracs[k] * m_cond[k];
107  sum2 += m_molefracs[k] / m_cond[k];
108  }
109  m_lambda = 0.5*(sum1 + 1.0/sum2);
110  m_condmix_ok = true;
111  }
112  return m_lambda;
113 }
114 
115 void MixTransport::getThermalDiffCoeffs(doublereal* const dt)
116 {
117  for (size_t k = 0; k < m_nsp; k++) {
118  dt[k] = 0.0;
119  }
120 }
121 
122 void MixTransport::getSpeciesFluxes(size_t ndim, const doublereal* const grad_T,
123  size_t ldx, const doublereal* const grad_X,
124  size_t ldf, doublereal* const fluxes)
125 {
126  update_T();
127  update_C();
128 
130 
131  const vector_fp& mw = m_thermo->molecularWeights();
132  const doublereal* y = m_thermo->massFractions();
133  doublereal rhon = m_thermo->molarDensity();
134 
135  vector_fp sum(ndim,0.0);
136  for (size_t n = 0; n < ndim; n++) {
137  for (size_t k = 0; k < m_nsp; k++) {
138  fluxes[n*ldf + k] = -rhon * mw[k] * m_spwork[k] * grad_X[n*ldx + k];
139  sum[n] += fluxes[n*ldf + k];
140  }
141  }
142  // add correction flux to enforce sum to zero
143  for (size_t n = 0; n < ndim; n++) {
144  for (size_t k = 0; k < m_nsp; k++) {
145  fluxes[n*ldf + k] -= y[k]*sum[n];
146  }
147  }
148 }
149 
151 {
152  doublereal t = m_thermo->temperature();
153  if (t == m_temp) {
154  return;
155  }
156  if (t < 0.0) {
157  throw CanteraError("MixTransport::update_T",
158  "negative temperature "+fp2str(t));
159  }
160  GasTransport::update_T();
161  // temperature has changed, so polynomial fits will need to be redone.
162  m_spcond_ok = false;
163  m_bindiff_ok = false;
164  m_condmix_ok = false;
165 }
166 
168 {
169  // signal that concentration-dependent quantities will need to
170  // be recomputed before use, and update the local mole
171  // fractions.
172 
173  m_visc_ok = false;
174  m_condmix_ok = false;
175 
177 
178  // add an offset to avoid a pure species condition
179  for (size_t k = 0; k < m_nsp; k++) {
180  m_molefracs[k] = std::max(Tiny, m_molefracs[k]);
181  }
182 }
183 
185 {
186  if (m_mode == CK_Mode) {
187  for (size_t k = 0; k < m_nsp; k++) {
188  m_cond[k] = exp(dot4(m_polytempvec, m_condcoeffs[k]));
189  }
190  } else {
191  for (size_t k = 0; k < m_nsp; k++) {
193  }
194  }
195  m_spcond_ok = true;
196  m_condmix_ok = false;
197 }
198 
199 }
std::vector< vector_fp > m_condcoeffs
Polynomial fits to the thermal conductivity of each species.
Definition: MixTransport.h:199
This structure holds transport model parameters relevant to transport in ideal gases with a kinetic t...
vector_fp m_cond
vector of species thermal conductivities (W/m /K)
Definition: MixTransport.h:206
vector_fp alpha
Polarizability of each species in the phase.
bool m_visc_ok
Update boolean for mixture rule for the mixture viscosity.
Definition: GasTransport.h:147
Various templated functions that carry out common vector operations (see Templated Utility Functions)...
doublereal dot4(const V &x, const V &y)
Templated Inner product of two vectors of length 4.
Definition: utilities.h:67
bool m_condmix_ok
Update boolean for the mixture rule for the mixture thermal conductivity.
Definition: MixTransport.h:218
virtual void update_C()
Update the internal parameters whenever the concentrations have changed.
bool m_bindiff_ok
Update boolean for the binary diffusivities at unit pressure.
Definition: GasTransport.h:156
thermo_t * m_thermo
pointer to the object representing the phase
Base class for transport property managers.
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 ...
vector_fp sigma
Lennard-Jones diameter of the species in the current phase.
doublereal molarDensity() const
Molar density (kmol/m^3).
Definition: Phase.cpp:597
void getMoleFractions(doublereal *const x) const
Get the species mole fraction vector.
Definition: Phase.cpp:519
doublereal m_temp
Current value of the temperature at which the properties in this object are calculated (Kelvin)...
Definition: GasTransport.h:205
bool m_spcond_ok
Update boolean for the species thermal conductivities.
Definition: MixTransport.h:215
Header file defining class TransportFactory (see TransportFactory)
virtual void getMobilities(doublereal *const mobil)
Get the Electrical mobilities (m^2/V/s).
int m_mode
Type of the polynomial fits to temperature.
Definition: GasTransport.h:160
virtual void update_T()
Update the internal parameters whenever the temperature has changed.
vector_fp zrot
Rotational relaxation number for the species in the current phase.
vector_fp eps
Lennard-Jones well-depth of the species in the current phase.
void updateCond_T()
Update the temperature dependent parts of the species thermal conductivities.
virtual bool initGas(GasTransportParams &tr)
Initialize the transport object.
vector_fp m_spwork
work space length = m_kk
Definition: GasTransport.h:166
std::string fp2str(const double x, const std::string &fmt)
Convert a double into a c++ string.
Definition: stringUtils.cpp:29
const doublereal * massFractions() const
Return a const pointer to the mass fraction array.
Definition: Phase.h:454
virtual void getMixDiffCoeffs(doublereal *const d)
Returns the Mixture-averaged diffusion coefficients [m^2/s].
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:68
vector_fp m_polytempvec
Powers of the ln temperature, up to fourth order.
Definition: GasTransport.h:201
vector_fp crot
Dimensionless rotational heat capacity of the species in the current phase.
MixTransport()
Default constructor.
virtual bool initGas(GasTransportParams &tr)
Called by TransportFactory to set parameters.
const vector_fp & molecularWeights() const
Return a const reference to the internal vector of molecular weights.
Definition: Phase.cpp:505
doublereal m_lambda
Internal storage for the calculated mixture thermal conductivity.
Definition: MixTransport.h:212
doublereal temperature() const
Temperature (K).
Definition: Phase.h:528
bool m_debug
Debug flag - turns on more printing.
Definition: MixTransport.h:228
doublereal dot5(const V &x, const V &y)
Templated Inner product of two vectors of length 5.
Definition: utilities.h:85
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:165
DenseMatrix dipole
The effective dipole moment for (i,j) collisions.
doublereal m_sqrt_t
current value of temperature to 1/2 power
Definition: GasTransport.h:215
const doublereal Tiny
Small number to compare differences of mole fractions against.
Definition: ct_defs.h:155
virtual Transport * duplMyselfAsTransport() const
Duplication routine for objects which inherit from Transport.
std::vector< vector_fp > condcoeffs
temperature-fits of the heat conduction
Contains declarations for string manipulation functions within Cantera.
#define DATA_PTR(vec)
Creates a pointer to the start of the raw data for a vector.
Definition: ct_defs.h:36
size_t m_nsp
Number of species.
virtual void getThermalDiffCoeffs(doublereal *const dt)
Return the thermal diffusion coefficients.
Class MixTransport implements mixture-averaged transport properties for ideal gas mixtures...
Definition: MixTransport.h:56
Header file for class ThermoPhase, the base class for phases with thermodynamic properties, and the text for the Module thermoprops (see Thermodynamic Properties and class ThermoPhase).
virtual doublereal thermalConductivity()
Returns the mixture thermal conductivity (W/m /K)
Headers for the MixTransport object, which models transport properties in ideal gas solutions using a...
Class that holds the data that is read in from the xml file, and which is used for processing of the ...
const doublereal Boltzmann
Boltzmann's constant [J/K].
Definition: ct_defs.h:78
vector_fp m_molefracs
Vector of species mole fractions.
Definition: GasTransport.h:141
Class GasTransport implements some functions and properties that are shared by the MixTransport and M...
Definition: GasTransport.h:16