1D advection diffusion with pdepe
9 次查看(过去 30 天)
显示 更早的评论
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])
0 个评论
采纳的回答
Torsten
2024-5-17
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Eigenvalue Problems 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!