% LEP: Eqn 18-34 coupled with segregation model
%

k=0.5;
cao=5;
n=2;
U=4;
L=4;
Da=10;
tspan = [0.01 14.]; % Range for the independent variable
y0 = [0;0]; % Initial values for the dependent variables 
[t y]=ode45(@(t,y)ODEfun(t,y,k,cao,n,U,L,Da),tspan,y0);
plot(t,y(:,1),t,y(:,2),'LineWidth',1.5)
xlabel('time(mins)')
ylabel('Conversion')
leg=legend('X','X_{Seg}');
leg.ItemTokenSize=[10,10];
axis([0 14 0 1])
title(' Conversion Profile')
grid on

%

function dYfuncvecdt = ODEfun(t,Yfuncvec,k,cao,n,U,L,Da); 
X = Yfuncvec(1); 
Xseg = Yfuncvec(2); 
Per = U*L/Da;
Phi = t*U/L;
dXdt=k*(cao^n)*(1 - X)^n/cao;
dXsegdt=X*exp(-((1 - Phi)^2)/(4*Phi/Per))/(2*sqrt(3.14*Phi/Per));
dYfuncvecdt = [dXdt; dXsegdt]; 
end

%