From f3faca473c419f41e6cd7b1fdec3a89a2f094136 Mon Sep 17 00:00:00 2001 From: Caitlin Parke Date: Fri, 9 Aug 2024 16:33:10 -0400 Subject: [PATCH 01/14] Added ECM + split OCV model --- .../lithium_ion/__init__.py | 3 +- .../lithium_ion/basic_ecm_split_OCV.py | 87 +++++++++++++++++++ 2 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py diff --git a/src/pybamm/models/full_battery_models/lithium_ion/__init__.py b/src/pybamm/models/full_battery_models/lithium_ion/__init__.py index b02868dbe9..f98da10b73 100644 --- a/src/pybamm/models/full_battery_models/lithium_ion/__init__.py +++ b/src/pybamm/models/full_battery_models/lithium_ion/__init__.py @@ -24,8 +24,9 @@ from .Yang2017 import Yang2017 from .mpm import MPM from .msmr import MSMR +from .basic_ecm_split_OCV import ECMsplitOCV __all__ = ['Yang2017', 'base_lithium_ion_model', 'basic_dfn', 'basic_dfn_composite', 'basic_dfn_half_cell', 'basic_spm', 'dfn', 'electrode_soh', 'electrode_soh_half_cell', 'mpm', 'msmr', - 'newman_tobias', 'spm', 'spme'] + 'newman_tobias', 'spm', 'spme', 'ecm_split_ocv'] diff --git a/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py b/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py new file mode 100644 index 0000000000..5ad9574ab2 --- /dev/null +++ b/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py @@ -0,0 +1,87 @@ +# +# Equivalent Circuit Model with split OCV +# +import pybamm +from .base_lithium_ion_model import BaseModel + + +class ECMsplitOCV(BaseModel): + """Basic Equivalent Circuit Model that uses two OCV functions + for each electrode from the OCV function from Lithium ion parameter sets. + This class differs from the :class: pybamm.equivalent_circuit.Thevenin() due + to dual OCV functions to make up the voltage from each electrode. + + Parameters + ---------- + name: str, optional + The name of the model. + """ + + def __init__(self, name="ECM with split OCV"): + super().__init__({}, name) + # TODO citations + param = self.param + + ###################### + # Variables + ###################### + # All variables are only time-dependent + # No domain definition needed + + c_n = pybamm.Variable("Negative particle SOC") + c_p = pybamm.Variable("Positive particle SOC") + Q = pybamm.Variable("Discharge capacity [A.h]") + V = pybamm.Variable("Voltage [V]") + + # model is isothermal + T = param.T_init + I = param.current_with_time + + # Capacity equation + self.rhs[Q] = I / 3600 + self.initial_conditions[Q] = pybamm.Scalar(0) + + # Capacity in each electrode + # TODO specify capcity for negative and positive electrodes + # may be user-defined + q_n = 1 # Ah + q_p = 1 # Ah + Qn = q_n + Qp = q_p + + # State of charge electrode equations + self.rhs[c_n] = - I / Qn / 3600 + self.rhs[c_p] = I / Qp / 3600 + self.initial_conditions[c_n] = param.n.prim.c_init_av / param.n.prim.c_max + self.initial_conditions[c_p] = param.p.prim.c_init_av / param.p.prim.c_max + + # OCV's for the electrodes + Un = param.n.prim.U(c_n, T) + Up = param.p.prim.U(c_p, T) + + # IR resistance, hard coded for now + IR = 0.1 + V = Up - Un - IR + + self.variables = { + "Negative particle SOC": c_n, + "Positive particle SOC": c_p, + "Current [A]": I, + "Discharge capacity [A.h]": Q, + "Voltage [V]": V, + "Times [s]": pybamm.t, + "Positive electrode potential [V]": Up, + "Negative electrode potential [V]": Un, + "Current variable [A]": I, + "Current function [A]": I, + } + + # Events specify points at which a solution should terminate + self.events += [ + pybamm.Event("Minimum voltage [V]", V - param.voltage_low_cut), + pybamm.Event("Maximum voltage [V]", param.voltage_high_cut - V), + pybamm.Event("Maximum Negative Electrode SOC", 0.999 - c_n), + pybamm.Event("Maximum Positive Electrode SOC", 0.999 - c_p), + pybamm.Event("Minimum Negative Electrode SOC", c_n - 0.0001), + pybamm.Event("Minimum Positive Electrode SOC", c_p - 0.0001), + ] From f93e67b2fcaf2a183cb7fd63774196b698807a0f Mon Sep 17 00:00:00 2001 From: Caitlin Parke Date: Fri, 9 Aug 2024 16:39:33 -0400 Subject: [PATCH 02/14] pre-commit changes --- .../full_battery_models/lithium_ion/basic_ecm_split_OCV.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py b/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py index 5ad9574ab2..7d8d933a20 100644 --- a/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py +++ b/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py @@ -44,13 +44,13 @@ def __init__(self, name="ECM with split OCV"): # Capacity in each electrode # TODO specify capcity for negative and positive electrodes # may be user-defined - q_n = 1 # Ah - q_p = 1 # Ah + q_n = 1 # Ah + q_p = 1 # Ah Qn = q_n Qp = q_p # State of charge electrode equations - self.rhs[c_n] = - I / Qn / 3600 + self.rhs[c_n] = -I / Qn / 3600 self.rhs[c_p] = I / Qp / 3600 self.initial_conditions[c_n] = param.n.prim.c_init_av / param.n.prim.c_max self.initial_conditions[c_p] = param.p.prim.c_init_av / param.p.prim.c_max From 83239a3d48b9ad5ce1564f16f299d73f590389e2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 9 Aug 2024 20:43:34 +0000 Subject: [PATCH 03/14] style: pre-commit fixes --- .../full_battery_models/lithium_ion/basic_ecm_split_OCV.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py b/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py index 5ad9574ab2..7d8d933a20 100644 --- a/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py +++ b/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py @@ -44,13 +44,13 @@ def __init__(self, name="ECM with split OCV"): # Capacity in each electrode # TODO specify capcity for negative and positive electrodes # may be user-defined - q_n = 1 # Ah - q_p = 1 # Ah + q_n = 1 # Ah + q_p = 1 # Ah Qn = q_n Qp = q_p # State of charge electrode equations - self.rhs[c_n] = - I / Qn / 3600 + self.rhs[c_n] = -I / Qn / 3600 self.rhs[c_p] = I / Qp / 3600 self.initial_conditions[c_n] = param.n.prim.c_init_av / param.n.prim.c_max self.initial_conditions[c_p] = param.p.prim.c_init_av / param.p.prim.c_max From 2a945f280c428610fd74c008eb9bee97baf33f9f Mon Sep 17 00:00:00 2001 From: Caitlin Parke Date: Mon, 12 Aug 2024 11:17:11 -0400 Subject: [PATCH 04/14] Added parameter objects in model --- .../lithium_ion/basic_ecm_split_OCV.py | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py b/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py index 7d8d933a20..4cb0730958 100644 --- a/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py +++ b/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py @@ -42,16 +42,12 @@ def __init__(self, name="ECM with split OCV"): self.initial_conditions[Q] = pybamm.Scalar(0) # Capacity in each electrode - # TODO specify capcity for negative and positive electrodes - # may be user-defined - q_n = 1 # Ah - q_p = 1 # Ah - Qn = q_n - Qp = q_p + Q_n = pybamm.Parameter("Negative electrode capacity [A.h]") + Q_p = pybamm.Parameter("Positive electrode capacity [A.h]") # State of charge electrode equations - self.rhs[c_n] = -I / Qn / 3600 - self.rhs[c_p] = I / Qp / 3600 + self.rhs[c_n] = -I / Q_n / 3600 + self.rhs[c_p] = I / Q_p / 3600 self.initial_conditions[c_n] = param.n.prim.c_init_av / param.n.prim.c_max self.initial_conditions[c_p] = param.p.prim.c_init_av / param.p.prim.c_max @@ -59,9 +55,11 @@ def __init__(self, name="ECM with split OCV"): Un = param.n.prim.U(c_n, T) Up = param.p.prim.U(c_p, T) - # IR resistance, hard coded for now - IR = 0.1 - V = Up - Un - IR + # Resistance for IR expression + R = pybamm.Parameter("Ohmic resistance [Ohm]") + + # Voltage expression + V = Up - Un - I * R self.variables = { "Negative particle SOC": c_n, From dbeaeb515f690e40cbda5642f76c1fbeb78d3c96 Mon Sep 17 00:00:00 2001 From: Caitlin Parke Date: Tue, 13 Aug 2024 14:45:42 -0400 Subject: [PATCH 05/14] still working --- .../lithium_ion/basic_ecm_split_OCV.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py b/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py index 4cb0730958..e1e62b5b46 100644 --- a/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py +++ b/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py @@ -42,8 +42,15 @@ def __init__(self, name="ECM with split OCV"): self.initial_conditions[Q] = pybamm.Scalar(0) # Capacity in each electrode - Q_n = pybamm.Parameter("Negative electrode capacity [A.h]") - Q_p = pybamm.Parameter("Positive electrode capacity [A.h]") + Q_n = param.n.Q_init + Q_p = param.p.Q_init + # Q_n = pybamm.Parameter("Negative electrode capacity [A.h]") + # Q_p = pybamm.Parameter("Positive electrode capacity [A.h]") + R = pybamm.Parameter("Ohmic resistance [Ohm]") + Un = pybamm.Parameter("Negative electrode OCP [V]") + Up = pybamm.Parameter("Positive electrode OCP [V]") + c_n_0 = pybamm.Parameter("Negative electrode initial SOC") + c_p_0 = pybamm.Parameter("Positive electrode initial SOC") # State of charge electrode equations self.rhs[c_n] = -I / Q_n / 3600 @@ -72,6 +79,7 @@ def __init__(self, name="ECM with split OCV"): "Negative electrode potential [V]": Un, "Current variable [A]": I, "Current function [A]": I, + "Negative electrode capacity [A.h]": Q_n, } # Events specify points at which a solution should terminate From 3daabce7885a9659b71a6f79e2414d6bdb941a2f Mon Sep 17 00:00:00 2001 From: Caitlin Parke Date: Wed, 14 Aug 2024 12:01:58 -0400 Subject: [PATCH 06/14] parameter updates --- .../lithium_ion/basic_ecm_split_OCV.py | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py b/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py index e1e62b5b46..00fe7a2bf0 100644 --- a/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py +++ b/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py @@ -7,7 +7,7 @@ class ECMsplitOCV(BaseModel): """Basic Equivalent Circuit Model that uses two OCV functions - for each electrode from the OCV function from Lithium ion parameter sets. + for each electrode. This model is easily parameterizable with minimal parameters. This class differs from the :class: pybamm.equivalent_circuit.Thevenin() due to dual OCV functions to make up the voltage from each electrode. @@ -34,7 +34,6 @@ def __init__(self, name="ECM with split OCV"): V = pybamm.Variable("Voltage [V]") # model is isothermal - T = param.T_init I = param.current_with_time # Capacity equation @@ -42,29 +41,28 @@ def __init__(self, name="ECM with split OCV"): self.initial_conditions[Q] = pybamm.Scalar(0) # Capacity in each electrode - Q_n = param.n.Q_init - Q_p = param.p.Q_init - # Q_n = pybamm.Parameter("Negative electrode capacity [A.h]") - # Q_p = pybamm.Parameter("Positive electrode capacity [A.h]") - R = pybamm.Parameter("Ohmic resistance [Ohm]") - Un = pybamm.Parameter("Negative electrode OCP [V]") - Up = pybamm.Parameter("Positive electrode OCP [V]") - c_n_0 = pybamm.Parameter("Negative electrode initial SOC") - c_p_0 = pybamm.Parameter("Positive electrode initial SOC") + Q_n = pybamm.Parameter("Negative electrode capacity [A.h]") + Q_p = pybamm.Parameter("Positive electrode capacity [A.h]") # State of charge electrode equations + c_n_0 = pybamm.Parameter("Negative electrode initial SOC") + c_p_0 = pybamm.Parameter("Positive electrode initial SOC") self.rhs[c_n] = -I / Q_n / 3600 self.rhs[c_p] = I / Q_p / 3600 - self.initial_conditions[c_n] = param.n.prim.c_init_av / param.n.prim.c_max - self.initial_conditions[c_p] = param.p.prim.c_init_av / param.p.prim.c_max - - # OCV's for the electrodes - Un = param.n.prim.U(c_n, T) - Up = param.p.prim.U(c_p, T) + self.initial_conditions[c_n] = c_n_0 + self.initial_conditions[c_p] = c_p_0 # Resistance for IR expression R = pybamm.Parameter("Ohmic resistance [Ohm]") + # Open-circuit potential for each electrode + Un = pybamm.FunctionParameter( + "Negative electrode OCP [V]", {"Negative particle SOC": c_n} + ) + Up = pybamm.FunctionParameter( + "Positive electrode OCP [V]", {"Positive particle SOC": c_p} + ) + # Voltage expression V = Up - Un - I * R @@ -77,9 +75,7 @@ def __init__(self, name="ECM with split OCV"): "Times [s]": pybamm.t, "Positive electrode potential [V]": Up, "Negative electrode potential [V]": Un, - "Current variable [A]": I, "Current function [A]": I, - "Negative electrode capacity [A.h]": Q_n, } # Events specify points at which a solution should terminate From 758175f07874d5193467af976adf4bc67c26fd9d Mon Sep 17 00:00:00 2001 From: Caitlin Parke Date: Fri, 16 Aug 2024 00:42:04 -0400 Subject: [PATCH 07/14] added tests --- .../lithium_ion/basic_ecm_split_OCV.py | 19 +++++--- .../test_lithium_ion/test_ecm_split_OCV.py | 46 +++++++++++++++++++ .../test_lithium_ion/test_ecm_split_OCV.py | 9 ++++ 3 files changed, 67 insertions(+), 7 deletions(-) create mode 100644 tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py create mode 100644 tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py diff --git a/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py b/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py index 00fe7a2bf0..9195a7433d 100644 --- a/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py +++ b/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py @@ -2,10 +2,9 @@ # Equivalent Circuit Model with split OCV # import pybamm -from .base_lithium_ion_model import BaseModel -class ECMsplitOCV(BaseModel): +class ECMsplitOCV(pybamm.BaseModel): """Basic Equivalent Circuit Model that uses two OCV functions for each electrode. This model is easily parameterizable with minimal parameters. This class differs from the :class: pybamm.equivalent_circuit.Thevenin() due @@ -18,9 +17,9 @@ class ECMsplitOCV(BaseModel): """ def __init__(self, name="ECM with split OCV"): - super().__init__({}, name) + super().__init__(name) # TODO citations - param = self.param + # param = self.param ###################### # Variables @@ -34,7 +33,9 @@ def __init__(self, name="ECM with split OCV"): V = pybamm.Variable("Voltage [V]") # model is isothermal - I = param.current_with_time + I = pybamm.FunctionParameter( + "Current function [A]", {"Time [s]": pybamm.t} + ) # Capacity equation self.rhs[Q] = I / 3600 @@ -66,6 +67,10 @@ def __init__(self, name="ECM with split OCV"): # Voltage expression V = Up - Un - I * R + # Parameters for Voltage cutoff + voltage_high_cut = pybamm.Parameter('Upper voltage cut-off [V]') + voltage_low_cut = pybamm.Parameter('Lower voltage cut-off [V]') + self.variables = { "Negative particle SOC": c_n, "Positive particle SOC": c_p, @@ -80,8 +85,8 @@ def __init__(self, name="ECM with split OCV"): # Events specify points at which a solution should terminate self.events += [ - pybamm.Event("Minimum voltage [V]", V - param.voltage_low_cut), - pybamm.Event("Maximum voltage [V]", param.voltage_high_cut - V), + pybamm.Event("Minimum voltage [V]", V - voltage_low_cut), + pybamm.Event("Maximum voltage [V]", voltage_high_cut - V), pybamm.Event("Maximum Negative Electrode SOC", 0.999 - c_n), pybamm.Event("Maximum Positive Electrode SOC", 0.999 - c_p), pybamm.Event("Minimum Negative Electrode SOC", c_n - 0.0001), diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py new file mode 100644 index 0000000000..e14dc7f803 --- /dev/null +++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py @@ -0,0 +1,46 @@ +# +# Test that the model works should I change the base model to just regular base model from .lihtium_ion_model BaseModel +# does that set parameters that we really don't want, is this really as simple as we want it to be +import pybamm +import numpy as np + +class TestECMSplitOCVModel: + def test_run_model_with_parameters(self): + model = pybamm.lithium_ion.ECMsplitOCV() + + # example parameters + qp0 = 8.73231852 + qn0 = 5.82761507 + c0_n = 0.9013973983641687*0.9 + c0_p = 0.5142305254580026*0.83 + + # OCV functions + def Un(theta_n): + Un = 0.1493 + 0.8493*np.exp(-61.79*theta_n) + 0.3824*np.exp(-665.8*theta_n) \ + - np.exp(39.42*theta_n-41.92) - 0.03131*np.arctan(25.59*theta_n - 4.099) \ + - 0.009434*np.arctan(32.49*theta_n - 15.74) + return Un + + def Up(theta_p): + Up = -10.72*theta_p**4 + 23.88*theta_p**3 - 16.77*theta_p**2 + 2.595*theta_p + 4.563 + return Up + + pars = pybamm.ParameterValues( + { + 'Positive electrode capacity [A.h]' : qp0, + 'Ohmic resistance [Ohm]' : 0.001, + 'Negative electrode initial SOC' : c0_n, + 'Lower voltage cut-off [V]' : 2.8, + 'Positive electrode initial SOC' : c0_p, + 'Upper voltage cut-off [V]' : 4.2, + 'Negative electrode capacity [A.h]' : qn0, + 'Current function [A]' : 5, + 'Positive electrode OCP [V]' : Up, + 'Negative electrode OCP [V]' : Un, + } + ) + + # solve the model + sim = pybamm.Simulation(model, parameter_values=pars) + t_eval = np.linspace(0, 3600) + sim.solve(t_eval) \ No newline at end of file diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py new file mode 100644 index 0000000000..67266de5ae --- /dev/null +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py @@ -0,0 +1,9 @@ +# +# Test for the ecm split-OCV model +# +import pybamm + +class TestECMSplitOCV: + def test_ecmsplitocv_well_posed(self): + model = pybamm.lithium_ion.ECMsplitOCV() + model.check_well_posedness() \ No newline at end of file From 99e31196650de430b775c35544e14060d87a0eb0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 16 Aug 2024 04:42:19 +0000 Subject: [PATCH 08/14] style: pre-commit fixes --- .../lithium_ion/basic_ecm_split_OCV.py | 8 ++- .../test_lithium_ion/test_ecm_split_OCV.py | 50 ++++++++++++------- .../test_lithium_ion/test_ecm_split_OCV.py | 3 +- 3 files changed, 36 insertions(+), 25 deletions(-) diff --git a/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py b/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py index 9195a7433d..55895e6c9d 100644 --- a/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py +++ b/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py @@ -33,9 +33,7 @@ def __init__(self, name="ECM with split OCV"): V = pybamm.Variable("Voltage [V]") # model is isothermal - I = pybamm.FunctionParameter( - "Current function [A]", {"Time [s]": pybamm.t} - ) + I = pybamm.FunctionParameter("Current function [A]", {"Time [s]": pybamm.t}) # Capacity equation self.rhs[Q] = I / 3600 @@ -68,8 +66,8 @@ def __init__(self, name="ECM with split OCV"): V = Up - Un - I * R # Parameters for Voltage cutoff - voltage_high_cut = pybamm.Parameter('Upper voltage cut-off [V]') - voltage_low_cut = pybamm.Parameter('Lower voltage cut-off [V]') + voltage_high_cut = pybamm.Parameter("Upper voltage cut-off [V]") + voltage_low_cut = pybamm.Parameter("Lower voltage cut-off [V]") self.variables = { "Negative particle SOC": c_n, diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py index e14dc7f803..dbf43133f3 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py +++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py @@ -4,43 +4,55 @@ import pybamm import numpy as np + class TestECMSplitOCVModel: def test_run_model_with_parameters(self): model = pybamm.lithium_ion.ECMsplitOCV() - + # example parameters qp0 = 8.73231852 qn0 = 5.82761507 - c0_n = 0.9013973983641687*0.9 - c0_p = 0.5142305254580026*0.83 + c0_n = 0.9013973983641687 * 0.9 + c0_p = 0.5142305254580026 * 0.83 # OCV functions def Un(theta_n): - Un = 0.1493 + 0.8493*np.exp(-61.79*theta_n) + 0.3824*np.exp(-665.8*theta_n) \ - - np.exp(39.42*theta_n-41.92) - 0.03131*np.arctan(25.59*theta_n - 4.099) \ - - 0.009434*np.arctan(32.49*theta_n - 15.74) + Un = ( + 0.1493 + + 0.8493 * np.exp(-61.79 * theta_n) + + 0.3824 * np.exp(-665.8 * theta_n) + - np.exp(39.42 * theta_n - 41.92) + - 0.03131 * np.arctan(25.59 * theta_n - 4.099) + - 0.009434 * np.arctan(32.49 * theta_n - 15.74) + ) return Un def Up(theta_p): - Up = -10.72*theta_p**4 + 23.88*theta_p**3 - 16.77*theta_p**2 + 2.595*theta_p + 4.563 + Up = ( + -10.72 * theta_p**4 + + 23.88 * theta_p**3 + - 16.77 * theta_p**2 + + 2.595 * theta_p + + 4.563 + ) return Up - + pars = pybamm.ParameterValues( { - 'Positive electrode capacity [A.h]' : qp0, - 'Ohmic resistance [Ohm]' : 0.001, - 'Negative electrode initial SOC' : c0_n, - 'Lower voltage cut-off [V]' : 2.8, - 'Positive electrode initial SOC' : c0_p, - 'Upper voltage cut-off [V]' : 4.2, - 'Negative electrode capacity [A.h]' : qn0, - 'Current function [A]' : 5, - 'Positive electrode OCP [V]' : Up, - 'Negative electrode OCP [V]' : Un, + "Positive electrode capacity [A.h]": qp0, + "Ohmic resistance [Ohm]": 0.001, + "Negative electrode initial SOC": c0_n, + "Lower voltage cut-off [V]": 2.8, + "Positive electrode initial SOC": c0_p, + "Upper voltage cut-off [V]": 4.2, + "Negative electrode capacity [A.h]": qn0, + "Current function [A]": 5, + "Positive electrode OCP [V]": Up, + "Negative electrode OCP [V]": Un, } ) # solve the model sim = pybamm.Simulation(model, parameter_values=pars) t_eval = np.linspace(0, 3600) - sim.solve(t_eval) \ No newline at end of file + sim.solve(t_eval) diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py index 67266de5ae..a26b42a459 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py @@ -3,7 +3,8 @@ # import pybamm + class TestECMSplitOCV: def test_ecmsplitocv_well_posed(self): model = pybamm.lithium_ion.ECMsplitOCV() - model.check_well_posedness() \ No newline at end of file + model.check_well_posedness() From b1de9d1cf11db4e0c80817415ddca2f8d99591e9 Mon Sep 17 00:00:00 2001 From: Caitlin Parke Date: Fri, 16 Aug 2024 00:44:19 -0400 Subject: [PATCH 09/14] pre-commit --- .../lithium_ion/basic_ecm_split_OCV.py | 8 ++- .../test_lithium_ion/test_ecm_split_OCV.py | 50 ++++++++++++------- .../test_lithium_ion/test_ecm_split_OCV.py | 3 +- 3 files changed, 36 insertions(+), 25 deletions(-) diff --git a/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py b/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py index 9195a7433d..55895e6c9d 100644 --- a/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py +++ b/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py @@ -33,9 +33,7 @@ def __init__(self, name="ECM with split OCV"): V = pybamm.Variable("Voltage [V]") # model is isothermal - I = pybamm.FunctionParameter( - "Current function [A]", {"Time [s]": pybamm.t} - ) + I = pybamm.FunctionParameter("Current function [A]", {"Time [s]": pybamm.t}) # Capacity equation self.rhs[Q] = I / 3600 @@ -68,8 +66,8 @@ def __init__(self, name="ECM with split OCV"): V = Up - Un - I * R # Parameters for Voltage cutoff - voltage_high_cut = pybamm.Parameter('Upper voltage cut-off [V]') - voltage_low_cut = pybamm.Parameter('Lower voltage cut-off [V]') + voltage_high_cut = pybamm.Parameter("Upper voltage cut-off [V]") + voltage_low_cut = pybamm.Parameter("Lower voltage cut-off [V]") self.variables = { "Negative particle SOC": c_n, diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py index e14dc7f803..dbf43133f3 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py +++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py @@ -4,43 +4,55 @@ import pybamm import numpy as np + class TestECMSplitOCVModel: def test_run_model_with_parameters(self): model = pybamm.lithium_ion.ECMsplitOCV() - + # example parameters qp0 = 8.73231852 qn0 = 5.82761507 - c0_n = 0.9013973983641687*0.9 - c0_p = 0.5142305254580026*0.83 + c0_n = 0.9013973983641687 * 0.9 + c0_p = 0.5142305254580026 * 0.83 # OCV functions def Un(theta_n): - Un = 0.1493 + 0.8493*np.exp(-61.79*theta_n) + 0.3824*np.exp(-665.8*theta_n) \ - - np.exp(39.42*theta_n-41.92) - 0.03131*np.arctan(25.59*theta_n - 4.099) \ - - 0.009434*np.arctan(32.49*theta_n - 15.74) + Un = ( + 0.1493 + + 0.8493 * np.exp(-61.79 * theta_n) + + 0.3824 * np.exp(-665.8 * theta_n) + - np.exp(39.42 * theta_n - 41.92) + - 0.03131 * np.arctan(25.59 * theta_n - 4.099) + - 0.009434 * np.arctan(32.49 * theta_n - 15.74) + ) return Un def Up(theta_p): - Up = -10.72*theta_p**4 + 23.88*theta_p**3 - 16.77*theta_p**2 + 2.595*theta_p + 4.563 + Up = ( + -10.72 * theta_p**4 + + 23.88 * theta_p**3 + - 16.77 * theta_p**2 + + 2.595 * theta_p + + 4.563 + ) return Up - + pars = pybamm.ParameterValues( { - 'Positive electrode capacity [A.h]' : qp0, - 'Ohmic resistance [Ohm]' : 0.001, - 'Negative electrode initial SOC' : c0_n, - 'Lower voltage cut-off [V]' : 2.8, - 'Positive electrode initial SOC' : c0_p, - 'Upper voltage cut-off [V]' : 4.2, - 'Negative electrode capacity [A.h]' : qn0, - 'Current function [A]' : 5, - 'Positive electrode OCP [V]' : Up, - 'Negative electrode OCP [V]' : Un, + "Positive electrode capacity [A.h]": qp0, + "Ohmic resistance [Ohm]": 0.001, + "Negative electrode initial SOC": c0_n, + "Lower voltage cut-off [V]": 2.8, + "Positive electrode initial SOC": c0_p, + "Upper voltage cut-off [V]": 4.2, + "Negative electrode capacity [A.h]": qn0, + "Current function [A]": 5, + "Positive electrode OCP [V]": Up, + "Negative electrode OCP [V]": Un, } ) # solve the model sim = pybamm.Simulation(model, parameter_values=pars) t_eval = np.linspace(0, 3600) - sim.solve(t_eval) \ No newline at end of file + sim.solve(t_eval) diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py index 67266de5ae..a26b42a459 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py @@ -3,7 +3,8 @@ # import pybamm + class TestECMSplitOCV: def test_ecmsplitocv_well_posed(self): model = pybamm.lithium_ion.ECMsplitOCV() - model.check_well_posedness() \ No newline at end of file + model.check_well_posedness() From 3f1e7f50792a157ecfb0c2cb269d3f426c5032e0 Mon Sep 17 00:00:00 2001 From: Caitlin Parke Date: Mon, 19 Aug 2024 20:07:44 -0400 Subject: [PATCH 10/14] added default plotting variables --- .../lithium_ion/basic_ecm_split_OCV.py | 14 ++++++++++++-- .../test_lithium_ion/test_ecm_split_OCV.py | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py b/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py index 55895e6c9d..19398b4a4f 100644 --- a/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py +++ b/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py @@ -76,8 +76,8 @@ def __init__(self, name="ECM with split OCV"): "Discharge capacity [A.h]": Q, "Voltage [V]": V, "Times [s]": pybamm.t, - "Positive electrode potential [V]": Up, - "Negative electrode potential [V]": Un, + "Positive electrode OCP [V]": Up, + "Negative electrode OCP [V]": Un, "Current function [A]": I, } @@ -90,3 +90,13 @@ def __init__(self, name="ECM with split OCV"): pybamm.Event("Minimum Negative Electrode SOC", c_n - 0.0001), pybamm.Event("Minimum Positive Electrode SOC", c_p - 0.0001), ] + + @property + def default_quick_plot_variables(self): + return [ + "Voltage [V]", + ["Negative particle SOC", "Positive particle SOC"], + "Negative electrode OCP [V]", + "Positive electrode OCP [V]", + "Current [A]", + ] diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py index dbf43133f3..947b3dda35 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py +++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py @@ -1,6 +1,6 @@ # -# Test that the model works should I change the base model to just regular base model from .lihtium_ion_model BaseModel -# does that set parameters that we really don't want, is this really as simple as we want it to be +# Test that the model works with an example parameter set +# import pybamm import numpy as np From e4504a6d6d6a717d18326917dccb75b80d057f5e Mon Sep 17 00:00:00 2001 From: Caitlin Parke Date: Tue, 20 Aug 2024 18:18:42 -0400 Subject: [PATCH 11/14] added docs --- docs/source/api/models/lithium_ion/ecm_split_ocv.rst | 7 +++++++ docs/source/api/models/lithium_ion/index.rst | 1 + .../full_battery_models/lithium_ion/basic_ecm_split_OCV.py | 2 -- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 docs/source/api/models/lithium_ion/ecm_split_ocv.rst diff --git a/docs/source/api/models/lithium_ion/ecm_split_ocv.rst b/docs/source/api/models/lithium_ion/ecm_split_ocv.rst new file mode 100644 index 0000000000..2fcc4d37d8 --- /dev/null +++ b/docs/source/api/models/lithium_ion/ecm_split_ocv.rst @@ -0,0 +1,7 @@ +Equivalent Circuit Model with Split OCV (ECMsplitOCV) +===================================================== + +.. autoclass:: pybamm.lithium_ion.ECMsplitOCV + :members: + +.. footbibliography:: diff --git a/docs/source/api/models/lithium_ion/index.rst b/docs/source/api/models/lithium_ion/index.rst index 1a72c3c662..52efe44d6b 100644 --- a/docs/source/api/models/lithium_ion/index.rst +++ b/docs/source/api/models/lithium_ion/index.rst @@ -12,3 +12,4 @@ Lithium-ion Models msmr yang2017 electrode_soh + ecm_split_ocv diff --git a/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py b/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py index 19398b4a4f..2869d9b94f 100644 --- a/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py +++ b/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py @@ -18,8 +18,6 @@ class ECMsplitOCV(pybamm.BaseModel): def __init__(self, name="ECM with split OCV"): super().__init__(name) - # TODO citations - # param = self.param ###################### # Variables From 9a996c4006e2cf94ab9f39f0e96f7813f710d0bb Mon Sep 17 00:00:00 2001 From: Caitlin Parke Date: Wed, 21 Aug 2024 16:46:28 -0400 Subject: [PATCH 12/14] updated for pytest and better coverage --- .../test_lithium_ion/test_ecm_split_OCV.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py index a26b42a459..5645466d93 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py @@ -8,3 +8,8 @@ class TestECMSplitOCV: def test_ecmsplitocv_well_posed(self): model = pybamm.lithium_ion.ECMsplitOCV() model.check_well_posedness() + + def test_get_default_quick_plot_variables(self): + model = pybamm.lithium_ion.ECMsplitOCV() + variables = model.default_quick_plot_variables + assert "Current [A]" in variables From f23ac77d82de6ec0ea05a3da98f4873e862b75b1 Mon Sep 17 00:00:00 2001 From: Caitlin Parke Date: Tue, 3 Sep 2024 13:11:22 -0400 Subject: [PATCH 13/14] updated tests and naming convention --- CHANGELOG.md | 1 + .../api/models/lithium_ion/ecm_split_ocv.rst | 4 +-- .../lithium_ion/__init__.py | 4 +-- ...ic_ecm_split_OCV.py => basic_splitOCVR.py} | 36 +++++++++---------- ...est_ecm_split_OCV.py => test_splitOCVR.py} | 24 ++++++------- ...est_ecm_split_OCV.py => test_splitOCVR.py} | 6 ++-- 6 files changed, 37 insertions(+), 38 deletions(-) rename src/pybamm/models/full_battery_models/lithium_ion/{basic_ecm_split_OCV.py => basic_splitOCVR.py} (66%) rename tests/integration/test_models/test_full_battery_models/test_lithium_ion/{test_ecm_split_OCV.py => test_splitOCVR.py} (73%) rename tests/unit/test_models/test_full_battery_models/test_lithium_ion/{test_ecm_split_OCV.py => test_splitOCVR.py} (70%) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1e8a720e7..72755d1538 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Features +- Added a lithium ion equivalent circuit model with split open circuit voltages for each electrode. ([#4330](https://github.com/pybamm-team/PyBaMM/pull/4330)) - Added additional user-configurable options to the (`IDAKLUSolver`) and adjusted the default values to improve performance. ([#4282](https://github.com/pybamm-team/PyBaMM/pull/4282)) - Added the diffusion element to be used in the Thevenin model. ([#4254](https://github.com/pybamm-team/PyBaMM/pull/4254)) diff --git a/docs/source/api/models/lithium_ion/ecm_split_ocv.rst b/docs/source/api/models/lithium_ion/ecm_split_ocv.rst index 2fcc4d37d8..a7d833cf55 100644 --- a/docs/source/api/models/lithium_ion/ecm_split_ocv.rst +++ b/docs/source/api/models/lithium_ion/ecm_split_ocv.rst @@ -1,7 +1,7 @@ -Equivalent Circuit Model with Split OCV (ECMsplitOCV) +Equivalent Circuit Model with Split OCV (SplitOCVR) ===================================================== -.. autoclass:: pybamm.lithium_ion.ECMsplitOCV +.. autoclass:: pybamm.lithium_ion.SplitOCVR :members: .. footbibliography:: diff --git a/src/pybamm/models/full_battery_models/lithium_ion/__init__.py b/src/pybamm/models/full_battery_models/lithium_ion/__init__.py index f98da10b73..556e8de31c 100644 --- a/src/pybamm/models/full_battery_models/lithium_ion/__init__.py +++ b/src/pybamm/models/full_battery_models/lithium_ion/__init__.py @@ -24,9 +24,9 @@ from .Yang2017 import Yang2017 from .mpm import MPM from .msmr import MSMR -from .basic_ecm_split_OCV import ECMsplitOCV +from .basic_splitOCVR import SplitOCVR __all__ = ['Yang2017', 'base_lithium_ion_model', 'basic_dfn', 'basic_dfn_composite', 'basic_dfn_half_cell', 'basic_spm', 'dfn', 'electrode_soh', 'electrode_soh_half_cell', 'mpm', 'msmr', - 'newman_tobias', 'spm', 'spme', 'ecm_split_ocv'] + 'newman_tobias', 'spm', 'spme', 'basic_splitOCVR'] diff --git a/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py b/src/pybamm/models/full_battery_models/lithium_ion/basic_splitOCVR.py similarity index 66% rename from src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py rename to src/pybamm/models/full_battery_models/lithium_ion/basic_splitOCVR.py index 2869d9b94f..386a5c08fc 100644 --- a/src/pybamm/models/full_battery_models/lithium_ion/basic_ecm_split_OCV.py +++ b/src/pybamm/models/full_battery_models/lithium_ion/basic_splitOCVR.py @@ -4,7 +4,7 @@ import pybamm -class ECMsplitOCV(pybamm.BaseModel): +class SplitOCVR(pybamm.BaseModel): """Basic Equivalent Circuit Model that uses two OCV functions for each electrode. This model is easily parameterizable with minimal parameters. This class differs from the :class: pybamm.equivalent_circuit.Thevenin() due @@ -25,8 +25,8 @@ def __init__(self, name="ECM with split OCV"): # All variables are only time-dependent # No domain definition needed - c_n = pybamm.Variable("Negative particle SOC") - c_p = pybamm.Variable("Positive particle SOC") + theta_n = pybamm.Variable("Negative particle stoichiometry") + theta_p = pybamm.Variable("Positive particle stoichiometry") Q = pybamm.Variable("Discharge capacity [A.h]") V = pybamm.Variable("Voltage [V]") @@ -42,22 +42,22 @@ def __init__(self, name="ECM with split OCV"): Q_p = pybamm.Parameter("Positive electrode capacity [A.h]") # State of charge electrode equations - c_n_0 = pybamm.Parameter("Negative electrode initial SOC") - c_p_0 = pybamm.Parameter("Positive electrode initial SOC") - self.rhs[c_n] = -I / Q_n / 3600 - self.rhs[c_p] = I / Q_p / 3600 - self.initial_conditions[c_n] = c_n_0 - self.initial_conditions[c_p] = c_p_0 + theta_n_0 = pybamm.Parameter("Negative electrode initial stoichiometry") + theta_p_0 = pybamm.Parameter("Positive electrode initial stoichiometry") + self.rhs[theta_n] = -I / Q_n / 3600 + self.rhs[theta_p] = I / Q_p / 3600 + self.initial_conditions[theta_n] = theta_n_0 + self.initial_conditions[theta_p] = theta_p_0 # Resistance for IR expression R = pybamm.Parameter("Ohmic resistance [Ohm]") # Open-circuit potential for each electrode Un = pybamm.FunctionParameter( - "Negative electrode OCP [V]", {"Negative particle SOC": c_n} + "Negative electrode OCP [V]", {"Negative particle stoichiometry": theta_n} ) Up = pybamm.FunctionParameter( - "Positive electrode OCP [V]", {"Positive particle SOC": c_p} + "Positive electrode OCP [V]", {"Positive particle stoichiometry": theta_p} ) # Voltage expression @@ -68,8 +68,8 @@ def __init__(self, name="ECM with split OCV"): voltage_low_cut = pybamm.Parameter("Lower voltage cut-off [V]") self.variables = { - "Negative particle SOC": c_n, - "Positive particle SOC": c_p, + "Negative particle stoichiometry": theta_n, + "Positive particle stoichiometry": theta_p, "Current [A]": I, "Discharge capacity [A.h]": Q, "Voltage [V]": V, @@ -83,17 +83,17 @@ def __init__(self, name="ECM with split OCV"): self.events += [ pybamm.Event("Minimum voltage [V]", V - voltage_low_cut), pybamm.Event("Maximum voltage [V]", voltage_high_cut - V), - pybamm.Event("Maximum Negative Electrode SOC", 0.999 - c_n), - pybamm.Event("Maximum Positive Electrode SOC", 0.999 - c_p), - pybamm.Event("Minimum Negative Electrode SOC", c_n - 0.0001), - pybamm.Event("Minimum Positive Electrode SOC", c_p - 0.0001), + pybamm.Event("Maximum Negative Electrode stoichiometry", 0.999 - theta_n), + pybamm.Event("Maximum Positive Electrode stoichiometry", 0.999 - theta_p), + pybamm.Event("Minimum Negative Electrode stoichiometry", theta_n - 0.0001), + pybamm.Event("Minimum Positive Electrode stoichiometry", theta_p - 0.0001), ] @property def default_quick_plot_variables(self): return [ "Voltage [V]", - ["Negative particle SOC", "Positive particle SOC"], + ["Negative particle stoichiometry", "Positive particle stoichiometry"], "Negative electrode OCP [V]", "Positive electrode OCP [V]", "Current [A]", diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_splitOCVR.py similarity index 73% rename from tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py rename to tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_splitOCVR.py index 947b3dda35..ef4391acdd 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py +++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_splitOCVR.py @@ -3,17 +3,16 @@ # import pybamm import numpy as np +import tests -class TestECMSplitOCVModel: - def test_run_model_with_parameters(self): - model = pybamm.lithium_ion.ECMsplitOCV() - +class TestSplitOCVR: + def test_basic_processing(self): # example parameters qp0 = 8.73231852 qn0 = 5.82761507 - c0_n = 0.9013973983641687 * 0.9 - c0_p = 0.5142305254580026 * 0.83 + theta0_n = 0.9013973983641687 * 0.9 + theta0_p = 0.5142305254580026 * 0.83 # OCV functions def Un(theta_n): @@ -41,18 +40,17 @@ def Up(theta_p): { "Positive electrode capacity [A.h]": qp0, "Ohmic resistance [Ohm]": 0.001, - "Negative electrode initial SOC": c0_n, + "Negative electrode initial stoichiometry": theta0_n, "Lower voltage cut-off [V]": 2.8, - "Positive electrode initial SOC": c0_p, + "Positive electrode initial stoichiometry": theta0_p, "Upper voltage cut-off [V]": 4.2, "Negative electrode capacity [A.h]": qn0, "Current function [A]": 5, "Positive electrode OCP [V]": Up, "Negative electrode OCP [V]": Un, + "Nominal cell capacity [A.h]": 5, } ) - - # solve the model - sim = pybamm.Simulation(model, parameter_values=pars) - t_eval = np.linspace(0, 3600) - sim.solve(t_eval) + model = pybamm.lithium_ion.SplitOCVR() + modeltest = tests.StandardModelTest(model) + modeltest.test_all(param=pars) diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_splitOCVR.py similarity index 70% rename from tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py rename to tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_splitOCVR.py index 5645466d93..e807ec1607 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_ecm_split_OCV.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_splitOCVR.py @@ -4,12 +4,12 @@ import pybamm -class TestECMSplitOCV: +class TestSplitOCVR: def test_ecmsplitocv_well_posed(self): - model = pybamm.lithium_ion.ECMsplitOCV() + model = pybamm.lithium_ion.SplitOCVR() model.check_well_posedness() def test_get_default_quick_plot_variables(self): - model = pybamm.lithium_ion.ECMsplitOCV() + model = pybamm.lithium_ion.SplitOCVR() variables = model.default_quick_plot_variables assert "Current [A]" in variables From 3b21bf62ae604edfd322c7702550b3d97a9b9cbd Mon Sep 17 00:00:00 2001 From: "Eric G. Kratz" Date: Tue, 3 Sep 2024 16:45:19 -0400 Subject: [PATCH 14/14] Move changelog update to unreleased --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0962bdbe23..9e61a1b795 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,13 @@ # [Unreleased](https://github.com/pybamm-team/PyBaMM/) +## Features + +- Added a lithium ion equivalent circuit model with split open circuit voltages for each electrode. ([#4330](https://github.com/pybamm-team/PyBaMM/pull/4330)) + # [v24.9.0](https://github.com/pybamm-team/PyBaMM/tree/v24.9.0) - 2024-09-03 ## Features -- Added a lithium ion equivalent circuit model with split open circuit voltages for each electrode. ([#4330](https://github.com/pybamm-team/PyBaMM/pull/4330)) - Added additional user-configurable options to the (`IDAKLUSolver`) and adjusted the default values to improve performance. ([#4282](https://github.com/pybamm-team/PyBaMM/pull/4282)) - Added the diffusion element to be used in the Thevenin model. ([#4254](https://github.com/pybamm-team/PyBaMM/pull/4254))