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;
137 /* act according to state */
143 /* check temperature */
144 dt=md->t_avg-md->t_ref;
151 printf(" ### insert atoms (%d/%d) ###\n",
152 hp->insert_count*INS_ATOMS,INS_RUNS*INS_ATOMS);
154 /* change state after last insertion */
155 if(hp->insert_count==INS_RUNS)
156 hp->state=STATE_POSTRUN;
162 /* check temperature */
163 dt=md->t_avg-md->t_ref;
168 /* decrease temperature */
169 hp->postrun_count+=1;
170 printf(" ### postrun (%d/%d) ###\n",
171 hp->postrun_count,POST_RUNS);
172 set_temperature(md,md->t_ref-POST_DT);
173 if(hp->postrun_count==POST_RUNS)
177 printf("[hook] FATAL (default case!?!)\n");
181 /* reset the average counters */
185 moldyn_add_schedule(md,steps,tau);
190 int main(int argc,char **argv) {
192 /* main moldyn structure */
195 /* hook parameter structure */
198 /* potential parameters */
199 t_tersoff_mult_params tp;
200 t_albe_mult_params ap;
202 /* testing location & velocity vector */
204 memset(&r,0,sizeof(t_3dvec));
205 memset(&v,0,sizeof(t_3dvec));
207 /* initialize moldyn */
208 moldyn_init(&md,argc,argv);
210 /* choose integration algorithm */
211 set_int_alg(&md,MOLDYN_INTEGRATE_VERLET);
213 /* choose potential */
215 set_potential3b_j1(&md,albe_mult_3bp_j1);
216 set_potential3b_k1(&md,albe_mult_3bp_k1);
217 set_potential3b_j2(&md,albe_mult_3bp_j2);
218 set_potential3b_k2(&md,albe_mult_3bp_k2);
220 set_potential1b(&md,tersoff_mult_1bp);
221 set_potential3b_j1(&md,tersoff_mult_3bp_j1);
222 set_potential3b_k1(&md,tersoff_mult_3bp_k1);
223 set_potential3b_j2(&md,tersoff_mult_3bp_j2);
224 set_potential3b_k2(&md,tersoff_mult_3bp_k2);
228 set_potential_params(&md,&ap);
230 set_potential_params(&md,&tp);
233 /* cutoff radius & bondlen */
235 set_cutoff(&md,ALBE_S_SI);
236 set_bondlen(&md,ALBE_S_SI,ALBE_S_C,ALBE_S_SIC);
237 //set_cutoff(&md,ALBE_S_C);
239 set_cutoff(&md,TM_S_SI);
240 set_bondlen(&md,TM_S_SI,TM_S_C,-1.0);
241 //set_cutoff(&md,TM_S_C);
245 * potential parameters
249 * tersoff mult potential parameters for SiC
255 tp.lambda[0]=TM_LAMBDA_SI;
257 tp.beta[0]=TM_BETA_SI;
267 tp.lambda[1]=TM_LAMBDA_C;
269 tp.beta[1]=TM_BETA_C;
277 tersoff_mult_complete_params(&tp);
280 * albe mult potential parameters for SiC
287 ap.lambda[0]=ALBE_LAMBDA_SI;
289 ap.gamma[0]=ALBE_GAMMA_SI;
299 ap.lambda[1]=ALBE_LAMBDA_C;
301 ap.gamma[1]=ALBE_GAMMA_C;
306 ap.Smixed=ALBE_S_SIC;
307 ap.Rmixed=ALBE_R_SIC;
308 ap.Amixed=ALBE_A_SIC;
309 ap.Bmixed=ALBE_B_SIC;
310 ap.r0_mixed=ALBE_R0_SIC;
311 ap.lambda_m=ALBE_LAMBDA_SIC;
313 ap.gamma_m=ALBE_GAMMA_SIC;
314 ap.c_mixed=ALBE_C_SIC;
315 ap.d_mixed=ALBE_D_SIC;
316 ap.h_mixed=ALBE_H_SIC;
318 albe_mult_complete_params(&ap);
320 /* set (initial) dimensions of simulation volume */
322 set_dim(&md,LCNTX*ALBE_LC_SI,LCNTY*ALBE_LC_SI,LCNTZ*ALBE_LC_SI,TRUE);
323 //set_dim(&md,LCNTX*ALBE_LC_C,LCNTY*ALBE_LC_C,LCNTZ*ALBE_LC_C,TRUE);
324 //set_dim(&md,LCNTX*ALBE_LC_SIC,LCNTY*ALBE_LC_SIC,LCNTZ*ALBE_LC_SIC,TRUE);
326 set_dim(&md,LCNTX*LC_SI,LCNTY*LC_SI,LCNTZ*LC_SI,TRUE);
327 //set_dim(&md,LCNTX*LC_C,LCNTY*LC_C,LCNTZ*LC_C,TRUE);
328 //set_dim(&md,LCNTX*TM_LC_SIC,LCNTY*TM_LC_SIC,LCNTZ*TM_LC_SIC,TRUE);
331 /* set periodic boundary conditions in all directions */
332 set_pbc(&md,TRUE,TRUE,TRUE);
334 /* create the lattice / place atoms */
337 create_lattice(&md,DIAMOND,ALBE_LC_SI,SI,M_SI,
338 //create_lattice(&md,DIAMOND,ALBE_LC_C,C,M_C,
340 create_lattice(&md,DIAMOND,LC_SI,SI,M_SI,
342 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
343 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
344 0,LCNTX,LCNTY,LCNTZ,NULL);
345 // 1,LCNTX,LCNTY,LCNTZ,NULL);
347 /* create zinkblende structure */
350 r.x=0.5*0.25*ALBE_LC_SIC; r.y=r.x; r.z=r.x;
351 create_lattice(&md,FCC,ALBE_LC_SIC,SI,M_SI,
352 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
353 0,LCNTX,LCNTY,LCNTZ,&r);
354 r.x+=0.25*ALBE_LC_SIC; r.y=r.x; r.z=r.x;
355 create_lattice(&md,FCC,ALBE_LC_SIC,C,M_C,
356 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
357 1,LCNTX,LCNTY,LCNTZ,&r);
359 r.x=0.5*0.25*TM_LC_SIC; r.y=r.x; r.z=r.x;
360 create_lattice(&md,FCC,TM_LC_SIC,SI,M_SI,
361 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
362 0,LCNTX,LCNTY,LCNTZ,&r);
363 r.x+=0.25*TM_LC_SIC; r.y=r.x; r.z=r.x;
364 create_lattice(&md,FCC,TM_LC_SIC,C,M_C,
365 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
366 1,LCNTX,LCNTY,LCNTZ,&r);
370 /* check for right atom placing */
371 moldyn_bc_check(&md);
373 /* testing configuration */
374 //r.x=0.27*sqrt(3.0)*LC_SI/2.0; v.x=0;
375 //r.x=(TM_S_SI+TM_R_SI)/4.0; v.x=0;
378 //add_atom(&md,SI,M_SI,0,
379 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
380 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
382 //r.x=-r.x; v.x=-v.x;
385 //add_atom(&md,SI,M_SI,0,
386 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
387 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
389 //r.z=0.27*sqrt(3.0)*LC_SI/2.0; v.z=0;
390 //r.x=(TM_S_SI+TM_R_SI)/4.0; v.x=0;
393 //add_atom(&md,SI,M_SI,0,
394 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
395 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
397 //r.z=-r.z; v.z=-v.z;
400 //add_atom(&md,SI,M_SI,0,
401 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
402 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
405 /* set temperature & pressure */
406 set_temperature(&md,atof(argv[2])+273.0);
407 set_pressure(&md,BAR);
409 /* set amount of steps to skip before average calc */
410 set_avg_skip(&md,AVG_SKIP);
412 /* set p/t scaling */
413 //set_pt_scale(&md,0,0,T_SCALE_BERENDSEN,100.0);
414 //set_pt_scale(&md,P_SCALE_BERENDSEN,0.001,
415 // T_SCALE_BERENDSEN,100.0);
416 //set_pt_scale(&md,0,0,T_SCALE_DIRECT,1.0);
417 //set_pt_scale(&md,P_SCALE_BERENDSEN,0.001,0,0);
419 /* initial thermal fluctuations of particles (in equilibrium) */
420 thermal_init(&md,TRUE);
422 /* create the simulation schedule */
423 moldyn_add_schedule(&md,PRERUN,PRE_TAU);
425 /* schedule hook function */
426 memset(&hookparam,0,sizeof(t_hp));
429 moldyn_set_schedule_hook(&md,&sic_hook,&hookparam);
430 //moldyn_set_schedule_hook(&md,&hook_del_atom,&hookparam);
431 //moldyn_add_schedule(&md,POSTRUN,1.0);
433 /* activate logging */
434 moldyn_set_log_dir(&md,argv[1]);
435 moldyn_set_report(&md,"Frank Zirkelbach",R_TITLE);
436 moldyn_set_log(&md,LOG_TOTAL_ENERGY,LOG_E);
437 moldyn_set_log(&md,LOG_TEMPERATURE,LOG_T);
438 moldyn_set_log(&md,LOG_PRESSURE,LOG_P);
439 moldyn_set_log(&md,VISUAL_STEP,LOG_V);
440 moldyn_set_log(&md,SAVE_STEP,LOG_S);
441 moldyn_set_log(&md,CREATE_REPORT,0);
443 /* next neighbour distance for critical checking */
444 set_nn_dist(&md,0.25*ALBE_LC_SI*sqrt(3.0));
447 * let's do the actual md algorithm now
449 * integration of newtons equations
451 moldyn_integrate(&md);
457 * post processing the data
461 moldyn_shutdown(&md);