Conversion of heat into work I am trying to learn Second law of thermodynamics, but could not intuitively understand why

heat can not be completely converted into work in a cyclic process but can be completely converted into work in a non-cyclic process.

If someone can explain it with some example having rotational motion of turbine than linear motion of piston it would be really helpful (because some people used the concept that you need to do some work to bring the piston back to its original position, which should not be the case in turbine motion).
Also, if you are using the concept of entropy, please define it first because I have learned two meanings of entropy:


*

*entropy from the classical thermodynamics point of view where it is just $\frac{Q}{T} ;$

*entropy from statistical thermodynamics point of view where it is the probability of a microscopic state of system it could be in.
 A: In a process like ideal (neglecting friction) isothermal expansion of a piston (only the expansion is considered), the heat you apply is completely converted into work. If we could use this process in an engine, 100% efficiency can be achieved (theoretically) but the length of the piston should be infinite. Since it is not possible, we use a cycle. We apply heat, get work then bring the working fluid to initial condition (heat rejection, contraction of the piston) then again repeat the same. Even in case of the turbine, the working fluid should be brought back to its initial state in order to obtain work continuously (in a power plant, Rankine cycle). This is why, Kelvin Planck statement says, it is not possible for a cyclic device to convert heat to work continuously without rejecting heat.
A: Closed cycle turbine losses include the movement of the gas around the primary coolant loop, for example.
Constraining the matter involved in the cycle to allow the process to repeat necessarily requires some device which does some work, consumes energy, and therefore introduces some "fundamental" inefficiency.
(As far as I can tell in practical world other losses are more significant and for example closed cycle gas turbines achieve higher efficiencies than open cycle ones.)
