Diffusion equation in Cartesian and Cylindrical coordinates

조회 수: 36 (최근 30일)
Neda
Neda 2024년 12월 18일 4:29
편집: Torsten 2024년 12월 20일 2:05
Hi Matlab Team,
I have written the code for the diffusion equation in Cartesian and Cylindrical coordinates using pdepe. However, in cylindrical coordinate, the graph is to the left and it is not symmetric. I think it is becasue of the geometry of cylindrical coordinate, but how can I fixed it to have a similar graph from cartesian and cylindrical code?
Thanks
  댓글 수: 2
Torsten
Torsten 2024년 12월 18일 10:05
Your description is far too vague to be able to give advice.
We need your code to reproduce what you are talking about.
Neda
Neda 2024년 12월 19일 22:25
Thank you !! Here is my code: when I change m from 0 to 1, the solution changes.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
m = 0;
x = linspace(0,1,201);
t = linspace(0,5,101);
sol = pdepe(m,@diffusion,@diffic,@diffbc,x,t);
u = sol;
surf(x,t,u)
%--------------------------------------------------------------------------
figure
for t_num = 1:length(t)
%----------------------------------------------------------------------
% Plot figure
hold off
plot(x, sol(t_num,:))
hold on
v = axis;
axis([x(1) x(end) 0 1])
getframe;
end
%--------------------------------------------------------------------------
% PDE function
function [c,f,s] = diffusion(x,t,u,dudx)
D = 0.01;
mu = 0.1;
K = 20;
c = 1;
f = (D)*dudx ;
s = 0;
end
% initial condition
function u0 = diffic(x)
% u0 = 0;
u0 = 0.01 + 0.99*(0.4 <= x)*(x <= 0.6);
end
% local function 3
function [pl,ql,pr,qr] = diffbc(xl,ul,xr,ur,t)
F = 0.0005;
pl = F; %
ql = 1; %
pr = 0; %
qr = 1; %
end

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

답변 (1개)

Torsten
Torsten 2024년 12월 20일 1:24
편집: Torsten 2024년 12월 20일 2:05
If m = 1, the condition at r = 0 set by "pdepe" is pl = 0, ql = 1. All other conditions make no sense mathematically because they would cause an unbounded solution for u at r = 0. So your setting pl = F will be internally overwritten by the solver.
Further, I don't understand why you are suprised that the solution changes when you change m from 0 to 1. Of course it will change because diffusion in a cylinder in r-direction differs from diffusion in a plate. Since the areas through which diffusion takes place are smaller in the region from 0 to 0.4 than from 0.6 to 1, concentration will increase faster in the region from 0 to 0.4 than from 0.6 to 1 - the profiles loose their symmetry.

카테고리

Help CenterFile Exchange에서 Partial Differential Equation Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by