Explain the concept of entropy in thermodynamics and its significance in understanding the direction of energy flow and the efficiency of heat engines. Discuss how entropy relates to the second law of thermodynamics and its implications for engineering systems.