# Comparing work in thermodynamics with work done in mechanics

Let us the consider a gas as our system enclosed in a cylinder with piston.

1st case(Expansion of gas):

Here force on the piston is exerted by the gas in upward direction and during expansion piston moves up. So, the work done here is positive(force and displacement in same direction). Also the relation W=PΔV (with their usual meanings) also satisfies the "positive" sense of work, since the volume increases during expansion.

2nd case(Compression of gas):

Here, the surrounding exerts the force on the piston and compresses the gas. Since, the direction of force by surrounding on the system and displacement of piston(both downwards) are in same direction, should not the work done by the surrounding on the system should be positive? But, W=PΔV gives -ve work, since volume decreases during compression. Why does the mechanical concept of work and W=PΔV does not give same result?

(In Physics)We are usually told that work done by the system is positive and work done by the surrounding on the system is negative.

But 2nd picture shows exactly what I am confused with. During compression, it is the gas that does negative work not the surrounding does the work in the gas?

1st picture is screenshot of book University Physics. 2nd picture is from here.

Normally both results are the same for work but it is defined in another way as you wrote: $dw = -pdV$ so the work you can get by integration.