Diffusion equation in Cartesian and Cylindrical coordinates

6 ビュー (過去 30 日間)
Neda
Neda 2024 年 12 月 18 日
編集済み: Torsten 2024 年 12 月 20 日
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 日
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 日
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 日
編集済み: Torsten 2024 年 12 月 20 日
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 Center および File ExchangeGeneral PDEs についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by