Calculation of constrained equilibria by Gibbs energy minimization