still full of bugs ...
[physik/posic.git] / sic.c
1 /*
2  * sic.c - investigation of the sic precipitation process of silicon carbide
3  *
4  * author: Frank Zirkelbach <frank.zirkelbach@physik.uni-augsburg.de>
5  *
6  */
7
8 #include <math.h>
9  
10 #include "moldyn.h"
11
12 #include "posic.h"
13
14 int main(int argc,char **argv) {
15
16         /* check argv */
17         if(argc!=3) {
18                 printf("[sic] usage: %s <logdir> <temperatur>\n",argv[0]);
19                 return -1;
20         }
21
22         /* main moldyn structure */
23         t_moldyn md;
24
25         /* potential parameters */
26         t_lj_params lj;
27         t_ho_params ho;
28         t_tersoff_mult_params tp;
29
30         /* misc parameters */
31         double tau;
32
33         /* testing location & velocity vector */
34         t_3dvec r,v;
35
36         /* values */
37         tau=1.0e-15;    /* delta t = 1 fs */
38
39         /* initialize moldyn */
40         printf("[sic] moldyn init\n");
41         moldyn_init(&md,argc,argv);
42
43         /* choose integration algorithm */
44         printf("[sic] setting integration algorithm\n");
45         set_int_alg(&md,MOLDYN_INTEGRATE_VERLET);
46
47         /* choose potential */
48         printf("[sic] selecting potential\n");
49         //set_potential1b(&md,tersoff_mult_1bp,&tp);
50         //set_potential2b(&md,tersoff_mult_2bp,&tp);
51         //set_potential2b_post(&md,tersoff_mult_post_2bp,&tp);
52         //set_potential3b(&md,tersoff_mult_3bp,&tp);
53         set_potential2b(&md,lennard_jones,&lj);
54         //set_potential2b(&md,harmonic_oscillator,&ho);
55
56         /* cutoff radius */
57         printf("[sic] setting cutoff radius\n");
58         //set_cutoff(&md,TM_S_SI);
59         set_cutoff(&md,3*LC_SI);
60
61         /*
62          * potential parameters
63          */
64
65         /* lennard jones */
66         lj.sigma6=LJ_SIGMA_SI*LJ_SIGMA_SI*LJ_SIGMA_SI;
67         lj.sigma6*=lj.sigma6;
68         lj.sigma12=lj.sigma6*lj.sigma6;
69         lj.epsilon4=4.0*LJ_EPSILON_SI;
70         lj.uc=lj.epsilon4*(lj.sigma12/pow(md.cutoff,12.0)-lj.sigma6/pow(md.cutoff,6));
71
72         /* harmonic oscillator */
73         ho.equilibrium_distance=0.25*sqrt(3.0)*LC_SI;
74         ho.spring_constant=.1;
75
76         /*
77          * tersoff mult potential parameters for SiC
78          */
79         tp.S[0]=TM_S_SI;
80         tp.R[0]=TM_R_SI;
81         tp.A[0]=TM_A_SI;
82         tp.B[0]=TM_B_SI;
83         tp.lambda[0]=TM_LAMBDA_SI;
84         tp.mu[0]=TM_MU_SI;
85         tp.beta[0]=TM_BETA_SI;
86         tp.n[0]=TM_N_SI;
87         tp.c[0]=TM_C_SI;
88         tp.d[0]=TM_D_SI;
89         tp.h[0]=TM_H_SI;
90
91         tp.S[1]=TM_S_C;
92         tp.R[1]=TM_R_C;
93         tp.A[1]=TM_A_C;
94         tp.B[1]=TM_B_C;
95         tp.lambda[1]=TM_LAMBDA_C;
96         tp.mu[1]=TM_MU_C;
97         tp.beta[1]=TM_BETA_C;
98         tp.n[1]=TM_N_C;
99         tp.c[1]=TM_C_C;
100         tp.d[1]=TM_D_C;
101         tp.h[1]=TM_H_C;
102
103         tp.chi=TM_CHI_SIC;
104
105         tersoff_mult_complete_params(&tp);
106
107         /* set (initial) dimensions of simulation volume */
108         printf("[sic] setting dimensions\n");
109         set_dim(&md,10*LC_SI,10*LC_SI,10*LC_SI,TRUE);
110
111         /* set periodic boundary conditions in all directions */
112         printf("[sic] setting periodic boundary conditions\n");
113         set_pbc(&md,TRUE,TRUE,TRUE);
114
115         /* create the lattice / place atoms */
116         printf("[sic] creating atoms\n");
117         create_lattice(&md,DIAMOND,LC_SI,SI,M_SI,
118         //               ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
119                        ATOM_ATTR_2BP|ATOM_ATTR_HB,
120                        0,10,10,10);
121         moldyn_bc_check(&md);
122
123         /* testing configuration */
124         //r.x=0.28*sqrt(3)*LC_SI/2;     v.x=0;
125         //r.x=1.75*LC_SI;       v.x=-0.01;
126         //r.y=0;                v.y=0;
127         //r.z=0;                v.z=0;
128         //add_atom(&md,SI,M_SI,0,
129         //           ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
130         //           ATOM_ATTR_2BP|ATOM_ATTR_HB,
131         //           &r,&v);
132         //r.x=-r.x;     v.x=-v.x;
133         //r.y=0;                v.y=0;
134         //r.z=0;                v.z=0;
135         //add_atom(&md,SI,M_SI,0,
136         //           ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
137         //           ATOM_ATTR_2BP|ATOM_ATTR_HB,
138         //           &r,&v);
139
140         /* setting a nearest neighbour distance for the moldyn checks */
141         set_nn_dist(&md,0.25*sqrt(3.0)*LC_SI); /* diamond ! */
142
143         /* set temperature */
144         printf("[sic] setting temperature -> %f\n",273+atof(argv[2]));
145         //set_temperature(&md,273.0+1410.0);
146         //set_temperature(&md,273.0+450.0);
147         //set_temperature(&md,273.0);
148         //set_temperature(&md,1.0);
149         //set_temperature(&md,0.0);
150         set_temperature(&md,atof(argv[2])+273.0);
151
152         /* set pressure */
153         printf("[sic] setting pressure\n");
154         set_pressure(&md,ATM);
155
156         /* set p/t scaling */
157         printf("[sic] set p/t scaling\n");
158         //set_pt_scale(&md,P_SCALE_BERENDSEN,100.0,
159         //                 T_SCALE_BERENDSEN,100.0);
160         //set_pt_scale(&md,0,0,T_SCALE_BERENDSEN,100.0);
161         //set_pt_scale(&md,P_SCALE_BERENDSEN,100.0,0,0);
162         
163         /* initial thermal fluctuations of particles (in equilibrium) */
164         printf("[sic] thermal init\n");
165         thermal_init(&md,TRUE);
166
167         /* create the simulation schedule */
168         printf("[sic] adding schedule\n");
169         moldyn_add_schedule(&md,10001,1.0);
170
171         /* activate logging */
172         printf("[sic] activate logging\n");
173         moldyn_set_log_dir(&md,argv[1]);
174         moldyn_set_log(&md,LOG_TOTAL_ENERGY,10);
175         moldyn_set_log(&md,VISUAL_STEP,100);
176
177         /*
178          * let's do the actual md algorithm now
179          *
180          * integration of newtons equations
181          */
182
183         printf("[sic] integration start, go get a coffee ...\n");
184         moldyn_integrate(&md);
185
186         /* close */
187
188         printf("[sic] shutdown\n");
189         moldyn_shutdown(&md);
190         
191         return 0;
192 }
193