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|ATOM_ATTR_VB,
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);
201 /* cutoff radius & bondlen */
203 set_cutoff(&md,ALBE_S_SI);
204 set_bondlen(&md,ALBE_S_SI,ALBE_S_C,ALBE_S_SIC);
205 //set_cutoff(&md,ALBE_S_C);
207 set_cutoff(&md,TM_S_SI);
208 set_bondlen(&md,TM_S_SI,TM_S_C,-1.0);
209 //set_cutoff(&md,TM_S_C);
213 * potential parameters
217 * tersoff mult potential parameters for SiC
223 tp.lambda[0]=TM_LAMBDA_SI;
225 tp.beta[0]=TM_BETA_SI;
235 tp.lambda[1]=TM_LAMBDA_C;
237 tp.beta[1]=TM_BETA_C;
245 tersoff_mult_complete_params(&tp);
248 * albe mult potential parameters for SiC
255 ap.lambda[0]=ALBE_LAMBDA_SI;
257 ap.gamma[0]=ALBE_GAMMA_SI;
267 ap.lambda[1]=ALBE_LAMBDA_C;
269 ap.gamma[1]=ALBE_GAMMA_C;
274 ap.Smixed=ALBE_S_SIC;
275 ap.Rmixed=ALBE_R_SIC;
276 ap.Amixed=ALBE_A_SIC;
277 ap.Bmixed=ALBE_B_SIC;
278 ap.r0_mixed=ALBE_R0_SIC;
279 ap.lambda_m=ALBE_LAMBDA_SIC;
281 ap.gamma_m=ALBE_GAMMA_SIC;
282 ap.c_mixed=ALBE_C_SIC;
283 ap.d_mixed=ALBE_D_SIC;
284 ap.h_mixed=ALBE_H_SIC;
286 albe_mult_complete_params(&ap);
288 /* set (initial) dimensions of simulation volume */
290 set_dim(&md,LCNTX*ALBE_LC_SI,LCNTY*ALBE_LC_SI,LCNTZ*ALBE_LC_SI,TRUE);
291 //set_dim(&md,LCNTX*ALBE_LC_C,LCNTY*ALBE_LC_C,LCNTZ*ALBE_LC_C,TRUE);
292 //set_dim(&md,LCNTX*ALBE_LC_SIC,LCNTY*ALBE_LC_SIC,LCNTZ*ALBE_LC_SIC,TRUE);
294 set_dim(&md,LCNTX*LC_SI,LCNTY*LC_SI,LCNTZ*LC_SI,TRUE);
295 //set_dim(&md,LCNTX*LC_C,LCNTY*LC_C,LCNTZ*LC_C,TRUE);
296 //set_dim(&md,LCNTX*TM_LC_SIC,LCNTY*TM_LC_SIC,LCNTZ*TM_LC_SIC,TRUE);
299 /* set periodic boundary conditions in all directions */
300 set_pbc(&md,TRUE,TRUE,TRUE);
302 /* create the lattice / place atoms */
304 create_lattice(&md,DIAMOND,ALBE_LC_SI,SI,M_SI,
305 //create_lattice(&md,DIAMOND,ALBE_LC_C,C,M_C,
307 create_lattice(&md,DIAMOND,LC_SI,SI,M_SI,
309 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
310 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
311 0,LCNTX,LCNTY,LCNTZ,NULL);
312 // 1,LCNTX,LCNTY,LCNTZ,NULL);
314 /* create zinkblende structure */
317 r.x=0.5*0.25*ALBE_LC_SIC; r.y=r.x; r.z=r.x;
318 create_lattice(&md,FCC,ALBE_LC_SIC,SI,M_SI,
319 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
320 0,LCNTX,LCNTY,LCNTZ,&r);
321 r.x+=0.25*ALBE_LC_SIC; r.y=r.x; r.z=r.x;
322 create_lattice(&md,FCC,ALBE_LC_SIC,C,M_C,
323 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
324 1,LCNTX,LCNTY,LCNTZ,&r);
326 r.x=0.5*0.25*TM_LC_SIC; r.y=r.x; r.z=r.x;
327 create_lattice(&md,FCC,TM_LC_SIC,SI,M_SI,
328 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
329 0,LCNTX,LCNTY,LCNTZ,&r);
330 r.x+=0.25*TM_LC_SIC; r.y=r.x; r.z=r.x;
331 create_lattice(&md,FCC,TM_LC_SIC,C,M_C,
332 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
333 1,LCNTX,LCNTY,LCNTZ,&r);
337 /* check for right atom placing */
338 moldyn_bc_check(&md);
340 /* testing configuration */
341 //r.x=0.27*sqrt(3.0)*LC_SI/2.0; v.x=0;
342 //r.x=(TM_S_SI+TM_R_SI)/4.0; v.x=0;
345 //add_atom(&md,SI,M_SI,0,
346 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
347 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
349 //r.x=-r.x; v.x=-v.x;
352 //add_atom(&md,SI,M_SI,0,
353 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
354 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
356 //r.z=0.27*sqrt(3.0)*LC_SI/2.0; v.z=0;
357 //r.x=(TM_S_SI+TM_R_SI)/4.0; v.x=0;
360 //add_atom(&md,SI,M_SI,0,
361 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
362 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
364 //r.z=-r.z; v.z=-v.z;
367 //add_atom(&md,SI,M_SI,0,
368 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
369 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
372 /* set temperature & pressure */
373 set_temperature(&md,atof(argv[2])+273.0);
374 set_pressure(&md,BAR);
376 /* set amount of steps to skip before average calc */
377 set_avg_skip(&md,(8.0/10.0*PRERUN));
379 /* set p/t scaling */
380 //set_pt_scale(&md,0,0,T_SCALE_BERENDSEN,100.0);
381 //set_pt_scale(&md,P_SCALE_BERENDSEN,0.001,
382 // T_SCALE_BERENDSEN,100.0);
383 //set_pt_scale(&md,0,0,T_SCALE_DIRECT,1.0);
384 //set_pt_scale(&md,P_SCALE_BERENDSEN,0.001,0,0);
386 /* initial thermal fluctuations of particles (in equilibrium) */
387 thermal_init(&md,TRUE);
389 /* create the simulation schedule */
390 moldyn_add_schedule(&md,PRERUN,1.0);
392 /* schedule hook function */
393 memset(&hookparam,0,sizeof(t_hp));
396 moldyn_set_schedule_hook(&md,&hook_add_atom,&hookparam);
397 //moldyn_set_schedule_hook(&md,&hook_del_atom,&hookparam);
398 //moldyn_add_schedule(&md,POSTRUN,1.0);
400 /* activate logging */
401 moldyn_set_log_dir(&md,argv[1]);
402 moldyn_set_report(&md,"Frank Zirkelbach",R_TITLE);
403 moldyn_set_log(&md,LOG_TOTAL_ENERGY,LOG_E);
404 moldyn_set_log(&md,LOG_TEMPERATURE,LOG_T);
405 moldyn_set_log(&md,LOG_PRESSURE,LOG_P);
406 moldyn_set_log(&md,VISUAL_STEP,LOG_V);
407 moldyn_set_log(&md,SAVE_STEP,LOG_S);
408 moldyn_set_log(&md,CREATE_REPORT,0);
411 * let's do the actual md algorithm now
413 * integration of newtons equations
415 moldyn_integrate(&md);
421 * post processing the data
425 moldyn_shutdown(&md);