added display atom data tool
[physik/posic.git] / display_atom_data.c
diff --git a/display_atom_data.c b/display_atom_data.c
new file mode 100644 (file)
index 0000000..0872366
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * code to display atom data
+ *
+ * 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 <save file> <nr1> <nr2> ... \n\n",prog);
+
+       return -1;
+}
+
+int main(int argc,char **argv) {
+
+       t_moldyn moldyn;
+       int ret;
+       int i;
+       int nr;
+       t_atom *atom;
+       double off;
+       double lc;
+
+       if(argc<2) {
+               usage(argv[0]);
+               return -1;
+       }
+
+       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;
+       }
+
+       /* todo: guessing offset/lc */
+       lc=ALBE_LC_SI;
+       off=0.125*lc-0.5*lc;
+
+       for(i=2;i<argc;i++) {
+
+               nr=atoi(argv[i]);
+               atom=&(moldyn.atom[nr]);
+               printf("\n## atom %d ##\n",nr);
+               printf("    r        r0         r-o      ");
+               printf("r0-o       dr         r-o [lc]\n");
+               printf("    -----------------------------");
+               printf("------------------------------\n");
+               printf(" x: %f %f | %f %f | %f | %f\n",
+                      atom->r.x,atom->r_0.x,atom->r.x-off,atom->r_0.x-off,
+                      atom->r.x-atom->r_0.x,(atom->r.x-off)/lc);
+               printf(" y: %f %f | %f %f | %f | %f\n",
+                      atom->r.y,atom->r_0.y,atom->r.y-off,atom->r_0.y-off,
+                      atom->r.y-atom->r_0.y,(atom->r.y-off)/lc);
+               printf(" z: %f %f | %f %f | %f | %f\n",
+                      atom->r.z,atom->r_0.z,atom->r.z-off,atom->r_0.z-off,
+                      atom->r.z-atom->r_0.z,(atom->r.z-off)/lc);
+               
+       }
+       
+       moldyn_free_save_file(&moldyn);
+
+       return 0;
+}