Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discrepancy between structure factors #1306

Open
joema10 opened this issue Feb 4, 2025 · 4 comments
Open

Discrepancy between structure factors #1306

joema10 opened this issue Feb 4, 2025 · 4 comments

Comments

@joema10
Copy link

joema10 commented Feb 4, 2025

I am using freud to calculate the structure factor from a trajectory computed with LAMMPS. I am trying to reproduce the results for the structure factor in figure 4 of this article: https://pubs.rsc.org/en/content/articlehtml/2021/sm/d1sm00445j

This is schematically my code using freud:

# Load x,y,z (positions)  and box limits (infLx, supLx)*(infLy, supLy)*(infLz, supLz)
# Transform coordinates to get the box size is (0,Lx)*(0,Ly)*(0,Lz)

points = np.column_stack((x, y, z))

deltaKbin = 2*np.pi/frame.Lx  
kmax = 8.16 
kmin = deltaKbin  
nbin = int((kmax-kmin)/deltaKbin)+1 

sf = freud.diffraction.StaticStructureFactorDirect(bins=nbin, k_max=kmax, k_min=kmin)
sf.compute((freud.box.Box(frame.Lx, frame.Ly, frame.Lz), points),reset=False)

Everything works fine for most of the cases (e.g. rho=0.155, 0.252 and T=0.3), but for rho=0.407 and T=0.3 I don't get the same result. In this case the g(r) is similar, but S(k) is totally different using freud (see below)

I have made my own code (very inefficient) and calculating S(k) sampling randomly values of \vec{k} gives similar results compare to the reported S(k). Also, using ovito I have calculated S(k) and it seems to come out similar as well. I don't know if this particular case is difficult because of some of the assumptions freud makes internally and I just haven't found the right set of parameters or if something is wrong

Please find attached screenshots of ovito, the comparison between my code and freud, as well as one of the frames of the simulation I am analysing

Any help is welcome

I am using jupyter-notebook in Ubuntu 18.04.6 LTS with:

  • python v3.9.21
  • freud v3.1.0

Frame_last.txt

Image

Image

@DomFijan
Copy link
Contributor

Have you tried using StaticStructureFactorDebye?
How do the results compare between Debye vs. Direct vs. your code?
It looks like the number of bins between what you use in your code and in Freud is also different. This is probably not the cause of the issue, but could you set the number of bins such that they are equivalent for easier comparison?
What happens if you set num_sampled_k_points in Direct to say 10 000? Do you get the same results? ( this also shouldn't matter)

@joema10
Copy link
Author

joema10 commented Feb 12, 2025

This is the result for all three methods. As you can see between 1 and 2 there is a maximum in both my code and Debye. That maximum is also observed in the given reference, but Direct does not show that maximum. For this figure I have used num_sampled_k_points=10000, but there doesn't seem to be any change from the default value.

Image

@DomFijan
Copy link
Contributor

Can you confirm that all the particles are inside the box? You can always wrap them for good measure.

Could you also share the full code you use to run the example, including extraction of box parameters, and coordinates from the file? With that I could try and take a closer look as well.

@joema10
Copy link
Author

joema10 commented Feb 15, 2025

Thanks for the suggestion. It seems that the particles are wrapped correctly

Attached is the python script I am using for this comparison. The framework I am using to calculate S(q) here is attached above. If you need anything else from me, please let me know

COMPUTE_Sq_from_LAMMPSdump.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants