Thermodynamics of segregation in alloys