Adibatic expansion of a gas¶
Until now we have worked with a box whose dimensions remain constant during the simulation. Modify your code so that the box can change size and shape during the simulation, for instance one or both walls moves at constant speed during the simulation to form a piston or a box with variable volume.
- What is the modified collision rule with the moving wall? Transform to a reference frame co-moving with the wall for the collision, then return back to the lab frame.
- Think how to change the function
_wall_time()
when the piston moves at constant speed. The collision time is again easy to find.
Energy is no longer conserved in this system, since the gas can do work on the piston. Study the temperature as a function of volume change and piston velocity.
In a second time perform cyclic motion in which the piston increases, then decreases the volume. Does the temperature return to its original value?
Defining the temperature¶
In statistical mechanics you have perhaps seen that equipartition implies that the kinetic energy per particle is linked to the temperature
$KE= \frac{3}{2} k_BT$, when working in three dimensions. The numerator 3
is just the dimension of space that we are working in. In two dimensions for our simulation we thus find that the kinetic energy per particle is linked to the temperature through: $$KE= k_BT $$