Deriving the entropy of mixing of a non-ideal solution In the earlier posted question named Derive expression for internal energy of mixing and entropy of mixing using statistical thermodynamics the entropy of mixing was found by assuming an ideal solution. The user Porphyrin mentioned that in case the molecules in the solution do interact with each other, the free energy would have an additional term (n1+n2)x1x2w, with 


  w≈(2E12−E11−E22) and E12E12 is the interaction energy between molecules of type 11 and 22 when they are adjacent and similarly for
  E11E11 and E22E22 all of which are negative. From a consideration of
  the energies involved ww is expected to be positive.


My question is: how do we go about finding an answer for the entropy of mixing when we do not assume that the solution is ideal?
The calculation of the mixing energy is extremely complicated and only approximate solutions have been obtained as far as I am aware. I shall attempt to outline one of these methods*.

All molecules are assumed to be spherical and of equal size and situated on a lattice with co-ordination number z . Each pair of neighbours AA of type A molecules contributes energy $w_{AA}$, similarly $w_{BB}$ for B molecules and energy $w_{AB}$ for AB pairs. The total energy due to these  interactions 
is 
$$E_T=N_{AA}w_{AA} + N_{BB}w_{BB}+N_{AB}w_{AB}$$ 
where $N_{AA}$ is the number of AA pairs and so on. Counting the number of  $A$ interactions and number of B ’s gives
$$zN_A=2N_{AA} + N_{AB}  ~~~\text{and }~~~ zN_B=2N_{BB} + N_{AB} $$

and thus  combining these equations gives
$$E_T=\frac{zN_Aw_{AA}}{2}+\frac{zN_Bw_{BB}}{2}+wN_{AB}=E^T_{AA}+E^T_{BB}+wN_{AB}$$

where $w=w_{AB}-w_{AA}/2-w_{BB}/2$ is the energy gain on mixing per pair of AB neighbours.

In statistical mechanics the partition function is the key to all other thermodynamic functions. In this case partition function is $$
Z= \sum_{N_{AB}}Z_AZ_Bg(N_A,N_B,N_{AB})e^{(-E^T_{AA}-E^T_{BB}-wN_{AB}/KT)}$$

and where $g(..) $ is the number of arrangements of $N_A$  A’s , $N_B$ B ’s and $N_{AB}$  pairs of molecules. Separating out the terms due to pure A and B molecules gives

$$Z=Z’_AZ’_B \sum_{N_{AB}}g(N_A,N_B,N_{AB})e^{-wN_{AB}/KT}$$

and as the Helmholtz energy is 
$F=-kT\ln(Z)=F_A+F_B+\Delta F$ 
and for mixing only the $\Delta F$ term is important the others being the energy of each pure component.
Thus 
$$\Delta F = -kT\ln\left(\sum_{N_{AB}}g(N_A,N_B,N_{AB})e^{-wN_{AB}/kT}  \right) $$

The change in energy can be obtained from the Gibbs-Helmholtz equation $(E = F-T(dF/dT))_V$ and is 
$$\Delta E= w\frac{\sum_{N_{AB}} N_{AB} g(N_A,N_B,N_{AB})e^{-wN_{AB}/kT} } { \sum_{N_{AB}}g(N_A,N_B,N_{AB})e^{-wN_{AB}/kT} } $$

and this is an equation that seems to have no exact solution and so this is where approximations have to be made.

The difficulty is in the exponential terms, as they contain $N_{AB}$ the aim is therefore to replace these with an average value, and thus the exponential terms become constant wrt $N_{AB}$. It can be shown that
$$\sum_{N_{AB} }g(N_A,N_B,N_{AB}) =\frac{(N_A + N_B)!}{N_A!N_B!}$$
and 
$$\bar N_{AB}=w\frac{\sum_{N_{AB}}N_{AB}g(N_A,N_B,N_{AB})}{\sum_{N_{AB}}g(N_A,N_B,N_{AB})} = z\frac{N_AN_B}{N_A + N_B} $$

By replacing $N_{AB}$ by $\bar N_{AB}$ in the partition function produces

$$Z=Z’_AZ’_B \sum_{N_{AB}}g(N_A,N_B,N_{AB})e^{-w\bar N_{AB}/KT)}
 = \frac{(N_A+N_B)!}{N_A!N_B!}\exp\left(-\frac{zw}{kT}\frac{N_AN_B}{N_A+N_B}\right)$$

the change in energy is then 

$$\Delta E = zw\frac{N_AN_B}{N_A+N_B}= w\bar N_{AB}$$

and this can be re-written as molec fractions to produce
$$ \Delta E= z(N_A+N_B)x_1x_2w$$


based on text in Rushbrooke ‘Introduction to Statistical Mechanics’