MATLAB PDE BC'S

clc;clear all;close all;
L = 1;
x = linspace(0,L,75);
t = linspace(0,1,75);
m = 1;
sol = pdepe(m,@heatpde,@heatic,@heatbc,x,t);
sol1=1-sol;
figure(1)
surf(x,t,sol1);
xlabel('y/b');
zlabel('(T-T_0)/(T_1-T_0)');
title('Fig 12.1-1'); grid on;
function [c,f,s] = heatpde(x,t,u,dudx)
c = 1;
f = dudx;
s = 0;
end
function u0 = heatic(x)
u0 = 1;
end
function [pl,ql,pr,qr] = heatbc(xl,ul,xr,ur,t)
% left Bc = ul
pl = ul;
ql = 0;
% right BC= ur
pr = ur;
qr = 0;
end
I am a pde code. I am having a problem using the BC's in image. can you please help me.

Respuestas (2)

Torsten
Torsten el 25 de Mzo. de 2022

0 votos

function [pl,ql,pr,qr] = heatbc(xl,ul,xr,ur,t)
Nu = 1.0;
% left Bc = ul
pl = 0;
ql = 1;
% right BC= ur
pr = Nu*ur;
qr = 1;
end

4 comentarios

Mr.DDWW
Mr.DDWW el 26 de Mzo. de 2022
clc;clear all;close all;
L = 1;
x = linspace(0,L,75);
t = linspace(0,1,75);
m = 1;
sol = pdepe(m,@heatpde,@heatic,@heatbc,x,t);
sol1=1-sol;
figure(1)
surf(x,t,sol1);
mesh (x,t,sol1);
xlabel('y/b');
zlabel('(T-T_0)/(T_1-T_0)');
title('Fig 12.1-1'); grid on;
function [c,f,s] = heatpde(x,t,u,dudx)
c = 1;
f = dudx;
s = 0;
end
function u0 = heatic(x)
u0 = 1;
end
function [pl,ql,pr,qr] = heatbc(xl,ul,xr,ur,t)
Nu = 1.0;
% left Bc = ul
pl = 0;
ql = 1;
% right BC= ur
pr = Nu*ur;
qr = 1;
end
I want to to obatain the solution from the image by chaning the size of the mesh (space coordubate ) I am not sure if my solution is correct
Torsten
Torsten el 26 de Mzo. de 2022
The boundary conditions from the image - transfered to pdepe language - should be implemented as
function [pl,ql,pr,qr] = heatbc(xl,ul,xr,ur,t)
Nu = 1.0;
% left Bc = ul
pl = 0;
ql = 1;
% right BC= ur
pr = Nu*ur;
qr = 1;
end
I don't understand what this has to do with the size of the mesh in spatial direction.
Mr.DDWW
Mr.DDWW el 26 de Mzo. de 2022
Well, I am supposed to obtain the numerical solution from the image by changing the size of the mesh
Torsten
Torsten el 26 de Mzo. de 2022
If it's the equation from the image you are trying to solve, you'll have to set m=0 instead of m=1 in your code.
If you want to solve the problem for different spatial meshes, change the "75" in
x = linspace(0,L,75);
to a different number.

Iniciar sesión para comentar.

Mr.DDWW
Mr.DDWW el 27 de Mzo. de 2022

0 votos

It is a slab. So the symmetry (m) = 1

Etiquetas

Preguntada:

el 25 de Mzo. de 2022

Respondida:

el 27 de Mzo. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by