Professional Documents
Culture Documents
Results: Name: Nur Aneesa Binti Abdul Halim STUDENT NO: 44624343 Matlab Week 9
Results: Name: Nur Aneesa Binti Abdul Halim STUDENT NO: 44624343 Matlab Week 9
Results: Name: Nur Aneesa Binti Abdul Halim STUDENT NO: 44624343 Matlab Week 9
MATLAB WEEK 9
RESULTS
x0=[1e-3 ; 1e-4];
Local minimum possible.
lsqnonlin stopped because the final change in the sum of squares relative to
its initial value is less than the default value of the function tolerance.
<stopping criteria details>
klaA = 0.000675 (CI: 0.000618 - 0.000731)
klaB = 0.000585 (CI: 0.000522 - 0.000649)
Observation:
- The accuracy for the initial guess is high because the confidence interval is within the range.
x0=[1e-3 ; 9];
Local minimum possible.
lsqnonlin stopped because the size of the current step is less than
the default value of the step size tolerance.
<stopping criteria details>
klaA = 0.000687 (CI: 0.000367 - 0.001007)
klaB = 8.605872 (CI: 8.213879 - 8.997865)
Observation:
- The accuracy of initial guess is low due to high range of confidence interval
RESULTS
Iterations are 4 and function evaluations are 15. The reasons there are different due to
reannealing step that includes gradient estimation. That increases the function count over
iteration count. Besides that, there is an initial error-check that evaluates the objective
function before any iterations take place.
klaA = 0.000675 (CI: 0.000618 - 0.000731)
klaB = 0.000585 (CI: 0.000522 - 0.000649)
RESULTS
Mean residue -0.0007
Normalised RMSE 0.0538
Relative RMSE 0.0573
R-squared 0.9462
Adj R-squared 0.9434
Comment: There calibration process adjusted the R-squared and increases the relative RMSE.
DRIVER
%Driver to evaluate a liquid liquid extractor model
%This driver sets initial conditions, runs the solver,
%and plots the results.
clear all
close all
% read in data
load data.csv
tdata=data(:,1); % time steps at which we have data
%set initial conditions. Zero in the solvent phase and equal to input in
the liquid phase.
% State variables are: Cas Cbs Cal Cbl
y0=[0,0,1,0.75];
%Plot the data and model over time to assess the calibration
subplot(2,2,1);
plot(t,CALmodel,'k-',t,CALdata,'k+',t,CBLmodel,'k-',t,CBLdata,'k*');
legend('C_{AL} model', 'C_{AL}','C_{BL} model', 'C_{BL}');
xlabel('time, s');
ylabel(' concentration, kg m^{-3}');
title('Calibration data vs calibrated model');
FUNCTION
function f=extractif(t,y,par)
%Code to describe liquid-liquid extractor
%Intensive implementation with transfer coefficients as parameters
%Conservation
f(1) = F1/Vs * (Ca1 - Cas) - kla * (Cstaral-Cal )* Vl/Vs;
f(2) = F1/Vs * (Cb1 - Cbs) - klb * (Cstarbl-Cbl )* Vl/Vs;
f(3) = F3/Vl * (Ca3 - Cal) + kla * (Cstaral-Cal );
f(4) = F3/Vl * (Cb3 - Cbl) + klb * (Cstarbl-Cbl );
f=f';
DRIVER
%Driver to evaluate a liquid liquid extractor model
%This driver sets initial conditions, runs the solver,
%and plots the results.
clear all
close all
% read in data
load data.csv
tdata=data(:,4); % time steps at which we have data
%set initial conditions. Zero in the solvent phase and equal to input in
the liquid phase.
% State variables are: Cas Cbs Cal Cbl
y0=[0.2299,0.1562,0.5401,0.4376];
%solve the model, by calling ODE45 with calibrated parameters
% Note that we specify the time values of the experimental data as our
% tspan parameter to ode45
% Therefore the time vectors for both the simulated and experimental data
% are identical so no interpolation is needed (t=tdata)
par=[0.000675 ;0.000585]; % !!! These will need updating with your
optimised values !!!
[t,y]=ode45(@(t,y)extractif(t,y,par),tdata,y0);
%Plot the data and model over time to assess the calibration
subplot(2,2,1);
plot(t,CALmodel,'k-',t,CALdata,'k+',t,CBLmodel,'k-',t,CBLdata,'k*');
legend('C_{AL} model', 'C_{AL}','C_{BL} model', 'C_{BL}');
xlabel('time, s');
ylabel(' concentration, kg m^{-3}');
title('Calibration data vs calibrated model');
%calculate and plot residuals
subplot(2,2,2);
eA=CALdata-CALmodel;
eB=CBLdata-CBLmodel;
plot(t,eA,'k+',t,eB,'k*');
xlabel('time, s');
ylabel('\epsilon=y_{i}-y_{mi}');
legend('C_{AL}','C_{BL}');
RESULTS
It shows the there is big difference between Cal and Cbl against time when the parameters is
modified.
DRIVER
%Driver to evaluate a liquid-liquid extractor model
%This driver sets initial conditions, runs the solver,
%and plots the results.
clear all
close all
% read in data
load data.csv
tdata=data(:,1); % time steps at which we have data
%set initial conditions. Zero in the solvent phase and equal to input in
the liquid phase.
% State variables are: Cas Cbs Cal Cbl
klA = 0.000675;
klB = 0.000585;
y0=[0,0,1,0.75];
par=[klA , klB*1.2]; % !!! These will need updating with your optimised
values !!!
[t2,y2]=ode45(@(t,y)extractif(t,y,par),tdata,y0);
par=[klA , klB*0.8]; % !!! These will need updating with your optimised
values !!!
[t3,y3]=ode45(@(t,y)extractif(t,y,par),tdata,y0);
par=[klA*1.2 , klB]; % !!! These will need updating with your optimised
values !!!
[t4,y4]=ode45(@(t,y)extractif(t,y,par),tdata,y0);
par=[klA*0.8, klB]; % !!! These will need updating with your optimised
values !!!
[t5,y5]=ode45(@(t,y)extractif(t,y,par),tdata,y0);
f1=(y1-y2)./y1;
subplot(2,2,1),(plot(t1,f1(:,3:4)))
title('Cal and Cbl vs time'),xlabel('time'),ylabel('Cal and Cbl')
f2=(y1-y3)./y1;
subplot(2,2,2),plot(t1,f2(:,3:4))
title('Cal and Cbl vs time'),xlabel('time'),ylabel('Cal and Cbl')
f3=(y1-y4)./y1;
subplot(2,2,3),plot(t1,f3(:,3:4))
title('Cal and Cbl vs time'),xlabel('time'),ylabel('Cal and Cbl')
f4=(y1-y5)./y1;
subplot(2,2,4),plot(t1,f4(:,3:4))
title('Cal and Cbl vs time'),xlabel('time'),ylabel('Cal and Cbl')