Thermodynamics Applied to Heat Engines