testing foo
[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
55         /*
56          * potential parameters
57          */
58
59         /* lennard jones */
60         lj.sigma6=LJ_SIGMA_SI*LJ_SIGMA_SI*LJ_SIGMA_SI;
61         lj.sigma6*=lj.sigma6;
62         lj.sigma12=lj.sigma6*lj.sigma6;
63         lj.epsilon4=4.0*LJ_EPSILON_SI;
64
65         /* harmonic oscillator */
66         ho.equilibrium_distance=0.25*sqrt(3.0)*LC_SI;
67         ho.spring_constant=1;
68
69         /*
70          * tersoff mult potential parameters for SiC
71          */
72         tp.S[0]=TM_S_SI;
73         tp.R[0]=TM_R_SI;
74         tp.A[0]=TM_A_SI;
75         tp.B[0]=TM_B_SI;
76         tp.lambda[0]=TM_LAMBDA_SI;
77         tp.mu[0]=TM_MU_SI;
78         tp.beta[0]=TM_BETA_SI;
79         tp.n[0]=TM_N_SI;
80         tp.c[0]=TM_C_SI;
81         tp.d[0]=TM_D_SI;
82         tp.h[0]=TM_H_SI;
83
84         tp.S[1]=TM_S_C;
85         tp.R[1]=TM_R_C;
86         tp.A[1]=TM_A_C;
87         tp.B[1]=TM_B_C;
88         tp.lambda[1]=TM_LAMBDA_C;
89         tp.mu[1]=TM_MU_C;
90         tp.beta[1]=TM_BETA_C;
91         tp.n[1]=TM_N_C;
92         tp.c[1]=TM_C_C;
93         tp.d[1]=TM_D_C;
94         tp.h[1]=TM_H_C;
95
96         tp.chi=TM_CHI_SIC;
97
98         tersoff_mult_complete_params(&tp);
99
100         /* cutoff radius */
101         printf("[sic] setting cutoff radius\n");
102         set_cutoff(&md,TM_S_SI);
103         //set_cutoff(&md,2*LC_SI);
104
105         /* set (initial) dimensions of simulation volume */
106         printf("[sic] setting dimensions\n");
107         set_dim(&md,5*LC_SI,5*LC_SI,5*LC_SI,TRUE);
108
109         /* set periodic boundary conditions in all directions */
110         printf("[sic] setting periodic boundary conditions\n");
111         set_pbc(&md,TRUE,TRUE,TRUE);
112
113         /* create the lattice / place atoms */
114         printf("[sic] creating atoms\n");
115         //create_lattice(&md,DIAMOND,LC_SI,SI,M_SI,
116         //               ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_HB,
117         //               0,5,5,5);
118         //moldyn_bc_check(&md);
119
120         /* testing configuration */
121         r.x=2.8/2;      v.x=0;
122         r.y=0;          v.y=0;
123         r.z=0;          v.z=0;
124         add_atom(&md,SI,M_SI,0,
125                    ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP,//|ATOM_ATTR_HB,
126         //           ATOM_ATTR_2BP,
127                    &r,&v);
128         r.x=-2.8/2;     v.x=0;
129         r.y=0;          v.y=0;
130         r.z=0;          v.z=0;
131         add_atom(&md,SI,M_SI,0,
132                    ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP,//|ATOM_ATTR_HB,
133         //           ATOM_ATTR_2BP,
134                    &r,&v);
135
136         /* setting a nearest neighbour distance for the moldyn checks */
137         set_nn_dist(&md,0.25*sqrt(3.0)*LC_SI); /* diamond ! */
138
139         /* set temperature */
140         printf("[sic] setting temperature -> %f\n",273+atof(argv[2]));
141         //set_temperature(&md,273.0+1410.0);
142         //set_temperature(&md,273.0+450.0);
143         //set_temperature(&md,273.0);
144         //set_temperature(&md,1.0);
145         //set_temperature(&md,0.0);
146         set_temperature(&md,atof(argv[2])+273.0);
147
148         /* set pressure */
149         printf("[sic] setting pressure\n");
150         set_pressure(&md,ATM);
151
152         /* set p/t scaling */
153         printf("[sic] set p/t scaling\n");
154         //set_pt_scale(&md,P_SCALE_BERENDSEN,100.0,
155         //                 T_SCALE_BERENDSEN,100.0);
156         //set_pt_scale(&md,0,0,T_SCALE_BERENDSEN,100.0);
157         
158         /* initial thermal fluctuations of particles (in equilibrium) */
159         printf("[sic] thermal init\n");
160         //thermal_init(&md,TRUE);
161
162         /* create the simulation schedule */
163         printf("[sic] adding schedule\n");
164         moldyn_add_schedule(&md,10000,.1);
165
166         /* activate logging */
167         printf("[sic] activate logging\n");
168         moldyn_set_log_dir(&md,argv[1]);
169         moldyn_set_log(&md,LOG_TOTAL_ENERGY,1);
170         moldyn_set_log(&md,VISUAL_STEP,20);
171
172         /*
173          * let's do the actual md algorithm now
174          *
175          * integration of newtons equations
176          */
177
178         printf("[sic] integration start, go get a coffee ...\n");
179         moldyn_integrate(&md);
180
181         /* close */
182
183         printf("[sic] shutdown\n");
184         moldyn_shutdown(&md);
185         
186         return 0;
187 }
188