NaveenKaliannan / StructureFactor

A simple matlab code to compute the structure factor S(q) from pair correlation function g(r)
20 stars 5 forks source link

Diffraction pattern is related to box shape #1

Open zhangyemayapro opened 1 year ago

zhangyemayapro commented 1 year ago

I'm dealing with a system composed of particles comfined in a circle and particles have arranged themselves into a triangular lattice. But I find that, the diffraction pattern is related to the box. Shouldn't the diffraction pattern independent of box?

from matplotlib import pyplot as plt
import numpy as np
import freud
uc = freud.data.UnitCell.hex()
n_repeats = (20, 20,1)
system = uc.generate_system(n_repeats)
position=system[1]
position=position[np.linalg.norm(position,axis=1)<10]
box=np.array([20., 40.,  0.,  0.,  0.,  0.], dtype="float32")
system=(box,position)

sf=freud.diffraction.DiffractionPattern(grid_size=512)
sf.compute(system,peak_width=1)

image image

fill-10 commented 1 year ago

It could be the periodic boundary condition.

zhangyemayapro commented 1 year ago

When I choose bigger box, the box still affects the symmetry.

box=np.array([40., 80.,  0.,  0.,  0.,  0.], dtype="float32")

How can I set non-period boundary?

Thanks for your help~

fill-10 commented 1 year ago

My guess: Lazy solution: use a smaller box, discard the particles outside and make sure that there is no vacuum space in your box. You will lose some resolution at small kx or ky. Permanent solution: write your own code/wait for the owner of this repo.

zhangyemayapro commented 1 year ago

Thanks for your help~