From 9914a005118001fb813281cdc21b06d6141b8272 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Sun, 9 Mar 2025 19:13:49 +0100 Subject: [PATCH] add innenwiderstand.py --- innenwiderstand.py | 66 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/innenwiderstand.py b/innenwiderstand.py index e69de29..51c890e 100644 --- a/innenwiderstand.py +++ b/innenwiderstand.py @@ -0,0 +1,66 @@ +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 + +def model_r(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)) + + +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_r(t, 100, bat_params)) + +plot.figure() +plot.plot(temps, rt_) +r, t = bas(100) +plot.title(f"Ri vs temperature (Base R={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: + ri = model_r(temp, 100, bat_params) + pi_ = (ri * 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()