Cantera 2.6.0
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.
25 * Reference:
26 * Pederson, Timothy, and R. C. Brown.
27 * "Simulation of electric field effects in premixed methane flames."
28 * Combustion and Flames 94.4(1993): 433-448.
29 * @ingroup onedim
30 */
31class IonFlow : public StFlow
32{
33public:
34 IonFlow(IdealGasPhase* ph = 0, size_t nsp = 1, size_t points = 1);
35 //! set the solving stage
36 virtual void setSolvingStage(const size_t phase);
37
38 virtual void resize(size_t components, size_t points);
39 virtual bool componentActive(size_t n) const;
40
41 virtual void _finalize(const double* x);
42 //! set to solve electric field on a point
43 void solveElectricField(size_t j=npos);
44 //! set to fix voltage on a point
45 void fixElectricField(size_t j=npos);
46 bool doElectricField(size_t j) {
47 return m_do_electric_field[j];
48 }
49
50 /**
51 * Sometimes it is desired to carry out the simulation using a specified
52 * electron transport profile, rather than assuming it as a constant (0.4).
53 * Reference:
54 * Bisetti, Fabrizio, and Mbark El Morsli.
55 * "Calculation and analysis of the mobility and diffusion coefficient
56 * of thermal electrons in methane/air premixed flames."
57 * Combustion and flame 159.12 (2012): 3518-3521.
58 * If in the future the class GasTranport is improved, this method may
59 * be discard. This method specifies this profile.
60 */
62 vector_fp& diff_e,
63 vector_fp& mobi_e);
64
65protected:
66 /*!
67 * This function overloads the original function. The residual function
68 * of electric field is added.
69 */
70 virtual void evalResidual(double* x, double* rsd, int* diag,
71 double rdt, size_t jmin, size_t jmax);
72 virtual void updateTransport(double* x, size_t j0, size_t j1);
73 virtual void updateDiffFluxes(const double* x, size_t j0, size_t j1);
74 //! Solving phase one: the fluxes of charged species are turned off
75 virtual void frozenIonMethod(const double* x, size_t j0, size_t j1);
76 //! Solving phase two: the electric field equation is added coupled
77 //! by the electrical drift
78 virtual void electricFieldMethod(const double* x, size_t j0, size_t j1);
79 //! flag for solving electric field or not
80 std::vector<bool> m_do_electric_field;
81
82 //! flag for importing transport of electron
84
85 //! electrical properties
87
88 //! index of species with charges
89 std::vector<size_t> m_kCharge;
90
91 //! index of neutral species
92 std::vector<size_t> m_kNeutral;
93
94 //! coefficients of polynomial fitting of fixed electron transport profile
96 vector_fp m_diff_e_fix;
97
98 //! mobility
100
101 //! solving stage
102 size_t m_stage;
103
104 //! index of electron
106
107 //! electric field
108 double E(const double* x, size_t j) const {
109 return x[index(c_offset_E, j)];
110 }
111
112 double dEdz(const double* x, size_t j) const {
113 return (E(x,j)-E(x,j-1))/(z(j)-z(j-1));
114 }
115
116 //! number density
117 double ND(const double* x, size_t k, size_t j) const {
118 return Avogadro * m_rho[j] * Y(x,k,j) / m_wt[k];
119 }
120
121 //! total charge density
122 double rho_e(double* x, size_t j) const {
123 double chargeDensity = 0.0;
124 for (size_t k : m_kCharge) {
125 chargeDensity += m_speciesCharge[k] * ElectronCharge * ND(x,k,j);
126 }
127 return chargeDensity;
128 }
129};
130
131}
132
133#endif
Class IdealGasPhase represents low-density gases that obey the ideal gas equation of state.
This class models the ion transportation in a flame.
Definition: IonFlow.h:32
virtual void evalResidual(double *x, double *rsd, int *diag, double rdt, size_t jmin, size_t jmax)
Definition: IonFlow.cpp:181
virtual 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:129
double E(const double *x, size_t j) const
electric field
Definition: IonFlow.h:108
vector_fp m_mobi_e_fix
coefficients of polynomial fitting of fixed electron transport profile
Definition: IonFlow.h:95
vector_fp m_speciesCharge
electrical properties
Definition: IonFlow.h:86
virtual void setSolvingStage(const size_t phase)
set the solving stage
Definition: IonFlow.cpp:169
size_t m_kElectron
index of electron
Definition: IonFlow.h:105
virtual 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:102
virtual void _finalize(const double *x)
In some cases, a domain may need to set parameters that depend on the initial solution estimate.
Definition: IonFlow.cpp:283
double rho_e(double *x, size_t j) const
total charge density
Definition: IonFlow.h:122
double ND(const double *x, size_t k, size_t j) const
number density
Definition: IonFlow.h:117
virtual bool componentActive(size_t n) const
Returns true if the specified component is an active part of the solver state.
Definition: IonFlow.cpp:68
virtual void resize(size_t components, size_t points)
Change the grid size. Called after grid refinement.
Definition: IonFlow.cpp:61
size_t m_stage
solving stage
Definition: IonFlow.h:102
vector_fp m_mobility
mobility
Definition: IonFlow.h:99
std::vector< size_t > m_kCharge
index of species with charges
Definition: IonFlow.h:89
std::vector< size_t > m_kNeutral
index of neutral species
Definition: IonFlow.h:92
virtual void updateDiffFluxes(const double *x, size_t j0, size_t j1)
Update the diffusive mass fluxes.
Definition: IonFlow.cpp:92
bool m_import_electron_transport
flag for importing transport of electron
Definition: IonFlow.h:83
void fixElectricField(size_t j=npos)
set to fix voltage on a point
Definition: IonFlow.cpp:241
virtual void updateTransport(double *x, size_t j0, size_t j1)
Update the transport properties at grid points in the range from j0 to j1, based on solution x.
Definition: IonFlow.cpp:77
void solveElectricField(size_t j=npos)
set to solve electric field on a point
Definition: IonFlow.cpp:216
std::vector< bool > m_do_electric_field
flag for solving electric field or not
Definition: IonFlow.h:80
void setElectronTransport(vector_fp &tfix, vector_fp &diff_e, vector_fp &mobi_e)
Sometimes it is desired to carry out the simulation using a specified electron transport profile,...
Definition: IonFlow.cpp:266
This class represents 1D flow domains that satisfy the one-dimensional similarity solution for chemic...
Definition: StFlow.h:37
Namespace for the Cantera kernel.
Definition: AnyMap.h:29
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:192
const double Avogadro
Avogadro's Number [number/kmol].
Definition: ct_defs.h:66
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:184
const double ElectronCharge
Elementary charge [C].
Definition: ct_defs.h:75