2 * sic.c - investigation of the sic precipitation process of silicon carbide
4 * author: Frank Zirkelbach <frank.zirkelbach@physik.uni-augsburg.de>
13 #include "potentials/harmonic_oscillator.h"
14 #include "potentials/lennard_jones.h"
15 #include "potentials/albe.h"
18 #include "potentials/tersoff_orig.h"
20 #include "potentials/tersoff.h"
28 //#define INJ_LENX (1*ALBE_LC_SIC)
29 //#define INJ_LENY (1*ALBE_LC_SIC)
30 //#define INJ_LENZ (1*ALBE_LC_SIC)
31 #define INJ_LENX (1*ALBE_LC_SI)
32 #define INJ_LENY (1*ALBE_LC_SI)
33 #define INJ_LENZ (1*ALBE_LC_SI)
34 #define INJ_TYPE_SILICON
35 //#define INJ_TYPE_CARBON
36 #define INJ_OFFSET (ALBE_LC_SI/8.0)
45 #define R_TITLE "Silicon self-interstitial"
53 int a_count; /* atom count */
54 u8 quit; /* quit mark */
55 int argc; /* arg count */
56 char **argv; /* args */
59 int hook_del_atom(void *moldyn,void *hook_params) {
67 set_pt_scale(md,0,0,T_SCALE_BERENDSEN,100.0);
73 int hook_add_atom(void *moldyn,void *hook_params) {
90 /* switch on t scaling */
91 if(md->schedule.count==0)
92 set_pt_scale(md,0,0,T_SCALE_BERENDSEN,100.0);
94 /* last schedule add if there is enough carbon inside */
95 if(hp->a_count==(INJECT*NR_ATOMS)) {
97 moldyn_add_schedule(md,POSTRUN,1.0);
101 /* more relaxing time for too high temperatures */
102 if(md->t-md->t_ref>T_C) {
103 moldyn_add_schedule(md,RELAX_S,1.0);
107 /* inject carbon atoms */
108 printf("injecting another %d atoms ... (-> %d / %d)\n",
109 NR_ATOMS,hp->a_count+NR_ATOMS,INJECT*NR_ATOMS);
110 for(j=0;j<NR_ATOMS;j++) {
121 r.x=-1.0/8.0*ALBE_LC_SI;
122 r.y=-1.0/8.0*ALBE_LC_SI;
123 r.z=1.0/8.0*ALBE_LC_SI;
127 r.x=(-0.5+0.25+0.125)*ALBE_LC_SI;
128 r.y=(-0.5+0.25+0.125)*ALBE_LC_SI;
129 r.z=(-0.5+0.25)*ALBE_LC_SI;
130 md->atom[4372].r.x=(-0.5+0.125+0.125)*ALBE_LC_SI;
131 md->atom[4372].r.y=(-0.5+0.125+0.125)*ALBE_LC_SI;
135 r.x=(rand_get_double(&(md->random))-0.5)*INJ_LENX;
136 r.y=(rand_get_double(&(md->random))-0.5)*INJ_LENY;
137 r.z=(rand_get_double(&(md->random))-0.5)*INJ_LENZ;
143 /* assume valid coordinates */
145 for(i=0;i<md->count;i++) {
147 v3_sub(&dist,&(atom->r),&r);
148 d=v3_absolute_square(&dist);
149 /* reject coordinates */
151 //printf("atom %d - %f\n",i,d);
158 #ifdef INJ_TYPE_CARBON
161 add_atom(md,SI,M_SI,0,
163 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB|ATOM_ATTR_VB,
166 hp->a_count+=NR_ATOMS;
168 /* add schedule for simulating injected atoms ;) */
169 moldyn_add_schedule(md,RELAX_S,1.0);
174 int main(int argc,char **argv) {
178 // printf("[sic] usage: %s <logdir> <temperatur>\n",argv[0]);
182 /* main moldyn structure */
185 /* hook parameter structure */
188 /* potential parameters */
189 t_tersoff_mult_params tp;
190 t_albe_mult_params ap;
192 /* testing location & velocity vector */
194 memset(&r,0,sizeof(t_3dvec));
195 memset(&v,0,sizeof(t_3dvec));
197 /* initialize moldyn */
198 moldyn_init(&md,argc,argv);
200 /* choose integration algorithm */
201 set_int_alg(&md,MOLDYN_INTEGRATE_VERLET);
203 /* choose potential */
205 set_potential3b_j1(&md,albe_mult_3bp_j1);
206 set_potential3b_k1(&md,albe_mult_3bp_k1);
207 set_potential3b_j2(&md,albe_mult_3bp_j2);
208 set_potential3b_k2(&md,albe_mult_3bp_k2);
210 set_potential1b(&md,tersoff_mult_1bp);
211 set_potential3b_j1(&md,tersoff_mult_3bp_j1);
212 set_potential3b_k1(&md,tersoff_mult_3bp_k1);
213 set_potential3b_j2(&md,tersoff_mult_3bp_j2);
214 set_potential3b_k2(&md,tersoff_mult_3bp_k2);
218 set_potential_params(&md,&ap);
220 set_potential_params(&md,&tp);
223 /* cutoff radius & bondlen */
225 set_cutoff(&md,ALBE_S_SI);
226 set_bondlen(&md,ALBE_S_SI,ALBE_S_C,ALBE_S_SIC);
227 //set_cutoff(&md,ALBE_S_C);
229 set_cutoff(&md,TM_S_SI);
230 set_bondlen(&md,TM_S_SI,TM_S_C,-1.0);
231 //set_cutoff(&md,TM_S_C);
235 * potential parameters
239 * tersoff mult potential parameters for SiC
245 tp.lambda[0]=TM_LAMBDA_SI;
247 tp.beta[0]=TM_BETA_SI;
257 tp.lambda[1]=TM_LAMBDA_C;
259 tp.beta[1]=TM_BETA_C;
267 tersoff_mult_complete_params(&tp);
270 * albe mult potential parameters for SiC
277 ap.lambda[0]=ALBE_LAMBDA_SI;
279 ap.gamma[0]=ALBE_GAMMA_SI;
289 ap.lambda[1]=ALBE_LAMBDA_C;
291 ap.gamma[1]=ALBE_GAMMA_C;
296 ap.Smixed=ALBE_S_SIC;
297 ap.Rmixed=ALBE_R_SIC;
298 ap.Amixed=ALBE_A_SIC;
299 ap.Bmixed=ALBE_B_SIC;
300 ap.r0_mixed=ALBE_R0_SIC;
301 ap.lambda_m=ALBE_LAMBDA_SIC;
303 ap.gamma_m=ALBE_GAMMA_SIC;
304 ap.c_mixed=ALBE_C_SIC;
305 ap.d_mixed=ALBE_D_SIC;
306 ap.h_mixed=ALBE_H_SIC;
308 albe_mult_complete_params(&ap);
310 /* set (initial) dimensions of simulation volume */
312 set_dim(&md,LCNTX*ALBE_LC_SI,LCNTY*ALBE_LC_SI,LCNTZ*ALBE_LC_SI,TRUE);
313 //set_dim(&md,LCNTX*ALBE_LC_C,LCNTY*ALBE_LC_C,LCNTZ*ALBE_LC_C,TRUE);
314 //set_dim(&md,LCNTX*ALBE_LC_SIC,LCNTY*ALBE_LC_SIC,LCNTZ*ALBE_LC_SIC,TRUE);
316 set_dim(&md,LCNTX*LC_SI,LCNTY*LC_SI,LCNTZ*LC_SI,TRUE);
317 //set_dim(&md,LCNTX*LC_C,LCNTY*LC_C,LCNTZ*LC_C,TRUE);
318 //set_dim(&md,LCNTX*TM_LC_SIC,LCNTY*TM_LC_SIC,LCNTZ*TM_LC_SIC,TRUE);
321 /* set periodic boundary conditions in all directions */
322 set_pbc(&md,TRUE,TRUE,TRUE);
324 /* create the lattice / place atoms */
327 create_lattice(&md,DIAMOND,ALBE_LC_SI,SI,M_SI,
328 //create_lattice(&md,DIAMOND,ALBE_LC_C,C,M_C,
330 create_lattice(&md,DIAMOND,LC_SI,SI,M_SI,
332 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
333 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
334 0,LCNTX,LCNTY,LCNTZ,NULL);
335 // 1,LCNTX,LCNTY,LCNTZ,NULL);
338 /* create zinkblende structure */
341 r.x=0.5*0.25*ALBE_LC_SIC; r.y=r.x; r.z=r.x;
342 create_lattice(&md,FCC,ALBE_LC_SIC,SI,M_SI,
343 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
344 0,LCNTX,LCNTY,LCNTZ,&r);
345 r.x+=0.25*ALBE_LC_SIC; r.y=r.x; r.z=r.x;
346 create_lattice(&md,FCC,ALBE_LC_SIC,C,M_C,
347 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
348 1,LCNTX,LCNTY,LCNTZ,&r);
350 r.x=0.5*0.25*TM_LC_SIC; r.y=r.x; r.z=r.x;
351 create_lattice(&md,FCC,TM_LC_SIC,SI,M_SI,
352 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
353 0,LCNTX,LCNTY,LCNTZ,&r);
354 r.x+=0.25*TM_LC_SIC; r.y=r.x; r.z=r.x;
355 create_lattice(&md,FCC,TM_LC_SIC,C,M_C,
356 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
357 1,LCNTX,LCNTY,LCNTZ,&r);
361 /* check for right atom placing */
362 moldyn_bc_check(&md);
364 /* testing configuration */
365 //r.x=0.27*sqrt(3.0)*LC_SI/2.0; v.x=0;
366 //r.x=(TM_S_SI+TM_R_SI)/4.0; v.x=0;
369 //add_atom(&md,SI,M_SI,0,
370 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
371 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
373 //r.x=-r.x; v.x=-v.x;
376 //add_atom(&md,SI,M_SI,0,
377 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
378 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
380 //r.z=0.27*sqrt(3.0)*LC_SI/2.0; v.z=0;
381 //r.x=(TM_S_SI+TM_R_SI)/4.0; v.x=0;
384 //add_atom(&md,SI,M_SI,0,
385 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
386 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
388 //r.z=-r.z; v.z=-v.z;
391 //add_atom(&md,SI,M_SI,0,
392 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
393 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
396 /* set temperature & pressure */
397 set_temperature(&md,atof(argv[2])+273.0);
398 set_pressure(&md,BAR);
400 /* set amount of steps to skip before average calc */
401 set_avg_skip(&md,(8.0/10.0*PRERUN));
403 /* set p/t scaling */
404 //set_pt_scale(&md,0,0,T_SCALE_BERENDSEN,100.0);
405 //set_pt_scale(&md,P_SCALE_BERENDSEN,0.001,
406 // T_SCALE_BERENDSEN,100.0);
407 //set_pt_scale(&md,0,0,T_SCALE_DIRECT,1.0);
408 //set_pt_scale(&md,P_SCALE_BERENDSEN,0.001,0,0);
410 /* initial thermal fluctuations of particles (in equilibrium) */
411 thermal_init(&md,TRUE);
413 /* create the simulation schedule */
414 moldyn_add_schedule(&md,PRERUN,1.0);
416 /* schedule hook function */
417 memset(&hookparam,0,sizeof(t_hp));
420 moldyn_set_schedule_hook(&md,&hook_add_atom,&hookparam);
421 //moldyn_set_schedule_hook(&md,&hook_del_atom,&hookparam);
422 //moldyn_add_schedule(&md,POSTRUN,1.0);
424 /* activate logging */
425 moldyn_set_log_dir(&md,argv[1]);
426 moldyn_set_report(&md,"Frank Zirkelbach",R_TITLE);
427 moldyn_set_log(&md,LOG_TOTAL_ENERGY,LOG_E);
428 moldyn_set_log(&md,LOG_TEMPERATURE,LOG_T);
429 moldyn_set_log(&md,LOG_PRESSURE,LOG_P);
430 moldyn_set_log(&md,VISUAL_STEP,LOG_V);
431 moldyn_set_log(&md,SAVE_STEP,LOG_S);
432 moldyn_set_log(&md,CREATE_REPORT,0);
435 * let's do the actual md algorithm now
437 * integration of newtons equations
439 moldyn_integrate(&md);
445 * post processing the data
449 moldyn_shutdown(&md);