Consider a cylindrical container contaning a gas with pressure P1 and volume V1 with a massless piston on top of the cylinder. There is a block of mass m on top of the piston. Suddenly, the mass is removed and so the gas expands irreversibly to a final pressure of P0 which is the external atmospheric pressure. Now I know that work done on a system depends on external forces, so the work done on gas will be = P0 *(change in volume)
Now, I want to know the work done on the atmosphere. So, in this case, my system will be the atmosphere and surroundings should be cylinder contaning the gas. So, work done on atmosphere by the gas will be = - P1 * (change in volume of container)......(or it should be an integral where pressure of gas changes from lower limit of P1 to an upper limit of P0).
So my question is, why are the two work calculated different? Is what I've done correct? One of my friend said that the way I'm calculating the work done by the gas on atmosphere is incorrect, if this is true, then what is the correct way?