Thermodynamic work done by or on a gas is equal to −Pout⋅ΔV.
Work (w) is the force (F) acting on a body multiplied by distance (Δd) along which that force is applied.
w=F⋅Δd
Work is measured in joules (J), which is equivalent to newton meters (N·m). Work is a change in energy.
Consider a gas in a piston, assuming the mass of the piston and friction are both negligible. Under normal conditions, the air outside the system applies force on the piston, pushing it down. At the same time, the gas inside applies force on the piston, pushing it up. These forces balance each other, and there is no net force on the piston. In this condition, the magnitude of the pressure of the gas inside (Pg) is equal to the magnitude of the air pressure outside (Pout). Pg and Pout have the same magnitude, but they have opposite directions. Therefore, Pg=−Pout.
Pressure-Volume Work
An expanding gas in a piston does work against the outside pressure.
If the gas is heated, its particles will move faster, which increases the pressure in a fixed-volume container. Heating the gas causes the piston to rise. The pressure inside (Pg) remains equal to the pressure outside (Pout).
Consider the initial equation for work, w=F⋅Δd. In this case, the pressure of the expanding gas is applying a force on the surface area (A) of the piston. F is equal to Pg multiplied by A.
w=PgAΔd
At the same time, Δd is the distance the piston rises. It can be written as Δh.
w=PgAΔh
Note that the term AΔh is the surface area multiplied by the change in height. Area multiplied by height equals volume. Area multiplied by change in height is equal to the change in volume, or ΔV.
w=PgΔV
Traditionally, the work done by a piston is written in terms of the pressure the piston works against. Therefore, the term Pg is replaced by Pout, giving an equation that relates work and outside pressure.
w=−PoutΔV
In this sign convention, when ΔV is positive, w is negative. This means that as the gas does work on its surroundings, it loses energy. The gas is doing work by pushing the piston and is losing energy in doing so. If ΔV is negative, w is positive. This means that if the surroundings do work on the gas, the gas gains energy. The gas is being compressed by the surroundings and is gaining energy while being compressed.