[CPMD-list] Pair correlation function
Younes Ansari
ara_1357_2416 at yahoo.com
Thu May 19 19:32:26 CEST 2005
I have a trajectory file like:
5 ----->no. of atoms
1 ------>no. of iteration
x1 y1 z1
x2 y2 z2
x3 y3 z3
..
..
5
2
x1 y1 z1
.
.
.
and I want to know if you can help me write a program in Matlab.
I have writen a program in matlab but I think there are many mistakes in it.
would you please send me how schematicly do it.
" in this section the program gets I=no. of terations you want to calculate g(r)"';
'" the time step of cpmd"';
'" g=the final distance to calculate g(r) "';
'" B=the box lenght witch is mostly similar to g'";
'" z=the no. of atoms '";
'" delta=the dr '";
I=input('Please input the number of Iterations: ');
timestep=input('please insert the time step of CPMD Iterations: ');
g=input('Please insert the distance: ');
B=input('Inser! t box lenght: ');
z=input('insert no. of atms: ');
delta=input('insert delta: ');
'"in this section, the program gets some parameters such as: "';
'" t,z1,n are some parameters to get the data from EXEL that you have changed TRAJEC.xyz to an exel format and import it to Matlab program"';
'" j,p are counters for the final normalization of g(r) '";
'" e is counting the no. of lines of deteminal G(by e(lines) & 1 (columns) ,v the same as G '";
t=1;
z1=2;
n=3;
y=0;
j=1;
e=g/.2;
G=zeros(e,1);
v=zeros(e,1);
d=1;
new=0;
p=0;
'" in this section the program starts to read the first r which is 0--->g and changes by 0.2 '";
'" every time the program c! alculates r the lin=lin+1 that used to normalize g(r) '";
for r=0:0.2:g
disp('r= ');r
mint=0;
min=0;
lin=0;
H=0;
'" q : in here we start to calculate the first iteration of the input file which is a 22 atom Cesium '"
'" l is a counter to read 22 lines of the input file '"
'" k= the first 22 line- x,y,z for the first atom and after the k is ended l=2 to calcu.. the second atom and so on to 22th atom'"
for q=1:I
for l=1:z
disp('r= ');r
for k=1:z-1
z1=z1+1;
if z1==n
z1=z1+1;
end
y=y+1;
'"in here the distance of each coordinate from others is calculated.'"
R(y)=((((TRAJEC((n),1)-TRAJEC((z1),1))^2)+((TRAJEC((n),2)-TRAJEC((z1),2))^2)+((TRAJEC((n),3)-TRAJEC((z1),3))^2))^(0.5));
'"o=the histogram to calculate'"
o=(R(y)/delta)+0.5;
'"fix is the same as (int) in Fortran '"
X = fix(o);
mint(y)=X;
'" in this section the program checks if the would be a R between r-delta to r+delta and if it is mint will be added to the min "';
if y>1
lin=lin+1;
if R(y)<(r+delta) & R(y)>(r-delta)
min=(mint(y)+H);
end
end
'"in here mint(y) is sent to H and next time if the condition=ok the mint=mint(y)+mint(y-1)"';
mint(y)=H;
end
'"in here n and z1 ar! e some parameters to chand the lines of the input file to read"'
n=n+1;
z1=t+1;
end
'" changing the lines of input file foe the next iteration'"
t=t+z+2;
z1=t+2;
n=t+2;
end
'"calculation of the slice and the volume'" ;
slice=((4/3)*3.141595*(((r+delta)^3)-(r^3)));
V=(((B^3)/z)*6.02E-2);
j=j+1;
v(j,1)=r;
p=p+1;
'"in this section g(r) will be calculated and if the first peak is appeared the mi! n of g(r) changes from zero to 1'";
if mint>0
new=1;
end
if new>=1
G(j,1)=1+((min*V)/(slice*z*2.4*lin*p));
else
G(j,1)=((min*V)/(slice*z*2.4));
end
n=3;
z1=2;
t=1;
end
---------------------------------
Discover Yahoo!
Find restaurants, movies, travel & more fun for the weekend. Check it out!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cpmd.org/pipermail/cpmd-list/attachments/20050519/0c9ca6f2/attachment.html
More information about the CPMD-list
mailing list