I get confused in problems where it is necessary to evaluate the work done by a gas that someway moves a mass. I'll make an example.
Consider the tube containing mercury and an ideal gas in A (Picture $(1)$). If the gas expands and increases its volume, what is the work done by the gas?
My reasoning, illustrated in $(2)$ and $(3)$ would be: since the only effect of the expansion is to "move" the red volume of Hg from the initial position to an higher position in the thin tube, then the work done by the gas equals the amount of change in potential energy of the red volume of Hg, that's all, there is no other work done by the gas.
It seems right but also a bit contractictory. Suppose for istance that the section of the tube was the same in the two parts. Then there would be still change in the potential energy of the red volume of Hg, but it seems to me that in that case nothing happens, as the Hg "goes down" and "goes up" of the same height, and the work should be zero.
If all the previous is right, then my question is: is it correct to think about such situations in this way? I mean to look at small volumes of the fluid that overall change their position, whitout caring about the rest of the fluid, to evaluate the change in potential energy?