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.5+0.25+0.125)*ALBE_LC_SI;
79 moldyn->atom[4372].r.z=(-0.5+0.25-0.125)*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 r.x=(rand_get_double(&(moldyn->random))-0.5)*INS_LENX;
90 r.y=(rand_get_double(&(moldyn->random))-0.5)*INS_LENY;
91 r.z=(rand_get_double(&(moldyn->random))-0.5)*INS_LENZ;
97 /* assume valid coordinates */
99 dmin=10000000000.0; // for sure too high!
100 for(i=0;i<moldyn->count;i++) {
101 atom=&(moldyn->atom[i]);
102 v3_sub(&dist,&(atom->r),&r);
103 check_per_bound(moldyn,&dist);
104 d=v3_absolute_square(&dist);
105 /* reject coordinates */
107 //printf("atom %d - %f\n",i,d);
115 add_atom(moldyn,INS_TYPE,INS_MASS,INS_BRAND,
116 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|\
119 printf(" %02d: atom %d | %f %f %f | %f\n",
120 j,moldyn->count-1,r.x,r.y,r.z,dmin);
126 int sic_hook(void *moldyn,void *hook_params) {
140 /* switch on t scaling */
141 if(md->schedule.count==0)
142 set_pt_scale(md,0,0,T_SCALE_BERENDSEN,T_SCALE_TAU);
144 /* my lousy state machine ! */
146 /* switch to insert state immediately */
147 if(hp->state==STATE_PRERUN)
148 hp->state=STATE_INSERT;
158 printf("[sic hook] unknown state\n");
162 /* act according to state */
166 /* immediately go on if no job is to be done */
167 if(hp->insert_count==INS_RUNS) {
168 printf(" --- insert run return ---\n");
169 hp->state=STATE_POSTRUN;
177 /* check temperature */
178 dt=md->t_avg-md->t_ref;
184 /* else -> insert atoms */
186 printf(" ### insert atoms (%d/%d) ###\n",
187 hp->insert_count*INS_ATOMS,INS_RUNS*INS_ATOMS);
193 /* immediately return if no job is to be done */
194 if(hp->postrun_count==POST_RUNS) {
195 printf(" --- post run return ---\n");
203 /* check temperature */
204 dt=md->t_avg-md->t_ref;
211 hp->postrun_count+=1;
212 printf(" ### postrun (%d/%d) ###\n",
213 hp->postrun_count,POST_RUNS);
214 set_temperature(md,md->t_ref-POST_DT);
218 /* reset the average counters */
222 moldyn_add_schedule(md,steps,tau);
227 int main(int argc,char **argv) {
229 /* main moldyn structure */
232 /* hook parameter structure */
235 /* potential parameters */
236 t_tersoff_mult_params tp;
237 t_albe_mult_params ap;
239 /* testing location & velocity vector */
241 memset(&r,0,sizeof(t_3dvec));
242 memset(&v,0,sizeof(t_3dvec));
244 /* initialize moldyn */
245 moldyn_init(&md,argc,argv);
247 /* choose integration algorithm */
248 set_int_alg(&md,MOLDYN_INTEGRATE_VERLET);
250 /* choose potential */
252 set_potential3b_j1(&md,albe_mult_3bp_j1);
253 set_potential3b_k1(&md,albe_mult_3bp_k1);
254 set_potential3b_j2(&md,albe_mult_3bp_j2);
255 set_potential3b_k2(&md,albe_mult_3bp_k2);
257 set_potential1b(&md,tersoff_mult_1bp);
258 set_potential3b_j1(&md,tersoff_mult_3bp_j1);
259 set_potential3b_k1(&md,tersoff_mult_3bp_k1);
260 set_potential3b_j2(&md,tersoff_mult_3bp_j2);
261 set_potential3b_k2(&md,tersoff_mult_3bp_k2);
265 set_potential_params(&md,&ap);
267 set_potential_params(&md,&tp);
270 /* cutoff radius & bondlen */
272 set_cutoff(&md,ALBE_S_SI);
273 set_bondlen(&md,ALBE_S_SI,ALBE_S_C,ALBE_S_SIC);
274 //set_cutoff(&md,ALBE_S_C);
276 set_cutoff(&md,TM_S_SI);
277 set_bondlen(&md,TM_S_SI,TM_S_C,-1.0);
278 //set_cutoff(&md,TM_S_C);
282 * potential parameters
286 * tersoff mult potential parameters for SiC
292 tp.lambda[0]=TM_LAMBDA_SI;
294 tp.beta[0]=TM_BETA_SI;
304 tp.lambda[1]=TM_LAMBDA_C;
306 tp.beta[1]=TM_BETA_C;
314 tersoff_mult_complete_params(&tp);
317 * albe mult potential parameters for SiC
324 ap.lambda[0]=ALBE_LAMBDA_SI;
326 ap.gamma[0]=ALBE_GAMMA_SI;
336 ap.lambda[1]=ALBE_LAMBDA_C;
338 ap.gamma[1]=ALBE_GAMMA_C;
343 ap.Smixed=ALBE_S_SIC;
344 ap.Rmixed=ALBE_R_SIC;
345 ap.Amixed=ALBE_A_SIC;
346 ap.Bmixed=ALBE_B_SIC;
347 ap.r0_mixed=ALBE_R0_SIC;
348 ap.lambda_m=ALBE_LAMBDA_SIC;
350 ap.gamma_m=ALBE_GAMMA_SIC;
351 ap.c_mixed=ALBE_C_SIC;
352 ap.d_mixed=ALBE_D_SIC;
353 ap.h_mixed=ALBE_H_SIC;
355 albe_mult_complete_params(&ap);
357 /* set (initial) dimensions of simulation volume */
360 set_dim(&md,LCNTX*ALBE_LC_SI,LCNTY*ALBE_LC_SI,LCNTZ*ALBE_LC_SI,TRUE);
363 set_dim(&md,LCNTX*ALBE_LC_C,LCNTY*ALBE_LC_C,LCNTZ*ALBE_LC_C,TRUE);
366 set_dim(&md,LCNTX*ALBE_LC_SIC,LCNTY*ALBE_LC_SIC,LCNTZ*ALBE_LC_SIC,TRUE);
370 set_dim(&md,LCNTX*LC_SI,LCNTY*LC_SI,LCNTZ*LC_SI,TRUE);
373 set_dim(&md,LCNTX*LC_C,LCNTY*LC_C,LCNTZ*LC_C,TRUE);
376 set_dim(&md,LCNTX*TM_LC_SIC,LCNTY*TM_LC_SIC,LCNTZ*TM_LC_SIC,TRUE);
380 /* set periodic boundary conditions in all directions */
381 set_pbc(&md,TRUE,TRUE,TRUE);
383 /* create the lattice / place atoms */
388 create_lattice(&md,DIAMOND,ALBE_LC_SI,SI,M_SI,
389 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
390 0,LCNTX,LCNTY,LCNTZ,NULL);
393 create_lattice(&md,DIAMOND,ALBE_LC_C,C,M_C,
394 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
395 1,LCNTX,LCNTY,LCNTZ,NULL);
399 create_lattice(&md,DIAMOND,LC_SI,SI,M_SI,
400 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
401 0,LCNTX,LCNTY,LCNTZ,NULL);
404 create_lattice(&md,DIAMOND,LC_C,SI,M_SI,
405 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
406 1,LCNTX,LCNTY,LCNTZ,NULL);
413 r.x=0.5*0.25*ALBE_LC_SIC; r.y=r.x; r.z=r.x;
414 create_lattice(&md,FCC,ALBE_LC_SIC,SI,M_SI,
415 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
416 0,LCNTX,LCNTY,LCNTZ,&r);
417 r.x+=0.25*ALBE_LC_SIC; r.y=r.x; r.z=r.x;
418 create_lattice(&md,FCC,ALBE_LC_SIC,C,M_C,
419 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
420 1,LCNTX,LCNTY,LCNTZ,&r);
422 r.x=0.5*0.25*TM_LC_SIC; r.y=r.x; r.z=r.x;
423 create_lattice(&md,FCC,TM_LC_SIC,SI,M_SI,
424 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
425 0,LCNTX,LCNTY,LCNTZ,&r);
426 r.x+=0.25*TM_LC_SIC; r.y=r.x; r.z=r.x;
427 create_lattice(&md,FCC,TM_LC_SIC,C,M_C,
428 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
429 1,LCNTX,LCNTY,LCNTZ,&r);
433 /* check for right atom placing */
434 moldyn_bc_check(&md);
436 /* testing configuration */
437 //r.x=0.27*sqrt(3.0)*LC_SI/2.0; v.x=0;
438 //r.x=(TM_S_SI+TM_R_SI)/4.0; v.x=0;
441 //add_atom(&md,SI,M_SI,0,
442 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
443 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
445 //r.x=-r.x; v.x=-v.x;
448 //add_atom(&md,SI,M_SI,0,
449 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
450 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
452 //r.z=0.27*sqrt(3.0)*LC_SI/2.0; v.z=0;
453 //r.x=(TM_S_SI+TM_R_SI)/4.0; v.x=0;
456 //add_atom(&md,SI,M_SI,0,
457 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
458 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
460 //r.z=-r.z; v.z=-v.z;
463 //add_atom(&md,SI,M_SI,0,
464 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
465 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
468 /* set temperature & pressure */
469 set_temperature(&md,atof(argv[2])+273.0);
470 set_pressure(&md,BAR);
472 /* set amount of steps to skip before average calc */
473 set_avg_skip(&md,AVG_SKIP);
475 /* set p/t scaling */
476 //set_pt_scale(&md,0,0,T_SCALE_BERENDSEN,100.0);
477 //set_pt_scale(&md,P_SCALE_BERENDSEN,0.001,
478 // T_SCALE_BERENDSEN,100.0);
479 //set_pt_scale(&md,0,0,T_SCALE_DIRECT,1.0);
480 //set_pt_scale(&md,P_SCALE_BERENDSEN,0.001,0,0);
482 /* initial thermal fluctuations of particles (in equilibrium) */
483 thermal_init(&md,TRUE);
485 /* create the simulation schedule */
486 moldyn_add_schedule(&md,PRERUN,PRE_TAU);
488 /* schedule hook function */
489 memset(&hookparam,0,sizeof(t_hp));
492 moldyn_set_schedule_hook(&md,&sic_hook,&hookparam);
493 //moldyn_set_schedule_hook(&md,&hook_del_atom,&hookparam);
494 //moldyn_add_schedule(&md,POSTRUN,1.0);
496 /* activate logging */
497 moldyn_set_log_dir(&md,argv[1]);
498 moldyn_set_report(&md,"Frank Zirkelbach",R_TITLE);
499 moldyn_set_log(&md,LOG_TOTAL_ENERGY,LOG_E);
500 moldyn_set_log(&md,LOG_TEMPERATURE,LOG_T);
501 moldyn_set_log(&md,LOG_PRESSURE,LOG_P);
502 moldyn_set_log(&md,VISUAL_STEP,LOG_V);
503 moldyn_set_log(&md,SAVE_STEP,LOG_S);
504 moldyn_set_log(&md,CREATE_REPORT,0);
506 /* next neighbour distance for critical checking */
507 set_nn_dist(&md,0.25*ALBE_LC_SI*sqrt(3.0));
510 * let's do the actual md algorithm now
512 * integration of newtons equations
514 moldyn_integrate(&md);
520 * post processing the data
524 moldyn_shutdown(&md);