A new treatment for calculating activities from phase diagrams involving two liquid or solid coexisting phases