pdepe changes in Matlab2014a: issues for 1D problems

4 views (last 30 days)
Hi,
Has anyone else experienced problems with using the new version of pdepe? I'm trying to solve the heat equation in one dimension with a prescribed temperature and density profile but this seems to now want me to input my initial and boundary conditions as vectors (this is fine for the initial conditions but not boundary) and this really slows it down. Has anyone else experienced anything similar? I've tried making the initial conditions/ profiles a function of x using 'fit' but it's still very slow.
The following lines of code have been added to pdepe in the 2014 version that are causing the error:
[U,Ux] = pdentrp(singular,m,xmesh(1),y0(:,1),xmesh(2),y0(:,2),xi(1));
[c,f,s] = feval(pde,xi(1),t(1),U,Ux,varargin{:});
if any([size(c,1),size(f,1),size(s,1)]~=npde)
error(message('MATLAB:pdepe:UnexpectedOutputPDEFUN',sprintf('%d',npde)))
end
[pL,qL,pR,qR] = feval(bc,xmesh(1),y0(:,1),xmesh(nx),y0(:,nx),t(1),varargin{:});
if any([size(pL,1),size(qL,1),size(pR,1),size(qR,1)]~=npde)
error(message('MATLAB:pdepe:UnexpectedOutputBCFUN',sprintf('%d',npde)))
end
Thanks!

Answers (4)

simopera6
simopera6 on 9 Feb 2016
I am facing the same problem. It is evident that the condition is size of the matrix should be equal to number of pdes. I checked the size as well. It is matching. Have you got the solution for this?
  1 Comment
Sammie
Sammie on 9 Feb 2016
Hi Sanket, The advice I was given by Mathworks was to do as above but use a gridded interplant instead of fit to speed things up. Hope that helps! Sammie

Sign in to comment.


simopera6
simopera6 on 10 Feb 2016
I am not understanding how to call vector 'u' when I am solving for multiple components in pdepe. Can you help in this? It is giving the same error and I am guessing that there is a problem in calling vector u. Do you also see any other problem in the code?
function [c,f,s] = newpdecolumnpe(x,t,u,DuDx) %Defining variables global vel Dcoe nComp matrix_in_trans;
%% writing c term and putting it into a column vector %c=zeros(2*nComp,1); c=ones(2*nComp,1); %count5=1;
% for j=1:nComp % f term for all the equations % c(count5,1)= 1; % c(count5+1,1)= 1; % count5 = count5+2; % if count5>20 % break % end % end disp(c) %% %finding f and putting it into a column vector f=zeros(2*nComp,1); count6=1; while count6<2*nComp % f term for all the equations f(count6,1)=Dcoe.*DuDx(1); f(count6+1,1)=0.*DuDx(2); count6=count6+2; end disp(f) %% %finding intermediate term of summation q qcum=0; [last_rows,no_comp] = size(u); for w=1:nComp qcum=qcum+u(2)./(matrix_in_trans(3,w)); %qcum=qcum+(u(last_rows,1))./(matrix_in_trans(3,w)); end disp(1-qcum); %% %finding s and putting it into a column vector eta= zeros(nComp,1); count5=1; for r=1:nComp eta(count5,1)= matrix_in_trans(1,r).*(u(1).*matrix_in_trans(3,r).*{1-qcum}- matrix_in_trans(2,r).*u(2)); matrix_in_trans(2,r).*u(last_rows,2*r)); count5=count5+1;
% sq= k1.*u(1).* qm - (k1.*u(1) + kd).*u(2); end %% %s=[-vel.*DuDx(1) - eta;eta];
%writing source term S and putting it into a column vector s=zeros(2*nComp,1); count6=1; for z=1:nComp % f term for all the equations s(count6,1)= -vel.*DuDx(2*z-1)- eta(z,1); s(count6+1,1)= eta(z,1); count6 = count6+2; end disp(s); end

simopera6
simopera6 on 10 Feb 2016
I am trying to solve mass transfer through packed column. For that I am writing this code. I have written this file for writing c, f & s for the pde. rest files are written correctly.
  1 Comment
Torsten
Torsten on 10 Feb 2016
What's unclear about "calling vector u" ?
Best wishes
Torsten.
P.S. Please format your code from above (use the {} Code button) and remove the uncommented lines before including it.

Sign in to comment.


simopera6
simopera6 on 21 Mar 2016
Hello Torsten, The earlier prolem is solved and I am working on a similar code where I have to solve diffusion equations for the flow through packed bed. I am using pdepe solver in MATLAB for the same.
I am getting following error when I run the program,
What can be the reasons of the same? I have already specified my x and t intervals. "When the first argument to ode15s is a function handle, the tspan and y0 arguments must be supplied."
Following is the code in brief:
{ %% Defining mesh sizes for both space and time N=50; Run_time=600; % minutes x=linspace(0,L,N); % spatial meshing t=linspace(0,Run_time,N); % time meshing tend=300; %% solution sol=pdepe(m,@fun1,@icfun1,@bcfun1,x,t); end } Thanks for your time :) Note: If possible and necessary, it would be great if you can direct me to someone who can help.
  1 Comment
Torsten
Torsten on 21 Mar 2016
I don't see that you initialized "m" in the call to pdepe ...
Best wishes
Torsten.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!