Skip to content

Commit

Permalink
Merge pull request #2268 from pybamm-team/develop
Browse files Browse the repository at this point in the history
Make release v22.8
  • Loading branch information
brosaplanella authored Aug 30, 2022
2 parents 5f4913d + 1f01c1e commit d0f27d3
Show file tree
Hide file tree
Showing 192 changed files with 7,943 additions and 4,737 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/work_precision_sets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Generate work precision sets

on:
release:
types: [created]
workflow_dispatch:

jobs:

benchmarks_on_release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Get current date
run: echo "VERSION=$(date +'%y.%-m')" >> $GITHUB_ENV
- name: Install PyBaMM
run: python -m pip install pybamm==${{ env.VERSION }}
- name: Run time_vs_* benchmarks for PyBaMM v${{ env.VERSION }}
run: |
python benchmarks/work_precision_sets/time_vs_dt_max.py
python benchmarks/work_precision_sets/time_vs_mesh_size.py
python benchmarks/work_precision_sets/time_vs_no_of_states.py
python benchmarks/work_precision_sets/time_vs_reltols.py
python benchmarks/work_precision_sets/time_vs_abstols.py
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
delete-branch: true
branch-suffix: short-commit-hash
commit-message: Work precision sets for PyBaMM version ${{ env.VERSION }}
title: Work precision sets for PyBaMM version ${{ env.VERSION }}
body: |
Update work precision sets for PyBaMM version ${{ env.VERSION }} in `release_work_precision_sets.md`
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
!CMakeLists.txt
!pybamm/CITATIONS.txt
!pybamm/input/**/*.csv
!benchmarks/benchmark_images/*.png

# running files
*.pyc
Expand Down
31 changes: 29 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# [Unreleased](https://github.com/pybamm-team/PyBaMM/)

# [v22.8](https://github.com/pybamm-team/PyBaMM/tree/v22.8) - 2022-08-31

## Features

- Added `CurrentSigmoidOpenCircuitPotential` model to model voltage hysteresis for charge/discharge ([#2256](https://github.com/pybamm-team/PyBaMM/pull/2256))
- Added "Chen2020_composite" parameter set for a composite graphite/silicon electrode. ([#2256](https://github.com/pybamm-team/PyBaMM/pull/2256))
- Added new cumulative variables `Throughput capacity [A.h]` and `Throughput energy [W.h]` to standard variables and summary variables, to assist with degradation studies. Throughput variables are only calculated if `calculate discharge energy` is set to `true`. `Time [s]` and `Time [h]` also added to summary variables. ([#2249](https://github.com/pybamm-team/PyBaMM/pull/2249))
- Added `lipf6_OKane2022` electrolyte to `OKane2022` parameter set ([#2249](https://github.com/pybamm-team/PyBaMM/pull/2249))
- Reformated submodel structure to allow composite electrodes. Composite positive electrode is now also possible. With current implementation, electrodes can have at most two phases. ([#2248](https://github.com/pybamm-team/PyBaMM/pull/2248))

## Bug fixes

- Added new parameter `Ratio of lithium moles to SEI moles` (short name z_sei) to fix a bug where this number was incorrectly hardcoded to 1. ([#2222](https://github.com/pybamm-team/PyBaMM/pull/2222))
- Changed short name of parameter `Inner SEI reaction proportion` from alpha_SEI to inner_sei_proportion, to avoid confusion with transfer coefficients. ([#2222](https://github.com/pybamm-team/PyBaMM/pull/2222))
- Deleted legacy parameters with short names beta_sei and beta_plating. ([#2222](https://github.com/pybamm-team/PyBaMM/pull/2222))
- Corrected initial SEI thickness for OKane2022 parameter set. ([#2218](https://github.com/pybamm-team/PyBaMM/pull/2218))

## Optimizations

- Simplified scaling for the exchange-current density. The dimensionless parameter `C_r` is kept, but no longer used anywhere ([#2238](https://github.com/pybamm-team/PyBaMM/pull/2238))
- Added limits for variables in some functions to avoid division by zero, sqrt(negative number), etc ([#2213](https://github.com/pybamm-team/PyBaMM/pull/2213))

## Breaking changes

- Parameters specific to a (primary/secondary) phase in a domain are doubly nested. e.g. `param.c_n_max` is now `param.n.prim.c_max` ([#2248](https://github.com/pybamm-team/PyBaMM/pull/2248))

# [v22.7](https://github.com/pybamm-team/PyBaMM/tree/v22.7) - 2022-07-31

## Features
Expand Down Expand Up @@ -34,7 +60,7 @@
## Breaking changes

- Exchange-current density functions (and some other functions) now take an additional argument, the maximum particle concentration for that phase ([#2134](https://github.com/pybamm-team/PyBaMM/pull/2134))
- Loss of lithium to SEI on cracks is now a degradation variable, so setting a particle mechanics submodel is now compulsory (NoMechanics will suffice)
- Loss of lithium to SEI on cracks is now a degradation variable, so setting a particle mechanics submodel is now compulsory (NoMechanics will suffice) ([#2104](https://github.com/pybamm-team/PyBaMM/pull/2104))

# [v22.6](https://github.com/pybamm-team/PyBaMM/tree/v22.6) - 2022-06-30

Expand All @@ -56,6 +82,7 @@

## Features

- Added a casadi version of the IDKLU solver, which is used for `model.convert_to_format = "casadi"` ([#2002](https://github.com/pybamm-team/PyBaMM/pull/2002))
- Added functionality to generate Julia expressions from a model. See [PyBaMM.jl](https://github.com/tinosulzer/PyBaMM.jl) for how to use these ([#1942](https://github.com/pybamm-team/PyBaMM/pull/1942)))
- Added basic callbacks to the Simulation class, and a LoggingCallback ([#1880](https://github.com/pybamm-team/PyBaMM/pull/1880)))

Expand All @@ -65,7 +92,7 @@

## Breaking changes

- Changed domain-specific parameter names to a nested attribute, e.g. `param.c_n_max` is now `param.n.c_max` ([#2063](https://github.com/pybamm-team/PyBaMM/pull/2063))
- Changed domain-specific parameter names to a nested attribute. `param.n.l_n` is now `param.n.l` ([#2063](https://github.com/pybamm-team/PyBaMM/pull/2063))

# [v22.4](https://github.com/pybamm-team/PyBaMM/tree/v22.4) - 2022-04-30

Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ keywords:
- "expression tree"
- "python"
- "symbolic differentiation"
version: "22.7"
version: "22.8"
repository-code: "https://github.com/pybamm-team/PyBaMM"
title: "Python Battery Mathematical Modelling (PyBaMM)"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions benchmarks/release-work-precision-sets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# PyBaMM 22.7
## Solve Time vs Abstols
<img src='./benchmark_images/time_vs_abstols_22.7.png'>

## Solve Time vs Reltols
<img src='./benchmark_images/time_vs_reltols_22.7.png'>

## Solve Time vs Mesh size
<img src='./benchmark_images/time_vs_mesh_size_22.7.png'>

## Solve Time vs dt_max
<img src='./benchmark_images/time_vs_dt_max_22.7.png'>

## Solve Time vs Number of states
<img src='./benchmark_images/time_vs_no_of_states_22.7.png'>
108 changes: 108 additions & 0 deletions benchmarks/work_precision_sets/time_vs_abstols.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import pybamm
import numpy as np
import matplotlib.pyplot as plt
import itertools


parameters = ["Marquis2019", "Ecker2015", "Ramadass2004", "Chen2020"]

models = {"SPM": pybamm.lithium_ion.SPM(), "DFN": pybamm.lithium_ion.DFN()}

abstols = [
0.0001,
1.0e-5,
1.0e-6,
1.0e-7,
1.0e-8,
1.0e-9,
1.0e-10,
1.0e-11,
1.0e-12,
1.0e-13,
]

solvers = {
"IDAKLUSolver": pybamm.IDAKLUSolver(),
"Casadi - safe": pybamm.CasadiSolver(),
"Casadi - fast": pybamm.CasadiSolver(mode="fast"),
}


fig, axs = plt.subplots(len(solvers), len(models), figsize=(8, 10))

for ax, i, j in zip(
axs.ravel(),
itertools.product(solvers.values(), models.values()),
itertools.product(solvers, models),
):

for params in parameters:

time_points = []
solver = i[0]

model = i[1].new_copy()
c_rate = 1
tmax = 3500 / c_rate
nb_points = 500
t_eval = np.linspace(0, tmax, nb_points)
geometry = model.default_geometry

# load parameter values and process model and geometry
param = pybamm.ParameterValues(params)
param.process_model(model)
param.process_geometry(geometry)

# set mesh
var_pts = {
"x_n": 20,
"x_s": 20,
"x_p": 20,
"r_n": 30,
"r_p": 30,
"y": 10,
"z": 10,
}
mesh = pybamm.Mesh(geometry, model.default_submesh_types, var_pts)

# discretise model
disc = pybamm.Discretisation(mesh, model.default_spatial_methods)
disc.process_model(model)

for tol in abstols:

solver.atol = tol
solver.solve(model, t_eval=t_eval)
time = 0
runs = 20
for k in range(0, runs):

solution = solver.solve(model, t_eval=t_eval)
time += solution.solve_time.value
time = time / runs

time_points.append(time)

ax.set_xscale("log")
ax.set_yscale("log")
ax.set_xlabel("abstols")
ax.set_ylabel("time(s)")
ax.set_title(f"{j[1]} with {j[0]}")
ax.plot(abstols, time_points)

plt.tight_layout()
plt.gca().legend(
parameters,
loc="lower right",
)


plt.savefig(f"benchmarks/benchmark_images/time_vs_abstols_{pybamm.__version__}.png")


content = f"# PyBaMM {pybamm.__version__}\n## Solve Time vs Abstols\n<img src='./benchmark_images/time_vs_abstols_{pybamm.__version__}.png'>\n" # noqa

with open("./benchmarks/release_work_precision_sets.md", "r") as original:
data = original.read()
with open("./benchmarks/release_work_precision_sets.md", "w") as modified:
modified.write(f"{content}\n{data}")
111 changes: 111 additions & 0 deletions benchmarks/work_precision_sets/time_vs_dt_max.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import pybamm
import numpy as np
import matplotlib.pyplot as plt


parameters = [
"Marquis2019",
"Prada2013",
"Ramadass2004",
"Chen2020",
]

models = {"SPM": pybamm.lithium_ion.SPM(), "DFN": pybamm.lithium_ion.DFN()}

dt_max = [
10,
20,
50,
80,
100,
150,
250,
400,
600,
900,
1200,
1600,
2100,
2600,
3000,
3600,
]


fig, axs = plt.subplots(1, len(models), figsize=(8, 3))

for ax, model_, model_name in zip(
axs.ravel(),
models.values(),
models,
):

for params in parameters:

time_points = []
# solver = pybamm.CasadiSolver()

model = model_.new_copy()
c_rate = 10
tmax = 3600 / c_rate
nb_points = 500
t_eval = np.linspace(0, tmax, nb_points)
geometry = model.default_geometry

# load parameter values and process model and geometry
param = pybamm.ParameterValues(params)
param.process_model(model)
param.process_geometry(geometry)

# set mesh
var_pts = {
"x_n": 20,
"x_s": 20,
"x_p": 20,
"r_n": 30,
"r_p": 30,
"y": 10,
"z": 10,
}
mesh = pybamm.Mesh(geometry, model.default_submesh_types, var_pts)

# discretise model
disc = pybamm.Discretisation(mesh, model.default_spatial_methods)
disc.process_model(model)

for t in dt_max:

solver = pybamm.CasadiSolver(dt_max=t)

solver.solve(model, t_eval=t_eval)
time = 0
runs = 20
for k in range(0, runs):

solution = solver.solve(model, t_eval=t_eval)
time += solution.solve_time.value
time = time / runs

time_points.append(time)

ax.set_xscale("log")
ax.set_yscale("log")
ax.set_xlabel("dt_max")
ax.set_ylabel("time(s)")
ax.set_title(f"{model_name}")
ax.plot(dt_max, time_points)

plt.tight_layout()
plt.gca().legend(
parameters,
loc="upper right",
)
plt.savefig(f"benchmarks/benchmark_images/time_vs_dt_max_{pybamm.__version__}.png")


content = f"## Solve Time vs dt_max\n<img src='./benchmark_images/time_vs_dt_max_{pybamm.__version__}.png'>\n" # noqa

with open("./benchmarks/release_work_precision_sets.md", "r") as original:
data = original.read()
with open("./benchmarks/release_work_precision_sets.md", "w") as modified:
modified.write(f"{content}\n{data}")
Loading

0 comments on commit d0f27d3

Please sign in to comment.