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 parabolicmoistureglobal 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 onplot(x,RH(3*end/4,:),'b.-','LineWidth',1)hold onplot(x,RH(2*end/4,:),'k','LineWidth',1)hold onplot(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 exic=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;
Best Answer