from numpy import matrix
# Variables
F = 10000. ; #[lb/hr]
NaOH_F = 40./100 ; #[wt. fraction]
NaOH_P1 = 95./100 ; #[wt. fraction of NaOH filter cake]
NaOH_P2 = (0.05 * 45)/100 ; #[wt. fraction of NaOH in NaOH soln.]
H2O_P2 = (0.05 * 55)/100 ; #[wt. fraction of H2O in NaOH soln.]
NaOH_R = 45./100; #[wt. fraction]
NaOH_G = 50./100; #[wt. fraction]
P = (NaOH_F * F)/(NaOH_P1 + NaOH_P2) ; #[lb/hr]
W = F-P ; # [lb/hr]
# Calculations & Results
a = matrix([[NaOH_G,-NaOH_R],[1,-1]]) # matrix formed of coefficients of unknown
b = matrix([[F*NaOH_F],[P]]); # matrix formed by constant
a = a.I
x = a*b ; # matrix of solutions . x(1) = G, x(2) = R
G = x[0] ; # [lb/hr]
R = x[1] ; # [lb/hr]
print '(a) Flow rate of water removed by evaporator is %.1f lb/hr'%W
print 'The recycle rate of the process is %.1f lb/hr'%R
NaOH_H = 45./100 ; #[wt fraction]
H2O_H = 55./100 ; #[wt fraction]
a1 = matrix([[NaOH_G,-NaOH_H],[NaOH_G,-H2O_H]]) ; # matrix formed of coefficients of unknown
b1 = matrix([[((NaOH_P1+NaOH_P2)* P)],[(H2O_P2) * P]]); # matrix formed by constant
x1 = a1**-1
x1 = x1*b1 ; # matrix of solutions nw_G = x1(1);H = x1(2)
nw_G1 = x1[0] ; # [lb/hr]
H = x1[1]; # [lb/hr]
nw_F = (NaOH_H * H + (NaOH_P1 + NaOH_P2) * P)/NaOH_F ; #[lb/hr]
print ' (b) Total feed rate when filterate is not recycled is %.1f lb/hr'%nw_F
# Variables
F_Bz = 100. ; # Fresh benzene feed / basis - [mol]
con_Bz = .95 ; # Fraction of conversion of benzene
sp_con = .20 ; # Fraction of single pass conversion
ex_H2 = .20 ; # Fraction of exces H2 used in fresh feed
R_Bz = 22.74 ; # Benzene in Recycle stream - [mol %]
R_H2 = 78.26 ; # H2 in Recycle stream - [mol %]
TLV_Bz = 0.5 ; # TLV value of benzene -[ppm]
TLV_C6H12 = 300. ; # TLV value of cyclohexane -[ppm]
TLV_H2 = 1000. ; # TLV value of H2 -[ppm]
# Calculations
F_H2 = F_Bz*3*(1+ex_H2) ; # H2 in Feed - [mol]
F = F_Bz + F_H2 ; # Total feed - [mol]
ex_r = con_Bz*F_Bz/(-(-1)) ; # Extent of reaction
P_Bz = F_Bz -1*(ex_r) ; # Benzene in P ,by benzene balance - [mol]
P_H2 = F_H2 + -3*(ex_r) ; # H2 in P ,by H2 balance - [mol]
P_C6H12 = 0 + 1*(ex_r) ; # Cyclohexane in P ,by cyclohexane balance - [mol]
P = P_Bz + P_H2 + P_C6H12 ; # Total Product - [ mol]
R = ((-(-ex_r))/(sp_con) - F_Bz)/(R_Bz/100.) ; # Recycle stream - [mol]
R_by_F = R/F ; # Ratio of R to F
TLV = (P_Bz/P)*(1/TLV_Bz) + (P_H2/P)*(1./TLV_H2) + (P_C6H12/P)*(1/TLV_C6H12) ; # TLV (environmental index)
# Results
print 'Ratio of R to F is %.2f .'%R_by_F
print ' TLV (environmental index) is %.3f .'%TLV
# Variables
RR = 8.33 ; # Recycle ratio
F = 100. ; # Overall feed/basis - [lb]
F_g = 0.40 ; # Fraction of glucose in overall feed
F_w = 0.60 ; # Fraction of water in overall feed
F_dash_f = 0.04 ; # Fraction of fructose in feed to reactor
P = F # By overall balance -[lb]
R = P/RR ; # Recycle stream - [lb]
P_w = (F_w * F)/ P ; # Fraction of water in product(P), by overall water balance
R_w = P_w ; #Fraction of water in recycle (R), since both R and P has same composition
# Calculations
F_dash = F +R ; # Feed to reactor ,by total balance -[lb]
R_f = (F_dash*F_dash_f)/R ; # Fraction of fructose in recycle stream
R_g = 1 - (R_f + R_w) ; # Fraction of glucose in recycle stream
F_dash_g = (F*F_g + R*R_g)/F_dash ; # Fraction of glucose i feed to reactor
f_con = ((F_dash*F_dash_g) - (R + P)*R_g)/(F_dash*F_dash_g) ; # Fraction of conversion of glucose in reactor
# Results
print 'Fraction of conversion of glucose in reactor is %.2f .'%f_con
# Variables
F = 100. ; # Overall feed/basis - [kg]
F_com = 0.10 ; # Mass fraction of component in fresh feed
F_w = 0.90 ; # Mass fraction of water in fresh feed
P_w = 0.10 ; # Mass fraction of water in product
P_com = 0.90 ; #Mass fraction of component in product
F_dash_com = 0.03 ; #Mass fraction of component in feed to reactor
W_w = 1. ; # Mass fraction of water in W(waste)
C_con = .40 ; # Fraction of conversion of component in reactor
# Calculations
P = F_com*F/P_com ; #By component balance- Product - [kg]
W = F - P ; # By overall balance - waste(W)- [kg]
Rw = (F*F_com - F*F_com*C_con)/C_con ; # Mass of component in recycle(R) - [kg]
F_dash = ( F*F_com + Rw )/F_dash_com ; # By component balance - feed to reactor(F') -[kg]
R = F_dash - F ; # Recycle(R) - By total balance -[kg]
w = Rw/R ; # Mass fraction of component in recycle(R)
# Results
print 'Recycle(R) stream- %.0f kg '%R
print ' Mass fraction of component in recycle(R)- %.4f .'%w
# Variables
F = 100. # Overall feed/basis - [kg]
F_n_C5H12 = 0.80 ; # Fraction of n_C5H12 in overall feed
F_i_C5H12 = 0.20 ; # Fraction of i_C5H12in overall feed
S_i_C5H12 = 1. ; # Fraction of i_C5H12 in isopentane stream
P_n_C5H12 = .90 ; # Fraction of n_C5H12 in overall product
P_i_C5H12 = .10 ; # Fraction of i_C5H12 in overall product
# Calculations
P = (F*F_n_C5H12)/P_n_C5H12 ; #Product Material Balance of n_C5H12 -[kg]
S = F - P ; # Isopentane stream (S) from overall material balance - [kg]
from numpy import matrix
a = matrix([[1,-1],[F_n_C5H12,-1]]) ; # Matrix of coefficients of unknown
b = matrix([[S],[0]]) ; # Matrix of constants
a = a.I
x = a*b # Matrix of solutions, x(1) = x , x(2) = y
xf = x[0]/F ; # Fraction of butane-free gas going to isopentane tower
# Results
print 'Fraction of butane-free gas going to isopentane tower is %.3f .'%xf
# Variables
F = 100. ; # Overall feed/basis - [mole]
F_H2 = 0.673 ; # Mole fraction of H2 in overall feed
F_CO = 0.325 ; # Mole fraction of i_C5H12in overall feed
F_CH4 = .002 ; # Mole fraction of CH4 in overall feed
E_CH3OH = 1. ; # Mole fraction of CH3OH in Exit(E)
z = .032 ;
CO_con = .18 ; # Fraction of conversion of CO in reactor
# Calculations
#By using eqn.(c) and (d)
P = F_CH4*F/z ; # Purge stream - [mole]
# Using eqn.(a) , (b) and (c)
x_plus_y = 1 - z ; # x + y
E = (F_H2*F + F_CO*F + 3*F_CH4*F - P*(x_plus_y + 3*z ))/3 ; # Exit stream - [mole]
# By using eqn. (d)
y = ( F_CO*F - E )/P ; # Mole fraction of CO
# By using eqn. (a)
x = 1 - z - y ; # Mole fraction of H2
# Lastly by using eqn.(e)
R = ( F_CO*F - P*y - F_CO*F*CO_con )/(y*CO_con) ; # Recycle steam - [mole]
# Results
print 'Moles of recycle(R) per mole of feed(F) - %.4f '%(R/F)
print ' Moles of CH3OH(E) per mole of feed(F) - %.4f '%(E/F)
print ' Moles of Purge(P) per mole of feed(F) - %.4f '%(P/F);
print ' Composition of Purge '
print ' Component Mole fraction '
print ' H2 %.3f '%x
print ' CO %.3f '%y
print ' CH4 %.3f '%z