Debian Codegraph @

src/num/aslFDElChemKinetics.h

raw
1 /*
2 * Advanced Simulation Library <http://asl.org.il>
3 *
4 * Copyright 2015 Avtech Scientific <http://avtechscientific.com>
5 *
6 *
7 * This file is part of Advanced Simulation Library (ASL).
8 *
9 * ASL is free software: you can redistribute it and/or modify it
10 * under the terms of the GNU Affero General Public License as
11 * published by the Free Software Foundation, version 3 of the License.
12 *
13 * ASL is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with ASL. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23
24 #ifndef ASLFDELCHEMKINETICS_H
25 #define ASLFDELCHEMKINETICS_H
26
27 #include "aslSingleKernelNM.h"
28 #include "acl/aclMath/aclVectorOfElementsDef.h"
29
30
31 namespace acl
32 {
33 class VectorOfElementsData;
34 class VectorOfElements;
35 }
36
37 namespace asl
38 {
39 class VectorTemplate;
40 template <typename V> class DataWithGhostNodes;
41 typedef DataWithGhostNodes<acl::VectorOfElementsData> DataWithGhostNodesACLData;
42 typedef std::shared_ptr<DataWithGhostNodesACLData> SPDataWithGhostNodesACLData;
43
44 /// Numerical method which computes electrode reactions
45 /**
46 !!!!!!!!!!!!need corrections
47
48
49 \ingroup ChemicalReactions
50 \ingroup NumMethods
51
52 Description of an electrochemical kinetic reaction on an electrode:
53 \f[ \ce{A <-> A^{n+} + n e-} \f]
54 The reaction kinetics is described by the Butler-Volmer equation:
55 \f[ j = j_0 c_A \cdot \left( e^{\frac { \alpha_a nF \eta} {RT}} - e^{ - { \frac { \alpha_c nF \eta} {RT}} } \right), \f]
56 where
57
58 - \f$ j_0 \f$ is an exchange current density, \f$ A/m^2 \f$, note the algorithm assumes \f$ mol/m^2/s \f$
59 - \f$ T \f$ is absolute temperature, \f$K\f$
60 - \f$ n \f$ is number of electrons involved in the electrode reaction
61 - \f$ F \f$ is the Faraday constant, \f$ 9.64853399 \cdot 10^4 C mol^{-1} \f$
62 - \f$ R \f$ is universal gas constant, \f$ 8.3144621 J K^{-1} mol^{-1} \f$
63 - \f$\alpha_c\f$ is so-called cathodic charge transfer coefficient
64 - \f$\alpha_a\f$ is so-called anodic charge transfer coefficient, dimensionless
65 - \f$\eta\f$ is activation overpotential defined as: \f$\eta = \phi - \phi_{eq}\f$
66 - \f$E\f$ is electrode potential, \f$ V \f$
67 - \f$E_{eq}\f$ equilibrium potential, \f$ V \f$
68 - \f$c_A\f$ concentration of the component \f$\ce{A}\f$
69
70 The equation describes chemical reaction namely it can be used together
71 with an appropriate transport equations and equation for the elecrostatic potential:
72 \f[ c_A^R = c_A - j \f]
73 \f[ c_{A^{n+}}^R = c_{A^{n+}} + j \f]
74 \f[ \vec\nabla \kappa \vec\nabla\phi + S_\phi = 0 \f]
75
76 class parameters are related to the quation ones as follows
77 \param a0 molar concentration of the component before reaction
78 \param aI molar concentration of the ionized component
79 \param efSPhi source term in the equation for electrostatic potential
80 \param phi electrostatic potential, \f$ \phi \f$
81 \param j0 corresponds to \f$ j_0 \f$, note it should have the same units as concentrations
82 \param phi0 corresponds to \f$ \phi_{eq} \f$
83 \param alphaA corresponds to \f$ \frac { \alpha_a F} {RT} \f$
84 \param alphaC corresponds to \f$ \frac { \alpha_c F} {RT} \f$
85 \param n corresponds to \f$ n \f$
86
87 */
88 class FDBVKinetics: public SingleKernelMapNM
89 {
90 public:
91 typedef SPDataWithGhostNodesACLData Data;
92 typedef SPAbstractDataWithGhostNodes Field;
93 typedef acl::VectorOfElements Param;
94
95 private:
96 acl::SPKernel kernelJ;
97 std::vector<Data> aI;
98 Data efSPhi;
99 Field phi;
100
101 vector<double> nI;
102 Param j0;
103 Param beta;
104 double n;
105
106 virtual void init0();
107 public:
108 FDBVKinetics(Data a0,
109 double n0,
110 Data aI,
111 double nI,
112 Data phiS,
113 Field phi,
114 const Param & j0,
115 const Param & beta,
116 double n);
117 void setElectricFieldSource(Field phi);
118 Field getElectricFieldSource() const;
119 inline Data & getAI(unsigned int i=0);
120 void addAI(Data ai, double ni);
121 void executeJ();
122 };
123
124 typedef std::shared_ptr<FDBVKinetics> SPFDBVKinetics;
125
126
127 SPFDBVKinetics generateFDBVKinetics(SPDataWithGhostNodesACLData a0,
128 double n0,
129 SPDataWithGhostNodesACLData aI,
130 double nI,
131 SPDataWithGhostNodesACLData phiS,
132 SPAbstractDataWithGhostNodes phi,
133 double j0,
134 double beta,
135 double n);
136
137
138
139 // ------------------------- Implementation ------------------------
140
141 inline FDBVKinetics::Data & FDBVKinetics::getAI(unsigned int i)
142 {
143 return aI[i];
144 }
145
146 } // asl
147 #endif // ASLFDADVECTIONDIFFUSION_H