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