Can you discuss the underlying principles of thermodynamic cycles, focusing on the efficiency and entropy changes in reversible and irreversible processes, and elaborate on how these principles are applied in various mechanical systems to optimize performance?