作者kanichan (KALA)
看板MATLAB
标题[运算] 透过histrogram计算RDF
时间Wed Oct 9 11:20:11 2013
参考了别人的radical distribution function code修改了许久
所绘出的图仍然有问题....
这边前面是取出图片中每个粒子的2D位置後设为cnt()
然後code如下
感觉是g_Now = hist(Rx,r)./r;这段出问题造成计算出来的平均粒子密度不为1
不知道是否有人可以提点一下.....
http://www.cchem.berkeley.edu/chem195/radial_distribution_8m.html
这边也有另一组别人写的code
但相较於下面这串从其他化工系硕论等级的语法我就不太懂里面需要的参数是什麽了....
我这边有的参数是从257*257 pixel的图片中约略2000个粒子的阵列的座标
http://goo.gl/JVrE1O
目前用下面的运算出来整个的平均密度不为1 而且还会decay= =
decay的部份应该是我把边界条件去掉的缘故
可是我还是不懂为何我算出来平均密度为6左右阿!!!!OTL
先感谢各位的协助了
前几天老板才在讲说现在业界都是需要会matlab的人才..............
e04都剩不到一年了什麽资源帮忙都没有还有时间要我生出一堆解决方案.......
唉.......连题目都不确定现在还要突然跳槽去搞模拟
%% Parameters -------------------------------------------------------------
dr = 1; % Step size in unit of nm
X = 20; % Range of g(r) in particle diameter
D = 50; % Ddiameter of a sphere in nm
d = 257/2000; % Pixel to micron ratio
r = 0:dr:X*D; % Distance variable
%% Functions---------------------------------------------------------------
g = zeros(1,length(r)); % Positional pair correlation function
M = length(cnt); % Total number of spheres
%% --------------------------------------
i = 1; % Reference sphere number
n = 0; % Reference sphere count
for i=1:M
N = 1; % N is the number of spheres withn a certain range (minus itself)
j = 1; % Comparing sphere number
for j=1:M
R = sqrt((cnt(i,1)-cnt(j,1))^2 + (cnt(i,2)-cnt(j,2))^2)/d; % Distance between ith and jth sphere
if R <= X*D && R~=0 % Excluding itself
Rx(N) = R; % Obtaining all the distances within the X*D circle
N = N + 1;
end
end
g_Now = hist(Rx,r)./r; % Histogram of Rx using r bin-series
g = g + g_Now; % Adding to the total g(r)
clear Rx; % Clear Rx vector
n = n + 1;
end
toc
plot(r,(g)); hold on
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.115.55.55
1F:→ kanichan:目前是透过觉得网址中的code来处理应该是比较快..... 10/09 11:22
2F:→ kanichan:可是我看不懂阿!!!!!!!!!!!!!!!!!!!Otz 10/09 11:23