
close all;
clear all;

E_bar = 100;
Ts = 600/3600;
SOC_0 = 0.5;

soc = @(P, eta) SOC_0 + Ts/E_bar * cumsum(eta * max(P,0) + 1/eta * min(P, 0));


rng(1);
P = randn(1000, 1)*10;

plot(soc(P, 0.5))
hold on
plot(soc(P, 1))
hold off


fprintf('avg soc (eta=0.5): %.2f\n', mean(soc(P, 0.5)))
fprintf('avg soc (eta=1):: %.2f\n', mean(soc(P, 1)))


fprintf('battery tends to discharge when eff is lower.\n')