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

35 vues (au cours des 30 derniers jours)
Yaser
Yaser le 16 Nov 2024 à 14:46
Modifié(e) : Torsten le 17 Nov 2024 à 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 commentaires
Yaser
Yaser le 17 Nov 2024 à 6:31
Thanks so much. I am so grateful to your answer 🙏.
Torsten
Torsten le 17 Nov 2024 à 11:50
Modifié(e) : Torsten le 17 Nov 2024 à 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.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Mathematics and Optimization dans Help Center et File Exchange

Produits


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by