Thermodynamics of Alloy Formation