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/tersoff.h"
21 int hook(void *moldyn,void *hook_params) {
32 printf("\nschedule hook: ");
34 if(!(md->schedule.count%2)) {
35 /* add carbon at random place, and enable t scaling */
36 for(j=0;j<NR_ATOMS;j++) {
39 r.x=rand_get_double(&(md->random))*md->dim.x;
40 r.y=rand_get_double(&(md->random))*md->dim.y;
41 r.z=rand_get_double(&(md->random))*md->dim.z;
42 for(i=0;i<md->count;i++) {
44 v3_sub(&dist,&(atom->r),&r);
45 d=v3_absolute_square(&dist);
52 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
55 printf("adding atoms & enable t scaling\n");
56 set_pt_scale(md,0,0,T_SCALE_BERENDSEN,100.0);
59 /* disable t scaling */
60 printf("disabling t scaling\n");
61 set_pt_scale(md,0,0,0,0);
67 int main(int argc,char **argv) {
71 printf("[sic] usage: %s <logdir> <temperatur>\n",argv[0]);
75 /* main moldyn structure */
78 /* potential parameters */
81 t_tersoff_mult_params tp;
83 /* atom injection counter */
86 /* testing location & velocity vector */
88 memset(&r,0,sizeof(t_3dvec));
89 memset(&v,0,sizeof(t_3dvec));
91 /* initialize moldyn */
92 moldyn_init(&md,argc,argv);
94 /* choose integration algorithm */
95 set_int_alg(&md,MOLDYN_INTEGRATE_VERLET);
97 /* choose potential */
98 set_potential1b(&md,tersoff_mult_1bp);
99 set_potential2b(&md,tersoff_mult_2bp);
100 set_potential2b_post(&md,tersoff_mult_post_2bp);
101 set_potential3b(&md,tersoff_mult_3bp);
102 //set_potential2b(&md,lennard_jones);
103 //set_potential2b(&md,harmonic_oscillator);
104 set_potential_params(&md,&tp);
105 //set_potential_params(&md,&lj);
106 //set_potential_params(&md,&ho);
109 set_cutoff(&md,TM_S_SI);
110 //set_cutoff(&md,LC_SI*sqrt(3.0));
111 //set_cutoff(&md,2.0*LC_SI);
114 * potential parameters
118 lj.sigma6=LJ_SIGMA_SI*LJ_SIGMA_SI*LJ_SIGMA_SI;
119 lj.sigma6*=lj.sigma6;
120 lj.sigma12=lj.sigma6*lj.sigma6;
121 lj.epsilon4=4.0*LJ_EPSILON_SI;
122 lj.uc=lj.epsilon4*(lj.sigma12/pow(md.cutoff,12.0)-lj.sigma6/pow(md.cutoff,6));
124 /* harmonic oscillator */
125 ho.equilibrium_distance=0.25*sqrt(3.0)*LC_SI;
126 //ho.equilibrium_distance=LC_SI;
127 ho.spring_constant=LJ_EPSILON_SI;
130 * tersoff mult potential parameters for SiC
136 tp.lambda[0]=TM_LAMBDA_SI;
138 tp.beta[0]=TM_BETA_SI;
148 tp.lambda[1]=TM_LAMBDA_C;
150 tp.beta[1]=TM_BETA_C;
158 tersoff_mult_complete_params(&tp);
160 /* set (initial) dimensions of simulation volume */
161 set_dim(&md,6*LC_SI,6*LC_SI,6*LC_SI,TRUE);
163 /* set periodic boundary conditions in all directions */
164 set_pbc(&md,TRUE,TRUE,TRUE);
166 /* create the lattice / place atoms */
167 //create_lattice(&md,CUBIC,LC_SI,SI,M_SI,
168 //create_lattice(&md,FCC,LC_SI,SI,M_SI,
169 create_lattice(&md,DIAMOND,LC_SI,SI,M_SI,
170 ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
171 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
173 moldyn_bc_check(&md);
175 /* testing configuration */
176 //r.x=0.27*sqrt(3.0)*LC_SI/2.0; v.x=0;
177 //r.x=(TM_S_SI+TM_R_SI)/4.0; v.x=0;
180 //add_atom(&md,SI,M_SI,0,
181 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
182 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
184 //r.x=-r.x; v.x=-v.x;
187 //add_atom(&md,SI,M_SI,0,
188 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
189 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
193 //r.z=sin(M_PI*60.0/180.0)*(TM_S_SI+TM_R_SI)/4.0; v.z=0;
194 //add_atom(&md,SI,M_SI,0,
195 // ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
196 // ATOM_ATTR_2BP|ATOM_ATTR_HB,
199 /* set temperature & pressure */
200 set_temperature(&md,atof(argv[2])+273.0);
201 set_pressure(&md,ATM);
203 /* set p/t scaling */
204 //set_pt_scale(&md,P_SCALE_BERENDSEN,0.001,
205 // T_SCALE_BERENDSEN,100.0);
206 //set_pt_scale(&md,0,0,T_SCALE_DIRECT,1.0);
207 //set_pt_scale(&md,P_SCALE_BERENDSEN,0.001,0,0);
209 /* initial thermal fluctuations of particles (in equilibrium) */
210 thermal_init(&md,TRUE);
212 /* create the simulation schedule */
213 /* initial configuration */
214 moldyn_add_schedule(&md,500,1.0);
216 for(inject=0;inject<INJECT;inject++) {
217 /* injecting atom and run with enabled t scaling */
218 moldyn_add_schedule(&md,400,1.0);
219 /* continue running with disabled t scaling */
220 moldyn_add_schedule(&md,100,1.0);
223 /* schedule hook function */
224 moldyn_set_schedule_hook(&md,&hook,NULL);
226 /* activate logging */
227 moldyn_set_log_dir(&md,argv[1]);
228 moldyn_set_report(&md,"Frank Zirkelbach","Test 1");
229 moldyn_set_log(&md,LOG_TOTAL_ENERGY,10);
230 moldyn_set_log(&md,LOG_TEMPERATURE,10);
231 moldyn_set_log(&md,LOG_PRESSURE,10);
232 moldyn_set_log(&md,VISUAL_STEP,100);
233 moldyn_set_log(&md,SAVE_STEP,100);
234 moldyn_set_log(&md,CREATE_REPORT,0);
237 * let's do the actual md algorithm now
239 * integration of newtons equations
241 moldyn_integrate(&md);
244 moldyn_shutdown(&md);