求救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]
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);
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
답변 (1개)
Torsten
2023년 12월 12일
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
DAN YENG
2023년 12월 12일
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) ?
DAN YENG
2023년 12월 12일
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.
DAN YENG
2023년 12월 12일
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
DAN YENG
2023년 12월 12일
Torsten
2023년 12월 12일
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.
DAN YENG
2023년 12월 12일
Torsten
2023년 12월 12일
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.
DAN YENG
2023년 12월 12일
카테고리
도움말 센터 및 File Exchange에서 Eigenvalue Problems에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



