Microscopic approach to the concept of work in the expansion process of an ideal gas.

Consider a movable wall in the gas container, such as a piston. When the pressure exerted by the gas on the piston is greater than the outer pressure the wall shall move, until the gas and external pressure become equal. In this process the gas has done some work on the piston.
EXPERIENCE: The expansion of a gas.

Let us begin with the most simple case, a single particle bouncing off a wall that can move freely. The particle mass is taken to be unity, and the mass of the piston is set to 100, which can be changed with a glider. 

By pressing "On" the particle is set into motion with an energy that is shown in a window. When the particle bounces off the wall, this starts moving with a certain energy, which is the energy lost by the particle. 

The same experiment can be carried out with more particles. Now, the piston mass is larger. The gas releases energy to the piston, so that its temperature becomes lower. 

Looking at the results in the previous experience, choose one of the following options: 
In an ideal gas expanding against vacuum the temperature decreases. 
By doing work compressing a gas increases its temperature. 
In an ideal gas expanding against vacuum the internal energy decreases. 
The work W done by the gas can be easily computed. Considering an infinitesimal displacement &x of the wall due to collisions of the gas particles, it may be assumed that the pressure P remains nearly constant in that interval. If S is the area of the piston, the work is

&W= F*&x = P*S*&x = P*&V

where &V is the resulting change in volume.

In a finite displacement of the wall it is necessary to assume that the process is quasi-static, i.e. slow enough as to allow to define the instantaneous pressure in the gas, and then sum the infinitesimal contributions P*&V. In the limit, this sum becomes the integral of the pressure over the range of variation of the volume.

First Law
Index 1.Introduction 2.Pressure 3.Temperature 4.internal Energy
5.Heat 7.First Law 8.Entropy 9.Velocity Distribution 10.Specific Heat