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"
31 int a_count; /* atom count */
32 u8 quit; /* quit mark */
33 int argc; /* arg count */
34 char **argv; /* args */
37 int hook(void *moldyn,void *hook_params) {
54 /* switch on t scaling */
55 if(md->schedule.count==0)
56 set_pt_scale(md,0,0,T_SCALE_BERENDSEN,100.0);
58 /* last schedule add if there is enough carbon inside */
59 if(hp->a_count==(INJECT*NR_ATOMS)) {
61 moldyn_add_schedule(md,5000,1.0);
65 /* more relaxing time for too high temperatures */
66 if(md->t-md->t_ref>T_C) {
67 moldyn_add_schedule(md,10,1.0);
71 /* inject carbon atoms */
72 printf("injecting another %d carbon atoms ...(-> %d / %d)\n",
73 NR_ATOMS,hp->a_count+NR_ATOMS,INJECT*NR_ATOMS);
74 for(j=0;j<NR_ATOMS;j++) {
77 r.x=(rand_get_double(&(md->random))-0.5)*md->dim.x*0.37;
78 r.y=(rand_get_double(&(md->random))-0.5)*md->dim.y*0.37;
79 r.z=(rand_get_double(&(md->random))-0.5)*md->dim.z*0.37;
80 //r.x=(1.0*atoi(hp->argv[3])-4.5)/9.0*ALBE_LC_SI;
81 //r.y=(1.0*atoi(hp->argv[4])-4.5)/9.0*ALBE_LC_SI;
82 //r.z=(1.0*atoi(hp->argv[5])-4.5)/9.0*ALBE_LC_SI;
83 /* assume valid coordinates */
85 for(i=0;i<md->count;i++) {
87 v3_sub(&dist,&(atom->r),&r);
88 d=v3_absolute_square(&dist);
89 /* reject coordinates */
98 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
101 hp->a_count+=NR_ATOMS;
103 /* add schedule for simulating injected atoms ;) */
104 moldyn_add_schedule(md,10,1.0);
109 int main(int argc,char **argv) {
113 // printf("[sic] usage: %s <logdir> <temperatur>\n",argv[0]);
117 /* main moldyn structure */
120 /* hook parameter structure */
123 /* potential parameters */
124 t_tersoff_mult_params tp;
125 t_albe_mult_params ap;
127 /* atom injection counter */
130 /* testing location & velocity vector */
132 memset(&r,0,sizeof(t_3dvec));
133 memset(&v,0,sizeof(t_3dvec));
135 /* initialize moldyn */
136 moldyn_init(&md,argc,argv);
138 /* choose integration algorithm */
139 set_int_alg(&md,MOLDYN_INTEGRATE_VERLET);
141 /* choose potential */
143 set_potential3b_j1(&md,albe_mult_3bp_j1);
144 set_potential3b_k1(&md,albe_mult_3bp_k1);
145 set_potential3b_j2(&md,albe_mult_3bp_j2);
146 set_potential3b_k2(&md,albe_mult_3bp_k2);
148 set_potential1b(&md,tersoff_mult_1bp);
149 set_potential3b_j1(&md,tersoff_mult_3bp_j1);
150 set_potential3b_k1(&md,tersoff_mult_3bp_k1);
151 set_potential3b_j2(&md,tersoff_mult_3bp_j2);
152 set_potential3b_k2(&md,tersoff_mult_3bp_k2);
156 set_potential_params(&md,&ap);
158 set_potential_params(&md,&tp);
163 set_cutoff(&md,ALBE_S_SI);
165 set_cutoff(&md,TM_S_SI);
169 * potential parameters
173 * tersoff mult potential parameters for SiC
179 tp.lambda[0]=TM_LAMBDA_SI;
181 tp.beta[0]=TM_BETA_SI;
191 tp.lambda[1]=TM_LAMBDA_C;
193 tp.beta[1]=TM_BETA_C;
201 tersoff_mult_complete_params(&tp);
204 * albe mult potential parameters for SiC
211 ap.lambda[0]=ALBE_LAMBDA_SI;
213 ap.gamma[0]=ALBE_GAMMA_SI;
223 ap.lambda[1]=ALBE_LAMBDA_C;
225 ap.gamma[1]=ALBE_GAMMA_C;
230 ap.Smixed=ALBE_S_SIC;
231 ap.Rmixed=ALBE_R_SIC;
232 ap.Amixed=ALBE_A_SIC;
233 ap.Bmixed=ALBE_B_SIC;
234 ap.r0_mixed=ALBE_R0_SIC;
235 ap.lambda_m=ALBE_LAMBDA_SIC;
237 ap.gamma_m=ALBE_GAMMA_SIC;
238 ap.c_mixed=ALBE_C_SIC;
239 ap.d_mixed=ALBE_D_SIC;
240 ap.h_mixed=ALBE_H_SIC;
242 albe_mult_complete_params(&ap);
244 /* set (initial) dimensions of simulation volume */
246 set_dim(&md,LCNT*ALBE_LC_SI,LCNT*ALBE_LC_SI,LCNT*ALBE_LC_SI,TRUE);
247 //set_dim(&md,LCNT*ALBE_LC_C,LCNT*ALBE_LC_C,LCNT*ALBE_LC_C,TRUE);
248 //set_dim(&md,LCNT*ALBE_LC_SIC,LCNT*ALBE_LC_SIC,LCNT*ALBE_LC_SIC,TRUE);
250 //set_dim(&md,LCNT*LC_SI,LCNT*LC_SI,LCNT*LC_SI,TRUE);
251 //set_dim(&md,LCNT*LC_C,LCNT*LC_C,LCNT*LC_C,TRUE);
252 set_dim(&md,LCNT*TM_LC_SIC,LCNT*TM_LC_SIC,LCNT*TM_LC_SIC,TRUE);
255 /* set periodic boundary conditions in all directions */
256 set_pbc(&md,TRUE,TRUE,TRUE);
258 /* create the lattice / place atoms */
260 create_lattice(&md,DIAMOND,ALBE_LC_SI,SI,M_SI,
261 //create_lattice(&md,DIAMOND,ALBE_LC_C,C,M_C,
263 //create_lattice(&md,DIAMOND,LC_SI,SI,M_SI,
265 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
266 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
267 0,LCNT,LCNT,LCNT,NULL);
268 // 1,LCNT,LCNT,LCNT,NULL);
270 /* create zinkblende structure */
273 r.x=0.5*0.25*ALBE_LC_SIC; r.y=r.x; r.z=r.x;
274 create_lattice(&md,FCC,ALBE_LC_SIC,SI,M_SI,
275 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
276 0,LCNT,LCNT,LCNT,&r);
277 r.x+=0.25*ALBE_LC_SIC; r.y=r.x; r.z=r.x;
278 create_lattice(&md,FCC,ALBE_LC_SIC,C,M_C,
279 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
280 1,LCNT,LCNT,LCNT,&r);
282 r.x=0.5*0.25*TM_LC_SIC; r.y=r.x; r.z=r.x;
283 create_lattice(&md,FCC,TM_LC_SIC,SI,M_SI,
284 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
285 0,LCNT,LCNT,LCNT,&r);
286 r.x+=0.25*TM_LC_SIC; r.y=r.x; r.z=r.x;
287 create_lattice(&md,FCC,TM_LC_SIC,C,M_C,
288 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
289 1,LCNT,LCNT,LCNT,&r);
293 /* check for right atom placing */
294 moldyn_bc_check(&md);
296 /* testing configuration */
297 //r.x=0.27*sqrt(3.0)*LC_SI/2.0; v.x=0;
298 //r.x=(TM_S_SI+TM_R_SI)/4.0; v.x=0;
301 //add_atom(&md,SI,M_SI,0,
302 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
303 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
305 //r.x=-r.x; v.x=-v.x;
308 //add_atom(&md,SI,M_SI,0,
309 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
310 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
312 //r.z=0.27*sqrt(3.0)*LC_SI/2.0; v.z=0;
313 //r.x=(TM_S_SI+TM_R_SI)/4.0; v.x=0;
316 //add_atom(&md,SI,M_SI,0,
317 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
318 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
320 //r.z=-r.z; v.z=-v.z;
323 //add_atom(&md,SI,M_SI,0,
324 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
325 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
328 /* set temperature & pressure */
329 set_temperature(&md,atof(argv[2])+273.0);
330 set_pressure(&md,BAR);
332 /* set amount of steps to skip before average calc */
333 set_avg_skip(&md,1000);
335 /* set p/t scaling */
336 //set_pt_scale(&md,0,0,T_SCALE_BERENDSEN,100.0);
337 //set_pt_scale(&md,P_SCALE_BERENDSEN,0.001,
338 // T_SCALE_BERENDSEN,100.0);
339 //set_pt_scale(&md,0,0,T_SCALE_DIRECT,1.0);
340 //set_pt_scale(&md,P_SCALE_BERENDSEN,0.001,0,0);
342 /* initial thermal fluctuations of particles (in equilibrium) */
343 thermal_init(&md,TRUE);
345 /* create the simulation schedule */
346 moldyn_add_schedule(&md,1000,1.0);
347 //moldyn_add_schedule(&md,1000,1.0);
348 //moldyn_add_schedule(&md,1000,1.0);
349 //moldyn_add_schedule(&md,1000,1.0);
350 //moldyn_add_schedule(&md,1000,1.0);
351 //moldyn_add_schedule(&md,1000,1.0);
353 //for(inject=0;inject<INJECT;inject++) {
354 // /* injecting atoms */
355 // moldyn_add_schedule(&md,10,1.0);
358 /* schedule hook function */
359 memset(&hookparam,0,sizeof(t_hp));
362 moldyn_set_schedule_hook(&md,&hook,&hookparam);
364 /* activate logging */
365 moldyn_set_log_dir(&md,argv[1]);
366 moldyn_set_report(&md,"Frank Zirkelbach","Test 1");
367 moldyn_set_log(&md,LOG_TOTAL_ENERGY,1);
368 moldyn_set_log(&md,LOG_TEMPERATURE,1);
369 moldyn_set_log(&md,LOG_PRESSURE,1);
370 moldyn_set_log(&md,VISUAL_STEP,100);
371 moldyn_set_log(&md,SAVE_STEP,100);
372 moldyn_set_log(&md,CREATE_REPORT,0);
375 * let's do the actual md algorithm now
377 * integration of newtons equations
379 moldyn_integrate(&md);
385 * post processing the data
389 moldyn_shutdown(&md);