Simuveliq

Ideal and real gas calculator

Type what you know about the gas —pressure, volume, temperature, moles, mass or density— and leave empty what you are looking for: the calculator solves for the unknown with the ideal gas law, explains the constant R in your units and warns when the data disagree. At high pressure or low temperature it compares the ideal gas with three real-gas equations.

Theory and worked examples: Ideal and real gases.

What you can do

Guide: ideal and real gases

A gas is described by four quantities: pressure P, volume V, amount n (moles) and temperature T. In an ideal gas the molecules take up no room and do not attract each other, and the four are tied by a single equation. This guide explains that equation, the combined gas law, mixtures (Dalton's law) and when to switch to a real gas, with examples solved in the calculator.

The ideal-gas equation

P · V = n · R · T

T is always in kelvin (T = t + 273.15). R is the same constant written in different units: 8.314 J/(mol·K) = 8.314 kPa·L/(mol·K) = 0.082057 L·atm/(mol·K) = 62.364 L·mmHg/(mol·K). Use the one that matches the units of P and V. The molar mass M turns mass into moles (n = m/M), and combining with the density gives ρ = P·M/(R·T): a measured density gives the molar mass of an unknown gas.

Worked example: grams of CO2 in a tank

A 10.0 L tank holds CO2 at 5.00 atm and 20 °C. How many grams are there?

  1. Units: T = 20 + 273.15 = 293.15 K; with P in atm and V in L, R = 0.082057 L·atm/(mol·K).
  2. Moles: n = P·V/(R·T) = 5.00 × 10.0 / (0.082057 × 293.15) = 2.079 mol.
  3. Mass: M(CO2) = 44.009 g/mol, so m = n·M = 2.079 × 44.009 = 91.48 g (and the density is 9.148 g/L).

Change of state: the combined gas law

When the same gas goes from one state to another, PV/(nT) has the same value before and after: P1V1/(n1T1) = P2V2/(n2T2). What does not change cancels out, leaving the named cases: Boyle (T and n constant, P·V constant), Charles (P constant, V/T constant), Gay-Lussac (V constant, P/T constant) and Avogadro (P and T constant, V/n constant).

Example: 500 mL of gas at 740 mmHg and 22 °C is brought to 0 °C and 760 mmHg. With the temperatures in kelvin (295.15 K and 273.15 K): V2 = 500 × (740/760) × (273.15/295.15) = 450.6 mL. Check: P·V/T = 1254 mmHg·mL/K in both states.

Mixtures: Dalton's law

In a mixture of ideal gases each gas exerts the pressure it would have alone in the vessel (its partial pressure), and the total is the sum: P = Σ Pi, with Pi = xi·P and xi = ni/ntotal. The mean molar mass is M̄ = Σ xi·Mi (dry air gives about 28.96 g/mol).

Gas collected over water: 250 mL of O2 collected over water at 25 °C with a barometric pressure of 755 mmHg. The gas comes out saturated with vapor; the vapor pressure of water at 25 °C is 23.78 mmHg, so P(O2) = 755 − 23.78 = 731.2 mmHg and n = P·V/(R·T) = 731.2 × 0.25 / (62.364 × 298.15) = 0.009832 mol (0.3146 g). Forgetting the water vapor would make the result 3.25 % too high.

Real gases and the factor Z

At high pressure or near the critical point the molecules do take up room and attract each other. The compressibility factor Z = P·v/(R·T) (v = V/n) measures the difference: Z = 1 is ideal. The cubic equations correct the ideal gas with just the critical temperature and pressure (and the acentric factor ω): van der Waals, P = RT/(v − b) − a/v², with a = 27R²Tc²/(64Pc) and b = RTc/(8Pc); Redlich–Kwong and Peng–Robinson, which refine the attraction term.

Example: 1 mol of CO2 in 0.500 L at 300 K. The ideal gas gives 49.89 bar; van der Waals 39.94 bar (Z = 0.8005), Redlich–Kwong 38.95 bar and Peng–Robinson 38.2 bar, against 38.74 bar from the reference equation of state of CO2. The ideal gas is 28.8 % too high; the cubics are within a few percent. If the pressure is given and the volume is sought, the cubic can have three roots: the smallest is the liquid, the largest the vapor, and the stable one has the lowest fugacity.

How to use the calculator

  1. At the top choose what to compute: Ideal gas, Change of state, Mixtures (Dalton) or Real gas.
  2. Type the data you have, each with its unit (atm, kPa, bar, mmHg; L, mL, m³; °C, K), and leave empty what you are looking for. The calculator says what it computes and what is missing, and warns if the data do not agree.
  3. Under «Real gas» choose the substance (its critical constants come from the CoolProp list) or type the a and b, or Tc, Pc and ω, of the exercise.
  4. Read the result, the figure and the step by step, and download the detailed solution as a PDF.

Common mistakes

More tools

Versión en español

© 2026 Simuveliq. All rights reserved.