Parameters renormalization in lsqcurvefit to estimate parameters in ODE15s

6 views (last 30 days)
Hello!
I am trying to solve a parametric ODE system. I woul like to estimate the parameters by fitting the calculated data with experimental data.
The problem is that these parameters differ by many orders of magnitude.From a physical point of view I have already an idea of the order of magnitude the estimated value should get:
n_abs = 3.3e15; % (cm-3)
p0 = 9e17; % (cm-3)
Br = 2e-10; % (cm3/s)
kte = 7e-8; %(cm3/s)
Nte = 1e15; % (cm-3)
gamma = 9.3e-30; %(cm6/s)
Now.. the lsqcurvefit combined with the ode solved can't deal with such values so i was thinking to renormalize the parameters to let the ode solver see only values around unity. Like this I renormalize the initial values of the parameters:
%normalization
t_n_abs = n_abs * 1e-16;
t_p0 = p0 * 1e-18;
t_Br = Br * 1e09;
t_kte = kte * 1e7;
t_Nte = Nte * 1e-16;
t_gamma = gamma * 1e29;
I don't know how to normalize and go back to the right values the parameters and initial conditions within the "kinetics" function.
Here my code that does not work. Can you please tell me how would you solve it?
T1 = readtable('data.txt');
t = T1.t*1e9; %in ns seconds
c = T1.c;
%parameters
n_abs = 3.3e15; % (cm-3)
p0 = 9e17; % (cm-3)
Br = 2e-10; % (cm3/s)
kte = 7e-8; %(cm3/s)
Nte = 1e15; % (cm-3)
gamma = 9.3e-30; %(cm6/s)
%normalization
t_n_abs = n_abs * 1e-16;
t_p0 = p0 * 1e-18;
t_Br = Br * 1e09;
t_kte = kte * 1e7;
t_Nte = Nte * 1e-16;
t_gamma = gamma * 1e29;
%initial values
theta0 = [t_p0 , t_Br , t_kte , t_Nte, t_gamma, t_n_abs , t_n_abs + t_p0 , 0 ,0];
[theta,Rsdnrm,Rsd,ExFlg,OptmInfo,Lmda,Jmat]=lsqcurvefit(@(theta,t) kinetics(theta,t),theta0,t,c,zeros(1,9));
[Cfit,T] = kinetics(theta,t);
fprintf(1,'\tRate Constants:\n')
for k1 = 1:length(theta)
fprintf(1, '\t\tTheta(%d) = %d\n', k1, theta(k1))
end
fprintf('\nNOTE — The last four ‘theta’ values are the initial conditions.\n\n')
figure(1)
plot(t, c, 'p')
hold on
plot(t, Cfit);
ylim([1e-4 1])
hold off
grid
xlabel('Time (ns)')
ylabel('normalized units')
legend('data', 'fitting', 'Location','N')
set(gca,'yscale','log')
function [C,T] = kinetics(theta,t)
y0 = theta(6:end);
[T,y] = ode15s(@odefcn, t, y0);
% Now i have to go back to the normal units
theta(1) = theta(1) * 1e18;
theta(2) = theta(2) * 1e-09;
theta(3) = theta(3) * 1e-7;
theta(4) = theta(4) * 1e16;
theta(5) = theta(5) * 1e-29;
theta(6) = theta(6) * 1e16;
theta(7) = theta(7) * 1e18;
theta(8) = theta(8) * 1e16;
theta(9) = theta(9);
function dydt = odefcn(t,y)
dydt = zeros(4,1);
dydt(1) = -theta(2).*y(1).*y(2)-theta(3).*y(1).*(theta(4)-y(3))-theta(5)*y(1).*y(2).^2;
dydt(2) = -theta(2).*y(1).*y(2)-theta(5)*y(1).*y(2).^2;
dydt(3) = theta(3).*y(1).*(theta(4)-y(3));
dydt(4) = 0;
end
C=theta(2)*y(:,1).*y(:,2)/max(theta(2)*y(:,1).*y(:,2));
%Normalization
theta(1) = theta(1) * 1e-18;
theta(2) = theta(2) * 1e09;
theta(3) = theta(3) * 1e7;
theta(4) = theta(4) * 1e-16;
theta(5) = theta(5) * 1e29;
theta(6) = theta(6) * 1e-16;
theta(7) = theta(7) * 1e-18;
theta(8) = theta(8) * 1e-16;
theta(9) = theta(9);
end
  5 Comments
Antonella Treglia
Antonella Treglia on 10 Jun 2021
It is a system of rate equation describing carrier dynamics in semiconductors. The orders of magnitude are well known and accepted in the scientific community. Moreover I can not rescale the equations themselves because the initial conditions are also in the order of 1e14/1e17.
Star Strider
Star Strider on 10 Jun 2021
I would still see if the ga function can fit them acceptably. The range of the parameters is going to be a problem, regardless. I doubt anything other than some sort of efficient extended-precision (more than 64-bit floating point) implementation of ga is going to be able to deal with them.

Sign in to comment.

Answers (0)

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!