我有一些参考数据,我希望根据这些数据拟合一些模型数据。我为此开发了一个5-param模型。现在的工作是使用Matlab优化模型参数。但是,我对ref与模型数据的拟合非常差(r ^ 2仅在0.6范围内)。我尝试使用fminsearch和nlinfit算法。
一个可能的原因可能是我的参数不具有相似的数量级(而1个参数的范围是e-09,另一个是〜e03)。我不确定是否使用params的缩放/标准化,如果是,那么如何去做。有人可以帮忙吗?
这是我的代码供您阅读:
voltage = xlsread('co_content_29_07_avik.xlsx','A9:A99'); % voltage
current = xlsread('co_content_29_07_avik.xlsx','B9:B99'); % current
% Cell characteristics from manufacturer's datasheet
V_oc = 0.665; %V
I_sc = 5.75; %A
V_mp = 0.56; % V
I_mp = 5.35; % A
a = 1.2 % educated guess
% Calculate thermal voltage
k = 1.3806e-23; %Boltzmann constant - Joule/Kelvin
T = 298;
q = 1.602e-19; %electron charge - Coulomb
n_cell = 1; % no. of cells
V_t = n_cell*k*T/q;
% Calculate unoptimized cell parameters (R_s, R_sh, I_0, I_ph, n)
A = a*V_t/I_mp;
B = -(V_mp*(2*I_mp - I_sc)/(V_mp*I_sc + V_oc*(I_mp - I_sc)));
C = -((2*V_mp - V_oc)/a*V_t) + (V_mp*I_sc - V_oc*I_mp)/(V_mp*I_sc + V_oc*(I_mp - I_sc));
D = (V_mp-V_oc)/(a*V_t);
R_s = A*lambertw((B*exp(C) - (D+C)))
R_sh_num = (V_mp-I_mp*R_s)*(V_mp - R_s*(I_sc-I_mp) - a*V_t);
R_sh_den = (V_mp-I_mp*R_s)*(I_sc-I_mp) - a*V_t*I_mp;
R_sh = R_sh_num/R_sh_den
I_0 = (I_sc*(R_sh + R_s) - V_oc)/(R_sh*exp(V_oc/(a*V_t)))
I_ph = (R_sh+R_s)*I_sc/R_sh
len = length(voltage);
for i=1:1:len
non_exp1 = R_s*R_sh*I_0/(a*V_t*(R_s + R_sh));
lambexp1 = R_sh*(R_s*I_ph + R_s*I_0 + voltage(i,1))/(a*V_t*(R_s + R_sh));
lambarg1 = non_exp1*exp(lambexp1);
firstterm1 = -voltage(i,1)/(R_s + R_sh);
midterm1 = -(lambertw(lambarg1)*a*V_t/R_s);
third1 = R_sh*(I_0 + I_ph)/(R_s + R_sh);
I_1(i,1) = firstterm1 + midterm1 + third1;
end
% Optimize using fminsearch algo
fun = @(p) sum((current - (voltage/(p(1)+p(2)) - (lambertw((p(1)*p(2)*p(3))/(p(5)*V_t*(p(1)+p(2)))))*exp((p(2)*(p(1)*p(4)+p(1)*p(3)+voltage))/(p(5)*V_t*(p(1)+p(2))))*p(5)*V_t/p(1) + (p(2)*(p(3)+p(4))/(p(1)+p(2))))).^2);
% initial guess for param
pguess = [0.005,4.75,0.000000001,5.75,1.2];
%optimize
[x,fval,exitflag,output] = fminsearch(fun,pguess,optimset('MaxFunEvals',1000))