Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 44

2022

Advanced Energy Storage Systems Project

SINDHU PILLI
STUDENT ID: 110060987
Name: Sindhu Pilli
Student ID: 110060987

(a)SOC-OCV Data plotting:


The general code for plotting the given data table is shown blow. The x-axis and y-axis are
SOC and OCV of the respective battery (1,2,3 and 4).

clc
clear
load Data. Mat
%Converting the given table into array. This way we convert it into a matrix with 32 rows
and 8 columns.
data= table2array (Data);
Battery1SOC= data (1:32,1);
Battery1OCV= data (1:32,2);
Battery2SOC= data (1:32,3);
Battery2OCV= data (1:32,4);
Battery3SOC= data (1:32,5);
Battery3OCV= data (1:32,6);
Battery4SOC= data(1:32,7);
Name: Sindhu Pilli
Student ID: 110060987

Battery4OCV= data(1:32,8);
%Figure1 (1 to 4)
figure;
subplot(2,2,1);
plot(Battery1SOC,Battery1OCV)
grid on
subplot(2,2,2);
plot(Battery2SOC,Battery2OCV);
grid on
subplot(2,2,3);
plot(Battery3SOC,Battery3OCV);
grid on
subplot(2,2,4);
plot(Battery4SOC,Battery4OCV);
grid on

Graphs :
Name: Sindhu Pilli
Student ID: 110060987

(b) Plot OCV-SOC model (s vs. V◦(s) for all 8 models)

In the following code, the s vs V◦(s) is considered using two ways. Initially, the s values are
scaled for 32 iterations in order to find the ‘k’ values.
Secondly, the scaled s value has been graphed along with the voltage values, for s from 0 to 1
with 1000 steps in between.
Battery Modelling:
Battery modelling is necessary for the efficient development of BMS.The reason for
considering mathematical modelling of a battery is the significance of accuracy they have,
when compared with the equivalent circuit models. These models track the non-linear
relationship between the battery's real-time operation and the discharge rate without
considering the recovery impact [1].
In the current project different models have been discussed. The observations and
measurements have been made using MATLAB algorithm and programming from given
OCV(Open circuit voltage ) and SOC( State of charge) data of four different batteries.
1.Linear Model:
Description:
Code:
E=0.175;
%PlottingvBattery1SOC Vs V1 using 32 values of s-Linear model
%All the even numbered graphs in the subplot belong to (s vs v1][0,1])-Linear model
ScaledSOCb1= ((1-(2*E))*Battery1SOC)+ E;
for i=1:32
b1(i,:)=[1 ScaledSOCb1(i)];
end
k= ((b1'*b1)^(-1))*(b1'*Battery1OCV);
V1=b1*k ;
figure ;
subplot(4,2,1)
plot(Battery1SOC,V1)
%Plotting using s vs v1 belongs to [0,1]-Linear Model
s=0:0.001:1;
s_dash= ((1-(2*E))*s)+ E;
for i=1:1001
b11(i,:)=[1 s_dash(i)];
end
v1=b11*k ;
subplot(4,2,2)
plot(s,v1)
%Plotting using 32 values of s for battery 2-Linear Model
ScaledSOCb2= ((1-(2*E))*Battery2SOC)+ E;
for i=1:32
b2(i,:)=[1 ScaledSOCb2(i)];
end
Name: Sindhu Pilli
Student ID: 110060987

k= ((b2'*b2)^(-1))*(b2'*Battery2OCV);
V2=b2*k ;
subplot(4,2,3)
plot(V2,Battery2SOC)
%Plotting using s vs v2 belongs to [0,1]-Battery 2-Linear model
s=0:0.001:1;
s_dash= ((1-(2*E))*s)+ E;
for i=1:1001
b12(i,:)=[1 s_dash(i)];
end
v2=b12*k ;
subplot(4,2,4)
plot(s,v2)
%Plotting using 32 values of s for battery 3-Linear model
ScaledSOCb3= ((1-(2*E))*Battery3SOC)+ E;
for i=1:32
b3(i,:)=[1 ScaledSOCb3(i)];
end
k= ((b3'*b3)^(-1))*(b3'*Battery3OCV);
V3=b3*k ;
subplot(4,2,5)
plot(V3,Battery3SOC)
%Plotting using s vs v1 belongs to [0,1]-Battery 3-Linear model
s=0:0.001:1;
s_dash= ((1-(2*E))*s)+ E;
for i=1:1001
b13(i,:)=[1 s_dash(i)];
end
v3=b13*k ;
subplot(4,2,6)
plot(s,v3)
%Plotting using 32 values of s for battery 4-Linear model
ScaledSOCb4= ((1-(2*E))*Battery4SOC)+ E;
for i=1:32
b4(i,:)=[1 ScaledSOCb4(i)];
end
k= ((b4'*b4)^(-1))*(b4'*Battery4OCV);
V4=b4*k ;
subplot(4,2,7)
plot(V4,Battery4SOC)
%Plotting using s vs v1 belongs to [0,1]-Battery 4-Linear model
s=0:0.001:1;
s_dash= ((1-(2*E))*s)+ E;
for i=1:1001
b14(i,:)=[1 s_dash(i)];
end
v4=b14*k ;
subplot(4,2,8)
plot(s,v4)
Name: Sindhu Pilli
Student ID: 110060987

%Fig 3( Subplots 4)
%Calculation of Vbar of Battery1-Linear model
N=32;
M=length(k);
Vbarb1_linear=sum(V1)/N;
%Calculation of BF
BFb1_linear=(1-(norm(V1-Battery1OCV)/norm(Battery1OCV-Vbarb1_linear)))*100;
%Calculation of R^2
R2b1_linear=(1-(((norm(V1-Battery1OCV))^2/((norm(Battery1OCV-
Vbarb1_linear))^2))))*100;
%Calculation of ME
MEb1_linear=max(abs(Battery1OCV-V1));
%Calculation of RMS
RMSb1_linear=norm(Battery1OCV-V1)/sqrt(N-M);
errorb1_linear=abs(Battery1OCV-V1);
%Calculation of AIC
S2b1_linear=sum(errorb1_linear.^2);
AICb1_linear=(N*(log(S2b1_linear/N)))+(2*(M+1));
figure ;
subplot(2,2,1)
plot(Battery1SOC,errorb1_linear)

%Calculation of Vbar for Battery 2-Linear model


N=32;
M=length(k);
Vbarb2_linear=sum(V2)/N;
%Calculation of BF
BFb2_linear=(1-(norm(V2-Battery2OCV)/norm(Battery2OCV-Vbarb2_linear)))*100;
%Calculation of R^2
R2b2_linear=(1-(((norm(V2-Battery2OCV))^2/((norm(Battery2OCV-
Vbarb2_linear))^2))))*100;
%Calculation of ME
MEb2_linear=max(abs(Battery2OCV-V2));
%Calculation of RMS
RMSb2_linear=norm(Battery2OCV-V2)/sqrt(N-M);
errorb2_linear=abs(Battery2OCV-V2);
%Calculation of AIC
S2b2_linear=sum(errorb2_linear.^2);
AICb2_linear=(N*(log(S2b2_linear/N)))+(2*(M+1));
subplot(2,2,2)
plot(Battery2SOC,errorb2_linear)

%Calculation of Vbar for Battery 3-Linear model


N=32;
M=length(k);
Vbarb3_linear=sum(V3)/N;
%Calculation of BF
BFb3_linear=(1-(norm(V3-Battery3OCV)/norm(Battery3OCV-Vbarb3_linear)))*100;
%Calculation of R^2
Name: Sindhu Pilli
Student ID: 110060987

R2b3_linear=(1-(((norm(V3-Battery3OCV))^2/((norm(Battery3OCV-
Vbarb3_linear))^2))))*100;
%Calculation of ME
MEb3_linear=max(abs(Battery3OCV-V3));
%Calculation of RMS
RMSb3_linear=norm(Battery3OCV-V3)/sqrt(N-M);
errorb3_linear=abs(Battery3OCV-V3);
%Calculation of AIC
S3b3_linear=sum(errorb3_linear.^2);
AICb3_linear=(N*(log(S3b3_linear/N)))+(2*(M+1));
subplot(2,2,3)
plot(Battery3SOC,errorb3_linear)

%Calculation of Vbar for Battery 4-Linear model

N=32;
M=length(k);
Vbarb4_linear=sum(V4)/N;
%Calculation of BF
BFb4_linear=(1-(norm(V4-Battery4OCV)/norm(Battery4OCV-Vbarb4_linear)))*100;
%Calculation of R^2
R2b4_linear=(1-(((norm(V4-Battery4OCV))^2/((norm(Battery4OCV-
Vbarb4_linear))^2))))*100;
%Calculation of ME
MEb4_linear=max(abs(Battery4OCV-V4));
%Calculation of RMS
RMSb4_linear=norm(Battery4OCV-V4)/sqrt(N-M);
errorb4_linear=abs(Battery4OCV-V4);
%Calculation of AIC
S4b4_linear=sum(errorb4_linear.^2);
AICb4_linear=(N*(log(S4b4_linear/N)))+(2*(M+1));
subplot(2,2,4)
plot(Battery4SOC,errorb4_linear)

Error Graphs:
Name: Sindhu Pilli
Student ID: 110060987

Graphs:
Name: Sindhu Pilli
Student ID: 110060987

Conclusion:

2.Shepherd Model:
Description:
Code:
%Plotting BatterySOC vs V1 for 32 values -Shepherd model
E=0.175;
%Plotting for 32 values i, Battery1Soc vs V1-Shepherd model
ScaledSOCb1= ((1-(2*E))*Battery1SOC)+ E;
for i=1:32
b1(i,:)=[1 1/ScaledSOCb1(i)];
end
k= ((b1'*b1)^(-1))*(b1'*Battery1OCV);
V1=b1*k ;
figure ;
subplot(4,2,1)
plot(Battery1SOC,V1)
%Plotting using s vs v1 belongs to [0,1]-Battery 1-Shepherd model
s=0:0.001:1;
s_dash= ((1-(2*E))*s)+ E;
for i=1:1001
b13(i,:)=[1 1/s_dash(i)];
end
v1=b13*k ;
subplot(4,2,2)
plot(s,v1)
%Plotting 32 values of i, Battery2SOC vs V1-Shepherd model
ScaledSOCb2= ((1-(2*E))*Battery2SOC)+ E;
for i=1:32
b2(i,:)=[1 1/ScaledSOCb2(i)];
end
k= ((b2'*b2)^(-1))*(b2'*Battery2OCV);
V2=b2*k ;
subplot(4,2,3)
plot(Battery1SOC,V2)
%Plotting using s vs v2 belongs to [0,1]-Battery 2-Shepherd model
s=0:0.001:1;
s_dash= ((1-(2*E))*s)+ E;
for i=1:1001
b12(i,:)=[1 1/s_dash(i)];
end
v2=b12*k ;
subplot(4,2,4)
Name: Sindhu Pilli
Student ID: 110060987

plot(s,v2)
%Plotting 32 values Battery3SOC vs V3
ScaledSOCb3= ((1-(2*E))*Battery3SOC)+ E;
for i=1:32
b3(i,:)=[1 1/ScaledSOCb3(i)];
end
k= ((b3'*b3)^(-1))*(b3'*Battery3OCV);
V3=b3*k ;
subplot(4,2,5)
plot(Battery3SOC,V3)
%Plotting using s vs v3 belongs to [0,1]-Battery 3-Shepherd model
s=0:0.001:1;
s_dash= ((1-(2*E))*s)+ E;
for i=1:1001
b13(i,:)=[1 1/s_dash(i)];
end
v3=b13*k ;
subplot(4,2,6)
plot(s,v3)
%Plotting 32 values Battery4SOC Vs V4
ScaledSOCb4= ((1-(2*E))*Battery4SOC)+ E;
for i=1:32
b4(i,:)=[1 1/ScaledSOCb4(i)];
end
k= ((b4'*b4)^(-1))*(b4'*Battery4OCV);
V4=b4*k ;
subplot(4,2,7)
plot(Battery4SOC,V4)
%Plotting using s vs v4 where s(0,1) Battery4-Shepherd model
s=0:0.001:1;
s_dash= ((1-(2*E))*s)+ E;
for i=1:1001
b14(i,:)=[1 1/s_dash(i)];
end
v4=b14*k ;
subplot(4,2,8)
plot(s,v4)

Code for calculating errors:

%Fig 5( subplots 4)
%Calculation of Vbar of Battery1 Shepherd model
N=32;
M=length(k);
Vbarb1_nernst=sum(V1)/N;
%Calculation of BF
BFb1_shepherd=(1-(norm(V1-Battery1OCV)/norm(Battery1OCV-Vbarb1_nernst)))*100;
%Calculation of R^2
R2b1_shepherd=(1-(((norm(V1-Battery1OCV))^2/((norm(Battery1OCV-
Vbarb1_nernst))^2))))*100;
Name: Sindhu Pilli
Student ID: 110060987

%Calculation of ME
MEb1_shepherd=max(abs(Battery1OCV-V1));
%Calculation of RMS
RMSb1_shepherd=norm(Battery1OCV-V1)/sqrt(N-M);
errorb1_shepherd=abs(Battery1OCV-V1);
%Calculation of AIC
S2b1_shepherd=sum(errorb1_shepherd.^2);
AICb1_shepherd=(N*(log(S2b1_shepherd/N)))+(2*(M+1));
figure;
subplot(2,2,1)
plot(Battery1SOC,errorb1_shepherd)

%Calculation of Vbar for Battery 2 Shepherd model


N=32;
M=length(k);
Vbarb2_shepherd=sum(V2)/N;
%Calculation of BF
BFb2_shepherd=(1-(norm(V2-Battery2OCV)/norm(Battery2OCV-Vbarb2_shepherd)))*100;
%Calculation of R^2
R2b2_shepherd=(1-(((norm(V2-Battery2OCV))^2/((norm(Battery2OCV-
Vbarb2_shepherd))^2))))*100;
%Calculation of ME
MEb2_shepherd=max(abs(Battery2OCV-V2));
%Calculation of RMS
RMSb2_shepherd=norm(Battery2OCV-V2)/sqrt(N-M);
errorb2_shepherd=abs(Battery2OCV-V2);
%Calculation of AIC
S2b2_shepherd=sum(errorb2_shepherd.^2);
AICb2_shepherd=(N*(log(S2b2_shepherd/N)))+(2*(M+1));
subplot(2,2,2)
plot(Battery2SOC,errorb2_shepherd)

%Calculation of Vbar for Battery 3 Shepherd model


N=32;
M=length(k);
Vbarb3_shepherd=sum(V3)/N;
%Calculation of BF
BFb3_shepherd=(1-(norm(V3-Battery3OCV)/norm(Battery3OCV-Vbarb3_shepherd)))*100;
%Calculation of R^2
R2b3_shepherd=(1-(((norm(V3-Battery3OCV))^2/((norm(Battery3OCV-
Vbarb3_shepherd))^2))))*100;
%Calculation of ME
MEb3_shepherd=max(abs(Battery3OCV-V3));
%Calculation of RMS
RMSb3_shepherd=norm(Battery3OCV-V3)/sqrt(N-M);
errorb3_shepherd=abs(Battery2OCV-V3);
%Calculation of AIC
S2b3_shepherd=sum(errorb3_shepherd.^2);
AICb3_shepherd=(N*(log(S2b3_shepherd/N)))+(2*(M+1));
subplot(2,2,3)
Name: Sindhu Pilli
Student ID: 110060987

plot(Battery3SOC,errorb3_shepherd)

%Calculation of Vbar for Battery 4 Shepherd model


N=32;
M=length(k);
Vbarb1_nernst=sum(V4)/N;
%Calculation of BF
BFb4_shepherd=(1-(norm(V4-Battery4OCV)/norm(Battery4OCV-Vbarb1_nernst)))*100;
%Calculation of R^2
R2b4_shepherd=(1-(((norm(V4-Battery4OCV))^2/((norm(Battery4OCV-
Vbarb1_nernst))^2))))*100;
%Calculation of ME
MEb4_shepherd=max(abs(Battery4OCV-V4));
%Calculation of RMS
RMSb4_shepherd=norm(Battery4OCV-V4)/sqrt(N-M);
errorb4_shepherd=abs(Battery4OCV-V4);
%Calculation of AIC
S2b4_shepherd=sum(errorb4_shepherd.^2);
AICb4_shepherd=(N*(log(S2b4_shepherd/N)))+(2*(M+1));
subplot(2,2,4)
plot(Battery4SOC,errorb4_shepherd)

Graphs:
Name: Sindhu Pilli
Student ID: 110060987

Error graph:
Name: Sindhu Pilli
Student ID: 110060987

3.Nernst Model:
Description:
Code:
E=0.175;
%Plotting BatterySOC vs V -BATTERY 1( using i=32 values)-Nernst Model
ScaledSOCb1= ((1-(2*E))*Battery1SOC)+ E;
b1=zeros(32,3);
for i=1:32
b1(i,:)=[1 log(ScaledSOCb1(i)) log(1-(ScaledSOCb1(i)))];
end
k= ((b1'*b1)^(-1))*(b1'*Battery1OCV);
V1=b1*k ;
figure;
subplot(4,2,1)
plot(Battery1SOC,V1)
%Plotting using s vs v1 belongs to [0,1]-Battery 1-Nernst model
s=0:0.001:1;
s_dash= ((1-(2*E))*s)+ E;
b11=zeros(32,3);
for i=1:1001
b11(i,:)=[1 log(s_dash(i)) log(1-(s_dash(i)))];
end
v1=b11*k ;
subplot(4,2,2)
plot(s,v1)
%Plotting Battery2SOC vs V2 -Nernst model with 32 values of i
ScaledSOCb2= ((1-(2*E))*Battery2SOC)+ E;
b2=zeros(32,3);
for i=1:32
b2(i,:)=[1 log(ScaledSOCb2(i)) log(1-(ScaledSOCb2(i)))];
end
k= ((b2'*b2)^(-1))*(b2'*Battery2OCV);
V2=b2*k ;
subplot(4,2,3)
plot(Battery2SOC,V2)
%Plotting using s vs v2 belongs to [0,1]-Battery 1-Nernst model
s=0:0.001:1;
s_dash= ((1-(2*E))*s)+ E;
b12=zeros(32,3);
for i=1:1001
b12(i,:)=[1 log(s_dash(i)) log(1-(s_dash(i)))];
end
v2=b12*k ;
subplot(4,2,4)
plot(s,v2)
%Plotting Battery3SOC vs V3 -Nernst model with 32 values of i
ScaledSOCb3= ((1-(2*E))*Battery3SOC)+ E;
b3=zeros(32,3);
Name: Sindhu Pilli
Student ID: 110060987

for i=1:32
b3(i,:)=[1 log(ScaledSOCb3(i)) log(1-(ScaledSOCb3(i)))];
end
k= ((b3'*b3)^(-1))*(b3'*Battery3OCV);
V3=b3*k ;
subplot(4,2,5)
plot(Battery3SOC,V3)
%Plotting using s vs v3 belongs to [0,1]-Battery 1-Nernst model
s=0:0.001:1;
s_dash= ((1-(2*E))*s)+ E;
b13=zeros(32,3);
for i=1:1001
b13(i,:)=[1 log(s_dash(i)) log(1-(s_dash(i)))];
end
v3=b13*k ;
subplot(4,2,6)
plot(s,v3)
%Plotting Battery4SOC vs V4 -Nernst model with 32 values of i
ScaledSOCb4= ((1-(2*E))*Battery4SOC)+ E;
b4=zeros(32,3);
for i=1:32
b4(i,:)=[1 log(ScaledSOCb4(i)) log(1-(ScaledSOCb4(i)))];
end
k= ((b4'*b4)^(-1))*(b4'*Battery4OCV);
V4=b4*k ;
subplot(4,2,7)
plot(Battery4SOC,V4)
%Plotting using s vs v4 belongs to [0,1]-Battery 1-Nernst model
s=0:0.001:1;
s_dash= ((1-(2*E))*s)+ E;
b14=zeros(32,3);
for i=1:1001
b14(i,:)=[1 log(s_dash(i)) log(1-(s_dash(i)))];
end
v4=b14*k ;
subplot(4,2,8)
plot(s,v4)
Code for calculating errors:

%Fig 7( subplots 4)
%Calculation of Vbar of Battery1
N=32;
M=length(k);
Vbarb1_nernst=sum(V1)/N;
%Calculation of BF
BFb1_nernst=(1-(norm(V1-Battery1OCV)/norm(Battery1OCV-Vbarb1_nernst)))*100;
%Calculation of R^2
Name: Sindhu Pilli
Student ID: 110060987

R2b1_nernst=(1-(((norm(V1-Battery1OCV))^2/((norm(Battery1OCV-
Vbarb1_nernst))^2))))*100;
%Calculation of ME
MEb1_nernst=max(abs(Battery1OCV-V1));
%Calculation of RMS
RMSb1_nernst=norm(Battery1OCV-V1)/sqrt(N-M);
errorb1_nernst=abs(Battery1OCV-V1);
%Calculation of AIC
S2b1_nernst=sum(errorb1_nernst.^2);
AICb1_nernst=(N*(log(S2b1_nernst/N)))+(2*(M+1));
subplot(2,2,1)
plot(Battery1SOC,errorb1_nernst)

%Calculation of Vbar for Battery 2


N=32;
M=length(k);
Vbarb2_nernst=sum(V2)/N;
%Calculation of BF
BFb2_nernst=(1-(norm(V2-Battery2OCV)/norm(Battery2OCV-Vbarb2_nernst)))*100;
%Calculation of R^2
R2b2_nernst=(1-(((norm(V2-Battery2OCV))^2/((norm(Battery2OCV-
Vbarb2_nernst))^2))))*100;
%Calculation of ME
MEb2_nernst=max(abs(Battery2OCV-V2));
%Calculation of RMS
RMSb2_nernst=norm(Battery2OCV-V2)/sqrt(N-M);
errorb2_nernst=abs(Battery2OCV-V2);
%Calculation of AIC
S2b2_nernst=sum(errorb2_nernst.^2);
AICb2_nernst=(N*(log(S2b2_nernst/N)))+(2*(M+1));
subplot(2,2,2)
plot(Battery2SOC,errorb2_nernst)

%Calculation of Vbar for Battery 3


N=32;
M=length(k);
Vbarb3_nernst=sum(V3)/N;
%Calculation of BF
BFb3_nernst=(1-(norm(V3-Battery3OCV)/norm(Battery3OCV-Vbarb3_nernst)))*100;
%Calculation of R^2
R2b3_nernst=(1-(((norm(V3-Battery3OCV))^2/((norm(Battery3OCV-
Vbarb3_nernst))^2))))*100;
%Calculation of ME
MEb3_nernst=max(abs(Battery3OCV-V3));
%Calculation of RMS
RMSb3_nernst=norm(Battery3OCV-V3)/sqrt(N-M);
errorb3_nernst=abs(Battery3OCV-V3);
%Calculation of AIC
S2b3_nernst=sum(errorb3_nernst.^2);
Name: Sindhu Pilli
Student ID: 110060987

AICb3_nernst=(N*(log(S2b3_nernst/N)))+(2*(M+1));
subplot(2,2,3)
plot(Battery3SOC,errorb3_nernst)

%Calculation of Vbar for Battery 4


N=32;
M=length(k);
Vbarb4_nernst=sum(V4)/N;
%Calculation of BF
BFb4_nernst=(1-(norm(V4-Battery4OCV)/norm(Battery4OCV-Vbarb4_nernst)))*100;
%Calculation of R^2
R2b4_nernst=(1-(((norm(V4-Battery4OCV))^2/((norm(Battery4OCV-
Vbarb4_nernst))^2))))*100;
%Calculation of ME
MEb4_nernst=max(abs(Battery4OCV-V4));
%Calculation of RMS
RMSb4_nernst=norm(Battery4OCV-V4)/sqrt(N-M);
errorb4_nernst=abs(Battery4OCV-V4);
%Calculation of AIC
S2b4_nernst=sum(errorb4_nernst.^2);
AICb4_nernst=(N*(log(S2b4_nernst/N)))+(2*(M+1));
subplot(2,2,4)
plot(Battery4SOC,errorb4_nernst)

Graphs:
Name: Sindhu Pilli
Student ID: 110060987

Error graphs:
Name: Sindhu Pilli
Student ID: 110060987

4.Combined model:
Description:
Code:
%Plotting Battery1SOC Vs V1 using 32 values of s for Combined model(Battery 1)

E=0.175;
ScaledSOCb1= ((1-(2*E))*Battery1SOC)+ E;
b1=zeros(32,5);

for i=1:32
b1(i,:)=[1 1/(ScaledSOCb1(i)) ScaledSOCb1(i) log(ScaledSOCb1(i)) log(1-
ScaledSOCb1(i))];
end

k= ((b1'*b1)^(-1))*(b1'*Battery1OCV);
V1=b1*k ;
figure;
subplot(2,2,1)
plot(Battery1SOC,V1)

% Plotting s vs v1 belongs where s belongs to [0,1] for Combined Model (Battery1)

s=0:0.001:1;
s_dash= ((1-(2*E))*s)+ E;
b11=zeros(32,5);

for i=1:1001
b11(i,:)=[1 1/(s_dash(i)) s_dash(i) log(s_dash(i)) log(1-s_dash(i))];
end

v1=b11*k ;
subplot(4,2,6)
plot(s,v1)

%Plotting Battery1SOC Vs V1 using 32 values of s for Combined model(Battery 1)

ScaledSOCb2= ((1-(2*E))*Battery2SOC)+ E;
b2=zeros(32,5);

for i=1:32
b2(i,:)=[1 1/(ScaledSOCb2(i)) (ScaledSOCb2(i)) log(ScaledSOCb2(i)) log(1-
ScaledSOCb2(i))];
end

k= ((b2'*b2)^(-1))*(b2'*Battery2OCV);
Name: Sindhu Pilli
Student ID: 110060987

V2=b2*k ;
subplot(2,2,2)
plot(Battery2SOC,V2)

% Plotting s vs v2 belongs where s belongs to [0,1] for Combined Model (Battery2)

s=0:0.001:1;
s_dash= ((1-(2*E))*s)+ E;
b12=zeros(32,5);

for i=1:1001
b12(i,:)=[1 1/(s_dash(i)) s_dash(i) log(s_dash(i)) log(1-s_dash(i))];
end

v2=b12*k ;
subplot(4,2,6)
plot(s,v2)

%Plotting Battery3SOC Vs V3 using 32 values of s for Combined model(Battery 3)

ScaledSOCb3= ((1-(2*E))*Battery3SOC)+ E;
b3=zeros(32,5);

for i=1:32
b3(i,:)=[1 1/(ScaledSOCb3(i)) (ScaledSOCb3(i)) log(ScaledSOCb3(i)) log(1-
(ScaledSOCb3(i)))];
end

k= ((b3'*b3)^(-1))*(b3'*Battery3OCV);
V3=b3*k ;
subplot(2,2,3)
plot(Battery3SOC,V3)

% Plotting s vs v3 belongs where s belongs to [0,1] for Combined Model (Battery3)

s=0:0.001:1;
s_dash= ((1-(2*E))*s)+ E;
b13=zeros(32,5);

for i=1:1001
b13(i,:)=[1 1/(s_dash(i)) s_dash(i) log(s_dash(i)) log(1-s_dash(i))];
end

v3=b13*k ;
subplot(4,2,6)
plot(s,v3)

%Plotting Battery4SOC Vs V4 using 32 values of s for Combined model(Battery 4)


Name: Sindhu Pilli
Student ID: 110060987

ScaledSOCb4= ((1-(2*E))*Battery4SOC)+ E;
b4=zeros(32,5);

for i=1:32
b4(i,:)=[1 1/(ScaledSOCb4(i)) (ScaledSOCb4(i)) log(ScaledSOCb4(i)) log(1-
(ScaledSOCb4(i)))];
end

k= ((b4'*b4)^(-1))*(b4'*Battery4OCV);
V4=b4*k ;
subplot(2,2,4)
plot(Battery4SOC,V4)

% Plotting s vs v4 belongs where s belongs to [0,1] for Combined Model (Battery4)

s=0:0.001:1;
s_dash= ((1-(2*E))*s)+ E;
b14=zeros(32,5);

for i=1:1001
b14(i,:)=[1 1/(s_dash(i)) s_dash(i) log(s_dash(i)) log(1-s_dash(i))];
end

v4=b14*k ;
subplot(4,2,6)
plot(s,v4)

Code for calculating errors:

N=32;
M=length(k);
Vbarb1_Combinedmodel=sum(V1)/N;
%Calculation of BF
BFb1_Combinedmodel=(1-(norm(V1-Battery1OCV)/norm(Battery1OCV-
Vbarb1_Combinedmodel)))*100;
%Calculation of R^2
R2b1_Combinedmodel=(1-(((norm(V1-Battery1OCV))^2/((norm(Battery1OCV-
Vbarb1_Combinedmodel))^2))))*100;
%Calculation of ME
MEb1_Combinedmodel=max(abs(Battery1OCV-V1));
%Calculation of RMS
RMSb1_Combinedmodel=norm(Battery1OCV-V1)/sqrt(N-M);
errorb1_polynomial=abs(Battery1OCV-V1);
%Calculation of AIC
S2b1_Combinedmodel=sum(errorb1_polynomial.^2);
AICb1_Combinedmodel=(N*(log(S2b1_Combinedmodel/N)))+(2*(M+1));
figure;
subplot(2,2,1)
plot(Battery1SOC,errorb1_polynomial)
Name: Sindhu Pilli
Student ID: 110060987

%Calculation of Vbar for Battery 2 Combined model


N=32;
M=length(k);
Vbarb2_Combinedmodel=sum(V2)/N;
%Calculation of BF
BFb2_Combinedmodel=(1-(norm(V2-Battery2OCV)/norm(Battery2OCV-
Vbarb2_Combinedmodel)))*100;
%Calculation of R^2
R2b2_Combinedmodel=(1-(((norm(V2-Battery2OCV))^2/((norm(Battery2OCV-
Vbarb2_Combinedmodel))^2))))*100;
%Calculation of ME
MEb2_Combinedmodel=max(abs(Battery2OCV-V2));
%Calculation of RMS
RMSb2_Combinedmodel=norm(Battery2OCV-V2)/sqrt(N-M);
errorb2_Combinedmodel=abs(Battery2OCV-V2);
%Calculation of AIC
S2b2_Combinedmodel=sum(errorb2_Combinedmodel.^2);
AICb2_Combinedmodel=(N*(log(S2b2_Combinedmodel/N)))+(2*(M+1));
subplot(2,2,2)
plot(Battery2SOC,errorb2_Combinedmodel)

%Calculation of Vbar for Battery 3 Combined model


N=32;
M=length(k);
Vbarb3_Combinedmodel=sum(V3)/N;
%Calculation of BF
BFb3_Combinedmodel=(1-(norm(V3-Battery3OCV)/norm(Battery3OCV-
Vbarb3_Combinedmodel)))*100;
%Calculation of R^2
R2b3_Combinedmodel=(1-(((norm(V3-Battery3OCV))^2/((norm(Battery3OCV-
Vbarb3_Combinedmodel))^2))))*100;
%Calculation of ME
MEb3_Combinedmodel=max(abs(Battery3OCV-V3));
%Calculation of RMS
RMSb3_Combinedmodel=norm(Battery3OCV-V3)/sqrt(N-M);
errorb3_Combinedmodel=abs(Battery3OCV-V3);
%Calculation of AIC
S2b3_Combinedmodel=sum(errorb3_Combinedmodel.^2);
AICb3_Combinedmodel=(N*(log(S2b3_Combinedmodel/N)))+(2*(M+1));
subplot(2,2,3)
plot(Battery3SOC,errorb3_Combinedmodel)

%Calculation of Vbar for Battery 4 Combined model


N=32;
M=length(k);
Vbarb4_Combinedmodel=sum(V4)/N;
%Calculation of BF
BFb4_Combinedmodel=(1-(norm(V4-Battery4OCV)/norm(Battery4OCV-
Vbarb4_Combinedmodel)))*100;
Name: Sindhu Pilli
Student ID: 110060987

%Calculation of R^2
R2b4_Combinedmodel=(1-(((norm(V4-Battery4OCV))^2/((norm(Battery4OCV-
Vbarb4_Combinedmodel))^2))))*100;
%Calculation of ME
MEb4_Combinedmodel=max(abs(Battery4OCV-V4));
%Calculation of RMS
RMSb4_Combinedmodel=norm(Battery4OCV-V4)/sqrt(N-M);
errorb4_Combinedmodel=abs(Battery4OCV-V4);
%Calculation of AIC
S2b4_Combinedmodel=sum(errorb4_Combinedmodel.^2);
AICb4_Combinedmodel=(N*(log(S2b4_Combinedmodel/N)))+(2*(M+1));
subplot(2,2,4)
plot(Battery4SOC,errorb4_Combinedmodel)

Error graphs:

Graphs:
Name: Sindhu Pilli
Student ID: 110060987

5.Combinedplus3 Model:
Description:
Code for s vs V(s):
E=0.175;
% Plotting Battery1SOC vs V1-Combined+3 model
ScaledSOCb1= ((1-(2*E))*Battery1SOC)+ E;
b1=zeros(32,8);
for i=1:32
b1(i,:)=[1 1/(ScaledSOCb1(i)) ScaledSOCb1(i) 1/((ScaledSOCb1(i))^2)
1/((ScaledSOCb1(i))^3) 1/((ScaledSOCb1(i))^4) log(ScaledSOCb1(i)) log(1-
ScaledSOCb1(i)) ];
end
k= ((b1'*b1)^(-1))*(b1'*Battery1OCV);
V1=b1*k ;
figure;
subplot(4,2,1)
plot(Battery1SOC,V1)

%Plotting using s vs v1 belongs to [0,1]-Battery 1-Combined model


s=0:0.001:1;
s_dash= ((1-(2*E))*s)+ E;
b11=zeros(32,8);
Name: Sindhu Pilli
Student ID: 110060987

for i=1:1001
b11(i,:)=[1 1/(s_dash(i)) s_dash(i) 1/((s_dash(i))^2) 1/((s_dash(i))^3) 1/((s_dash(i))^4)
log(s_dash(i)) log(1-s_dash(i)) ];
end
v1=b11*k ;
subplot(4,2,2)
plot(s,v1)

% Plotting Battery2SOC vs V2-Combined+3 model


ScaledSOCb2= ((1-(2*E))*Battery2SOC)+ E;
b2=zeros(32,8);
for i=1:32
b2(i,:)=[1 1/(ScaledSOCb2(i)) ScaledSOCb2(i) 1/((ScaledSOCb2(i))^2)
1/((ScaledSOCb2(i))^3) 1/((ScaledSOCb2(i))^4) log(ScaledSOCb2(i)) log(1-
ScaledSOCb2(i)) ];
end
k= ((b2'*b2)^(-1))*(b2'*Battery2OCV);
V2=b2*k ;
subplot(4,2,3)
plot(Battery2SOC,V2)

%Plotting using s vs v2 belongs to [0,1]-Battery 2-Combined model


s=0:0.001:1;
s_dash= ((1-(2*E))*s)+ E;
b12=zeros(32,8);
for i=1:1001
b12(i,:)=[1 1/(s_dash(i)) s_dash(i) 1/((s_dash(i))^2) 1/((s_dash(i))^3) 1/((s_dash(i))^4)
log(s_dash(i)) log(1-s_dash(i)) ];
end
v2=b12*k ;
subplot(4,2,4)
plot(s,v2)

% Plotting Battery3SOC vs V3-Combined+3 model


ScaledSOCb3= ((1-(2*E))*Battery3SOC)+ E;
b3=zeros(32,8);
for i=1:32
b3(i,:)=[1 1/(ScaledSOCb3(i)) ScaledSOCb3(i) 1/((ScaledSOCb3(i))^2)
1/((ScaledSOCb3(i))^3) 1/((ScaledSOCb3(i))^4) log(ScaledSOCb3(i)) log(1-
ScaledSOCb3(i)) ];
end
k= ((b3'*b3)^(-1))*(b3'*Battery3OCV);
V3=b3*k ;
subplot(4,2,5)
plot(Battery3SOC,V3)
%Plotting using s vs v3 belongs to [0,1]-Battery 2-Combined model
s=0:0.001:1;
s_dash= ((1-(2*E))*s)+ E;
b13=zeros(32,8);
for i=1:1001
Name: Sindhu Pilli
Student ID: 110060987

b13(i,:)=[1 1/(s_dash(i)) s_dash(i) 1/((s_dash(i))^2) 1/((s_dash(i))^3) 1/((s_dash(i))^4)


log(s_dash(i)) log(1-s_dash(i)) ];
end
v3=b13*k ;
subplot(4,2,6)
plot(s,v3)

% Plotting Battery4SOC vs V4-Combined+3 model


ScaledSOCb4= ((1-(2*E))*Battery4SOC)+ E;
b4=zeros(32,8);
for i=1:32
b4(i,:)=[1 1/(ScaledSOCb4(i)) ScaledSOCb4(i) 1/((ScaledSOCb4(i))^2)
1/((ScaledSOCb4(i))^3) 1/((ScaledSOCb4(i))^4) log(ScaledSOCb4(i)) log(1-
ScaledSOCb4(i)) ];
end
k= ((b4'*b4)^(-1))*(b4'*Battery4OCV);
V4=b4*k ;
subplot(4,2,7)
plot(Battery4SOC,V4)
%Plotting using s vs v4 belongs to [0,1]-Battery 2-Combined model
s=0:0.001:1;
s_dash= ((1-(2*E))*s)+ E;
b14=zeros(32,8);
for i=1:1001
b14(i,:)=[1 1/(s_dash(i)) s_dash(i) 1/((s_dash(i))^2) 1/((s_dash(i))^3) 1/((s_dash(i))^4)
log(s_dash(i)) log(1-s_dash(i)) ];
end
v4=b14*k ;
subplot(4,2,8)
plot(s,v4)

%Fig 11( 4 subplots)


%Calculation of Vbar of Battery1
N=32;
M=length(k);
Vbarb1_Combinedmodel3=sum(V1)/N;
%Calculation of BF
BFb1_Combinedmodel3=(1-(norm(V1-Battery1OCV)/norm(Battery1OCV-
Vbarb1_Combinedmodel3)))*100;
%Calculation of R^2
R2b1_Combinedmodel3=(1-(((norm(V1-Battery1OCV))^2/((norm(Battery1OCV-
Vbarb1_Combinedmodel3))^2))))*100;
%Calculation of ME
MEb1_Combinedmodel3=max(abs(Battery1OCV-V1));
%Calculation of RMS
RMSb1_Combinedmodel3=norm(Battery1OCV-V1)/sqrt(N-M);
errorb1_Combinedmodel3=abs(Battery1OCV-V1);
%Calculation of AIC
S2b1_Combinedmodel3=sum(errorb1_Combinedmodel3.^2);
AICb1_Combinedmodel3=(N*(log(S2b1_Combinedmodel/N)))+(2*(M+1));
Name: Sindhu Pilli
Student ID: 110060987

figure;
subplot(2,2,1)
plot(Battery1SOC,errorb1_Combinedmodel3)

Code for calculating errors:

%Calculation of Vbar for Battery 2


N=32;
M=length(k);
Vbarb2_Combinedmodel3=sum(V2)/N;
%Calculation of BF
BFb2_Combinedmodel3=(1-(norm(V2-Battery2OCV)/norm(Battery2OCV-
Vbarb2_Combinedmodel3)))*100;
%Calculation of R^2
R2b2_Combinedmodel3=(1-(((norm(V2-Battery2OCV))^2/((norm(Battery2OCV-
Vbarb2_Combinedmodel3))^2))))*100;
%Calculation of ME
MEb2_Combinedmodel3=max(abs(Battery2OCV-V2));
%Calculation of RMS
RMSb2_Combinedmodel3=norm(Battery2OCV-V2)/sqrt(N-M);
errorb2_Combinedmodel3=abs(Battery2OCV-V2);
%Calculation of AIC
S2b2_Combinedmodel3=sum(errorb2_Combinedmodel3.^2);
AICb2_Combinedmodel3=(N*(log(S2b2_Combinedmodel/N)))+(2*(M+1));
subplot(2,2,2)
plot(Battery2SOC,errorb2_Combinedmodel3)

%Calculation of Vbar for Battery 3


N=32;
M=length(k);
Vbarb3_Combinedmodel3=sum(V3)/N;
%Calculation of BF
BFb3_Combinedmodel3=(1-(norm(V3-Battery3OCV)/norm(Battery3OCV-
Vbarb3_Combinedmodel3)))*100;
%Calculation of R^2
R2b3_Combinedmodel3=(1-(((norm(V3-Battery3OCV))^2/((norm(Battery3OCV-
Vbarb3_Combinedmodel3))^2))))*100;
%Calculation of ME
MEb3_Combinedmodel3=max(abs(Battery3OCV-V3));
%Calculation of RMS
RMSb3_Combinedmodel3=norm(Battery3OCV-V3)/sqrt(N-M);
errorb3_Combinedmodel3=abs(Battery3OCV-V3);
%Calculation of AIC
S2b3_Combinedmodel3=sum(errorb3_Combinedmodel3.^2);
AICb3_Combinedmodel3=(N*(log(S2b3_Combinedmodel/N)))+(2*(M+1));
subplot(2,2,3)
plot(Battery3SOC,errorb3_Combinedmodel3)

%Calculation of Vbar for Battery 4


N=32;
Name: Sindhu Pilli
Student ID: 110060987

M=length(k);
Vbarb4_Combinedmodel3=sum(V4)/N;
%Calculation of BF
BFb4_Combinedmodel3=(1-(norm(V4-Battery3OCV)/norm(Battery4OCV-
Vbarb4_Combinedmodel3)))*100;
%Calculation of R^2
R2b4_Combinedmodel3=(1-(((norm(V4-Battery3OCV))^2/((norm(Battery4OCV-
Vbarb4_Combinedmodel3))^2))))*100;
%Calculation of ME
MEb4_Combinedmodel3=max(abs(Battery4OCV-V4));
%Calculation of RMS
RMSb4_Combinedmodel3=norm(Battery4OCV-V4)/sqrt(N-M);
errorb4_Combinedmodel3=abs(Battery4OCV-V4);
%Calculation of AIC
S2b4_Combinedmodel3=sum(errorb4_Combinedmodel3.^2);
AICb4_Combinedmodel3=(N*(log(S2b4_Combinedmodel/N)))+(2*(M+1));
subplot(2,2,4)
plot(Battery4SOC,errorb4_Combinedmodel3)

Graphs:
Name: Sindhu Pilli
Student ID: 110060987

Error graphs:

6.Polynomial
Code for s vs V(s)
E=0.175;m=3;n=2;
%Plotting battery1soc vs V1 using 32 iterations Polynomial model
ScaledSOCb1= ((1-(2*E))*Battery1SOC)+ E;
b1=zeros(32,6);
for i=1:32
b1(i,:)=[1 (ScaledSOCb1(i)^1) (ScaledSOCb1(i)^2) (ScaledSOCb1(i)^3)
1/((ScaledSOCb1(i))^1) 1/((ScaledSOCb1(i))^2) ];
end
k= ((b1'*b1)^(-1))*(b1'*Battery1OCV);
V1=b1*k ;
figure;
subplot(4,2,1)
plot(Battery1SOC,V1)
%Plotting s vs v1 for 1000 points Polynomial model
s=0:0.001:1;
s_dash= ((1-(2*E))*s)+ E;
Name: Sindhu Pilli
Student ID: 110060987

b11=zeros(32,6);
for i=1:1001
b11(i,:)=[1 ((s_dash(i))) ((s_dash(i))^2) (s_dash(i)^3) 1/((s_dash(i))^1) 1/((s_dash(i))^2) ];
end
v1=b11*k ;
subplot(4,2,2)
plot(s,v1)

%Plotting battery2soc vs V2 using 32 iterations Polynomial model


ScaledSOCb2= ((1-(2*E))*Battery2SOC)+ E;
b2=zeros(32,6);
for i=1:32
b2(i,:)=[1 (ScaledSOCb2(i)^1) (ScaledSOCb2(i)^2) (ScaledSOCb2(i)^3)
1/((ScaledSOCb2(i))^1) 1/((ScaledSOCb2(i))^2) ];
end
k= ((b2'*b2)^(-1))*(b2'*Battery2OCV);
V2=b2*k ;
subplot(4,2,3)
plot(Battery2SOC,V2)

%Plotting s vs v2 for 1000 points Polynomial model


s=0:0.001:1;
s_dash= ((1-(2*E))*s)+ E;
b12=zeros(32,6);
for i=1:1001
b12(i,:)=[1 (s_dash(i)^1) (s_dash(i)^2) (s_dash(i)^3) 1/((s_dash(i))^1) 1/((s_dash(i))^2) ];
end
v2=b12*k ;
subplot(4,2,4)
plot(s,v2)

%Plotting battery3soc vs V3 using 32 iterations Polynomial model


ScaledSOCb3= ((1-(2*E))*Battery3SOC)+ E;
b3=zeros(32,6);
for i=1:32
b3(i,:)=[1 (ScaledSOCb3(i)^1) (ScaledSOCb3(i)^2) (ScaledSOCb3(i)^3)
1/((ScaledSOCb3(i))^1) 1/((ScaledSOCb3(i))^2) ];
end
k= ((b3'*b3)^(-1))*(b3'*Battery3OCV);
V3=b3*k ;
subplot(4,2,5)
plot(Battery3SOC,V3)

%Plotting s vs v3 for 1000 points Polynomial model


s=0:0.001:1;
s_dash= ((1-(2*E))*s)+ E;
b12=zeros(32,6);
for i=1:1001
b12(i,:)=[1 (s_dash(i)^1) (s_dash(i)^2) (s_dash(i)^3) 1/((s_dash(i))^1) 1/((s_dash(i))^2) ];
Name: Sindhu Pilli
Student ID: 110060987

end
v3=b12*k ;
subplot(4,2,6)
plot(s,v3)

%Plotting battery4soc vs V4 using 32 iterations Polynomial model


ScaledSOCb4= ((1-(2*E))*Battery4SOC)+ E;
b4=zeros(32,6);
for i=1:32
b4(i,:)=[1 (ScaledSOCb4(i)^1) (ScaledSOCb4(i)^2) (ScaledSOCb4(i)^3)
1/((ScaledSOCb4(i))^1) 1/((ScaledSOCb4(i))^2) ];
end
k= ((b4'*b4)^(-1))*(b4'*Battery4OCV);
V4=b4*k ;
subplot(4,2,7)
plot(Battery4SOC,V4)
s=0:0.001:1;
s_dash= ((1-(2*E))*s)+ E;
b14=zeros(32,6);
for i=1:1001
b14(i,:)=[1 (s_dash(i)^1) (s_dash(i)^2) (s_dash(i)^3) 1/((s_dash(i))^1) 1/((s_dash(i))^2) ];
end
v4=b14*k ;
subplot(4,2,8)
plot(s,v4)

Code for calculating errors:


%Calculation of Vbar of Battery1 Polynomial model
N=32;
M=length(k);
Vbarb3_polynomial=sum(V1)/N;
%Calculation of BF
BFb1_polynomial=(1-(norm(V1-Battery1OCV)/norm(Battery1OCV-
Vbarb3_polynomial)))*100;
%Calculation of R^2
R2b1_polynomial=(1-(((norm(V1-Battery1OCV))^2/((norm(Battery1OCV-
Vbarb3_polynomial))^2))))*100;
%Calculation of ME
MEb1_polynomial=max(abs(Battery1OCV-V1));
%Calculation of RMS
RMSb1_polynomial=norm(Battery1OCV-V1)/sqrt(N-M);
errorb1_polynomial=abs(Battery1OCV-V1);
%Calculation of AIC
S2b1_polynomial=sum(errorb1_polynomial.^2);
AICb1_polynomial=(N*(log(S2b1_polynomial/N)))+(2*(M+1));
subplot(2,2,1)
plot(Battery1SOC,errorb1_polynomial)

%Calculation of Vbar for Battery 2 Polynomial model


N=32;
Name: Sindhu Pilli
Student ID: 110060987

M=length(k);
Vbarb2_polynomial=sum(V2)/N;
%Calculation of BF
BFb2_polynomial=(1-(norm(V2-Battery2OCV)/norm(Battery2OCV-
Vbarb2_polynomial)))*100;
%Calculation of R^2
R2b2_polynomial=(1-(((norm(V2-Battery2OCV))^2/((norm(Battery2OCV-
Vbarb2_polynomial))^2))))*100;
%Calculation of ME
MEb2_polynomial=max(abs(Battery2OCV-V2));
%Calculation of RMS
RMSb2_polynomial=norm(Battery2OCV-V2)/sqrt(N-M);
errorb2_polynomial=abs(Battery2OCV-V2);
%Calculation of AIC
S2b2_polynomial=sum(errorb2_polynomial.^2);
AICb2_polynomial=(N*(log(S2b2_polynomial/N)))+(2*(M+1));
subplot(2,2,2)
plot(Battery2SOC,errorb2_polynomial)

%Calculation of Vbar for Battery 3 Polynomial model


N=32;
M=length(k);
Vbarb3_pb3olynomial=sum(V3)/N;
%Calculation of BF
BFb3_polynomial=(1-(norm(V3-Battery3OCV)/norm(Battery3OCV-
Vbarb3_polynomial)))*100;
%Calculation of R^2
R2b3_polynomial=(1-(((norm(V3-Battery3OCV))^2/((norm(Battery3OCV-
Vbarb3_polynomial))^2))))*100;
%Calculation of ME
MEb3=max(abs(Battery3OCV-V3));
%Calculation of RMS
RMSb3_polynomial=norm(Battery3OCV-V3)/sqrt(N-M);
errorb3_polynomial=abs(Battery3OCV-V3);
%Calculation of AIC
S2b3_polynomial=sum(errorb3_polynomial.^2);
AICb3_polynomial=(N*(log(S2b3_polynomial/N)))+(2*(M+1));
subplot(2,2,3)
plot(Battery3SOC,errorb3_polynomial)

%Calculation of Vbar for Battery 4 Polynomial model


N=32;
M=length(k);
Vbarb4_polynomial=sum(V4)/N;
%Calculation of BF
BFb4_polynomial=(1-(norm(V4-Battery4OCV)/norm(Battery4OCV-
Vbarb4_polynomial)))*100;
%Calculation of R^2
Name: Sindhu Pilli
Student ID: 110060987

R2b4_polynomial=(1-(((norm(V4-Battery4OCV))^2/((norm(Battery4OCV-
Vbarb4_polynomial))^2))))*100;
%Calculation of ME
MEb4=max(abs(Battery4OCV-V4));
%Calculation of RMS
RMSb4_polynomial=norm(Battery4OCV-V4)/sqrt(N-M);
errorb4_polynomial=abs(Battery4OCV-V3);
%Calculation of AIC
S2b4_polynomial=sum(errorb4_polynomial.^2);
AICb4_polynomial=(N*(log(S2b4_polynomial/N)))+(2*(M+1));
subplot(2,2,4)
plot(Battery4SOC,errorb4_polynomial)

Graphs:

Error graphs:
Name: Sindhu Pilli
Student ID: 110060987

7.Exponential
Code for soc vs V:
e=2.718;
E=0.175;m=3;n=2;
%Plotting Battery1soc vs V1- Exponential model
ScaledSOCb1= ((1-(2*E))*Battery1SOC)+ E;
b1=zeros(32,4);
for i=1:32
b1(i,:)=[1 (e^(ScaledSOCb1(i)^1)) (e^(ScaledSOCb1(i)^2)) 1/(e^(ScaledSOCb1(i)))];
end
k= ((b1'*b1)^(-1))*(b1'*Battery1OCV);
V1=b1*k ;
figure;
subplot(4,2,1)
plot(Battery1SOC,V1)

%Plotting s vs v1 -Exponential model -battery 1


s=0:0.001:1;
s_dash= ((1-(2*E))*s)+ E;
b11=zeros(32,4);
for i=1:1001
b11(i,:)=[1 (e^(s_dash(i)^1)) (e^(s_dash(i)^2)) 1/(e^(s_dash(i))) ];
end
v1=b11*k ;
subplot(4,2,2)
plot(s,v1)

%Plotting Battery2Soc vs V2-Exponential model


Name: Sindhu Pilli
Student ID: 110060987

ScaledSOCb2= ((1-(2*E))*Battery2SOC)+ E;
b2=zeros(32,4);
for i=1:32
b2(i,:)=[1 (e^(ScaledSOCb2(i)^1)) (e^(ScaledSOCb2(i)^2)) 1/(e^(ScaledSOCb2(i)))];
end
k= ((b2'*b2)^(-1))*(b2'*Battery2OCV);
V2=b2*k ;
subplot(4,2,3)
plot(Battery2SOC,V2)

%Plotting s vs v2 for 1000 points Exponential model


s=0:0.001:1;
s_dash= ((1-(2*E))*s)+ E;
b12=zeros(32,4);
for i=1:1001
b12(i,:)=[1 (e^(s_dash(i)^1)) (e^(s_dash(i)^2)) 1/(e^(s_dash(i))) ];
end
v2=b12*k ;
subplot(4,2,4)
plot(s,v2)

%Plotting Battery3Soc vs V3-Exponential model


ScaledSOCb3= ((1-(2*E))*Battery3SOC)+ E;
b3=zeros(32,4);
for i=1:32
b3(i,:)=[1 (e^(ScaledSOCb1(i)^1)) (e^(ScaledSOCb1(i)^2)) 1/(e^(ScaledSOCb1(i)))];
end
k= ((b3'*b3)^(-1))*(b3'*Battery3OCV);
V3=b3*k ;
subplot(4,2,5)
plot(Battery3SOC,V3)

%Plotting s vs v3 for 1000 points exponential model


s=0:0.001:1;
s_dash= ((1-(2*E))*s)+ E;
b13=zeros(32,4);
for i=1:1001
b13(i,:)=[1 (e^(s_dash(i)^1)) (e^(s_dash(i)^2)) 1/(e^(s_dash(i))) ];
end
v3=b13*k ;
subplot(4,2,6)
plot(s,v3)

%Plotting battery4Soc vs V4-Exponential model


ScaledSOCb4= ((1-(2*E))*Battery4SOC)+ E;
b4=zeros(32,4);
for i=1:32
b4(i,:)=[1 (e^(ScaledSOCb1(i)^1)) (e^(ScaledSOCb1(i)^2)) 1/(e^(ScaledSOCb1(i)))];
end
k= ((b4'*b4)^(-1))*(b4'*Battery4OCV);
Name: Sindhu Pilli
Student ID: 110060987

V4=b4*k ;
subplot(4,2,7)
plot(Battery4SOC,V4)

%Plotting s vs v4 for 1000 points exponential model


s=0:0.001:1;
s_dash= ((1-(2*E))*s)+ E;
b14=zeros(32,4);
for i=1:1001
b14(i,:)=[1 (e^(s_dash(i)^1)) (e^(s_dash(i)^2)) 1/(e^(s_dash(i))) ];
end
v4=b14*k ;
subplot(4,2,8)
plot(s,v4)

Code for calculating errors:


N=32;
M=length(k);
Vbarb1_nernst=sum(V1)/N;
%Calculation of BF
BFb1_exponential=(1-(norm(V1-Battery1OCV)/norm(Battery1OCV-Vbarb1_nernst)))*100;
%Calculation of R^2
R2b1_exponential=(1-(((norm(V1-Battery1OCV))^2/((norm(Battery1OCV-
Vbarb1_nernst))^2))))*100;
%Calculation of ME
MEb1_exponential=max(abs(Battery1OCV-V1));
%Calculation of RMS
RMSb1_exponential=norm(Battery1OCV-V1)/sqrt(N-M);
errorb1_exponential=abs(Battery1OCV-V1);
%Calculation of AIC
S2b1_exponential=sum(errorb1_polynomial.^2);
AICb1_exponential=(N*(log(S2b1_exponential/N)))+(2*(M+1));
figure;
subplot(2,2,1)
plot(Battery1SOC,errorb1_exponential)

%Calculation of Vbar for Battery 2 Exponential model


N=32;
M=length(k);
Vbarb2_exponential=sum(V2)/N;
%Calculation of BF
BFb2_exponential=(1-(norm(V2-Battery2OCV)/norm(Battery2OCV-
Vbarb2_exponential)))*100;
%Calculation of R^2
R2b2_exponential=(1-(((norm(V1-Battery2OCV))^2/((norm(Battery2OCV-
Vbarb1_nernst))^2))))*100;
%Calculation of ME
Name: Sindhu Pilli
Student ID: 110060987

MEb2_exponential=max(abs(Battery2OCV-V2));
%Calculation of RMS
RMSb2_exponential=norm(Battery2OCV-V2)/sqrt(N-M);
errorb2_exponential=abs(Battery1OCV-V2);
%Calculation of AIC
S2b2_exponential=sum(errorb2_exponential.^2);
AICb2_exponential=(N*(log(S2b2_exponential/N)))+(2*(M+1));
subplot(2,2,2)
plot(Battery2SOC,errorb2_exponential)

%Calculation of Vbar for Battery 3 Exponential model


N=32;
M=length(k);
Vbarb3_exponential=sum(V3)/N;
%Calculation of BF
BFb3_exponential=(1-(norm(V3-Battery3OCV)/norm(Battery3OCV-
Vbarb3_exponential)))*100;
%Calculation of R^2
R2b3_exponential=(1-(((norm(V1-Battery3OCV))^2/((norm(Battery3OCV-
Vbarb3_exponential))^2))))*100;
%Calculation of ME
MEb3_exponential=max(abs(Battery3OCV-V3));
%Calculation of RMS
RMSb3_exponential=norm(Battery3OCV-V3)/sqrt(N-M);
errorb3_exponential=abs(Battery3OCV-V3);
%Calculation of AIC
S2b3_exponential=sum(errorb3_polynomial.^2);
AICb3_exponential=(N*(log(S2b3_exponential/N)))+(2*(M+1));
subplot(2,2,3)
plot(Battery3SOC,errorb3_exponential)

%Calculation of Vbar for Battery 4 Exponential model


N=32;
M=length(k);
Vbarb4_exponential=sum(V4)/N;
%Calculation of BF
BFb4_exponential=(1-(norm(V4-Battery4OCV)/norm(Battery4OCV-
Vbarb4_exponential)))*100;
%Calculation of R^2
R2b4_exponential=(1-(((norm(V4-Battery4OCV))^2/((norm(Battery4OCV-
Vbarb4_exponential))^2))))*100;
%Calculation of ME
MEb4_exponential=max(abs(Battery4OCV-V2));
%Calculation of RMS
RMSb4_exponential=norm(Battery4OCV-V2)/sqrt(N-M);
errorb4_exponential=abs(Battery4OCV-V2);
%Calculation of AIC
S2b4_exponential=sum(errorb4_exponential.^2);
AICb4_exponential=(N*(log(S2b4_exponential/N)))+(2*(M+1));
subplot(2,2,4)
Name: Sindhu Pilli
Student ID: 110060987

plot(Battery4SOC,errorb4_exponential)

Graphs:

Error graphs:
Name: Sindhu Pilli
Student ID: 110060987
Name: Sindhu Pilli
Student ID: 110060987

Individual Metrics (Battery 1 )


OCV Model AIC RMSE R^2 BF Max Error
Linear Model -134.23 0.1154 89.6692 67.8585 0.5463
Shepherd – 143.6238 0.0997 92.2954 72.2428 0.2758
Model
Nernst Model -145.6438 0.0952 93.2049 73.9326 0.4255
Combined -178.006 0.0553 97.8656 85.3905 0.1850
Model
Combined+3 -566.2803 1.2521e-04 100.0000 99.9688 4.3415e-04
Model
Polynomial -205.7623 0.0358 99.1393 90.7226 0.0885
Model
Exponential -143.6906 0.0950 93.2148 73.9517 0.4063
Model

Individual Metrics (Battery 2 )


OCV Model AIC RMSE R^2 BF Max Error
Linear Model -134.0416 0.1158 89.6525 67.8325 0.5482
Shepherd -143.6151 0.0997 92.3281 72.3017 0.2760
Model
Nernst Model -145.5532 0.0954 93.2164 73.9547 0.4262
Combined -178.7011 0.0553 97.875 85.4236 0.1848
Model
Combined+3 -564.6968 1.2834e-04 100 99.9681 4.4639e-04
Model
Polynomial -205.8450 0.0357 99.1454 90.755 0.0881
Model
Exponential -143.5927 0.0970 93.2248 73.9708 0.4069
Model
Name: Sindhu Pilli
Student ID: 110060987

Individual Metrics (Battery 3 )


OCV Model AIC RMSE R^2 BF Max Error
Linear Model -135.1353 0.1138 89.937 68.2783 0.5386
Shepherd -143.9100 0.0993 92.3507 72.3426 0.2691
Model
Nernst Model -146.5850 0.0938 93.3904 74.2909 0.4193
Combined -179.6014 0.0545 97.9213 85.6081 0.1826
Model
Combined+3 -570.1974 1.177e-04 100.0000 99.9706 3.83e-04
Model
Polynomial -206.3090 0.0355 99.1524 90.8199 0.0879
Model
Exponential -144.6174 0.0955 93.3971 74.3028 0.4005
Model

Individual Metrics (Battery 4)


OCV Model AIC RMSE R^2 BF Max Error
Linear Model -137.9862 0.1089 90.9261 69.8771 0.5165
Shepherd -144.5950 0.0982 92.6193 72.8325 0.2410
Model
Nernst Model -149.7950 0.0892 94.1064 75.7232 0.3981
Combined -184.9944 0.0501 98.2687 86.8420 0.1670
Model
Combined+3 -635.6162 4.2377e-05 100.0000 99.9895 7.7563e-05
Model
Polynomial -211.0159 0.0330 99.2788 91.5074 0.0804
Model
Exponential -147.3195 0.0915 94.0181 75.5422 0.3821
Model
Name: Sindhu Pilli
Student ID: 110060987

Individual Rankings ( Battery 1 )


OCV Model AIC RMSE R^2 BF Max Error Borda
Ranking
Linear Model 7 7 7 7 7 7
Shepherd 6 6 4 6 4 6
Model
Nernst Model 4 4 6 5 6 4
Combined 3 3 3 3 3 3
Model
Combined+3 1 1 1 1 1 1
Model
Polynomial 2 2 2 2 2 2
Model
Exponential 5 5 5 4 5 5
Model

Individual Rankings ( Battery 2 )


OCV Model AIC RMSE R^2 BF Max Error
Linear Model 7 7 7 7 7
Shepherd 6 6 6 6 6
Model
Nernst Model 4 4 4 4 4
Combined 3 3 3 3 3
Model
Combined+3 1 1 1 1 1
Model
Polynomial 2 2 2 2 2
Model
Exponential 5 5 5 5 5
Model
Name: Sindhu Pilli
Student ID: 110060987

Individual Rankings (Battery 3)


OCV Model AIC RMSE R^2 BF Max Error Borda Ranking
Linear Model 7 7 7 7 7 7
Shepherd 6 6 6 6 4 6
Model
Nernst 4 4 5 5 6 4
Model
Combined 3 3 3 3 3 3
Model
Combined+3 1 1 1 1 1 1
Model
Polynomial 2 2 2 2 2 2
Model
Exponential 5 5 4 4 5 5
Model

Individual Rankings (Battery 4)


OCV Model AIC RMSE R^2 BF Max Error Borda Ranking
Linear Model 7 7 7 7 7 7
Shepherd 6 6 6 6 4 6
Model
Nernst 4 4 4 4 6 4
Model
Combined 3 3 3 3 3 3
Model
Combined+3 1 1 1 1 1 1
Model
Polynomial 2 2 2 2 2 2
Model
Exponential 5 5 5 5 5 5
Model
Name: Sindhu Pilli
Student ID: 110060987

References:

[1] S. Tamilselvi, S. Gunasundari, N. Karuppiah, A. Razak RK, S. Madhusudan, V. M.


Nagarajan, T. Sathish, M. Z. Shamim, C. A. Saleel, and A. Afzal, “A review on battery
modelling techniques,” Sustainability, vol. 13, no. 18, p. 10042, 2021.

You might also like