How squeezing and releasing a gas can pull enough heat out of water to turn it solid — and the physics behind every refrigerator, air conditioner, and heat pump on Earth.
Begin the tutorial →It sounds like a magic trick. You take a gas, push it together into a smaller space, let it cool down, then release it — and the gas comes out cold enough to freeze water solid. Yet this is exactly how the refrigerator in your kitchen works, and how the first commercial ice was manufactured in the 1830s.
The puzzle deepens when you remember that gases are invisible, weightless-feeling stuff. They have no obvious connection to temperature. But they do — and the connection is one of the deepest ideas in physics. Temperature is motion of molecules. Anything that systematically slows molecules down — including letting them push outward against a piston — will cool them.
This tutorial builds the explanation piece by piece. We will start from what temperature actually means at the molecular level, work our way through the ideal gas law and adiabatic processes, see exactly why expansion cools a gas, walk through the four-step refrigeration cycle that uses this fact, calculate the energy needed to freeze water, and finally put everything together in a working simulator.
By the end, you should be able to look at your fridge and understand every component on the back of it.
PV = nRT and what each letter meansThe core idea is simple: compression heats, expansion cools. The genius of refrigeration is doing both at the right places — heating the gas outside the fridge so it can dump heat to the room, then cooling it inside the fridge so it can absorb heat from your food. The next sections explain each link in that chain.
Before we can understand why expanding a gas cools it, we need to be honest about what temperature actually is. It is not a substance. It is not a fluid. It is a measure of how fast molecules are jiggling.
Every gas — air, helium, refrigerant vapor — is made of an enormous number of tiny molecules flying in straight lines until they collide with each other or with the walls of their container. The molecules carry kinetic energy: KE = ½ m v².
The temperature of the gas is just the average kinetic energy of those molecules. Double the temperature (on the Kelvin scale) and you have doubled the average kinetic energy. Cool the gas and you have slowed the molecules down. Cool it enough and they slow to a complete stop — that happens at 0 K, absolute zero, −273.15 °C.
When you touch something hot, what you feel as "hot" is billions of fast molecules slamming into your skin, transferring kinetic energy to your nerve cells. When something feels cold, your skin's faster molecules are losing energy to the slower molecules of the cold object. Heat always flows from faster molecules to slower ones, until the averages equalize.
Pressure on the walls of a container is the cumulative effect of trillions of molecule–wall collisions per second. Each molecule bounces off a wall, reversing momentum, and the wall feels a tiny push. Summed over the whole surface, that push is pressure.
This immediately tells us two things:
So pressure rises both when you crowd more molecules into the same space, and when you make them move faster (heat them up). This single observation is the seed of the entire ideal gas law.
Cooling a gas = slowing its molecules down. Any process that systematically removes kinetic energy from the molecules will lower the temperature. The trick of refrigeration is finding a process that does this — and expansion turns out to be exactly such a process.
Three centuries of experiments on gases boil down to one equation. For any gas at moderate pressures, four quantities — pressure, volume, amount, and temperature — are locked together by a constant.
| Symbol | Meaning | Units |
|---|---|---|
| P | Pressure — force per unit area on the walls | pascals (Pa) |
| V | Volume — space the gas fills | m³ |
| n | Amount — number of moles of gas | mol |
| R | Universal gas constant | 8.314 J/(mol·K) |
| T | Temperature (absolute) | kelvin (K) |
The equation says: if you know any three of these, you can compute the fourth. Compress a fixed amount of gas into half its volume without changing its temperature, and the pressure doubles. Squeeze it and hold pressure constant, and the temperature must drop. Every gas interaction in a refrigerator obeys this rule.
Real refrigerators manipulate P, V, and T along two idealized paths:
Isothermal — temperature held constant. Heat is allowed to flow in or out freely, so changes in V are balanced by changes in P with no temperature change. This is what the condenser coil approximates: hot gas dumps heat to the room while slowly condensing at roughly constant temperature.
Adiabatic — no heat flows in or out. Changes happen too fast, or the container is too well insulated, for heat exchange. Here P, V, and T all change together. This is what happens inside the compressor and the expansion valve.
The next section is about why adiabatic processes are the magic behind cooling.
Adjust the sliders to see how pressure, volume, and amount together fix the temperature of an ideal gas. The locked quantity T = PV / nR updates live.
Notice that if you double the pressure while keeping the volume and amount fixed, the temperature doubles too. Squeezing a gas without letting heat escape genuinely makes it hotter — which is exactly how a diesel engine ignites its fuel without a spark plug.
This is the heart of the whole tutorial. In an adiabatic process — one where no heat enters or leaves — compressing a gas makes it hot, and letting it expand makes it cold. The reason is energy bookkeeping.
Imagine a piston pushing inward on a gas. As the piston moves, it does mechanical work on the gas molecules: every molecule that hits the inward-moving piston bounces back slightly faster, like a tennis ball hit by an advancing racket. The piston's kinetic energy is being transferred into the gas.
If the gas were allowed to lose heat through the walls at the same time, this added energy would leak out and the temperature would stay roughly constant (isothermal). But in an adiabatic process the walls are insulating and the compression is fast — the energy has nowhere to go. It piles up as kinetic energy of the molecules. Average kinetic energy goes up. The gas gets hot.
This is why a bicycle pump gets warm when you pump up a tire, why diesel engines can ignite fuel without a spark, and why the gas coming out of a refrigerator compressor is genuinely hot to the touch.
Now run the process backwards. Pull the piston outward. The molecules bouncing off the retreating piston rebound slightly slower — like a tennis ball hit by a racket being pulled away. The piston is stealing kinetic energy from the gas to do work pushing it outward.
If the walls are insulating and the expansion is fast, no heat can flow in to make up the loss. The total kinetic energy of the gas drops. The molecules slow down. The temperature falls. This is the cooling we exploit.
The deeper way to say it: the gas is doing work on its surroundings (pushing the piston out), and that work has to come from somewhere. In an adiabatic expansion, it comes from the gas's own internal energy — which is exactly the kinetic energy of its molecules, which is exactly its temperature. Do enough work, drop the temperature enough, and you can freeze water.
For a monatomic ideal gas, γ = 5/3. For air (mostly diatomic N₂ and O₂), γ ≈ 1.4. The exponent means a small volume change produces a noticeable temperature change — which is exactly what we want for refrigeration.
Click and drag the piston handle up (expand) or down (compress). Watch how temperature, pressure, and the molecules' speed respond. Toggle between adiabatic (insulated, fast) and isothermal (heat leaks in/out, slow) modes to feel the difference.
In adiabatic mode, dragging the piston down heats the gas dramatically — a 2× compression takes a room-temperature gas up past 400 K. Drag it back up and the gas drops below freezing. In isothermal mode the temperature barely budges, because heat leaks through the walls to balance the work done. Refrigerators exploit the adiabatic behavior.
Real refrigerators don't use a piston to expand the gas — they use a tiny throttling valve (a "capillary tube" or "expansion valve"). The cooling that happens there has a slightly different cause and a name: the Joule–Thomson effect.
When a real gas is pushed through a constriction from high pressure to low pressure, something subtle happens. The expansion is isenthalpic — no heat is exchanged and no shaft work is done — yet the temperature still changes. For most gases at room temperature, the gas cools.
The cause is intermolecular forces. Real gas molecules aren't perfectly independent — they weakly attract each other. As the gas expands through the throttle, the molecules move farther apart, pulling against those attractive forces. That pulling costs energy, and the energy comes from the molecules' own kinetic energy. The gas slows down. It cools.
An ideal gas (a mathematical fiction with no intermolecular forces) shows no Joule–Thomson cooling at all. The effect exists purely because real gases aren't ideal.
Every gas has an inversion temperature. Below it, throttling cools the gas. Above it, throttling actually warms the gas.
| Gas | Inversion temp | Cools at room temp? |
|---|---|---|
| Helium | ~40 K | No — warms up |
| Hydrogen | ~200 K | No — warms up |
| Nitrogen (air) | ~620 K | Yes — cools |
| Oxygen (air) | ~760 K | Yes — cools |
| Carbon dioxide | ~1500 K | Yes — cools a lot |
This is why you cannot simply throttle room-temperature helium to cool it — you have to pre-cool it below 40 K first, which is why liquefying helium is hard. Conversely, CO₂ at room temperature cools so aggressively on throttling that it can partially solidify into dry ice.
The throttling valve in a real fridge exploits both effects at once: the pressure drop cools the refrigerant through the Joule–Thomson mechanism, and the partial evaporation of the high-pressure liquid refrigerant further drops the temperature (because evaporation itself absorbs latent heat — the same physics that makes sweat cool your skin). Together they produce the freezing-cold mixture that enters the evaporator coils.
Now we have all the ingredients. A real refrigerator stitches them into a closed loop that constantly pumps heat from a cold place (inside the fridge) to a hot place (your kitchen) — apparently violating common sense, but obeying thermodynamics perfectly.
An electric motor drives a piston that squeezes the cold low-pressure refrigerant vapor from the evaporator. Compression is fast and the gas is insulated from its surroundings, so it is nearly adiabatic. Both pressure and temperature shoot up. The gas leaves the compressor hot — often 60–80 °C — and at high pressure.
The hot high-pressure gas flows through the condenser coils on the back of the fridge. Because it is hotter than the room, heat flows out into the kitchen air. As it loses heat the gas condenses into a high-pressure liquid — still warm, but now liquid. The condenser is essentially isothermal during the phase change: the temperature holds near the refrigerant's condensation point while the latent heat is dumped.
The high-pressure liquid is forced through a tiny throttling valve (or a long thin capillary tube). On the other side the pressure is much lower. The liquid partially flashes into vapor. Both the Joule–Thomson cooling and the latent heat of evaporation combine to drop the temperature dramatically — by 30–50 °C in a typical fridge. This is the cold source.
The cold low-pressure liquid/vapor mix flows through the evaporator coils inside the fridge. Because it is colder than the food and water inside, heat flows from the contents into the refrigerant. The refrigerant absorbs this heat and evaporates fully into a gas. The contents get colder; the refrigerant returns to the compressor as a cool low-pressure gas, ready to start the loop again.
The colored stream shows the refrigerant. Red = hot high-pressure gas/liquid, blue = cold low-pressure vapor. Play it, or step through manually.
Heat naturally flows from hot to cold. The fridge apparently forces heat from cold (inside) to hot (kitchen) — but it pays for that with the electrical work fed to the compressor. The total energy — heat moved plus electrical work — gets dumped into the kitchen as heat. The second law of thermodynamics is safe: the entropy of the universe still increases. Your fridge is a heat pump, and heat pumps always need an external energy source.
To freeze water, the cold evaporator coils must pull out a specific, calculable amount of energy. There are two phases — cooling the liquid down to its freezing point, and then freezing it solid at that point.
Water has a specific heat capacity of 4.18 kJ/(kg·K) — meaning 4.18 kJ of energy must be removed to cool 1 kg of water by 1 K. Tap water at 20 °C must be cooled to 0 °C:
That is the easy part. Note that water has an unusually high specific heat — it takes a lot of energy to change its temperature, which is why oceans stabilize climate and why sweating is so effective at cooling us.
Once at 0 °C, the water still does not freeze. An additional, surprisingly large amount of energy — the latent heat of fusion — must be removed to convert liquid water to ice at the same temperature:
That energy goes into breaking loose the disordered liquid structure and locking molecules into the rigid crystal lattice of ice. The temperature stays pinned at 0 °C the entire time — phase changes are isothermal.
That is roughly the energy in a slice of bread, all of which must be carried away by the refrigerant and dumped into your kitchen. A typical domestic freezer can move about 50–100 kJ per minute, so freezing a 1 kg ice cube tray from room temperature takes 5–10 minutes of compressor time.
Set the evaporator coil temperature with the slider, then watch the water cool and freeze. The colder the coil, the faster heat is removed. Click the canvas to add a "seed crystal" — just like dropping a snowflake into supercooled water.
The plateau at 0 °C is the latent heat of fusion in action. During that flat part, the temperature stops dropping even though heat is still being removed — that energy is going entirely into the phase change, not into temperature. The wider the mass, the longer the plateau.
Here is everything wired up. Adjust the compressor power and expansion ratio, and watch the refrigerant travel the loop. Inside the fridge, a beaker of water sits in contact with the evaporator coil and freezes whenever the cycle runs cold enough.
Crank the compressor power too low and the evaporator never gets cold enough to drop the water below 0 °C. Push the expansion ratio too high and the compressor outlet overheats — at very high ratios the cycle becomes inefficient because too much of the work goes into re-heating rather than pumping heat. A real engineer tunes these for the refrigerant being used.
When the compressor runs, refrigerant gets hot in step 1, dumps that heat to the room in step 2 (condenser), then throttles down to a freezing-cold mix in step 3. That cold mix absorbs heat from the fridge interior — and from the beaker of water — in step 4. The water temperature falls, plateaus at 0 °C while the latent heat is removed, then drops further once it's solid ice. Turn the compressor off and the whole loop slowly equilibrates back to room temperature.
The vapor-compression cycle is one of the most successful engineering ideas in history. Once you understand it, you start seeing it everywhere.
The textbook case. Refrigerants like R-134a or isobutane run the four-step loop continuously, holding the interior between −18 °C (freezer) and +4 °C (fridge).
Same cycle, larger scale, with the evaporator coil inside your room and the condenser outside. A fan blows room air over the cold evaporator to cool it; another fan blows outside air over the hot condenser to carry heat away.
Run the cycle in reverse — evaporator outside, condenser inside — and the same machine becomes a heater that pulls heat from outdoor air (even at −10 °C) and dumps it indoors. Three units of heat delivered for every one unit of electricity spent.
The Linde process: compress air, cool it, throttle it through a valve to cool further (Joule–Thomson), use the cold exhaust to pre-cool the next batch, and repeat until the temperature drops below the gas's boiling point. This is how liquid nitrogen (77 K), oxygen (90 K), and even liquid helium (4 K) are produced industrially.
Compress CO₂ to high pressure, cool it, then throttle-expand it. The dramatic Joule–Thomson cooling (CO₂ has a huge inversion temperature) causes some of it to freeze directly into solid dry ice at −78.5 °C — no liquid phase involved.
Refration loops keep chemical reactors at sub-ambient temperatures, condense vapors in distillation columns, and crystallize out products. Without controlled cooling, most of modern petrochemistry would be impossible.
Air could in principle be used as a refrigerant (the "air cycle" was used on early aircraft). But air's specific heat per unit volume is low, its Joule–Thomson coefficient at typical operating conditions is modest, and it never condenses — so you lose the huge latent-heat benefit of a phase change. Real refrigerants are chosen because they boil and condense at convenient temperatures and pressures, and have large latent heats. Modern choices (hydrofluorocarbons, hydrocarbons, ammonia, CO₂) balance performance, safety, and environmental impact.
PV = nRT.Revisit the interactive demos above. Try compressing the piston rapidly in adiabatic mode and notice how hot the gas gets. Try throttling a tiny expansion ratio in the full simulator and notice how the water never freezes. The single equation PV = nRT and the single insight that expansion does work at the expense of internal energy are enough to predict almost everything you observed.
Built as a single self-contained HTML file — no servers, no installs, no dependencies beyond a font CDN with system-font fallback. Open it anywhere, even offline once cached.