Available energy and the second law analysis