Thermodynamics-related processes during the migration of acid gases and methane in deep sedimentary formations