The gibbs method for molecular-based computer simulations of phase equilibria