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 CenterFile Exchange에서 Mathematics and Optimization에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by