Skip to content

Commit

Permalink
Merge branch 'develop' into 441-functional-parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolaCourtier authored Aug 19, 2024
2 parents 0e29fbe + a5ce284 commit 0e9b2bb
Show file tree
Hide file tree
Showing 34 changed files with 1,131 additions and 272 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,37 @@ jobs:
run: |
nox -s examples
# Quick benchmarks on macos-14
benchmarks:
needs: style
runs-on: macos-14
strategy:
fail-fast: false
name: Benchmarks

steps:
- name: Check out PyBOP repository
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Set up Python 3.12
id: setup-python
uses: actions/setup-python@v4
with:
python-version: 3.12

- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip asv[virtualenv]
- name: Run quick benchmarks
shell: bash
run: |
asv machine --machine "GitHubRunner"
asv run --machine "GitHubRunner" --quick --show-stderr
# Runs only on macos-14 with Python 3.12
check_coverage:
needs: style
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ci:

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.5.6"
rev: "v0.5.7"
hooks:
- id: ruff
args: [--fix, --show-fixes]
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
## Features

- [#441](https://github.com/pybop-team/PyBOP/issues/441) - Adds an example for estimating constants within a `pybamm.FunctionalParameter`.
- [#460](https://github.com/pybop-team/PyBOP/pull/460) - Notebook example files added for ECM and folder structure updated.
- [#450](https://github.com/pybop-team/PyBOP/pull/450) - Adds support for IDAKLU with output variables, and corresponding examples, tests.
- [#364](https://github.com/pybop-team/PyBOP/pull/364) - Adds the MultiFittingProblem class and the multi_fitting example script.
- [#444](https://github.com/pybop-team/PyBOP/issues/444) - Merge `BaseModel` `build()` and `rebuild()` functionality.
- [#435](https://github.com/pybop-team/PyBOP/pull/435) - Adds SLF001 linting for private members.
- [#418](https://github.com/pybop-team/PyBOP/issues/418) - Wraps the `get_parameter_info` method from PyBaMM to get a dictionary of parameter names and types.
- [#413](https://github.com/pybop-team/PyBOP/pull/413) - Adds `DesignCost` functionality to `WeightedCost` class with additional tests.
Expand All @@ -14,6 +18,7 @@

## Bug Fixes

- [#454](https://github.com/pybop-team/PyBOP/issue/454) - Fixes benchmarking suite.
- [#421](https://github.com/pybop-team/PyBOP/issues/421) - Adds a default value for the initial SOC for design problems.

## Breaking Changes
Expand All @@ -28,6 +33,7 @@

## Bug Fixes


## Breaking Changes

# [v24.6](https://github.com/pybop-team/PyBOP/tree/v24.6) - 2024-07-08
Expand Down
2 changes: 1 addition & 1 deletion asv.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"python -m build --wheel -o {build_cache_dir} {build_dir}"
],
"default_benchmark_timeout": 180,
"branches": ["develop"],
"branches": ["HEAD"],
"environment_type": "virtualenv",
"matrix": {
"req":{
Expand Down
13 changes: 8 additions & 5 deletions benchmarks/benchmark_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,20 @@ def setup(self, model, parameter_set):
self.model = model(parameter_set=pybop.ParameterSet.pybamm(parameter_set))

# Define fitting parameters
parameters = [
parameters = pybop.Parameters(
pybop.Parameter(
"Current function [A]",
prior=pybop.Gaussian(0.4, 0.02),
bounds=[0.2, 0.7],
initial_value=0.4,
)
]
)

# Generate synthetic data
sigma = 0.001
self.t_eval = np.arange(0, 900, 2)
values = self.model.predict(t_eval=self.t_eval)
self.init_state = {"Initial SoC": 0.5}
values = self.model.predict(t_eval=self.t_eval, initial_state=self.init_state)
corrupt_values = values["Voltage [V]"].data + np.random.normal(
0, sigma, len(self.t_eval)
)
Expand All @@ -58,7 +59,7 @@ def setup(self, model, parameter_set):

# Create fitting problem
self.problem = pybop.FittingProblem(
model=self.model, dataset=dataset, parameters=parameters, init_soc=0.5
model=self.model, dataset=dataset, parameters=parameters
)

def time_model_predict(self, model, parameter_set):
Expand All @@ -69,7 +70,9 @@ def time_model_predict(self, model, parameter_set):
model (pybop.Model): The model class being benchmarked.
parameter_set (str): The name of the parameter set being used.
"""
self.model.predict(inputs=self.inputs, t_eval=self.t_eval)
self.model.predict(
inputs=self.inputs, t_eval=self.t_eval, initial_state=self.init_state
)

def time_model_simulate(self, model, parameter_set):
"""
Expand Down
8 changes: 4 additions & 4 deletions benchmarks/benchmark_optim_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def setup(self, model, parameter_set, optimiser):
model_instance = model(parameter_set=pybop.ParameterSet.pybamm(parameter_set))

# Define fitting parameters
parameters = [
parameters = pybop.Parameters(
pybop.Parameter(
"Negative electrode active material volume fraction",
prior=pybop.Gaussian(0.6, 0.02),
Expand All @@ -41,7 +41,7 @@ def setup(self, model, parameter_set, optimiser):
bounds=[0.375, 0.625],
initial_value=0.51,
),
]
)

# Generate synthetic data
sigma = 0.001
Expand Down Expand Up @@ -75,7 +75,7 @@ def time_optimisation_construction(self, model, parameter_set, optimiser):
Args:
model (pybop.Model): The model class being benchmarked.
parameter_set (str): The name of the parameter set being used.
optimiser (pybop.Optimiser): The optimizer class being used.
optimiser (pybop.Optimiser): The optimiser class being used.
"""
self.optim = pybop.Optimisation(self.cost, optimiser=optimiser)

Expand All @@ -86,6 +86,6 @@ def time_cost_evaluate(self, model, parameter_set, optimiser):
Args:
model (pybop.Model): The model class being benchmarked.
parameter_set (str): The name of the parameter set being used.
optimiser (pybop.Optimiser): The optimizer class being used.
optimiser (pybop.Optimiser): The optimiser class being used.
"""
self.cost([0.63, 0.51])
8 changes: 4 additions & 4 deletions benchmarks/benchmark_parameterisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def setup(self, model, parameter_set, optimiser):
Args:
model (pybop.Model): The model class to be benchmarked.
parameter_set (str): The name of the parameter set to be used.
optimiser (pybop.Optimiser): The optimizer class to be used.
optimiser (pybop.Optimiser): The optimiser class to be used.
"""
# Set random seed
set_random_seed()
Expand All @@ -45,7 +45,7 @@ def setup(self, model, parameter_set, optimiser):
model_instance = model(parameter_set=params)

# Define fitting parameters
parameters = [
parameters = pybop.Parameters(
pybop.Parameter(
"Negative electrode active material volume fraction",
prior=pybop.Gaussian(0.55, 0.03),
Expand All @@ -56,7 +56,7 @@ def setup(self, model, parameter_set, optimiser):
prior=pybop.Gaussian(0.55, 0.03),
bounds=[0.375, 0.7],
),
]
)

# Generate synthetic data
sigma = 0.003
Expand Down Expand Up @@ -110,7 +110,7 @@ def time_parameterisation(self, model, parameter_set, optimiser):
Args:
model (pybop.Model): The model class being benchmarked (unused).
parameter_set (str): The name of the parameter set being used (unused).
optimiser (pybop.Optimiser): The optimizer class being used (unused).
optimiser (pybop.Optimiser): The optimiser class being used (unused).
"""
self.optim.run()

Expand Down
4 changes: 2 additions & 2 deletions benchmarks/benchmark_track_parameterisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def setup(self, model, parameter_set, optimiser):
model_instance = model(parameter_set=params)

# Define fitting parameters
parameters = [
parameters = pybop.Parameters(
pybop.Parameter(
"Negative electrode active material volume fraction",
prior=pybop.Gaussian(0.55, 0.03),
Expand All @@ -56,7 +56,7 @@ def setup(self, model, parameter_set, optimiser):
prior=pybop.Gaussian(0.55, 0.03),
bounds=[0.375, 0.7],
),
]
)

# Generate synthetic data
sigma = 0.003
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1639,8 +1639,7 @@
"outputs": [],
"source": [
"problem.set_target(dataset_two_pulse)\n",
"model.parameter_set[\"Initial SoC\"] = 0.8 - 0.0075\n",
"model.rebuild(dataset_two_pulse)"
"model.build(dataset=dataset_two_pulse, initial_state={\"Initial SoC\": 0.8 - 0.0075})"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion examples/notebooks/equivalent_circuit_identification.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"\n",
"### Setting up the Environment\n",
"\n",
"Before we begin, we need to ensure that we have all the necessary tools. We will install PyBOP from its development branch and upgrade some dependencies:"
"Before we begin, we need to ensure that we have all the necessary tools. We will install PyBOP and upgrade dependencies:"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions examples/notebooks/multi_model_identification.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"\n",
"### Setting up the Environment\n",
"\n",
"Before we begin, we need to ensure that we have all the necessary tools. We will install PyBOP from its development branch and upgrade some dependencies:"
"Before we begin, we need to ensure that we have all the necessary tools. We will install PyBOP and upgrade dependencies:"
]
},
{
Expand Down Expand Up @@ -147,7 +147,7 @@
"metadata": {},
"outputs": [],
"source": [
"synth_model.build(dataset, initial_state=initial_state)\n",
"synth_model.build(dataset=dataset, initial_state=initial_state)\n",
"synth_model.signal = [\"Voltage [V]\"]\n",
"values = synth_model.simulate(t_eval=t_eval, inputs={})"
]
Expand Down
2 changes: 1 addition & 1 deletion examples/notebooks/multi_optimiser_identification.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"\n",
"### Setting up the Environment\n",
"\n",
"Before we begin, we need to ensure that we have all the necessary tools. We will install PyBOP from its development branch and upgrade some dependencies:"
"Before we begin, we need to ensure that we have all the necessary tools. We will install PyBOP and upgrade dependencies:"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion examples/notebooks/optimiser_calibration.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"\n",
"### Setting up the Environment\n",
"\n",
"Before we begin, we need to ensure that we have all the necessary tools. We will install PyBOP from its development branch and upgrade some dependencies:"
"Before we begin, we need to ensure that we have all the necessary tools. We will install PyBOP and upgrade dependencies:"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion examples/notebooks/pouch_cell_identification.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"\n",
"### Setting up the Environment\n",
"\n",
"Before we begin, we need to ensure that we have all the necessary tools. We will install PyBOP from its development branch and upgrade some dependencies:"
"Before we begin, we need to ensure that we have all the necessary tools. We will install PyBOP and upgrade dependencies:"
]
},
{
Expand Down
Loading

0 comments on commit 0e9b2bb

Please sign in to comment.