]> hackdaworld.org Git - physik/posic.git/commitdiff
tool to search for bonds
authorhackbard <hackbard@sage.physik.uni-augsburg.de>
Mon, 5 May 2008 06:53:26 +0000 (08:53 +0200)
committerhackbard <hackbard@sage.physik.uni-augsburg.de>
Mon, 5 May 2008 06:53:26 +0000 (08:53 +0200)
Makefile
search_bonds.c [new file with mode: 0644]

index fbe3f593332468b0732fcb891e77ea6c18382737..62a137e22b1410fb8a33ff173519842112af99d1 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,7 @@ DEPS += potentials/lennard_jones.o potentials/harmonic_oscillator.o
 DEPS += potentials/tersoff.o potentials/albe.o
 
 ALL = mdrun sic fluctuation_calc postproc pair_correlation_calc diffusion_calc
-ALL += bond_analyze
+ALL += bond_analyze search_bonds
 
 all: $(ALL)
 
@@ -39,6 +39,8 @@ diffusion_calc: $(DEPS)
 
 bond_analyze: $(DEPS)
 
+search_bonds: $(DEPS)
+
 .PHONY:clean
 clean:
        rm -vf $(ALL) *.o */*.o
diff --git a/search_bonds.c b/search_bonds.c
new file mode 100644 (file)
index 0000000..d3c1199
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * 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;
+}