clear; clc; close all; %Simulate fed-batch operation for xx hours % Specify the simulation time tspan = [0 37]; % Specify values of control variables [Qin0; Xtin; Xvin; Qe; Sin; Fc; Fair; Tin; Tcin] u0 = [0.0; 0.0; 0.0; 0.0; 400; 40; 60000; 30; 15]; % Specify initial conditions [Xt; Xv; S; P; Oliq; Ogas; T; Tc; Vl; Gloss; MP] x0 = [0.1; 0.1; 50; 0; 0.0065; 0.305; 30; 20; 1000; 0.0; 0.0]; ux0 = [u0;x0]; % Simulate the bioreactor operation until the selected time tf [t,x] = ode15s(@EthanolModel,tspan,x0,[],ux0); N=length(t); for i=1:size(t,1) [~,mmax(i,:),Pmax(i,:),bP(i,:),m(i,:),Kd(i,:),Qin(i,:)] = EthanolModel(t(i,:),x(i,:),ux0); end % Loss of substrate at the end of the bioreactor operation-Cumulative ethanol mass produced Gloss = x(N,3)*x(N,9); %plots Results %Total and Viable Cellular Biomass figure(1) f=plot(t,x(:,1), t,x(:,2)); set(gca,'linewidth',1,'fontsize',12) set(f,'linewidth',3) grid title('Total & Viable Cellular Biomass') ylabel('Biomass concentration [g/L]','FontSize',12,'FontWeight', 'bold') xlabel('t [h]','FontSize', 12, 'FontWeight','bold') legend('Xt','Xv') %Substrate(S) and Production(P) concentration figure(2) f=plot(t,x(:,3),'y', t,x(:,4),'g'); set(gca,'linewidth',1,'fontsize',12) set(f,'linewidth',3) grid title('Substrate (S) & Product (P) concetration') ylabel('Concentration [g/L]','FontSize',12,'FontWeight', 'bold') xlabel('t [h]','FontSize', 12, 'FontWeight','bold') legend('S','P') % Dissolved and gaseous oxygen concentration figure(3) title('Dissolved and Gaseous oxygen concentration') hold on yyaxis left f=plot(t,x(:,5),'color',[0.3010 0.7450 0.9330]); set(gca,'linewidth',1,'fontsize',12) set(f,'linewidth',3) grid on ylabel('Oliq [g/L]','FontSize',12,'FontWeight', 'bold', 'color',[0.3010 0.7450 0.9330]) yyaxis right f=plot(t,x(:,6),'color',[250/255 128/255 114/255]); set(gca,'linewidth',1,'fontsize',12) set(f,'linewidth',3) grid on ylabel('Ogas [g/L]','FontSize',12,'FontWeight', 'bold','color',[250/255 128/255 114/255]) xlabel('t [h]','FontSize', 12, 'FontWeight','bold') legend('Oliq','Ogas') hold off % Bioreactor & Cooling jacket temperature figure(4) f=plot(t,x(:,7), t,x(:,8)); set(gca,'linewidth',1,'fontsize',12) set(f,'linewidth',3) grid title('Bioreactor & Cooling jacket temperature') ylabel('Temperature [oC]','FontSize',12,'FontWeight', 'bold') xlabel('t [h]','FontSize', 12, 'FontWeight','bold') legend('T','Tc') % Specific growth and death rate figure(5) f=plot(t,mmax, t,m, t,Kd); set(gca,'linewidth',1,'fontsize',12) set(f,'linewidth',3) grid title('Specific growth and death rate') ylabel('Specific growth and death rate [1/h]','FontSize',12,'FontWeight', 'bold') xlabel('t [h]','FontSize', 12, 'FontWeight','bold') legend('mimax','mi','Kd') % Production rate figure(6) title('Production rate') hold on yyaxis left f=plot(t,bP); set(gca,'linewidth',1,'fontsize',12) set(f,'linewidth',3) grid on ylabel('bP [1/h]','FontSize',12,'FontWeight', 'bold') yyaxis right f=plot(t,Pmax); set(gca,'linewidth',1,'fontsize',12) set(f,'linewidth',3) grid on ylabel('Pmax','FontSize',12,'FontWeight', 'bold') xlabel('t [h]','FontSize', 12, 'FontWeight','bold') legend('bP','Pmax') hold off % Culture Volume & Total substrate fed to the BR figure(7) title('Culture Volume & Total substrate fed to the BR') hold on yyaxis left f=plot(t,x(:,9)); set(gca,'linewidth',1,'fontsize',12) set(f,'linewidth',3) grid on ylabel('Vl [L]','FontSize',12,'FontWeight', 'bold') yyaxis right f=plot(t,x(:,10)); set(gca,'linewidth',1,'fontsize',12) set(f,'linewidth',3) grid on ylabel('Sf_cum [g]','FontSize',12,'FontWeight', 'bold') xlabel('t [h]','FontSize', 12, 'FontWeight','bold') legend('Vl','Sf_cum') hold off % Feeding Policy figure(8) title('Feeding policy') f=plot(t,Qin); set(gca,'linewidth',1,'fontsize',12) set(f,'linewidth',3) grid on ylabel('Qin [L/h]','FontSize',12,'FontWeight', 'bold') xlabel('t [h]','FontSize', 12, 'FontWeight','bold') legend('Qin')