import math
T = 298.15 #[K] temperature
P = 1. #[atm] pressure
R = 8.314*10**(-3) #[kJ/(mol*K)]
g_a_0 = -20.9 #[kJ/mol]
g_b_0 = -17.2 #[kJ/mol]
x_a = math.exp((g_b_0-g_a_0)/(R*T))/(1+math.exp((g_b_0-g_a_0)/(R*T)))
x_b = 1-x_a
print " The chemical equilibrium composition of the gaseous mixture contains %f mol fraction isobutane \t\t\t\t\t\t\t\tan %f mol fraction n-bumath.tane"%(x_a,x_b)
import math
T = 298.15 #[K] temperature
P = 0.987 #[atm] pressure
g_0_NO = 86.6 #[kJ/mol] Free energy of formation the NO from elements
R = 8.314 #[J/(mol*K)]
g_0_O2 = 0.00
g_0_N2 = 0.00
delta_g_0 = 2*g_0_NO - g_0_O2 - g_0_N2 #[kJ/mol]
delta_g_01 = delta_g_0*1000 #[J/mol]
K_298 = math.exp((-delta_g_01)/(R*T))
f_0_N2 = 1. #[bar]
f_0_O2 = 1. #[bar]
f_0_NO = 1. #[bar]
y_N2 = 0.78
y_O2 = 0.21
y_NO_298 = math.sqrt(K_298*y_N2*y_O2)
T_1 = 2000 #[K]
K_2000 = 4.0*10**-4
y_NO_2000 = math.sqrt(K_2000*y_N2*y_O2)*10**(6) #[ppm]
print " The equilibrium constant for the reaction at 298.15 K is \t\t\t %.1e"%(K_298)
print " The concentration of NO at equilibrium at temperature 298.15 K is \t\t %.1e"%(y_NO_298)
print " The equilibrium consmath.tant for the reaction at 2000 K is \t\t\t %.1e"%(K_2000)
print " The concentration of NO at equilibrium at temperature 2000 K is \t\t %.0f ppm"%(round(y_NO_2000,-2))
from scipy.optimize import fsolve
import math
Temp = 2000. #[K]
n_air = 1. #[mol] no of moles of the air
K_2000 = 4*10**(-4)
def f(x):
return (2*x)**(2) - K_2000*(0.78-x)*(0.21-x)
#return (K_2000-2)*x**(2)-K_2000*(0.78+0.21)*x+K_2000*0.78*0.21
x = fsolve(f,0)
c_NO = 2*x*10**(6) #[ppm]
p = c_NO/8100.*100
print " The calculated NO cocentration is %f ppm, which %f%% of the value computed in example 12.1"%(c_NO,p)
from scipy.optimize import fsolve
import math
Temp = 298. #[K]
K = 29.6 # equilibrium consmath.tant at 298 K
P = 1. #[bar]
n_water_0 = 0.833 #[mol]
n_ethylene_0 = 1. #[mol]
n_ethanol_0 = 0. #[mol]
n_T_0 = (n_water_0+n_ethylene_0+n_ethanol_0) #[mol]
def f(e):
return ((0+e)/(1.833-e))/(((1-e)/(1.833-e))*((0.833-e)/(1.833-e)))-K*P/(1)
e_1 = fsolve(f,0)
e_2 = fsolve(f,0.5)
y_ethanol = ((0+e_2)/(1.833-e_2))
y_ethylene = ((1-e_2)/(1.833-e_2))
y_water = ((0.833-e_2)/(1.833-e_2))
print "Concentration of the ethylene at the equilibrium is %f"%(y_ethylene)
print " Concentration of the water at the equilibrium is %f"%(y_water)
print " Concentration of the ethanol at the equilibrium is %f"%(y_ethanol)
from scipy.optimize import fsolve
import math
Temp = 273.15+25 #[C]
P = 1. #[bar]
R = 8.314 #[J/(mol*K)]
g_H2O_0 = -237.1 #[kJ/mol]
g_O2_0 = 0 #[kJ/mol]
g_H2_0 = 0 #[kJ/mol]
delta_g_0 = g_H2O_0 - 0.5*g_O2_0-g_H2_0 #[kJ/mol]
delta_g_1 = delta_g_0*1000 #[J/mol]
K = math.exp((-delta_g_1)/(R*Temp))
n_T_0 = 1.5#[mol]
def f(e):
return (e/(1.5-0.5*e))/(((1-e)/(1.5-0.5*e))*((0.5-0.5*e)/(1.5-0.5*e))**(0.5))
y_H2 = 2.4e-28
y_O2 = 0.5*y_H2
print " The equilibrium mol fraction of the hydrogen is %0.3e"%(y_H2)
print " And the equilibrium mol fraction of the oxygen is %e "%(y_O2)
import math
from scipy.integrate import quad
Temp = 298.15 #[K]
Press = 1*10**(5) #[Pa]
R = 8.314 #[J/(mol*K)]
v_liquid = 1.805*10**(-5) #[m**(3)/mol] this liquid specific volume and we will treat is as a consmath.tant
P_vapour_25 = 0.0317*10**(5) #[Pa]
def f0(P):
return v_liquid*P**(0)
delta_g_0_1 = quad(f0,Press,P_vapour_25)[0]
delta_g_0_2 = 0 #[J/mol]
def f1(P):
return 1./P
delta_g_0_3 = (R*Temp)* quad(f1,P_vapour_25,Press)[0]
delta_g_0 = delta_g_0_1+delta_g_0_2+delta_g_0_3 #[J/mol]
delta_g_1 = delta_g_0/1000 #[kJ/mol]
print " Total change in the free energy of water going under given conditions is %0.2f kJ/mol"%(delta_g_1)
delta_g_0_ideal_gas = -228.6 #[kJ/mol]
delta_g_0_liquid = -237.1 #[kJ/mol]
delta_g_o = delta_g_0_ideal_gas-delta_g_0_liquid #[kJ/mol]
print " From the values of Table A.8 given in the book the free energy change is %0.2f kJ/mol"%(delta_g_o)
import math
from scipy.integrate import quad
T1 = 273.15+25 #[K]
T2 = 273.15+400 #[K]
R = 8.314 #[J/(mol*K)]
g0_NH3 = -16.5 #[kJ/mol]
g0_N2 = 0 #[kJ/mol]
g0_H2 = 0 #[kJ/mol]
delta_g_0 = g0_NH3 - 0.5*g0_N2 - 1.5*g0_H2 #[kJ/mol]
K_1 = math.exp(-delta_g_0*1000/(R*T1)) # Equilibrium consmath.tant of the reaction at temperature 298.15 K
h0_NH3 = -46.1 #[kJ/mol]
h0_N2 = 0 #[kJ/mol]
h0_H2 = 0 #[kJ/mol]
del_h_1 = h0_NH3 - 0.5*h0_N2 - 1.5*h0_H2 #[kJ/mol]
a_NH3 = 3.578
a_H2 = 3.249
a_N2 = 3.280
b_NH3 = 3.020*10**(-3) #[1/K]
b_H2 = 0.422*10**(-3)
b_N2 = 0.593*10**(-3)
c_NH3 = 0 #[1/K**(2)]
c_H2 = 0 #[1/K**(2)]
c_N2 = 0 #[1/K**(2)]
d_NH3 = -0.186*10**(5) #[K**(2)]
d_H2 = 0.083*10**(5) #[K**(2)]
d_N2 = 0.040*10**(5) #[K**(2)]
del_a = a_NH3 - 0.5*a_N2 - 1.5*a_H2
del_b = b_NH3 - 0.5*b_N2 - 1.5*b_H2
del_c = c_NH3 - 0.5*c_N2 - 1.5*c_H2
del_d = d_NH3 - 0.5*d_N2 - 1.5*d_H2
I = R*( del_a*T1 + del_b*T1**(2)/2 + del_c*T1**(3)/3 - del_d/T1) #[J/mol]
def f5(T):
return (del_h_1*1000 - I + R*(del_a*T + del_b*T**(2)/2 + del_c*T**(3)/3 - del_d/T))/T**(2)
X = (1/R)* quad(f5,T1,T2)[0]
K_2 = K_1*math.exp(X)
print " Equilibrium consmath.tants for the formation of ammonia from hydrogen and nitrogen are "
print " K = %0.0f at temperature 25 deg C"%(K_1)
print " K = %f at temperature 400 deg C"%(K_2)
from scipy.optimize import fsolve
import math
n_H2_0 = 1.5 #[mol]
n_N2_0 = 0.5 #[mol]
n_NH3_0 = 0 #[mol]
T_1 = 298.15 #[K]
T_2 = 673.15 #[K]
P = 1. #[bar]
K_298 = 778. # at temperature 298.15K
K_673 = 0.013 # at temperature 673.15K
def g(e_1):
return ((0+e_1)/(2-e_1))/(((0.5-0.5*e_1)/(2-e_1))**(0.5)*((1.5-1.5*e_1)/(2-e_1))**(1.5))-K_298
e_1 = fsolve(g,0.97)
y_NH3_298 = e_1/(2-e_1)
def h(e_2):
return ((0+e_2)/(2-e_2))/(((0.5-0.5*e_2)/(2-e_2))**(0.5)*((1.5-1.5*e_2)/(2-e_2))**(1.5))-K_673
e_2 = fsolve(h,0)
y_NH3_673 = e_2/(2-e_2)
print " The mole fraction of NH3 in the equilibrium at the temperature 298.15K and 1 bar is %f"%(y_NH3_298)
print " The mole fraction of NH3 in the equilibrium at the temperature 673.15K and 1 bar is %f"%(y_NH3_673)
from scipy.optimize import fsolve
import math
Temp = 273.15+400 #[K]
P = 150*1.01325 #[bar]
K_673 = 0.013
K = K_673*(P/1)**(1.5+0.5-1)
def f(e):
return ((0+e)/(2-e))/(((0.5-0.5*e)/(2-e))**(0.5)*((1.5-1.5*e)/(2-e))**(1.5))-K
e=fsolve(f,0.5)
y_NH3 = (0+e)/(2-e)
print "The mole fraction of the ammonia in the equilibrium is %0.2f"%(y_NH3)
from scipy.optimize import fsolve
import math
T = 273.15+400 #[K] given temperature
P = 150*1.01325 #[bar] given pressure
K_673 = 0.013
K_v = (10**((0.1191849/T + 91.87212/T**(2) + 25122730/T**(4))*P))**(-1)
K = (K_673/K_v)*(P/1)**(1.5+0.5-1)
def f(e):
return ((0+e)/(2-e))/(((0.5-0.5*e)/(2-e))**(0.5)*((1.5-1.5*e)/(2-e))**(1.5))-K
e = fsolve(f,0.2)
y_NH3 = (0+e)/(2-e)
print " The mole fraction of the ammonia in the equilibrium is %0.2f"%(y_NH3)
from scipy.optimize import fsolve
import math
p_i = 1. #[atm] initial pressure
P = 150. #[atm] final pressure
T = 273+25. #[K] Given temperature
R = 8.314 #[J/(mol*K)]
delta_g_0 = 10.54*1000 #[J/mol]
K = math.exp((-delta_g_0)/(R*T))
def f(e):
return (e*e)/((1-e)*(1-e))-K
e = fsolve(f,0)
v_C2H5OOC2H5 = 97.67 #[ml/mol]
v_H2O = 18.03 #[ml/mol]
v_C2H5OH = 58.30 #[ml/mol]
v_CH3COOH = 57.20 #[ml/mol]
delta_v = v_C2H5OOC2H5 + v_H2O - v_C2H5OH - v_CH3COOH #[ml/mol]
def g(e_1):
return (e_1*e_1)/((1-e_1)*(1-e_1))*math.exp((delta_v)/(R*T)*(P-p_i))-K
e_1 = fsolve(g,0.2)
a = e_1/e
print "On increamath.sing the pressure from 1 atm to 150 atm the reacted amount of the equimolar \
reacmath.tants at equilibrium becomes %f times of initial"%(a)
import math
P = 150. #[atm] given pressure
T = 400. #[C] temperature
K = 0.013
K_v = 0.84
delta_v = 1.5+0.5-1
K_p = (K/K_v)*(1/1)**(delta_v) #[1/bar]
print " Value of the K_p at the given condition is %f 1/bar)"%(K_p)
print " The basic K is dimensionless%( but K_p has the dimensions of pressure to the power."