-
-
Notifications
You must be signed in to change notification settings - Fork 606
/
Copy pathbase_electrolyte_diffusion.py
158 lines (130 loc) · 5.32 KB
/
base_electrolyte_diffusion.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#
# Base class for electrolyte diffusion
#
import pybamm
class BaseElectrolyteDiffusion(pybamm.BaseSubModel):
"""Base class for conservation of mass in the electrolyte.
Parameters
----------
param : parameter class
The parameters to use for this submodel
reactions : dict, optional
Dictionary of reaction terms
**Extends:** :class:`pybamm.BaseSubModel`
"""
def __init__(self, param):
super().__init__(param)
def _get_standard_concentration_variables(self, c_e_n, c_e_s, c_e_p):
"""
A private function to obtain the standard variables which
can be derived from the concentration in the electrolyte.
Parameters
----------
c_e_n : :class:`pybamm.Symbol`
The electrolyte concentration in the negative electrode.
c_e_s : :class:`pybamm.Symbol`
The electrolyte concentration in the separator.
c_e_p : :class:`pybamm.Symbol`
The electrolyte concentration in the positive electrode.
Returns
-------
variables : dict
The variables which can be derived from the concentration in the
electrolyte.
"""
c_e_typ = self.param.c_e_typ
c_e = pybamm.concatenation(c_e_n, c_e_s, c_e_p)
c_e_av = pybamm.x_average(c_e)
c_e_n_av = pybamm.x_average(c_e_n)
c_e_s_av = pybamm.x_average(c_e_s)
c_e_p_av = pybamm.x_average(c_e_p)
variables = {
"Electrolyte concentration": c_e,
"Electrolyte concentration [mol.m-3]": c_e_typ * c_e,
"Electrolyte concentration [Molar]": c_e_typ * c_e / 1000,
"X-averaged electrolyte concentration": c_e_av,
"X-averaged electrolyte concentration [mol.m-3]": c_e_typ * c_e_av,
"X-averaged electrolyte concentration [Molar]": c_e_typ * c_e_av / 1000,
"Negative electrolyte concentration": c_e_n,
"Negative electrolyte concentration [mol.m-3]": c_e_typ * c_e_n,
"Negative electrolyte concentration [Molar]": c_e_typ * c_e_n / 1000,
"Separator electrolyte concentration": c_e_s,
"Separator electrolyte concentration [mol.m-3]": c_e_typ * c_e_s,
"Separator electrolyte concentration [Molar]": c_e_typ * c_e_s / 1000,
"Positive electrolyte concentration": c_e_p,
"Positive electrolyte concentration [mol.m-3]": c_e_typ * c_e_p,
"Positive electrolyte concentration [Molar]": c_e_typ * c_e_p / 1000,
"X-averaged negative electrolyte concentration": c_e_n_av,
"X-averaged negative electrolyte concentration [mol.m-3]": c_e_typ
* c_e_n_av,
"X-averaged separator electrolyte concentration": c_e_s_av,
"X-averaged separator electrolyte concentration [mol.m-3]": c_e_typ
* c_e_s_av,
"X-averaged positive electrolyte concentration": c_e_p_av,
"X-averaged positive electrolyte concentration [mol.m-3]": c_e_typ
* c_e_p_av,
}
return variables
def _get_standard_porosity_times_concentration_variables(
self, eps_c_e_n, eps_c_e_s, eps_c_e_p
):
eps_c_e = pybamm.concatenation(eps_c_e_n, eps_c_e_s, eps_c_e_p)
variables = {
"Porosity times concentration": eps_c_e,
"Negative electrode porosity times concentration": eps_c_e_n,
"Separator porosity times concentration": eps_c_e_s,
"Positive electrode porosity times concentration": eps_c_e_p,
}
return variables
def _get_standard_flux_variables(self, N_e):
"""
A private function to obtain the standard variables which
can be derived from the mass flux in the electrolyte.
Parameters
----------
N_e : :class:`pybamm.Symbol`
The flux in the electrolyte.
Returns
-------
variables : dict
The variables which can be derived from the flux in the
electrolyte.
"""
param = self.param
flux_scale = param.D_e_typ * param.c_e_typ / param.L_x
variables = {
"Electrolyte flux": N_e,
"Electrolyte flux [mol.m-2.s-1]": N_e * flux_scale,
}
return variables
def _get_total_concentration_electrolyte(self, c_e, epsilon):
"""
A private function to obtain the total ion concentration in the electrolyte.
Parameters
----------
c_e : :class:`pybamm.Symbol`
The electrolyte concentration
epsilon : :class:`pybamm.Symbol`
The porosity
Returns
-------
variables : dict
The "Total concentration in electrolyte [mol]" variable.
"""
c_e_typ = self.param.c_e_typ
L_x = self.param.L_x
A = self.param.A_cc
c_e_total = pybamm.x_average(epsilon * c_e)
variables = {
"Total concentration in electrolyte [mol]": c_e_typ * L_x * A * c_e_total
}
return variables
def set_events(self, variables):
c_e = variables["Electrolyte concentration"]
self.events.append(
pybamm.Event(
"Zero electrolyte concentration cut-off",
pybamm.min(c_e) - 0.002,
pybamm.EventType.TERMINATION,
)
)