Ideal Gas Law Simulation Report

Simulating the Relationship Between Pressure and Other Variables in a 3D Environment

Luke Carlson
Trevor Day School
March 11, 2013


The Ideal Gas Law describes the characteristics of ideal gas in a container. Often written as \(PV=nRT\), this law displays the relationship between Pressure, Volume, Temperature, moles of the particle, and the universal gas constant in a system. The Ideal Gas Law can be derived from combining three other gas laws: Boyle’s Law, Charles’s Law, and Avogadro’s Law.

Boyle’s Law postulates that in a system with uniform temperature, the pressure of an ideal gas is inversely proportional with volume of the gas. Thus, the pressure times the volume is equal to a constant value in the system, often shown as \(PV = k\) (where k is the constant). Since the constant is the same no matter the circumstances in the system, the law can be used to relate changes in pressure or volume as \(P_{1}V_{1} = P_{2}V_{2}\) (where 1 indicates the initial and 2 is the final state).

Charles’s Law states that in a system with uniform pressure, the temperature is inversely proportional to the volume of the container holding the ideal gas (\(V \propto T\)). Since this law applies to any variation in volume or temperature, it can be written as \(\frac{V_{1}}{T_{1}} = \frac{V_{2}}{T_{2}}\)

Avogadro’s Law declares that in a system with a constant temperature and pressure, equivalent volumes of the same ideal gas will contain an equal number of particles. Mathematically, the relationship can be shown using \(\frac{V}{n} = k\) (where k is the constant in the system).

These three laws can be combined mathematically to create \(\frac{PV}{Tn} = R\) (R is a constant in the system). When rearranged, this creates \(PV=nRT\) or the Ideal Gas Law.


In this lab, I set out to create a 3D simulation of ideal gas particles in a cubic container in order to experimentally determine the pressure of the gas based on given circumstances. From there, I planned to explore the relationship between pressure and volume as well as pressure and number of particles.To produce an sumlation, a replication of a real world circumstance using programming, of a gas particle it is first necessary to understand exactly how particles affect the pressure of a system. Pressure is the amount of force over a specific area, also written as \(Pressure=F/A\). Force can also be described as change in momentum over change in time: \(F = \frac{\Delta p}{\Delta t}\). The change momentum of a single particle equals its mass multiplied by its change in velocity: \({\Delta p} = m\Delta v\). Since there is more than one particle in a system, the entire change in momentum is the combined change in velocities of each particle that hits the specified area. Thus, the following formula can be used to determine total force:

  \(F = \frac{2m * \displaystyle\sum\limits_{i=1}^n v}{\Delta t}\) Where \(n\) is the number of collisions and \(v\) is the velocity of the particle hitting the wall. Since the change in velocity is double the initial velocity, the 2 can be placed outside the summation along with the mass.

Once the force has been computed using the momentum of the particles, the pressure can then be determined with the initial formula \(P = F/A\).


Increasing the number of particles in the simulation will yield a greater pressure. Furthermore, increasing the volume of a container will decrease the pressure in the system.