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 md->atom[4372].r.x=(-0.5+0.125+0.125)*ALBE_LC_SI;
72 md->atom[4372].r.y=(-0.5+0.125+0.125)*ALBE_LC_SI;
76 r.x=(rand_get_double(&(moldyn->random))-0.5)*INS_LENX;
77 r.y=(rand_get_double(&(moldyn->random))-0.5)*INS_LENY;
78 r.z=(rand_get_double(&(moldyn->random))-0.5)*INS_LENZ;
84 /* assume valid coordinates */
86 dmin=10000000000.0; // for sure too high!
87 for(i=0;i<moldyn->count;i++) {
88 atom=&(moldyn->atom[i]);
89 v3_sub(&dist,&(atom->r),&r);
90 check_per_bound(moldyn,&dist);
91 d=v3_absolute_square(&dist);
92 /* reject coordinates */
94 //printf("atom %d - %f\n",i,d);
102 add_atom(moldyn,INS_TYPE,INS_MASS,INS_BRAND,
103 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|\
106 printf(" %02d: atom %d | %f %f %f | %f\n",
107 j,moldyn->count-1,r.x,r.y,r.z,dmin);
113 int sic_hook(void *moldyn,void *hook_params) {
127 /* switch on t scaling */
128 if(md->schedule.count==0)
129 set_pt_scale(md,0,0,T_SCALE_BERENDSEN,100.0);
131 /* my lousy state machine ! */
133 /* switch to insert state immediately */
134 if(hp->state==STATE_PRERUN)
135 hp->state=STATE_INSERT;
145 printf("[sic hook] unknown state\n");
149 /* act according to state */
153 /* immediately go on if no job is to be done */
154 if(hp->insert_count==INS_RUNS) {
155 printf("immediate insert run return!\n");
156 hp->state=STATE_POSTRUN;
164 /* check temperature */
165 dt=md->t_avg-md->t_ref;
171 /* else -> insert atoms */
173 printf(" ### insert atoms (%d/%d) ###\n",
174 hp->insert_count*INS_ATOMS,INS_RUNS*INS_ATOMS);
180 /* immediately return if no job is to be done */
181 if(hp->postrun_count==POST_RUNS) {
182 printf("immediate post run return!\n");
190 /* check temperature */
191 dt=md->t_avg-md->t_ref;
198 hp->postrun_count+=1;
199 printf(" ### postrun (%d/%d) ###\n",
200 hp->postrun_count,POST_RUNS);
201 set_temperature(md,md->t_ref-POST_DT);
205 /* reset the average counters */
209 moldyn_add_schedule(md,steps,tau);
214 int main(int argc,char **argv) {
216 /* main moldyn structure */
219 /* hook parameter structure */
222 /* potential parameters */
223 t_tersoff_mult_params tp;
224 t_albe_mult_params ap;
226 /* testing location & velocity vector */
228 memset(&r,0,sizeof(t_3dvec));
229 memset(&v,0,sizeof(t_3dvec));
231 /* initialize moldyn */
232 moldyn_init(&md,argc,argv);
234 /* choose integration algorithm */
235 set_int_alg(&md,MOLDYN_INTEGRATE_VERLET);
237 /* choose potential */
239 set_potential3b_j1(&md,albe_mult_3bp_j1);
240 set_potential3b_k1(&md,albe_mult_3bp_k1);
241 set_potential3b_j2(&md,albe_mult_3bp_j2);
242 set_potential3b_k2(&md,albe_mult_3bp_k2);
244 set_potential1b(&md,tersoff_mult_1bp);
245 set_potential3b_j1(&md,tersoff_mult_3bp_j1);
246 set_potential3b_k1(&md,tersoff_mult_3bp_k1);
247 set_potential3b_j2(&md,tersoff_mult_3bp_j2);
248 set_potential3b_k2(&md,tersoff_mult_3bp_k2);
252 set_potential_params(&md,&ap);
254 set_potential_params(&md,&tp);
257 /* cutoff radius & bondlen */
259 set_cutoff(&md,ALBE_S_SI);
260 set_bondlen(&md,ALBE_S_SI,ALBE_S_C,ALBE_S_SIC);
261 //set_cutoff(&md,ALBE_S_C);
263 set_cutoff(&md,TM_S_SI);
264 set_bondlen(&md,TM_S_SI,TM_S_C,-1.0);
265 //set_cutoff(&md,TM_S_C);
269 * potential parameters
273 * tersoff mult potential parameters for SiC
279 tp.lambda[0]=TM_LAMBDA_SI;
281 tp.beta[0]=TM_BETA_SI;
291 tp.lambda[1]=TM_LAMBDA_C;
293 tp.beta[1]=TM_BETA_C;
301 tersoff_mult_complete_params(&tp);
304 * albe mult potential parameters for SiC
311 ap.lambda[0]=ALBE_LAMBDA_SI;
313 ap.gamma[0]=ALBE_GAMMA_SI;
323 ap.lambda[1]=ALBE_LAMBDA_C;
325 ap.gamma[1]=ALBE_GAMMA_C;
330 ap.Smixed=ALBE_S_SIC;
331 ap.Rmixed=ALBE_R_SIC;
332 ap.Amixed=ALBE_A_SIC;
333 ap.Bmixed=ALBE_B_SIC;
334 ap.r0_mixed=ALBE_R0_SIC;
335 ap.lambda_m=ALBE_LAMBDA_SIC;
337 ap.gamma_m=ALBE_GAMMA_SIC;
338 ap.c_mixed=ALBE_C_SIC;
339 ap.d_mixed=ALBE_D_SIC;
340 ap.h_mixed=ALBE_H_SIC;
342 albe_mult_complete_params(&ap);
344 /* set (initial) dimensions of simulation volume */
347 set_dim(&md,LCNTX*ALBE_LC_SI,LCNTY*ALBE_LC_SI,LCNTZ*ALBE_LC_SI,TRUE);
350 set_dim(&md,LCNTX*ALBE_LC_C,LCNTY*ALBE_LC_C,LCNTZ*ALBE_LC_C,TRUE);
353 set_dim(&md,LCNTX*ALBE_LC_SIC,LCNTY*ALBE_LC_SIC,LCNTZ*ALBE_LC_SIC,TRUE);
357 set_dim(&md,LCNTX*LC_SI,LCNTY*LC_SI,LCNTZ*LC_SI,TRUE);
360 set_dim(&md,LCNTX*LC_C,LCNTY*LC_C,LCNTZ*LC_C,TRUE);
363 set_dim(&md,LCNTX*TM_LC_SIC,LCNTY*TM_LC_SIC,LCNTZ*TM_LC_SIC,TRUE);
367 /* set periodic boundary conditions in all directions */
368 set_pbc(&md,TRUE,TRUE,TRUE);
370 /* create the lattice / place atoms */
375 create_lattice(&md,DIAMOND,ALBE_LC_SI,SI,M_SI,
376 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
377 0,LCNTX,LCNTY,LCNTZ,NULL);
380 create_lattice(&md,DIAMOND,ALBE_LC_C,C,M_C,
381 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
382 1,LCNTX,LCNTY,LCNTZ,NULL);
386 create_lattice(&md,DIAMOND,LC_SI,SI,M_SI,
387 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
388 0,LCNTX,LCNTY,LCNTZ,NULL);
391 create_lattice(&md,DIAMOND,LC_C,SI,M_SI,
392 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
393 1,LCNTX,LCNTY,LCNTZ,NULL);
400 r.x=0.5*0.25*ALBE_LC_SIC; r.y=r.x; r.z=r.x;
401 create_lattice(&md,FCC,ALBE_LC_SIC,SI,M_SI,
402 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
403 0,LCNTX,LCNTY,LCNTZ,&r);
404 r.x+=0.25*ALBE_LC_SIC; r.y=r.x; r.z=r.x;
405 create_lattice(&md,FCC,ALBE_LC_SIC,C,M_C,
406 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
407 1,LCNTX,LCNTY,LCNTZ,&r);
409 r.x=0.5*0.25*TM_LC_SIC; r.y=r.x; r.z=r.x;
410 create_lattice(&md,FCC,TM_LC_SIC,SI,M_SI,
411 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
412 0,LCNTX,LCNTY,LCNTZ,&r);
413 r.x+=0.25*TM_LC_SIC; r.y=r.x; r.z=r.x;
414 create_lattice(&md,FCC,TM_LC_SIC,C,M_C,
415 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
416 1,LCNTX,LCNTY,LCNTZ,&r);
420 /* check for right atom placing */
421 moldyn_bc_check(&md);
423 /* testing configuration */
424 //r.x=0.27*sqrt(3.0)*LC_SI/2.0; v.x=0;
425 //r.x=(TM_S_SI+TM_R_SI)/4.0; v.x=0;
428 //add_atom(&md,SI,M_SI,0,
429 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
430 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
432 //r.x=-r.x; v.x=-v.x;
435 //add_atom(&md,SI,M_SI,0,
436 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
437 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
439 //r.z=0.27*sqrt(3.0)*LC_SI/2.0; v.z=0;
440 //r.x=(TM_S_SI+TM_R_SI)/4.0; v.x=0;
443 //add_atom(&md,SI,M_SI,0,
444 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
445 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
447 //r.z=-r.z; v.z=-v.z;
450 //add_atom(&md,SI,M_SI,0,
451 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
452 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
455 /* set temperature & pressure */
456 set_temperature(&md,atof(argv[2])+273.0);
457 set_pressure(&md,BAR);
459 /* set amount of steps to skip before average calc */
460 set_avg_skip(&md,AVG_SKIP);
462 /* set p/t scaling */
463 //set_pt_scale(&md,0,0,T_SCALE_BERENDSEN,100.0);
464 //set_pt_scale(&md,P_SCALE_BERENDSEN,0.001,
465 // T_SCALE_BERENDSEN,100.0);
466 //set_pt_scale(&md,0,0,T_SCALE_DIRECT,1.0);
467 //set_pt_scale(&md,P_SCALE_BERENDSEN,0.001,0,0);
469 /* initial thermal fluctuations of particles (in equilibrium) */
470 thermal_init(&md,TRUE);
472 /* create the simulation schedule */
473 moldyn_add_schedule(&md,PRERUN,PRE_TAU);
475 /* schedule hook function */
476 memset(&hookparam,0,sizeof(t_hp));
479 moldyn_set_schedule_hook(&md,&sic_hook,&hookparam);
480 //moldyn_set_schedule_hook(&md,&hook_del_atom,&hookparam);
481 //moldyn_add_schedule(&md,POSTRUN,1.0);
483 /* activate logging */
484 moldyn_set_log_dir(&md,argv[1]);
485 moldyn_set_report(&md,"Frank Zirkelbach",R_TITLE);
486 moldyn_set_log(&md,LOG_TOTAL_ENERGY,LOG_E);
487 moldyn_set_log(&md,LOG_TEMPERATURE,LOG_T);
488 moldyn_set_log(&md,LOG_PRESSURE,LOG_P);
489 moldyn_set_log(&md,VISUAL_STEP,LOG_V);
490 moldyn_set_log(&md,SAVE_STEP,LOG_S);
491 moldyn_set_log(&md,CREATE_REPORT,0);
493 /* next neighbour distance for critical checking */
494 set_nn_dist(&md,0.25*ALBE_LC_SI*sqrt(3.0));
497 * let's do the actual md algorithm now
499 * integration of newtons equations
501 moldyn_integrate(&md);
507 * post processing the data
511 moldyn_shutdown(&md);