A thermodynamic model for the stacking-fault energy