From c55b2a36383cdb44270d0d83e5231d3d1ddbd020 Mon Sep 17 00:00:00 2001 From: Brady Planden Date: Tue, 9 Apr 2024 14:31:07 +0100 Subject: [PATCH] example implementation with GITT class --- examples/scripts/gitt.py | 17 ++++++++++++-- pybop/models/lithium_ion/weppner_huggins.py | 25 ++++++--------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/examples/scripts/gitt.py b/examples/scripts/gitt.py index 4c4b0945..7ec56206 100644 --- a/examples/scripts/gitt.py +++ b/examples/scripts/gitt.py @@ -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( { @@ -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) diff --git a/pybop/models/lithium_ion/weppner_huggins.py b/pybop/models/lithium_ion/weppner_huggins.py index c4d7438a..280bb24b 100644 --- a/pybop/models/lithium_ion/weppner_huggins.py +++ b/pybop/models/lithium_ion/weppner_huggins.py @@ -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( @@ -49,9 +45,7 @@ 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") @@ -59,24 +53,19 @@ def __init__(self, name="Weppner & Huggins model"): 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