Thermodynamic work done by or on a gas is equal to .
Work (w) is the force (F) acting on a body multiplied by distance () along which that force is applied.
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, .
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, . 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.
At the same time, is the distance the piston rises. It can be written as .
Note that the term 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 .
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.
In this sign convention, when 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 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.