Problem solving coupled PDE / Adsorption

17 visualizzazioni (ultimi 30 giorni)
Jose Adones
Jose Adones il 22 Feb 2023
Commentato: Jose Adones il 28 Ago 2023
Hello, I'm trying to model a packed bed to adsorps H2O on Activated Alumina. I've worked a lot researching but I'm not getting proper results.
I've watched many papers and codes, but they doesn't use mole fraction as unit of concentration.
The result should be around 2.59 mol/kg adsorbed
Thank you in advance.
The code that I'm working at is this:
L=0.4 %Large m
R=8.314; %J/molK
P0=493000; %Pascal
T0=298; %K
yWater=0.3/100; % mole fraction, air composed by 0.3% of Water
pco2=0.1972 %To use on function, alumina doesnt adsorb co2 on this layer
psWater=3.169 %kPa
%% Activated Alumina Isotherm temperature dependent from Zhang 2013
nh2o=40548*exp(-2987/T0);
bco2=5.762*10^-2 *exp(191.57/T0); %1/kPa
bh2o=7.504*exp(490.85/T0); %1/kPa
qsat=0.0934*exp(1030.8/T0) %qsaturation mol/kg
epss=0.26
rhos=820 %Kg/m3
%% Velocity
rof=1.184; %kg/m3 %density at 298K
m=10; %inlet mass flowrate kg/s Qdot=V*A ROF=m/Qdot
A=pi/4 *1.5^2; %area m^2
Q=m/rof; %flow m^3
v=Q/A; %superficial velocity m/s
u=v/epss; %intersticial velocity m/s
%% Mass transfer
LDF1=1E-3; %1/s
%% Main code
Nz=101;
z=linspace(0,L,Nz);
dz=z(2)-z(1);
% Time step
t=0:14400;
% Initial condition
ICA=zeros(1,Nz); %Inlet gas concentration
ICB=zeros(1,Nz); %Initial bed concentration
IC=[ICA,ICB]; %Vector
% Solver
[t y]=ode15s(@f,t,IC,[],Nz,yWater,P0,qsat,bh2o,bco2,pco2,LDF1,u,rhos,R,T0,epss,dz,nh2o,psWater);
% Extract value
c1=y(:,1:Nz);
q1=y(:,Nz+1:2*Nz);
% Re BC
c1(:,1)=yWater;
c1(:,end)=(4*c1(:,end-1)-c1(:,end-2))./3;
q1(:,end)=(4*q1(:,end-1)-q1(:,end-2))./3;
function dydt=f(t,y,Nz,yWater,P0,qsat,bh2o,bco2,pco2,LDF1,u,rhos,R,T0,epss,dz,nh2o,psWater);
dydt=zeros(length(y),1);
dc1dt=zeros(Nz,1);
dq1dt=zeros(Nz,1);
%Assign values
c1=y(1:Nz);
q1=y(Nz+1:2*Nz);
%BC
c1(1)=yWater;
c1(end)=(4*c1(end-1)-c1(end-2))./3;
q1(end)=(4*q1(end-1)-q1(end-2))./3;
%interior
for i=2:Nz-1
dc1dz(i)=(c1(i+1)-c1(i-1)) ./2./dz; %Centered
ph2o(i)=c1(i)*P0/1000; %Mole fraction to kPa
q1star(i)=qsat*bh2o.*ph2o(i)*exp(nh2o*ph2o(i)/psWater)/(1+bh2o.*ph2o(i)+bco2*pco2); %Extended Langmuir
dq1dt(i)=LDF1.*(q1star(i)-q1(i)); %LDF
dc1dt(i)=-u.*dc1dz(i)-((rhos*R*T0./P0).*((1-epss)./epss).*dq1dt(i));
end
dydt=[dc1dt;dq1dt];
end
  2 Commenti
Torsten
Torsten il 22 Feb 2023
Are you sure about the velocity u ? Never seen an adsorption with a flow velocity for the adsorbent of 18.4 m/s .
Jose Adones
Jose Adones il 22 Feb 2023
Modificato: Jose Adones il 22 Feb 2023
Hi @Torsten, I'm trying to recreate the paper "The effect of air purification on liquid air energy storage – An analysis from molecular to systematic modelling", they use a bed of 1.5 m of diameter and a inlet massflow of 10 kg/s.
It bothers me too, but it seems to be that way.
If you have any different idea, let me know, I'll be very greatful.
Thank you.

Accedi per commentare.

Risposte (2)

Torsten
Torsten il 22 Feb 2023
Spostato: Torsten il 22 Feb 2023
Your code works if you change the centered scheme for the first derivatives to the usual upwind scheme:
dc1dz(i)=(c1(i)-c1(i-1))/dz; %Upwind
instead of
dc1dz(i)=(c1(i+1)-c1(i-1)) ./2./dz; %Centered
  9 Commenti
Jose Adones
Jose Adones il 15 Mar 2023
Less than 2%, do you think that I should consider velocity as a constant?
Torsten
Torsten il 15 Mar 2023
Modificato: Torsten il 15 Mar 2023
Try a linear increase of velocity over the length of the reactor that reflects this decrease in mass. I don't think you will get an effect on the results. Maybe if temperature changes drastically because of the adsorption, the effect on fluid velocity might become more important.

Accedi per commentare.


Jose Adones
Jose Adones il 11 Giu 2023
Modificato: Torsten il 11 Giu 2023
Hi @Torsten, after sometime I finally made a functional adsorption code with heat transfer, I've followed a lot of your answers here.
But I have a question, I'm using langmuir for calculate qstar, but langmuir is useless when the RH exceeds 54%, so I have an excess surface work isotherm as follows:
T=298;
R=8.314;
ps=1.279;
Mw=18; %g/mol
%Langmuir parameters
k1 = 0.002082; % mol/g
k2 = 3.851e-5; % 1/K
k3 = 0.083; % 1/(mol/m3)
k4 = 1659; % K
k5 = 1.073;
k6 = 1.049; % K
qm = k1 + k2 * T;
b = k3 * exp(k4 / T);
n1 = k5 + k6 / T;
p=linspace(0,ps,1000); %Concentration mol/m3
qstar = (qm * b * p.^n1) ./ (1 + b * p.^n1);
figure(1)
plot(p,qstar)
hold on
%ESW == qstar >54% RH
esw = -0.0386*(log(abs(R*T*log(p/ps)))-13.3)/Mw;
plot(p/ps,esw)
xlim([0, 1]);
ylim([0, 0.020]);
xlabel('Relative humidity')
ylabel('Adsorbed amount mol/g')
hold off
How can use this "double" isotherm on my code?
Thank you in advance
cFeed = 0.523; % Concentration at the inlet node in mol/m3
Taire = 293; % Air Temperature at the inlet in K
L = 0.3; % Column length in m
t0 = 0; % Initial time in s
tf = 50000; % Final time in s
dt = 1; % Time step
z = [0:0.001:L].'; % Mesh generation
t = [t0:dt:tf]; % Time vector
n = numel(z); % Mesh size
%%%%%% Initial conditions and boundary conditions %%%%%%%$%
c0 = zeros(n,1); % c = 0 at t = 0 for all z
c0(1) = cFeed; % c = cFeed at z = 0 and t > 0
q0 = 1E-5*ones(n,1); % t = 0, q = 0 for all z
T0 = Taire*ones(n,1);
T0(1) = Taire;
Tw0 = Taire*ones(n,1);
y0 = [c0 ; q0 ; T0 ; Tw0];
%%%%% Solving using the ODE15S solver %%%%%%
[Tiempo, Y] = ode15s(@(t,y) MyFun(t,y,z), t, y0);
%%%%%% Plots %%%%%
figure(2)
plot(Tiempo/60, Y(:,n))
legend('c/cFeed')
xlabel('Time min')
ylabel('Concentration mol/m3')
figure(3)
plot(Tiempo/60, Y(:,2*n))
legend('q')
xlabel('Time min')
ylabel('Adsorbed amount mol/g')
figure(4)
plot(Tiempo/60, Y(:,3*n))
legend('Air temperature')
xlabel('Time in minutes')
ylabel('Temperature in Kelvin')
figure(5)
plot(Tiempo/60, Y(:,4*n))
title('Wall temperature with atmospheric air at 293K')
legend('Wall temperature')
xlabel('Time in minutes')
ylabel('Temperature in Kelvin')
function DyDt = MyFun(t, y, z)
n=numel(z);
epsilon = 0.37; % Bed porosity
volflow = 1.5e-4; % Flow rate in m^3/s
bedarea = pi/4 * 0.033^2; % Bed area in m^2
v = volflow / bedarea; % Superficial velocity in m/s
rho = 1100; % Particle density in kg/m^3
Dl = 2.316e-3; % Axial dispersion coefficient in m^2/s
k = 5e-4; % Mass transfer coefficient
T = 293; % Temperature in K
R = 8.314; %J/mol K
% Langmuir isotherm parameters
k1 = 0.002082; % mol/g
k2 = 3.851e-5; % 1/K
k3 = 0.083; % 1/(mol/m3)
k4 = 1659; % K
k5 = 1.073;
k6 = 1.049; % K
qm = k1 + k2 * T;
b = k3 * exp(k4 / T);
n1 = k5 + k6 / T;
%% Heat Transfer Calculation
Tatm = T;
Kl = 2.766; %W/m K
alfa = 0.52; %Dimensionless
rog = 1.159; %kg/m3
rob = 690; %kg/m3
dh = 62700; %j/mol
hi = 1.5; %W/m2 s k
ho = 4.2; %W/m2 s k
Rbi = 0.033; %m
Rbo = 0.03323; %m
cps = 920; %j/kg K
cpa = 2392.6; %j/kg K
Ma = 27.8732/1000; %kg/mol
row = 7700;
cpw = 500;
cpg= 1047;
%%
% Creating vectors for the variables
c = zeros(n,1);
q = zeros(n,1);
T= zeros(n,1);
Tw= zeros(n,1);
DcDt = zeros(n,1);
DqDt = zeros(n,1);
DTDt = zeros(n,1);
DTwDt = zeros(n,1);
zhalf = zeros(n-1,1);
DcDz = zeros(n,1);
D2cDz2 = zeros(n,1);
DTDz = zeros(n,1);
D2TDz2 = zeros(n,1);
DyDt = zeros(4*n,1);
c = y(1:n);
q = y(n+1:2*n);
T = y(2*n+1:3*n);
Tw = y(3*n+1:4*n);
% Interior points of the mesh
zhalf(1:n-1) = (z(1:n-1) + z(2:n)) / 2;
% Calculation of spatial derivatives
DcDz(2:n) = (c(2:n) - c(1:n-1)) ./ (z(2:n) - z(1:n-1));
D2cDz2(2:n-1) = ((c(3:n) - c(2:n-1)) ./ (z(3:n) - z(2:n-1)) - (c(2:n-1) - c(1:n-2)) ./ (z(2:n-1) - z(1:n-2))) ./ (zhalf(2:n-1) - zhalf(1:n-2));
DTDz(2:n) = (T(2:n) - T(1:n-1)) ./ (z(2:n) - z(1:n-1));
D2TDz2(2:n-1) = ((T(3:n) - T(2:n-1)) ./ (z(3:n) - z(2:n-1)) - (T(2:n-1) - T(1:n-2)) ./ (z(2:n-1) - z(1:n-2))) ./ (zhalf(2:n-1) - zhalf(1:n-2));
% Calculation of D2cDz2 at z=L for the boundary condition dc/dz = 0
D2cDz2(n) = -1.0 / (z(n) - zhalf(n-1)) * DcDz(n);
D2TDz2(n) = -1.0 / (z(n) - zhalf(n-1)) * DTDz(n);
% Calculation of qstar (adsorption capacity)
qstar = (qm * b * (c(1:n)).^n1) ./ (1 + b * (c(1:n)).^n1);
DqDt = (k * (qstar - q));
DcDt(1) = 0.0;
DcDt(2:n) = (Dl * D2cDz2(2:n) - v/epsilon * DcDz(2:n)) - ((1 - epsilon) / epsilon) * rho * 1000*DqDt(2:n);
% Calculation of temperature
DTDt(1)=0.0;
DTDt(2:n) = (Kl*D2TDz2(2:n) - rog*cpg*epsilon*v*DTDz(2:n) - rob*dh*DqDt(2:n)- 2*hi/Rbi *(T(2:n)-Tw(2:n)))...
./ (alfa*rog*cpg + rob*cps + rob*q(2:n)*cpa*Ma);
DTwDt(1)=0;
DTwDt(2:n) = (2*pi*Rbi*hi*(T(2:n)-Tw(2:n)) -2*pi*Rbo*ho*(Tw(2:n)-Tatm))./ (row*cpw*(pi*(Rbo^2 - Rbi^2)));
% Concatenation of the temporal derivative vectors
DyDt = [DcDt; DqDt; DTDt; DTwDt];
end
  10 Commenti
Torsten
Torsten il 22 Ago 2023
Modificato: Torsten il 22 Ago 2023
As you can see in the last plot from your code, the water vapor concentration decreases in the reactor right from the beginning whereas in Fig. 5 of the article, it rises to about 1.5 mol/m^3 for ~1500 s.
I don't have access to the article, but you should check the design variables of the desorption again (volume flow and temperature of flushing gas (why do you compute ps with Tfeed and not with T ?), your adsorption isotherm, the factor 1000 in the expression "((1 - epsilon) / epsilon) * rho * 1000*DqDt(2:n)",...)
cFeed = 1E-6; % Concentration at the inlet node in mol/m3
Taire = 423;
L = 0.3; % Column length in m
t0 = 0; % Initial time in s
tf = 10000; % Final time in s
dt = 1; % Time step
z = [0:0.001:L].'; % Mesh generation
t = [t0:dt:tf]; % Time vector
n = numel(z); % Mesh size
% Initial conditions and boundary conditions
c0 = 0.523*ones(n,1); % c = 0 at t = 0 for all z
c0(1) = cFeed; % c = cFeed at z = 0 and t > 0
q0 = 0.0123*ones(n,1); % t = 0, q = 0 for all z
T0 = 293*ones(n,1);
T0(1) = 423;
Tw0 = 298*ones(n,1);
y0 = [c0 ; q0 ; T0 ; Tw0];
% Solving using the ODE15S solver
[Time, Y] = ode15s(@(t,y) MyFun(t,y,z), t, y0);
c = Y(:,1:n);
q = Y(:,n+1:2*n);
T = Y(:,2*n+1:3*n);
Tw = Y(:,3*n+1:4*n);
figure(1)
% Subplot of the first graph
subplot(2, 1, 1);
plot(Time, c(:,end))
hold on
title('Outlet concentration')
xlabel('Time in seconds')
ylabel('Concentration')
xlim([0 8000])
% Subplot of the second graph
subplot(2, 1, 2);
plot(Time, T(:,end), 'r')
hold on
title('Temperature during the Process')
xlabel('Time in seconds')
ylabel('Temperature in Kelvin')
xlim([0 8000])
%figure(2)
%plot(z,[q(1,:);q(50,:);q(end,:)])
figure(3)
plot(z,[c(1,:);c(50,:);c(end,:)])
toc
Elapsed time is 9.826570 seconds.
function DyDt = MyFun(t, y, z)
n=numel(z);
epsilon = 0.37; % Bed porosity
volflow = 4.3e-4; % Flow rate in m^3/s
bedarea = pi/4 * 0.033^2; % Bed area in m^2
v = volflow / bedarea; % Superficial velocity in m/s
rho = 1100; % Particle density in kg/m^3
Dl = 3.995e-3; % Axial dispersion coefficient in m^2/s
k = 5e-3; % Mass transfer coefficient
Tfeed = 423; % Temperature in K
R = 8.314; % J/mol K
% Langmuir isotherm parameters
k1 = 0.002082; % mol/g
k2 = 3.851e-5; % 1/K
k3 = 0.083; % 1/(mol/m3)
k4 = 1659; % K
k5 = 1.073;
k6 = 1.049; % K
qm = k1 + k2 * Tfeed;
b = k3 * exp(k4 / Tfeed);
n1 = k5 + k6 / Tfeed;
%% Heat Transfer Calculation
Tatm = 293;
Kl = 3.374; % W/m K
alfa = 0.52; % Dimensionless
rog = 1.159; % kg/m3
rob = 690; % kg/m3
dh = 62700; % J/mol
hi = 1.5; % W/m2 s K
ho = 4.2; % W/m2 s K
Rbi = 0.033; % m
Rbo = 0.03323; % m
cps = 920; % J/kg K
cpa = 2392.6; % J/kg K
Ma = 18/1000; % kg/mol
row = 7700;
cpw = 500;
cpg = 1047;
%%
% Creating vectors for variables
c = zeros(n,1);
q = zeros(n,1);
T = zeros(n,1);
Tw = zeros(n,1);
DcDt = zeros(n,1);
DqDt = zeros(n,1);
DTDt = zeros(n,1);
DTwDt = zeros(n,1);
zhalf = zeros(n-1,1);
DcDz = zeros(n,1);
D2cDz2 = zeros(n,1);
DTDz = zeros(n,1);
D2TDz2 = zeros(n,1);
DyDt = zeros(4*n,1);
c = y(1:n);
q = y(n+1:2*n);
T = y(2*n+1:3*n);
Tw = y(3*n+1:4*n);
% Interior mesh points
zhalf(1:n-1) = (z(1:n-1) + z(2:n)) / 2;
% Calculation of spatial derivatives
DcDz(2:n) = (c(2:n) - c(1:n-1)) ./ (z(2:n) - z(1:n-1));
D2cDz2(2:n-1) = ((c(3:n) - c(2:n-1)) ./ (z(3:n) - z(2:n-1)) - (c(2:n-1) - c(1:n-2)) ./ (z(2:n-1) - z(1:n-2))) ./ (zhalf(2:n-1) - zhalf(1:n-2));
DTDz(2:n) = (T(2:n) - T(1:n-1)) ./ (z(2:n) - z(1:n-1));
D2TDz2(2:n-1) = ((T(3:n) - T(2:n-1)) ./ (z(3:n) - z(2:n-1)) - (T(2:n-1) - T(1:n-2)) ./ (z(2:n-1) - z(1:n-2))) ./ (zhalf(2:n-1) - zhalf(1:n-2));
% Calculation of D2cDz2 at z=L for the boundary condition dc/dz = 0
D2cDz2(n) = -1.0 / (z(n) - zhalf(n-1)) * DcDz(n);
D2TDz2(n) = -1.0 / (z(n) - zhalf(n-1)) * DTDz(n);
% Calculation of qstar (adsorption capacity)
ps=(0.61094*exp(17.625*(Tatm-273.15)./(Tatm-30.11)).*1000./(R*T(1:n))); % mol/m3
qstar = (qm * b * (c(1:n)).^n1) ./ (1 + b * ((c(1:n)).^n1).*(1-(c(1:n)./ps)).^0.03);
DqDt = (k * (qstar - q));
DcDt(1) = 0.0;
DcDt(2:n) = (Dl * D2cDz2(2:n) - v/epsilon * DcDz(2:n)) - ((1 - epsilon) / epsilon) * rho * 1000*DqDt(2:n);
% Temperature calculation
DTDt(1)=0.0;
DTDt(2:n) = (Kl*D2TDz2(2:n) - rog*cpg*v/epsilon *DTDz(2:n) + ((1-epsilon)/epsilon)*dh*rho*1000*DqDt(2:n)- 2*hi/Rbi *(T(2:n)-Tw(2:n)))...
./ (alfa*rog*cpg + ((1-epsilon)/epsilon)*rob*cps); % Luberti 2015
DTwDt(1)=0;
DTwDt(2:n) = (2*pi*Rbi*hi*(T(2:n)-Tw(2:n)) -2*pi*Rbo*ho*(Tw(2:n)-Tatm))./ (row*cpw*(pi*(Rbo^2 - Rbi^2)));
% Concatenation of temporal derivatives vectors
DyDt = [DcDt; DqDt; DTDt; DTwDt];
end
Jose Adones
Jose Adones il 28 Ago 2023
  1. I will check the desing variables
  2. "why do you compute ps with Tfeed and not with T" Idk, I believe thats the problem
  3. "your adsorption isotherm, the factor 1000 in the expression "((1 - epsilon) / epsilon) * rho * 1000*DqDt(2:n)",...)" That is because the isotherm is in mol/g and must be used in kg
Thank you Torsten

Accedi per commentare.

Categorie

Scopri di più su Mathematics in Help Center e File Exchange

Prodotti


Release

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by