Thermodynamics 

A Carnot cycle is an ideal thermodynamic cycle proposed by French physicist Sadi Carnot in 1824 and expanded upon by others in the 1830s and 1840s. By Carnot's theorem, it provides an upper limit on the efficiency of any classical thermodynamic engine during the conversion of heat into work, or conversely, the efficiency of a refrigeration system in creating a temperature difference through the application of work to the system.
In a Carnot cycle, a system or engine transfers energy in the form of heat between two thermal reservoirs at temperatures and (referred to as the hot and cold reservoirs, respectively), and a part of this transferred energy is converted to the work done by the system. The cycle is reversible, and there is no generation of entropy. (In other words, entropy is conserved; entropy is only transferred between the thermal reservoirs and the system without gain or loss of it.) When work is applied to the system, heat moves from the cold to hot reservoir (heat pump or refrigeration). When heat moves from the hot to the cold reservoir, the system applies work to the environment. The work done by the system or engine to the environment per Carnot cycle depends on the temperatures of the thermal reservoirs and the entropy transferred from the hot reservoir to the system per cycle such as , where is heat transferred from the hot reservoir to the system per cycle.
External video  

Carnot cycle from The Mechanical Universe 
A Carnot cycle as an idealized thermodynamic cycle performed by a heat engine (Carnot heat engine) consists of the following steps.
Isothermal expansion. Heat (as an energy) is transferred reversibly from hot temperature reservoir at constant temperature T_{H} to the gas at temperature infinitesimally less than T_{H} (to allow heat transfer to the gas without practically changing the gas temperature so isothermal heat addition or absorption). During this step (1 to 2 on Figure 1, A to B in Figure 2), the gas is thermally in contact with the hot temperature reservoir (while thermally isolated from the cold temperature reservoir) and the gas is allowed to expand, doing work on the surroundings by gas pushing up the piston (stage 1 figure, right). Although the pressure drops from points 1 to 2 (figure 1) the temperature of the gas does not change during the process because the heat transferred from the hot temperature reservoir to the gas is exactly used to do work on the surroundings by the gas, so no gas internal energy changes (no gas temperature change for an ideal gas). Heat Q_{H} > 0 is absorbed from the hot temperature reservoir, resulting in an increase in the entropy of the gas by the amount .
Isentropic (reversible adiabatic) expansion of the gas (isentropic work output). For this step (2 to 3 on Figure 1, B to C in Figure 2) the gas in the engine is thermally insulated from both the hot and cold reservoirs, thus they neither gain nor lose heat, an 'adiabatic' process. The gas continues to expand with reduction of its pressure, doing work on the surroundings (raising the piston; stage 2 figure, right), and losing an amount of internal energy equal to the work done. The gas expansion without heat input causes the gas to cool to the "cold" temperature (by losing its internal energy), that is infinitesimally higher than the cold reservoir temperature T_{C}. The entropy remains unchanged as no heat Q transfers (Q = 0) between the system (the gas) and its surroundings, so an isentropic process, meaning no entropy change in the process).
Isothermal compression. Heat transferred reversibly to low temperature reservoir at constant temperature T_{C} (isothermal heat rejection). In this step (3 to 4 on Figure 1, C to D on Figure 2), the gas in the engine is in thermal contact with the cold reservoir at temperature T_{C} (while thermally isolated from the hot temperature reservoir) and the gas temperature is infinitesimally higher than this temperature (to allow heat transfer from the gas to the cold reservoir without practically changing the gas temperature). The surroundings do work on the gas, pushing the piston down (stage 3 figure, right). An amount of energy earned by the gas from this work exactly transfers as a heat energy Q_{C} < 0 (negative as leaving from the system, according to the universal convention in thermodynamics) to the cold reservoir so the entropy of the system decreases by the amount .^{[1]} because the isothermal compression decreases the multiplicity of the gas.
Isentropic compression. (4 to 1 on Figure 1, D to A on Figure 2) Once again the gas in the engine is thermally insulated from the hot and cold reservoirs, and the engine is assumed to be frictionless and the process is slow enough, hence reversible. During this step, the surroundings do work on the gas, pushing the piston down further (stage 4 figure, right), increasing its internal energy, compressing it, and causing its temperature to rise back to the temperature infinitesimally less than T_{H} due solely to the work added to the system, but the entropy remains unchanged. At this point the gas is in the same state as at the start of step 1.
In this case, since it is a reversible thermodynamic cycle (no net change in the system and its surroundings per cycle)^{[2]}^{[1]}
This is true as and are both smaller in magnitude and in fact are in the same ratio as .
When a Carnot cycle is plotted on a pressure–volume diagram (Figure 1), the isothermal stages follow the isotherm lines for the working fluid, the adiabatic stages move between isotherms, and the area bounded by the complete cycle path represents the total work that can be done during one cycle. From point 1 to 2 and point 3 to 4 the temperature is constant (isothermal process). Heat transfer from point 4 to 1 and point 2 to 3 are equal to zero (adiabatic process).
Main article: Temperature–entropy diagram 
The behavior of a Carnot engine or refrigerator is best understood by using a temperature–entropy diagram (T–S diagram), in which the thermodynamic state is specified by a point on a graph with entropy (S) as the horizontal axis and temperature (T) as the vertical axis (Figure 2). For a simple closed system (control mass analysis), any point on the graph represents a particular state of the system. A thermodynamic process is represented by a curve connecting an initial state (A) and a final state (B). The area under the curve is:

(1) 
which is the amount heat transferred in the process. If the process moves the system to greater entropy, the area under the curve is the amount of heat absorbed by the system in that process; otherwise, it is the amount of heat removed from or leaving from the system. For any cyclic process, there is an upper portion of the cycle and a lower portion. In TS diagrams for a clockwise cycle, the area under the upper portion will be the energy absorbed by the system during the cycle, while the area under the lower portion will be the energy removed from the system during the cycle. The area inside the cycle is then the difference between the two (the absorbed net heat energy), but since the internal energy of the system must have returned to its initial value, this difference must be the amount of work done by the system per cycle. Referring to Figure 1, mathematically, for a reversible process, we may write the amount of work done over a cyclic process as:

(2) 
Since dU is an exact differential, its integral over any closed loop is zero and it follows that the area inside the loop on a T–S diagram is equal to the total work performed by the system on the surroundings if the loop is traversed in a clockwise direction, and is equal to the total work done on the system by the surroundings as the loop is traversed in a counterclockwise direction.
Evaluation of the above integral is particularly simple for a Carnot cycle. The amount of energy transferred as work is
The total amount of heat transferred from the hot reservoir to the system (in the isothermal expansion) will be
Due to energy conservation, the net heat transferred, , is equal to the work performed^{[1]}
The efficiency is defined to be:

(3) 
where
The expression with the temperature can be derived from the expressions above with the entropy: and . Since , a minus sign appears in the final expression for .
This is the Carnot heat engine working efficiency definition as the fraction of the work done by the system to the thermal energy received by the system from the hot reservoir per cycle. This thermal energy is the cycle initiator.
A Carnot heatengine cycle described is a totally reversible cycle. That is, all the processes that compose it can be reversed, in which case it becomes the Carnot heat pump and refrigeration cycle. This time, the cycle remains exactly the same except that the directions of any heat and work interactions are reversed. Heat is absorbed from the lowtemperature reservoir, heat is rejected to a hightemperature reservoir, and a work input is required to accomplish all this. The P–V diagram of the reversed Carnot cycle is the same as for the Carnot heatengine cycle except that the directions of the processes are reversed.^{[3]}
Main article: Carnot's theorem (thermodynamics) 
It can be seen from the above diagram that for any cycle operating between temperatures and , none can exceed the efficiency of a Carnot cycle.
Carnot's theorem is a formal statement of this fact: No engine operating between two heat reservoirs can be more efficient than a Carnot engine operating between those same reservoirs. Thus, Equation 3 gives the maximum efficiency possible for any engine using the corresponding temperatures. A corollary to Carnot's theorem states that: All reversible engines operating between the same heat reservoirs are equally efficient. Rearranging the right side of the equation gives what may be a more easily understood form of the equation, namely that the theoretical maximum efficiency of a heat engine equals the difference in temperature between the hot and cold reservoir divided by the absolute temperature of the hot reservoir. Looking at this formula an interesting fact becomes apparent: Lowering the temperature of the cold reservoir will have more effect on the ceiling efficiency of a heat engine than raising the temperature of the hot reservoir by the same amount. In the real world, this may be difficult to achieve since the cold reservoir is often an existing ambient temperature.
In other words, the maximum efficiency is achieved if and only if entropy does not change per cycle. An entropy change per cycle is made, for example, if there is friction leading to dissipation of work into heat. In that case, the cycle is not reversible and the Clausius theorem becomes an inequality rather than an equality. Otherwise, since entropy is a state function, the required dumping of heat into the environment to dispose of excess entropy leads to a (minimal) reduction in efficiency. So Equation 3 gives the efficiency of any reversible heat engine.
In mesoscopic heat engines, work per cycle of operation in general fluctuates due to thermal noise. If the cycle is performed quasistatically, the fluctuations vanish even on the mesoscale.^{[4]} However, if the cycle is performed faster than the relaxation time of the working medium, the fluctuations of work are inevitable. Nevertheless, when work and heat fluctuations are counted, an exact equality relates the exponential average of work performed by any heat engine to the heat transfer from the hotter heat bath.^{[5]}
See also: Heat Engine § Efficiency 
Carnot realized that, in reality, it is not possible to build a thermodynamically reversible engine. So, real heat engines are even less efficient than indicated by Equation 3. In addition, real engines that operate along the Carnot cycle style (isothermal expansion / isentropic expansion / isothermal compression / isentropic compression) are rare. Nevertheless, Equation 3 is extremely useful for determining the maximum efficiency that could ever be expected for a given set of thermal reservoirs.
Although Carnot's cycle is an idealization, Equation 3 as the expression of the Carnot efficiency is still useful. Consider the average temperatures,
For the Carnot cycle, or its equivalent, the average value ⟨T_{H}⟩ will equal the highest temperature available, namely T_{H}, and ⟨T_{C}⟩ the lowest, namely T_{C}. For other less efficient thermodynamic cycles, ⟨T_{H}⟩ will be lower than T_{H}, and ⟨T_{C}⟩ will be higher than T_{C}. This can help illustrate, for example, why a reheater or a regenerator can improve the thermal efficiency of steam power plants and why the thermal efficiency of combinedcycle power plants (which incorporate gas turbines operating at even higher temperatures) exceeds that of conventional steam plants. The first prototype of the diesel engine was based on the Carnot cycle.
A Carnot heat engine is a heat engine performing a Carnot cycle, and its realization on a macroscopic scale is impractical. For example, for the isothermal expansion part of the Carnot cycle, the following conditions must be satisfied simultaneously at every step in the expansion:^{[6]}
These (and other) "infinitesimal" requirements make the Carnot cycle take an infinite amount of time. Other practical requirements that make the Carnot cycle hard to realize (e.g., fine control of the gas, thermal contact with the surroundings including high and low temperature reservoirs), so the Carnot engine should be thought as the theoretical limit of macroscopic scale heat engines rather than a practical device that could ever be built.