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