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.

Respuestas (1)

Grzegorz Knor
Grzegorz Knor el 25 de Nov. de 2011

2 votos

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 comentarios

HARRISON WANDERA
HARRISON WANDERA el 2 de Feb. de 2021
@Grzegorz Knor how will the boundary conditions look like for the same equation but in two dimension case?
HARRISON WANDERA
HARRISON WANDERA el 2 de Feb. de 2021
@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.

Iniciar sesión para comentar.

Categorías

Más información sobre Historical Contests en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 3 de Oct. de 2011

Comentada:

el 2 de Feb. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by