% script for case study
% of water-gas shift equilibrium
% over a range of temperatures
% set up with external arguments
% feed specifications
FeedH2 = 450; % kmol/h
FeedCO2 = 50;
FeedH2O = 1150;
FeedCO = 500;
T = 500:25:1500; % array of temperatures
n = length(T);
for i = 1:n
    fanon = @(x) fx(x,T(i),FeedH2,FeedCO2,FeedH2O,FeedCO)
    xsoln(i) = fzero(fanon,[50,450]);
    ProdH2(i) = FeedH2 + xsoln(i);
    ProdCO2(i) = FeedCO2 + xsoln(i);
    ProdH2O(i) = FeedH2O - xsoln(i);
    ProdCO(i) = FeedCO - xsoln(i);
end
plot(T,ProdH2,'c',T,ProdCO2,'g',T,ProdH2O,'b',T,ProdCO,'m')
grid; grid minor
xlabel('Temperature - degC')
ylabel('Flow Rate - kmol/h')
title('Water-Gas Shift Equilibrium')
legend('H2','CO2','H2O','CO','Location','eastoutside')

