from matplotlib import pyplot as plot import numpy as np class Params: def __init__(self, alpha, beta): self.alpha = alpha self.beta = beta def bas(soc: float): return 0.05, 25 # from: # "Experimental Analysis and Modeling of # Temperature Dependence of Lithium-Ion Battery # Direct Current Resistance for Power Capability Prediction", # Linfeng Zheng et al., University of Technology Sydney, Australia # URL: # https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://opus.lib.uts.edu.au/rest/bitstreams/80b07f8a-db41-4cdc-b645-dbe5c0bf2446/retrieve&ved=2ahUKEwi4teeEzv2LAxVVxgIHHZwIF1IQFnoECBkQAQ&usg=AOvVaw30hTrXeAXEETJDmB7-0rze def model_bat_dcr(temperature: float, soc: float, p: Params): rb, tb = bas(soc) tb = 25 tb2 = tb*tb _t = temperature t2 = temperature*temperature return rb * np.exp(p.alpha*(t2 - tb2) + p.beta*(_t - tb)) def main() -> None: temps = [0, 5, 10, 20, 25, 40] pl = 10000 il = 100 ul = 100 rl = ul/il p_ = np.linspace(0, 20000, 100) i_ = p_/ul bat_params = Params(alpha=0.0007545, beta=-0.07033) rt_ = [] for t in temps: rt_.append(model_bat_dcr(t, 100, bat_params)) plot.figure() plot.plot(temps, rt_) r, t = bas(100) plot.title(f"DCR vs temperature (Base DCR={r}@{t}°C)") plot.xlabel("Temperature [°C]") plot.ylabel("R [Ohm]") plot.grid() titles = [ "Battery power loss vs internal battery resistance (DCR)", "Batter power consumption vs internal battery resistance (DCR)" ] for sp, name, title in zip([0, 1], ["P_loss [kW]", "P_batt [kW]"], titles): plot.figure() legs = [] plot.grid() for temp in temps: dcr = model_bat_dcr(temp, 100, bat_params) pi_ = (dcr * i_ * i_) + sp*p_ x = p_/1000 y = pi_/1000 legs.append(f"temp={temp} °C") plot.plot(x, y) plot.xlabel("P_demand [kW]") plot.title(title) plot.legend(legs) plot.ylabel(name) plot.show() if __name__ == '__main__': main()