Cantera  3.2.0a2
Loading...
Searching...
No Matches
IonFlow.h
Go to the documentation of this file.
1//! @file IonFlow.h
2
3// This file is part of Cantera. See License.txt in the top-level directory or
4// at https://cantera.org/license.txt for license and copyright information.
5
6#ifndef CT_IONFLOW_H
7#define CT_IONFLOW_H
8
10
11namespace Cantera
12{
13/**
14 * This class models the ion transportation in a flame. There are three
15 * stages of the simulation.
16 *
17 * The first stage turns off the diffusion of ions due to the fast
18 * diffusion rate of electron without internal electric forces (ambi-
19 * polar diffusion effect).
20 *
21 * The second stage evaluates drift flux from electric field calculated from
22 * Poisson's equation, which is solved together with other equations. Poisson's
23 * equation is coupled because the total charge densities depends on the species'
24 * concentration. See Pedersen and Brown @cite pedersen1993 for details.
25 *
26 * @ingroup flowGroup
27 */
28class IonFlow : public Flow1D
29{
30public:
31 //! Create a new IonFlow domain.
32 //! @param ph Object representing the gas phase. This object will be used
33 //! to evaluate all thermodynamic, kinetic, and transport properties.
34 //! @param nsp Number of species.
35 //! @param points Initial number of grid points
36 IonFlow(ThermoPhase* ph = 0, size_t nsp = 1, size_t points = 1);
37
38 //! Create a new IonFlow domain.
39 //! @param sol Solution object used to evaluate all thermodynamic, kinetic, and
40 //! transport properties
41 //! @param id name of flow domain
42 //! @param points initial number of grid points
43 IonFlow(shared_ptr<Solution> sol, const string& id="", size_t points = 1);
44
45 string domainType() const override;
46
47 size_t getSolvingStage() const override {
48 warn_deprecated("IonFlow::getSolvingStage", "To be removed after Cantera 3.2. "
49 " Use doElectricField() instead.");
50 return (m_do_electric_field) ? 2 : 1;
51 }
52 void setSolvingStage(const size_t stage) override;
53
54 void resize(size_t components, size_t points) override;
55 bool componentActive(size_t n) const override;
56
57 void solveElectricField(size_t j=npos) override;
58 void fixElectricField(size_t j=npos) override;
59 bool doElectricField(size_t j=npos) const override {
60 if (j != npos) {
61 warn_deprecated("IonFlow::doElectricField", "Argument to be removed after "
62 "Cantera 3.2.");
63 }
65 }
66
67 /**
68 * Sometimes it is desired to carry out the simulation using a specified
69 * electron transport profile, rather than assuming it as a constant (0.4).
70 * See Bisetti and El Morsli @cite bisetti2012.
71 * If in the future the class GasTransport is improved, this method may
72 * be discarded. This method specifies this profile.
73 */
74 void setElectronTransport(vector<double>& tfix,
75 vector<double>& diff_e,
76 vector<double>& mobi_e);
77
78protected:
79
80 /**
81 * Evaluate the electric field equation residual by Gauss's law.
82 *
83 * The function calculates the electric field equation as:
84 * @f[
85 * \frac{dE}{dz} = \frac{e}{\varepsilon_0} \sum (q_k \cdot n_k)
86 * @f]
87 *
88 * and
89 *
90 * @f[
91 * E = -\frac{dV}{dz}
92 * @f]
93 *
94 * The electric field equation is based on Gauss's law,
95 * accounting for charge density and permittivity of free space
96 * (@f$ \varepsilon_0 @f$).
97 * The zero electric field is first evaluated and if the solution state is 2,
98 * then the alternative form the electric field equation is evaluated.
99 *
100 * For argument explanation, see evalContinuity() base class.
101 */
102 void evalElectricField(double* x, double* rsd, int* diag,
103 double rdt, size_t jmin, size_t jmax) override;
104
105 /**
106 * Evaluate the species equations' residual. This function overloads the
107 * original species function.
108 *
109 * A Neumann boundary for the charged species at the
110 * left boundary is added, and the default boundary condition from the overloaded
111 * method is left the same for the right boundary.
112 *
113 * For argument explanation, see evalContinuity() base class.
114 */
115 void evalSpecies(double* x, double* rsd, int* diag,
116 double rdt, size_t jmin, size_t jmax) override;
117 void updateTransport(double* x, size_t j0, size_t j1) override;
118 void updateDiffFluxes(const double* x, size_t j0, size_t j1) override;
119 //! Solving phase one: the fluxes of charged species are turned off and the electric
120 //! field is not solved.
121 void frozenIonMethod(const double* x, size_t j0, size_t j1);
122 //! Solving phase two: the electric field equation is added coupled
123 //! by the electrical drift
124 void electricFieldMethod(const double* x, size_t j0, size_t j1);
125 //! flag for solving electric field or not
127
128 //! flag for importing transport of electron
130
131 //! electrical properties
132 vector<double> m_speciesCharge;
133
134 //! index of species with charges
135 vector<size_t> m_kCharge;
136
137 //! index of neutral species
138 vector<size_t> m_kNeutral;
139
140 //! Coefficients of polynomial fit for electron mobility as a function of
141 //! temperature.
142 //! @see setElectronTransport
143 vector<double> m_mobi_e_fix;
144
145 //! Coefficients of polynomial fit for electron diffusivity as a function of
146 //! temperature.
147 //! @see setElectronTransport
148 vector<double> m_diff_e_fix;
149
150 //! mobility
151 vector<double> m_mobility;
152
153 //! index of electron
155
156 //! electric field [V/m]
157 double E(const double* x, size_t j) const {
158 return x[index(c_offset_E, j)];
159 }
160
161 //! Axial gradient of the electric field [V/m²]
162 double dEdz(const double* x, size_t j) const {
163 return (E(x,j)-E(x,j-1))/(z(j)-z(j-1));
164 }
165
166 //! number density [molecules/m³]
167 double ND(const double* x, size_t k, size_t j) const {
168 return Avogadro * m_rho[j] * Y(x,k,j) / m_wt[k];
169 }
170
171 //! total charge density
172 double rho_e(double* x, size_t j) const {
173 double chargeDensity = 0.0;
174 for (size_t k : m_kCharge) {
175 chargeDensity += m_speciesCharge[k] * ElectronCharge * ND(x,k,j);
176 }
177 return chargeDensity;
178 }
179};
180
181}
182
183#endif
double z(size_t jlocal) const
Get the coordinate [m] of the point with local index jlocal
Definition Domain1D.h:484
size_t index(size_t n, size_t j) const
Returns the index of the solution vector, which corresponds to component n at grid point j.
Definition Domain1D.h:335
This class represents 1D flow domains that satisfy the one-dimensional similarity solution for chemic...
Definition Flow1D.h:46
vector< double > m_rho
Density at each grid point.
Definition Flow1D.h:858
vector< double > m_wt
Molecular weight of each species.
Definition Flow1D.h:860
double Y(const double *x, size_t k, size_t j) const
Get the mass fraction of species k at point j from the local state vector x.
Definition Flow1D.h:691
This class models the ion transportation in a flame.
Definition IonFlow.h:29
vector< size_t > m_kCharge
index of species with charges
Definition IonFlow.h:135
vector< double > m_diff_e_fix
Coefficients of polynomial fit for electron diffusivity as a function of temperature.
Definition IonFlow.h:148
void electricFieldMethod(const double *x, size_t j0, size_t j1)
Solving phase two: the electric field equation is added coupled by the electrical drift.
Definition IonFlow.cpp:148
double E(const double *x, size_t j) const
electric field [V/m]
Definition IonFlow.h:157
size_t m_kElectron
index of electron
Definition IonFlow.h:154
void frozenIonMethod(const double *x, size_t j0, size_t j1)
Solving phase one: the fluxes of charged species are turned off and the electric field is not solved.
Definition IonFlow.cpp:123
void resize(size_t components, size_t points) override
Change the grid size. Called after grid refinement.
Definition IonFlow.cpp:83
bool m_do_electric_field
flag for solving electric field or not
Definition IonFlow.h:126
void setElectronTransport(vector< double > &tfix, vector< double > &diff_e, vector< double > &mobi_e)
Sometimes it is desired to carry out the simulation using a specified electron transport profile,...
Definition IonFlow.cpp:277
void evalElectricField(double *x, double *rsd, int *diag, double rdt, size_t jmin, size_t jmax) override
Evaluate the electric field equation residual by Gauss's law.
Definition IonFlow.cpp:202
double rho_e(double *x, size_t j) const
total charge density
Definition IonFlow.h:172
size_t getSolvingStage() const override
Get the solving stage (used by IonFlow specialization)
Definition IonFlow.h:47
double ND(const double *x, size_t k, size_t j) const
number density [molecules/m³]
Definition IonFlow.h:167
void updateTransport(double *x, size_t j0, size_t j1) override
Update the transport properties at grid points in the range from j0 to j1, based on solution x.
Definition IonFlow.cpp:97
vector< double > m_mobility
mobility
Definition IonFlow.h:151
double dEdz(const double *x, size_t j) const
Axial gradient of the electric field [V/m²].
Definition IonFlow.h:162
void updateDiffFluxes(const double *x, size_t j0, size_t j1) override
Update the diffusive mass fluxes.
Definition IonFlow.cpp:114
void evalSpecies(double *x, double *rsd, int *diag, double rdt, size_t jmin, size_t jmax) override
Evaluate the species equations' residual.
Definition IonFlow.cpp:227
void setSolvingStage(const size_t stage) override
Solving stage mode for handling ionized species (used by IonFlow specialization)
Definition IonFlow.cpp:185
bool m_import_electron_transport
flag for importing transport of electron
Definition IonFlow.h:129
bool doElectricField(size_t j=npos) const override
Retrieve flag indicating whether electric field is solved or not (used by IonFlow specialization)
Definition IonFlow.h:59
void solveElectricField(size_t j=npos) override
Set to solve electric field in a point (used by IonFlow specialization)
Definition IonFlow.cpp:245
void fixElectricField(size_t j=npos) override
Set to fix voltage in a point (used by IonFlow specialization)
Definition IonFlow.cpp:261
string domainType() const override
Domain type flag.
Definition IonFlow.cpp:73
vector< size_t > m_kNeutral
index of neutral species
Definition IonFlow.h:138
vector< double > m_mobi_e_fix
Coefficients of polynomial fit for electron mobility as a function of temperature.
Definition IonFlow.h:143
bool componentActive(size_t n) const override
Returns true if the specified component is an active part of the solver state.
Definition IonFlow.cpp:88
vector< double > m_speciesCharge
electrical properties
Definition IonFlow.h:132
Base class for a phase with thermodynamic properties.
const double Avogadro
Avogadro's Number [number/kmol].
Definition ct_defs.h:81
const double ElectronCharge
Elementary charge [C].
Definition ct_defs.h:90
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595
const size_t npos
index returned by functions to indicate "no position"
Definition ct_defs.h:180
@ c_offset_E
electric field
Definition Flow1D.h:29
void warn_deprecated(const string &source, const AnyBase &node, const string &message)
A deprecation warning for syntax in an input file.
Definition AnyMap.cpp:1997