function FedBatch3 clear, clc, format short g, format compact tspan = [0 1.]; % Range for the independent variable y0 = [24.; 0; 0; 0.8; 0]; % Initial values for the dependent variables tg=[]; Nx=[]; Ns=[];Np=[]; V=[]; PR=[]; [t,y]=ode45(@ODEfunIni,tspan,y0); disp([' time = ' int2str(t(end) ) ' Nx = ' num2str(y(end,1)) ' Ns = ' num2str(y(end,2)) ' Np = ' num2str(y(end,3)) ' V = ' num2str(y(end,4)) ' Pr= ' num2str(y(end,5))]); tspan=[t(end) t(end)+5]; y0=y(end,:); tg=[tg; t]; Nx=[Nx; y(:,1)]; Ns=[Ns; y(:,2)]; Np=[Np; y(:,3)];V= [V; y(:,4)]; PR=[PR; y(:,5)]; ncycle=10; for j=1:ncycle [t,y]=ode45(@ODEfunProc,tspan,y0); disp([' time = ' int2str(t(end) ) ' Nx = ' num2str(y(end,1)) ' Ns = ' num2str(y(end,2)) ' Np = ' num2str(y(end,3)) ' V = ' num2str(y(end,4)) ' Pr= ' num2str(y(end,5))]); tspan=[t(end) t(end)+1]; y0=y(end,:); tg=[tg; t]; Nx=[Nx; y(:,1)]; Ns=[Ns; y(:,2)]; Np=[Np; y(:,3)];V= [V; y(:,4)]; PR=[PR; y(:,5)]; [t,y]=ode45(@ODEfunHarv,tspan,y0); disp([' time = ' int2str(t(end) ) ' Nx = ' num2str(y(end,1)) ' Ns = ' num2str(y(end,2)) ' Np = ' num2str(y(end,3)) ' V = ' num2str(y(end,4)) ' Pr= ' num2str(y(end,5))]); tspan=[t(end) t(end)+5]; y0=y(end,:); tg=[tg; t]; Nx=[Nx; y(:,1)]; Ns=[Ns; y(:,2)]; Np=[Np; y(:,3)];V= [V; y(:,4)]; PR=[PR; y(:,5)]; end plot(tg,Nx./V,'-',tg,Ns./V,'.-',tg,Np./V,'*'); %plot(tg,Nx,'-',tg,Ns,'.-',tg,Np,'*',); legend('X','S','P'); xlabel(' Time (hr) '); ylabel('Concentration (g/L)'); pause plot(tg,PR) xlabel(' Time (hr) '); ylabel('Fermentation Products (g) '); return %- - - - - - - - - - - - - - - - - - - - - - function dYfuncvecdt = ODEfunIni(t,Yfuncvec); Nx = Yfuncvec(1); Ns = Yfuncvec(2); Np = Yfuncvec(3); V = Yfuncvec(4); PR = Yfuncvec(5); %Kinetic constant (1/hr) mum = .3; %Kinetic constant (g glucose/L) Ks = 1; %Kinetic constant (g glucose/L)^2 KI = 300; %(g cells/g glucose) Yxs = .4; %(g cells/g product) Yxp = .15; %Feed sustrate concentration, initialization stage (g glucose/L) S0 = 200; %Feed flow rate, initialization stage (L/hr) FI = .2; %Substrate concentration (g/L) S = Ns / V; %Cell concentration (g/L) X = Nx / V; %Production rate (g product/L-hr) munet = mum * S / (Ks + S + S ^ 2 / KI); %Product concentration (g/L) P = Np / V; %Feed cell concentration (g/L) X0 = 0; %Quantity of cells (g) dNxdt = FI * X0 + munet * V * X; %Quantity of glucose (g) dNsdt = FI * S0 + munet * V * X / Yxs; %Quntity of fermentation products (g) dNpdt = munet * V * X / Yxp; %Culture volume (L) dVdt = FI; %Production rate (g/hr) dPRdt = 0; dYfuncvecdt = [dNxdt; dNsdt; dNpdt; dVdt; dPRdt]; function dYfuncvecdt = ODEfunProc(t,Yfuncvec); Nx = Yfuncvec(1); Ns = Yfuncvec(2); Np = Yfuncvec(3); V = Yfuncvec(4); PR = Yfuncvec(5); %Kinetic constant (1/hr) mum = .3; %Kinetic constant (g glucose/L) Ks = 1; %Kinetic constant (g glucose/L)^2 KI = 300; %(g cells/g glucose) Yxs = .4; %(g cells/g product) Yxp = .15; %Feed sustrate cncentration (g glucose/L) SP = 200; %Feed flow rate, processing stage (L/hr) FP = .5; %Substrate concentration (g/L) S = Ns / V; %Cell concentration (g/L) X = Nx / V; %Production rate (g product/L-hr) munet = mum * S / (Ks + S + S ^ 2 / KI); %Product concentration (g/L) P = Np / V; %Feed cell concentration (g/L) X0 = 0; %Quantity of cells (g) dNxdt = munet * X * V; %Quantity of glucose (g) dNsdt = FP * SP - (munet * X * V / Yxs); %Quantity of fermentation products (g) dNpdt = munet * X * V / Yxp; %Culture volume (L) dVdt = FP; %Production rate (g/hr) dPRdt = 0; dYfuncvecdt = [dNxdt; dNsdt; dNpdt; dVdt; dPRdt]; function dYfuncvecdt = ODEfunHarv(t,Yfuncvec); Nx = Yfuncvec(1); Ns = Yfuncvec(2); Np = Yfuncvec(3); V = Yfuncvec(4); PR = Yfuncvec(5); %Outlet flow rate, harvesting stage (L/hr) FH = 2.5; %Kinetic constant (1/hr) mum = .3; %Kinetic constant (g glucose/L) Ks = 1; %Kinetic constant (g glucose/L)^2 KI = 300; %(g cells/g glucose) Yxs = .4; %(g cells/g product) Yxp = .15; %Substrate concentration (g/L) S = Ns / V; %Cell concentration (g/L) X = Nx / V; %Production rate (g product/L-hr) munet = mum * S / (Ks + S + S ^ 2 / KI); %Product concentration (g/L) P = Np / V; %Feed cell concentration (g/L) X0 = 0; %Quantity of cells (g) dNxdt = 0 - (FH * X) + munet * X * V; %Quantity of glucose (g) dNsdt = 0 - (FH * S) - (munet * X * V / Yxs); %Quantity of fermentation products (g) dNpdt = 0 - (FH * P) - (munet * X * V / Yxp); %Culture volume (L) dVdt = 0 - FH; %Production rate (g/hr) dPRdt = FH * P; dYfuncvecdt = [dNxdt; dNsdt; dNpdt; dVdt; dPRdt];