freud: Incorrect RDF normalization
Describe the bug The radial distribution function g® that I accumulated for a trajectory does not have the correct limiting value. The system is dilute and so g -> 1 for large r, but freud’s result is consistently smaller. I recomputed g using VMD and obtained the behavior I physically expected. I can rescale the freud result onto VMD’s by multiplying by a factor of ~1.05, suggesting a possible normalization issue. (This factor could be specific to my system though: 20 particles, cubic box with L = 50, 1000 frames.)
To Reproduce
Minimum reproducer script (gr.py) and a sample trajectory (cm.gsd) are attached below. The script reads the trajectory and accumulates g® with rmax = 20 and dr = 0.2. The freud output (freud_gr.dat) should match the VMD output (vmd_gr.dat), and both should approach 1.
Error output
Comparison of freud and VMD output

System configuration
- OS: Ubuntu 16
- python 3.7.4
- freud 1.2.2 (I confirmed this on other system configurations too.)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 20 (2 by maintainers)
I think you are correct that it appears to be a definition issue. In the thermodynamic limit the two results are identical, but for the finite systems we’re calculating they differ by that factor of 1/N. To be honest I’m somewhat agnostic to the choice we make, as long as it’s properly documented (if we choose not to change the code I definitely think we need to make it clear in the docs that users should expect that scaling factor). I think that it’s probably a bit more precise not to change it, but users could certainly be surprised by the behavior for small N.
I’d like to get @joaander’s take on this before making any final changes since I believe he either wrote or oversaw the creation of this implementation. He’s out of town until after labor day unfortunately, but if this is holding you back let us know and we can at least create a fix ASAP and hold off on a final decision for when he returns.