› Ideal Gas Laws Simulator Back
Thermodynamics / High School Physics

Ideal Gas Laws Simulator

Adjust temperature, volume, and moles to calculate pressure in real time using the ideal gas law. Experience Boyle's, Charles's, and Gay-Lussac's laws across P-V, P-T, and V-T diagram tabs.

State Parameters

Presets (Gas States)
Ideal Gas Law
$$PV = nRT$$ $P$: Pressure [Pa] $V$: Volume [m³]
$n$: Number of moles [mol] $T$: Temperature [K]
$R = 8.314\ \text{J/(mol·K)}$

Isothermal (T=const): $PV = \text{const}$
Isobaric (P=const): $V \propto T$
Isochoric (V=const): $P \propto T$

While paused, moving a slider updates the results immediately.

Results
—
Pressure P
—
P [kPa] / [atm]
—
Density ρ (air basis)
—
Molecular rms speed v_rms
P-V diagram
P-T diagram
V-T diagram
Pv
Vt
Results
—
Pressure P [kPa]
—
Volume V [L]
—
Temperature T [K]
—
Molecular speed v_rms [m/s]
Molecules (speed ∝ √T) Wall collisions → Pressure Piston (position ∝ V)
Reducing the volume increases collisions and raises pressure (Boyle's law). Raising the temperature accelerates the molecules and increases pressure and volume (Charles's/Gay-Lussac's law). PV=nRT always holds.
💬 Conversation to Deepen Understanding
🙋
PV=nRT — so if I increase P, V goes down... isn't that all there is to it? Why is temperature T also in the equation?
🎓
Boyle's law (PV=const) only holds 'when temperature is constant.' In reality, temperature changes too, so we need the general form PV=nRT that includes T. For example, a tire. On a hot summer day, the tire warms up, its volume (the tire shape) stays almost the same, but the pressure increases — that's an 'isochoric process.' If you move the temperature slider on the P-V diagram, you'll see the isothermal curves shift up and down.
🙋
Why do the isothermal curves on the P-V diagram become 'hyperbolas'?
🎓
When T=const, PV = nRT = constant. So P = k/V, an inverse proportion equation, and the graph becomes a hyperbola. The graph of XY = const is a hyperbola — it's exactly the 'inverse proportion graph' you learned in middle school math. The higher the temperature, the larger the constant k = nRT, so for the same volume the pressure is higher, shifting the hyperbola to the upper right.
🙋
What is 'molecular mean speed' in the simulator? Does it differ by gas type?
🎓
It's the 'root-mean-square speed' calculated by $v_{\rm rms} = \sqrt{3RT/M}$ (M is molar mass [kg/mol]). For air (M≈0.029) at room temperature (300K), it's roughly 516 m/s — faster than the speed of sound (343 m/s)! For light hydrogen (M=0.002), it's about 1934 m/s. Heavier gases move slower, and higher temperatures make them faster. In CFD analysis, this speed relates to the threshold of compressibility effects (Mach number).
🙋
With the 'Standard Conditions' preset, 1 mol came out to 24.5 L, but isn't the famous value 22.4 L?
🎓
22.4 L is the value at STP (0°C=273K, 1 atm). In recent international standards, 'standard conditions' have shifted to SATP (25°C=298K, 100 kPa), giving 24.5 L. V = nRT/P = 1×8.314×298/100000 ≈ 0.0248 m³ = 24.8 L (displayed as 24.5 L as an approximation). In entrance exams, '22.4 L' is still often used, but in practice and modern textbooks, 24.5 L is the standard.
🙋
In real CAE (thermal-fluid analysis), when do you use the ideal gas model and when do you not?
🎓
You can use the ideal gas model under conditions of low pressure (a few MPa or less) and high temperature (well above the boiling point). In Ansys Fluent, you just select 'Ideal Gas' in the fluid properties. On the other hand, for supercritical fluids (high-pressure CO₂ or water), intermolecular forces can't be ignored, so you switch to real gas models like van der Waals or Peng-Robinson. For gas turbine combustor analysis at around 1500K, the ideal gas model is fine, but for LNG (liquefied natural gas) transport analysis, you need a real gas model.
Frequently Asked Questions
Should I use absolute temperature [K] or Celsius [°C]?
PV=nRT always uses absolute temperature [K]. T[K] = T[°C] + 273.15. 0°C is 273K. Substituting in Celsius will cause large calculation errors, so be careful. Charles's law V/T=const also assumes absolute temperature; at 0°C volume does not become zero, but at -273°C (= 0K, absolute zero) it theoretically becomes zero.
What is Avogadro's law?
"Under the same temperature and pressure, equal volumes of all gases contain the same number of molecules." In PV=nRT, if P and T are fixed, V ∝ n only — meaning the type of gas (M) does not matter; volume is determined solely by the number of moles. In this simulator, switching the gas between "air" and "hydrogen" under the same conditions will show the same volume.
What does the area enclosed in a P-V diagram represent?
It represents the work done by the gas on the surroundings (or work done on the gas). W = ∫P dV. For isothermal expansion, W = nRT·ln(V₂/V₁). In a Carnot cycle heat engine, the four processes — high-temperature isothermal expansion, adiabatic expansion, low-temperature isothermal compression, adiabatic compression — form a closed area on the P-V diagram, and that area is the net work extracted per cycle.
What corrections does the van der Waals equation make?
In the form (P + an²/V²)(V - nb) = nRT, it corrects for intermolecular attraction and finite molecular volume. a is the attraction strength ([Pa·m⁶/mol²]), b is the molecular volume ([m³/mol]). For CO₂, a=0.364, b=4.27×10⁻⁵. At high pressures or near the critical point, deviations from ideal gas behavior become large. The critical temperature Tc = 8a/(27Rb) and critical pressure Pc = a/(27b²) can be derived.
Can the adiabatic process (PV^γ=const) be applied to ideal gases?
Yes, the adiabatic process for an ideal gas is expressed as PV^γ = const (γ = Cp/Cv is the heat capacity ratio). For monatomic gases, γ=5/3; for diatomic gases (air), γ=7/5=1.4. In adiabatic compression, temperature rises as T₂ = T₁(V₁/V₂)^(γ-1). Diesel engines compress air adiabatically to about 800°C or more, causing injected fuel to auto-ignite. On a P-V diagram, it appears as a steeper hyperbola than an isothermal curve.
What are the units and practical conversions for the gas constant R?
R = 8.314 J/(mol·K) = 8.314 Pa·m³/(mol·K). Practical conversions: when using volume in L, R = 8.314×10⁻³ kPa·m³/(mol·K) or 0.08206 L·atm/(mol·K) (convenient when using atmospheric pressure in atm). In engineering units, the specific gas constant R_specific = R/M [J/(kg·K)] is used (for air, R_air = 8.314/0.029 ≈ 287 J/(kg·K)).

How to Use

  1. Enter absolute temperature (K) in the temperature field; valid range 250–500 K for air simulations
  2. Set volume (m³) using the volume slider or direct input; typical range 0.01–1.0 m³ for laboratory chambers
  3. Specify number of moles (mol) of gas; for 1 kg of dry air at sea level, use approximately 34.5 mol
  4. Read output pressure in kPa and atm, density (kg/m³), and molecular RMS speed (m/s) calculated in real time

Worked Example

A sealed steel vessel contains 2.5 mol of air at T=300 K and V=0.050 m³. Using ideal gas law PV=nRT with R=8.314 J/(mol·K): P=(2.5×8.314×300)/0.050=124.7 kPa or 1.23 atm. Air density ρ=nM/V=(2.5×0.029)/0.050=1.45 kg/m³. Molecular RMS speed v_rms=√(3RT/M)=√(3×8.314×300/0.029)=484 m/s. Increasing T to 350 K raises P to 145.6 kPa while v_rms increases to 521 m/s.

Practical Notes

  1. Use absolute temperature (Kelvin); converting 25°C requires adding 273.15, not 273
  2. For compressed gas cylinders, typical pressures reach 20–30 MPa; this simulator models lower-pressure ranges (0.1–500 kPa)
  3. Density outputs assume dry air (M=0.029 kg/mol); moisture content alters results by 1–3%
  4. RMS speed predicts gas diffusion rates; nitrogen (M=0.028 kg/mol) travels ~2% faster than oxygen (M=0.032 kg/mol)

🎬 Watch it in motion

Phase Transitions of Matter Explained | Melting, Boiling and Sublimation Visualized
Phase Transitions of Matter Explained | Melting, Boiling and Sublimation Visualized