Why do I receive Error using pdepe (line 293) Spatial discretization has failed ?

조회 수: 35 (최근 30일)
Yaser
Yaser 2024년 11월 16일 14:46
편집: Torsten 2024년 11월 17일 11:58
I am trying to write a code to reproduce this model shown in the attached figure. C', A' and Phi' are u1, u2 and u3, respectively. Why do I receive Error using pdepe (line 293) Spatial discretization has failed ?
Here is my code.
clear, clc
global phio Z k T e B1 B2 B3 B4 B6 B7 B8 B9 B10 B11
B1 = 5.55E-03 ; B2 = 1E-04 ; B3 = 8.33E-03 ; B4 = 1E-04 ;
B6 = 9.04E-011 ; B7 = B6; B8 = B4 ; B9 = B3 ; B10 = B4 ;
B11 = B3 ; Z = 2 ; k = 1.38E-23 ; T = 300 ; e = 1.6E-19 ; phio = 1 ;
function [c,f,s] = Nernest(x,t,u,dudx)
global phio Z k T e B1 B2 B3 B4 B6 B7 B8 B9 B10 B11
c = [1; 1; 0];
f = [B1*u(1)*dudx(3)+B2*dudx(1) ; -B3*u(2)*dudx(3) + B4*dudx(2) ; -dudx(3) ] ;
s = [0; 0; B6*u(2)-B7*u(1)];
end
function u0 = Nernestic(x)
global phio Z k T e B1 B2 B3 B4 B6 B7 B8 B9 B10 B11
u0 = [1;1;phio*x];
end
function [pl,ql,pr,qr] = Nernestbc(xl,ul,xr,ur,t)
global phio Z k T e B1 B2 B3 B4 B6 B7 B8 B9 B10 B11
pl = [ 0 ; 0 ; ul(3) + k*T*log(Z*ul(1))/(Z*e*phio) ];
ql = [ 0 ; 0 ; 0 ];
pr = [ ur(1) ; ur(2) ; ur(3) - phio + (k*T*log(Z*ur(1))/(Z*e*phio)) ];
qr = [ 0 ; 0 ; 0 ];
end
x = linspace(0,1,25);
t = linspace(0,1,25);
m = 0;
sol = pdepe(m,@Nernest,@Nernestic,@Nernestbc,x,t);
u1 = sol(:,:,1);
u2 = sol(:,:,2);
u3 = sol(:,:,3);
plot(x,u3)
  댓글 수: 7
Yaser
Yaser 2024년 11월 17일 6:31
Thanks so much. I am so grateful to your answer 🙏.
Torsten
Torsten 2024년 11월 17일 11:50
편집: Torsten 2024년 11월 17일 11:51
I made a slight mistake, but the answer remains the same (the problem seems unsolvable with "pdepe"):
But I don't know how the boundary condition for C at x = 0, namely dC/dx = 0, could be set in the form
pl(1) + ql(1)*(B1*ul(1)*dudx(3)+B2*dudx(1)) = dudx(1)
where pl(1), ql(1) had to be chosen suitably.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics and Optimization에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by