2 * sic.c - investigation of the sic precipitation process of silicon carbide
4 * author: Frank Zirkelbach <frank.zirkelbach@physik.uni-augsburg.de>
14 #include "potentials/harmonic_oscillator.h"
15 #include "potentials/lennard_jones.h"
16 #include "potentials/albe.h"
19 #include "potentials/tersoff_orig.h"
21 #include "potentials/tersoff.h"
28 #define INJ_LENX (10*ALBE_LC_SIC)
29 #define INJ_LENY (10*ALBE_LC_SIC)
30 #define INJ_LENZ (10*ALBE_LC_SIC)
31 #define INJ_OFFSET (ALBE_LC_SI/8.0)
39 #define R_TITLE "Insertion of 8000 carbon atoms in silicon"
47 int a_count; /* atom count */
48 u8 quit; /* quit mark */
49 int argc; /* arg count */
50 char **argv; /* args */
53 int hook(void *moldyn,void *hook_params) {
70 /* switch on t scaling */
71 if(md->schedule.count==0)
72 set_pt_scale(md,0,0,T_SCALE_BERENDSEN,100.0);
74 /* last schedule add if there is enough carbon inside */
75 if(hp->a_count==(INJECT*NR_ATOMS)) {
77 moldyn_add_schedule(md,POSTRUN,1.0);
81 /* more relaxing time for too high temperatures */
82 if(md->t-md->t_ref>T_C) {
83 moldyn_add_schedule(md,10,1.0);
87 /* inject carbon atoms */
88 printf("injecting another %d carbon atoms ...(-> %d / %d)\n",
89 NR_ATOMS,hp->a_count+NR_ATOMS,INJECT*NR_ATOMS);
90 for(j=0;j<NR_ATOMS;j++) {
93 r.x=(rand_get_double(&(md->random))-0.5)*INJ_LENX;
95 r.y=(rand_get_double(&(md->random))-0.5)*INJ_LENY;
97 r.z=(rand_get_double(&(md->random))-0.5)*INJ_LENZ;
99 /* assume valid coordinates */
101 for(i=0;i<md->count;i++) {
103 v3_sub(&dist,&(atom->r),&r);
104 d=v3_absolute_square(&dist);
105 /* reject coordinates */
113 //add_atom(md,C,M_C,1,
114 add_atom(md,SI,M_SI,1,
115 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
118 hp->a_count+=NR_ATOMS;
120 /* add schedule for simulating injected atoms ;) */
121 moldyn_add_schedule(md,10,1.0);
126 int main(int argc,char **argv) {
130 // printf("[sic] usage: %s <logdir> <temperatur>\n",argv[0]);
134 /* main moldyn structure */
137 /* hook parameter structure */
140 /* potential parameters */
141 t_tersoff_mult_params tp;
142 t_albe_mult_params ap;
144 /* testing location & velocity vector */
146 memset(&r,0,sizeof(t_3dvec));
147 memset(&v,0,sizeof(t_3dvec));
149 /* initialize moldyn */
150 moldyn_init(&md,argc,argv);
152 /* choose integration algorithm */
153 set_int_alg(&md,MOLDYN_INTEGRATE_VERLET);
155 /* choose potential */
157 set_potential3b_j1(&md,albe_mult_3bp_j1);
158 set_potential3b_k1(&md,albe_mult_3bp_k1);
159 set_potential3b_j2(&md,albe_mult_3bp_j2);
160 set_potential3b_k2(&md,albe_mult_3bp_k2);
162 set_potential1b(&md,tersoff_mult_1bp);
163 set_potential3b_j1(&md,tersoff_mult_3bp_j1);
164 set_potential3b_k1(&md,tersoff_mult_3bp_k1);
165 set_potential3b_j2(&md,tersoff_mult_3bp_j2);
166 set_potential3b_k2(&md,tersoff_mult_3bp_k2);
170 set_potential_params(&md,&ap);
172 set_potential_params(&md,&tp);
177 set_cutoff(&md,ALBE_S_SI);
178 //set_cutoff(&md,ALBE_S_C);
180 set_cutoff(&md,TM_S_SI);
181 //set_cutoff(&md,TM_S_C);
185 * potential parameters
189 * tersoff mult potential parameters for SiC
195 tp.lambda[0]=TM_LAMBDA_SI;
197 tp.beta[0]=TM_BETA_SI;
207 tp.lambda[1]=TM_LAMBDA_C;
209 tp.beta[1]=TM_BETA_C;
217 tersoff_mult_complete_params(&tp);
220 * albe mult potential parameters for SiC
227 ap.lambda[0]=ALBE_LAMBDA_SI;
229 ap.gamma[0]=ALBE_GAMMA_SI;
239 ap.lambda[1]=ALBE_LAMBDA_C;
241 ap.gamma[1]=ALBE_GAMMA_C;
246 ap.Smixed=ALBE_S_SIC;
247 ap.Rmixed=ALBE_R_SIC;
248 ap.Amixed=ALBE_A_SIC;
249 ap.Bmixed=ALBE_B_SIC;
250 ap.r0_mixed=ALBE_R0_SIC;
251 ap.lambda_m=ALBE_LAMBDA_SIC;
253 ap.gamma_m=ALBE_GAMMA_SIC;
254 ap.c_mixed=ALBE_C_SIC;
255 ap.d_mixed=ALBE_D_SIC;
256 ap.h_mixed=ALBE_H_SIC;
258 albe_mult_complete_params(&ap);
260 /* set (initial) dimensions of simulation volume */
262 set_dim(&md,LCNTX*ALBE_LC_SI,LCNTY*ALBE_LC_SI,LCNTZ*ALBE_LC_SI,TRUE);
263 //set_dim(&md,LCNTX*ALBE_LC_C,LCNTY*ALBE_LC_C,LCNTZ*ALBE_LC_C,TRUE);
264 //set_dim(&md,LCNTX*ALBE_LC_SIC,LCNTY*ALBE_LC_SIC,LCNTZ*ALBE_LC_SIC,TRUE);
266 set_dim(&md,LCNTX*LC_SI,LCNT*LC_SI,LCNT*LC_SI,TRUE);
267 //set_dim(&md,LCNTX*LC_C,LCNTY*LC_C,LCNTZ*LC_C,TRUE);
268 //set_dim(&md,LCNTX*TM_LC_SIC,LCNTY*TM_LC_SIC,LCNTZ*TM_LC_SIC,TRUE);
271 /* set periodic boundary conditions in all directions */
272 set_pbc(&md,TRUE,TRUE,TRUE);
274 /* create the lattice / place atoms */
276 create_lattice(&md,DIAMOND,ALBE_LC_SI,SI,M_SI,
277 //create_lattice(&md,DIAMOND,ALBE_LC_C,C,M_C,
279 //create_lattice(&md,DIAMOND,LC_SI,SI,M_SI,
281 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
282 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
283 0,LCNTX,LCNTY,LCNTZ,NULL);
284 // 1,LCNTX,LCNTY,LCNTZ,NULL);
286 /* create zinkblende structure */
289 r.x=0.5*0.25*ALBE_LC_SIC; r.y=r.x; r.z=r.x;
290 create_lattice(&md,FCC,ALBE_LC_SIC,SI,M_SI,
291 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
292 0,LCNTX,LCNTY,LCNTZ,&r);
293 r.x+=0.25*ALBE_LC_SIC; r.y=r.x; r.z=r.x;
294 create_lattice(&md,FCC,ALBE_LC_SIC,C,M_C,
295 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
296 1,LCNTX,LCNTY,LCNTZ,&r);
298 r.x=0.5*0.25*TM_LC_SIC; r.y=r.x; r.z=r.x;
299 create_lattice(&md,FCC,TM_LC_SIC,SI,M_SI,
300 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
301 0,LCNTX,LCNTY,LCNTZ,&r);
302 r.x+=0.25*TM_LC_SIC; r.y=r.x; r.z=r.x;
303 create_lattice(&md,FCC,TM_LC_SIC,C,M_C,
304 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
305 1,LCNTX,LCNTY,LCNTZ,&r);
309 /* check for right atom placing */
310 moldyn_bc_check(&md);
312 /* testing configuration */
313 //r.x=0.27*sqrt(3.0)*LC_SI/2.0; v.x=0;
314 //r.x=(TM_S_SI+TM_R_SI)/4.0; v.x=0;
317 //add_atom(&md,SI,M_SI,0,
318 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
319 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
321 //r.x=-r.x; v.x=-v.x;
324 //add_atom(&md,SI,M_SI,0,
325 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
326 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
328 //r.z=0.27*sqrt(3.0)*LC_SI/2.0; v.z=0;
329 //r.x=(TM_S_SI+TM_R_SI)/4.0; v.x=0;
332 //add_atom(&md,SI,M_SI,0,
333 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
334 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
336 //r.z=-r.z; v.z=-v.z;
339 //add_atom(&md,SI,M_SI,0,
340 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
341 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
344 /* set temperature & pressure */
345 set_temperature(&md,atof(argv[2])+273.0);
346 set_pressure(&md,BAR);
348 /* set amount of steps to skip before average calc */
349 set_avg_skip(&md,(8.0/10.0*PRERUN));
351 /* set p/t scaling */
352 //set_pt_scale(&md,0,0,T_SCALE_BERENDSEN,100.0);
353 //set_pt_scale(&md,P_SCALE_BERENDSEN,0.001,
354 // T_SCALE_BERENDSEN,100.0);
355 //set_pt_scale(&md,0,0,T_SCALE_DIRECT,1.0);
356 //set_pt_scale(&md,P_SCALE_BERENDSEN,0.001,0,0);
358 /* initial thermal fluctuations of particles (in equilibrium) */
359 thermal_init(&md,TRUE);
361 /* create the simulation schedule */
362 moldyn_add_schedule(&md,PRERUN,1.0);
364 /* schedule hook function */
365 memset(&hookparam,0,sizeof(t_hp));
368 moldyn_set_schedule_hook(&md,&hook,&hookparam);
370 /* activate logging */
371 moldyn_set_log_dir(&md,argv[1]);
372 moldyn_set_report(&md,"Frank Zirkelbach",R_TITLE);
373 moldyn_set_log(&md,LOG_TOTAL_ENERGY,LOG_E);
374 moldyn_set_log(&md,LOG_TEMPERATURE,LOG_T);
375 moldyn_set_log(&md,LOG_PRESSURE,LOG_P);
376 moldyn_set_log(&md,VISUAL_STEP,LOG_V);
377 moldyn_set_log(&md,SAVE_STEP,LOG_S);
378 moldyn_set_log(&md,CREATE_REPORT,0);
381 * let's do the actual md algorithm now
383 * integration of newtons equations
385 moldyn_integrate(&md);
391 * post processing the data
395 moldyn_shutdown(&md);