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) {
33 char fb[32]="saves/fcc_test";
37 rand_init(&random,NULL,1);
38 random.status|=RAND_STAT_VERBOSE;
40 /* testing random numbers */
41 //for(a=0;a<1000000;a++)
42 // printf("%f %f\n",rand_get_gauss(&random),
43 // rand_get_gauss(&random));
53 printf("placing silicon atoms ... ");
54 //count=create_lattice(DIAMOND,Si,M_SI,LC_SI,a,b,c,&si);
55 //printf("(%d) ok!\n",count);
57 si=malloc(2*sizeof(t_atom));
69 printf("setting thermal fluctuations\n");
70 //thermal_init(si,&random,count,t);
74 /* check kinetic energy */
76 e=get_e_kin(si,count);
77 printf("kinetic energy: %f\n",e);
78 printf("3/2 N k T = %f\n",1.5*count*K_BOLTZMANN*t);
80 /* check total momentum */
81 p=get_total_p(si,count);
82 printf("total momentum: %f\n",v3_norm(&p));
84 /* check potential energy */
87 md.potential=potential_lennard_jones;
88 md.force=force_lennard_jones;
89 //md.cutoff_square=((LC_SI/4.0)*(LC_SI/4.0));
90 md.cutoff_square=36.0;
92 md.integrate=velocity_verlet;
98 lj.sigma6=3.0/16.0*LC_SI*LC_SI;
99 help=lj.sigma6*lj.sigma6;
101 lj.sigma12=lj.sigma6*lj.sigma6;
106 printf("potential energy: %f\n",u);
107 printf("total energy (1): %f\n",e+u);
108 printf("total energy (2): %f\n",get_total_energy(&md));
115 * let's do the actual md algorithm now
117 * integration of newtons equations
121 //visual_atoms(&vis,0.0,si,count);
124 moldyn_integrate(&md);
126 printf("total energy (after integration): %f\n",get_total_energy(&md));
135 //printf("starting velocity verlet: ");
138 //for(runs=0;runs<RUNS;runs++) {
143 * r(t+h) = r(t) + h * dr/dt|t + h^2/2m * F(t)
144 * dr/dt|(t+h) = dr/dt|t + h/2m * (F(t) + F(t+h))
147 //for(i=0;i<amount_si;i++) {
148 // /* calculation of new positions r(t+h) */
149 // si[i].x+=si[i].vx*tau;
150 // si[i].y+=si[i].vy*tau;
151 // si[i].z+=si[i].vz*tau;
152 // si[i].x+=(tau2*si[i].fx/m2);
153 // if(si[i].x>LX) si[i].x-=LEN_X;
154 // else if(si[i].x<-LX) si[i].x+=LEN_X;
155 // si[i].y+=(tau2*si[i].fy/m2);
156 // if(si[i].y>LY) si[i].y-=LEN_Y;
157 // else if(si[i].y<-LY) si[i].y+=LEN_Y;
158 // si[i].z+=(tau2*si[i].fz/m2);
159 // if(si[i].z>LZ) si[i].z-=LEN_Z;
160 // else if(si[i].z<-LZ) si[i].z+=LEN_Z;
161 // /* calculation of velocities v(t+h/2) */
162 // si[i].vx+=(tau*si[i].fx/m2);
163 // si[i].vy+=(tau*si[i].fy/m2);
164 // si[i].vz+=(tau*si[i].fz/m2);
165 // /* reset of forces */
170 // for(i=0;i<amount_si;i++) {
171 // /* calculation of forces at new positions r(t+h) */
172 // for(j=0;j<i;j++) {
173 // deltax=si[i].x-si[j].x;
174 // if(deltax>LX) deltax-=LEN_X;
175 // else if(-deltax>LX) deltax+=LEN_X;
176 // deltax2=deltax*deltax;
177 // deltay=si[i].y-si[j].y;
178 // if(deltay>LY) deltay-=LEN_Y;
179 // else if(-deltay>LY) deltay+=LEN_Y;
180 // deltay2=deltay*deltay;
181 // deltaz=si[i].z-si[j].z;
182 // if(deltaz>LZ) deltaz-=LEN_Z;
183 // else if(-deltaz>LZ) deltaz+=LEN_Z;
184 // deltaz2=deltaz*deltaz;
185 // distance=deltax2+deltay2+deltaz2;
186 // if(distance<=R2_CUTOFF) {
187 // tmp=1.0/distance; // 1/r^2
189 // tmp*=tmp; // 1/r^4
190 // lj1*=tmp; // 1/r^6
191 // tmp*=tmp; // 1/r^8
193 // lj1*=tmp; // 1/r^14
197 // si[i].fx-=lj*deltax;
198 // si[i].fy-=lj*deltay;
199 // si[i].fz-=lj*deltaz;
200 // si[j].fx+=lj*deltax;
201 // si[j].fy+=lj*deltay;
202 // si[j].fz+=lj*deltaz;
206 // for(i=0;i<amount_si;i++) {
207 // /* calculation of new velocities v(t+h) */
208 // si[i].vx+=(tau*si[i].fx/m2);
209 // si[i].vy+=(tau*si[i].fy/m2);
210 // si[i].vz+=(tau*si[i].fz/m2);
215 // /* rasmol script & xyz file */
216 // sprintf(xyz,"./saves/si-%.15f.xyz",time);
217 // sprintf(ppm,"./video/si-%.15f.ppm",time);
218 // fd1=open(xyz,O_WRONLY|O_CREAT|O_TRUNC);
220 // perror("rasmol xyz file open");
223 // dprintf(fd2,"load xyz %s\n",xyz);
224 // dprintf(fd2,"spacefill 200\n");
225 // dprintf(fd2,"rotate x 11\n");
226 // dprintf(fd2,"rotate y 13\n");
227 // dprintf(fd2,"set ambient 20\n");
228 // dprintf(fd2,"set specular on\n");
229 // dprintf(fd2,"zoom 400\n");
230 // dprintf(fd2,"write ppm %s\n",ppm);
231 // dprintf(fd2,"zap\n");
232 // dprintf(fd1,"%d\nsilicon\n",amount_si+9);
233 // for(i=0;i<amount_si;i++)
234 // dprintf(fd1,"Si %f %f %f %f\n",
235 // si[i].x,si[i].y,si[i].z,time);
236 // dprintf(fd1,"H 0.0 0.0 0.0 %f\n",time);
237 // dprintf(fd1,"He %f %f %f %f\n",LX,LY,LZ,time);
238 // dprintf(fd1,"He %f %f %f %f\n",-LX,LY,LZ,time);
239 // dprintf(fd1,"He %f %f %f %f\n",LX,-LY,LZ,time);
240 // dprintf(fd1,"He %f %f %f %f\n",LX,LY,-LZ,time);
241 // dprintf(fd1,"He %f %f %f %f\n",-LX,-LY,LZ,time);
242 // dprintf(fd1,"He %f %f %f %f\n",-LX,LY,-LZ,time);
243 // dprintf(fd1,"He %f %f %f %f\n",LX,-LY,-LZ,time);
244 // dprintf(fd1,"He %f %f %f %f\n",-LX,-LY,-LZ,time);
249 // /* increase time */
256 // printf(" done\n");