Thermodynamics of polymer miscibility