# matlab implementation of battery state of charge constraints

7 views (last 30 days)
sibabalo noludwwe on 5 May 2020
background: 1. I have a 33 bus IEEE network with two battery units and other distributed generation. I am formulating my problem using intlinprog in matlab ( the problem is not problem based).
2. the problem is solved over a time horizon of ten hours (1 hour time step).
3. i have formulated all my other constraints for the other distributed generation.
4. I have an issue with formulating the battery constraints over a time horizon. at the moment my battery is always charging and the state of charge is constant (always taking the minimum value)
5. Attached are the constraint I am trying to formulate,
6. Below is how I formulated the state of charge, charging power and discharging power.
function [SOC_1,SOC_initial01]=stateofcharge1(mg,ce,de,SOC_in,BESS,insert,T,nNodes)
T1=dfsearch(T,mg,'edgetonew'); %returns an ordered cell array of egdes from a microgrid.N-by 2
v1=dfsearch(T,mg);% node ID in terms of their discovery from MG 33x1
fr=T1(:,1); %32x1
to=T1(:,2);%32x1
size(v1); %33x1
%% Battery store equality constraint (SOC)-698:673
disch=zeros(33,33);
char=zeros(33,33);
SOC=zeros(33,33);
for k=size(v1):-1:1
a=v1(k);
disch(insert,a)=(1/de);
char(insert,a)=-1*ce;
SOC(insert,a)=1;
insert=insert+1;
end
z=zeros(nNodes,nNodes);%33x33
z2=zeros(33,4);
cz=zeros(33,33);
SOC_1=[cz z z z z z z z z z z z z z z z z z z z2 disch z char z SOC z];
SOC_initial01=zeros(33,1);
SOC_initial01(7,1)=0*BESS(1);
end
question 1:how can I include the SOC of the previous time step to my current SOC, I am thinking this is the reason why my SOC is always constants?

### Categories

Find more on Energy Storage in Help Center and File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by