problem of pdepe!

1 Ansicht (letzte 30 Tage)
Junyi Fan
Junyi Fan am 12 Mär. 2019
Beantwortet: David Goodmanson am 12 Mär. 2019
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?

Antworten (1)

David Goodmanson
David Goodmanson am 12 Mär. 2019
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.

Kategorien

Mehr zu Mathematics and Optimization finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by