필터 지우기
필터 지우기

Fixed Bed Adsorption Model

조회 수: 26 (최근 30일)
Puteri Ellyana Mohmad Latfi
Puteri Ellyana Mohmad Latfi 2022년 4월 16일
댓글: Brandon 2022년 9월 1일
I have to model a fixed bed adsorption to obtain the breakthrough curve of the adsorption. I tried to code the model but i think the initial and boundary condition in the code are not correct. Beside that, I got this error when i ran this code.
Warning: Failure at t=2.006182e+02. Unable to meet integration tolerances without reducing the step size below the
smallest value allowed (4.547474e-13) at time t.
> In ode15s (line 655)
In fyp (line 19)
I am not really good with MATLAB, so I would really appreciate any of your help. Thank you very much. I have also attached the model's equations in the file.
Cfeed = 0.0224; % Inlet concentration
tf = 2000; % End time
nz = 200; % Number of gateways
np = nz + 1; % Number of gateposts
% Initial Concentrations
Cb = zeros(np,1); Cb(1) = Cfeed;
Cp = zeros(np,1);
% Prepare data to pass to ode solver
c0 = [Cb; Cp];
dt = tf/100;
tspan = 0:dt:tf;
% Call ode solver
[t, c] = ode15s(@rates, tspan, c0);
% Plot results
plot(t, c(:,np)/Cfeed),grid
xlabel('time'), ylabel('Cb/Cfeed')
title('Figure 1: Exit Cb/Cfeed vs time')
figure
plot(t, c(:,2*np)),grid
xlabel('time'), ylabel('Cp')
title('Figure 2: Exit Cp vs time')
figure
plot(t, c(:,np)-c(:,2*np)), grid
xlabel('time'), ylabel('Cb - Cp')
title('Figure 3: Exit Cb-Cp vs time')
k = 598;
q = k*c(:,2*np); % Freundlcih equation
figure
plot(t,q), grid
xlabel('time'), ylabel('q')
title('Figure 4: Exit q vs time')
% Function to calculate rate of change of concentrations with time
function dcdt = rates(~, c)
a=0.00000000261;
b=0.2102;
d=1705.4719;
e=-38.8576;
L=0.08;
nz = 200; % Number of gateways
np = nz + 1; % Number of gateposts
dz = L/nz;
Cb = c(1:np);
Cp = c(np+1:end);
dCbdt = zeros(np,1);
dCpdt = zeros(np,1);
for i = 2:np-1
dCbdt(i) = (a/dz^2)*(Cb(i+1)-2*Cb(i)+Cb(i-1)) - b/(2*dz)*(Cb(i+1)-Cb(i-1)) - d*(Cb(i)-Cp(i));
dCpdt(i) = e*(Cb(i)-Cp(i)); % Needed to change the sign from -ve to +ve here.
end % i loop
% For simplicity, set exit rates to those of the immediately previous nodes
dCbdt(np) = dCbdt(np-1);
dCpdt(np) = dCpdt(np-1);
% Combine rates for the function to return to the calling routine
dcdt = [dCbdt; dCpdt];
end % of rates function
  댓글 수: 1
Brandon
Brandon 2022년 9월 1일
Can I ask you, how did you derive the differential equations that you are using in your model?

댓글을 달려면 로그인하십시오.

답변 (1개)

Torsten
Torsten 2022년 4월 16일
편집: Torsten 2022년 4월 16일
Cfeed = 0.0224; % Inlet concentration
tf = 3000; % End time
nz = 400; % Number of gateways
np = nz + 1; % Number of gateposts
% Initial Concentrations
Cb = zeros(np,1); Cb(1) = Cfeed;
Cp = zeros(np,1);
% Prepare data to pass to ode solver
c0 = [Cb; Cp];
dt = tf/200;
tspan = 0:dt:tf;
% Call ode solver
[t, c] = ode15s(@rates, tspan, c0);
% Plot results
figure(1)
plot(t, c(:,np)/Cfeed),grid
xlabel('time'), ylabel('Cb/Cfeed')
title('Figure 1: Exit Cb/Cfeed vs time')
figure(2)
plot(t, c(:,2*np)),grid
xlabel('time'), ylabel('Cp')
title('Figure 2: Exit Cp vs time')
figure(3)
plot(t, c(:,np)-c(:,2*np)), grid
xlabel('time'), ylabel('Cb - Cp')
title('Figure 3: Exit Cb-Cp vs time')
k = 598;
q = k*c(:,2*np); % Freundlcih equation
figure(4)
plot(t,q), grid
xlabel('time'), ylabel('q')
title('Figure 4: Exit q vs time')
L=0.08;
dz = L/nz;
z=0:dz:L;
figure(5)
plot(z,[c(1,1:np);c(2,1:np);c(3,1:np);c(4,1:np);c(5,1:np)])
figure(6)
plot(z,[c(1,np+1:2*np);c(2,np+1:2*np);c(3,np+1:2*np);c(4,np+1:2*np);c(5,np+1:2*np)])
% Function to calculate rate of change of concentrations with time
function dcdt = rates(t, c)
a=0.00000000261;
b=0.2102;
d=1705.4719;
e=8.8576;
L=0.08;
nz = 400; % Number of gateways
np = nz + 1; % Number of gateposts
dz = L/nz;
Cb = c(1:np);
Cp = c(np+1:end);
dCbdt = zeros(np,1);
dCpdt = zeros(np,1);
for i = 2:np-1
%dCbdt(i) = (a/dz^2)*(Cb(i+1)-2*Cb(i)+Cb(i-1)) - b/(2*dz)*(Cb(i+1)-Cb(i-1)) - d*(Cb(i)-Cp(i));
dCbdt(i) = (a/dz^2)*(Cb(i+1)-2*Cb(i)+Cb(i-1)) - b/dz*(Cb(i)-Cb(i-1)) - d*(Cb(i)-Cp(i));
dCpdt(i) = e*(Cb(i)-Cp(i)); % Needed to change the sign from -ve to +ve here.
end % i loop
% For simplicity, set exit rates to those of the immediately previous nodes
%dCbdt(np) = dCbdt(np-1);
%dCpdt(np) = dCpdt(np-1);
dCbdt(np) = -2*a*(Cb(np)-Cb(np-1))/dz^2 - d*(Cb(np)-Cp(np));
dCpdt(np) = e*(Cb(np)-Cp(np));
% Combine rates for the function to return to the calling routine
dcdt = [dCbdt; dCpdt];
t
end % of rates function
Concerning your equations: Since you don't solve equations for Cp within the particle, but only define an overall mass transfer coefficient at r=R, you don't need the conditions at r=0 and r=R.
  댓글 수: 13
Puteri Ellyana Mohmad Latfi
Puteri Ellyana Mohmad Latfi 2022년 5월 14일
the other constant changes as well but e can be adjusted to get the right breakthrough curve. do you mind showing me how to do that?
Torsten
Torsten 2022년 5월 15일
편집: Torsten 2022년 5월 15일
time = [0 40 50 65 75 90 110];
cnorm = [0 0 0.01 0.2 0.6 0.95 1.0];
p0 = 2.0;
info = 0;
sol = lsqnonlin(@(p)fit(p,time,cnorm,info),p0);
info = 1;
res = fit(sol,time,cnorm,info)
function res = fit(p,time,cnorm,info)
format long
p
Cfeed = 0.0227; % Inlet concentration
tf = 250; % End time
nz = 100; % Number of gateways
np = nz + 1; % Number of gateposts
% Initial Concentrations
Cb = zeros(np,1); Cb(1) = Cfeed;
Cp = zeros(np,1);
% Prepare data to pass to ode solver
c0 = [Cb; Cp];
if info==0
tspan = time;
elseif info==1
tf = 250; % End time
dt = tf/200;
tspan = 0:dt:tf;
end
% Call ode solver
[t, c] = ode15s(@(t,c)rates(t,c,p), tspan, c0);
if info==0
res = cnorm.' - c(:,np)/Cfeed
elseif info==1
res = cnorm - interp1(t,c(:,np),time)/Cfeed
end
if info == 1
% Plot results
figure(1)
plot(t, c(:,np)/Cfeed),grid
hold on
plot(time,cnorm,'*')
xlabel('time'), ylabel('Cb/Cfeed')
title('Figure 1: Exit Cb/Cfeed vs time')
L=0.065;
dz = L/nz;
z=0:dz:L;
figure(2)
plot(z,[c(40,1:np);c(80,1:np);c(120,1:np);c(160,1:np);c(200,1:np)])
figure(3)
plot(z,[c(40,np+1:2*np);c(80,np+1:2*np);c(120,np+1:2*np);c(160,np+1:2*np);c(200,np+1:2*np)])
end
end
% Function to calculate rate of change of concentrations with time
function dcdt = rates(t, c, e)
persistent iter
if isempty(iter)
iter = 0;
end
iter = iter + 1;
a=0.00000001278;
b=0.16056;
d=244.9429;
%e=1.3964;
L=0.065;
nz = 100; % Number of gateways
np = nz + 1; % Number of gateposts
dz = L/nz;
Cb = c(1:np);
Cp = c(np+1:end);
dCbdt = zeros(np,1);
dCpdt = zeros(np,1);
for i = 2:np-1
%dCbdt(i) = (a/dz^2)*(Cb(i+1)-2*Cb(i)+Cb(i-1)) - b/(2*dz)*(Cb(i+1)-Cb(i-1)) - d*(Cb(i)-Cp(i));
dCbdt(i) = (a/dz^2)*(Cb(i+1)-2*Cb(i)+Cb(i-1)) - b/(2*dz)*(Cb(i+1)-Cb(i-1)) - d*(Cb(i)-Cp(i));
dCpdt(i) = e*(Cb(i)-Cp(i)); % Needed to change the sign from -ve to +ve here.
end % i loop
% For simplicity, set exit rates to those of the immediately previous nodes
%dCbdt(np) = dCbdt(np-1);
%dCpdt(np) = dCpdt(np-1);
dCbdt(np) = -b/dz*(Cb(np)-Cb(np-1)) - 2*a/dz^2*(Cb(np)-Cb(np-1)) - d*(Cb(np)-Cp(np));
dCpdt(np) = e*(Cb(np)-Cp(np));
% Combine rates for the function to return to the calling routine
dcdt = [dCbdt; dCpdt];
if mod(iter,100)==0
disp(t)
iter = 0;
end
end % of rates function

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by