# How is conversion inside heat engines of heat (random motion) to work (organized motion) explained in quantum physics?

When heat engines convert heat into work, they change the random motion of millions of particles into motion in a single direction. What is the phenomenon responsible for this alignment of trajectories? Can quantum physics explain it?

To give you an example of how random motion can be directed: suppose you place a gas in a container that is floating in a vacuum, and then you drill a hole into the container. The previously random-gas will escape through the hole and will therefore now be travelling only in the (say) positive $x$ direction, with no atoms travelling in the negative $x$ direction (excluding the container itself). There isn't any sort of magical, low-level phenomenon responsible for this process.