]> hackdaworld.org Git - physik/posic.git/commitdiff
search bonds using infrastructure now, new visual atoms tool
authorhackbard <hackbard@sage.physik.uni-augsburg.de>
Mon, 5 May 2008 08:07:01 +0000 (10:07 +0200)
committerhackbard <hackbard@sage.physik.uni-augsburg.de>
Mon, 5 May 2008 08:07:01 +0000 (10:07 +0200)
Makefile
mdrun.h
moldyn.c
moldyn.h
pse.h
search_bonds.c
visual_atoms.c [new file with mode: 0644]

index 62a137e22b1410fb8a33ff173519842112af99d1..36c411ef907eece86406a2b9bf0754ff7b26619a 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 search_bonds
+ALL += bond_analyze search_bonds visual_atoms
 
 all: $(ALL)
 
@@ -41,6 +41,8 @@ bond_analyze: $(DEPS)
 
 search_bonds: $(DEPS)
 
+visual_atoms: $(DEPS)
+
 .PHONY:clean
 clean:
        rm -vf $(ALL) *.o */*.o
diff --git a/mdrun.h b/mdrun.h
index fa169067643a6ca2b61926694545678f78838384..ad5c0c2405144d7d8a69f3c44c204338e6a5dc90 100644 (file)
--- a/mdrun.h
+++ b/mdrun.h
@@ -18,9 +18,6 @@
 /* main molecular dynamics api */
 #include "moldyn.h"
 
-/* elements */
-#include "pse.h"
-
 /* list api */
 #include "list/list.h"
 
index 82ae543c073457a47372253f6c238f76d1bfe6b5..4330396652b99ca6ee4f935935d1ecfcabd48541 100644 (file)
--- a/moldyn.c
+++ b/moldyn.c
 #include "potentials/tersoff.h"
 #endif
 
-
-/*
- * global variables, pse and atom colors (only needed here)
- */ 
-
-static char *pse_name[]={
-       "*",
-       "H",
-       "He",
-       "Li",
-       "Be",
-       "B",
-       "C",
-       "N",
-       "O",
-       "F",
-       "Ne",
-       "Na",
-       "Mg",
-       "Al",
-       "Si",
-       "P",
-       "S",
-       "Cl",
-       "Ar",
-};
-
-static char *pse_col[]={
-       "*",
-       "White",
-       "He",
-       "Li",
-       "Be",
-       "B",
-       "Gray",
-       "N",
-       "Blue",
-       "F",
-       "Ne",
-       "Na",
-       "Mg",
-       "Al",
-       "Yellow",
-       "P",
-       "S",
-       "Cl",
-       "Ar",
-};
-
-/*
-static double pse_mass[]={
-       0,
-       0,
-       0,
-       0,
-       0,
-       0,
-       M_C,
-       0,
-       0,
-       0,
-       0,
-       0,
-       0,
-       0,
-       M_SI,
-       0,
-       0,
-       0,
-       0,
-};
-
-static double pse_lc[]={
-       0,
-       0,
-       0,
-       0,
-       0,
-       0,
-       LC_C,
-       0,
-       0,
-       0,
-       0,
-       0,
-       0,
-       0,
-       LC_SI,
-       0,
-       0,
-       0,
-       0,
-};
-*/
-
 /*
  * the moldyn functions
  */
index cd7c5d02b890b6fbe3374cce2de1ee05d3559e89..ca40103646abf12c1c3a0b2d6b806dd62a1bc9c3 100644 (file)
--- a/moldyn.h
+++ b/moldyn.h
@@ -353,6 +353,12 @@ typedef struct s_vb {
 #define DIAMOND                        0x04
 #define ZINCBLENDE             0x08
 
+/*
+ * more includes
+ */
+
+#include "pse.h"
+
 /*
  *
  * function prototypes
diff --git a/pse.h b/pse.h
index d9aff121f60ce5b1ab22eb73f1ef8c0340bb6cdb..3391d2676f548bac70a61d3e434ea038e5ea0d9a 100644 (file)
--- a/pse.h
+++ b/pse.h
@@ -51,3 +51,47 @@ static double pse_lc[]={
        0,
 };
 
+static char *pse_name[]={
+       "*",
+       "H",
+       "He",
+       "Li",
+       "Be",
+       "B",
+       "C",
+       "N",
+       "O",
+       "F",
+       "Ne",
+       "Na",
+       "Mg",
+       "Al",
+       "Si",
+       "P",
+       "S",
+       "Cl",
+       "Ar",
+};
+
+static char *pse_col[]={
+       "*",
+       "White",
+       "He",
+       "Li",
+       "Be",
+       "B",
+       "Gray",
+       "N",
+       "Blue",
+       "F",
+       "Ne",
+       "Na",
+       "Mg",
+       "Al",
+       "Yellow",
+       "P",
+       "S",
+       "Cl",
+       "Ar",
+};
+
index d3c11990f273b25466ba2334871586fccd435ea4..82911090c2b42341d252d3e6582fb649c582a587 100644 (file)
 #include "moldyn.h"
 #include "potentials/albe.h"
 
+typedef struct s_data {
+       double pm,len;
+       u8 type;
+} t_data;
+
 int usage(char *prog) {
 
        printf("\nusage:\n");
@@ -28,25 +33,63 @@ int usage(char *prog) {
        return -1;
 }
 
+int process(t_moldyn *moldyn,t_atom *ai,t_atom *aj,void *ptr,u8 bc) {
+
+       t_3dvec dist;
+       double d;
+       t_data *data;
+
+       data=ptr;
+
+       if(aj<ai)
+               return 0;
+
+       switch(data->type) {
+               case 'a':
+                       if(ai->brand!=0)
+                               return 0;
+                       if(aj->brand!=0)
+                               return 0;
+                               
+                       break;
+               case 'b':
+                       if(ai->brand!=1)
+                               return 0;
+                       if(aj->brand!=1)
+                               return 0;
+                       break;
+               default:
+                       if(ai->brand==aj->brand)
+                               return 0;
+                       break;
+       }
+
+       v3_sub(&dist,&(ai->r),&(aj->r));
+       check_per_bound(moldyn,&dist);
+       d=v3_norm(&dist);
+
+       if((d<=data->len+data->pm)&(d>=data->len-data->pm))
+               printf(" # atoms %d/%d %d/%d - %f\n",
+                      ai->tag,ai->brand,
+                      aj->tag,aj->brand,d);
+
+       return 0;
+}
+
 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;
+       t_data data;
 
        if(argc!=5) {
                usage(argv[0]);
                return -1;
        }
 
-       bondlen=atof(argv[3]);
-       bondpm=atof(argv[4]);
+       data.type=argv[2][0];
+       data.len=atof(argv[3]);
+       data.pm=atof(argv[4]);
 
        memset(&moldyn,0,sizeof(t_moldyn));
 
@@ -58,67 +101,12 @@ int main(int argc,char **argv) {
        }
 
        /* link cell init */
-       moldyn.cutoff=bondlen+bondpm;
+       moldyn.cutoff=data.len+data.pm;
        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);
-               }
-       }
+       process_2b_bonds(&moldyn,&data,process);
 
+       /* analyzing ... */
        link_cell_shutdown(&moldyn);
 
        moldyn_free_save_file(&moldyn);
diff --git a/visual_atoms.c b/visual_atoms.c
new file mode 100644 (file)
index 0000000..9baa487
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * code visualize atoms
+ *
+ * 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"
+
+int usage(char *prog) {
+
+       printf("\nusage:\n");
+       printf("  %s <file> <centre atom> <radius> [marked atom]\n\n",prog);
+
+       return -1;
+}
+
+int main(int argc,char **argv) {
+
+       t_moldyn moldyn;
+       t_atom *itom,*jtom;
+       int j;
+       int ret;
+       t_list n[27];
+       t_list *this;
+       t_linkcell *lc;
+       t_3dvec dist;
+       double d,radius;
+       int ma,ca;
+
+       if(argc<4) {
+               usage(argv[0]);
+               return -1;
+       }
+
+       ca=atoi(argv[2]);
+       radius=atof(argv[3]);
+
+       ma=-1;
+       if(argc==5)
+               ma=atoi(argv[4]);
+
+       memset(&moldyn,0,sizeof(t_moldyn));
+
+       printf("[visual atoms] reading save file ...\n");
+       ret=moldyn_read_save_file(&moldyn,argv[1]);
+       if(ret) {
+               printf("[visual atoms] exit!\n");
+               return ret;
+       }
+
+       /* link cell init */
+       moldyn.cutoff=radius;
+       link_cell_init(&moldyn,VERBOSE);
+       lc=&(moldyn.lc);
+
+       /* serach atoms */
+       itom=&(moldyn.atom[ca]);
+       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);
+
+       
+       printf("%s %f %f %f %s %f\n",
+              pse_name[itom->element],itom->r.x,itom->r.y,itom->r.z,
+              "Green",itom->ekin);
+
+       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;
+
+                       v3_sub(&dist,&(itom->r),&(jtom->r));
+                       check_per_bound(&moldyn,&dist);
+                       d=v3_norm(&dist);
+
+                       if(d<=radius) {
+                               printf("%s %f %f %f %s %f\n",
+                                      pse_name[jtom->element],
+                                      jtom->r.x,jtom->r.y,jtom->r.z,
+                                      (jtom->tag==ma)?"Red":pse_col[jtom->element],
+                                      jtom->ekin);
+                       }
+
+               } while(list_next_f(this)!=L_NO_NEXT_ELEMENT);
+       }
+
+       link_cell_shutdown(&moldyn);
+
+       moldyn_free_save_file(&moldyn);
+
+       return 0;
+}