" Example  3.4. We have the equilibrium reaction

  CO + 1/2 O2 =  CO2.

The product is disassociated as follows

			alpha CO + n2 O2 + n3 CO2.

Find the concentrations of each species under the following conditions."
P_0 = Po#
T_eq = 2500                             "[K] Equilibrium temperature"
P_eq =5.76*P_0		             "[KPa] Equilibrium pressure"


"Carbon balance"

1 = alpha + n_3

"Oxygen balance"

2 = alpha + 2*n_2 + 2*n_3

"Calculation of Mole Fractions in the Gas Product Mixture"

n_P = alpha + n_2 + n_3

y_1 = alpha/n_P			   	"CO"
y_2 = n_2/n_P				"O2"
y_3 = n_3/n_P				"CO2"

"Gibbs free energy  at equilibrium temperature of the  Product species"

g_CO2 = ENTHALPY(CO2,T=T_eq) - T_eq*ENTROPY(CO2, T=T_eq,P=y_3*P_eq)
g_CO   = ENTHALPY(CO,   T=T_eq) - T_eq*ENTROPY(CO,   T=T_eq,P=y_1*P_eq)
g_O2  = ENTHALPY(O2,   T=T_eq) - T_eq*ENTROPY(O2,    T=T_eq,P=y_2*P_eq)

"Gibbs Free Energy of the Product"

G_prod = 1.0 * g_CO2

"Gibbs Free Energy of the Reactants"

G_reac = 1.0 * g_CO + 0.5 * g_O2

"Find Equilibrium"

DELTAG = G_reac - G_prod

DELTAG = 0

"Now back out the same equilibrium constant that the text has"

P_1 = y_1*P_eq
P_2 = y_2*P_eq
P_3 = y_3*P_eq

K_P = (P_3/P_0)/( (P_1/P_0) * sqrt(P_2/P_0) )