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
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 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 */
61 void setElectronTransport(vector_fp& tfix,
62 vector_fp& diff_e,
63 vector_fp& mobi_e);
64
65 protected:
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
83 bool m_import_electron_transport;
84
85 //! electrical properties
86 vector_fp m_speciesCharge;
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
95 vector_fp m_mobi_e_fix;
96 vector_fp m_diff_e_fix;
97
98 //! mobility
99 vector_fp m_mobility;
100
101 //! solving stage
102 size_t m_stage;
103
104 //! index of electron
105 size_t m_kElectron;
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
StFlow.h
Cantera::IdealGasPhase
Class IdealGasPhase represents low-density gases that obey the ideal gas equation of state.
Definition: IdealGasPhase.h:270
Cantera::IonFlow
This class models the ion transportation in a flame.
Definition: IonFlow.h:32
Cantera::IonFlow::evalResidual
virtual void evalResidual(double *x, double *rsd, int *diag, double rdt, size_t jmin, size_t jmax)
Definition: IonFlow.cpp:181
Cantera::IonFlow::electricFieldMethod
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
Cantera::IonFlow::E
double E(const double *x, size_t j) const
electric field
Definition: IonFlow.h:108
Cantera::IonFlow::m_mobi_e_fix
vector_fp m_mobi_e_fix
coefficients of polynomial fitting of fixed electron transport profile
Definition: IonFlow.h:95
Cantera::IonFlow::m_speciesCharge
vector_fp m_speciesCharge
electrical properties
Definition: IonFlow.h:86
Cantera::IonFlow::setSolvingStage
virtual void setSolvingStage(const size_t phase)
set the solving stage
Definition: IonFlow.cpp:169
Cantera::IonFlow::m_kElectron
size_t m_kElectron
index of electron
Definition: IonFlow.h:105
Cantera::IonFlow::frozenIonMethod
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
Cantera::IonFlow::_finalize
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
Cantera::IonFlow::rho_e
double rho_e(double *x, size_t j) const
total charge density
Definition: IonFlow.h:122
Cantera::IonFlow::ND
double ND(const double *x, size_t k, size_t j) const
number density
Definition: IonFlow.h:117
Cantera::IonFlow::componentActive
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
Cantera::IonFlow::resize
virtual void resize(size_t components, size_t points)
Change the grid size. Called after grid refinement.
Definition: IonFlow.cpp:61
Cantera::IonFlow::m_stage
size_t m_stage
solving stage
Definition: IonFlow.h:102
Cantera::IonFlow::m_mobility
vector_fp m_mobility
mobility
Definition: IonFlow.h:99
Cantera::IonFlow::m_kCharge
std::vector< size_t > m_kCharge
index of species with charges
Definition: IonFlow.h:89
Cantera::IonFlow::m_kNeutral
std::vector< size_t > m_kNeutral
index of neutral species
Definition: IonFlow.h:92
Cantera::IonFlow::updateDiffFluxes
virtual void updateDiffFluxes(const double *x, size_t j0, size_t j1)
Update the diffusive mass fluxes.
Definition: IonFlow.cpp:92
Cantera::IonFlow::m_import_electron_transport
bool m_import_electron_transport
flag for importing transport of electron
Definition: IonFlow.h:83
Cantera::IonFlow::fixElectricField
void fixElectricField(size_t j=npos)
set to fix voltage on a point
Definition: IonFlow.cpp:241
Cantera::IonFlow::updateTransport
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
Cantera::IonFlow::solveElectricField
void solveElectricField(size_t j=npos)
set to solve electric field on a point
Definition: IonFlow.cpp:216
Cantera::IonFlow::m_do_electric_field
std::vector< bool > m_do_electric_field
flag for solving electric field or not
Definition: IonFlow.h:80
Cantera::IonFlow::setElectronTransport
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
Cantera::StFlow
This class represents 1D flow domains that satisfy the one-dimensional similarity solution for chemic...
Definition: StFlow.h:37
Cantera
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:557
Cantera::npos
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:192
Cantera::Avogadro
const double Avogadro
Avogadro's Number [number/kmol].
Definition: ct_defs.h:66
Cantera::vector_fp
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
Cantera::ElectronCharge
const double ElectronCharge
Elementary charge [C].
Definition: ct_defs.h:75