Thermodynamics applied to Heat Engines