DEV Community

Surendra Singh Kamboj
Surendra Singh Kamboj

Posted on AI-assisted

Most probable, average and rms speed of gas molecules: Maxwell's numbers in JavaScript

For a gas at temperature T the three characteristic speeds are in the fixed ratio v_p : v_avg : v_rms = 1 : 1.128 : 1.225. Here are the numbers for nitrogen at 300 K, run in Node.

How do you calculate the three speeds?

const k = 1.380649e-23, m = 28.0134 * 1.66054e-27;   // N2 molecule, kg
const T = 300;
const vp   = Math.sqrt(2 * k * T / m);               // most probable
const vavg = Math.sqrt(8 * k * T / (Math.PI * m));   // mean
const vrms = Math.sqrt(3 * k * T / m);               // root mean square
console.log(vp.toFixed(1), vavg.toFixed(1), vrms.toFixed(1)); // 422.0 476.2 516.8 m/s
console.log(Math.sqrt(3 * k * 600 / m).toFixed(1));           // 730.9 m/s at 600 K
Enter fullscreen mode Exit fullscreen mode
Speed Formula N2 at 300 K
Most probable sqrt(2kT/m) 422.0 m/s
Average sqrt(8kT/(pi m)) 476.2 m/s
Root mean square sqrt(3kT/m) 516.8 m/s

What happens when the temperature doubles?

Every speed grows with the square root of T, so the speeds rise by a factor of 1.414: v_rms goes from 516.8 to 730.9 m/s.

FAQ: Why is v_rms the largest?

Squaring weights the fast molecules more heavily, so the rms value sits above the mean.

I build PractiSci, a free-to-start virtual lab. See the distribution move with temperature: Maxwell distribution lab. Chapter guide: Thermodynamics.

Top comments (0)