Hi everyone! I'm running and modifying some code from the Alejandro Garcia book, "Numerical Methods for Physics". I generalized it to three dimensions, but noticed a problem when calculating the average temperature. Then I went back to the original, untouched program, and found that the problem was already there. The program essentially uses "representative particles", meaning each particle represents a certain number of particles in roughly the same position and velocity in a gas. It then divides up the volume it's in into cells, for processing collisions and a few other things. The cell widths should be a fraction of the mean free path to "ensure that a cell is locally homogeneous". It goes through a user submitted number of time steps, in which it moves the particles, processes collisions among themselves and the walls, sorts them into their new cells, and takes statistical averages. Basically, my problem is that the average temperature calculated by the program seems to get higher as there are less cells in the system, and lower as there are more cells. I think this happens because of how he's calculating the average temperature. Every time step a few averages are calculated for each cell. For a cell, it calculates ave_vx, ave_vy, ave_vz, and ave_v2, where the first three are averages of the x, y, and z velocities of the particles in that cell, and ave_v2 is the average of vx^2+vy^2+vz^2 for the particles in that cell. Now, the way it calculates temperature for each cell is by doing ave_v2-((ave_vx)^2+(ave_vy)^2+(ave_vz)^2). The book mentions that this isn't a proper measurement of temperature: "If you've ever had a rigorous training in equilibrium statistical mechanics, you should instinctively cringe at [this equation]. The proper thermodynamic definition of temperature is based on entropy and involves an average over an ensemble of states. All the same, it is useful to extend definitions of thermodynamic quantities, such as temperature, to nonequilibrium systems by using equilibrium identities, such as the equipartition theorem." Is this the reason why? Can anyone help me? Thanks!