Files
we_collect/innenwiderstand.py
T
2025-03-09 19:13:49 +01:00

67 lines
1.3 KiB
Python

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