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"
33 int a_count; /* atom count */
34 u8 quit; /* quit mark */
35 int argc; /* arg count */
36 char **argv; /* args */
39 int hook(void *moldyn,void *hook_params) {
56 /* switch on t scaling */
57 if(md->schedule.count==0)
58 set_pt_scale(md,0,0,T_SCALE_BERENDSEN,100.0);
60 /* last schedule add if there is enough carbon inside */
61 if(hp->a_count==(INJECT*NR_ATOMS)) {
63 moldyn_add_schedule(md,POSTRUN,1.0);
67 /* more relaxing time for too high temperatures */
68 if(md->t-md->t_ref>T_C) {
69 moldyn_add_schedule(md,10,1.0);
73 /* inject carbon atoms */
74 printf("injecting another %d carbon atoms ...(-> %d / %d)\n",
75 NR_ATOMS,hp->a_count+NR_ATOMS,INJECT*NR_ATOMS);
76 for(j=0;j<NR_ATOMS;j++) {
80 r.x=(rand_get_double(&(md->random))-0.5)*md->dim.x*0.37;
81 r.y=(rand_get_double(&(md->random))-0.5)*md->dim.y*0.37;
82 r.z=(rand_get_double(&(md->random))-0.5)*md->dim.z*0.37;
83 r.x=(1.0*atoi(hp->argv[3])-4.5)/9.0*ALBE_LC_SI;
84 r.y=(1.0*atoi(hp->argv[4])-4.5)/9.0*ALBE_LC_SI;
85 r.z=(1.0*atoi(hp->argv[5])-4.5)/9.0*ALBE_LC_SI;
87 r.x=(rand_get_double(&(md->random))-0.5)*LC_SI;
88 r.y=(rand_get_double(&(md->random))-0.5)*LC_SI;
89 r.z=(rand_get_double(&(md->random))-0.5)*LC_SI;
90 /* assume valid coordinates */
92 for(i=0;i<md->count;i++) {
94 v3_sub(&dist,&(atom->r),&r);
95 d=v3_absolute_square(&dist);
96 /* reject coordinates */
105 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
108 hp->a_count+=NR_ATOMS;
110 /* add schedule for simulating injected atoms ;) */
111 moldyn_add_schedule(md,10,1.0);
116 int main(int argc,char **argv) {
120 // printf("[sic] usage: %s <logdir> <temperatur>\n",argv[0]);
124 /* main moldyn structure */
127 /* hook parameter structure */
130 /* potential parameters */
131 t_tersoff_mult_params tp;
132 t_albe_mult_params ap;
134 /* testing location & velocity vector */
136 memset(&r,0,sizeof(t_3dvec));
137 memset(&v,0,sizeof(t_3dvec));
139 /* initialize moldyn */
140 moldyn_init(&md,argc,argv);
142 /* choose integration algorithm */
143 set_int_alg(&md,MOLDYN_INTEGRATE_VERLET);
145 /* choose potential */
147 set_potential3b_j1(&md,albe_mult_3bp_j1);
148 set_potential3b_k1(&md,albe_mult_3bp_k1);
149 set_potential3b_j2(&md,albe_mult_3bp_j2);
150 set_potential3b_k2(&md,albe_mult_3bp_k2);
152 set_potential1b(&md,tersoff_mult_1bp);
153 set_potential3b_j1(&md,tersoff_mult_3bp_j1);
154 set_potential3b_k1(&md,tersoff_mult_3bp_k1);
155 set_potential3b_j2(&md,tersoff_mult_3bp_j2);
156 set_potential3b_k2(&md,tersoff_mult_3bp_k2);
160 set_potential_params(&md,&ap);
162 set_potential_params(&md,&tp);
167 set_cutoff(&md,ALBE_S_SI);
169 set_cutoff(&md,TM_S_SI);
173 * potential parameters
177 * tersoff mult potential parameters for SiC
183 tp.lambda[0]=TM_LAMBDA_SI;
185 tp.beta[0]=TM_BETA_SI;
195 tp.lambda[1]=TM_LAMBDA_C;
197 tp.beta[1]=TM_BETA_C;
205 tersoff_mult_complete_params(&tp);
208 * albe mult potential parameters for SiC
215 ap.lambda[0]=ALBE_LAMBDA_SI;
217 ap.gamma[0]=ALBE_GAMMA_SI;
227 ap.lambda[1]=ALBE_LAMBDA_C;
229 ap.gamma[1]=ALBE_GAMMA_C;
234 ap.Smixed=ALBE_S_SIC;
235 ap.Rmixed=ALBE_R_SIC;
236 ap.Amixed=ALBE_A_SIC;
237 ap.Bmixed=ALBE_B_SIC;
238 ap.r0_mixed=ALBE_R0_SIC;
239 ap.lambda_m=ALBE_LAMBDA_SIC;
241 ap.gamma_m=ALBE_GAMMA_SIC;
242 ap.c_mixed=ALBE_C_SIC;
243 ap.d_mixed=ALBE_D_SIC;
244 ap.h_mixed=ALBE_H_SIC;
246 albe_mult_complete_params(&ap);
248 /* set (initial) dimensions of simulation volume */
250 set_dim(&md,LCNT*ALBE_LC_SI,LCNT*ALBE_LC_SI,LCNT*ALBE_LC_SI,TRUE);
251 //set_dim(&md,LCNT*ALBE_LC_C,LCNT*ALBE_LC_C,LCNT*ALBE_LC_C,TRUE);
252 //set_dim(&md,LCNT*ALBE_LC_SIC,LCNT*ALBE_LC_SIC,LCNT*ALBE_LC_SIC,TRUE);
254 //set_dim(&md,LCNT*LC_SI,LCNT*LC_SI,LCNT*LC_SI,TRUE);
255 //set_dim(&md,LCNT*LC_C,LCNT*LC_C,LCNT*LC_C,TRUE);
256 set_dim(&md,LCNT*TM_LC_SIC,LCNT*TM_LC_SIC,LCNT*TM_LC_SIC,TRUE);
259 /* set periodic boundary conditions in all directions */
260 set_pbc(&md,TRUE,TRUE,TRUE);
262 /* create the lattice / place atoms */
264 create_lattice(&md,DIAMOND,ALBE_LC_SI,SI,M_SI,
265 //create_lattice(&md,DIAMOND,ALBE_LC_C,C,M_C,
267 //create_lattice(&md,DIAMOND,LC_SI,SI,M_SI,
269 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
270 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
271 0,LCNT,LCNT,LCNT,NULL);
272 // 1,LCNT,LCNT,LCNT,NULL);
274 /* create zinkblende structure */
277 r.x=0.5*0.25*ALBE_LC_SIC; r.y=r.x; r.z=r.x;
278 create_lattice(&md,FCC,ALBE_LC_SIC,SI,M_SI,
279 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
280 0,LCNT,LCNT,LCNT,&r);
281 r.x+=0.25*ALBE_LC_SIC; r.y=r.x; r.z=r.x;
282 create_lattice(&md,FCC,ALBE_LC_SIC,C,M_C,
283 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
284 1,LCNT,LCNT,LCNT,&r);
286 r.x=0.5*0.25*TM_LC_SIC; r.y=r.x; r.z=r.x;
287 create_lattice(&md,FCC,TM_LC_SIC,SI,M_SI,
288 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
289 0,LCNT,LCNT,LCNT,&r);
290 r.x+=0.25*TM_LC_SIC; r.y=r.x; r.z=r.x;
291 create_lattice(&md,FCC,TM_LC_SIC,C,M_C,
292 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
293 1,LCNT,LCNT,LCNT,&r);
297 /* check for right atom placing */
298 moldyn_bc_check(&md);
300 /* testing configuration */
301 //r.x=0.27*sqrt(3.0)*LC_SI/2.0; v.x=0;
302 //r.x=(TM_S_SI+TM_R_SI)/4.0; v.x=0;
305 //add_atom(&md,SI,M_SI,0,
306 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
307 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
309 //r.x=-r.x; v.x=-v.x;
312 //add_atom(&md,SI,M_SI,0,
313 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
314 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
316 //r.z=0.27*sqrt(3.0)*LC_SI/2.0; v.z=0;
317 //r.x=(TM_S_SI+TM_R_SI)/4.0; v.x=0;
320 //add_atom(&md,SI,M_SI,0,
321 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
322 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
324 //r.z=-r.z; v.z=-v.z;
327 //add_atom(&md,SI,M_SI,0,
328 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
329 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
332 /* set temperature & pressure */
333 set_temperature(&md,atof(argv[2])+273.0);
334 set_pressure(&md,BAR);
336 /* set amount of steps to skip before average calc */
337 set_avg_skip(&md,PRERUN);
339 /* set p/t scaling */
340 //set_pt_scale(&md,0,0,T_SCALE_BERENDSEN,100.0);
341 //set_pt_scale(&md,P_SCALE_BERENDSEN,0.001,
342 // T_SCALE_BERENDSEN,100.0);
343 //set_pt_scale(&md,0,0,T_SCALE_DIRECT,1.0);
344 //set_pt_scale(&md,P_SCALE_BERENDSEN,0.001,0,0);
346 /* initial thermal fluctuations of particles (in equilibrium) */
347 thermal_init(&md,TRUE);
349 /* create the simulation schedule */
350 moldyn_add_schedule(&md,PRERUN,1.0);
352 /* schedule hook function */
353 memset(&hookparam,0,sizeof(t_hp));
356 moldyn_set_schedule_hook(&md,&hook,&hookparam);
358 /* activate logging */
359 moldyn_set_log_dir(&md,argv[1]);
360 moldyn_set_report(&md,"Frank Zirkelbach","Test 1");
361 moldyn_set_log(&md,LOG_TOTAL_ENERGY,1);
362 moldyn_set_log(&md,LOG_TEMPERATURE,1);
363 moldyn_set_log(&md,LOG_PRESSURE,1);
364 moldyn_set_log(&md,VISUAL_STEP,100);
365 moldyn_set_log(&md,SAVE_STEP,100);
366 moldyn_set_log(&md,CREATE_REPORT,0);
369 * let's do the actual md algorithm now
371 * integration of newtons equations
373 moldyn_integrate(&md);
379 * post processing the data
383 moldyn_shutdown(&md);