pde mass transfer with reaction

3 次查看(过去 30 天)
Mr.DDWW
Mr.DDWW 2022-5-12
编辑: Torsten 2022-5-12
initial condition
(BC1)
(BC2)
I think S= lamda* theat^@ but I do not know how to write it in matlab. Can you please correct the BC's
%HERE IS MY CODE
clc;clear all;close all;
L = 1;
x = linspace(0,L,50);
t = linspace(0,1,50);
% t = [linspace(0,0.05,20), linspace(0.5,5,10)];
m = 1;
sol = pdepe(m,@heatpde,@heatic,@heatbc,x,t);
% colormap hot
sol1=1-sol;
figure(1)
surf(x,t,sol1);
% imagesc(x,t,sol)
% colorbar
% plot3(x,t,sol)
xlabel('y/b');
zlabel('(T-T_0)/(T_1-T_0)');
title('Fig 12.1-1'); grid on;
function [c,f,s] = heatpde(x,t,u,dudx)
c = 1;
f = dudx;
s = 0;
end
function u0 = heatic(x)
u0 = 0;
end
function [pl,ql,pr,qr] = heatbc(xl,ul,xr,ur,t)
pl = ul-1;
ql = 0;
pr = ur+1 ;
qr = 0;
end

回答(1 个)

Torsten
Torsten 2022-5-12
编辑:Torsten 2022-5-12
clc;clear all;close all;
L = 1;
x = linspace(0,L,50);
t = linspace(0,1,50);
% t = [linspace(0,0.05,20), linspace(0.5,5,10)];
m = 0;
lambda = 1.0;
sol = pdepe(m,@(x,t,u,dudx)heatpde(x,t,u,dudx,lambda),@heatic,@heatbc,x,t);
sol1 = 1-sol(:,:,1); % Don't know why you want to plot 1-theta instead of theta
% colormap hot
figure(1)
surf(x,t,sol1);
% imagesc(x,t,sol)
% colorbar
% plot3(x,t,sol)
xlabel('y/b');
zlabel('(T-T_0)/(T_1-T_0)');
title('Fig 12.1-1'); grid on;
function [c,f,s] = heatpde(x,t,u,dudx,lambda)
c = 1;
f = dudx;
s = -lambda^2*u;
end
function u0 = heatic(x)
u0 = 0;
end
function [pl,ql,pr,qr] = heatbc(xl,ul,xr,ur,t)
pl = 0.0;
ql = 1.0;
pr = ur-1 ;
qr = 0.0;
end

Community Treasure Hunt

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

Start Hunting!

Translated by