Using pdepe to solve heat diffusion between two laysers
Show older comments
To learn to use pdepe to solve the heat diffusion between two layers, I started with using pdepe to solve the classic problem "two semi-infinite bodies in contact," whose theoretical solution predicts that the interface temperature would reach to a constant temperature at the moment of contact and remain constant throughout the contact period. However, the interface temperature calculated by pdepe is time dependent though the value is quite close to the theoretical one. I appreciate if anyone could advice me why pdepe doesn't give the "correct answer"? Is it because there is sth wrong with my code?
The heat equation that I'm trying to solve is: rho*c*du/dt=k*d2u/dx2
and my code is as follows:
==========================
function pdex4
m = 0;
x=[-100, -0.2, -0.1, -0.001,-0.0001,-0.000001, 0, 0.000001,0.0001,0.001, 0.1, 0.2, 100];
% -100<x<0, object 1 % 0<=x<100, object 2
t = [0 0.001 0.01 0.1 0.5 1 1.5 20];
sol = pdepe(m,@pdex4pde,@pdex4ic,@pdex4bc,x,t);
u1 = sol(:,:,1)
% --------------------------------------------------------------
function [c,f,s] = pdex4pde(x,t,u,DuDx) %governing equation x_interface=0;
if x < x_interface %object 1
c=rho1*c1;
f = k1*DuDx;
s = 0;
else %object 2
c=rhos*cs;
f = ks*DuDx;
s = 0;
end
% --------------------------------------------------------------
function u0 = pdex4ic(x)
x_interface=0;
if x < x_interface %object 1 initial condition
u0=u1i;
else
u0=u2i; %object 2 initial condition
end
% --------------------------------------------------------------
function [pl,ql,pr,qr] = pdex4bc(xl,ul,xr,ur,t)
% BC for semi-infinite bodies: Same as the initial conditions at two ends.
pl = ul(1)-u1i; ql = 0; pr = ur(1)-u2i; qr = 0;
==========================
Answers (1)
Torsten
on 1 Mar 2016
0 votes
You set the initial temperature at the interface to u2i - so you can't expect that pdepe knows better.
Best wishes
Torsten.
4 Comments
asphalt
on 2 Mar 2016
Torsten
on 2 Mar 2016
It's not possible to skip the conditions for the interface.
Usually, the properties are set by the arithmetic mean of the properties from the right and from the left.
By the way: Could you explicitly state the problem you are trying to solve and for which you think pdepe does not give the correct answer ?
Best wishes
Torsten.
asphalt
on 4 Mar 2016
Torsten
on 4 Mar 2016
It will be better to solve both problems in two separate domains.
The problem you tried above will have transmission conditions
T1 = T2
lambda1*dT1/dn = lambda2*dT2/dn
at the interface during the calculation.
pdepe is not suited for this purpose. I don't know if problems with contact resistance can explicitly be treated with the PDE Toolbox. I'd discretize the equations in space (1d), incorporate the transmission condition and solve the resulting system of ordinary differential equations using ODE15S, e.g.
Best wishes
Torsten.
Categories
Find more on Heat Transfer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!