]> hackdaworld.org Git - physik/posic.git/blob - search_bonds.c
added interval for anneal stage
[physik/posic.git] / search_bonds.c
1 /*
2  * code searching for special types of bonds
3  *
4  * author: frank.zirkelbach@physik.uni-augsburg.de
5  *
6  */
7
8 #define _GNU_SOURCE
9 #include <stdio.h>
10 //#include <stdlib.h>
11 //#include <unistd.h>
12 //#include <string.h>
13 //#include <sys/types.h>
14 //#include <sys/stat.h>
15 //#include <fcntl.h>
16
17 #include "moldyn.h"
18 #include "potentials/albe.h"
19
20 typedef struct s_data {
21         double pm,len;
22         u8 type;
23 } t_data;
24
25 int usage(char *prog) {
26
27         printf("\nusage:\n");
28         printf("  %s <file> <type> <bondlen> <+->\n",prog);
29         printf("    type: a - 0-0 bond\n");
30         printf("    type: b - 1-1 bond\n");
31         printf("    type: c - 0-1 / 1-0  bond\n\n");
32
33         return -1;
34 }
35
36 int process(t_moldyn *moldyn,t_atom *ai,t_atom *aj,void *ptr,u8 bc) {
37
38         t_3dvec dist;
39         double d;
40         t_data *data;
41
42         data=ptr;
43
44         if(aj<ai)
45                 return 0;
46
47         switch(data->type) {
48                 case 'a':
49                         if(ai->brand!=0)
50                                 return 0;
51                         if(aj->brand!=0)
52                                 return 0;
53                                 
54                         break;
55                 case 'b':
56                         if(ai->brand!=1)
57                                 return 0;
58                         if(aj->brand!=1)
59                                 return 0;
60                         break;
61                 default:
62                         if(ai->brand==aj->brand)
63                                 return 0;
64                         break;
65         }
66
67         v3_sub(&dist,&(ai->r),&(aj->r));
68         check_per_bound(moldyn,&dist);
69         d=v3_norm(&dist);
70
71         if((d<=data->len+data->pm)&(d>=data->len-data->pm))
72                 printf(" # atoms %d/%d %d/%d - %f\n",
73                        ai->tag,ai->brand,
74                        aj->tag,aj->brand,d);
75
76         return 0;
77 }
78
79 int main(int argc,char **argv) {
80
81         t_moldyn moldyn;
82         int ret;
83         t_data data;
84
85         if(argc!=5) {
86                 usage(argv[0]);
87                 return -1;
88         }
89
90         data.type=argv[2][0];
91         data.len=atof(argv[3]);
92         data.pm=atof(argv[4]);
93
94         memset(&moldyn,0,sizeof(t_moldyn));
95
96         printf("[search bonds] reading save file ...\n");
97         ret=moldyn_read_save_file(&moldyn,argv[1]);
98         if(ret) {
99                 printf("[search bonds] exit!\n");
100                 return ret;
101         }
102
103         /* link cell init */
104         moldyn.cutoff=data.len+data.pm;
105         link_cell_init(&moldyn,VERBOSE);
106
107         process_2b_bonds(&moldyn,&data,process);
108
109         /* analyzing ... */
110         link_cell_shutdown(&moldyn);
111
112         moldyn_free_save_file(&moldyn);
113
114         return 0;
115 }