It’s been crazy cold this week, even down where I live in Louisiana, thanks to an outbreak of a polar vortex. This frigid air is bad for all kinds of things, including football helmets, apparently. But it’s actually a great time to demonstrate one of the basic ideas in science: the ideal gas law.

You probably have some balloons somewhere around the house, maybe left over from New Year’s. Try this out: Blow up a balloon and tie it off real tight. Got it? Now put on the warmest jacket you have and take the balloon outside. What happens? Yes, with the drop in temperature the balloon shrinks—the volume inside decreases—even though it still contains the *same amount* of air!

How can that be? Well, according to the ideal gas law, there’s a relationship between the temperature, volume, and pressure of a gas in a closed container, so that if you know two of them you can calculate the third. The famous equation is **PV = nRT**. It says the pressure (**P**) times the volume (**V**) equals the product of the amount of gas (**n**), a constant of proportionality (**R**), and the temperature (**T**). Oh, by the “amount of gas” we mean the mass of all the molecules in it.

There’s a bunch of stuff to go over here, but let me get to the main point. There’s two ways to look at a gas. The one I just gave is actually the chemistry way. This treats a gas as a continuous medium, in the same way you’d look at water as just a fluid, and it has the properties we just mentioned.

But in physics, we like to think of a gas as a collection of discrete particles that move around. In the air, these would be molecules of nitrogen (N_{2}) or oxygen (O_{2}); in the model, they’re just tiny balls bouncing around in a container. An individual particle of gas doesn’t have a pressure or temperature. Instead it has a mass and velocity.

But here’s the important point. If we have two ways to model a gas (as continuous or as particles), these two models should agree in their predictions. In particular, I should be able to explain pressure and temperature by using my particle model. Oh, but what about the other properties in the ideal gas law? Well, we have the volume of a continuous gas. But since a gas takes up all the space in a container, it’s equal to the volume of the container. If I put a bunch of tiny particles in a box of volume **V**, that would be the same as the volume of the continuous gas. Then we have the “amount” of gas designated by the variable **n** in the ideal gas law. This is actually the number of moles for that gas. It’s basically just another way to count the number of particles. So, the particle and continuous model also have to agree here. (Want to know more about moles? Here’s an explanation for you.)

Particle Model for the Ideal Gas Law

OK, if you take an inflated balloon, it’s going to have a LOT of molecules of air in it, maybe around 10^{22} particles. There’s no way you could count them. But we can build a physics model of a gas using a much smaller number of particles. In fact, let’s start with just one particle. Well, I can easily model a single object moving with some constant velocity, but that’s hardly a gas. I at least need to put it in a container. To keep it simple, let’s use a sphere.

The particle will move inside the sphere, but it’s going to have to interact with the wall at some point. When that happens, the wall will exert a force on the particle in a direction perpendicular to the surface. In order to see how this force changes the motion of the particle, we can use the momentum principle. This says that a moving particle has a momentum (**p**) that is equal to the particle’s mass (**m**) times its velocity (**v**). Then a net force (**F**) will produce a certain change in the momentum (symbolized by **Δp**) per unit of time. It looks like this:

It’s possible to use this and find out how the momentum of the particle changes (and thus how the velocity changes), but what about the net force and the change in time? There are two tricks we can use here. First, I’m going to break the motion into small intervals of time (**Δt**). That means I don’t have continuous motion of the particle but instead just discrete steps. (It’ll be fine, trust me.)

Now for the force. When a particle hits the wall, there’s only one interaction, and that interaction will be the net force (only one force). I can model this surface interaction as if it were a spring. The more the particle pushes into the wall, the greater the force with which the wall pushes back against the particle. This is exactly how a spring behaves.

What does this single particle moving around in a sphere look like? For this, I’m going to use Python for my calculations. (You can see the code here if you’re interested.) Obviously this isn’t much like a real gas. I’m using a sphere with a radius of 1 meter and a “particle” with a mass of 100 grams. (That’s twice as heavy as a tennis ball, so be glad you don’t live in an atmosphere made up of these particles.) We could easily change those values and the model would look and act the same. It’s all good.

That looks nice. Now, if I can do one particle, I can easily do 100, right? First, here’s a very important point about the ideal gas law: It assumes that the molecules in the gas only interact with the walls of the container; they don’t interact with each other. That’s not entirely realistic (hence the term “ideal”), but it makes our modeling job much easier.

To make things as much like an actual gas as possible, I’m going to do two things. First, these 100 particles are going to start off randomly distributed throughout the sphere. Second, the initial velocities will have a normal distribution of speeds and will start off in random directions. Oh, I need a few more programming tricks to deal with 100 particles, but you can see the code here. Ready? Spin ’er up!

It looks fine, but does it act like an ideal gas? Let’s measure the temperature and pressure.

Measuring Temperature

What is temperature? It’s actually not as simple as you may think. My favorite macroscopic definition is that temperature is the property two objects have in common when they’re in contact with each other for a long time. (We call that thermal equilibrium.) However, at the particle level, temperature is a measure of the motion of the molecules. When a gas gets hotter, the stuff zips around with greater speed. We can measure this as the average particle kinetic energy, where the kinetic energy (**K**) is calculated as:

You can see how closely related that is to our expression for momentum above. So, for our particle model of a gas, I just need to calculate the kinetic energy of each particle and then find the average for all of them. Since my calculations are in Python, this is fairly straightforward. Running the program for 5 seconds, we can see if this value of kinetic energy changes over time.

OK, that doesn’t *look* constant, but it is essentially constant. First you can see from the graph that the kinetic energy only varies between about 0.78 and 0.81 (technically the units would be in joules). The reason it’s not perfectly constant is that when particles interact with the wall, they temporarily slow down. These lower speeds are counted in the average kinetic energy. However, in a real container there are many, many more particles in the middle that are *not* interacting with the side, so this would flatten out. I’m counting this as a constant.

Measuring the Pressure

Where the kinetic energy is a property of the gas particles, the pressure is due to the interaction with the walls (for an ideal gas). Pressure is defined as the force on a surface divided by the area of that surface. Well, I know the area of a sphere, it’s **4πr ^{2}**, where

**r**is the radius. That means I just need to calculate the force during each interaction, add up all these forces, and then divide by the area. Oh, guess what? I’m already calculating this wall force as part of the bouncing ball model. It’s so simple that even Python can do it. Here’s a plot.

This data jumps around quite a bit more than the average kinetic energy. We get a pressure (**P**) ranging between about 6 and 19 newtons per square meter with an average of 12.3 N/m^{2}. Again, this variability is a problem with the surface. With only 100 particles, most of them are not interacting with the wall at any given time. If there’s no interaction at all, the pressure would be zero. But imagine that I had 10^{22} particles. Although there would still be fluctuations in the pressure, the ratio of wall-interacting to non-wall-interacting particles would be fairly constant and would produce a constant pressure-time graph.

What Happens When the Volume Changes?

Now let’s do another little experiment—a computational experiment to see how well our Python model behaves. We already have calculations for a spherical container with a radius of 1 meter (average **K** = 0.79 and average **P** = 12.3). What happens if we keep the same temperature but shrink the sphere to a radius of 0.5 meter? Here’s what the two spheres look like side by side:

In both spheres, the particles are moving at the same speed. But in the small sphere on the left, they have less room to move around, so there are more collisions with the walls—which means a higher pressure. Indeed, the model gives me a **P** of around 78 N/m^{2}, much higher than the 12 N/m^{2} I got in the large sphere.

Let’s see if this agrees with the ideal gas law **(PV = nRT**). In this case, everything on the right side of that equation remains constant. Remember that **n** is a measure of the number of particles (both have 100), **R** is always a constant, and **T** is constant since I started with similar speeds. This means the stuff on the left-hand side of the equation (**PV**) must also be constant, so it’s the same for both spheres. I can write this as the following:

This says that the product of pressure and volume for the large sphere (**P _{1}V_{1}**) must be equal to the product for the small sphere (

**P**). Well, I have the values for pressure, and I can easily calculate the volume of a sphere—so let’s do it. Plugging in my values I get

_{2}V_{2}**P**= 41 and

_{1}V_{1}**P**= 44. That’s close enough for me (especially for a model with just 100 particles). So my particle model agrees with the predictions of the ideal gas law!

_{2}V_{2}What about the example of the balloon in cold air? Can we explain that using the particle model of a gas? Yes, we can. First, it’s important to note that the rubber skin of a balloon basically (but not perfectly) maintains a constant internal pressure. OK, so we have a balloon inside with a bunch of particles and some starting volume. When we take it outside the gas gets cold, so the particles will have a lower average kinetic energy and move slower. With slower-moving particles, there are two things that will happen. There will be fewer collisions with the wall of the balloon (because they are moving slower), and when they do collide, there will be a lower impact force (again because they aren’t moving as fast).

Again we can put all the constant values on one side of the ideal gas law and the stuff that changes on the other side. This leaves us with:

When **T** decreases, the only way to keep both sides the same is if the volume (**V**) also decreases. There you have it: A balloon gets smaller when it gets cold.