% THE THERMODYNAMICS-BASED BLACK-BOX MODEL OF MICROBIAL REACTIONS AND MASS % TRANSFER-BASED MODEL OF A LARGE-SCALE BUBBLE COLUMN BIOREACTOR FOR SYNGAS % FERMENTATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % By: % Eduardo F. Almeida Benalcázar, de Ecuador pa'l mundo % Henk Noorman % Rubens Maciel Filho % John A. Posada Duque % year 2019 % This code simulates the fermentation of the 3:1 H2/CO2 mixture. function BC_H2 % This subroutine calls the optimization function to solve the systems of % equations for a determined range of H2 dissolved concentrations (CH2). % After all the CH2 (or C_D) range is covered, results stored in matrix % 'FF', which is stored in a '.mat' file with a customizable name. % The matrix FF is then used to estimate the C_D concentration profiles % along the height of the liquid column. Here only one variables is % obtained from this search, the one that saves the mean-log C_D where the % threshold is first reached at the top of the liquid column. % Once the operation point has been found considering the location of the % threshold, it is used to calculate the process energy requirements. clear all close all global R Temp MWw MWet MWX pHo HT H Ptop Feed VR T Pmix Yet... F_mlM qH2 kLa vsGC P_ml Cb Cml Ct DH Nmix L_et L_w L_mix MTC_CO2... MTC_H2 EG DG01_Cat_et_H2 FL_out VL Pb Cet Rates K... Umax_H2_et YXH2_et mS_et_H2 D D_O2 HS KH2 y % Input variables Temp = 37 + 273.15; % Temperature, K Ptop = 1.5; % Top pressure, atm Dil = 0; % gas dilution percentage, % Cet_i = 45; % Maximum allowed ethanol concentration, g/L H = 20; % Vessel height, m K = 1.0; % Mass transfer coefficient multiplying factor EG = 0.15; % Gas hold-up pcv = [Temp, Ptop, Dil, Cet_i, H, K, EG]; % Vector saved with the input parameters a = 'H2CO2_0.mat'; % Name for FF matrix storage % Other fixed & complementary parameters CH2_max = 2; % Maximum H2 concentration for range, mol/m3 R = 0.008314; % Ideal gas constant, kJ/mol/K, for Pa*m3/mol/K multiply by 1000 MWw = 18.015; % Water mol weight, g/mol MWet = 46.069; % Ethanol mol weight, g/mol MWX = 25.25; % Microbial biomass mol weight, g/mol pHo = 5.5; % Extracellular pH VR = 700; % Reactor total volume, m^3 T = (VR*4/(3.1416*H))^(1/2); % Reactor diameter, m HT = H/T; % reactor asepct ratio Feed = [0.00001, (3/4)*(1 - Dil/100), (1/4)*(1 - Dil/100), Dil/100]; % Composition of feed, % mol VL = VR*0.8*(1 - EG); % Volume of liquid in bioreactor, m^3 g = 9.8; % Gravity's acceleration dens = 1000; % fermentation broth density, kg/m^3 % Tank dimensions Hmix = 0.8*H; % Height of g-l mixture, m AT = 3.1416*T^2/4; % Tank's cross-sectional area, m^2 Pb = Ptop + 9800*Hmix/101325; % Bottom pressure, atm P_ml = (Pb - Ptop)/log(Pb/Ptop); % Estimation of VLE data as function of temperature YY = NRTL_VLE(Temp); % Kinetic parameters KH2 = 0.04; % mM % Latent heats of vaporization, kJ/mol C = [5.21E7, 0.3199, -0.212, 0.25795, 647.13; 5.69E7, 0.3359, 0 , 0 , 513.92]; L_w = C(1,1)*(1 - Temp/C(1,5))^(C(1,2) + C(1,3)*Temp/C(1,5) + C(1,4)*(Temp/C(1,5))^2); % For water, J/kmol L_w = L_w/1e6; % kJ/mol L_et = C(2,1)*(1 - Temp/C(2,5))^(C(2,2) + C(2,3)*Temp/C(2,5) + C(2,4)*(Temp/C(2,5))^2); % For ethanol, J/kmol L_et = L_et/1e6; % kJ/mol % Film diffusivities of gas into water, cm^2/s MV = [30.7, 14.3, 34]; MV_O2 = 25.6; D = 0.000000074.*(2.6*MWw).^0.5*(Temp)./(0.7.*MV.^0.6); % CO H2 CO2 D_O2 = 0.000000074.*(2.6*MWw).^0.5*(Temp)./(0.7.*MV_O2.^0.6); % Henry's coefficients [H_CO, H_H2, H_CO2] = Henry; HS = [H_CO, H_H2, H_CO2]; % Empty vectors for results storage FF = []; % Reactor localized data ch2 = []; % CO concentration range % Extra auxiliary variables w = 0; % Indicator of iteration number hh = 1; % Loop breaker initializer % Successful initial guesses % X, F_in, F_out, Y_H2_out, Y_CO2_out, CCO2, Cet, FL_out x0 = [ 1.516 456 475 0.7188 0.2396 13.178 0.0331 0.001]; % The model unknowns are: % C_x: biomass concentration (Cmol_x/m^3) % F_in: Gas inflow rate (mol/s) % F_out: Gas outflow rate (mol/s) % Y_H2_out: H2 mol fraction in offgas (-) % Y_CO2_out: CO2 mol fraction in offgas (-) % CCO2: Mean-log CO2 concentration in the liquid phase (mol/m^3) % FL_out: Liquid volumetric outflow rate (m^3/s) % Iteration loop, solves bioreactor operation at 400 different values % of C_D for CH2 = logspace(log10(CH2_max),log10(1e-3),400) % Lower and upper bounds lb = [1e-10, 1e-10, 1e-10, 1e-10, 1e-10, 1e-10, 1/MWet, 0]; ub = [10000, 10000, 10000, Feed(2), Feed(3), 5000, Cet_i/MWet, 3]; % Two sets of options, one for each optimization method. sqp is used to % stabilize value, although it does not bring a solution for its own. % Interior-point is used to take sqp off from 'stubborn' answer, sort % of like shaking the table a bit so the little balls fall into the % holes. options1 = optimset('Display','off',... 'Algorithm','sqp','ScaleProblem','obj-and-constr','MaxFunEval',1000); options2 = optimset('Display','off',... 'Algorithm','interior-point','ScaleProblem','obj-and-constr','MaxFunEval',1000); % % First optimization, if this one fails, then optimizations in % series will try to stabilize the solution using the two % aforementioned optimization algorithms [f,fval,exitflag] = fmincon(@(x) solving_BC(x,KH2,AT,Pb,CH2,YY),... x0,[],[],[],[],lb,ub,@(x) mycon2(x,CH2),options1); x0 = f; % Loop with a maximum of 10 sets of shake-and-point optimizations. Used % to help convergence. while exitflag == -2 [f] = fmincon(@(x)... solving_BC(x,KH2,AT,Pb,CH2,YY),... x0,[],[],[],[],lb,ub,@(x) mycon2(x,CH2),options2); x0 = f; [f,fval,exitflag] = fmincon(@(x)... solving_BC(x,KH2,AT,Pb,CH2,YY),... x0,[],[],[],[],lb,ub,@(x) mycon2(x,CH2),options1); x0 = f; hh = hh + 1; if hh == 2 break end end % Data storage. A conditions is used to store only data that comes % derived from solved optimizations. if exitflag == 1 % Definition of other variables to store H2_cons = (f(2)*Feed(2) - f(3)*f(4))*100/(f(2)*Feed(2)); % Gas utilization, % Pro_et = f(1)*Rates(4)/3600; % Ethanol volumetric productivity, mol/m^3/s et_l = f(7)*1000*f(8)/(f(1)*Rates(4)*VL/3600); % Portion of ethanol produced that leaves the bioreactor along the liquid phase, dimensionless et_g = Yet*Pmix*f(3)/(Ptop*f(1)*Rates(4)*VL/3600); % Portion of ethanol produced that leaves the bioreactor along the gas phase, dimensionless H2_used = kLa(2)*(Cml(2) - CH2)*VL; % H2 consumed, mol/s H2_fed = f(2)*Feed(2); % H2 fed, mol/s H2_out = f(3)*f(4); % H2 unconsumed, mol/s CO2_used = kLa(3)*(Cml(3) - f(6))*VL; % CO2 consumed, mol/s CO2_fed = f(2)*Feed(3); % CO2 fed, mol/s CO2_out = f(3)*f(5); % CO2 unconsumed, mol/s % Variables storage FF = [FF; f,... % 1: X, mol/m^3; % 2: F_in, mol/s; % 3: F_out, mol/s; % 4: Y_H2_out 5: Y_CO2_out; 6: CCO2; 7: Cet; 8: FL_out Pro_et,... % 9: Ethanol productivity, mol/m^3/s et_l,... % 10: Fraction of ethanol through the liquid, mol/mol et_g,... % 11: Fraction of ethanol through the gas, mol/mol H2_cons,... % 12: H2 consumption, % H2_used,... % 13: H2 used, mol/s H2_fed,... % 14: H2 fed to system, mol/s H2_out,... % 15: H2 Un-used, mol/s CO2_used,... % 16: CO2 used, mol/s CO2_fed,... % 17: CO2 fed to system, mol/s CO2_out,... % 18: CO2 UN-used, mol/s Rates(7),... % 19: biomass growth rate, h^-1 Rates(2),... % 20: H2 consumption rate, mol_H2/Cmol_x/h Rates(8),... % 21: CO2 consumption rate, mol_CO2/Cmol_x/h F_mlM,... % 22: Mean log gas flow rate, mol/s qH2,... % 23: molH2/Cmol_x/h kLa(2),... % 24: H2 kLa, 1/s kLa(3),... % 25: CO2 kLa, 1/s vsGC,... % 26: Superficial gas velocity, P corrected, m/s P_ml,... % 27: Mean log pressure, atm Pb,... % 28: Bottom pressure, atm Cb(2),... % 29: Saturation C_H2 @ reactor bottom, m^3/s Cml(2),... % 30: Saturation C_H2 @ mean log pressure, m^3/s Ct(2),... % 31: Saturation C_H2 @ reactor top, m^3/s Cb(3),... % 32: Saturation C_CO2 @ reactor bottom, m^3/s Cml(3),... % 33: Saturation C_CO2 @ mean log pressure, m^3/s Ct(3),... % 34: Saturation C_CO2 @ reactor top, m^3/s MTC_H2,... % 35: H2 mass transfer capacity, mol/m^3/s MTC_CO2,... % 36: CO2 mass transfer capacity, mol/m^3/s DH,... % 37: Enthalpy of reaction, kJ/mol_e-donor Nmix,... % 38: Water-ethanol rate of evaporation, mol/s Pmix,... % 39: Ethanol/water mix partial pressure, atm Yet,... % 40: Ethanol fraction in Water/ethanol vapor mix, mol/mol L_mix,... % 41: Latent heat of etOH/water mix, kJ/mol DG01_Cat_et_H2,... % 42: Gibbs free energy change in catabolic reaction @ physiological conditions, kJ/mol_{e-donor} Umax_H2_et,... % 43: U_max according to qS_max YXH2_et... % 44: Biomass yield, Cmol_x/mol_{carbon source} mS_et_H2,... % 45: Maintenance coefficient, mol_D/Cmol_x/h Rates(9)]; % 46: Specific rate of water consumption, mol_water/Cmol_x/h ch2 = [ch2 CH2]; save(a,'FF','ch2','pcv'); x0 = f; % Optimization for the next CH2 value takes this solution as initial guess. Improves convergence stability end w = w + 1; % Iteration counter hh = 1; % Optimization loop reset % Display message di = [' Iteration: ',num2str(w),'; exitflag: ',num2str(exitflag)]; disp(di) end %% Gas concentration profiles thres = size(ch2,2); % value used if no threshold were found for iii = 1:size(ch2,2) % Interpolation of parameters from stored matrix FF Ced_d = ch2(iii); % Mean log C_D, mol/m^3 Pmix = interp1(ch2,FF(:,39),Ced_d,'pchip')*101325; % Partial pressure of ethanol-water mix, Pa Fin = interp1(ch2,FF(:,2),Ced_d,'pchip')/(1 - Pmix/(Pb*101325)); % Gas inflow rate, mol/s yH2_i = Feed(2); % H2 mol fraction at reactor inlet yCO2_i = Feed(3); % CO2 mol fraction at reactor inlet cet = interp1(ch2,FF(:,7),Ced_d,'pchip'); % Ethanol concentration in the liquid, mol/L xx = interp1(ch2,FF(:,1),Ced_d,'pchip'); % Biomass concentration, mol/m^3 CCO2 = interp1(ch2,FF(:,6),Ced_d,'pchip'); % CO2 concentration @ top of bioreactor, mol/m^3 % Discretization of height and hydrostatic pressure nn = 9; % Number of points in the y-axis discretization HH = Hmix.*(1 - linspace(0,1,nn + 1)); % Discretized height, m PP = Ptop*101325 + g.*dens.*HH; % Discretized pressure, Pa % Solving of concentration profiles by correcting variable F_in for % mean log C_H2 to fit with the top and bottom C_H2 values. % The corrected value of F_in is not used for further calculations as % it deviates by 3.5% from the un-corrected value. To check this, take % the corrected value from variable 'yyy'. opt3 = optimoptions(@fmincon,'Display','off',... 'Algorithm','interior-point','ScaleProblem','obj-and-constr'); opt4 = optimoptions(@fmincon,'Display','off',... 'Algorithm','sqp','ScaleProblem','obj-and-constr'); x0 = Fin; % Initial guess for gas inflow rate yyy = fmincon(@(x)... iterat_H2(x,Ced_d,CCO2,nn,HH,PP,yH2_i,yCO2_i,Pb,Pmix,AT,xx,K,iii),... x0,[],[],[],[],1e-20,[],@(x) consFin(x,nn,Ced_d),opt3); x0 = yyy; yyy = fmincon(@(x)... iterat_H2(x,Ced_d,CCO2,nn,HH,PP,yH2_i,yCO2_i,Pb,Pmix,AT,xx,K,iii),... x0,[],[],[],[],1e-20,[],@(x) consFin(x,nn,Ced_d),opt4); % Estimation of DG_cat at the top of fermentor to check if threshold % was reached dgcat = Cat_H2(y(nn)/HS(2),y(2*nn)/HS(3),cet,Temp); % Is DG_cat threshold? if dgcat(1) > -15 && dgcat(1) < -13 thres = iii; break end end %% Selection of operation points for H2/CO2 fermentation % Operation point is defined by the H2 threshold concentration and the % biomass concentration limit lim_x = find(FF(:,1).*25.25./1000 > 10,1); op = min([lim_x,thres - 1]); % Segregating data for operation point FF_op = FF(op,:); % Load relevant data from FF_op vector F_in = FF_op(2); % Gas inflow rate, mol/s F_out = FF_op(3); % Gas outflow rate, mol/s Y_ed_out = FF_op(4); % H2 mol fraction in offgas Y_CO2_out = FF_op(5); % CO2 mol fraction in offgas Cet = FF_op(7); % Ethanol concentration, mol/L FL_out = FF_op(8); % Liquid outflow rate, m^3/s Pro_et = FF_op(9); % Ethanol volumetric productivity, mol/m^3/s et_l = FF_op(10); % Fraction of ethanol through the liquid, mol/mol et_g = FF_op(11); % Fraction of ethanol through the gas, mol/mol ed_cons = FF_op(12); % H2 utilization per pass through bioreactor, % qH2 = FF_op(23); % Specific CO uptake rate, mol_CO/Cmol_x/h Pb = FF_op(28); % Bottom pressure, atm Pmix = FF_op(39); % Ethanol/water mix partial pressure, atm Yet = FF_op(40); % Ethanol fraction in Water/ethanol vapor mix, mol/mol %% ENERGY BALANCES % Inflow compression power, kW gama_i = 1.4*Feed(2) + 1.3*Feed(3); % Heat capacity ratio for gas feed V_1 = F_in*(ed_cons/100)*R*1000*Temp/(101325); % Volumetric gas inflow rate, m^3/s (takes only the amount of gas needed considering the offgas recycle) P_comp_i = ((gama_i./(gama_i - 1))*(101325).*V_1.*((Pb/1).^((gama_i - 1)./gama_i) - 1))./(0.7.*1e3); % kW P_comp_i1 = P_comp_i./(MWet.*Pro_et.*VL); % Specific power requirement, MJ/kg_ethanol % Outflow compression power, kW gama_o = 1.4.*Y_ed_out + 1.300.*Y_CO2_out + 1.13.*(Yet.*Pmix./Ptop) + 1.330.*((1 - Yet).*Pmix./Ptop); % Heat capacity ratio for offgas V_out = F_out.*R.*1000.*Temp./(Ptop.*101325); % Volumetric gas inflow rate, m^3/s P_comp = ((gama_o./(gama_o - 1)).*(Ptop*101325).*V_out.*((Pb/Ptop).^((gama_o - 1)./gama_o) - 1))./(0.7.*1e3); % kW P_comp_1 = P_comp./(MWet.*Pro_et.*VL); % Specific power requirement, MJ/kg_ethanol % Water/ethanol condensation from offgas T_c = 273.15 - 6; % Condensation temperature, K L_w = C(1,1)*(1 - T_c/C(1,5))^(C(1,2) + C(1,3)*T_c/C(1,5) + C(1,4)*(T_c/C(1,5))^2); % J/kmol L_w = L_w/1e6; L_et = C(2,1)*(1 - T_c/C(2,5))^(C(2,2) + C(2,3)*T_c/C(2,5) + C(2,4)*(T_c/C(2,5))^2); % J/kmol L_et = L_et/1e6; L_cond = L_w.*(1 - Yet) + L_et.*Yet; % Latent heat of water/ethanol mixture condensation, J/kmol P_cond = L_cond.*F_out.*(Pmix./Ptop).*0.21; % kW P_cond_1 = P_cond./(MWet.*Pro_et.*VL); % Specific power requirement, MJ/kg_ethanol % Product distillation, kW Xw_g = Yet.*MWet./(Yet.*MWet + (1 - Yet).*MWw); % Conversion from mol fractions to mass fractions Xw_l = Cet.*MWet./1000; P_dis_g = 22.194.*(Xw_g.*100).^(-0.794).*et_g; % Specific power requirement for condensed vapors distillation, MJ/kg_ethanol P_dis_l = 22.194.*(Xw_l.*100).^(-0.794).*et_l; % Specific power requirement for fermentation broth distillation, MJ/kg_ethanol % Total power requirements PT = P_comp_i1 + P_comp_1 + P_cond_1 + P_dis_g + P_dis_l; % Total electric energy, MJ/kg_et % Display of final message di1 = ['Ethanol volumetric productivity: ',num2str(Pro_et*MWet*3.6),' g/(L*h)']; di2 = ['Gas utlization: ',num2str(ed_cons),' %']; di3 = ['Total power requirements: ',num2str(PT),' MJ/kg_et']; disp(di1) disp(di2) disp(di3) end %% Makes the concentration profile match with the mean log C_H2 by % adjusting the value of F_in function yyy = iterat_H2(x,Ced_d,CCO2,nn,HH,PP,yH2_i,yCO2_i,Pb,Pmix,AT,xx,K,iii) global y % Initial value taken by F_in F_i = x; opt1 = optimoptions(@fmincon,'Display','off','Algorithm','sqp',... 'ScaleProblem','obj-and-constr'); opt2 = optimoptions(@fmincon,'Display','off','Algorithm','interior-point',... 'ScaleProblem','obj-and-constr'); % Condition put to improve the convergence and solving time by making x0 % to take the last solved concentration profile if iii == 1 x0 = [Ced_d.*ones(nn,1); % C_H2, mM CCO2.*ones(nn,1)]; % C_CO2, mM else x0 = y; end lb = ones(size(x0)).*1e-20; % Avoids concentrations getting negative values y = fmincon(@(x)... pro_H2(x),x0,[],[],[],[],lb,[],... @(x) cons(x,nn,HH,PP,F_i,yH2_i,yCO2_i,Pb,Pmix,AT,xx,K),opt2); x0 = y; y = fmincon(@(x)... pro_H2(x),x0,[],[],[],[],lb,[],... @(x) cons(x,nn,HH,PP,F_i,yH2_i,yCO2_i,Pb,Pmix,AT,xx,K),opt1); % Optimization aimed at minimizing this value yyy = abs((y(1) - y(nn))/log(y(1)/y(nn)) - Ced_d); % Does mean-log C_D agree with top and bottom C_D? end %% Constraints for F_in correction function [c,ceq] = consFin(x,nn,Ced_d) global y c = []; ceq = real((y(1) - y(nn))/log(y(1)/y(nn)) - Ced_d); % Does mean-log C_D agree with top and bottom C_D? here used as non-linear equality end %% Minimization of CH2 at the top of reactor function f = pro_H2(x) % Minimizes the first value of C_D. It is just a trick to use fmincon as % a solver for the system of non-linear equations. fmincon brings the % advantage of constaining the solutions to positive values f = x(1); end %% Constraints for finding concentration profiles. Mass balances. function [c,ceq] = cons(x,nn,HH,PP,F_i,yH2_i,yCO2_i,Pb,Pmix,AT,xx,K) global R Temp KH2 qSmax HS D D_O2 % Construction of the mass balance equations at the different compartments c = []; ceq = zeros(size(x)); for i = 1:nn % Calculation of mean-log gas flow rates in the discretized y-axis if i == 1 % Equations for first point in 'nn' (initial conditions) @ reactor % bottom pml = (PP(i + 1) - PP(i))/log(PP(i + 1)/PP(i)); % Mean log pressure for mass transfer calculations fml = F_i; % Gas flow rate, mol/s FH2 = fml*yH2_i*(1 - Pmix/(Pb*101325)); % H2 gas flow rate, mol/s FCO2 = fml*yCO2_i*(1 - Pmix/(Pb*101325)); % CO2 gas flow rate, mol/s else % Equations for bulk pml = (PP(i + 1) - PP(i))/log(PP(i + 1)/PP(i)); FH2 = FH2 - MTC_H2/3600; FCO2 = FCO2 - MTC_CO2/3600; fml = abs((FH2 + FCO2)./(1 - Pmix/pml)); % Written in absolute value because when negative it crashes the solver. With abs() the solver works end VL = AT*(HH(i) - HH(i + 1)); % Volume of liquid phase, m^3 Vml = fml*R*1000*Temp/pml; % Volumetric gas flow rate, m^3/s V0ml = Vml*pml*273.15/(Temp*101325); % Volumetric gas flow rate @ standard conditions, m^3/s vsG0 = V0ml/AT; % superficial gas velocity @ standard conditions, m/s vsGC = vsG0*101325*log(PP(i + 1)/PP(i))/(PP(i + 1) - PP(i)); % Pressure-corrected superficial gas velocity, m/s kLa_H2 = K*(0.32.*vsGC.^0.7).*(1.022.^(Temp - 293.15)).*(D(2)./D_O2)*3600; % H2 mass tranfer coeffcient, s^-1 kLa_CO2 = K*(0.32.*vsGC.^0.7).*(1.022.^(Temp - 293.15)).*(D(3)./D_O2)*3600; % CO2 mass tranfer coeffcient, s^-1 CH2_s = (pml/101325)*(HS(2))*(FH2/fml); % H2 saturation concentration, mol/m^3 CCO2_s = (pml/101325)*(HS(3))*(FCO2/fml); % CO2 saturation concentration, mol/m^3 MTC_H2 = kLa_H2*(CH2_s - x(i))*VL; % H2 mass tranfer rate, mol/h MTC_CO2 = kLa_CO2*(CCO2_s - x(i + nn))*VL; % CO2 mass tranfer rate, mol/h qH2 = -qSmax*x(i)/(KH2 + x(i)); % Specific H2 uptake rate, mol/Cmol_x/h qCO2 = qH2/3; % Specific CO2 uptake rate, mol/Cmol_x/h RH2 = qH2*xx*VL; % H2 consumption rate by bacteria, mol/h RCO2 = qCO2*xx*VL; % CO2 consumption rate by bacteria, mol/h ceq(i) = real(MTC_H2 + RH2); % H2 balance, in units mol/h ceq(i + nn) = real(MTC_CO2 + RCO2); % CO2 balance, in units mol/h end end %% Mass transfer-based model of the largescale syngas fermentor function f = solving_BC(x,KH2,AT,Pb,CH2,YY) % This is the function in which the mass balances around the fermentor are % defined. It mixes mass transfer with the thermodynamic model of bacteria. global R Temp MWet Ptop Feed PB Rates Pmix kLa Cml Yet EG MWw qH2... vsGC Cb Ct DH Nmix L_et L_w L_mix MTC_CO2 MTC_H2 Cet F_mlM VL... FL_out Xet K qSmax D D_O2 HS % Collection of unknowns X = x(1); % Biomass concentration, mol/m^3 F_in = x(2); % Gas inflow rate, mol/s F_out = x(3); % Gas outflow rate, mol/s Y_H2_out = x(4); % H2 mol fraction in offgas, mol/mol Y_CO2_out = x(5); % CO2 mol fraction in offgas, mol/mol CCO2 = x(6); % CO2 mean-log concentration in the liquid phase, mol/m^3 Cet = x(7); % Ethanol concentration in liquid phase, mol/L FL_out = x(8); % Ethanol concentration in liquid phase, mol/L % Interpolation of VLE data from YY matrix Xet = Cet*MWet/1000; % Conversion of Cet, from mol/L to x w/w Xet = Xet*MWw/(MWet + Xet*(MWw - MWet)); % X ethanol, mol/mol Yet = interp1(YY(:,1),YY(:,2),Xet,'pchip'); % Mixture partial pressure, atm Pmix = interp1(YY(:,1),YY(:,3),Xet,'pchip')/101.325; % Y ethanol in vapor mixture, mol/mol % Retrival of rates from function micro CCO = 1e-7; YYY = micro(CCO/HS(1),CH2/HS(2),CCO2/HS(3),Cet); Met = YYY(1,:); qSmax = YYY(3,3); % General and specific rates, gas mass balances qH2 = -qSmax*(CH2./(KH2 + CH2)); % Without consiering maintenance!!!!!!!!!!!!! Rates = qH2.*Met./(Met(2)); % Rates, mol_i/Cmol_X/h % Heat of reaction DH_st = Met(13)/-Met(2); % Entalphy of reaction, kJ/mol_e-donor dT = [Temp,25 + 273.15]; Cps = cp(dT); % Cps = [Cp_CO,Cp_H2,Cp_etl,Cp_X,Cp_CO2,Cp_wl]; DH = DH_st + Cps(1)*Met(1)/Met(2) + Cps(2)*Met(2)/Met(2) +... Cps(3)*Met(4)/Met(2) + Cps(4)*Met(7)/Met(2) +... Cps(5)*Met(8)/Met(2) + Cps(6)*Met(9)/Met(2); % mean log mixing and mass transfer properties vsGC = (EG/0.6)^(1/0.7); vsG0 = vsGC/(log((Pb/Ptop))/(Pb - Ptop)); F_mlV0 = vsG0*AT; Pml = (Pb - Ptop)/log(Pb/Ptop); F_mlV = F_mlV0*101325*Temp/(Pml*273.15*101325); F_mlM = F_mlV*Pml*101328/(R*1000*Temp); Nmix = Pmix*F_out/Ptop; % Ethanol/water mixture evaporated, mol/s L_mix = 7.27495*(Cet*MWet/1000 + 0.010617)*L_et +... (1 - 7.27495*(Cet*MWet/1000 + 0.010617))*L_w; % latent heat of etOH/water mix % Partial pressures and gas composition at reactor inlet/outlet PB = (Pb - Pmix).*Feed(1:3); PT = Ptop.*[1e-10 Y_H2_out Y_CO2_out]; % Saturation concentrations, mol/m^3 Ct = PT.*HS; Cb = PB.*HS; Cml = (Cb - Ct)./log(Cb./Ct); % kLa, 1/s kLa_O2_20 = K*0.32*vsGC^0.7; kLa_O2 = kLa_O2_20*1.022^(Temp - 293.15); kLa = kLa_O2.*D./D_O2; MTC_H2 = kLa(2)*(Cml(2) - CH2); % H2 MTC, mol/m^3/s MTC_CO2 = kLa(3)*(Cml(3) - CCO2); % H2 MTC, mol/m^3/s % Objective function: ethanol exit along the liquid outflow f = Cet*1000*FL_out/(X*Rates(4)*VL/3600); end %% Optimization constraints function [c,ceq] = mycon2(x,CH2) global Rates Pmix kLa Cml Yet VL Ptop... Feed F_mlM Pb FL_out Cet DG01_Cat_et_H2 Xet X = x(1); % Biomass concentration, mol/m^3 F_in = x(2); % Gas inflow rate, mol/s F_out = x(3); % Gas outflow rate, mol/s Y_H2_out = x(4); Y_CO2_out = x(5); CCO2 = x(6); Cet = x(7); FL_out = x(8); % Inequalities c(1) = DG01_Cat_et_H2; % Guarantees thermodynamic feasibility c(2) = -FL_out; % Avoids liquid outflow rate going negative c(3) = Rates(9)*X*VL/3600 - FL_out*1e6*(1 - Xet)/18 -... % Water balance Pmix*(1 - Yet)*F_out/Ptop; c(4) = (Rates(7)/3600)*VL - FL_out; % Cells production rate does not surpass liquid outflow's capacity to remove them % Equalities ceq(1) = kLa(2)*(Cml(2) - CH2) + Rates(2)*X/3600; % H2 at liquid ceq(2) = F_in*Feed(2) - F_out*Y_H2_out... - kLa(2)*(Cml(2) - CH2)*VL; % H2 at gas ceq(3) = kLa(3)*(Cml(3) - CCO2) + Rates(8)*X/3600; % CO2 at liquid ceq(4) = F_in*Feed(3) - F_out*Y_CO2_out... - kLa(3)*(Cml(3) - CCO2)*VL; % CO2 at gas ceq(5) = X*Rates(4)*VL/3600 - ... Yet*Pmix*F_out/Ptop - (Cet*1000)*FL_out; % Ethanol at both ceq(6) = 1 - Y_H2_out - Y_CO2_out - Pmix/Ptop... - Feed(4)*F_in/F_out; % Gas mol fractions summation ceq(7) = F_mlM - abs((F_out - F_in/(1 - Pmix/Pb)))/... abs(log(F_out/(F_in/(1 - Pmix/Pb)))); % Gas flow rate, mean log, mol/s end %% Heat capacities function [Cps] = cp(dT) % Calculates heat capacities of substances involved in metabolism T1 = dT(1); T2 = dT(2); % Constants % etOH_l w_l etOH_g C1 = [1.0264e5, 2.7637e5, 0.492e5]; C2 = [-1.3963e2, -2.0901e3, 1.4577e5]; C3 = [-3.0341e-2, 8.1250e0, 1.6628e3]; C4 = [2.0386e-3, -1.4116e-2, 0.9390e5]; C5 = [0, 9.3701e-6, 744.7]; % Gases Cp % From Perry's handbook Cp_H2 = (6.62 + 0.00081*T2 +... 6.62 + 0.00081*T1)*(4.184e-3)/2; % kJ/K/mol Cp_CO2 = (10.34 + 0.00274.*T2 - 195500/T2.^2 + ... 10.34 + 0.00274.*T1 - 195500/T1.^2)*(4.184e-3)/2; % kJ/K/mol Cp_CO = (6.60 + 0.0012*T2 +... 6.60 + 0.0012*T1)*(4.184e-3)/2; % kJ/K/mol Cp_etl = (C1(1) + C2(1)*T2 + C3(1)*T2^2 + C4(1)*T2^3 + C5(1)*T2^4 +... C1(1) + C2(1)*T1 + C3(1)*T1^2 + C4(1)*T1^3 + C5(1)*T1^4)/(1e6*2); % kJ/K/mol Cp_wl = (C1(2) + C2(2)*T2 + C3(2)*T2^2 + C4(2)*T2^3 + C5(2)*T2^4 +... C1(2) + C2(2)*T1 + C3(2)*T1^2 + C4(2)*T1^3 + C5(2)*T1^4)/(1e6*2); % kJ/K/mol Cp_X = 1.301; % kJ/K/Cmol, from Battley et al 1997 Cps = [Cp_CO,Cp_H2,Cp_etl,Cp_X,Cp_CO2,Cp_wl]; end %% Estimation of Henry's constants function [H_CO, H_H2, H_CO2] = Henry global Temp H_CO = 9.5E-4*exp(1300*(1/Temp - 1/298.15))*1000; % mol/m3/atm H_H2 = 7.8E-4*exp(500*(1/Temp - 1/298.15))*1000; % mol/m3/atm H_CO2 = 3.4E-2*exp(2400*(1/Temp - 1/298.15))*1000; % mol/m3/atm end %% Thermodynamics-based black-box model of bacterial reactions function y = micro(PCO,PH2,PCO2,Cet) % This function defines the stoichiometry of metabolic reactions. Also % defines maximum substrate uptake rates. The calculation is based on the % DH at physiological conditions. % This function is called by the mass transfer model being optimized global R Temp DG01_Cat_et_H2 Umax_H2_et YXH2_et mS_et_H2 pHi = 7; % Intracellular pH e_cap = 3; % e-mol/C-molX/h Ea = -69000; %% STOICHIOMETRY % The stoichiometry of reactions follows the same order of substances as % the rows in matrix S in function 'stoich'; see below. % The definition of stochiometries starts by defining the equations for the % electron donor and the electron acceptor. From those, electrons are % balanced and one final equation is defined which contains the electron % donor and the acceptor. % The equations undergo an automatic balancing of Oxygen, Hydrogen and % Charge, which is excecuted by function 'stoich'; see below % Catabolism D_et_H2 = [0 -1 0 0 0 0 0 0]; % Stoichiometry of electron donor equation for ethanol production from H2 X = D_et_H2; Y = stoich(X,Temp); D_et_H2 = Y; A_et_H2 = [0 0 0 0.5 0 0 0 -1]; % Stoichiometry of electron acceptor equation for ethanol production from H2 X = A_et_H2; Y = stoich(X,Temp); A_et_H2 = Y; Cat_et_H2 = (D_et_H2(1:11)*A_et_H2(11) - A_et_H2(1:11)*D_et_H2(11))/(A_et_H2(11) - D_et_H2(11)); % Stoichiometry of catabolic equation for ethanol production from H2 Cat_et_H2 = Cat_et_H2/(-Cat_et_H2(8)); X = Cat_et_H2(1:8); Y = stoich(X,Temp); Cat_et_H2 = Y; % per mol of C-source D_X_H2 = [0 -1 0 0 0 0 0 0]; % Stoichiometry of electron donor equation for anabolism from H2 X = D_X_H2; Y = stoich(X,Temp); D_X_H2 = Y; A_X_H2 = [0 0 -0.25 0 0 0 1 -1]; % Stoichiometry of electron acceptor equation for anabolism from H2 X = A_X_H2; Y = stoich(X,Temp); A_X_H2 = Y; An_H2 = (D_X_H2(1:11)*A_X_H2(11) - A_X_H2(1:11)*D_X_H2(11))/(A_X_H2(11) - D_X_H2(11)); % Stoichiometry of anabolic equation for ethanol production from H2 An_H2 = An_H2/An_H2(7); X = An_H2(1:8); Y = stoich(X,Temp); An_H2 = Y; %% ENERGETICS OF CATABOLISM & ANABOLISM DG01_Cat_et_H2 = Cat_et_H2(end) + R.*Temp.*(Cat_et_H2(1).*log(PCO) + Cat_et_H2(2).*log(PH2) + Cat_et_H2(3)*log(0.1)... + Cat_et_H2(4)*log(Cet) + Cat_et_H2(8).*log(PCO2) + Cat_et_H2(10)*log(10^-pHi)); % kJ/Cmol_x % Energy dissipation DG_Dis_CO2 = 200 + 18*(6 - 1)^1.8 + exp(((3.8 - 0)^2)^0.16*(3.6 + 0.4*1)); % kJ/Cmol_x % Metabolic reaction from H2 to ethanol Met_et_H2 = An_H2(1:8)*4/(2*-An_H2(2)) + Cat_et_H2(1:8)*DG_Dis_CO2/-DG01_Cat_et_H2; % mol/C-molX X = Met_et_H2; Y = stoich(X,Temp); Met_et_H2 = Y; % Biomass yields YXH2_et = 1./(DG_Dis_CO2/-DG01_Cat_et_H2 + 4/(2*-An_H2(2))); % Cmol_x/mol_CS % Maintenance mS_et_H2 = 4.5*exp(-69000/(R*1000)*(1/Temp - 1/298.15))./-(DG01_Cat_et_H2/Cat_et_H2(2)); % mol_CO/Cmol_x/h % q_S^max & U^max ETC = e_cap*exp(Ea/(R*1000)*(1/Temp - 1/298.15)); % e-mol/C-molX/h qSmax_H2 = ETC/2; Umax_H2_et = (qSmax_H2 + mS_et_H2).*YXH2_et; % Variables export y = zeros(3,size(Met_et_H2,2)); y(1,:) = Met_et_H2; y(3,3) = qSmax_H2; end function y = Cat_H2(PH2,PCO2,Cet,Temp) global R pHi = 7; % Intracellular pH % The stoichiometry of reactions follows the same order of substances as % the rows in matrix S in function 'stoich'; see below. D_et_H2 = [0 -1 0 0 0 0 0 0]; % Stoichiometry of electron donor equation for ethanol production from H2 X = D_et_H2; Y = stoich(X,Temp); D_et_H2 = Y; A_et_H2 = [0 0 0 0.5 0 0 0 -1]; % Stochiometry of electron acceptor equation for ethanol production from H2 X = A_et_H2; Y = stoich(X,Temp); A_et_H2 = Y; Cat_et_H2 = (D_et_H2(1:11)*A_et_H2(11) - A_et_H2(1:11)*D_et_H2(11))/(A_et_H2(11) - D_et_H2(11));% Stoichiometry of catabolic equation for ethanol production from H2 Cat_et_H2 = Cat_et_H2/(-Cat_et_H2(8)); X = Cat_et_H2(1:8); Y = stoich(X,Temp); Cat_et_H2 = Y; % per mole of C-source DG01_Cat_et_H2 = Cat_et_H2(end) + R.*Temp.*(Cat_et_H2(2).*log(PH2) + Cat_et_H2(3)*log(0.1)... + Cat_et_H2(4)*log(Cet) + Cat_et_H2(8).*log(PCO2) + Cat_et_H2(10)*log(10^-pHi)); % kJ/mol_CS y(:,1) = DG01_Cat_et_H2; % kJ/molCO2 y(:,2) = DG01_Cat_et_H2.*-Cat_et_H2(2)./Cat_et_H2(4); % kJ/mol_et end %% Stochiometry of catabolic, anabolic and metabolic reactions function Y = stoich(X,Temp) % This function calculates the amounts of water, protons and electrons in % electorn donor and acceptor reactions, also in catabolic, anabolic and % metabolic reactions. It also calculates the standard DG and DH changes in % all the said reactions. % This function is called many times by function 'micro' and 'Cat_H2'. % Acetate and acetic acid production is considered by this function, % although such products are not reported in the main document. That part % of the calculation was used for validating the threshold concentrations % and the construction of figures SI2 and SI3 of the supplementary % information material. % Matrix S contains information abut the C, H, O and N content in each % substance involved in the reactions, plus their charge (Ch), degree of % reduction (dr), mol weight (MW), standard Gibbs free energy (dG) and % Enthapy (dH) of formation per mole of substance % C H O N Ch dr MW dG dH S = [1 0 1 0 0 2 28 -137.17 -110.53; % CO 0 2 0 0 0 2 2 0 0 ; % H2 0 4 0 1 1 0 18 -80.4 -133.3 ; % NH4+ 2 6 1 0 0 12 46 -181.6 -288.3 ; % Ethanol 2 3 2 0 -1 8 59 -369.4 -485.8 ; % Acetate 2 4 2 0 0 8 60 -396.1 -485.5 ; % Acetic acid 1 1.75 0.50 0.25 0 4.00 25.25 -67 -91 ; % Biomass 1 0 2 0 0 0 44 -394.4 -393.5 ; % CO2 0 2 1 0 0 0 18 -237.7 -285.33; % H2O 0 1 0 0 1 0 1 0 0 ; % H+ 0 0 0 0 -1 1 0 0 0 ]; % Electrons Y = X; Y = [Y -(Y*S(1:length(Y),3))]; % Oxygen is balanced with H2O Y = [Y -(Y*S(1:length(Y),2))]; % Hydrogen is balanced with H+ Y = [Y (Y*S(1:length(Y),5))]; % Charge is balanced with electrons lim = length(Y); Y = [Y Y*S(1:lim,8)]; % Standard Gibbs free energy Y = [Y Y(1:lim)*S(1:lim,9)]; % Standard Enthalpy of reaction Y = [Y Temp*(Y(lim + 1)/298.15 + Y(lim + 2)*(1/Temp - 1/298.15))]; % dG correction for temperature end %% Estimation of vapor-liquid equilibria of the ethanol-water mixture function YY = NRTL_VLE(Temp) % Initial definition of temperature and pressure R = 8.3144598; % m3*Pa/K*/mol % Antoine coefficients, 1: ethanol, 2: water, P[kPa], T[K] A = [7.24215, 7.11572]; B = [1596.044, 1684.123]; C = [-46.655, -43.568]; n = 200; % Number of data points for each curve nn = 1; % Counter YY = zeros(n,3); % Initiatization of data storage matrix for x1 = linspace(0,1,n) % Definition of mol fractions in liquid x2 = 1 - x1; x = [x1; x2]; % Individual parameters per substance a_11 = 0.3; th_12 = (88*4.184)/(R*Temp); th_21 = (976*4.184)/(R*Temp); G_12 = exp(-a_11*th_12); G_21 = exp(-a_11*th_21); % Activity coefficients in the liquid phase phi_liq(1) = exp(x(2)^2*(th_21*(G_21/(x(1) + x(2)*G_21))^2 +... th_12*G_12/(x(2) + x(1)*G_12)^2)); phi_liq(2) = exp(x(1)^2*(th_12*(G_12/(x(2) + x(1)*G_12))^2 +... th_21*G_21/(x(1) + x(2)*G_21)^2)); % Partial pressures and mol fractions in vapor phase P_i = 10.^(A - B./(C + (Temp))); % in kPa Pmix = P_i(1)*x(1)*phi_liq(1) + P_i(2)*x(2)*phi_liq(2); y(1) = P_i(1)*x(1)*phi_liq(1)/Pmix; y(2) = P_i(2)*x(2)*phi_liq(2)/Pmix; % Save values into one matrix YY(nn,:) = [x(1) y(1) Pmix]; nn = nn + 1; end end