Assume for purposes of discussion a closed container with a concentration of gas on one side and near-vacuum on the other. We could let the gas pressure equalise naturally, or we could construct a barrier with a turbine such that the gas moving from the concentrated side to the vacuum side spins the turbine and produces electricity. In both cases, the gas reaches equilibrium after some time, but in one of the cases the system performs work. My question is, what happens to the excess energy not used to produce electricity in the first example (with no turbine).
My intuition tells me that the answer has to be one of the following: Either the gas that drove the turbine is colder than the gas that did not, or that the electrical energy produced is actually less than the energy required to build the turbine so the electrical energy was actually input into the system by action of building the turbine.
Is either of my answer right? What else have I not accounted for?
Thanks.