Hi all, I have a question regarding the lumped thermal model.
Currently, it is formulated by defining the thickness and densities of the anode (film & current collector), separator, & cathode (film & current collector). I see an effective volumetric heat capacity is later calculated via a thermal parameter:
# Effective heat capacity
T_vol_av = variables["Volume-averaged cell temperature [K]"]
rho_c_p_eff_av = self.param.rho_c_p_eff(T_vol_av)
def rho_c_p_eff(self, T):
"""Effective volumetric heat capacity [J.m-3.K-1]"""
return (
self.n.rho_c_p_cc(T) * self.geo.n.L_cc
+ self.n.rho_c_p(T) * self.geo.n.L
+ self.s.rho_c_p(T) * self.geo.s.L
+ self.p.rho_c_p(T) * self.geo.p.L
+ self.p.rho_c_p_cc(T) * self.geo.p.L_cc
) / self.geo.L
Instead of getting to the effective volumetric heat capacity this way, is there an easy way to directly define the cell level effective heat capacity (J/K)? Or is there an easy way to override the above function so it can be entered that way? Depending on the construction, other cell components like the casing, tabs, electrolyte amount, etc can affect the overall effective heat capacity to different degrees. I am trying to “abstract” some of this into components that are already in the lumped thermal model, but it is a bit messy.
I think I have it figure out. I was able to extend the current lumped model and add a custom bulk cell level heat capacity. I created a new submodel (BulkLumped). I can then pass this in as an option (bulk_thermal) and everything seems to work normally as expected. Let me know if anyone sees any errors.
import pybamm
from .lumped import Lumped
class BulkLumped(Lumped):
#Custom class for the lumped thermal submodel. This will allow for a bulk heat capacity
#to be entered.
def __init__(self, param, options=None, x_average=False):
super().__init__(param, options=options, x_average=x_average)
self.param.bulk_cp = pybamm.Parameter("Cell heat capacity [J/K]")
def get_coupled_variables(self, variables):
variables = super().get_coupled_variables(variables)
V_cell = self.param.V_cell
bulk_cp = self.param.bulk_cp
# Calculate the effective volumetric heat capacity from the bulk value
# This overrides the value calculated by the base Lumped model.
custom_rho_c_p_eff = bulk_cp/V_cell
variables.update({"Volume-averaged effective heat capacity [J.K-1.m-3]":custom_rho_c_p_eff})
return variables
import pybamm
import matplotlib.pyplot as plt
from parameter_sets.ParameterSet import get_parameter_values
#Setup options and model (Do not build yet)
options = {"thermal": "bulk_lumped", #Bring in custom thermal model
"contact resistance": "true",
"calculate discharge energy": "true"}
model = pybamm.lithium_ion.DFN(options=options)
#Setup parameter values (also our custom cell cp)
params = pybamm.ParameterValues(get_parameter_values())
cell_cp = 60 #Custom cell level heat capacity
params.update({"Cell heat capacity [J/K]": cell_cp}, check_already_exists=False)
#Setup custom thermal termination (65 degrees C)
def thermal_cutoff(variables):
return 65 - variables["X-averaged cell temperature [C]"]
thermal_termination = pybamm.step.CustomTermination(name = "Thermal cutoff [C]", event_function=thermal_cutoff)
terminations = [thermal_termination, "2.5V"]
#Setup experiments and run sim
experiment = ([pybamm.step.current(40, termination = terminations, period = "1 seconds")])
solver = pybamm.IDAKLUSolver()
sim = pybamm.Simulation(model=model, parameter_values=params, experiment=experiment, solver=solver)
solution = sim.solve()
#Get parameters of interest
vol = solution["Terminal voltage [V]"].data
temp = solution["X-averaged cell temperature [C]"].data
energy = solution["Discharge energy [W.h]"].data
#Plot
fig, ax = plt.subplots()
ax2 = ax.twinx()
ax.plot(energy, vol, color = "black")
ax2.plot(energy, temp, color = "black", linestyle = "dashed")
ax.grid(alpha = 0.1)
plt.show()