How to define stepchanges, variable BC for different timeintervalls using pdepe?
Show older comments
I am trying to define stepchanges of relative humidity at the boundary of a slab varying from 0.9 to 0.3 every 12 hours without any progress. The code is working without any issues for only one single BC but not otherwise. Any idea how I can get it? Thanks!
function parabolicmoisture
global tp a_v tend v_s delta exi
L=0.15;
k=0.028;
rho=156;
cp=990;
mu=4.25;
D=25*10^-6;
delta=D/mu;
v_s=17.28e-3;
exi=5/0.65;
a_v=(delta*v_s)/exi;
m = 0;
tp=24*3600;
tend=2*tp;
x = linspace(0,L,1000);
t = linspace(0,tend,2000);
sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,x,t);
RH = sol(:,:,1);
% A solution profile can also be illuminating.
plot(x,RH(end,:),'r--','LineWidth',2)
hold on
plot(x,RH(3*end/4,:),'b.-','LineWidth',1)
hold on
plot(x,RH(2*end/4,:),'k','LineWidth',1)
hold on
plot(x,RH(1*end/4,:),'*')
title(strcat('Solution at t = ', num2str(tend)))
legend('48h','36h','24h','12h')
xlabel('Distance x')
ylabel('RH (%)')
% %Plot surface temperature vs. time
% figure, plot(t,RH(:,1))
% title('Surface RH')
% xlabel('Time (s)')
% ylabel('RH (%)')
% --------------------------------------------------------------
function [c,f,s] = pdex1pde(x,t,u,DuDx)
global a_v v_s delta exi
c=1/a_v;
f = 1*DuDx;
s = 0;
% --------------------------------------------------------------
function u0 = pdex1ic(x)
u0 = 0;
% --------------------------------------------------------------
function [pl,ql,pr,qr] = pdex1bc(xl,ul,xr,ur,t)
global tend
%
if t<(tend/4)
pl = ul-0.9;
elseif t>=(tend/4) || t<tend/2
pl = ul-0.3;
elseif t>=tend/2 || t<3*tend/4
pl = ul-0.9;
elseif t>=3*tend/4
pl = ul-0.3;
end
ql = 0;
pr = ur;
qr = 0;
5 Comments
Torsten
on 19 Aug 2019
You don't have to use || , but &&.
Ali Karim
on 19 Aug 2019
Torsten
on 19 Aug 2019
Then restart pdepe at tend/4, tend/2 and 3*tend/4 with the new boundary condition.
Ali Karim
on 19 Aug 2019
Torsten
on 19 Aug 2019
Take a look at the last comment under
https://de.mathworks.com/matlabcentral/answers/451622-pdepe-boundary-condition-outputting-odd-results
Accepted Answer
More Answers (1)
Ali Karim
on 19 Aug 2019
0 votes
Categories
Find more on Language Support in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!