% Script implemented by Francois Grosjean (OUFTI-2)
% Different plots of the IV characteristic of two 26.64 cm^2 UTJ cells
% Four relative insolations G are compared
close all
vmax=3;% Maximum voltage of the curve
%G = relative insolation [-] (G=1 => 1367 W/m^2)
%TaC = temperature of the cell in operation [Celsius]

G=[0.7,0.8,0.9,1];

TaC=28;  
Voc=zeros(1,4);
VMPP=zeros(1,4);
Imax=zeros(1,4);
Pmax=zeros(1,4);
figure
grid on
for i=1:4
    V=0:0.005:vmax;
    I = Cell_UJT(V,G(i),TaC);
    I(I<0) = 0;
    idx = find(I==0, 1, 'first');
    V=2.*V;
    P=V.*I;
    Voc(i)=V(idx);
    Imax(i)=max(I);
    % Plots the IV characteristic of a solar panel of OUFTI-2
    % i.e. two solar cells of 23.64 cm^2 in series
    [Pmax(i),index(i)]=max(P);
    VMPP(i)=V(index(i));
    plot(V,P)
    ylim([0 1.1*Pmax(i)])
    ylabel('Power [W]')
    xlim([0 2*vmax])
    xlabel('Voltage [V]')
    hold on
    K(i)=VMPP(i)./Voc(i);
end