Please help me solve this material balance
17 views (last 30 days)
Show older comments

8 Comments
Accepted Answer
Torsten
on 11 Sep 2023
Edited: Torsten
on 12 Sep 2023
This is a typical problem for MATLAB's "pdepe". So I suggest you use this integrator for partial differential equations.
9 Comments
Torsten
on 13 Sep 2023
x = [0.05 0.1 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.61];
t = [0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.17];
m = 0;
sol = pdepe(m, @pdefun, @icfun, @bcfun, x, t);
u1 = sol(:,:,1);
u2 = sol(:,:,2);
surf(x,t,u1)
title('u_1(x,t)')
xlabel('Distance x')
ylabel('Time t')
surf(x,t,u2)
title('u_2(x,t)')
xlabel('Distance x')
ylabel('Time t')
%% -------------- Local functions --------------
% Partial Differential Equation to solve
function [c, f, s] = pdefun(x, t, u, dudx)
D1= 0.00000190;
D2=0.0000198;
p=1;
v1=0.0011;
v2=0.0026;
r=0.000006;
k=0.082;
C=0.0205;
R=8.205;
T=305.15;
M=16;
e=0.036;
c = [1; 1];
f = [D1; p*D2].*dudx;
F = -r+k*(C-u(1));
J =(-(R*T*e)/M)+k*(C-u(1));
s = [F-v1*dudx(1); J-p*v2*dudx(2)];
end
% Initial Conditions
function u0 = icfun(x)
u0 = [x; 0];
end
% Boundary Conditions
function [pl, ql, pr, qr] = bcfun(xl, ul, xr, ur, t)
v1=0.0011;
v2=0.0026;
C=0.0205;
pl = [-v1*(ul(1)-C); -v2*(ul(2)-C)];
ql = [1; 1];
pr = [0; 0];
qr = [1; 1];
end
More Answers (1)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!







