Skip to content

Commit 9cb7cf0

Browse files
#1456 fix example
1 parent 078e445 commit 9cb7cf0

File tree

4 files changed

+43
-13
lines changed

4 files changed

+43
-13
lines changed

examples/notebooks/initialize-model-with-solution.ipynb

+14-5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
"name": "stdout",
2424
"output_type": "stream",
2525
"text": [
26+
"\u001b[33mWARNING: You are using pip version 21.0.1; however, version 21.1 is available.\n",
27+
"You should consider upgrading via the '/Users/vsulzer/Documents/Energy_storage/PyBaMM/.tox/dev/bin/python -m pip install --upgrade pip' command.\u001b[0m\n",
2628
"Note: you may need to restart the kernel to use updated packages.\n"
2729
]
2830
}
@@ -159,7 +161,7 @@
159161
{
160162
"data": {
161163
"application/vnd.jupyter.widget-view+json": {
162-
"model_id": "0b5f9d809e244114b29f527062decbe9",
164+
"model_id": "7ad44c260ec446e0bd04a2f7dfbf8c65",
163165
"version_major": 2,
164166
"version_minor": 0
165167
},
@@ -173,7 +175,7 @@
173175
{
174176
"data": {
175177
"text/plain": [
176-
"<pybamm.plotting.quick_plot.QuickPlot at 0x7f3292dc9710>"
178+
"<pybamm.plotting.quick_plot.QuickPlot at 0x1447078e0>"
177179
]
178180
},
179181
"execution_count": 6,
@@ -240,7 +242,7 @@
240242
{
241243
"data": {
242244
"application/vnd.jupyter.widget-view+json": {
243-
"model_id": "d1e3967157584ff3802279544b0cc442",
245+
"model_id": "aaf63750ed354d1987703fd2fdde83af",
244246
"version_major": 2,
245247
"version_minor": 0
246248
},
@@ -254,7 +256,7 @@
254256
{
255257
"data": {
256258
"text/plain": [
257-
"<pybamm.plotting.quick_plot.QuickPlot at 0x7f32818d1990>"
259+
"<pybamm.plotting.quick_plot.QuickPlot at 0x10437c370>"
258260
]
259261
},
260262
"execution_count": 8,
@@ -299,6 +301,13 @@
299301
"source": [
300302
"pybamm.print_citations()"
301303
]
304+
},
305+
{
306+
"cell_type": "code",
307+
"execution_count": null,
308+
"metadata": {},
309+
"outputs": [],
310+
"source": []
302311
}
303312
],
304313
"metadata": {
@@ -317,7 +326,7 @@
317326
"name": "python",
318327
"nbconvert_exporter": "python",
319328
"pygments_lexer": "ipython3",
320-
"version": "3.7.4"
329+
"version": "3.8.8"
321330
},
322331
"toc": {
323332
"base_numbering": 1,

pybamm/models/submodels/electrolyte_diffusion/base_electrolyte_diffusion.py

+13
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,19 @@ def _get_standard_concentration_variables(self, c_e_n, c_e_s, c_e_p):
7878

7979
return variables
8080

81+
def _get_standard_porosity_times_concentration_variables(
82+
self, eps_c_e_n, eps_c_e_s, eps_c_e_p
83+
):
84+
eps_c_e = pybamm.concatenation(eps_c_e_n, eps_c_e_s, eps_c_e_p)
85+
86+
variables = {
87+
"Porosity times concentration": eps_c_e,
88+
"Negative electrode porosity times concentration": eps_c_e_n,
89+
"Separator porosity times concentration": eps_c_e_s,
90+
"Positive electrode porosity times concentration": eps_c_e_p,
91+
}
92+
return variables
93+
8194
def _get_standard_flux_variables(self, N_e):
8295
"""
8396
A private function to obtain the standard variables which

pybamm/models/submodels/electrolyte_diffusion/constant_concentration.py

+13
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,19 @@ def get_fundamental_variables(self):
3939
return variables
4040

4141
def get_coupled_variables(self, variables):
42+
eps_n = variables["Negative electrode porosity"]
43+
eps_s = variables["Separator porosity"]
44+
eps_p = variables["Positive electrode porosity"]
45+
c_e_n = variables["Negative electrolyte concentration"]
46+
c_e_s = variables["Separator electrolyte concentration"]
47+
c_e_p = variables["Positive electrolyte concentration"]
48+
49+
variables.update(
50+
self._get_standard_porosity_times_concentration_variables(
51+
eps_n * c_e_n, eps_s * c_e_s, eps_p * c_e_p
52+
)
53+
)
54+
4255
c_e = variables["Electrolyte concentration"]
4356
eps = variables["Porosity"]
4457

pybamm/models/submodels/electrolyte_diffusion/full_diffusion.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,9 @@ def get_fundamental_variables(self):
2929
eps_c_e_s = pybamm.standard_variables.eps_c_e_s
3030
eps_c_e_p = pybamm.standard_variables.eps_c_e_p
3131

32-
eps_c_e = pybamm.concatenation(eps_c_e_n, eps_c_e_s, eps_c_e_p)
33-
34-
variables = {
35-
"Porosity times concentration": eps_c_e,
36-
"Negative electrode porosity times concentration": eps_c_e_n,
37-
"Separator porosity times concentration": eps_c_e_s,
38-
"Positive electrode porosity times concentration": eps_c_e_p,
39-
}
32+
variables = self._get_standard_porosity_times_concentration_variables(
33+
eps_c_e_n, eps_c_e_s, eps_c_e_p
34+
)
4035

4136
return variables
4237

0 commit comments

Comments
 (0)