Skip to content

Commit

Permalink
pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
parkec3 committed Aug 16, 2024
1 parent 758175f commit b1de9d1
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
sim.solve(t_eval)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
#
import pybamm


class TestECMSplitOCV:
def test_ecmsplitocv_well_posed(self):
model = pybamm.lithium_ion.ECMsplitOCV()
model.check_well_posedness()
model.check_well_posedness()

0 comments on commit b1de9d1

Please sign in to comment.