Cantera  4.0.0a1
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 phase Solution object used to evaluate all thermodynamic, kinetic, and
33 //! transport properties
34 //! @param id name of flow domain
35 //! @param points initial number of grid points
36 IonFlow(shared_ptr<Solution> phase, const string& id="", size_t points = 1);
37
38 string domainType() const override;
39
40 void resize(size_t components, size_t points) override;
41 bool componentActive(size_t n) const override;
42
43 void solveElectricField() override;
44 void fixElectricField() override;
45 bool doElectricField() const override {
47 }
48
49 /**
50 * Sometimes it is desired to carry out the simulation using a specified
51 * electron transport profile, rather than assuming it as a constant (0.4).
52 * See Bisetti and El Morsli @cite bisetti2012.
53 * If in the future the class GasTransport is improved, this method may
54 * be discarded. This method specifies this profile.
55 */
56 void setElectronTransport(span<const double> tfix, span<const double> diff_e,
57 span<const double> mobi_e);
58
59protected:
60
61 /**
62 * Evaluate the electric field equation residual by Gauss's law.
63 *
64 * The function calculates the electric field equation as:
65 * @f[
66 * \frac{dE}{dz} = \frac{e}{\varepsilon_0} \sum (q_k \cdot n_k)
67 * @f]
68 *
69 * and
70 *
71 * @f[
72 * E = -\frac{dV}{dz}
73 * @f]
74 *
75 * The electric field equation is based on Gauss's law,
76 * accounting for charge density and permittivity of free space
77 * (@f$ \varepsilon_0 @f$).
78 * The zero electric field is first evaluated and if the solution state is 2,
79 * then the alternative form the electric field equation is evaluated.
80 *
81 * For argument explanation, see evalContinuity() base class.
82 */
83 void evalElectricField(span<const double> x, span<double> rsd, span<int> diag,
84 double rdt, size_t jmin, size_t jmax) override;
85
86 /**
87 * Evaluate the species equations' residual. This function overloads the
88 * original species function.
89 *
90 * A Neumann boundary for the charged species at the
91 * left boundary is added, and the default boundary condition from the overloaded
92 * method is left the same for the right boundary.
93 *
94 * For argument explanation, see evalContinuity() base class.
95 */
96 void evalSpecies(span<const double> x, span<double> rsd, span<int> diag,
97 double rdt, size_t jmin, size_t jmax) override;
98 void updateTransport(span<const double> x, size_t j0, size_t j1) override;
99 void updateDiffFluxes(span<const double> x, size_t j0, size_t j1) override;
100 //! Solving phase one: the fluxes of charged species are turned off and the electric
101 //! field is not solved.
102 void frozenIonMethod(span<const double> x, size_t j0, size_t j1);
103 //! Solving phase two: the electric field equation is added coupled
104 //! by the electrical drift
105 void electricFieldMethod(span<const double> x, size_t j0, size_t j1);
106 //! flag for solving electric field or not
108
109 //! flag for importing transport of electron
111
112 //! electrical properties
113 vector<double> m_speciesCharge;
114
115 //! index of species with charges
116 vector<size_t> m_kCharge;
117
118 //! index of neutral species
119 vector<size_t> m_kNeutral;
120
121 //! Coefficients of polynomial fit for electron mobility as a function of
122 //! temperature.
123 //! @see setElectronTransport
124 vector<double> m_mobi_e_fix;
125
126 //! Coefficients of polynomial fit for electron diffusivity as a function of
127 //! temperature.
128 //! @see setElectronTransport
129 vector<double> m_diff_e_fix;
130
131 //! mobility
132 vector<double> m_mobility;
133
134 //! index of electron
136
137 //! electric field [V/m]
138 double E(span<const double> x, size_t j) const {
139 return x[index(c_offset_E, j)];
140 }
141
142 //! Axial gradient of the electric field [V/m²]
143 double dEdz(span<const double> x, size_t j) const {
144 return (E(x,j)-E(x,j-1))/(z(j)-z(j-1));
145 }
146
147 //! number density [molecules/m³]
148 double ND(span<const double> x, size_t k, size_t j) const {
149 return Avogadro * m_rho[j] * Y(x,k,j) / m_wt[k];
150 }
151
152 //! total charge density
153 double rho_e(span<const double> x, size_t j) const {
154 double chargeDensity = 0.0;
155 for (size_t k : m_kCharge) {
156 chargeDensity += m_speciesCharge[k] * ElectronCharge * ND(x,k,j);
157 }
158 return chargeDensity;
159 }
160};
161
162}
163
164#endif
double z(size_t jlocal) const
Get the coordinate [m] of the point with local index jlocal
Definition Domain1D.h:590
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:332
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:69
vector< double > m_rho
Density at each grid point.
Definition Flow1D.h:884
double Y(span< 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:711
vector< double > m_wt
Molecular weight of each species.
Definition Flow1D.h:886
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:116
vector< double > m_diff_e_fix
Coefficients of polynomial fit for electron diffusivity as a function of temperature.
Definition IonFlow.h:129
size_t m_kElectron
index of electron
Definition IonFlow.h:135
void setElectronTransport(span< const double > tfix, span< const double > diff_e, span< const double > mobi_e)
Sometimes it is desired to carry out the simulation using a specified electron transport profile,...
Definition IonFlow.cpp:250
void resize(size_t components, size_t points) override
Change the grid size. Called after grid refinement.
Definition IonFlow.cpp:80
bool m_do_electric_field
flag for solving electric field or not
Definition IonFlow.h:107
void evalElectricField(span< const double > x, span< double > rsd, span< int > diag, double rdt, size_t jmin, size_t jmax) override
Evaluate the electric field equation residual by Gauss's law.
Definition IonFlow.cpp:183
void electricFieldMethod(span< 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:145
double rho_e(span< const double > x, size_t j) const
total charge density
Definition IonFlow.h:153
double ND(span< const double > x, size_t k, size_t j) const
number density [molecules/m³]
Definition IonFlow.h:148
void frozenIonMethod(span< 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:120
vector< double > m_mobility
mobility
Definition IonFlow.h:132
void fixElectricField() override
Set to fix voltage in a point (used by IonFlow specialization)
Definition IonFlow.cpp:238
bool doElectricField() const override
Retrieve flag indicating whether electric field is solved or not (used by IonFlow specialization)
Definition IonFlow.h:45
double E(span< const double > x, size_t j) const
electric field [V/m]
Definition IonFlow.h:138
void updateDiffFluxes(span< const double > x, size_t j0, size_t j1) override
Update the diffusive mass fluxes.
Definition IonFlow.cpp:111
bool m_import_electron_transport
flag for importing transport of electron
Definition IonFlow.h:110
void evalSpecies(span< const double > x, span< double > rsd, span< int > diag, double rdt, size_t jmin, size_t jmax) override
Evaluate the species equations' residual.
Definition IonFlow.cpp:208
double dEdz(span< const double > x, size_t j) const
Axial gradient of the electric field [V/m²].
Definition IonFlow.h:143
string domainType() const override
Domain type flag.
Definition IonFlow.cpp:70
vector< size_t > m_kNeutral
index of neutral species
Definition IonFlow.h:119
vector< double > m_mobi_e_fix
Coefficients of polynomial fit for electron mobility as a function of temperature.
Definition IonFlow.h:124
void solveElectricField() override
Set to solve electric field in a point (used by IonFlow specialization)
Definition IonFlow.cpp:226
bool componentActive(size_t n) const override
Returns true if the specified component is an active part of the solver state.
Definition IonFlow.cpp:85
void updateTransport(span< const 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:94
vector< double > m_speciesCharge
electrical properties
Definition IonFlow.h:113
const double Avogadro
Avogadro's Number [number/kmol].
Definition ct_defs.h:84
const double ElectronCharge
Elementary charge [C].
Definition ct_defs.h:93
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:183
@ c_offset_E
electric field
Definition Flow1D.h:30