Boyle's Law Simulator
P₁V₁ = P₂V₂ — Isothermal Gas Compression • Simulate • Explore • Practice • Quiz
Display Controls
Drag the piston to change the volume Switch the chart to P vs 1/V or log–log to straighten the curve Right-click the canvas for more
Σ Live equations — values substituted from the current state
📈 Straightening the curve — P vs 1/V and the log–log form
⚡ Isothermal work — the area under the curve
💡 What-if coach — what to try next
1 Overview
This tool covers P₁V₁ = P₂V₂ two ways. Simulate gives you a piston or a sealed syringe of gas you can compress by hand, with animated molecules, a live pressure gauge and a chart that redraws as you drag. Calculate is a straight solver: type any three of P₁, V₁, P₂, V₂ and it returns the fourth with the full worked derivation.
The single most useful control is the Chart switch. Boyle's law draws a hyperbola on a P–V diagram, and a hyperbola is almost impossible to verify by eye. Switching to P vs 1/V or log–log straightens it into a line you can actually check with a ruler — which is how the law is tested in a real laboratory.
2 Driving the simulation
Drag the piston on the canvas, or use the Volume slider, or type an exact figure into the box beside it. The slider is logarithmic, so a syringe at 3 mL and a compressor at 50 L both get a usable amount of travel. Capacity sets the full stroke of the vessel; the volume can then be anything from 5% of it up to the full amount.
The Temperature control selects which isotherm you are on. Boyle's law governs movement along one curve, so dragging the piston never changes T. Moving the temperature is a separate action that hops you to a different curve, and the one you came from stays behind as a dashed ghost — which is how the textbook claim that hotter isotherms lie further from the origin becomes something you can see rather than something you are told.
The Gas tabs change the species. The PV product is identical for all three, because an ideal gas does not care which molecule it is made of; what changes is the molecular speed, since vrms = √(3RT/M). Helium (M = 4 g/mol) moves about 2.7× faster than air, CO₂ (M = 44) about 0.8× as fast, and the animation obeys that.
Switch Apparatus to Syringe for the version of this experiment a school laboratory actually runs: a graduated barrel with a sealed nozzle and a gauge, which is what you would set up on the bench.
3 The three chart views
P–V is the familiar rectangular hyperbola. Every point on it has the same PV product; the area beneath a section of it is the work done.
P vs 1/V plots pressure against the reciprocal of volume. Since P = k × (1/V), this is a straight line through the origin whose gradient is the Boyle constant k. This is the plot most school practicals ask for, because a straight line through the origin is easy to judge and the gradient hands you k directly.
log–log plots log₁₀P against log₁₀V. Taking logs of PV = k gives log P = −log V + log k, so this is a straight line of gradient exactly −1 with an intercept of log k. It is the sharper test of the two: the gradient is a pure number that does not depend on your units, so a line that comes out at −0.93 instead of −1 tells you something went wrong — usually that the gas warmed up while you were compressing it.
4 The Calculate tab
Pick which of P₁, V₁, P₂, V₂ you want, then type the other three. The chosen one becomes a read-only output so you cannot accidentally type into the answer. The result panel also reports the constant k, the compression ratio V₂/V₁, and the isothermal work W = k ln(V₂/V₁) in joules.
A detail worth knowing: Boyle's law needs only that the units of P match on both sides and the units of V match on both sides. You can work entirely in atm and mL if you want — no conversion to SI is required. What is not optional is that the pressure be absolute: a tyre gauge reading 220 kPa means 220 above atmospheric, so roughly 320 kPa absolute goes into the equation.
Press Show Calculation in the ribbon under the canvas for the full derivation, typeset properly, including the work integral.
5 Presets, exports and shortcuts
- Six presets load real scenarios: a 2 L lab cylinder, a 60 mL syringe, a diver's 6 L lungful, a 50 L compressor charge, tidal breathing, and a balloon carried to altitude.
- Export CSV writes a 30-point sweep of the current isotherm with V, P, 1/V, log V, log P and PV in separate columns — ready to paste into a spreadsheet and plot for a lab report — plus every state you traced by dragging.
- Save PNG exports the diagram with a watermark. Right-click the canvas for Copy state values, Export CSV, Export PNG, Toggle grid and Reset.
- Display Controls, at the top-left of the canvas, switch the grid, the isotherm, the ghost curve, the trail, the molecules, the gauge and the equation strip independently.
- The SI / Imperial switch reads everything in psi and cubic feet instead. It is display only — the law is solved in kPa and litres throughout.
6 Explore, Practice and Quiz
Explore holds sixteen concept cards in four groups — gas law basics, Boyle's law itself, applications, and ideal-gas theory — each with a formula, an explanation and a worked numerical example.
Practice generates randomised problems from twelve templates: the four rearrangements of P₁V₁ = P₂V₂, scuba depth, syringe, compressor, balloon, breathing, volume-ratio and unit-conversion questions. Enter a number and press Check. Show Solution reveals the steps and is not counted against your score.
Quiz is five multiple-choice questions drawn from a pool of fifteen, covering the statement of the law, the shape of the isotherm, the linear plots, where the law fails, and the applications.
7 Engineering notes
- Watch the k = PV readout as you drag. It should not move. That invariance is Boyle's law; everything else is a consequence.
- k is not a universal constant. It equals nRT for the sample in front of you, so it changes the moment you change the temperature or the amount of gas.
- 1 kPa·L = 1 J exactly, which is why the work readout is already in joules and why R = 8.314 kPa·L/(mol·K) is the same number as 8.314 J/(mol·K).
- A fast compression is not isothermal. Work a bicycle pump hard and the barrel gets hot — that is adiabatic, PVγ = constant, and the pressure rises faster than Boyle predicts. Compress slowly enough for the heat to leak away and you recover Boyle's law.
- Study the other two sub-laws with the Charles' Law Simulator and the combined equation with the Ideal Gas Law Calculator.
Boyle's Law — Understanding Pressure-Volume Relationships in Gases
Boyle's Law is one of the fundamental gas laws in thermodynamics, describing the inverse relationship between the pressure and volume of a gas at constant temperature. Discovered by Robert Boyle in 1662, it states that for a fixed mass of an ideal gas at constant temperature (isothermal conditions), the product of pressure and volume remains constant: PV = constant. This means that when you compress a gas into a smaller volume, its pressure increases proportionally, and when you allow it to expand, the pressure decreases. The mathematical expression P₁V₁ = P₂V₂ allows engineers and scientists to predict how gases will behave when confined volumes change.
The relationship produces a characteristic hyperbolic curve on a P-V diagram, where each curve (called an isotherm) represents the set of all possible pressure-volume states at a given temperature. At higher temperatures, the isotherm shifts outward, indicating that the gas occupies a larger volume at the same pressure. This simulator lets you visualise this behavior with animated gas particles bouncing inside a piston-cylinder assembly, providing an intuitive understanding of molecular behavior during compression and expansion.
How Does Boyle's Law Work?
At the molecular level, gas pressure results from molecules colliding with the walls of their container. When the volume decreases, the same number of molecules occupies a smaller space, leading to more frequent collisions with the container walls and thus higher pressure. Conversely, when the volume increases, molecules have more room to move, collisions become less frequent, and pressure drops. The key requirement is that the temperature remains constant — meaning the average kinetic energy of the molecules does not change. Only the frequency of collisions changes, not the force of each individual collision.
Straightening the curve — P against 1/V and the log–log plot
A rectangular hyperbola is a poor thing to test by eye. You cannot tell a genuine PV = k curve from something slightly wrong by looking at it, which is why nobody actually verifies Boyle’s law from a P–V plot. Instead the curve is linearised, and there are two standard ways to do it. Both are built into the Chart switch above the simulator.
Plot P against 1/V. Since P = k × (1/V), this is a straight line through the origin whose gradient is the constant k. Two things make it the usual choice for a school practical: a line through the origin is easy to judge by eye, and the gradient hands you k directly without any further arithmetic.
Plot log P against log V. Take logarithms of both sides of PV = k:
| Step | Working |
|---|---|
| Start from Boyle’s law | PV = k |
| Take log₁₀ of both sides | log(PV) = log k |
| Logs turn a product into a sum | log P + log V = log k |
| Rearrange into y = mx + c | log P = −log V + log k |
So a graph of log P against log V is a straight line with gradient exactly −1 and an intercept of log k. This is the sharper of the two tests, for a reason worth understanding: the gradient is a pure number. It does not depend on whether you measured in kPa or psi, litres or cubic inches — only the intercept moves when you change units. A measured gradient of −0.93 rather than −1 is therefore a real physical signal, and the usual cause is that the gas warmed up during the compression, so the process was not isothermal after all. That is the single most common way a Boyle’s law practical goes wrong.
Switch the chart in the simulator between the three views and the same state dot stays on the same gas: only the axes change. The hyperbola becomes a line through the origin, then a line of gradient −1.
Using the Boyle’s law calculator
The Calculate tab solves P₁V₁ = P₂V₂ for whichever quantity you are missing. Choose the unknown, type the other three, and the answer appears along with the constant k, the compression ratio and the work done.
| To find | Rearrangement | Typical question |
|---|---|---|
| P2 | P2 = P1V1 / V2 | Gas compressed into a smaller vessel — what pressure results? |
| V2 | V2 = P1V1 / P2 | A bubble rises and the pressure falls — how much does it expand? |
| P1 | P1 = P2V2 / V1 | Working backwards from a measured final state. |
| V1 | V1 = P2V2 / P1 | How much free air went into that receiver? |
Two rules decide whether your answer is right. First, the pressure must be absolute. A tyre or receiver gauge reads the amount above atmospheric, so add about 101 kPa before the value enters the equation — forgetting this is the most common error in the whole topic. Second, and more forgivingly, the units need only be consistent: P₁ and P₂ in the same unit, V₁ and V₂ in the same unit. Working in atm and millilitres is perfectly valid, because the units cancel on both sides. No conversion to SI is required.
What exactly is the Boyle constant k?
k is nothing more than the product PV for the particular sample of gas in front of you. Its usefulness is that it does not change while you compress or expand that sample at fixed temperature — which is precisely what the law asserts, and what the k = PV readout in the simulator lets you watch. Drag the piston through its whole travel and the number should not move.
It is not a universal constant like R. Comparing Boyle’s law with the ideal gas law gives k = nRT, so k belongs to one isotherm of one sample: change the temperature, or add gas, and k changes with it. Its units are kPa·L, which are joules — 1 kPa·L = 1 J exactly — and that is not a coincidence. The isothermal work done between two volumes is W = k ln(V₂/V₁), so k sets the energy scale of the whole process. Because ΔU = 0 for an isothermal ideal gas, the same quantity of heat must cross the boundary: Q = W.
Boyle's Law in Engineering Applications
Boyle's Law has wide-ranging applications across mechanical engineering, biomedical devices, and everyday life. Hydraulic and pneumatic systems rely on gas compression to transmit force — compressors, air brakes, and pneumatic actuators all operate on this principle. In scuba diving, understanding Boyle's Law is critical: as a diver ascends, the surrounding water pressure decreases, causing air in the lungs and buoyancy compensator to expand. Ascending too rapidly can cause decompression sickness. Medical syringes work by pulling the plunger back (increasing volume, decreasing pressure), which draws fluid into the barrel. Internal combustion engines compress the air-fuel mixture in the cylinder, increasing its pressure before ignition. Even breathing relies on Boyle's Law — the diaphragm contracts to increase lung volume, lowering the internal pressure below atmospheric pressure, which causes air to rush in.
Ideal Gas vs Real Gas Behavior
Boyle's Law applies perfectly to ideal gases, where molecules are assumed to have no volume and no intermolecular forces. Real gases (like air, helium, and CO₂) deviate from ideal behavior at very high pressures (where molecular volume becomes significant) and very low temperatures (where intermolecular forces dominate). For most engineering applications at moderate pressures and temperatures, Boyle's Law provides accurate predictions. The ideal gas equation PV = nRT combines Boyle's Law with Charles's Law, providing a more comprehensive model. In this simulator, you can experiment with different gas types and observe how they follow the P₁V₁ = P₂V₂ relationship.
A Bicycle Pump — The Cleanest Demonstration in the Workshop
Pick up a bicycle pump and seal the outlet with your finger. Push the handle down halfway. You feel the resistance rise sharply — you have just done Boyle’s experiment. Take the calculation through:
| Step | Working | Result |
|---|---|---|
| Initial state (uncompressed) | P1 = 1 atm = 101 kPa absolute, V1 = 200 mL | — |
| After pushing piston to half stroke | V2 = 100 mL | — |
| Apply Boyle’s law isothermally | P2 = P1V1/V2 = 101×200/100 | P2 = 202 kPa absolute |
| Gauge pressure (subtract atmosphere) | 202 − 101 | 101 kPa (~14.6 psi) |
| Push to one quarter stroke | V3 = 50 mL | — |
| New pressure | P3 = 101×200/50 | 404 kPa absolute (~44 psi gauge) |
The pressure quadruples when you compress to a quarter, exactly as the hyperbolic relationship predicts. That is why the last few inches of a bike-pump stroke feel so much harder than the first few. The relationship is non-linear in a way your hand feels but the formula sometimes hides.
Three Practical Cases Where Boyle’s Law Matters Daily
- Scuba diving. At 10 m depth, pressure is 2 atm. A diver’s lung volume at full inhalation is the same physical volume as at the surface, but holds twice the moles of gas. If the diver ascends without exhaling, lung volume doubles by the time they reach the surface — rupturing alveoli (pulmonary barotrauma). The first rule of scuba: never hold your breath while ascending.
- Scuba decompression sickness. The same gas absorbed under pressure (at depth) wants to come out of solution when pressure drops. Ascend slowly so nitrogen bubbles form gradually and the lungs can exhale them. Ascent rate guidelines (3−9 m/min) come from this calculation.
- Pneumatic compressor sizing. A workshop’s air receiver tank stores compressed air. To deliver 100 L of free air per minute, a 50-litre receiver at 8 bar holds about 8×50 = 400 L of free air — four minutes of supply if the compressor stops.
When Boyle’s Law Stops Being Accurate — The Real-Gas Correction
Boyle’s law assumes molecules occupy no volume and don’t attract each other. Both fail at high pressure. A real gas obeys the van der Waals equation:
(P + an²/V²)(V − nb) = nRT
The corrections kick in around 50 bar for air, much earlier for CO2 (which is close to its critical point at ordinary temperatures). Below 10 bar Boyle’s law is accurate to about 1 %. Above 100 bar it can be off by 10 % or more. For scuba tanks at 200 bar, real-gas tables (NIST, ASHRAE) replace the simple formula.
References for Gas Behaviour
- Cengel, Y. A. & Boles, M. A. — Thermodynamics: An Engineering Approach, 9th ed., Chapter 3 (Properties of Pure Substances).
- Boyle, R. (1662) — A Defence of the Doctrine Touching the Spring and Weight of the Air. The original paper. Worth reading at least once for the experimental method.
- NIST Reference Fluid Thermodynamic and Transport Properties Database (REFPROP) — the modern accurate source.
Boyle's Law & Gas Law Formulas
| Law | Formula | Condition |
|---|---|---|
| Boyle's Law | P1V1 = P2V2 | Constant temperature (isothermal) |
| Charles's Law | V1/T1 = V2/T2 | Constant pressure (isobaric) |
| Gay-Lussac's Law | P1/T1 = P2/T2 | Constant volume (isochoric) |
| Combined Gas Law | P1V1/T1 = P2V2/T2 | Fixed amount of gas |
| Ideal Gas Law | PV = nRT | R = 8.314 J/(mol·K) |
Explore Related Simulators
If you found this Boyle's Law simulator helpful, explore our Ideal Gas Law Simulator, Charles's Law Simulator, Specific Heat Capacity Simulator, Thermal Expansion Simulator, and Thermodynamics Cycles Simulator, and Pneumatic Circuit Simulator for more hands-on practice.