求救TT HELP WITH THE PDE error (too many input arguments)

T = 3500;
L = 2;
D = 0.00611;
v = 0.012;
lambda1 = 0.000154;
lambda2 = 0.000154;
w=9/5;
theta1 = 0.818;
theta2=0.0818;
c0m = 1;
c0im = 0;
c0 = [c0m;c0im]
c0 = 2×1
1 0
cin = 0;
M = 5;
N = 100;
t = linspace (T/M,T,M);
x = linspace (0,L,N);
options = odeset;
c = pdepe(0,@slowsorpde,@slowsorpic,@slowsorpbc,x,t,options,...
D,v,theta1,theta2,lambda1,lambda2,...
c0,cin,w);
Error using solution>slowsorpic
Too many input arguments.

Error in pdepe (line 225)
temp = feval(ic,xmesh(1),varargin{:});
plot (t,c(:,:,1))
xlabel ('time'); ylabel ('concentration');
function [c,f,s] = slowsorpde(x,t,u,DuDx,D,v,theta1,theta2,lambda1,lambda2,c0,cin,w)
c = [1;1];
f = [D;0].*DuDx;
s = -[v;0].*DuDx - [lambda1;lambda2].*u - [(w/theta1)*(u(1)-u(2))-lambda2*u(2);(w/theta2)*(u(1)-u(2))];
end
function u0 = slowsorpic(x,d,v,c0)
u0 = c0;
end
function [pl,ql,pr,qr] = slowsorpbc(xl,ul,xr,ur,t,D,v,theta1,theata2,lambda1,lambda2,c0,cin)
pl = [ul(1)-cin;0];
ql = [0;1];
pr = [0;0];
qr = [1;1];
end

Answers (1)

If you transfer inputs to the pdepe functions by
c = pdepe(0,@slowsorpde,@slowsorpic,@slowsorpbc,x,t,options,...
D,v,theta1,theta2,lambda1,lambda2,...
c0,cin,w);
@slowsorpde,@slowsorpic,@slowsorpbc must have all these inputs in the list of input parameters:
function u0 = slowsorpic(x,D,v,theta1,theata2,lambda1,lambda2,c0,cin,w)
function [pl,ql,pr,qr] = slowsorpbc(xl,ul,xr,ur,t,D,v,theta1,theata2,lambda1,lambda2,c0,cin,w)
instead of
function u0 = slowsorpic(x,d,v,c0)
function [pl,ql,pr,qr] = slowsorpbc(xl,ul,xr,ur,t,D,v,theta1,theata2,lambda1,lambda2,c0,cin)

12 Comments

thx u for replying so quickly truely thx u
i will give it a try right now
clf
clear
T = 3500;
L = 2;
D = 0.00611;
v = 0.012;
lambda1 = 0.000154;
lambda2 = 0.000154;
w=9/5;
theta1 = 0.818;
theta2=0.0818;
c0m = 1;
c0im = 0;
c0 = [c0m;c0im]
c0 = 2×1
1 0
cin = 0;
gplot = 1;
M = 5;
N = 100;
t = linspace (T/M,T,M);
x = linspace (0,L,N);
options = odeset;
c = pdepe(0,@slowsorpde,@slowsorpic,@slowsorpbc,x,t,options,...
D,v,theta1,theta2,lambda1,lambda2,...
c0,cin,w);
Warning: Failure at t=7.346742e+02. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (1.818989e-12) at time t.
Warning: Time integration has failed. Solution is available at requested time points up to t=7.000000e+02.
switch gplot
case 1
plot (t,c(:,:,1)) % breakthrough curves
xlabel ('time'); ylabel ('concentration');
case 2
plot (x,c(:,:,1)') % profiles
xlabel ('space'); ylabel ('concentration');
end
Error using plot
Vectors must be the same length.
function [c,f,s] = slowsorpde(x,t,u,DuDx,D,v,theta1,theta2,lambda1,lambda2,c0,cin,w)
c = [1;1];
f = [D;0].*DuDx;
s = -[v;0].*DuDx - [lambda1;lambda2].*u - [(w/theta1)*(u(1)-u(2))-lambda2*u(2);(w/theta2)*(u(1)-u(2))];
end
function u0 = slowsorpic(x,d,v,theta1,theta2,lambda1,lambda2,...
c0,cin,w)
u0 = c0;
end
function [pl,ql,pr,qr] = slowsorpbc(xl,ul,xr,ur,t,D,v,theta1,theata2,lambda1,lambda2,c0,cin,w)
pl = [ul(1)-cin;0];
ql = [0;1];
pr = [0;0];
qr = [1;1];
end
sorry another problem occur .seems like a math problem , but this is a pde .
I don't think i can understand the error
The integrator has problems to get a solution for times greater than 734 (s ?).
I'd look at the solutions obtained so far (maybe by setting t = [700 734]) to see which equation might cause trouble.
You are aware that your equation for u(2) is usually not solvable with pdepe because it has no second-order derivatives, but is a usual ordinary differential equation (for which setting boundary conditions is not appropriate) ?
thx again .
I thought u(2) means that the dependent in second pde, if this is not the way it works idk how to derive the s section in function define. i attach the function here.sorry for bothering
Your notation is correct. But "pdepe" is designed for parabolic-elliptic partial differential equations, thus equations for which the f-term in function "slowsorpde" is not equal to 0.
For the ordinary differential equation for u(2), in theory no boundary values need to be supplied. In "pdepe" this is not possible - it needs pl(2), ql(2), pr(2) and qr(2). You set du(2)/dx = 0 at both ends, and this is the best you can do (although mathematically not correct). You might be successful - see what pdepe returns.
(maybe by setting t = [700 734]) to see which equation might cause trouble.
sry idk how exactly set it if the pde has not solved .
this question may be stupid .but i really don't know
I set the integration interval to [700 734] and removed the source terms in both equations.
Without them, the computation seems to work out fine. Trying to include them gives unphysical results. It's up to you to draw your conclusions.
T = 3500;
L = 2;
D = 0.00611;
v = 0.012;
lambda1 = 0.000154;
lambda2 = 0.000154;
w=9/5;
theta1 = 0.818;
theta2=0.0818;
c0m = 1;
c0im = 0;
c0 = [c0m;c0im];
cin = 0;
M = 5;
N = 100;
%t = linspace (T/M,T,M);
t = linspace (700,734);
x = linspace (0,L,N);
options = odeset;
c = pdepe(0,@slowsorpde,@slowsorpic,@slowsorpbc,x,t,options,...
D,v,theta1,theta2,lambda1,lambda2,...
c0,cin,w);
u1 = c(:,:,1);
u2 = c(:,:,2);
figure(1)
plot (x,u1(4,:))
xlabel ('position'); ylabel ('concentration');
figure(2)
plot (x,u2(4,:))
xlabel ('position'); ylabel ('concentration');
function [c,f,s] = slowsorpde(x,t,u,DuDx,D,v,theta1,theta2,lambda1,lambda2,c0,cin,w)
c = [1;1];
f = [D;0].*DuDx;
s = -[v;0].*DuDx; %- [lambda1;lambda2].*u - [(w/theta1)*(u(1)-u(2))-lambda2*u(2);(w/theta2)*(u(1)-u(2))];
end
function u0 = slowsorpic(x,D,v,theta1,theta2,lambda1,lambda2,c0,cin,w)
u0 = c0;
end
function [pl,ql,pr,qr] = slowsorpbc(xl,ul,xr,ur,t,D,v,theta1,theta2,lambda1,lambda2,c0,cin,w)
pl = [ul(1)-cin;0];
ql = [0;1];
pr = [0;0];
qr = [1;1];
end
in fact this is modified from teacher's script. And what i can do is the inspect and check through the script to meet other equation in paper (need a lot of simplification) and the 0 in f is come from the review of the lecture script .it do so at the second ode that dosen't have the form f like pde funtion in matlab.
Since the code works with f(2) = 0 if the source terms are not included, it seems that this is not the problem for the bad results, but the strength or form of the source terms themselves.
so the source term may not suppose to has its place here and the tspan noly work between 700 to 734 right?
thx u a lot .really thx u .but i think if the function has no source term .i may not have enough support to explain this in the team proposal in my classTT. Maybe i simplify too much in that paper.
may i give you the paper link ? if possible ,could i bother you for this subject? i want to understand how can i do this .i know,i can't do it on my own.And i hope i can pay for this study,if you can teach me
so the source term may not suppose to has its place here and the tspan noly work between 700 to 734 right?
I showed you a way to debug your code if problems arise and you want to find the reason for these problems.
First you noticed that the integrator stopped at t = 734 because of numerical problems.
So instead of [700 3500], I set the integration interval to [700 734] and looked at the results.
They were not physical because you got strongly negative concentrations.
So I intermediately removed the source terms and the results were reasonable, also for the original interval of integration [700 3500].
This does not mean that from now on you cannot include source terms in your model. It means that you should look at the model parameters, the form of the source terms and your initial conditions and see whether they can make problems if the source terms are switched on again.
thx you .i think i understand the way you check tsapn.it is late here.i need to rest.thx you again.
This does not mean that from now on you cannot include source terms in your model. It means that you should look at the model parameters, the form of the source terms and your initial conditions and see whether they can make problems if the source terms are switched on again
this will be a a little difficult for me ,but still thx u

Sign in to comment.

Asked:

on 12 Dec 2023

Commented:

on 12 Dec 2023

Community Treasure Hunt

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

Start Hunting!