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