A method for the simultaneous phase equilibria and stability calculations for multiphase reacting and non-reacting systems