Pdepe: Spatial discretization has failed. Discretization supports only parabolic and elliptic equations, with flux term involving spatial derivative.

25 次查看(过去 30 天)
Hi,
I was trying to solve PDE about diffusion in solutions, which yields:
>> test2
Error using pdepe (line 293)
Spatial discretization has failed. Discretization supports only parabolic and elliptic equations, with flux term involving spatial derivative.
Error in test2 (line 5)
sol = pdepe(m,@pdex4pde,@pdex4ic,@pdex4bc,x,t);
Please see the code below
function test2
m = 0;
x = [0 0.01 0.1 0.5 1 5 10 20 30 50 100 200];
t = [0.001 0.005 0.01 0.05 0.1 0.5 1 1.5 2 5 10 100];
sol = pdepe(m,@pdex4pde,@pdex4ic,@pdex4bc,x,t);
u1 = sol(:,:,1);
u2 = sol(:,:,2);
u3 = sol(:,:,3);
u4 = sol(:,:,4);
figure;
surf(x,t,u1);
title('u1(x,t)');
xlabel('Distance x');
ylabel('Time t');
figure;
surf(x,t,u2);
title('u2(x,t)');
xlabel('Distance x');
ylabel('Time t');
figure;
surf(x,t,u3);
title('u3(x,t)');
xlabel('Distance x');
ylabel('Time t');
figure;
surf(x,t,u4);
title('u4(x,t)');
xlabel('Distance x');
ylabel('Time t');
%----------------------------------------------------
function [c,f,s] = pdex4pde(x,t,u,DuDx)
c = [1; 1; 1; 1];
f = [1.91e-9; 0.923e-9; 1.19e-9; 5.27e-9] .* DuDx;
s = [(-2.23e3.*u(1).*u(4)+5.02e-5.*u(2)-200*1*0.6/(96485*2*0.1));
(2.23e3.*u(1).*u(4)-5.02e-5.*u(2)-6e9.*u(2).*u(4)+1.29e6.*u(3));
(6e9.*u(2).*u(4)-1.29e6.*u(3));
(-2.23e3.*u(1).*u(4)+5.02e-5.*u(2)-6e9.*u(2).*u(4)+1.29e6.*u(3)+200*0.6/(96485*0.1)) ];
%----------------------------------------------------------
function u0 = pdex4ic(x)
u0 = [ 0; 0; 0; 1];
%---------------------------------------------------------------
function [pl,ql,pr,qr] = pdex4bc(xl,ul,xr,ur,t)
pl = [ul(1)-24.5e-3; 0; 0; 0];
ql = [0; 1; 1; 1];
pr = [0; 1; 1; ur(4)-1];
qr = [1; 0; 0; 0];

采纳的回答

Bill Greene
Bill Greene 2019-11-19
Your boundary conditions (BC) are specified incorrectly; a qr(i) value of zero and pr(i)=constant is not a valid BC.
Since you did not provide a mathematical description of your problem, it is impossible to say what the correct BC should be. Do you perhaps want pr(2)=ur(2)-1 and pr(3)=ur(3)-1?

更多回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by