How do I calculate the pair distribution function, g(r), if I know a list of particle centres?

21 vues (au cours des 30 derniers jours)
I have a list of particle centre of mass in x, y, and z directions. I want to calculate the pair distribution function, g(r) that basically tells about the probability of finding a particle next to the reference particle. I followed the procedure given in this link How to calculate the pair correlation function g(r) (emory.edu), but didn't get the result as expected. This is what I tried.
count = 0;
for i = 1:np % np is the number of particles
for j = (i+1):np
dist = sqrt((x(i)-x(j))^2 + (y(i)-y(j))^2 + (z(i)-z(j))^2) % x, y, and z are the particle centre of mass
for r = 1:del_r:50 % for now i used del_r=1
volume(r) = 4*pi*r^2*del_r;
if (dist < r) && (dist < (r + del_r))
count = count + 1; % the problem is to count the number of particles that satisfy this if condition.
tot_count(r) = count/np;
end
end
end
cnt_ovr_vol = tot_count./volume;
num_den = np/(nx*ny*nz); %nx = ny = nz = 100;
g_r = (cnt_ovr_vol./num_den);
end
Does my code make sense as per the procedure in the link?
  2 commentaires
Amirsaman Eghtesad
Amirsaman Eghtesad le 2 Août 2022
According to the link, you have to change (dist < r) to (dist >r).
Hisay Lama
Hisay Lama le 6 Juil 2023
You need to take care of edge correction, mentioned here:
They used a function checkquadrant for that.

Connectez-vous pour commenter.

Réponses (1)

Aditya Shah
Aditya Shah le 11 Oct 2022
Hi!
The following MATLAB File Exchange example, explains how to calculate the Pair distribution Function g(r):

Catégories

En savoir plus sur Triangulation Representation dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by