From 4f7a62883e5e47be44856c9767c9255c1d68190d Mon Sep 17 00:00:00 2001 From: hackbard Date: Mon, 5 May 2008 08:53:26 +0200 Subject: [PATCH] tool to search for bonds --- Makefile | 4 +- search_bonds.c | 127 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 search_bonds.c diff --git a/Makefile b/Makefile index fbe3f59..62a137e 100644 --- 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 index 0000000..d3c1199 --- /dev/null +++ b/search_bonds.c @@ -0,0 +1,127 @@ +/* + * code searching for special types of bonds + * + * author: frank.zirkelbach@physik.uni-augsburg.de + * + */ + +#define _GNU_SOURCE +#include +//#include +//#include +//#include +//#include +//#include +//#include + +#include "moldyn.h" +#include "potentials/albe.h" + +int usage(char *prog) { + + printf("\nusage:\n"); + printf(" %s <+->\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;ir.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(jtombrand!=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; +} -- 2.39.2