Skip to content

Commit cc041dd

Browse files
#836 fix example
1 parent 64520df commit cc041dd

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed
+15-16
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
import pybamm as pb
2-
options = {"sei": "ec reaction limited",
3-
"porosity": "variable porosity"}
2+
3+
pb.set_logging_level("INFO")
4+
options = {"sei": "ec reaction limited", "sei porosity change": True}
45
param = pb.ParameterValues(chemistry=pb.parameter_sets.Ramadass2004)
56
model = pb.lithium_ion.DFN(options)
6-
experiment = pb.Experiment((
7+
experiment = pb.Experiment(
78
[
89
"Charge at 1 C until 4.2 V",
910
"Hold at 4.2 V until C/10",
1011
"Rest for 5 minutes",
11-
"Discharge at 2 C until 2.8 V (1 seconds period)",
12+
"Discharge at 2 C until 2.8 V",
1213
"Rest for 5 minutes",
1314
]
14-
* 5 +
15-
[
15+
* 2
16+
+ [
1617
"Charge at 1 C until 4.2 V",
1718
"Hold at 4.2 V until C/20",
1819
"Rest for 30 minutes",
19-
"Discharge at C/3 until 2.8 V(1 seconds period)",
20+
"Discharge at C/3 until 2.8 V",
2021
"Charge at 1 C until 4.2 V",
2122
"Hold at 4.2 V until C/20",
2223
"Rest for 30 minutes",
23-
"Discharge at 1 C until 2.8 V(1 seconds period)",
24+
"Discharge at 1 C until 2.8 V",
2425
"Charge at 1 C until 4.2 V",
2526
"Hold at 4.2 V until C/20",
2627
"Rest for 30 minutes",
27-
"Discharge at 2 C until 2.8 V(1 seconds period)",
28+
"Discharge at 2 C until 2.8 V",
2829
"Charge at 1 C until 4.2 V",
2930
"Hold at 4.2 V until C/20",
3031
"Rest for 30 minutes",
31-
"Discharge at 3 C until 2.8 V(1 seconds period)",
32-
]) * 2
32+
"Discharge at 3 C until 2.8 V",
33+
]
3334
)
34-
sim = pb.Simulation(model, experiment=experiment,
35-
parameter_values=param)
36-
sim.solve(solver=pb.CasadiSolver(mode="safe"))
35+
sim = pb.Simulation(model, experiment=experiment, parameter_values=param)
36+
sim.solve(solver=pb.CasadiSolver(mode="safe", dt_max=120))
3737
sim.plot(
3838
[
3939
"Current [A]",
40-
'Total current density [A.m-2]',
40+
"Total current density [A.m-2]",
4141
"Terminal voltage [V]",
4242
"Discharge capacity [A.h]",
4343
"Electrolyte potential [V]",
@@ -48,4 +48,3 @@
4848
"X-averaged total negative electrode sei thickness [m]",
4949
]
5050
)
51-

pybamm/models/full_battery_models/base_battery_model.py

+6
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,12 @@ def options(self, extra_options):
314314
options["sei film resistance"]
315315
)
316316
)
317+
if options["sei porosity change"] not in [True, False]:
318+
raise pybamm.OptionError(
319+
"Unknown sei porosity change '{}'".format(
320+
options["sei porosity change"]
321+
)
322+
)
317323

318324
if options["dimensionality"] == 0:
319325
if options["current collector"] not in ["uniform"]:

tests/unit/test_models/test_full_battery_models/test_base_battery_model.py

+2
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ def test_options(self):
127127
pybamm.BaseBatteryModel({"sei": "bad sei"})
128128
with self.assertRaisesRegex(pybamm.OptionError, "sei film resistance"):
129129
pybamm.BaseBatteryModel({"sei film resistance": "bad sei film resistance"})
130+
with self.assertRaisesRegex(pybamm.OptionError, "sei porosity change"):
131+
pybamm.BaseBatteryModel({"sei porosity change": "bad sei porosity change"})
130132
# variable defaults
131133
model = pybamm.BaseBatteryModel()
132134
self.assertEqual(model.options["sei film resistance"], None)

0 commit comments

Comments
 (0)