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++) {
113 r.x=1.0/8.0*ALBE_LC_SI;
114 r.y=-1.0/8.0*ALBE_LC_SI;
115 r.z=-1.0/8.0*ALBE_LC_SI;
116 //r.x=(rand_get_double(&(md->random))-0.5)*INJ_LENX;
118 //r.y=(rand_get_double(&(md->random))-0.5)*INJ_LENY;
120 //r.z=(rand_get_double(&(md->random))-0.5)*INJ_LENZ;
122 /* assume valid coordinates */
124 for(i=0;i<md->count;i++) {
126 v3_sub(&dist,&(atom->r),&r);
127 d=v3_absolute_square(&dist);
128 /* reject coordinates */
136 #ifdef INJ_TYPE_CARBON
139 add_atom(md,SI,M_SI,0,
141 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
144 hp->a_count+=NR_ATOMS;
146 /* add schedule for simulating injected atoms ;) */
147 moldyn_add_schedule(md,RELAX_S,1.0);
152 int main(int argc,char **argv) {
156 // printf("[sic] usage: %s <logdir> <temperatur>\n",argv[0]);
160 /* main moldyn structure */
163 /* hook parameter structure */
166 /* potential parameters */
167 t_tersoff_mult_params tp;
168 t_albe_mult_params ap;
170 /* testing location & velocity vector */
172 memset(&r,0,sizeof(t_3dvec));
173 memset(&v,0,sizeof(t_3dvec));
175 /* initialize moldyn */
176 moldyn_init(&md,argc,argv);
178 /* choose integration algorithm */
179 set_int_alg(&md,MOLDYN_INTEGRATE_VERLET);
181 /* choose potential */
183 set_potential3b_j1(&md,albe_mult_3bp_j1);
184 set_potential3b_k1(&md,albe_mult_3bp_k1);
185 set_potential3b_j2(&md,albe_mult_3bp_j2);
186 set_potential3b_k2(&md,albe_mult_3bp_k2);
188 set_potential1b(&md,tersoff_mult_1bp);
189 set_potential3b_j1(&md,tersoff_mult_3bp_j1);
190 set_potential3b_k1(&md,tersoff_mult_3bp_k1);
191 set_potential3b_j2(&md,tersoff_mult_3bp_j2);
192 set_potential3b_k2(&md,tersoff_mult_3bp_k2);
196 set_potential_params(&md,&ap);
198 set_potential_params(&md,&tp);
203 set_cutoff(&md,ALBE_S_SI);
204 //set_cutoff(&md,ALBE_S_C);
206 set_cutoff(&md,TM_S_SI);
207 //set_cutoff(&md,TM_S_C);
211 * potential parameters
215 * tersoff mult potential parameters for SiC
221 tp.lambda[0]=TM_LAMBDA_SI;
223 tp.beta[0]=TM_BETA_SI;
233 tp.lambda[1]=TM_LAMBDA_C;
235 tp.beta[1]=TM_BETA_C;
243 tersoff_mult_complete_params(&tp);
246 * albe mult potential parameters for SiC
253 ap.lambda[0]=ALBE_LAMBDA_SI;
255 ap.gamma[0]=ALBE_GAMMA_SI;
265 ap.lambda[1]=ALBE_LAMBDA_C;
267 ap.gamma[1]=ALBE_GAMMA_C;
272 ap.Smixed=ALBE_S_SIC;
273 ap.Rmixed=ALBE_R_SIC;
274 ap.Amixed=ALBE_A_SIC;
275 ap.Bmixed=ALBE_B_SIC;
276 ap.r0_mixed=ALBE_R0_SIC;
277 ap.lambda_m=ALBE_LAMBDA_SIC;
279 ap.gamma_m=ALBE_GAMMA_SIC;
280 ap.c_mixed=ALBE_C_SIC;
281 ap.d_mixed=ALBE_D_SIC;
282 ap.h_mixed=ALBE_H_SIC;
284 albe_mult_complete_params(&ap);
286 /* set (initial) dimensions of simulation volume */
288 set_dim(&md,LCNTX*ALBE_LC_SI,LCNTY*ALBE_LC_SI,LCNTZ*ALBE_LC_SI,TRUE);
289 //set_dim(&md,LCNTX*ALBE_LC_C,LCNTY*ALBE_LC_C,LCNTZ*ALBE_LC_C,TRUE);
290 //set_dim(&md,LCNTX*ALBE_LC_SIC,LCNTY*ALBE_LC_SIC,LCNTZ*ALBE_LC_SIC,TRUE);
292 set_dim(&md,LCNTX*LC_SI,LCNTY*LC_SI,LCNTZ*LC_SI,TRUE);
293 //set_dim(&md,LCNTX*LC_C,LCNTY*LC_C,LCNTZ*LC_C,TRUE);
294 //set_dim(&md,LCNTX*TM_LC_SIC,LCNTY*TM_LC_SIC,LCNTZ*TM_LC_SIC,TRUE);
297 /* set periodic boundary conditions in all directions */
298 set_pbc(&md,TRUE,TRUE,TRUE);
300 /* create the lattice / place atoms */
302 create_lattice(&md,DIAMOND,ALBE_LC_SI,SI,M_SI,
303 //create_lattice(&md,DIAMOND,ALBE_LC_C,C,M_C,
305 create_lattice(&md,DIAMOND,LC_SI,SI,M_SI,
307 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
308 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
309 0,LCNTX,LCNTY,LCNTZ,NULL);
310 // 1,LCNTX,LCNTY,LCNTZ,NULL);
312 /* create zinkblende structure */
315 r.x=0.5*0.25*ALBE_LC_SIC; r.y=r.x; r.z=r.x;
316 create_lattice(&md,FCC,ALBE_LC_SIC,SI,M_SI,
317 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
318 0,LCNTX,LCNTY,LCNTZ,&r);
319 r.x+=0.25*ALBE_LC_SIC; r.y=r.x; r.z=r.x;
320 create_lattice(&md,FCC,ALBE_LC_SIC,C,M_C,
321 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
322 1,LCNTX,LCNTY,LCNTZ,&r);
324 r.x=0.5*0.25*TM_LC_SIC; r.y=r.x; r.z=r.x;
325 create_lattice(&md,FCC,TM_LC_SIC,SI,M_SI,
326 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
327 0,LCNTX,LCNTY,LCNTZ,&r);
328 r.x+=0.25*TM_LC_SIC; r.y=r.x; r.z=r.x;
329 create_lattice(&md,FCC,TM_LC_SIC,C,M_C,
330 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
331 1,LCNTX,LCNTY,LCNTZ,&r);
335 /* check for right atom placing */
336 moldyn_bc_check(&md);
338 /* testing configuration */
339 //r.x=0.27*sqrt(3.0)*LC_SI/2.0; v.x=0;
340 //r.x=(TM_S_SI+TM_R_SI)/4.0; v.x=0;
343 //add_atom(&md,SI,M_SI,0,
344 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
345 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
347 //r.x=-r.x; v.x=-v.x;
350 //add_atom(&md,SI,M_SI,0,
351 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
352 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
354 //r.z=0.27*sqrt(3.0)*LC_SI/2.0; v.z=0;
355 //r.x=(TM_S_SI+TM_R_SI)/4.0; v.x=0;
358 //add_atom(&md,SI,M_SI,0,
359 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
360 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
362 //r.z=-r.z; v.z=-v.z;
365 //add_atom(&md,SI,M_SI,0,
366 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
367 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
370 /* set temperature & pressure */
371 set_temperature(&md,atof(argv[2])+273.0);
372 set_pressure(&md,BAR);
374 /* set amount of steps to skip before average calc */
375 set_avg_skip(&md,(8.0/10.0*PRERUN));
377 /* set p/t scaling */
378 //set_pt_scale(&md,0,0,T_SCALE_BERENDSEN,100.0);
379 //set_pt_scale(&md,P_SCALE_BERENDSEN,0.001,
380 // T_SCALE_BERENDSEN,100.0);
381 //set_pt_scale(&md,0,0,T_SCALE_DIRECT,1.0);
382 //set_pt_scale(&md,P_SCALE_BERENDSEN,0.001,0,0);
384 /* initial thermal fluctuations of particles (in equilibrium) */
385 thermal_init(&md,TRUE);
387 /* create the simulation schedule */
388 moldyn_add_schedule(&md,PRERUN,1.0);
390 /* schedule hook function */
391 memset(&hookparam,0,sizeof(t_hp));
394 moldyn_set_schedule_hook(&md,&hook_add_atom,&hookparam);
395 //moldyn_set_schedule_hook(&md,&hook_del_atom,&hookparam);
396 //moldyn_add_schedule(&md,POSTRUN,1.0);
398 /* activate logging */
399 moldyn_set_log_dir(&md,argv[1]);
400 moldyn_set_report(&md,"Frank Zirkelbach",R_TITLE);
401 moldyn_set_log(&md,LOG_TOTAL_ENERGY,LOG_E);
402 moldyn_set_log(&md,LOG_TEMPERATURE,LOG_T);
403 moldyn_set_log(&md,LOG_PRESSURE,LOG_P);
404 moldyn_set_log(&md,VISUAL_STEP,LOG_V);
405 moldyn_set_log(&md,SAVE_STEP,LOG_S);
406 moldyn_set_log(&md,CREATE_REPORT,0);
409 * let's do the actual md algorithm now
411 * integration of newtons equations
413 moldyn_integrate(&md);
419 * post processing the data
423 moldyn_shutdown(&md);