freud icon indicating copy to clipboard operation
freud copied to clipboard

Diffraction pattern depends on shape of simulation box

Open tcmoore3 opened this issue 3 years ago • 3 comments

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):

  • I get this behavior with versions 2.4 and 2.5

tcmoore3 avatar Apr 20 '21 14:04 tcmoore3

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?

bdice avatar Apr 20 '21 14:04 bdice

@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.

tcmoore3 avatar Apr 20 '21 14:04 tcmoore3

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.

joaander avatar Apr 20 '21 15:04 joaander