problem of pdepe!

1 回表示 (過去 30 日間)
Junyi Fan
Junyi Fan 2019 年 3 月 12 日
回答済み: David Goodmanson 2019 年 3 月 12 日
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?

回答 (1 件)

David Goodmanson
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.

カテゴリ

Help Center および File ExchangeMathematics and Optimization についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by