Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement GITT example #249

Merged
merged 36 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
c8069ba
#223 refactor problems into problem folder
brosaplanella Mar 17, 2024
f380ea4
add Weppner & Huggins model, with some hacks to make it work
brosaplanella Mar 20, 2024
e83d6b3
add GITT FittingProblem
brosaplanella Mar 20, 2024
575c27e
add GITT example
brosaplanella Mar 20, 2024
ab34b4d
Merge branch 'develop' into issue-223-GITT
brosaplanella Mar 20, 2024
7b53b75
style: pre-commit fixes
pre-commit-ci[bot] Mar 20, 2024
659c98e
#223 fix typo
brosaplanella Mar 25, 2024
d98349a
#223 rename example
brosaplanella Mar 25, 2024
4cbac89
#223 add unit test GITT
brosaplanella Mar 25, 2024
feae75b
Merge remote-tracking branch 'upstream/develop' into issue-223-GITT
brosaplanella Mar 25, 2024
b586aac
style: pre-commit fixes
pre-commit-ci[bot] Mar 25, 2024
d583f1d
#223 import pybop
brosaplanella Mar 25, 2024
cef8cc2
style: pre-commit fixes
pre-commit-ci[bot] Mar 25, 2024
6ab1378
#223 comment out failing test to check coverage
brosaplanella Mar 25, 2024
d17b1f7
Merge branch 'issue-223-GITT' of github.com:brosaplanella/PyBOP into …
brosaplanella Mar 25, 2024
b85dbcb
#223 fix ruff
brosaplanella Mar 25, 2024
d447d66
#223 fix failing example
brosaplanella Mar 30, 2024
da4ff8b
Apply suggestions from code review
brosaplanella Apr 8, 2024
d4bf431
#223 fix typo
brosaplanella Apr 8, 2024
edb5e18
remove duplicated parameters
brosaplanella Apr 8, 2024
c4e88d4
#223 add citation
brosaplanella Apr 8, 2024
1e49571
Merge remote-tracking branch 'upstream/develop' into issue-223-GITT
brosaplanella Apr 8, 2024
8ae2f19
style: pre-commit fixes
pre-commit-ci[bot] Apr 8, 2024
74972bc
ruff
brosaplanella Apr 8, 2024
a9d57c5
#223 fix failing tests
brosaplanella Apr 8, 2024
2f6a0e7
style: pre-commit fixes
pre-commit-ci[bot] Apr 8, 2024
c505c41
Merge branch 'develop' into issue-223-GITT
brosaplanella Apr 14, 2024
c126ee2
Merge remote-tracking branch 'upstream/develop' into issue-223-GITT
brosaplanella May 15, 2024
3e1b601
#223 get surface area to volume ratio from PyBaMM
brosaplanella May 15, 2024
6a5ee3d
#223 reverted change as surface area per unit volume is a variable
brosaplanella May 15, 2024
d38b38f
#223 remove GITT class and move to example
brosaplanella May 15, 2024
0a646f8
#223 update CHANGELOG
brosaplanella May 15, 2024
20d3612
#223 remove references to GITT class
brosaplanella May 15, 2024
fdbc803
#223 add credit to pbparam team
brosaplanella May 15, 2024
1ab30d4
#223 add tests for WeppnerHuggins
brosaplanella May 16, 2024
d91c1e5
style: pre-commit fixes
pre-commit-ci[bot] May 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions examples/scripts/gitt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import numpy as np
import pybamm

import pybop

# Define model
original_parameters = pybamm.ParameterValues("Xu2019")
brosaplanella marked this conversation as resolved.
Show resolved Hide resolved
model = pybop.lithium_ion.SPM(
parameter_set=original_parameters, options={"working electrode": "positive"}
)

# Generate data
sigma = 0.005
t_eval = np.arange(0, 150, 2)
values = model.predict(t_eval=t_eval)
corrupt_values = values["Voltage [V]"].data + np.random.normal(0, sigma, len(t_eval))

# Form dataset
dataset = pybop.Dataset(
{
"Time [s]": t_eval,
"Current function [A]": values["Current [A]"].data,
"Voltage [V]": corrupt_values,
}
)

# Define parameter set
parameter_set = pybamm.ParameterValues(
brosaplanella marked this conversation as resolved.
Show resolved Hide resolved
{
"Reference OCP [V]": 4.1821,
"Derivative of the OCP wrt stoichiometry [V]": -1.38636,
"Current function [A]": original_parameters["Current function [A]"],
"Number of electrodes connected in parallel to make a cell": original_parameters[
"Number of electrodes connected in parallel to make a cell"
],
"Electrode width [m]": original_parameters["Electrode width [m]"],
"Electrode height [m]": original_parameters["Electrode height [m]"],
"Positive electrode active material volume fraction": original_parameters[
"Positive electrode active material volume fraction"
],
"Positive electrode porosity": original_parameters[
"Positive electrode porosity"
],
"Positive particle radius [m]": original_parameters[
"Positive particle radius [m]"
],
"Positive electrode thickness [m]": original_parameters[
"Positive electrode thickness [m]"
],
"Positive electrode diffusivity [m2.s-1]": original_parameters[
"Positive electrode diffusivity [m2.s-1]"
],
"Maximum concentration in positive electrode [mol.m-3]": original_parameters[
"Maximum concentration in positive electrode [mol.m-3]"
],
}
)

# Define the cost to optimise
signal = ["Voltage [V]"]
brosaplanella marked this conversation as resolved.
Show resolved Hide resolved
problem = pybop.GITT(
model="Weppner & Huggins", parameter_set=parameter_set, dataset=dataset
BradyPlanden marked this conversation as resolved.
Show resolved Hide resolved
)
cost = pybop.RootMeanSquaredError(problem)

# Build the optimisation problem
optim = pybop.Optimisation(cost=cost, optimiser=pybop.PSO, verbose=True)

# Run the optimisation problem
x, final_cost = optim.run()
print("Estimated parameters:", x)

# Plot the timeseries output
pybop.quick_plot(problem, parameter_values=x, title="Optimised Comparison")

# Plot convergence
pybop.plot_convergence(optim)

# Plot the parameter traces
pybop.plot_parameters(optim)
2 changes: 1 addition & 1 deletion examples/standalone/problem.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from pybop._problem import BaseProblem
from pybop import BaseProblem


class StandaloneProblem(BaseProblem):
Expand Down
8 changes: 5 additions & 3 deletions pybop/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@
from ._utils import is_numeric

#
# Cost class
# Problem class
# Problem classes
#
from ._problem import BaseProblem, FittingProblem, DesignProblem
from .problems.base_problem import BaseProblem
from .problems.fitting_problem import FittingProblem
from .problems.design_problem import DesignProblem
from .problems.gitt import GITT

#
# Cost function class
Expand Down
Loading
Loading