-
-
Notifications
You must be signed in to change notification settings - Fork 572
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2268 from pybamm-team/develop
Make release v22.8
- Loading branch information
Showing
192 changed files
with
7,943 additions
and
4,737 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}") |
Oops, something went wrong.