Skip to content

Commit

Permalink
example implementation with GITT class
Browse files Browse the repository at this point in the history
  • Loading branch information
BradyPlanden committed Apr 9, 2024
1 parent 2f6a0e7 commit c55b2a3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
17 changes: 15 additions & 2 deletions examples/scripts/gitt.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
}
)

# Define diffusion parameter for fitting
parameters = [
pybop.Parameter(
"Positive electrode diffusivity [m2.s-1]",
prior=pybop.Gaussian(5e-14, 1e-13),
bounds=[1e-16, 1e-11],
true_value=parameter_set["Positive electrode diffusivity [m2.s-1]"],
),
]

# Define parameter set
parameter_set.update(
{
Expand All @@ -32,9 +42,12 @@
check_already_exists=False,
)

# Weppner & Huggins model
wep_huggins_model = pybop.lithium_ion.WeppnerHuggins(parameter_set=parameter_set)

# Define the cost to optimise
problem = pybop.GITT(
model="Weppner & Huggins", parameter_set=parameter_set, dataset=dataset
problem = pybop.FittingProblem(
model=wep_huggins_model, parameters=parameters, dataset=dataset
)
cost = pybop.RootMeanSquaredError(problem)

Expand Down
25 changes: 7 additions & 18 deletions pybop/models/lithium_ion/weppner_huggins.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ def __init__(self, name="Weppner & Huggins model"):
# `ParameterValues` class when the model is processed.
self.options["working electrode"] = "positive"

t = pybamm.t
######################
# Parameters
######################

d_s = pybamm.Parameter("Positive electrode diffusivity [m2.s-1]")

c_s_max = pybamm.Parameter(
Expand All @@ -49,34 +45,27 @@ def __init__(self, name="Weppner & Huggins model"):

i_app = self.param.current_density_with_time

U = pybamm.Parameter("Reference OCP [V]")

U_prime = pybamm.Parameter("Derivative of the OCP wrt stoichiometry [V]")
u_prime = pybamm.Parameter("Derivative of the OCP wrt stoichiometry [V]")

epsilon = pybamm.Parameter("Positive electrode active material volume fraction")

r_particle = pybamm.Parameter("Positive particle radius [m]")

a = 3 * (epsilon / r_particle)

l_w = self.param.p.L

######################
# Governing equations
######################
u_surf = (
(2 / (np.pi**0.5))
* (i_app / ((d_s**0.5) * a * self.param.F * l_w))
* (t**0.5)
* (i_app / ((d_s**0.5) * a * self.param.F * self.param.p.L))
* (pybamm.t**0.5)
)
# Linearised voltage
V = U + (U_prime * u_surf) / c_s_max
######################
# (Some) variables
######################
V = pybamm.Parameter("Reference OCP [V]") + (u_prime * u_surf) / c_s_max

# Variables
self.variables = {
"Voltage [V]": V,
"Time [s]": t,
"Time [s]": pybamm.t,
}

@property
Expand Down

0 comments on commit c55b2a3

Please sign in to comment.