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()