2 * posic.c - precipitation process of silicon carbide in silicon
4 * author: Frank Zirkelbach <hackbard@hackdaworld.org>
10 #include "init/init.h"
11 #include "visual/visual.h"
15 int main(int argc,char **argv) {
28 char fb[32]="saves/fcc_test";
32 rand_init(&random,NULL,1);
33 random.status|=RAND_STAT_VERBOSE;
35 /* testing random numbers */
36 //for(a=0;a<1000000;a++)
37 // printf("%f %f\n",rand_get_gauss(&random),
38 // rand_get_gauss(&random));
48 printf("placing silicon atoms ... ");
49 count=create_lattice(DIAMOND,Si,M_SI,LC_SI,a,b,c,&si);
50 printf("(%d) ok!\n",count);
52 printf("setting thermal fluctuations\n");
53 thermal_init(si,&random,count,t);
57 visual_atoms(&vis,0.0,si,count);
59 /* check kinetic energy */
61 e=get_e_kin(si,count);
62 printf("kinetic energy: %f\n",e);
63 printf("3/2 N k T = %f\n",1.5*count*K_BOLTZMANN*t);
65 /* check total momentum */
66 p=get_total_p(si,count);
67 printf("total momentum: %f\n",v3_norm(&p));
70 * let's do the actual md algorithm now
72 * integration of newtons equations
82 //printf("starting velocity verlet: ");
85 //for(runs=0;runs<RUNS;runs++) {
90 * r(t+h) = r(t) + h * dr/dt|t + h^2/2m * F(t)
91 * dr/dt|(t+h) = dr/dt|t + h/2m * (F(t) + F(t+h))
94 //for(i=0;i<amount_si;i++) {
95 // /* calculation of new positions r(t+h) */
96 // si[i].x+=si[i].vx*tau;
97 // si[i].y+=si[i].vy*tau;
98 // si[i].z+=si[i].vz*tau;
99 // si[i].x+=(tau2*si[i].fx/m2);
100 // if(si[i].x>LX) si[i].x-=LEN_X;
101 // else if(si[i].x<-LX) si[i].x+=LEN_X;
102 // si[i].y+=(tau2*si[i].fy/m2);
103 // if(si[i].y>LY) si[i].y-=LEN_Y;
104 // else if(si[i].y<-LY) si[i].y+=LEN_Y;
105 // si[i].z+=(tau2*si[i].fz/m2);
106 // if(si[i].z>LZ) si[i].z-=LEN_Z;
107 // else if(si[i].z<-LZ) si[i].z+=LEN_Z;
108 // /* calculation of velocities v(t+h/2) */
109 // si[i].vx+=(tau*si[i].fx/m2);
110 // si[i].vy+=(tau*si[i].fy/m2);
111 // si[i].vz+=(tau*si[i].fz/m2);
112 // /* reset of forces */
117 // for(i=0;i<amount_si;i++) {
118 // /* calculation of forces at new positions r(t+h) */
119 // for(j=0;j<i;j++) {
120 // deltax=si[i].x-si[j].x;
121 // if(deltax>LX) deltax-=LEN_X;
122 // else if(-deltax>LX) deltax+=LEN_X;
123 // deltax2=deltax*deltax;
124 // deltay=si[i].y-si[j].y;
125 // if(deltay>LY) deltay-=LEN_Y;
126 // else if(-deltay>LY) deltay+=LEN_Y;
127 // deltay2=deltay*deltay;
128 // deltaz=si[i].z-si[j].z;
129 // if(deltaz>LZ) deltaz-=LEN_Z;
130 // else if(-deltaz>LZ) deltaz+=LEN_Z;
131 // deltaz2=deltaz*deltaz;
132 // distance=deltax2+deltay2+deltaz2;
133 // if(distance<=R2_CUTOFF) {
134 // tmp=1.0/distance; // 1/r^2
136 // tmp*=tmp; // 1/r^4
137 // lj1*=tmp; // 1/r^6
138 // tmp*=tmp; // 1/r^8
140 // lj1*=tmp; // 1/r^14
144 // si[i].fx-=lj*deltax;
145 // si[i].fy-=lj*deltay;
146 // si[i].fz-=lj*deltaz;
147 // si[j].fx+=lj*deltax;
148 // si[j].fy+=lj*deltay;
149 // si[j].fz+=lj*deltaz;
153 // for(i=0;i<amount_si;i++) {
154 // /* calculation of new velocities v(t+h) */
155 // si[i].vx+=(tau*si[i].fx/m2);
156 // si[i].vy+=(tau*si[i].fy/m2);
157 // si[i].vz+=(tau*si[i].fz/m2);
162 // /* rasmol script & xyz file */
163 // sprintf(xyz,"./saves/si-%.15f.xyz",time);
164 // sprintf(ppm,"./video/si-%.15f.ppm",time);
165 // fd1=open(xyz,O_WRONLY|O_CREAT|O_TRUNC);
167 // perror("rasmol xyz file open");
170 // dprintf(fd2,"load xyz %s\n",xyz);
171 // dprintf(fd2,"spacefill 200\n");
172 // dprintf(fd2,"rotate x 11\n");
173 // dprintf(fd2,"rotate y 13\n");
174 // dprintf(fd2,"set ambient 20\n");
175 // dprintf(fd2,"set specular on\n");
176 // dprintf(fd2,"zoom 400\n");
177 // dprintf(fd2,"write ppm %s\n",ppm);
178 // dprintf(fd2,"zap\n");
179 // dprintf(fd1,"%d\nsilicon\n",amount_si+9);
180 // for(i=0;i<amount_si;i++)
181 // dprintf(fd1,"Si %f %f %f %f\n",
182 // si[i].x,si[i].y,si[i].z,time);
183 // dprintf(fd1,"H 0.0 0.0 0.0 %f\n",time);
184 // dprintf(fd1,"He %f %f %f %f\n",LX,LY,LZ,time);
185 // dprintf(fd1,"He %f %f %f %f\n",-LX,LY,LZ,time);
186 // dprintf(fd1,"He %f %f %f %f\n",LX,-LY,LZ,time);
187 // dprintf(fd1,"He %f %f %f %f\n",LX,LY,-LZ,time);
188 // dprintf(fd1,"He %f %f %f %f\n",-LX,-LY,LZ,time);
189 // dprintf(fd1,"He %f %f %f %f\n",-LX,LY,-LZ,time);
190 // dprintf(fd1,"He %f %f %f %f\n",LX,-LY,-LZ,time);
191 // dprintf(fd1,"He %f %f %f %f\n",-LX,-LY,-LZ,time);
196 // /* increase time */
203 // printf(" done\n");