for loop hanging in mfile
조회 수: 3 (최근 30일)
이전 댓글 표시
I want to draw characteristic curve for photovoltaic panel at different temperature temp=[25,35,45,55] but it enters for loop and can't exit when i change all temp to 25 the nominal temperature it works any other change hang.
clear all
clc
close all hidden
%%Information from the MSX60 solar array datasheet
% You may change these parameters to fit the I-V model
% to other kinds of solar arrays.
Iscn = 4.7; %Nominal short-circuit voltage [A]
Vocn = 43.2; %Nominal array open-circuit voltage [V]
Imp = 4.35; %Array current @ maximum power point [A]
Vmp = 34.6; %Array voltage @ maximum power point [V]
Pmax_e = Vmp*Imp; %Array maximum output peak power [W]
Kv = -0.223*Vocn %Voltage/temperature coefficient [V/K]
Ki = 0.0042*Iscn %Current/temperature coefficient [A/K]
Ns = 72; %Number of series cells
Npp= 1 ;
Nss= 1;
% %%Constants
k = 1.3806503e-23; %Boltzmann (J/K)
q = 1.60217646e-19; %Electron charge (C)
a1 = 1; %Diode Ideality Facotrs constant
a=1;
p=a1;
%%Algorithm parameters
%Increment of Rs
Rsinc = 0.0001;
%Initial value of "a"
a = 1.0;
%Increment of "a"
ainc = 0.005;
%Maximum tolerable power error
tol = 0.0001;
%Maximum number of iteractions for each value of "a"
nimax = 10000;
%Voltage points in each iteraction
nv = 100;
%Number of "a" values to try
namax = 80;
%%Nominal values
Gn = 1000; % Nominal irradiance (W/m^2) @ 25oC
Tn = 25 + 273.15; % Nominal operating temperature (K)
Irrad=[1000,800,600,400,200];
Temp=[65,55,45,35,25];
Temperature=1; % Set Temperature=1 for Temperature changes Curves;
Irradiance=0; % Set Irradiance=1 for Irradiance changes Curves;
%%Code for generating I-V and P-V curves
for j=1:6
% %%Adjusting algorithm
if Temperature==1
if j==6
break
end
T=Temp(j)+273.15;
G=Irrad(j);
end
if Irradiance==1
G=Irrad(j);
T=298.15;
end
%
Vtn = k * Tn / q; %Thermal junction voltage (nominal)
Vt = k * T / q; %Thermal junction voltage (current temperature)
Rp =268.013169;Rs = 0.692200; %these Values are calculated using MSX60.m file
% Temperature and irradiation effect on the current
dT = T-Tn;
Ipvn = Iscn; % Nominal light-generated current((a1+a2)/2.2)
Ipv = (Ipvn + Ki*dT) *G/Gn; % Actual light-generated current
Isc_ = ( Iscn + Ki*dT );
Voc_ = ( Vocn + Kv*dT );
%Io = (Ipv - Vocn/Rp)/(exp(Vocn/Vt/a1/Ns)-1); %%NEW %%UPDATED ON JUNE/2010 %%
Io = Isc_/(exp(Voc_/((a1)/p)/Ns/Vt)-1);
clear V
clear I
V = 0:Vocn/nv:Vocn; % Voltage vector
I = zeros(1,size(V,2)); % Current vector
for j = 1 : length(V) %Calculates for all voltage values
% Solves g = I - f(I,V) = 0 with Newntonn-Raphson
g(j) = Ipv-Io*(exp((V(j)+I(j)*Rs)/Vt/Ns/a1)-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/a1)-1)-(V(j)+I(j)*Rs)/Rp-I(j);
glin(j) = -Io*Rs/Vt/Ns/a1*exp((V(j)+I(j)*Rs)/Vt/Ns/a1)-Rs/Rp-1;
I_(j) = I(j) - g(j)/glin(j);
I(j) = I_(j);
end
end % fr j = 1 : size(V,2)
%%Display the I-V and P-V curves.
% I-V curve
figure(3)
grid on
hold on
xlabel('V (V)');
ylabel('I (A)');
xlim([0 47]);
ylim([0 6]);
plot(V,I,'LineWidth',2,'Color','b'); %
text(38,5, 'T=25 °C ', 'Color', 'r');
text(20, 4.8, '1000 W/ m2 ', 'Color', 'k');
text(20, 3.8, '800 W/ m2 ', 'Color', 'k');
text(20, 2.9, '600 W/ m2 ', 'Color', 'k');
text(20, 1.9, '400 W/ m2 ', 'Color', 'k');
text(20, 1.2, '200 W/ m2 ', 'Color', 'k');
% P-V curve
figure(4)
grid on
hold on
xlabel('V (V)');
ylabel('P (W)');
xlim([0 47]);
ylim([0 160]);
text(36, 150, '1000 W/m2 ', 'Color', 'k');
text(36, 125, '800 W/m2 ', 'Color', 'k');
text(36, 95, '600 W/m2 ', 'Color', 'k');
text(36, 65, '400 W/m2 ', 'Color', 'k');
text(36, 35, '200 W/m2 ', 'Color', 'k');
plot(V,V.*I,'LineWidth',2,'Color','b'); %
end
댓글 수: 1
Jawairia Atiq
2016년 1월 3일
편집: Jawairia Atiq
2016년 1월 3일
Can you send your .m file using which you calculated Rs and Rp values?? I am working on a project related solar array modeling.
답변 (0개)
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!