]> hackdaworld.org Git - physik/posic.git/blob - vasp_tools/create_lattice.c
5f6cb8d1582b8157f2a0ce9e2dd749afd3af5b1d
[physik/posic.git] / vasp_tools / create_lattice.c
1 /*
2  * create lattice (for usage in vasp POSCAR file)
3  *
4  * author: Frank Zirkelbach <frank.zirkelbach@physik.uni-augsburg.de>
5  *
6  */
7
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <math.h>
12 #include "../math/math.h"
13
14 #define FCC             0x01
15 #define DIAMOND         0x02
16 #define ZINCBLENDE      0x03
17
18 int main(int argc,char **argv) {
19
20         int i,j,k,l,cnt;
21         t_3dvec basis[3];
22         t_3dvec offset;
23         t_3dvec r,n;
24         char type;
25         double zrot;
26
27         if(argc<5) {
28                 printf("usage: %s type lx ly lz\n",argv[0]);
29                 return -1;
30         }
31
32         type=argv[1][0];
33         type=DIAMOND;
34
35         zrot=0.0;
36         if(argc==6)
37                 zrot=atof(argv[5]);
38
39         offset.x=0.25;
40         offset.y=0.25;
41         offset.z=0.25;
42
43         memset(basis,0,3*sizeof(t_3dvec));
44         basis[0].x=0.5;
45         basis[0].y=0.5;
46         basis[1].x=0.5;
47         basis[1].z=0.5;
48         basis[2].y=0.5;
49         basis[2].z=0.5;
50
51         cnt=0;
52         r.x=0.0;
53         for(i=0;i<atoi(argv[2]);i++) {
54                 r.y=0.0;
55                 for(j=0;j<atoi(argv[3]);j++) {
56                         r.z=0.0;
57                         for(k=0;k<atoi(argv[4]);k++) {
58
59         // first atom
60         printf(" %.2f %.2f %.2f T T T\n",r.x,r.y,r.z);
61         cnt+=1;
62         // face centered atoms
63         for(l=0;l<3;l++) {
64                 v3_add(&n,&r,&(basis[l]));
65                 printf(" %.2f %.2f %.2f T T T\n",n.x,n.y,n.z);
66                 cnt+=1;
67         }
68
69                                 r.z+=1.0;
70                         }
71                         r.y+=1.0;
72                 }
73                 r.x+=1.0;
74         }
75
76         // second fcc lattice
77         if(type==DIAMOND) {
78
79         r.x=0.0;
80         for(i=0;i<atoi(argv[2]);i++) {
81                 r.y=0.0;
82                 for(j=0;j<atoi(argv[3]);j++) {
83                         r.z=0.0;
84                         for(k=0;k<atoi(argv[4]);k++) {
85
86         // first atom
87         printf(" %.2f %.2f %.2f T T T\n",r.x+0.25,r.y+0.25,r.z+0.25);
88         cnt+=1;
89         // face centered atoms
90         for(l=0;l<3;l++) {
91                 v3_add(&n,&r,&(basis[l]));
92                 printf(" %.2f %.2f %.2f T T T\n",n.x+0.25,n.y+0.25,n.z+0.25);
93                 cnt+=1;
94         }
95
96                                 r.z+=1.0;
97                         }
98                         r.y+=1.0;
99                 }
100                 r.x+=1.0;
101         }
102
103         }
104
105
106         printf("\ntotal: %d ions\n\n",cnt);
107
108         return 0;
109
110 }
111