refactored

This commit is contained in:
2025-03-30 13:10:48 +02:00
parent 7eb0ab96ef
commit 8eaafb6bda
6 changed files with 109 additions and 100 deletions
+41 -37
View File
@@ -29,46 +29,50 @@ def model_bat_dcr(temperature: float, soc: float, p: Params):
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
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))
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.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()
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)
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.show()
plot.title(title)
plot.legend(legs)
plot.ylabel(name)
plot.show()
if __name__ == '__main__':
main()