Cantera  3.2.0a5
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 //! @deprecated To be removed after %Cantera 3.2. Use constructor using Solution
37 //! instead.
38 IonFlow(ThermoPhase* ph = 0, size_t nsp = 1, size_t points = 1);
39
40 //! Create a new IonFlow domain.
41 //! @param phase Solution object used to evaluate all thermodynamic, kinetic, and
42 //! transport properties
43 //! @param id name of flow domain
44 //! @param points initial number of grid points
45 IonFlow(shared_ptr<Solution> phase, const string& id="", size_t points = 1);
46
47private:
48 //! Initialize arrays.
49 //! @todo Consolidate once legacy constructors are removed after %Cantera 3.2.
50 void _init(ThermoPhase* ph, size_t nsp, size_t points);
51
52public:
53 string domainType() const override;
54
55 size_t getSolvingStage() const override {
56 warn_deprecated("IonFlow::getSolvingStage", "To be removed after Cantera 3.2. "
57 " Use doElectricField() instead.");
58 return (m_do_electric_field) ? 2 : 1;
59 }
60 void setSolvingStage(const size_t stage) override;
61
62 void resize(size_t components, size_t points) override;
63 bool componentActive(size_t n) const override;
64
65 void solveElectricField(size_t j=npos) override;
66 void fixElectricField(size_t j=npos) override;
67 bool doElectricField(size_t j=npos) const override {
68 if (j != npos) {
69 warn_deprecated("IonFlow::doElectricField", "Argument to be removed after "
70 "Cantera 3.2.");
71 }
73 }
74
75 /**
76 * Sometimes it is desired to carry out the simulation using a specified
77 * electron transport profile, rather than assuming it as a constant (0.4).
78 * See Bisetti and El Morsli @cite bisetti2012.
79 * If in the future the class GasTransport is improved, this method may
80 * be discarded. This method specifies this profile.
81 */
82 void setElectronTransport(vector<double>& tfix,
83 vector<double>& diff_e,
84 vector<double>& mobi_e);
85
86protected:
87
88 /**
89 * Evaluate the electric field equation residual by Gauss's law.
90 *
91 * The function calculates the electric field equation as:
92 * @f[
93 * \frac{dE}{dz} = \frac{e}{\varepsilon_0} \sum (q_k \cdot n_k)
94 * @f]
95 *
96 * and
97 *
98 * @f[
99 * E = -\frac{dV}{dz}
100 * @f]
101 *
102 * The electric field equation is based on Gauss's law,
103 * accounting for charge density and permittivity of free space
104 * (@f$ \varepsilon_0 @f$).
105 * The zero electric field is first evaluated and if the solution state is 2,
106 * then the alternative form the electric field equation is evaluated.
107 *
108 * For argument explanation, see evalContinuity() base class.
109 */
110 void evalElectricField(double* x, double* rsd, int* diag,
111 double rdt, size_t jmin, size_t jmax) override;
112
113 /**
114 * Evaluate the species equations' residual. This function overloads the
115 * original species function.
116 *
117 * A Neumann boundary for the charged species at the
118 * left boundary is added, and the default boundary condition from the overloaded
119 * method is left the same for the right boundary.
120 *
121 * For argument explanation, see evalContinuity() base class.
122 */
123 void evalSpecies(double* x, double* rsd, int* diag,
124 double rdt, size_t jmin, size_t jmax) override;
125 void updateTransport(double* x, size_t j0, size_t j1) override;
126 void updateDiffFluxes(const double* x, size_t j0, size_t j1) override;
127 //! Solving phase one: the fluxes of charged species are turned off and the electric
128 //! field is not solved.
129 void frozenIonMethod(const double* x, size_t j0, size_t j1);
130 //! Solving phase two: the electric field equation is added coupled
131 //! by the electrical drift
132 void electricFieldMethod(const double* x, size_t j0, size_t j1);
133 //! flag for solving electric field or not
135
136 //! flag for importing transport of electron
138
139 //! electrical properties
140 vector<double> m_speciesCharge;
141
142 //! index of species with charges
143 vector<size_t> m_kCharge;
144
145 //! index of neutral species
146 vector<size_t> m_kNeutral;
147
148 //! Coefficients of polynomial fit for electron mobility as a function of
149 //! temperature.
150 //! @see setElectronTransport
151 vector<double> m_mobi_e_fix;
152
153 //! Coefficients of polynomial fit for electron diffusivity as a function of
154 //! temperature.
155 //! @see setElectronTransport
156 vector<double> m_diff_e_fix;
157
158 //! mobility
159 vector<double> m_mobility;
160
161 //! index of electron
163
164 //! electric field [V/m]
165 double E(const double* x, size_t j) const {
166 return x[index(c_offset_E, j)];
167 }
168
169 //! Axial gradient of the electric field [V/m²]
170 double dEdz(const double* x, size_t j) const {
171 return (E(x,j)-E(x,j-1))/(z(j)-z(j-1));
172 }
173
174 //! number density [molecules/m³]
175 double ND(const double* x, size_t k, size_t j) const {
176 return Avogadro * m_rho[j] * Y(x,k,j) / m_wt[k];
177 }
178
179 //! total charge density
180 double rho_e(double* x, size_t j) const {
181 double chargeDensity = 0.0;
182 for (size_t k : m_kCharge) {
183 chargeDensity += m_speciesCharge[k] * ElectronCharge * ND(x,k,j);
184 }
185 return chargeDensity;
186 }
187};
188
189}
190
191#endif
double z(size_t jlocal) const
Get the coordinate [m] of the point with local index jlocal
Definition Domain1D.h:731
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:408
This class represents 1D flow domains that satisfy the one-dimensional similarity solution for chemic...
Definition Flow1D.h:47
ThermoPhase & phase()
Access the phase object used to compute thermodynamic properties for points in this domain.
Definition Flow1D.h:93
vector< double > m_rho
Density at each grid point.
Definition Flow1D.h:930
vector< double > m_wt
Molecular weight of each species.
Definition Flow1D.h:932
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:763
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:143
vector< double > m_diff_e_fix
Coefficients of polynomial fit for electron diffusivity as a function of temperature.
Definition IonFlow.h:156
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:157
double E(const double *x, size_t j) const
electric field [V/m]
Definition IonFlow.h:165
size_t m_kElectron
index of electron
Definition IonFlow.h:162
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:132
void resize(size_t components, size_t points) override
Change the grid size. Called after grid refinement.
Definition IonFlow.cpp:92
bool m_do_electric_field
flag for solving electric field or not
Definition IonFlow.h:134
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:286
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:211
double rho_e(double *x, size_t j) const
total charge density
Definition IonFlow.h:180
size_t getSolvingStage() const override
Get the solving stage (used by IonFlow specialization)
Definition IonFlow.h:55
double ND(const double *x, size_t k, size_t j) const
number density [molecules/m³]
Definition IonFlow.h:175
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:106
void _init(ThermoPhase *ph, size_t nsp, size_t points)
Initialize arrays.
Definition IonFlow.cpp:26
vector< double > m_mobility
mobility
Definition IonFlow.h:159
double dEdz(const double *x, size_t j) const
Axial gradient of the electric field [V/m²].
Definition IonFlow.h:170
void updateDiffFluxes(const double *x, size_t j0, size_t j1) override
Update the diffusive mass fluxes.
Definition IonFlow.cpp:123
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:236
void setSolvingStage(const size_t stage) override
Solving stage mode for handling ionized species (used by IonFlow specialization)
Definition IonFlow.cpp:194
bool m_import_electron_transport
flag for importing transport of electron
Definition IonFlow.h:137
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:67
void solveElectricField(size_t j=npos) override
Set to solve electric field in a point (used by IonFlow specialization)
Definition IonFlow.cpp:254
void fixElectricField(size_t j=npos) override
Set to fix voltage in a point (used by IonFlow specialization)
Definition IonFlow.cpp:270
string domainType() const override
Domain type flag.
Definition IonFlow.cpp:82
vector< size_t > m_kNeutral
index of neutral species
Definition IonFlow.h:146
vector< double > m_mobi_e_fix
Coefficients of polynomial fit for electron mobility as a function of temperature.
Definition IonFlow.h:151
bool componentActive(size_t n) const override
Returns true if the specified component is an active part of the solver state.
Definition IonFlow.cpp:97
vector< double > m_speciesCharge
electrical properties
Definition IonFlow.h:140
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:30
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