import math
# Variables
Vol_total = 3; #[m**(3)] - Total volume of solution
x_ethanol = 0.6; #Mole fraction of ethanol
x_water = 0.4; #Mole fraction of water
# Calculations
#The partial molar volumes of the components in the mixture are
V_ethanol_bar = 57.5*10**(-6); #[m**(3)/mol]
V_water_bar = 16*10**(-6); #[m**(3)/mol]
#The molar volumes of the pure components are
V_ethanol = 57.9*10**(-6); #[m**(3)/mol]
V_water = 18*10**(-6); #[m**(3)/mol]
#The molar volume of the solution is
V_sol = x_ethanol*V_ethanol_bar + x_water*V_water_bar; #[m**(3)/mol]
#Total number of moles can be calculated as
n_total = Vol_total/V_sol; #[mol]
#Moles of the components are
n_ethanol = n_total*x_ethanol; #[mol]
n_water = n_total*x_water; #[mol]
#Finally the volume of the pure components required can be calculated as
Vol_ethanol = V_ethanol*n_ethanol;
Vol_water = V_water*n_water;
# Results
print "Required volume of ethanol is %f cubic metre"%(Vol_ethanol);
print "Required volume of water is %f cubic metre"%(Vol_water);
import math
# Variables
T = 25+273.15; #[K] - Temperature
P = 1; #[atm]
#Component 1 = water
#component 2 = methanol
a = -3.2; #[cm**(3)/mol] - A constant
V2 = 40.7; #[cm**(3)/mol] - Molar volume of pure component 2 (methanol)
#V1_bar = 18.1 + a*x_2**(2)
# Calculations and Results
#From Gibbs-Duhem equation at constant temperature and pressure we have
#x_1*dV1_bar + x_2*dV2_bar = 0
#dV2_bar = -(x_1/x_2)*dV1_bar = -(x_1/x_2)*a*2*x_2*dx_2 = -2*a*x_1*dx_2 = 2*a*x_1*dx_1
#At x_1 = 0: x_2 = 1 and thus V2_bar = V2
#Integrating the above equation from x_1 = 0 to x_1 in the RHS, and from V2_bar = V2 to V2 in the LHS, we get
#V2_bar = V2 + a*x_1**(2) - Molar volume of component 2(methanol) in the mixture
print "The expression for the partial molar volume of methanol2 isV2_bar = V2 + a*x_1**2 [cm**3/mol]";
#At infinite dilution, x_2 approach 0 and thus x_1 approach 1, therefore
x_1 = 1; # Mole fraction of component 1(water) at infinite dilution
V2_bar_infinite = V2 + a*(x_1**(2)); #[cm**(3)/mol]
print "The partial molar volume of methanol at infinite dilution is %f cm**3/mol"%(V2_bar_infinite);
# Variables
#H = a*x_1 + b*x_2 +c*x_1*x_2
#The values of the constants are
a = 15000; #[J/mol]
b = 20000; #[J/mol]
c = -2000; #[J/mol]
# Calculations and Results
#(1)
#Enthalpy of pure component 1 = H1 is obtained at x_2 = 0, thus
x_2 = 0;
x_1 = 1;
H1 = a*x_1 + b*x_2 +c*x_1*x_2; #[J/mol]
print "a).The enthalpy of pure component 1 is %f J/mol"%(H1);
#Similarly for component 2,
#Enthalpy of pure component 2 = H2 is obtained at x_1 = 0, thus
x_1_prime = 0;
x_2_prime = 1;
H2 = a*x_1_prime + b*x_2_prime +c*x_1_prime*x_2_prime; #[J/mol]
print " The enthalpy of pure component 2 is %f J/mol"%(H2);
#(c)
#From part (b), we have the relation
#H1_bar = a + c*(x_2**(2))
#H2_bar = b + c*(x_1**(2))
#For enthalpy of component 1 at infinite dilution, x_1 approach 0 and thus x_2 approach 1, therefore
x_1_c = 0;
x_2_c = 1;
H1_infinite = a + c*(x_2_c**(2)); #[cm**(3)/mol]
print "C).The enthalpy of componenet 1 at infinite dilution at x_1 = 0) is %f J/mol"%(H1_infinite);
#At x_1 = 0.2
x_1_c1 = 0.2;
x_2_c1 = 0.8;
H1_bar_c1 = a + c*(x_2_c1**(2)); #[J/mol]
print " The enthalpy of componenet 1 at at x_1 = 0.2) is %f J/mol"%(H1_bar_c1);
#At x_1 = 0.8
x_1_c2 = 0.8;
x_2_c2 = 0.2;
H1_bar_c2 = a + c*(x_2_c2**(2)); #[J/mol]
print " The enthalpy of componenet 1 at at x_1 = 0.8) is %f J/mol"%(H1_bar_c2);
import math
# Variables
n = 1*10**(3); #[mol] - No of moles
P = 0.1; #[MPa] - Pressure of the surrounding
T = 300; #[K] - Temperature of the surrounding
x_1 = 0.79; #Mole fraction of N2 in the air
x_2 = 0.21; #Mole fraction of O2 in the air
R=8.314; #[J/mol*K]
# Calculations
#Change in availability when x_1 moles of component 1 goes from pure state to that in the mixture is
#x_1*(si_1 - si_2) = x_1*[H1 - H1_bar - T_0*(S1 - S1_bar)]
#Similarly change in availability of x_2 moles of component 2 is
#x_2*(si_1 - si_2) = x_2*[H2 - H2_bar - T_0*(S2 - S2_bar)]
#and thus total availability change when 1 mol of mixture is formed from x_1 mol of component 1 and x_2 mol of component 2 is equal to reversible work
#W_rev = x_1*[H1 - H1_bar - T_0*(S1 - S1_bar)] + x_2*[H2 - H2_bar - T_0*(S2 - S2_bar)]
#W_rev = -[delta_H_mix] +T_0*[delta_S_mix]
#If T = T_0 that is,temperature of mixing is same as that of surroundings, W_rev = -delta_G_mix.
#W_rev = -delta_G_mix = R*T*(x_1*math.log(x_1) + x_2*math.log(x_2))
W_rev = R*T*(x_1*math.log(x_1) + x_2*math.log(x_2)); #[J/mol]
#Therefore total work transfer is given by
W_min = (n*W_rev)/1000; #[kJ]
# Results
print "The minimum work required is %f kJ"%(W_min);
import math
# Variables
x_A = 0.20; # Mole fraction of A
x_B = 0.35; # Mole fraction of B
x_C = 0.45; # Mole fraction of C
phi_A = 0.7; # Fugacity coefficient of A
phi_B = 0.6; # Fugacity coefficient of B
phi_C = 0.9; # Fugacity coefficient of C
P = 6.08; #[MPa] - Pressure
T = 384; #[K] - Temperature
# Calculations
#We know that
#math.log(phi) = x_1*math.log(phi_) + x_2*math.log(phi_2) + x_3*math.log(phi_3)
math.log_phi = x_A*math.log(phi_A) + x_B*math.log(phi_B) + x_C*math.log(phi_C); # Fugacity coefficient
phi = math.exp(math.log_phi);
#Thus fugacity is given by,
f_mixture = phi*P; #[MPa]
# Results
print "The fugacity of the mixture is %f MPa"%(f_mixture);