Modeling pv (plot i-v, p-v characteristics of pv array)

31 visualizzazioni (ultimi 30 giorni)
M_Shaban
M_Shaban il 27 Dic 2021
Commentato: Shilpa il 14 Lug 2025
How to plot i-v and p-v characteristics curves in Matlab/Simulink using this code:
%Initial Data
q = 1.6*10^(-19);
k = 1.38*10^(-23); %Boltzmann’s costant
T = 298; %Temperature in Kelvin(25+273)
%% Datasheet table STC value of panel
Isc = 3.45; % Short circuit current
Voc = 21.7; %Open circuit voltage
Imp = 3.15; %Maximum power current
Vmp = 17.4; %Maximum power voltage
N = 36; %number of cells connected in series
Pmax = Vmp*Imp; %Maximum power point
A = 1;
vt = (k*A*T*N)/q;
Rs = (Voc/Imp) - (Vmp/Imp) + ((vt/Imp)*log((vt)/(vt + Vmp)));
I0 = Isc/(exp(Voc/vt) - exp(Rs*Isc/vt));
Ipv = I0*((exp(Voc/vt)) - 1);
%% First step
iter = 10;000;
it = 0;
tol = 0.1;
A1 = A;
VmpC = (vt*(log((Ipv+I0-Imp)/I0))) - (Rs*Imp);
e1 = VmpC - Vmp;
Rs1 = Rs;
while (it < iter && e1 > tol)
if VmpC < Vmp
A1 = A1 - 0.01;
else
A1 = A1 + 0.01;
end
vt1 = (k*A1*T*N)/q;
I01 = Isc/(exp(Voc/vt1) - exp(Rs1*Isc/vt1));
Ipv1 = I01*((exp(Voc/vt1))- 1);
VmpC = (vt1*(log((Ipv1 + I01 - Imp)/I01))) - (Rs1*Imp);
e1 = (VmpC -Vmp);
it = it + 1;
end
vt1 = (k*A1*T*N)/q;
Rs1 = (Voc/Imp) -(VmpC/Imp) + ((vt1/Imp)*log((vt1)/(vt1 + VmpC)));
%% Second step
tolI = 0.001;
iter = 10000;
itI = 0;
I01 = Isc/(exp(Voc/vt1) - exp(Rs1*Isc/vt1));
Ipv1 = I01*((exp(Voc/vt1))-1);
Rp = (( - Vmp)*(Vmp + (Rs1*Imp)))/(Pmax - (Vmp*Ipv1) + (Vmp*I01*(exp(((Vmp + (Rs1*Imp))/vt1) - 1))));
%calculate I0 with new Rp value
I02 = (Isc*(1 + Rs1/Rp)- Voc/Rp)/(exp(Voc/vt1) - exp(Rs1*Isc/vt1));
Ipv2 = I02*((exp(Voc/vt1)) - 1) + Voc/Rp;
ImpC = Pmax/VmpC;
err = abs(Imp - ImpC);
Rpnew = Rp;
while err>tolI && itI<iter
if ImpC<Imp
Rpnew = Rp + 0.1*itI;
elseif ImpC>=Imp
Rpnew = Rp - 0.1*itI;
end
%Calculate I0 with Rpnew
I02 = (Isc*(1 + Rs1/Rpnew) - Voc/Rpnew)/(exp(Voc/vt1)- exp(Rs1*Isc/vt1));
Ipv2 = I02*((exp(Voc/vt1)) - 1) + Voc/Rpnew;
eqn = @(ImpC) Ipv2 - (I02*(exp((Vmp + (Rs1*ImpC))/vt1) - 1))- ImpC-(Vmp + Rs1*ImpC)/Rpnew;
current_c = Imp;
s = fzero(eqn,current_c);
ImpC = s;
itI = itI+1;
err = abs(Imp - ImpC);
end
X = sprintf('A = %.2f, I0 = %d, Ipv = %.3f, Rs = %f, Rp = %f', A1,I02,Ipv2,Rs1,Rpnew);
disp(X);
  4 Commenti
M_Shaban
M_Shaban il 7 Dic 2022
I honestly don't remember but this is the code we used in our graduation project.

Accedi per commentare.

Risposte (1)

M_Shaban
M_Shaban il 5 Dic 2022
Spostato: Joel Van Sickel il 12 Dic 2022
This code calculate the parameters and draw p-v, i-v curves:
Iscn = 5.45; %Nominal short-circuit voltage [A]
Vocn = 22.2; %Nominal array open-circuit voltage [V]
Imp = 4.95; %Array current @ maximum power point [A]
Vmp = 17.2; %Array voltage @ maximum power point [V]
Pmax_e = Vmp*Imp; %Array maximum output peak power [W]
Kv = -0.072; %Voltage/temperature coefficient [V/K]
Ki = .00104; %Current/temperature coefficient [A/K]
Ns = 36; %Nunber of series cells
k = 1.38e-23; %Boltzmann [J/K]
q = 1.6e-19; %Electron charge [C]
a = 1.1; %Diode constant
Gn = 1000; % Nominal irradiance [W/m^2] @ 25oC
Tn = 25 + 273; % Nominal operating temperature [K]
T = Tn;
G = Gn;
Vtn = k * Tn / q;
%Thermal junction voltage (nominal)
Vt = k * T / q; %Thermal junction voltage (current temperature)
Ion = Iscn/(exp(Vocn/a/Ns/Vtn)-1); % Nominal diode saturation current
Io = Ion;
% Reference values of Rs and Rp
Rs_max = (Vocn - Vmp)/ Imp;
Rsh_min = Vmp/(Iscn-Imp) - Rs_max;
% Initial guesses of Rsh and Rs
Rsh = Rsh_min;
Rs = 0;
tol = 0.001;
% Power mismatch Tolerance
P=[0];
error = Inf;
%dummy value
% Iterative process for Rs and Rp until Pmax,model =
Pmax,experimental
while (error>tol)
% Temperature and irradiation effect on the current
dT = T-Tn;
Ipvn = (Rs+Rsh)/Rsh * Iscn;
Ipv = (Ipvn + Ki*dT) *G/Gn;
Isc = (Iscn + Ki*dT) *G/Gn;
% Increments Rs
Rs = Rs + .01;
% Parallel resistance(2)
Rsh=Vmp*(Vmp+Imp*Rs)/(Vmp*IpvVmp*Io*exp((Vmp+Imp*Rs)/Vt/Ns/a)+Vmp*Io-Pmax_e);
% Solving the I-V equation for several (V,I) pairs
clear V
clear I
V = 0:.1:45; % 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 Newntonn-Raphson
g(j) = Ipv-Io*(exp((V(j)+I(j)*Rs)/Vt/Ns/a)-1)-(V(j)+I(j)*Rs)/Rsh-I(j);
while (abs(g(j)) > 0.001)
g(j) = Ipv-Io*(exp((V(j)+I(j)*Rs)/Vt/Ns/a)-1)-(V(j)+I(j)*Rs)/Rsh-I(j);
glin(j) = -Io*Rs/Vt/Ns/a*exp((V(j)+I(j)*Rs)/Vt/Ns/a)-Rs/Rsh-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/a)-1)-(V+I.*Rs)/Rsh).*V;
Pmax_m = max(P);
error = (Pmax_m-Pmax_e);
end % while (error>tol)
%% Outputs
% I-V curve
figure(1)
grid
on
hold on
title('I-V curve');
xlabel('V [V]');
ylabel('I [A]');
xlim([0 Vocn+1]);
ylim([0 Iscn+1]);
plot(V,I,'LineWidth',2,'Color','k') %
plot([0 Vmp Vocn ],[Iscn Imp 0],'o','LineWidth',2,'MarkerSize',5,'Color','k')
% P-V curve
figure(2)
grid
on
hold on
title('P-V curve');
xlabel('V [V]');
ylabel('P [W]');
xlim([0 Vocn+1]);
ylim([0 Vmp*Imp+1]);
plot(V,P,'LineWidth',2,'Color','k') %
plot([0 Vmp Vocn ],[0 Pmax_e 0],'o','LineWidth',2,'MarkerSize',5,'Color','k')
fprintf('Model info:\n');
fprintf('Rsh = %.2f',Rsh);
fprintf(' Rs = %.2f',Rs);
fprintf(' a = %.2f',a);
fprintf(' Ipv = %.2f',Ipv);
fprintf(' Ion = %.3d',Ion);
fprintf('\n\n');
Hope it helps you.

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by