glotzerlab / freud

Powerful, efficient particle trajectory analysis in scientific Python.
https://freud.readthedocs.io
BSD 3-Clause "New" or "Revised" License
276 stars 49 forks source link

Diffraction pattern depends on shape of simulation box #750

Open tcmoore3 opened 3 years ago

tcmoore3 commented 3 years ago

Describe the bug When calculating a diffraction pattern, I expect the symmetry of the diffraction to reflect that of the particle positions. However, if the box has edges of different lengths, then this is not the case. E.g., if I make a square lattice with different numbers of unit cells in each direction, then I get a diffraction pattern that does not have a 4-fold symmetric rotation axis. See this notebook for an example.

System configuration (please complete the following information):

bdice commented 3 years ago

Thanks for filing this issue — @tcmoore3 I know you’ve been working on this, have you been able to make any progress on fixing the problem?

tcmoore3 commented 3 years ago

@bdice I've figured out the origin of this bug in the code, which comes from how the k-vectors are generated, relevant lines here and here. I need help figuring out how to proceed from here, since fixing this requires decisions about what kinds of assumptions/approximations you have to make to do this calculation.

joaander commented 3 years ago

When I last looked at it with @tcmoore3 I was looking at the coordinate transforms used to map the system from the box to a unit cube on which the FFT is performed. The k-vectors should be spaced at 1/width (or 2pi/width) in this space. There should be an inverse transformation to map the k-vectors back to simulation units that is a function of the shear and scale matrices.