Using the second principle of thermodynamics as a numerical stability criterion in snow models