I'm having trouble understanding when to include work done by external forces. I think that's probably hard to understand so I'm going to ask about some examples. Let's say, for example, you have a cylinder with a piston. When the pressure of the inside equals the (pressure of the outside, plus the force on the piston due to gravity), the piston moves and begins to do work, right? At the end of this process, the work done by the internal substance will exactly equal the opposite of the work done by the external pressure and force on the piston due to gravity, right? However, lets take an example where you're removing heat from the cylinder, IE the piston moves in the same direction as the force on the piston due to gravity and the force due to the external pressure. Here, you would have to find the total work done on the piston and then break it down into how much work the internal substance did, and how much the external forces did? One more, in many problems we've been asked to do, we're given a linear spring, and an atmospheric pressure (no mass on piston here for simplicity). On a PV(not specific) diagram, I usually end up with a triangle with a rectangle under it. The triangle is formed on the bottom by the distance between V1 and V2, on the side by the difference between P1 and P2 and the slope connecting these two lines is due to the spring. Under this triangle is a rectangle which extends down to the x axis between V1 and V2 that is included in the work integral. Does this rectangle represent the work to do resisting external forces?