Modelling Phase Equilibria: Thermodynamic Background and Practical Tools