Pressure-dependence of electrolysis voltage I'm trying to better understand electro-chemistry, so please explain why this second-kind perpetual motion device won't work. I guess it's safe to assume it won't work one way or another.

There is a cycle, which starts with low-pressure water.


The water is pressurized by a compressor. This requires work, but since water is nearly incompressible, the required work is very low: the distance over which the pressurization force is applied is almost zero.
Next, the high-pressure water is split into high-pressure hydrogen and oxygen gas. This requires a certain amount of electrical work.
Next, the high-pressure hydrogen and oxygen gas are expanded through turbines, expanding cylinders or other devices that allow the expansion to apply output work. Heat is added to keep the temperature constant during expansion, to maximize the work output. Note that, unlike the compression stage, expansion deals with gases, which are very compressible; therefore, the amount of work produced is substantial.
To close the cycle, the hydrogen and oxygen gases are recombined in a fuel cell, to end up with the same amount of water, at the same pressure as when we started the cycle. This delivers some electrical work.


Of course there are going to be energy losses; I expect the fuel cell will always yield less energy than is required in the electrolyzer. However, the difference between the compression work and the expansion work can be scaled up arbitrarily by using a higher pressure difference, so at some point this difference in work must yield more energy than is lost in the electrolysis/fuel cell combination. This energy comes from the heat flowing into the expander, but simply turning heat into excess work should not be possible.

So, what is wrong? The only way I see to prevent this to work is if the electrolyzer requires more work per reaction mass (essentially its voltage) than the fuel cell, even if they are both 100% efficient. This would imply that the reaction voltage is pressure-dependent, with a higher voltage at higher pressures. Is this the case? And is this only the case if the output material is more compressible (gas) than the input material (liquid)?

(The same should be true for evaporation/condensation enthalpies, as we could have designed a very similar cycle with evaporation/condensation instead of electrolysis/fuel cell.)
Of course, we're starting by acknowledging a perpetual motion machine is impossible.  The question, then, is how do we understand, through chemical thermodynamics, why your specific set of steps can't constitute a perpetual motion machine.  

The answer is that what you're not accounting for is that the electrical energy required for your step 2 is greater than you get back from your step 4, even if we don't have losses.  That's because, everything else being equal, the work needed to create gases against a high pressure is greater than that needed to create gases against a low pressure. I.e., $|w_2| &gt; |w_4|$.  

To understand why, let's simplify things by considering the pressure-dependence of the free energy of a pure substance at constant T: dG = VdP.  In step 2, because the pressure is so, high, you have increased the free energies of both the reactants and the products relative to what they'd be at atmospheric pressure.  To get the actual changes, you would need to calculate $\int^{P_f}_{P_i}V(P) dP$ for the reactants and products.  Since the products are gases (oxygen and hydrogen), and the volume of gases is much larger than that of liquids, the free energies of the products would be raised far more than that of the reactant (a liquid).  Thus the separation between the free energies of the reactants and products, (i.e.,  the magnitude of $\Delta G_r$) for step 2 (which is at high pressure), will be substantially greater than it is for step 4 (which is at low pressure).

You could also understand it using Le Chatelier's principle:  The volume of the products is higher than that of the reactants, and thus higher pressure will favor the reactants over the products.