Using ode45 to create simulated data and globally optimize the simulated data to two experimental data sets?
조회 수: 3 (최근 30일)
이전 댓글 표시
Research area: Chemical kinetics
Problem description: I have acquired reaction rate versus time (v-t) and photocurrent versus time (j-t) data. The ultimate goal is to simulate data and fit the experimental v-t and j-t data with the following expressions:
v(t)=k_AR*X(t), where X(t) will be determined by solving the differential equations below from the kinetic model.
The photocurrent versus time data will be fit using the following expression:
i(t)=q*A*C1[k1*z(t)*(X(t)+y(t))-k2*n(t)*X(t)], where q,A, C1 are constants, z(t), y(t), and n(t) will be determined by solving the differential equations below from the kinetic model.
I would like to use ode45 to solve the following set of ODEs and then minimize the error between the simulated results and the experimental data (using lsqcurvefit?) by optimizing k1, k2, k3, k_AR in the system of 5 differential equations below:
Eq. 1. dw/dt=k2*n*C1*X-k1*C1*w*z Eq. 2. dz/dt=G-k1*C1*w*z Eq. 3. dX/dt=k1*C1*w*z-2k3*C1*X^2-k2*n*C1*X Eq. 4. dy/dt=k3*C1*X^2-k1*z*C1*y Eq. 5. dn/dt=R-k2*n*C1*X
C1,G and R are known constants. X+y+z=1 ... (I am having trouble applying this condition in ODE solver) Initial Conditions are: X(0)=0, y(0)=0, w(0)=1, n(0)=n1, z(0)=z1, where n1 and z1 are initial numbers. I have tried the following routine to set up the ode solver:
syms w(t) z(t) X(t) y(t) n(t)
guess=[Gen0 1 0 0 Elec0]; %%z w X y n
eqn1=diff(w,t) == (k2*n*C1*X)-(k1*C1*w*z);
eqn2=diff(z,t) == Gen-(k1*C1*w*z);
eqn3=diff(X,t) == (k1*C1*w*z)-(2*k3*C1*X^2)-(k2*n*C1*X);
eqn4=diff(y,t) ==(k3*C1*X^2)-(k1*z*C1*y); %%dy/dt
eqn5=diff(n,t) == Elec-(k2*n*C1*X); %%dn/dt
[V,Y]=odeToVectorField([eqn1], [eqn2], [eqn3], [eqn4], [eqn5]);
M = matlabFunction(V,'vars',{'t','Y'});
sol = ode45(M,[.016 50],guess);
xaxis=[0.016:0.016:3125*0.016];
OHradconc=deval(sol,xaxis,[3]);
simulatedv=OHradconc.*k_AR;
I would then determine the "simulatedj" and I would like to minimize the error between simulatedv and experimental v-t as well as minimize the error between simulatedj and j-t. In this way, I would use two experimental data sets to determine k1, k2, k3, and k_AR.
댓글 수: 0
답변 (1개)
Star Strider
2016년 6월 28일
Using the Symbolic Math Toolbox is probably not the best approach to this problem. We did something similar in: Monod kinetics and curve fitting. You will likely find it helpful.
댓글 수: 2
Star Strider
2016년 7월 19일
In the Monod Kinetics example, the person was fitting the first column, corresponding to ‘[S]’, so the output returned to the objective function ‘Sv(:,1)’. If you want to fit ‘[X]’, the ‘S’ assignment in the Monod Kinetics code becomes:
S = Sv(:,3);
I admit I don’t understand this part of the code:
%%generate the rate data with same num of points as the experimental data
xaxis=[0.016:0.016:3125*0.016];
OHradconc=deval(sol,xaxis,[3]);
rate=OHradconc.*kAR; %%how can I optimize kAR here???
It’s not necessary, and will likely interfere with the correct function of the code.
All the parameters will be optimised, so you don’t have to select particular parameters for optimisation.
Also, lsqcurvefit can fit matrices (dependent data with multiple columns) if you want to fit more than one variable. You have to make appropriate changes in your code to return them as output from the objective function that lsqcurvefit uses. (In the Monod Kinetics example, ‘MonodKinetics1’ is the objective function.)
참고 항목
카테고리
Help Center 및 File Exchange에서 Least Squares에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!