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"
17 #include "potentials/tersoff_orig.h"
19 #include "potentials/tersoff.h"
23 int prerun_count; /* prerun count */
24 int insert_count; /* insert count */
25 int postrun_count; /* post run count */
26 unsigned char state; /* current state */
27 int argc; /* arg count */
28 char **argv; /* args */
31 #define STATE_PRERUN 0x00
32 #define STATE_INSERT 0x01
33 #define STATE_POSTRUN 0x02
35 /* include the config file */
38 int insert_atoms(t_moldyn *moldyn) {
51 for(j=0;j<INS_ATOMS;j++) {
62 r.x=-1.0/8.0*ALBE_LC_SI;
63 r.y=-1.0/8.0*ALBE_LC_SI;
64 r.z=1.0/8.0*ALBE_LC_SI;
68 r.x=(-0.5+0.25+0.125)*ALBE_LC_SI;
69 r.y=(-0.5+0.25+0.125)*ALBE_LC_SI;
70 r.z=(-0.5+0.25)*ALBE_LC_SI;
71 moldyn->atom[4372].r.x=(-0.5+0.125+0.125)*ALBE_LC_SI;
72 moldyn->atom[4372].r.y=(-0.5+0.125+0.125)*ALBE_LC_SI;
76 r.x=(-0.5+0.25)*ALBE_LC_SI;
77 r.y=(-0.5+0.25)*ALBE_LC_SI;
78 r.z=(-0.1)*ALBE_LC_SI;
79 moldyn->atom[4372].r.z=(-0.4)*ALBE_LC_SI;
83 r.x=INS_UX*ALBE_LC_SI;
84 r.y=INS_UY*ALBE_LC_SI;
85 r.z=INS_UZ*ALBE_LC_SI;
89 #ifdef INS_DYNAMIC_LEN
90 r.x=(rand_get_double(&(moldyn->random))-0.5)*\
92 r.y=(rand_get_double(&(moldyn->random))-0.5)*\
94 r.z=(rand_get_double(&(moldyn->random))-0.5)*\
97 r.x=(rand_get_double(&(moldyn->random))-0.5)*INS_LENX;
98 r.y=(rand_get_double(&(moldyn->random))-0.5)*INS_LENY;
99 r.z=(rand_get_double(&(moldyn->random))-0.5)*INS_LENZ;
106 /* assume valid coordinates */
108 dmin=10000000000.0; // for sure too high!
109 for(i=0;i<moldyn->count;i++) {
110 atom=&(moldyn->atom[i]);
111 v3_sub(&dist,&(atom->r),&r);
112 check_per_bound(moldyn,&dist);
113 d=v3_absolute_square(&dist);
114 /* reject coordinates */
116 //printf("atom %d - %f\n",i,d);
124 add_atom(moldyn,INS_TYPE,INS_MASS,INS_BRAND,
125 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|\
128 printf(" %02d: atom %d | %f %f %f | %f\n",
129 j,moldyn->count-1,r.x,r.y,r.z,dmin);
135 int sic_hook(void *moldyn,void *hook_params) {
150 /* switch on t scaling */
151 if(md->schedule.count==0)
152 set_pt_scale(md,P_SCALE_BERENDSEN,P_SCALE_TAU,
153 T_SCALE_BERENDSEN,T_SCALE_TAU);
155 /* my lousy state machine ! */
157 /* switch to insert state immediately */
158 if(hp->state==STATE_PRERUN)
159 hp->state=STATE_INSERT;
169 printf("[sic hook] unknown state\n");
173 /* act according to state */
181 /* check temperature */
182 dt=md->t_avg-md->t_ref;
183 dp=md->p_avg-md->p_ref;
188 if((dt>INS_DELTA_TC)|(dp>INS_DELTA_PC))
191 /* immediately go on if no job is to be done */
192 if(hp->insert_count==INS_RUNS) {
193 printf(" --- leaving insert state ---\n");
194 hp->state=STATE_POSTRUN;
198 /* else -> insert atoms */
200 printf(" ### insert atoms (%d/%d) ###\n",
201 hp->insert_count*INS_ATOMS,INS_RUNS*INS_ATOMS);
211 /* check temperature */
212 dt=md->t_avg-md->t_ref;
213 dp=md->p_avg-md->p_ref;
218 if((dt>POST_DELTA_TC)|(dp>POST_DELTA_PC))
221 /* immediately return if no job is to be done */
222 if(hp->postrun_count==POST_RUNS) {
223 printf(" --- leaving post run state ---\n");
228 hp->postrun_count+=1;
229 printf(" ### postrun (%d/%d) ###\n",
230 hp->postrun_count,POST_RUNS);
231 set_temperature(md,md->t_ref-POST_DT);
235 /* reset the average counters */
239 moldyn_add_schedule(md,steps,tau);
244 int main(int argc,char **argv) {
246 /* main moldyn structure */
249 /* hook parameter structure */
252 /* potential parameters */
253 t_tersoff_mult_params tp;
254 t_albe_mult_params ap;
256 /* testing location & velocity vector */
258 memset(&r,0,sizeof(t_3dvec));
259 memset(&v,0,sizeof(t_3dvec));
261 /* initialize moldyn */
262 moldyn_init(&md,argc,argv);
264 /* choose integration algorithm */
265 set_int_alg(&md,MOLDYN_INTEGRATE_VERLET);
267 /* choose potential */
269 set_potential3b_j1(&md,albe_mult_3bp_j1);
270 set_potential3b_k1(&md,albe_mult_3bp_k1);
271 set_potential3b_j2(&md,albe_mult_3bp_j2);
272 set_potential3b_k2(&md,albe_mult_3bp_k2);
274 set_potential1b(&md,tersoff_mult_1bp);
275 set_potential3b_j1(&md,tersoff_mult_3bp_j1);
276 set_potential3b_k1(&md,tersoff_mult_3bp_k1);
277 set_potential3b_j2(&md,tersoff_mult_3bp_j2);
278 set_potential3b_k2(&md,tersoff_mult_3bp_k2);
282 set_potential_params(&md,&ap);
284 set_potential_params(&md,&tp);
287 /* cutoff radius & bondlen */
289 set_cutoff(&md,ALBE_S_SI);
290 set_bondlen(&md,ALBE_S_SI,ALBE_S_C,ALBE_S_SIC);
291 //set_cutoff(&md,ALBE_S_C);
293 set_cutoff(&md,TM_S_SI);
294 set_bondlen(&md,TM_S_SI,TM_S_C,-1.0);
295 //set_cutoff(&md,TM_S_C);
299 * potential parameters
303 * tersoff mult potential parameters for SiC
309 tp.lambda[0]=TM_LAMBDA_SI;
311 tp.beta[0]=TM_BETA_SI;
321 tp.lambda[1]=TM_LAMBDA_C;
323 tp.beta[1]=TM_BETA_C;
331 tersoff_mult_complete_params(&tp);
334 * albe mult potential parameters for SiC
341 ap.lambda[0]=ALBE_LAMBDA_SI;
343 ap.gamma[0]=ALBE_GAMMA_SI;
353 ap.lambda[1]=ALBE_LAMBDA_C;
355 ap.gamma[1]=ALBE_GAMMA_C;
360 ap.Smixed=ALBE_S_SIC;
361 ap.Rmixed=ALBE_R_SIC;
362 ap.Amixed=ALBE_A_SIC;
363 ap.Bmixed=ALBE_B_SIC;
364 ap.r0_mixed=ALBE_R0_SIC;
365 ap.lambda_m=ALBE_LAMBDA_SIC;
367 ap.gamma_m=ALBE_GAMMA_SIC;
368 ap.c_mixed=ALBE_C_SIC;
369 ap.d_mixed=ALBE_D_SIC;
370 ap.h_mixed=ALBE_H_SIC;
372 albe_mult_complete_params(&ap);
374 /* set (initial) dimensions of simulation volume */
377 set_dim(&md,LCNTX*ALBE_LC_SI,LCNTY*ALBE_LC_SI,LCNTZ*ALBE_LC_SI,TRUE);
380 set_dim(&md,LCNTX*ALBE_LC_C,LCNTY*ALBE_LC_C,LCNTZ*ALBE_LC_C,TRUE);
383 set_dim(&md,LCNTX*ALBE_LC_SIC,LCNTY*ALBE_LC_SIC,LCNTZ*ALBE_LC_SIC,TRUE);
387 set_dim(&md,LCNTX*LC_SI,LCNTY*LC_SI,LCNTZ*LC_SI,TRUE);
390 set_dim(&md,LCNTX*LC_C,LCNTY*LC_C,LCNTZ*LC_C,TRUE);
393 set_dim(&md,LCNTX*TM_LC_SIC,LCNTY*TM_LC_SIC,LCNTZ*TM_LC_SIC,TRUE);
397 /* set periodic boundary conditions in all directions */
398 set_pbc(&md,TRUE,TRUE,TRUE);
400 /* create the lattice / place atoms */
405 create_lattice(&md,DIAMOND,ALBE_LC_SI,SI,M_SI,
406 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
407 0,LCNTX,LCNTY,LCNTZ,NULL);
410 create_lattice(&md,DIAMOND,ALBE_LC_C,C,M_C,
411 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
412 1,LCNTX,LCNTY,LCNTZ,NULL);
416 create_lattice(&md,DIAMOND,LC_SI,SI,M_SI,
417 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
418 0,LCNTX,LCNTY,LCNTZ,NULL);
421 create_lattice(&md,DIAMOND,LC_C,SI,M_SI,
422 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
423 1,LCNTX,LCNTY,LCNTZ,NULL);
430 r.x=0.5*0.25*ALBE_LC_SIC; r.y=r.x; r.z=r.x;
431 create_lattice(&md,FCC,ALBE_LC_SIC,SI,M_SI,
432 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
433 0,LCNTX,LCNTY,LCNTZ,&r);
434 r.x+=0.25*ALBE_LC_SIC; r.y=r.x; r.z=r.x;
435 create_lattice(&md,FCC,ALBE_LC_SIC,C,M_C,
436 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB|ATOM_ATTR_VB,
437 1,LCNTX,LCNTY,LCNTZ,&r);
439 r.x=0.5*0.25*TM_LC_SIC; r.y=r.x; r.z=r.x;
440 create_lattice(&md,FCC,TM_LC_SIC,SI,M_SI,
441 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
442 0,LCNTX,LCNTY,LCNTZ,&r);
443 r.x+=0.25*TM_LC_SIC; r.y=r.x; r.z=r.x;
444 create_lattice(&md,FCC,TM_LC_SIC,C,M_C,
445 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
446 1,LCNTX,LCNTY,LCNTZ,&r);
450 /* check for right atom placing */
451 moldyn_bc_check(&md);
453 /* testing configuration */
454 //r.x=0.27*sqrt(3.0)*LC_SI/2.0; v.x=0;
455 //r.x=(TM_S_SI+TM_R_SI)/4.0; v.x=0;
458 //add_atom(&md,SI,M_SI,0,
459 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
460 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
462 //r.x=-r.x; v.x=-v.x;
465 //add_atom(&md,SI,M_SI,0,
466 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
467 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
469 //r.z=0.27*sqrt(3.0)*LC_SI/2.0; v.z=0;
470 //r.x=(TM_S_SI+TM_R_SI)/4.0; v.x=0;
473 //add_atom(&md,SI,M_SI,0,
474 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
475 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
477 //r.z=-r.z; v.z=-v.z;
480 //add_atom(&md,SI,M_SI,0,
481 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
482 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
485 /* set temperature & pressure */
486 set_temperature(&md,atof(argv[2])+273.0);
487 set_pressure(&md,0.0);
489 /* set amount of steps to skip before average calc */
490 set_avg_skip(&md,AVG_SKIP);
492 /* set p/t scaling */
493 //set_pt_scale(&md,0,0,T_SCALE_BERENDSEN,100.0);
494 //set_pt_scale(&md,P_SCALE_BERENDSEN,0.01/(100*GPA),
495 // T_SCALE_BERENDSEN,100.0);
496 //set_pt_scale(&md,0,0,T_SCALE_DIRECT,1.0);
497 //set_pt_scale(&md,P_SCALE_BERENDSEN,0.001,0,0);
499 /* initial thermal fluctuations of particles (in equilibrium) */
500 thermal_init(&md,TRUE);
502 /* create the simulation schedule */
503 moldyn_add_schedule(&md,PRERUN,PRE_TAU);
505 /* schedule hook function */
506 memset(&hookparam,0,sizeof(t_hp));
509 moldyn_set_schedule_hook(&md,&sic_hook,&hookparam);
510 //moldyn_set_schedule_hook(&md,&hook_del_atom,&hookparam);
511 //moldyn_add_schedule(&md,POSTRUN,1.0);
513 /* activate logging */
514 moldyn_set_log_dir(&md,argv[1]);
515 moldyn_set_report(&md,"Frank Zirkelbach",R_TITLE);
516 moldyn_set_log(&md,LOG_TOTAL_ENERGY,LOG_E);
517 moldyn_set_log(&md,LOG_TEMPERATURE,LOG_T);
518 moldyn_set_log(&md,LOG_PRESSURE,LOG_P);
519 moldyn_set_log(&md,LOG_VOLUME,LOG_V);
520 moldyn_set_log(&md,VISUAL_STEP,LOG_A);
521 moldyn_set_log(&md,SAVE_STEP,LOG_S);
522 moldyn_set_log(&md,CREATE_REPORT,0);
524 /* next neighbour distance for critical checking */
525 set_nn_dist(&md,0.25*ALBE_LC_SI*sqrt(3.0));
528 * let's do the actual md algorithm now
530 * integration of newtons equations
532 moldyn_integrate(&md);
538 * post processing the data
542 moldyn_shutdown(&md);