--- /dev/null
+/*
+ * code searching for special types of bonds
+ *
+ * author: frank.zirkelbach@physik.uni-augsburg.de
+ *
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+//#include <stdlib.h>
+//#include <unistd.h>
+//#include <string.h>
+//#include <sys/types.h>
+//#include <sys/stat.h>
+//#include <fcntl.h>
+
+#include "moldyn.h"
+#include "potentials/albe.h"
+
+int usage(char *prog) {
+
+ printf("\nusage:\n");
+ printf(" %s <file> <type> <bondlen> <+->\n",prog);
+ printf(" type: a - 0-0 bond\n");
+ printf(" type: b - 1-1 bond\n");
+ printf(" type: c - 0-1 / 1-0 bond\n\n");
+
+ return -1;
+}
+
+int main(int argc,char **argv) {
+
+ t_moldyn moldyn;
+ t_atom *itom,*jtom;
+ int i,j;
+ int ret;
+ t_list n[27];
+ t_list *this;
+ t_linkcell *lc;
+ t_3dvec dist;
+ double d,bondlen,bondpm;
+
+ if(argc!=5) {
+ usage(argv[0]);
+ return -1;
+ }
+
+ bondlen=atof(argv[3]);
+ bondpm=atof(argv[4]);
+
+ memset(&moldyn,0,sizeof(t_moldyn));
+
+ printf("[search bonds] reading save file ...\n");
+ ret=moldyn_read_save_file(&moldyn,argv[1]);
+ if(ret) {
+ printf("[search bonds] exit!\n");
+ return ret;
+ }
+
+ /* link cell init */
+ moldyn.cutoff=bondlen+bondpm;
+ link_cell_init(&moldyn,VERBOSE);
+ lc=&(moldyn.lc);
+
+ /* analyzing ... */
+ for(i=0;i<moldyn.count;i++) {
+ itom=&(moldyn.atom[i]);
+ link_cell_neighbour_index(&moldyn,
+ (itom->r.x+moldyn.dim.x/2)/lc->x,
+ (itom->r.y+moldyn.dim.y/2)/lc->y,
+ (itom->r.z+moldyn.dim.z/2)/lc->z,
+ n);
+ for(j=0;j<27;j++) {
+ this=&(n[j]);
+ list_reset_f(this);
+
+ if(this->start==NULL)
+ continue;
+
+ do {
+
+ jtom=this->current->data;
+
+ if(jtom<itom)
+ continue;
+
+ switch(argv[2][0]) {
+ case 'a':
+ if(itom->brand!=0)
+ continue;
+ if(jtom->brand!=0)
+ continue;
+ break;
+ case 'b':
+ if(itom->brand!=1)
+ continue;
+ if(jtom->brand!=1)
+ continue;
+ break;
+ default:
+ if(itom->brand==jtom->brand)
+ continue;
+ break;
+ }
+
+ v3_sub(&dist,&(itom->r),&(jtom->r));
+ check_per_bound(&moldyn,&dist);
+ d=v3_norm(&dist);
+
+ if((d<=bondlen+bondpm)&(d>=bondlen-bondpm)) {
+
+ printf(" # atoms %d/%d %d/%d - %f\n",
+ itom->tag,itom->brand,
+ jtom->tag,jtom->brand,d);
+
+ }
+
+ } while(list_next_f(this)!=L_NO_NEXT_ELEMENT);
+ }
+ }
+
+ link_cell_shutdown(&moldyn);
+
+ moldyn_free_save_file(&moldyn);
+
+ return 0;
+}