# Variables
w_A1 = 1 #concentration of A in 1
w_B2 = 1 # concentration of B in 2
w_A3 = 0.8 # concentration of A in 3
w_B3 = 0.2 # concentration of B in 3
w_C4 = 1 # concentration of C in 4
w_A5 = 0.571 #concentration of A in 5
w_B5 = 0.143 #concentration of B in 5
w_C5 = 0.286 #concentration of C in 5
w_D6 = 1 # concentration of D in 6
w_A7 = 0.714 # concentration of A in 7
w_B7 = 0.286 # concentration of B in 7
w_B8 = 0.333 #concentration of B in 8
w_C8 = .667 #concentration of C in 8
us1 = 2 # Species involved in unit 1
us2 = 3 ; # Species involved in unit 2
us3 = 4 ; # Species involved in unit 3
# Caculations
total_sp = us1+us2+us3 # Total species in system
# Results
print 'Number of possible equations are 9, they are as follows- '
print ' Subsystem 1'
print ' A: F1*w_A1+F2*0 = F3*w_A3 (a)'
print ' B:F1*0 + F2*w_B2 = F3*w_B3 (b)'
print ' Subsystem 2'
print ' A: F3*w_A3+F4*0 = F5*w_A5 (c)'
print ' B:F3*w_B3 + F4*0 = F5*w_B5 (d)'
print ' C: F3*0+F4*w_C4 = F5*w_C5 (e)'
print ' Subsystem 3'
print ' A: F5*w_A5+F6*0 = F7*w_A7+F8*0 (f)'
print ' B:F5*w_B5 + F6*0 = F7*0+F8*w_B8 (g)'
print ' C: F5*w_C5+F6*0 = F7*0+F8*w_C8 (h)'
print ' D:F5*w_C5+F6*0 = F7*0+F8*w_C8 (i)'
print ' The above equations do not form a unique set'
# By inspection we can see that only 7 equations are independent
#Independent Equations are:
# Subsystem 1
#A: F1*w_A1+F2*0 = F3*w_A3 (a)
#B:F1*0 + F2*w_B2 = F3*w_B3 (b)
#Subsystem 2
#A: F3*w_A3+F4*0 = F5*w_A5 (c)
# C: F3*0+F4*w_C4 = F5*w_C5 (e)
# Subsystem 3
#A: F5*w_A5+F6*0 = F7*w_A7+F8*0 (f)
#B:F5*w_B5 + F6*0 = F7*0+F8*w_B8 (g)
#D:F5*w_C5+F6*0 = F7*0+F8*w_C8 (i)
print ' Number of independent equations are 7 '
from numpy import matrix
# Variables
G = 1400 #[kg]
n_un = 16 # Number of unknowns in the given problem(excluding extent of reactions)
n_ie = 16 ; # Number of independent equations
d_o_f = n_un-n_ie # Number of degree of freedom
print 'For unit 1 number of degree of freedom for the given system is %i .'%d_o_f
o1_air = 0.995 ; # Mass fraction of air at out of unit 1 in A
i1_air = 0.95 ; # Mass fraction air at in of unit 1 in G
i1_wtr = 0.02; # Mass fraction water at in of unit 1 in G
F1_wtr = 0.81 ; # Mass fraction of water at out of unit 1 in F
o1_wtr = 0.005 ; # Mass fraction of water at out of unit 1 in A
o2_wtr = 0.96 ; # Mass fraction of water at out of unit 2 in B
o3_wtr = 0.01; # Mass fraction of water at out of unit 3 in D
i1_act = 0.03 ; # Mass fraction of acetone at in of unit 1 in G
F1_act = 0.19 ; # Mass fraction of acetone at out of unit 1 in F
o3_act = 0.99 ; # Mass fraction of acetone at out of unit 3 in D
o2_act = 0.04 ; # Mass fraction of acetone at out of unit 2 in B
# Calculations
A = G*i1_air/o1_air ; #air-[kg]
F = G*i1_act/F1_act ; #[kg]
W = (F*F1_wtr+A*o1_wtr-G*i1_wtr)/1 #Pure water in -[kg]
n_un = 9 ; # Number of unknowns in the given problem(excluding extent of reactions)
n_ie = 9 ; # Number of independent equations
d_o_f = n_un-n_ie
print ' For unit 2 and 3 number of degree of freedom for the given system is %i .'%d_o_f
a = matrix([[o3_act, o2_act],[o3_wtr, o2_wtr]]);
b = matrix([[F*F1_act],[F*F1_wtr]])
a = a.I
x = a*b
# Results
print ' W-Pure water in to unit 1 - %.2f kg/hr'%W
print ' A-Air out of unit 1 - %.2f kg/hr'%A
print ' F-out of unit 1 - %.2f kg/hr'%F
print ' B-out of unit 2 - %.2f kg/hr'%x[1]
print ' D-out of unit 3 - %.2f kg/hr'%x[0]
from numpy import matrix
# Variables
P = 6205. #[lb mol/hr]
amt_F = 560. ; #[bbl]
C_F = 0.50 ; # [mol fraction]
H2_F = 0.47 ; #[mol fraction]
S_F = 0.03 ; #[mol fraction]
CH4_G = 0.96 ; #[mol fraction]
C2H2_G = 0.02 ; #[mol fraction]
CO2_G = 0.02 ; #[mol fraction]
O2_A = 0.21 ; #[mol fraction]
N2_A = 0.79 ; #[mol fraction]
# Analysis of air into Oil furnace(A1)
O2_A1 = 0.20 ; #[mol fraction]
N2_A1 = 0.76 ; #[mol fraction]
CO2_A1 = 0.04 ; #[mol fraction]
#Stack gas(P) analysis
N2_P = .8493 ; #[mol fraction]
O2_P = .0413 ; #[mol fraction]
SO2_P = .0010 ; # [mol fraction]
CO2_P = .1084 ; #[mol fraction]
# Degree of freedom analysis
n_un = 5;
n_ie = 5 ;
d_o_f = n_un-n_ie; # Number of degree of freedom
print 'Number of degree of freedom for the given system is %i .'%d_o_f
# Calculations & Results
F = P* SO2_P/S_F ; # [lb mol/hr]
a = matrix([[2*CH4_G+C2H2_G, -1, 0, 0],[0, 0, N2_A, N2_A1],[CO2_G ,-.5, O2_A, O2_A1+CO2_A1],
[CH4_G+2*C2H2_G+CO2_G,0,0,CO2_A1]]);# matrix of coefficients
b = matrix([[-F*H2_F],[P*N2_P],[P*(O2_P+CO2_P+SO2_P)],[(P*CO2_P-F*C_F)]]); # matrix of constants
a = a.I
x = a*b
G = x[0]
m_F = 7.91
Fc = (F*m_F)/(7.578*42) # Fuel gas consumed -[bbl/hr]
time = amt_F/Fc ; # Time for which available fuel gas lasts-[hr]
print '(1) Fuel gas consumed(F) is %.2f bbl/hr .'%Fc
print '(2) Time for which available fuel gas lasts is %.0f hr .'%time
# For increase in arsenic and mercury level
F_oil = Fc*42; #[gal/hr]
Em_ars2 = (3.96 *10**(-4))/1000.0 ; # [lb/gal]
Em_Hg2 = (5.92 *10**(-4))/1000.0 ; # [lb/gal]
ars_F = F_oil*Em_ars2
Hg_F = F_oil*Em_Hg2
G_gas = G*359 #[ft**3/hr]
Em_ars1 = (2.30 *10**(-4))/10**6 ; # [lb/ft**3]
Em_Hg1 = (1.34 *10**(-4))/10**6 ; # [lb/ft**3]
ars_G = G_gas*Em_ars1;
Hg_G = G_gas*Em_Hg1 ;
in_ars = ((ars_F-ars_G)/ars_G)*100 #[% increase in Arsenic emission]
in_Hg = ((Hg_F-Hg_G)/Hg_G)*100 #[% increase in Mercury emission]
print '(3) Increase in Arsenic emission is %.1f %% .'%in_ars
print '(4) Increase in Mercury emission is %.1f %% .'%in_Hg
from numpy import matrix
# Variables
M = 1000. ; #[lb]
F_s = 16/100. # Fraction of sugar in F
F_w = 25/100. # Fraction of water in F
F_p = 59/100. # Fraction of pulp in F
D_p = 80/100. # Fraction of pulp in D
E_s = 13/100. # Fraction of sugar in E
E_p = 14/100. # Fraction of pulp in E
G_p = 95/100. # Fraction of pulp in G
H_s = 15/100. # Fraction of sugar in H
K_s = 40/100. # Fraction of sugar in K
# Calculations
K_w = 1 - K_s
K = M/K_s;
L = K_w*K;
# For evaporator equations are
H_w = 1- H_s
H = K_s*K/H_s
J = H - K;
# For screen equations are
E_w = 1 - (E_p + E_s)
a1 = matrix([[1,-1],[E_p,-G_p]])
b1 = matrix([[H,],[0,]])
a1 = a1.I
x1 = a1*b1
E = x1[0]
G = x1[1]
G_s = (E_s*E - H_s *H )/G
G_w = 1 -(G_s + G_p)
a2 = matrix([[1,-1],[F_p,-D_p]]) # Matrix of coefficients of unknown
F = 7818.93
D = 1152.2634
D_s = (F_s*F - E_s*E )/D # By sugar balance
D_w = 1 -(D_s + D_p) # summation of wt. fraction is 1
S_rec = M/(F*F_s) ; # Fraction of sugar recovered
# Results
print 'Flow streams and their respective compositions.'
print ' M = %.0f lb '%M
print ' Sugar: %.2f '%1
print ' L = %.0f lb '%L
print ' Water: %.2f'%1
print ' K = %.0f lb '%K
print ' Sugar: %.2f'%K_s
print ' Water: %.2f'%K_w
print ' J = %.0f lb '%J
print ' Water: %.2f '%1
print ' H = %.0f lb '%H
print ' Sugar: %.2f'%H_s
print ' Water: %.2f'%H_w
print ' G = %.0f lb '%G
print ' Sugar: %.3f'%G_s
print ' Water: %.3f'%G_w
print ' Pulp : %.2f'%G_p
print ' E = %.0f lb '%E
print ' Sugar: %.2f'%E_s
print ' Water: %.2f'%E_w
print ' Pulp : %.2f'%E_p
print ' D = %.0f lb '%D
print ' Sugar: %.3f'%D_s
print ' Water: %.3f'%D_w
print ' Pulp : %.2f'%D_p
print ' F = %.0f lb '%F
print ' Sugar: %.2f'%F_s
print ' Water: %.2f'%F_w
print ' Pulp : %.2f'%F_p
# Variables
F = 15. #[L/hr]
cs_in = 10. #Nutrient conc. input vessel - [g nutrient/L substrate]
V1 = 100. ; # [L]
V2 = 50. ; #[L]
Yxs = 0.2 ; # [cells/g]
umax = 0.4 ; #[hr** - 1]
Ks = 2. ; #[g/L] - Monod constant
# Calculations
u1 = F/V1 #[hr** - 1] #[hr** - 1]
cs_out = (Ks * u1/umax)/(1 - (u1/umax))
x_out = Yxs * (cs_in - cs_out) #[g cells / L substrate]
u2 = F/V2;
cs_out1 = (Ks * u2/umax)/(1 - (u2/umax)) #Nutrient conc. output vessel - [g nutrient/L substrate]
x_out1 = Yxs * (cs_in - cs_out1) #[g cells / L substrate]
x_out2 = 1.73 # From eqn. (e),(f) and (g) - [g cells / L substrate]
# Results
print 'g cells/L from option 1 is %.2f.'%x_out
print 'g cells/L from option 2 is %.2f.'%x_out2
print 'By comparing option 1 and option 2 the respective answers are essentially the same.'