PDEPE and BCFUN

Hello,
I would like to use pdepe for solving Heat equation in 1D with a non linear coefficient. I know it is possible. But I remain stuck with the boundary condition and pl,pr,ql,qr.
Let us consider a classic Heat equation : pi^2 dUdt = d2U/dx2 with, U(0,x)= sin(pi x) and as boundary condition : u(t,0)=0=u(t,1) for t>=0 and 0<=x<=1
How do you translate this boundary condition into BCfun and pl,pr,qr,ql ??
Thanks. Alex.

回答(1 个)

Below is the full code:
function heat1D
m = 0;
xmesh = linspace(0,1,20);
tspan = linspace(0,3,60);
sol = pdepe(m,@pdefunH,@icfunH,@bcfunH,xmesh,tspan);
u = sol(:,:,1);
surf(xmesh,tspan,u)
function [c,f,s] = pdefunH(x,t,u,dudx)
c = pi^2;
f = dudx;
s = 0;
function u = icfunH(x)
u = sin(pi*x);
function [pl,ql,pr,qr] = bcfunH(xl,ul,xr,ur,t)
pl = ul;
ql = 0;
pr = ur;
qr = 0;

2 个评论

@Grzegorz Knor how will the boundary conditions look like for the same equation but in two dimension case?
@Grzegorz Knor i wrote them this way:
pl = [ul(1);ul(2)];
ql = [0;0];
pr = [ur(1);ur(2)];
qr = [0;0];
but i think am not correct because my code is not running as i expected. I will appreciate your intervention.

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Historical Contests 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by