Clear Filters
Clear Filters

1D advection diffusion with pdepe

3 views (last 30 days)
Kevin
Kevin on 17 May 2024
Commented: Kevin on 17 May 2024
Hello guys, i want to solve the 1D advection diffusion PDE in dimensionless form. The equation is the following:
​dC/dW=(1/Pe)*d^2C/dX^2-dC/dX
I want to simlulate the dimensionless concentration for an finite element in x-Direction. Because the variables are dimensionless, my inital condition is C=1 for all X at W=0. Then, for W>0, the concentration must decrease, because of an Flow with an liquid with a concentration of zero. I want to plot the dimensinlos concentration C vs. W and X.
I think, my mistake are the boundary conditions, but I can´t find the solution.
I would be happy about a solution, to solve my problem.
This is my code so far:
function [c, f, s] = pdefun(X, W, C, dCdX)
Pe = 10;
c = 1;
f = (1/Pe)*dCdX;
s = -dCdX;
end
function C0 = ic(X)
C0 = 1;
end
function [pl, ql, pr, qr] = bc(Xl, Cl, Xr, Cr, W)
Pe=10;
pl =Cl;
ql = -1/Pe;
pr = Cr-1;
qr = 0;
end
X = linspace(0, 1, 10);
W = linspace(0, 10, 100);
m = 0;
sol = pdepe(m, @pdefun, @ic, @bc, X, W);
u = sol(:,:,1);
surf(X,W,u)
xlabel('X')
ylabel('W')
zlabel('u(W,X)')
view([150 25])

Accepted Answer

Torsten
Torsten on 17 May 2024
You mean something like this ?
X = linspace(0, 1, 100);
W = linspace(0, 2, 30);
m = 0;
sol = pdepe(m, @pdefun, @ic, @bc, X, W);
u = sol(:,:,1);
plot(X,u(1:20,:))
function [c, f, s] = pdefun(X, W, C, dCdX)
Pe = 10;
c = 1;
f = (1/Pe)*dCdX;
s = -dCdX;
end
function C0 = ic(X)
C0 = 1;
end
function [pl, ql, pr, qr] = bc(Xl, Cl, Xr, Cr, W)
pl = -Cl;
ql = 1; % Sets 1/Pe*dC/dx = C
pr = 0;
qr = 1; % Sets dC/dx = 0
end
  1 Comment
Kevin
Kevin on 17 May 2024
Hi, thank you very much Torsten. The trend of the curves are very good, also for higher Peclét-Numbers, so that the concentration profile is typical for a plug flow. I had chosen the wrong boundary conditions :)

Sign in to comment.

More Answers (0)

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!