How do I create a boundary file to be used with the ASSEMPDE function for time-dependent boundary conditions?

1 view (last 30 days)
I would like to implement time-dependent boundary conditions in the case of a
parabolic initial/boundary value problem, when one does not know these values in closed form.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 16 Jan 2010
There are certain problems for which the boundary condition needs to be implemented in a boundary MATLAB file.
The boundary file needs to have the same format as the PDEBOUND template function. This can be obtained by typing
doc pdebound
at the MATLAB Command Prompt.
Here is the setup for the following parabolic initial/boundary value problem:
u_t(x,t)=Delta u(x,t)+f(x,t) in Omega x [0,1]
u(x,0)=u_0(x) in Omega
du/dn(x,t)=g(x,t) on boundary(Omega)
For this we will require global variables "tlist", providing the time nodes, and "gglob", which provides the Neumann data (g) on the edges of the underlying triangulation.
Refer the following code segment for an example of time-varying boundary conditions in boundary MATLAB file format:
function [q,g,h,r] = bvalues(p,e,u,time)
global gglob tlist; % two global variables
ne = size(e,2); % number of edges in e
tn = length(tlist); % number of time nodes
if isnan(time),
% then matlab wants to know which param. depend on time
q = zeros(1,ne); % pure Neumann cond. for all time nodes
h = zeros(1,2*ne); % no Dirichlet cond.
r = zeros(1,2*ne); % no Dirichlet cond.
g = zeros(1,ne); % initialize with correct size
g(1,:) = nan; % NaN denotes time-dependency
else
% then we have to calculate q,h,r,g for the time "time"
q = zeros(1,ne); % pure Neumann cond.
g = zeros(1,ne); % initialize with correct size
% since "time" may not belong to "tlist", we interpolate:
for i=1:ne,
g(1,i)=interp1(tlist,GGLOB(:,1,i),time);
end
h = zeros(1,2*ne); % no Dirichlet cond.
r = zeros(1,2*ne); % no Dirichlet cond.
end

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!