PV simulation
Show older comments
Dear Friend
i got a problem with my program,i need a soon as possible. when i run my program normaly the maximum points of different in should at a different point then use the MPPT will select the maxi but mine is already all in 1 maxi point.
Please i need help from you friends
this is my coding
function varargout = GUI(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @GUI_OpeningFcn, ...
'gui_OutputFcn', @GUI_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end %All of this coding is auto-generated by MATLAB
% --- Executes just before GUI is made visible.
function GUI_OpeningFcn(hObject, eventdata, handles, varargin)
clc;
handles.output = hObject;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%This coding serves as the initialization of system
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
global Iscn Vocn Imp Vmp Pmax Kv Ki Ns;
global Nss Npp;
global K Q D;
global Gn Tnot;
Iscn = 4.9;
Vocn = 21.4;
Imp = 4.10;
Vmp = 17.1;
Pmax = Vmp*Imp;
Kv =-0.123;
Ki = 3.18*10^(-3);
Ns = 36;
%%Array with Nss*Npp modules
Nss = 2;
Npp =2;
%%constant values
K = 1.3806503*10^(-23);
Q = 1.60217646*10^(-19);
D = 1.5; %Diode constant
%%Nomial Values
Gn =1000;
Tnot = 25 + 273;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%System initialization ends here
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
guidata(hObject, handles); %All of this coding is auto-generated by MATLAB
% --- Outputs from this function are returned to the command line.
function varargout = GUI_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output; %All of this coding is auto-generated by MATLAB
% --- Executes on button press in process.
function process_Callback(hObject, eventdata, handles)
global Iscn Vocn Imp Vmp Pmax Kv Ki Ns;
global Nss Npp;
global K Q D;
global Gn Tnot;
global RpminI RpI RsmaxI RsI GI Pmax_mI TI;
Ta = [25;25;25;25;25];
Ta = Ta + 273;
RH = [100;100;100;100;100];
Ir = [1000;1000;1000;1000;1000];
VI = zeros(1,351,5);
II = zeros(1,351,5);
PI = zeros(1,351,5);
RpminI = zeros(5,1);
RpI = zeros(5,1);
RsmaxI = zeros(5,1);
RsI = zeros(5,1);
GI = zeros(5,1);
Pmax_mI = zeros(5,1);
TI = zeros(5,1);
value1 = get(handles.v1,'String');
value1 = str2double(value1);
value2 = get(handles.v2,'String');
value2 = str2double(value2);
value3 = get(handles.v3,'String');
value3 = str2double(value3);
value4 = get(handles.v4,'String');
value4 = str2double(value4);
value5 = get(handles.v5,'String');
value5 = str2double(value5);
mode = get(handles.mode,'Value');
if mode == 1
Ta = [value1;value2;value3;value4;value5];
Ta = Ta + 273;
elseif mode == 2
RH = [value1;value2;value3;value4;value5];
elseif mode == 3
Ir = [value1;value2;value3;value4;value5];
else
end
for index = 1:5
clc;
percent = (index/5) * 100;
spercent = ['Processing .... ' num2str(percent) '%'];
display(spercent);
%%Adjusting algorithm
%The model is adjusted at the normal condition
T = Ta(index) - ((100 - RH(index))/5) + (0.025 * Ir(index));
G = Ir(index);
Vtn = K*Tnot / Q;
%(nominal)
Vt =K*T / Q;
%(current temperature)
Ion = Iscn /(exp(Vocn/D/Ns/Vtn)-1);
Io =Ion;
%reference values of Rs and Rp
Rsmax = (Vocn - Vmp) /Imp;
Rpmin = Vmp /(Iscn -Imp) - Rsmax;
%Initial assumption of Rp and Rs
Rp = Rpmin;
Rs = 0;
Tol = 0.001; %Power mismatching Tolerance
P=[0];
Error = Inf; %dummy value
%iterative process fo Rs and Rp until Pmax, model=Pmax, experimental
while (Error > Tol)
%display(Error);
dT = T-Tnot;
Ipvn = (Rs+ Rp)/Rp * Iscn;
Ipv =(Ipvn + Ki * dT) * G/Gn;
% Increments Rs
Rs =Rs + 0.001;
%Parallel resistance
Rp =Vmp *(Vmp +Imp*Rs)/(Vmp*Ipv-Vmp*Io*exp((Vmp+Imp*Rs)/Vt/Ns/D) + Vmp*Io-Pmax);
%Solving the I-V equation for many (V,I) Pairs
clear V
clear I
V =0:.1:35; % voltage vector
I =zeros(1,size(V,2)); % current Vector
for j= 1: size(V,2) %calculates for all voltage values
%solves g = I-f(I,v) =0 with Newnton-Raphson
g(j) =Ipv - Io*(exp((V(j)+I(j)*Rs)/Vt/Ns/D)- 1) -(V(j) + I(j)*Rs)/Rp -I(j);
while (abs(g(j))> 0.001)
g(j) =Ipv - Io*(exp((V(j)+I(j)*Rs)/Vt/Ns/D)- 1) -(V(j) + I(j)*Rs)/Rp -I(j);
glin(j) = -Io*Rs/Vt/Ns/D*exp((V(j)+I(j)*Rs)/Vt/Ns/D) -Rs/Rp-1;
I_(j) = I(j) - g(j)/glin(j);
I(j) =I_(j);
end
end %for j=1: size(v,2)
%calculates power using the I-V equation
P= (Ipv -Io*(exp((V+I.*Rs)/Vt/Ns/D)-1)-(V+I.*Rs)/Rp).*V;
Pmax_m = max(P);
Error = (Pmax_m-Pmax);
VI(1,:,index) = V(1,:);
II(1,:,index) = I(1,:);
PI(1,:,index) = P(1,:);
RpminI(index) = Rpmin;
RpI(index) = Rp;
RsmaxI(index)= Rsmax;
RsI(index) = Rs;
GI(index) = G;
Pmax_mI(index) = Pmax_m;
TI(index) = T;
end%while (Error>Tol)
end
s1 = get(handles.v1,'String');
s2 = get(handles.v2,'String');
s3 = get(handles.v3,'String');
s4 = get(handles.v4,'String');
s5 = get(handles.v5,'String');
%%outputs
%I-V curve
axes(handles.axes1);
grid on;
plot(VI(1,:,1),II(1,:,1),'Linewidth',2, 'color','r');
hold on;
plot(VI(1,:,2),II(1,:,2),'Linewidth',2, 'color','g');
hold on;
plot(VI(1,:,3),II(1,:,3),'Linewidth',2, 'color','b');
hold on;
plot(VI(1,:,4),II(1,:,4),'Linewidth',2, 'color','y');
hold on;
plot(VI(1,:,5),II(1,:,5),'Linewidth',2, 'color','k');
hold on;
xlim([0 (Vocn + 1 + 5)]);
ylim([0 (Iscn + 1)]);
hleg1 = legend(s1,s2,s3,s4,s5);
title('Adjusted I-V curve');
xlabel('voltage[V]');
ylabel('current[A]');
hold off;
%P-V curve
axes(handles.axes2);
grid on;
plot(VI(1,:,1),PI(1,:,1),'Linewidth',2, 'color','r');
hold on;
plot(VI(1,:,2),PI(1,:,2),'Linewidth',2, 'color','g');
hold on;
plot(VI(1,:,3),PI(1,:,3),'Linewidth',2, 'color','b');
hold on;
plot(VI(1,:,4),PI(1,:,4),'Linewidth',2, 'color','y');
hold on;
plot(VI(1,:,5),PI(1,:,5),'Linewidth',2, 'color','k');
hold on;
xlim([0 (Vocn + 1 + 5)]);
ylim([0 (Vmp*Imp + 1)]);
hleg1 = legend(s1,s2,s3,s4,s5);
title('P-V curve');
xlabel('voltage[V]');
ylabel('Power[W]');
hold off;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%PLOTTING END
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function result_Callback(hObject, eventdata, handles)
function result_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function data_no_Callback(hObject, eventdata, handles)
global RpminI RpI RsmaxI RsI GI Pmax_mI TI D;
mode = get(handles.data_no, 'Value');
Rpmin = RpminI(mode);
Rp = RpI(mode);
Rsmax = RsmaxI(mode);
Rs = RsI(mode);
T = TI(mode);
G = GI(mode);
Pmax_m = Pmax_mI(mode);
sresult = 'Model info:';
set(handles.t1,'String',sresult);
sresult = ['Rpmin = ' num2str(Rpmin)];
set(handles.t2,'String',sresult);
sresult = ['Rp = ' num2str(Rp)];
set(handles.t3,'String',sresult);
sresult = ['Rsmax = ' num2str(Rsmax)];
set(handles.t4,'String',sresult);
sresult = ['Rs = ' num2str(Rs)];
set(handles.t5,'String',sresult);
sresult = ['D = ' num2str(D)];
set(handles.t6,'String',sresult);
sresult = ['T = ' num2str(T-273)];
set(handles.t7,'String',sresult);
sresult = ['G = ' num2str(G)];
set(handles.t8,'String',sresult);
sresult = ['Pmax,m(model) =' num2str(Pmax_m)];
set(handles.t9,'String',sresult);
function data_no_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function v1_Callback(hObject, eventdata, handles)
function v1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function v2_Callback(hObject, eventdata, handles)
function v2_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function v3_Callback(hObject, eventdata, handles)
function v3_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function v4_Callback(hObject, eventdata, handles)
function v4_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function v5_Callback(hObject, eventdata, handles)
function v5_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function mode_Callback(hObject, eventdata, handles)
function mode_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
Answers (0)
Categories
Find more on Mathematics 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!