MATLAB Answers


How to implement irregular, time-dependent boundary condition in PDEPE function?

Asked by James Fraser on 7 Apr 2014
Latest activity Commented on by James Fraser on 7 Apr 2014
I am trying to use the MATLAB Partial Differential Equation solver, pdepe, for a simple 1D (one-dimensional) heat transfer in a space shuttle tile using Fourier's equation for heat transfer. All parameters are known, and I have organised the equation according to the MATLAB format.
However, the problem I have encountered is in the Boundary Conditions. For the shuttle tile, the outer surface (right hand boundary condition) varies in a time-dependent manner according to a predefined pattern that cannot be described mathematically. I can store the data in a vector, but I have thus far been unsuccessful in implementing this in the RHS boundary (pr).
Any help at all would be very much appreciated, a sample of my current code can be viewed below.
function pde1 % Function to perform parabolic PDE solver on Fourier's Heat transfer % equation in one dimension %
global rho cp k tinitial global n tempdata deltaT timedata
% tile properties
k = 0.141; % W/(m K)
rho = 352; % 22 lb/ft^3
cp = 1255; % 0.252 Btu/lb/F at 500F
n = 500;
tinitial = (60-32)*5/9; % intial temp throughout the tile
% Loads the outer surface temperature data in an array. % This data can then be extracted into a vector. load temp597.mat timedata tempdata
% properties required for Partial Differential Equation input
m = 0; % assume 'slab' shape
xmesh = linspace(0, 0.05, 21); % 21 spatial steps, up to 5cm
t = linspace(0, 4000, 500); % 250 time-steps over 2000 seconds
sol = pdepe(m, @pdef, @pdeic, @pdebc, xmesh, t);
u = sol(:,:,1);
% ========================================================================= % defines the properties of the PDE function
function[c,f,s] = pdef(x, t, u, DuDx)
c = rho*cp;
f = k*DuDx;
s = 0;
end % ========================================================================= % defines the Initial Conditions
function[u0] = pdeic(x)
u0 = tinitial;
end % ========================================================================= % defines the Boundary Conditions
function[pl,ql,pr,qr] = pdebc(xl, ul, xr, ur, t)
pl = 0;
ql = 1;
pr = ???;
qr = 1;
end end


Sign in to comment.

1 Answer

Answer by Bill Greene on 7 Apr 2014
 Accepted Answer

I think that
pr = interp1(timedata, tempdata, t) - ur;
may be what you need. Assuming the lengths of timedata and tempdata are the same, this will do a piecewise linear interpolation for the temperature at time t.
Beyond that, if you want to prescribe the temperatures at the right and left ends to a prescribed value, you want ql and qr equal zero rather than 1.


Thankyou very much for your help, the code does seem to at least run now, but I am met with the following warnings.
Warning: Failure at t=0.000000e+00. Unable to meet integration tolerances
without reducing the step size below the smallest value allowed (7.905050e-323)
at time t.
Warning: Time integration has failed. Solution is available at requested time
points up to t=0.000000e+00.
It tells me the problem lies with
sol = pdepe(m, @pdef, @pdeic, @pdebc, xmesh, t);
in my pde1 function. And lines 317 and 323 of the pdepe function.
Do you know how I can prevent this from happening?
On further checking through my function, when I output the variable pr, it informs me that, at all points,
pr = NaN
got it! Just needed
interp1(timedata, tempdata, t, 'linear', 'extrap')
many thanks!

Sign in to comment.