Skip to content

Commit 254dcde

Browse files
Merge branch 'develop' into issue-2670-interp2d
2 parents 4caac61 + 9b4490b commit 254dcde

File tree

10 files changed

+40
-5
lines changed

10 files changed

+40
-5
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repos:
99
- id: black
1010

1111
- repo: https://github.com/charliermarsh/ruff-pre-commit
12-
rev: "v0.0.261"
12+
rev: "v0.0.262"
1313
hooks:
1414
- id: ruff
1515
args: [--ignore=E741, --exclude=__init__.py]

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
## Bug fixes
1111

12+
- Parameter sets can now contain the key "chemistry", and will ignore its value (this previously would give errors in some cases) ([#2901](https://github.com/pybamm-team/PyBaMM/pull/2901))
1213
- Fixed a bug in the discretisation of initial conditions of a scaled variable ([#2856](https://github.com/pybamm-team/PyBaMM/pull/2856))
1314
- Fixed keyerror on "all" when getting sensitivities from IDAKLU solver([#2883](https://github.com/pybamm-team/PyBaMM/pull/2883))
1415

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
229229
<tr>
230230
<td align="center" valign="top" width="14.28%"><a href="https://github.com/chuckliu1979"><img src="https://avatars.githubusercontent.com/u/13491954?v=4?s=100" width="100px;" alt="Chuck Liu"/><br /><sub><b>Chuck Liu</b></sub></a><br /><a href="https://github.com/pybamm-team/PyBaMM/issues?q=author%3Achuckliu1979" title="Bug reports">🐛</a> <a href="https://github.com/pybamm-team/PyBaMM/commits?author=chuckliu1979" title="Code">💻</a></td>
231231
<td align="center" valign="top" width="14.28%"><a href="https://github.com/partben"><img src="https://avatars.githubusercontent.com/u/88316576?v=4?s=100" width="100px;" alt="partben"/><br /><sub><b>partben</b></sub></a><br /><a href="https://github.com/pybamm-team/PyBaMM/commits?author=partben" title="Documentation">📖</a></td>
232-
<td align="center" valign="top" width="14.28%"><a href="https://gavinw.me"><img src="https://avatars.githubusercontent.com/u/6828967?v=4?s=100" width="100px;" alt="Gavin Wiggins"/><br /><sub><b>Gavin Wiggins</b></sub></a><br /><a href="https://github.com/pybamm-team/PyBaMM/issues?q=author%3Awigging" title="Bug reports">🐛</a> <a href="https://github.com/pybamm-team/PyBaMM/commits?author=wigging" title="Code">💻</a></td>
232+
<td align="center" valign="top" width="14.28%"><a href="https://wigging.me"><img src="https://avatars.githubusercontent.com/u/6828967?v=4?s=100" width="100px;" alt="Gavin Wiggins"/><br /><sub><b>Gavin Wiggins</b></sub></a><br /><a href="https://github.com/pybamm-team/PyBaMM/issues?q=author%3Awigging" title="Bug reports">🐛</a> <a href="https://github.com/pybamm-team/PyBaMM/commits?author=wigging" title="Code">💻</a></td>
233233
<td align="center" valign="top" width="14.28%"><a href="https://github.com/dion-w"><img src="https://avatars.githubusercontent.com/u/91852142?v=4?s=100" width="100px;" alt="Dion Wilde"/><br /><sub><b>Dion Wilde</b></sub></a><br /><a href="https://github.com/pybamm-team/PyBaMM/issues?q=author%3Adion-w" title="Bug reports">🐛</a> <a href="https://github.com/pybamm-team/PyBaMM/commits?author=dion-w" title="Code">💻</a></td>
234234
<td align="center" valign="top" width="14.28%"><a href="https://www.ehtec.co"><img src="https://avatars.githubusercontent.com/u/48386220?v=4?s=100" width="100px;" alt="Elias Hohl"/><br /><sub><b>Elias Hohl</b></sub></a><br /><a href="https://github.com/pybamm-team/PyBaMM/commits?author=ehtec" title="Code">💻</a></td>
235235
<td align="center" valign="top" width="14.28%"><a href="https://github.com/KAschad"><img src="https://avatars.githubusercontent.com/u/93784399?v=4?s=100" width="100px;" alt="KAschad"/><br /><sub><b>KAschad</b></sub></a><br /><a href="https://github.com/pybamm-team/PyBaMM/issues?q=author%3AKAschad" title="Bug reports">🐛</a></td>

casadi-headers

Lines changed: 0 additions & 1 deletion
This file was deleted.

pybamm/parameters/parameter_values.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,14 @@ def __init__(self, values, chemistry=None):
7070
)
7171
self.update_from_chemistry(values)
7272
else:
73+
# Remove chemistry if present
74+
values.pop("chemistry", None)
7375
self.update(values, check_already_exists=False)
7476
else:
7577
# Check if values is a named parameter set
7678
if isinstance(values, str) and values in pybamm.parameter_sets:
7779
values = pybamm.parameter_sets[values]
78-
values.pop("chemistry")
80+
values.pop("chemistry", None)
7981
self.update(values, check_already_exists=False)
8082

8183
else:

pybamm/simulation.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import warnings
99
import sys
1010
from functools import lru_cache
11+
import tqdm
1112

1213

1314
def is_notebook():
@@ -510,6 +511,7 @@ def solve(
510511
starting_solution=None,
511512
initial_soc=None,
512513
callbacks=None,
514+
showprogress=False,
513515
**kwargs,
514516
):
515517
"""
@@ -557,6 +559,10 @@ def solve(
557559
callbacks : list of callbacks, optional
558560
A list of callbacks to be called at each time step. Each callback must
559561
implement all the methods defined in :class:`pybamm.callbacks.BaseCallback`.
562+
showprogress : bool, optional
563+
Whether to show a progress bar for cycling. If true, shows a progress bar
564+
for cycles. Has no effect when not used with an experiment.
565+
Default is False.
560566
**kwargs
561567
Additional key-word arguments passed to `solver.solve`.
562568
See :meth:`pybamm.BaseSolver.solve`.
@@ -698,7 +704,13 @@ def solve(
698704
num_cycles = len(self.experiment.cycle_lengths)
699705
feasible = True # simulation will stop if experiment is infeasible
700706
for cycle_num, cycle_length in enumerate(
701-
self.experiment.cycle_lengths, start=1
707+
# tqdm is the progress bar.
708+
tqdm.tqdm(
709+
self.experiment.cycle_lengths,
710+
disable=(not showprogress),
711+
desc="Cycling",
712+
),
713+
start=1,
702714
):
703715
logs["cycle number"] = (
704716
cycle_num + cycle_offset,

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pybtex>=0.24.0
1010
sympy >= 1.8
1111
xarray
1212
bpx
13+
tqdm
1314
# Note: Matplotlib is loaded for debug plots but to ensure pybamm runs
1415
# on systems without an attached display it should never be imported
1516
# outside of plot() methods.

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ def compile_KLU():
216216
"sympy>=1.8",
217217
"xarray",
218218
"bpx",
219+
"tqdm",
219220
# Note: Matplotlib is loaded for debug plots, but to ensure pybamm runs
220221
# on systems without an attached display, it should never be imported
221222
# outside of plot() methods.

tests/unit/test_experiments/test_simulation_with_experiment.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,21 @@ def test_run_experiment_termination_capacity(self):
342342
# all but the last value should be above the termination condition
343343
np.testing.assert_array_less(5.04, C[:-1])
344344

345+
def test_run_experiment_with_pbar(self):
346+
# The only thing to test here is for errors.
347+
experiment = pybamm.Experiment(
348+
[
349+
(
350+
"Discharge at 1C for 1 sec",
351+
"Charge at 1C for 1 sec",
352+
),
353+
]
354+
* 10,
355+
)
356+
model = pybamm.lithium_ion.SPM()
357+
sim = pybamm.Simulation(model, experiment=experiment)
358+
sim.solve(showprogress=True)
359+
345360
def test_run_experiment_termination_voltage(self):
346361
# with percent
347362
experiment = pybamm.Experiment(

tests/unit/test_parameters/test_parameter_values.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ def test_init(self):
5656
self.assertIn("a", param.keys())
5757
self.assertIn(1, param.values())
5858

59+
# from dict "chemistry" key gets removed
60+
param = pybamm.ParameterValues({"a": 1, "chemistry": "lithium-ion"})
61+
self.assertNotIn("chemistry", param.keys())
62+
5963
# from file
6064
param = pybamm.ParameterValues(
6165
"lithium_ion/testing_only/positive_electrodes/lico2_Ai2020/parameters.csv"

0 commit comments

Comments
 (0)