PDE toolbox: time-dependent Neumann conditions?
- From: Thorsten Raasch <raasch@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 10 Mar 2008 12:10:20 +0100
Hi,
according to the documentation of the PDE toolbox, Matlab is able to solve parabolic PDE with time-dependent boundary conditions. For Dirichlet conditions, e.g., u=t, this is indeed the case.
But I have problems in setting up inhomogeneous, time-dependent Neumann boundary conditions, e.g., (d/dn)u=t. It seems that the solver ignores the string 't' in the corresponding boundary condition matrix, see the following mini example. It consists of a geometry m-file, a boundary condition m-file, and a test program:
geometry m-file (square_geometry.m):
function [x,y]=square_geometry(bs,s)
nbs=4; % number of boundary segments
if nargin==0, % return number of boundary segments
x=nbs;
return
end
% setup parametrization matrix
d=[0 0 0 0;
1 1 1 1;
1 1 1 1;
0 0 0 0];
bs1=bs(:)';
if nargin==1, % return parametrization of boundary segments
x=d(:,bs1);
return
end
x=zeros(size(s));
y=zeros(size(s));
if ~isempty(s),
ii=find(bs==1); % bottom segment
if length(ii)
x(ii)=interp1([0 1],[0 1],s(ii));
y(ii)=0;
end
ii=find(bs==2); % right segment
if length(ii)
x(ii)=1;
y(ii)=interp1([0 1],[0 1],s(ii));
end
ii=find(bs==3); % upper segment
if length(ii)
x(ii)=interp1([0 1],[1 0],s(ii));
y(ii)=1;
end
ii=find(bs==4); % left segment
if length(ii)
x(ii)=0;
y(ii)=interp1([0 1],[1 0],s(ii));
end
end
boundary condition m-file (square_bc.m):
function [q,g,h,r]=square_bc(p,e,u,time)
% setup boundary condition matrix
bc=[1 1 1 1 1 1 '0' '0' '1' '0'; % bottom segment 1: u=0
1 0 1 1 '0' 't' zeros(1,4); % right segment 2 : (d/dn)u=t
1 1 1 1 1 1 '0' '0' '1' '1'; % top segment 3 : u=1
1 0 1 1 '0' '0' zeros(1,4)]'; % left segment 4 : (d/dn)u=0
% compute q,g,h,r
if any(size(u))
[q,g,h,r]=pdeexpd(p,e,u,time,bc);
else
[q,g,h,r]=pdeexpd(p,e,time,bc);
end
test program:
close all;
clear;
[p,e,t]=initmesh('square_geometry');
[p,e,t]=refinemesh('square_geometry',p,e,t);
u0=zeros(size(p,2),1); % initial value u(0,.)=0
N=10;
tlist=linspace(0,1,N); % time nodes
% solve u_t=Delta u
u1=parabolic(u0,tlist,'square_bc',p,e,t,1,0,0,1);
% plot solution for all times
if true,
for i=1:N,
figure;
pdeplot(p,e,t,'xydata',u1(:,i),'zdata',u1(:,i),...
'mesh','on','title',..['t=' num2str(tlist(i))]);
zlim([-1 1]);
end
end
Since the boundary conditions are time-dependent, the exact solution u will depend on the time parameter. But apparently Matlab returns a constant function. Is there an error in the setup of the boundary conditions or are indeed only stationary Neumann conditions allowed?
When entering the test problem and the time-dependent Neumann conditions in the GUI 'pdetool', I observe the same effect.
Best,
Thorsten Raasch
.
- Follow-Ups:
- Re: PDE toolbox: time-dependent Neumann conditions?
- From: Thorsten Raasch
- Re: PDE toolbox: time-dependent Neumann conditions?
- Prev by Date: Re: execution order in simulink
- Next by Date: sprintf and vector problem
- Previous by thread: weighted probablisitc neural network
- Next by thread: Re: PDE toolbox: time-dependent Neumann conditions?
- Index(es):
Relevant Pages
|