Skip to content
scipython.com

Q8.1.2Number concentration from the ideal gas law

Use SciPy's constants and conversion factors to calculate the number density, \(N/V\), of ideal gas molecules at standard temperature and pressure (\(T = 0\;\mathrm{^\circ{C}}\), \(p = 1\;\mathrm{atm}\)). The ideal gas law is \(pV = Nk_\mathrm{B}T\).

Show solution

The calculation \(N/V = p/k_\mathrm{B}T\) for the stated conditions can be done entirely with constants from scipy.constants:

In [x]: from scipy import constants
In [x]: constants.atm / constants.k / constants.zero_Celsius
Out[x]: 2.686780111798444e+25

This is the Loschmidt constant which is defined by the 2010 CODATA standards and included in scipy.constants (see the documentation for details):

In [x]: from scipy import constants
In [x]: constants.value('Loschmidt constant (273.15 K, 101.325 kPa)')
Out[x]: 2.686780111e+25