Cantera  2.4.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 http://www.cantera.org/license.txt for license and copyright information.
5 
6 #ifndef CT_IONFLOW_H
7 #define CT_IONFLOW_H
8 
9 #include "cantera/oneD/StFlow.h"
10 
11 namespace 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  */
31 class IonFlow : public StFlow
32 {
33 public:
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 
40  virtual void _finalize(const double* x);
41  //! set to solve electric field on a point
42  void solveElectricField(size_t j=npos);
43  //! set to fix voltage on a point
44  void fixElectricField(size_t j=npos);
45  bool doElectricField(size_t j) {
46  return m_do_electric_field[j];
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  * Reference:
53  * Bisetti, Fabrizio, and Mbark El Morsli.
54  * "Calculation and analysis of the mobility and diffusion coefficient
55  * of thermal electrons in methane/air premixed flames."
56  * Combustion and flame 159.12 (2012): 3518-3521.
57  * If in the future the class GasTranport is improved, this method may
58  * be discard. This method specifies this profile.
59  */
61  vector_fp& diff_e,
62  vector_fp& mobi_e);
63 
64 protected:
65  /*!
66  * This function overloads the original function. The residual function
67  * of electric field is added.
68  */
69  virtual void evalResidual(double* x, double* rsd, int* diag,
70  double rdt, size_t jmin, size_t jmax);
71  virtual void updateTransport(double* x, size_t j0, size_t j1);
72  virtual void updateDiffFluxes(const double* x, size_t j0, size_t j1);
73  //! Solving phase one: the fluxes of charged species are turned off
74  virtual void frozenIonMethod(const double* x, size_t j0, size_t j1);
75  //! Solving phase two: the electric field equation is added coupled
76  //! by the electrical drift
77  virtual void electricFieldMethod(const double* x, size_t j0, size_t j1);
78  //! flag for solving electric field or not
79  std::vector<bool> m_do_electric_field;
80 
81  //! flag for importing transport of electron
83 
84  //! electrical properties
86 
87  //! index of species with charges
88  std::vector<size_t> m_kCharge;
89 
90  //! index of neutral species
91  std::vector<size_t> m_kNeutral;
92 
93  //! coefficients of polynomial fitting of fixed electron transport profile
95  vector_fp m_diff_e_fix;
96 
97  //! mobility
99 
100  //! solving stage
101  int m_stage;
102 
103  //! index of electron
104  size_t m_kElectron;
105 
106  //! electric field
107  double E(const double* x, size_t j) const {
108  return x[index(c_offset_E, j)];
109  }
110 
111  double dEdz(const double* x, size_t j) const {
112  return (E(x,j)-E(x,j-1))/(z(j)-z(j-1));
113  }
114 
115  //! number density
116  double ND(const double* x, size_t k, size_t j) const {
117  return Avogadro * m_rho[j] * Y(x,k,j) / m_wt[k];
118  }
119 
120  //! total charge density
121  double rho_e(double* x, size_t j) const {
122  double chargeDensity = 0.0;
123  for (size_t k : m_kCharge) {
124  chargeDensity += m_speciesCharge[k] * ElectronCharge * ND(x,k,j);
125  }
126  return chargeDensity;
127  }
128 };
129 
130 }
131 
132 #endif
void solveElectricField(size_t j=npos)
set to solve electric field on a point
Definition: IonFlow.cpp:205
virtual void resize(size_t components, size_t points)
Change the grid size. Called after grid refinement.
Definition: IonFlow.cpp:59
vector_fp m_mobility
mobility
Definition: IonFlow.h:98
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:66
bool m_import_electron_transport
flag for importing transport of electron
Definition: IonFlow.h:82
size_t m_kElectron
index of electron
Definition: IonFlow.h:104
This class represents 1D flow domains that satisfy the one-dimensional similarity solution for chemic...
Definition: StFlow.h:36
Class IdealGasPhase represents low-density gases that obey the ideal gas equation of state...
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:165
double ND(const double *x, size_t k, size_t j) const
number density
Definition: IonFlow.h:116
double E(const double *x, size_t j) const
electric field
Definition: IonFlow.h:107
std::vector< bool > m_do_electric_field
flag for solving electric field or not
Definition: IonFlow.h:79
std::vector< int > vector_int
Vector of ints.
Definition: ct_defs.h:159
double rho_e(double *x, size_t j) const
total charge density
Definition: IonFlow.h:121
std::vector< size_t > m_kNeutral
index of neutral species
Definition: IonFlow.h:91
virtual void evalResidual(double *x, double *rsd, int *diag, double rdt, size_t jmin, size_t jmax)
Definition: IonFlow.cpp:170
vector_int m_speciesCharge
electrical properties
Definition: IonFlow.h:85
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:272
virtual void updateDiffFluxes(const double *x, size_t j0, size_t j1)
Update the diffusive mass fluxes.
Definition: IonFlow.cpp:81
virtual void setSolvingStage(const size_t phase)
set the solving stage
Definition: IonFlow.cpp:158
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:118
int m_stage
solving stage
Definition: IonFlow.h:101
const doublereal Avogadro
Avogadro&#39;s Number [number/kmol].
Definition: ct_defs.h:61
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:157
This class models the ion transportation in a flame.
Definition: IonFlow.h:31
std::vector< size_t > m_kCharge
index of species with charges
Definition: IonFlow.h:88
void fixElectricField(size_t j=npos)
set to fix voltage on a point
Definition: IonFlow.cpp:230
vector_fp m_mobi_e_fix
coefficients of polynomial fitting of fixed electron transport profile
Definition: IonFlow.h:94
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:8
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:255
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:91