2 * posic.c - precipitation process of silicon carbide in silicon
4 * author: Frank Zirkelbach <frank.zirkelbach@physik.uni-augsburg.de>
11 #include "math/math.h"
12 #include "init/init.h"
13 #include "visual/visual.h"
17 int main(int argc,char **argv) {
36 char fb[32]="saves/lj_test";
40 rand_init(&random,NULL,1);
41 random.status|=RAND_STAT_VERBOSE;
43 /* testing random numbers */
44 //for(a=0;a<1000000;a++)
45 // printf("%f %f\n",rand_get_gauss(&random),
46 // rand_get_gauss(&random));
60 printf("placing silicon atoms ... ");
61 //count=create_lattice(DIAMOND,Si,M_SI,LC_SI,a,b,c,&si);
62 //printf("(%d) ok!\n",count);
64 si=malloc(2*sizeof(t_atom));
76 printf("setting thermal fluctuations\n");
77 //thermal_init(si,&random,count,t);
81 /* check kinetic energy */
83 e=get_e_kin(si,count);
84 printf("kinetic energy: %.40f [J]\n",e);
85 printf("3/2 N k T = %.40f [J]\n",1.5*count*K_BOLTZMANN*t);
87 /* check total momentum */
88 p=get_total_p(si,count);
89 printf("total momentum: %.30f [Ns]\n",v3_norm(&p));
91 /* check potential energy */
94 md.potential=potential_lennard_jones;
95 //md.potential=potential_harmonic_oscillator;
96 md.force=force_lennard_jones;
97 //md.force=force_harmonic_oscillator;
98 //md.cutoff_square=((LC_SI/4.0)*(LC_SI/4.0));
100 md.cutoff_square=(0.6e-9*0.6e-9);
103 md.integrate=velocity_verlet;
110 lj.sigma6=LJ_SIGMA_SI*LJ_SIGMA_SI;
111 help=lj.sigma6*lj.sigma6;
113 lj.sigma12=lj.sigma6*lj.sigma6;
114 lj.epsilon=LJ_EPSILON_SI;
116 ho.equilibrium_distance=0.3e-9;
117 ho.spring_constant=1.0e-9;
121 printf("potential energy: %.40f [J]\n",u);
122 printf("total energy (1): %.40f [J]\n",e+u);
123 printf("total energy (2): %.40f [J]\n",get_total_energy(&md));
129 printf("estimated accurate time step: %.30f [s]\n",
130 estimate_time_step(&md,3.0,t));
134 * let's do the actual md algorithm now
136 * integration of newtons equations
139 moldyn_integrate(&md);
141 printf("total energy (after integration): %.40f [J]\n",
142 get_total_energy(&md));
151 //printf("starting velocity verlet: ");
154 //for(runs=0;runs<RUNS;runs++) {
159 * r(t+h) = r(t) + h * dr/dt|t + h^2/2m * F(t)
160 * dr/dt|(t+h) = dr/dt|t + h/2m * (F(t) + F(t+h))
163 //for(i=0;i<amount_si;i++) {
164 // /* calculation of new positions r(t+h) */
165 // si[i].x+=si[i].vx*tau;
166 // si[i].y+=si[i].vy*tau;
167 // si[i].z+=si[i].vz*tau;
168 // si[i].x+=(tau2*si[i].fx/m2);
169 // if(si[i].x>LX) si[i].x-=LEN_X;
170 // else if(si[i].x<-LX) si[i].x+=LEN_X;
171 // si[i].y+=(tau2*si[i].fy/m2);
172 // if(si[i].y>LY) si[i].y-=LEN_Y;
173 // else if(si[i].y<-LY) si[i].y+=LEN_Y;
174 // si[i].z+=(tau2*si[i].fz/m2);
175 // if(si[i].z>LZ) si[i].z-=LEN_Z;
176 // else if(si[i].z<-LZ) si[i].z+=LEN_Z;
177 // /* calculation of velocities v(t+h/2) */
178 // si[i].vx+=(tau*si[i].fx/m2);
179 // si[i].vy+=(tau*si[i].fy/m2);
180 // si[i].vz+=(tau*si[i].fz/m2);
181 // /* reset of forces */
186 // for(i=0;i<amount_si;i++) {
187 // /* calculation of forces at new positions r(t+h) */
188 // for(j=0;j<i;j++) {
189 // deltax=si[i].x-si[j].x;
190 // if(deltax>LX) deltax-=LEN_X;
191 // else if(-deltax>LX) deltax+=LEN_X;
192 // deltax2=deltax*deltax;
193 // deltay=si[i].y-si[j].y;
194 // if(deltay>LY) deltay-=LEN_Y;
195 // else if(-deltay>LY) deltay+=LEN_Y;
196 // deltay2=deltay*deltay;
197 // deltaz=si[i].z-si[j].z;
198 // if(deltaz>LZ) deltaz-=LEN_Z;
199 // else if(-deltaz>LZ) deltaz+=LEN_Z;
200 // deltaz2=deltaz*deltaz;
201 // distance=deltax2+deltay2+deltaz2;
202 // if(distance<=R2_CUTOFF) {
203 // tmp=1.0/distance; // 1/r^2
205 // tmp*=tmp; // 1/r^4
206 // lj1*=tmp; // 1/r^6
207 // tmp*=tmp; // 1/r^8
209 // lj1*=tmp; // 1/r^14
213 // si[i].fx-=lj*deltax;
214 // si[i].fy-=lj*deltay;
215 // si[i].fz-=lj*deltaz;
216 // si[j].fx+=lj*deltax;
217 // si[j].fy+=lj*deltay;
218 // si[j].fz+=lj*deltaz;
222 // for(i=0;i<amount_si;i++) {
223 // /* calculation of new velocities v(t+h) */
224 // si[i].vx+=(tau*si[i].fx/m2);
225 // si[i].vy+=(tau*si[i].fy/m2);
226 // si[i].vz+=(tau*si[i].fz/m2);
231 // /* rasmol script & xyz file */
232 // sprintf(xyz,"./saves/si-%.15f.xyz",time);
233 // sprintf(ppm,"./video/si-%.15f.ppm",time);
234 // fd1=open(xyz,O_WRONLY|O_CREAT|O_TRUNC);
236 // perror("rasmol xyz file open");
239 // dprintf(fd2,"load xyz %s\n",xyz);
240 // dprintf(fd2,"spacefill 200\n");
241 // dprintf(fd2,"rotate x 11\n");
242 // dprintf(fd2,"rotate y 13\n");
243 // dprintf(fd2,"set ambient 20\n");
244 // dprintf(fd2,"set specular on\n");
245 // dprintf(fd2,"zoom 400\n");
246 // dprintf(fd2,"write ppm %s\n",ppm);
247 // dprintf(fd2,"zap\n");
248 // dprintf(fd1,"%d\nsilicon\n",amount_si+9);
249 // for(i=0;i<amount_si;i++)
250 // dprintf(fd1,"Si %f %f %f %f\n",
251 // si[i].x,si[i].y,si[i].z,time);
252 // dprintf(fd1,"H 0.0 0.0 0.0 %f\n",time);
253 // dprintf(fd1,"He %f %f %f %f\n",LX,LY,LZ,time);
254 // dprintf(fd1,"He %f %f %f %f\n",-LX,LY,LZ,time);
255 // dprintf(fd1,"He %f %f %f %f\n",LX,-LY,LZ,time);
256 // dprintf(fd1,"He %f %f %f %f\n",LX,LY,-LZ,time);
257 // dprintf(fd1,"He %f %f %f %f\n",-LX,-LY,LZ,time);
258 // dprintf(fd1,"He %f %f %f %f\n",-LX,LY,-LZ,time);
259 // dprintf(fd1,"He %f %f %f %f\n",LX,-LY,-LZ,time);
260 // dprintf(fd1,"He %f %f %f %f\n",-LX,-LY,-LZ,time);
265 // /* increase time */
272 // printf(" done\n");