# Calculating temperature in molecular dynamics simulation

Can we use the formula for $V_{rms}$ to calculate the temperature of a ideal gas (In a molecular dynamics simulator)? Here is my approach to calculate the temperature:

1. At t=0, I initialize the velocities of molecules with values drawn from the range of (400,600) $m/s$ (drawn uniformly).
2. I let the distribution converge to a Maxwellian distribution of speeds.
3. At that time, I take the average of square of speeds of molecules, and take its root.
4. This gives me the $V_{rms}$ for the system.
5. I calculate the temperature using the standard formula.

Am I wrong at any step? Any advice on the initial distribution?

• You can only compute the temperature from the RMS-velocity if all of the particles have the same mass - is that the case? And note that the temperature must also be averaged over time. Regarding initial conditions: they don't matter too much if you allow the system to equilibrate, but it's standard to draw the initial velocities from the Maxwell distribution (i.e. the highlighted equation here). Commented Oct 8, 2016 at 11:02
• You specify molecules. Do you have to include the KE of rotational degrees of freedom, and the KE and PE of the vibrational modes? You might be able to ignore vibrational modes (not sure) but it seems to me that you would need to account for the rotation. Alternatively, you can calculate the KE of the atoms. (I'm not sure about any of this.) Commented Oct 8, 2016 at 11:55
• All particles have the same mass. Is it the case? My mentor has asked me to distribute the velocities uniformly, and then calculate the time it takes to converge to a Maxwellian. Commented Oct 8, 2016 at 16:17
• @garyp Yes, I am working with atoms, not molecules. Commented Oct 8, 2016 at 16:18