problem of pdepe!
1 回表示 (過去 30 日間)
古いコメントを表示
function pdex11
m = 0;
x = linspace(0,1,20);
t = linspace(0,2,5);
sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,x,t);
% Extract the first solution component as u.
u = sol(:,:,1);
% A surface plot is often a good way to study a solution.
surf(x,t,u)
title('Numerical solution computed with 20 mesh points.')
xlabel('Distance x')
ylabel('Time t')
% A solution profile can also be illuminating.
figure
plot(x,u(end,:))
title('Solution at t = 2')
xlabel('Distance x')
ylabel('u(x,2)')
% --------------------------------------------------------------
function [c,f,s] = pdex1pde(x,t,u,DuDx)
c = pi^2;
f = DuDx;
s = 0;
% --------------------------------------------------------------
function u0 = pdex1ic(x)
u0 = sin(pi*x);
% --------------------------------------------------------------
function [pl,ql,pr,qr] = pdex1bc(xl,ul,xr,ur,t)
pl = ul;
ql = 0;
pr = pi * exp(-t);
qr = 1;
And when I change the context of function into (c=1,f=DuDx/pi^2,s=0), the result is totally different.
Why?
0 件のコメント
回答 (1 件)
David Goodmanson
2019 年 3 月 12 日
Hi Junyi,
When you made the change, the flux went down by a factor of 1/pi^2. That's fine, but one of your boundary conditions depends on the flux and you need to change that one to compensate. If, in pdex1bc you change pr to
pr = (pi*exp(-t))/pi^2
then the value of u over the x,t plane (I changed t to have 10 points instead of 5) agrees with the original result within 3e-7.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Mathematics and Optimization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!