Professional Documents
Culture Documents
clear;
clf;
% Cell constant
beta = (V0+VL)/(V0*VL)*(A/L);
% Equilibrium composition
xinf = (V0*x00+VL*x0L)/(V0+VL);
for l = 1:nt+1;
% Fick diffusivities
Dfick = Dms_Dfick(DMS, x0(1:n,l));
% discrete update of compositions
for i = 1:(n-1);
x0(i,l+1) = x0(i,l) - dt*beta*Dfick(i,1:n-1)*(x0(1:n-1,l)-xinf(1:n-1));
end
x0(n,l+1) = 1-sum(x0(1:n-1,l+1));
% Compute values for right bulb
xL(1:n,l+1) = ((V0+VL)*xinf(1:n)-V0*x0(1:n,l+1))/VL;
end
r = 0:dt/3600:(nt+1)*dt/3600;
subplot(1,2,1)
plot(r,x0)
xlabel('time, hrs')
ylabel('mole fraction')
title('Duncan & Toor Run3 - Left Bulb')
legend('H2','N2','CO2')
subplot(1,2,2)
plot(r,xL)
xlabel('time, hrs')
ylabel('mole fraction')
title('Duncan & Toor Run3 - Right Bulb')
legend('H2','N2','CO2')
n = max(size(Dms));
B = zeros(n-1);
% Calculate the elements of the "B" matrix according to equation 2.1.22
for i=1:1:n-1
for j=1:1:i-1
B(i,j) = -x(i) * (1/Dms(i,j)-1/Dms(i,n));
end
for j=i+1:1:n-1
B(i,j) = -x(i) * (1/Dms(i,j)-1/Dms(i,n));
end
end
% Now correct the diagonal elements of the "B" matrix using equation 2.1.21
for i=1:n-1
sumTerm = 0;
for k=i+1:n
sumTerm = sumTerm + x(k)/Dms(i,k);
end
for k=1:i-1
sumTerm = sumTerm + x(k)/Dms(i,k);
end
B(i,i) = x(i)/Dms(i,n) + sumTerm;
end
Dfick = inv(B);