2 * create lattice (for usage in vasp POSCAR file)
4 * author: Frank Zirkelbach <frank.zirkelbach@physik.uni-augsburg.de>
12 #include "../math/math.h"
17 * there is fcc/diamond/zincblende only!
21 * 0: <0.5 0.5 0> <0 0.5 0.5> <0.5 0 0.5> contains 2 atoms
22 * 1: <0.5 -0.5 0> <0.5 0.5 0> <0 0 1> contains 4 atoms
23 * 2: <1 0 0> <0 1 0> <0 0 1> contains 8 atoms
29 * 2nd fcc: <0.25 0.25 0.25>
30 * -> diag: <0.25 0.25 0.25>
33 * 1st fcc: <0 0 0> <0.5 0.5 0.5>
34 * 2nd fcc: <0.5 0 0.25> <1.0 or 0.0 0.5 0.75>
38 * 1st fcc: <0 0 0> <0.5 0.5 0> <0.5 0 0.5> <0 0.5 0.5>
39 * 2nd fcc: <0.25 0.25 0.25> <0.75 0.75 0.25> <0.75 0.25 0.75>
41 * -> diag: <0.25 0.25 0.25>
45 int main(int argc,char **argv) {
47 int i,j,k,l,cnt,estimated;
53 char type,fccdia,foa,fixstr[6];
56 printf("usage: %s type fcc/dia lx ly lz\n",argv[0]);
57 printf(" basis types: 0, 1, 2 (see code)\n");
58 printf(" fcc/dia: 0=fcc, 1=dia\n");
59 printf(" optional: foa (fix outer atoms)\n");
84 memset(basis,0,3*sizeof(t_3dvec));
85 memset(o,0,3*sizeof(t_3dvec));
122 if(fccdia=='1') estimated*=2;
123 if(type=='1') estimated*=2;
124 if(type=='2') estimated*=4;
127 // print POSCAR 'header'
129 printf("cubic diamond\n");
132 v3_scale(&h,&basis[0],x);
133 printf(" %.5f %.5f %.5f\n",h.x,h.y,h.z);
134 v3_scale(&h,&basis[1],y);
135 printf(" %.5f %.5f %.5f\n",h.x,h.y,h.z);
136 v3_scale(&h,&basis[2],z);
137 printf(" %.5f %.5f %.5f\n",h.x,h.y,h.z);
139 printf(" %d\n",estimated);
140 printf("selective dynamics\n");
143 // now print the coordinates
149 // first atom (all types)
154 strcpy(fixstr,"T T T");
155 if(((r.x==0)||(r.y==0)||(r.z==0))&foa)
156 strcpy(fixstr,"F F F");
157 printf(" %.5f %.5f %.5f %s\n",r.x/x,r.y/y,r.z/z,fixstr);
160 // second atom (type 1)
162 v3_add(&h,&r,&(o[0]));
163 strcpy(fixstr,"T T T");
164 if(((h.x==0)||(h.y==0)||(h.z==0))&foa)
165 strcpy(fixstr,"F F F");
166 printf(" %.5f %.5f %.5f T T T\n",h.x/x,h.y/y,h.z/z);
170 // face centered atoms (type 2)
173 v3_add(&h,&r,&(o[l]));
174 strcpy(fixstr,"T T T");
175 if(((h.x==0)||(h.y==0)||(h.z==0))&foa)
176 strcpy(fixstr,"F F F");
177 printf(" %.5f %.5f %.5f T T T\n",h.x/x,h.y/y,h.z/z);
186 // second fcc lattice
193 // first atom (all types)
201 strcpy(fixstr,"T T T");
202 if(((r.x==0)||(r.y==0)||(r.z==0))&foa)
203 strcpy(fixstr,"F F F");
204 printf(" %.5f %.5f %.5f T T T\n",r.x/x,r.y/y,r.z/z);
207 // second atom (type 1)
209 v3_add(&h,&r,&(o[0]));
210 strcpy(fixstr,"T T T");
211 if(((h.x==0)||(h.y==0)||(h.z==0))&foa)
212 strcpy(fixstr,"F F F");
213 printf(" %.5f %.5f %.5f T T T\n",h.x/x,h.y/y,h.z/z);
217 // face centered atoms (type 2)
220 v3_add(&h,&r,&(o[l]));
221 strcpy(fixstr,"T T T");
222 if(((h.x==0)||(h.y==0)||(h.z==0))&foa)
223 strcpy(fixstr,"F F F");
224 printf(" %.5f %.5f %.5f T T T\n",h.x/x,h.y/y,h.z/z);
238 printf("\nWARNING! counted %d ions and estimated %d ions\n\n",