Error while using pdepe

3 次查看(过去 30 天)
Akshat Koolwal
Akshat Koolwal 2021-3-27
I am trying to solve a set of partial differential equations but the system returns the following error -:
Error using pdepe (line 293)
Spatial discretization has failed. Discretization supports only parabolic and elliptic equations, with flux term involving spatial derivative.
The code with the local functions is as follows -
clc;
clear all;
global k_10 k_20 E2_by_R E1_by_R h_1 h_2 v_r rho_r C_pr U_1 d_1 d_2 U_2 n d_3 rho_c C_pc v_c L rho_w C_pw ;
%% parameters
d_1 = 0.02; %m
d_2 = 0.024; %m
d_3 = 1; %m
n = 1200;
L = 6; %m
rho_r = 985; %kg/m3
rho_w = 7800; %kg/m3
rho_c = 998; %kg/m3
C_pr = 4.05; %kJ/kg*K
C_pw = 0.71; %kJ/kg*K
C_pc = 4.18; %kJ/kg*K
U_1 = 2.8; %kJ/m2*K*s
U_2 = 2.56; %kJ/m2*K*s
k_10 = 5.61e16; %/s
k_20 = 1.128e16; %/s
E1_by_R = 13477; %K
E2_by_R = 15290; %K
h_1 = 5.8e4; %kJ/kmol
h_2 = 1.8e4; %kJ/kmol
c_A0 = 2.85; %kmol/m3
T_r0 = 323; %K
T_c0 = 293; %K
q_r = 0.05;
q_c = 0.35;
f_r = n*pi*d_1*d_1/4;
f_c = pi*(d_3*d_3 - n*d_2*d_2)/4;
v_r = q_r/f_r; %m/s
v_c = q_c/f_c;
z = linspace(0,6,100);
t = linspace(0,1000,1000);
m = 0;
sol = pdepe(m,@pdefun,@pdeic,@pdebc,z,t);
y1 = sol(:,:,1);
y2 = sol(:,:,2);
y3 = sol(:,:,3);
y4 = sol(:,:,4);
y5 = sol(:,:,5);
function [c,f,s] = pdefun(z,t,y,dydz)
global k_10 k_20 E2_by_R E1_by_R h_1 h_2 v_r rho_r C_pr U_1 d_1 d_2 U_2 n d_3 rho_c C_pc v_c L rho_w C_pw;
c_A = y(1)
c_B = y(2)
T_r = y(3)
T_w = y(4)
T_c = y(5)
k_1 = k_10*exp(-E1_by_R/T_r);
k_2 = k_20*exp(-E2_by_R/T_r);
h_r = h_1*k_1*c_A+h_2*k_2*c_B;
s1 = -k_1*c_A;
s2 = (k_1*c_A-k_2*c_B);
s3 = (h_r/(rho_r*C_pr) - 4*U_1*(T_r-T_w)/(d_1*rho_r*C_pr));
s4 = 4*(d_1*U_1*(T_r-T_w)+d_2*U_2*(T_c-T_w))/(rho_w*C_pw*(d_2*d_2-d_1*d_1));
s5 = ((4*n*d_2*U_2*(T_w-T_c))/((d_3^2 - n*d_2^2)*rho_c*C_pc));
c = [1;1;1;1;1]
f = [-v_r*c_A;-v_r*c_B;-v_r*T_r;0;v_c*T_c]
s = [s1;s2;s3;s4;s5]
end
function u0 = pdeic(z)
u0 = [2.85;0;323;307.30;293];
end
function [pl,ql,pr,qr] = pdebc(zl,yl,zr,yr,t)
pl = [yl(1)-2.85;yl(2)-0;yl(3)-323;0;0];
pr = [0;0;0;0;yr(5)-293];
ql = [0;0;0;1;0];
qr = [0;0;0;1;0];
end

回答(1 个)

Ananya Tewari
Ananya Tewari 2021-3-30
The specified error generally arises when the initial conditions are inconsistent with boundary conditions. Try to rectify your code along with all the initial and boundary conditions.
Please refer to this answer for a solution
Refer to this doc to understand more about pdepe()

类别

Help CenterFile Exchange 中查找有关 Biological and Health Sciences 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by