- The for i = s:500 loop repeats the whole calculation 500 times. Try remove Outer Loop:Delete for i = s:500.
- The function (g(j)) and its derivative (glin(j)) are not correctly set up for the PV equation. Loop Over Each Current Value i.e. use for j = 1:length(Iexp) and solve for each voltage separately.
- The while loop can run forever if convergence is not reached. Properly define the function and derivative for the PV equation.
- Always starting with V(j) = 0 can slow or prevent convergence. Try add Maximum Iteration Count:E.g., max_iter = 100 to avoid infinite loops.
- The code tries to solve for all voltages together, but each current value should be solved one at a time. Try starting with a value closer to expected voltage (e.g., V(j) = Vocn).
calculating V experimental of a solar cell using newton rapson calculations
조회 수: 4 (최근 30일)
이전 댓글 표시
hello every one i have this calcculation that i have been doing for a while but i have no answers. i am trying to get the 62 values of V in the code below; i am using matlab 2018a
% Program different values of V for Iexp
clc
close all
global s Vt_T Iexp V
Iscn = 3.8; %Nominal short-circuit voltage [A]
Vocn = 21.1; %Nominal array open-circuit voltage [V]
Imp = 3.5; %Array current @ maximum power point [A]
Vmp = 17.1; %Array voltage @ maximum power point [V]
Pmax_e = Vmp*Imp; %Array maximum output peak power [W]
Kv = -80e-3; %Voltage/temperature coefficient [V/K]
Ki = .003; %Current/temperature coefficient [A/K]
Ns = 36; %Nunber of series cells
Gn = 1000; %Nominal irradiance [W/m^2] @ 25oC
Tn = 25 + 273.15; %Nominal operating temperature [K]
% Constants
k = 1.3806503e-23; %Boltzmann [J/K]
q = 1.60217646e-19; %Electron charge [C]
% a1 = 1.0; % Diode ideality factor (n)
Eg =1.12; % Band gap energy; 1. 12eV (Si) , 1. 42 (GaAs)
Vt_T=k*Tn/q; % Define thermal potential (Vt) at temp Ta
% Data values
Iexp = [3.81 3.81 3.81 3.81 3.81 3.80 3.80 3.80 3.80 3.80 3.80 3.75 3.70 3.65 3.60 3.55 3.50 3.45 ...
3.40 3.35 3.30 3.25 3.20 3.15 3.10 3.05 3.00 2.95 2.90 2.85 2.80 2.75 2.70 2.65 2.60 2.55 2.50 ...
2.40 2.30 2.20 2.10 2.00 1.90 1.80 1.70 1.60 1.50 1.40 1.30 1.20 1.10 1.00 0.90 0.80 0.70 0.60 ...
0.50 0.40 0.30 0.20 0.10 0.00];
Iph=3.86;
I0=1e-9;
Rs=0.33;
n=1.04;
Rp=117.99;
V = zeros(1,size(Iexp,2)); % Current vector
s=1;
for i=s:500
for j = 1 : size(Iexp,2) %Calculates for all voltage data values
% Solves g = V - f(I,V) = 0 with Newton-Raphson
g(j) = 117.99 * 3.86 - 117.99 * 1.0e-9*(exp((V(j) + 0.33*Iexp(j))/(1.04*Ns*Vt_T)) - 1)-...
(117.99 + 0.33)*Iexp(j)-V(j);
while (abs(g(j)) > 0.01)
g(j) = 117.99 * 3.86 - 117.99 * 1.0e-9*(exp((V(j) + 0.33*Iexp(j))/(1.04*Ns*Vt_T)) - 1)-...
(117.99 + 0.33)*Iexp(j)-V(j);
glin(j) = - 117.99*1.0e-9*(exp((V(j) + 0.33*Iexp(j)))/(1.04*Ns*Vt_T))-1; %#ok<*SAGROW>
V_(j) = V(j) - g(j)/glin(j);
V(j) = V_(j);
end
end
end
fprintf('=========== optimal parameters using LSE=========\n');
fprintf('\t V = %.2f\n',V);
댓글 수: 0
답변 (1개)
Leepakshi
2025년 9월 4일
Hi Fopa,
As per my understanding, we can try correcting below points in code to get desired solution:
Hope this will help!
Thanks
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!