]> hackdaworld.org Git - physik/posic.git/commitdiff
incorporated visual functions to moldyn api
authorhackbard <hackbard@sage.physik.uni-augsburg.de>
Tue, 9 Oct 2007 13:15:41 +0000 (15:15 +0200)
committerhackbard <hackbard@sage.physik.uni-augsburg.de>
Tue, 9 Oct 2007 13:15:41 +0000 (15:15 +0200)
Makefile
moldyn.c
moldyn.h
posic.h
sic.c
visual/Makefile [deleted file]
visual/visual.c [deleted file]
visual/visual.h [deleted file]

index bba7d4e9c2109b4043487d292f3a8301364f52d8..70f4a5d16798107d33343f80e6f74a61d8bc610c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,7 @@ CFLAGS += -DALBE
 
 LDFLAGS=-lm
 
-DEPS = moldyn.o visual/visual.o random/random.o list/list.o
+DEPS = moldyn.o random/random.o list/list.o
 DEPS += potentials/lennard_jones.o potentials/harmonic_oscillator.o
 DEPS += potentials/tersoff.o potentials/albe.o
 
index 41e022a7dfebb561d06bd6c1f64955d10cbf2112..3c4d87399dcaceffb42f6d91ffe97a58bd8e841f 100644 (file)
--- a/moldyn.c
+++ b/moldyn.c
 #include "moldyn.h"
 #include "report/report.h"
 
+/*
+ * 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",
+};
+
+/*
+ * the moldyn functions
+ */
+
 int moldyn_init(t_moldyn *moldyn,int argc,char **argv) {
 
        printf("[moldyn] init\n");
@@ -427,7 +479,6 @@ int moldyn_log_shutdown(t_moldyn *moldyn) {
                         moldyn->vlsdir);
                system(sc);
        }
-       if(&(moldyn->vis)) visual_tini(&(moldyn->vis));
 
        return 0;
 }
@@ -2004,6 +2055,96 @@ int analyze_bonds(t_moldyn *moldyn) {
        
        
 
+       return 0;
+}
+
+/*
+ * visualization code
+ */
+
+int visual_init(t_visual *v,char *filebase) {
+
+       char file[128+8];
+
+       strncpy(v->fb,filebase,128);
+       memset(file,0,128+8);
+
+       return 0;
+}
+
+int visual_atoms(t_visual *v,double time,t_atom *atom,int n) {
+
+       int i,fd;
+       char file[128+64];
+       t_3dvec dim;
+       double help;
+
+       dim.x=v->dim.x;
+       dim.y=v->dim.y;
+       dim.z=v->dim.z;
+
+       help=(dim.x+dim.y);
+
+       sprintf(file,"%s/atomic_conf_%07.f.xyz",v->fb,time);
+       fd=open(file,O_WRONLY|O_CREAT|O_TRUNC,S_IRUSR|S_IWUSR);
+       if(fd<0) {
+               perror("open visual save file fd");
+               return -1;
+       }
+
+       /* write the actual data file */
+       dprintf(fd,"# [P] %d %07.f <%f,%f,%f>\n",
+               n,time,help/40.0,help/40.0,-0.8*help);
+       for(i=0;i<n;i++)
+               dprintf(fd,"%s %f %f %f %s %f\n",pse_name[atom[i].element],
+                                                atom[i].r.x,
+                                                atom[i].r.y,
+                                                atom[i].r.z,
+                                                pse_col[atom[i].element],
+                                                atom[i].ekin);
+       if(dim.x) {
+               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
+                       -dim.x/2,-dim.y/2,-dim.z/2,
+                       dim.x/2,-dim.y/2,-dim.z/2);
+               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
+                       -dim.x/2,-dim.y/2,-dim.z/2,
+                       -dim.x/2,dim.y/2,-dim.z/2);
+               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
+                       dim.x/2,dim.y/2,-dim.z/2,
+                       dim.x/2,-dim.y/2,-dim.z/2);
+               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
+                       -dim.x/2,dim.y/2,-dim.z/2,
+                       dim.x/2,dim.y/2,-dim.z/2);
+
+               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
+                       -dim.x/2,-dim.y/2,dim.z/2,
+                       dim.x/2,-dim.y/2,dim.z/2);
+               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
+                       -dim.x/2,-dim.y/2,dim.z/2,
+                       -dim.x/2,dim.y/2,dim.z/2);
+               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
+                       dim.x/2,dim.y/2,dim.z/2,
+                       dim.x/2,-dim.y/2,dim.z/2);
+               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
+                       -dim.x/2,dim.y/2,dim.z/2,
+                       dim.x/2,dim.y/2,dim.z/2);
+
+               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
+                       -dim.x/2,-dim.y/2,dim.z/2,
+                       -dim.x/2,-dim.y/2,-dim.z/2);
+               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
+                       -dim.x/2,dim.y/2,dim.z/2,
+                       -dim.x/2,dim.y/2,-dim.z/2);
+               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
+                       dim.x/2,-dim.y/2,dim.z/2,
+                       dim.x/2,-dim.y/2,-dim.z/2);
+               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
+                       dim.x/2,dim.y/2,dim.z/2,
+                       dim.x/2,dim.y/2,-dim.z/2);
+       }
+
+       close(fd);
+
        return 0;
 }
 
index 0078990599926a33780af3a34c85643760556316..83414dd09fc045b99f07bca932c5c855a0d6d96b 100644 (file)
--- a/moldyn.h
+++ b/moldyn.h
@@ -64,8 +64,6 @@ typedef struct s_linkcell {
        int dnlc;               /* direct neighbour lists counter */
 } t_linkcell;
 
-#include "visual/visual.h"
-
 /* moldyn schedule structure */
 typedef struct s_moldyn_schedule {
        int count;
@@ -76,6 +74,13 @@ typedef struct s_moldyn_schedule {
        void *hook_params;
 } t_moldyn_schedule;
 
+/* visualization structure */
+typedef struct s_visual {
+       int fd;                 /* rasmol script file descriptor */
+       char fb[128];           /* basename of the save files */
+       t_3dvec dim;            /* dimensions of the simulation cell */
+} t_visual;
+
 /* moldyn main structure */
 typedef struct s_moldyn {
        int argc;               /* number of arguments */
@@ -375,7 +380,6 @@ typedef struct s_moldyn {
 #define FCC                    0x02
 #define DIAMOND                        0x04
 
-
 /*
  *
  * function prototypes
@@ -469,4 +473,8 @@ int moldyn_bc_check(t_moldyn *moldyn);
 
 int get_line(int fd,char *line,int max);
 
+int visual_init(t_visual *v,char *filebase);
+int visual_atoms(t_visual *v,double time,t_atom *atom,int n);
+
 #endif
+
diff --git a/posic.h b/posic.h
index 18d14d91e90ede46a9a793903c2280dbdaaa7e53..6374e0fe9a8510c6b13f035c18eb6d88b2535c47 100644 (file)
--- a/posic.h
+++ b/posic.h
 // swapped out functions
 #include "math/math.h"
 #include "list/list.h"
-#include "visual/visual.h"
 #include "random/random.h"
 
+// moldyn core functions
+#include "moldyn.h"
+
 // potentials
 #include "potentials/harmonic_oscillator.h"
 #include "potentials/lennard_jones.h"
diff --git a/sic.c b/sic.c
index 7855cc2e38eb81ab935c2bbd38c1746b10e2e52a..6e6369fbe7f79f222bb810275a1cb13660096cb9 100644 (file)
--- a/sic.c
+++ b/sic.c
@@ -8,7 +8,6 @@
 #include <math.h>
  
 #include "moldyn.h"
-#include "posic.h"
 
 /* potential */
 #include "potentials/harmonic_oscillator.h"
 #define INJ_OFFSET     (ALBE_LC_SI/8.0)
 #define RELAX_S                20
 
-#define LCNTX          5
-#define LCNTY          5
-#define LCNTZ          5
+#define LCNTX          9
+#define LCNTY          9
+#define LCNTZ          9
 #define PRERUN         10
-#define POSTRUN                2000
+#define POSTRUN                4000
 
 #define R_TITLE                "Silicon self-interstitial"
 #define LOG_E          10
@@ -57,7 +56,21 @@ typedef struct s_hp {
        char **argv;    /* args */
 } t_hp;
 
-int hook(void *moldyn,void *hook_params) {
+int hook_del_atom(void *moldyn,void *hook_params) {
+
+       t_moldyn *md;
+       t_hp *hp;
+
+       md=moldyn;
+       hp=hook_params;
+
+       set_pt_scale(md,0,0,T_SCALE_BERENDSEN,100.0);
+       del_atom(md,2);
+
+       return 0;
+}
+
+int hook_add_atom(void *moldyn,void *hook_params) {
 
        t_moldyn *md;
        t_3dvec r,v,dist;
@@ -97,11 +110,14 @@ int hook(void *moldyn,void *hook_params) {
        for(j=0;j<NR_ATOMS;j++) {
                run=1;
                while(run) {
-                       r.x=(rand_get_double(&(md->random))-0.5)*INJ_LENX;
+                       r.x=1.0/8.0*ALBE_LC_SI;
+                       r.y=-1.0/8.0*ALBE_LC_SI;
+                       r.z=-1.0/8.0*ALBE_LC_SI;
+                       //r.x=(rand_get_double(&(md->random))-0.5)*INJ_LENX;
                        r.x+=INJ_OFFSET;
-                       r.y=(rand_get_double(&(md->random))-0.5)*INJ_LENY;
+                       //r.y=(rand_get_double(&(md->random))-0.5)*INJ_LENY;
                        r.y+=INJ_OFFSET;
-                       r.z=(rand_get_double(&(md->random))-0.5)*INJ_LENZ;
+                       //r.z=(rand_get_double(&(md->random))-0.5)*INJ_LENZ;
                        r.z+=INJ_OFFSET;
                        /* assume valid coordinates */
                        run=0;
@@ -375,7 +391,9 @@ int main(int argc,char **argv) {
        memset(&hookparam,0,sizeof(t_hp));
        hookparam.argc=argc;
        hookparam.argv=argv;
-       moldyn_set_schedule_hook(&md,&hook,&hookparam);
+       moldyn_set_schedule_hook(&md,&hook_add_atom,&hookparam);
+       //moldyn_set_schedule_hook(&md,&hook_del_atom,&hookparam);
+       //moldyn_add_schedule(&md,POSTRUN,1.0);
 
        /* activate logging */
        moldyn_set_log_dir(&md,argv[1]);
diff --git a/visual/Makefile b/visual/Makefile
deleted file mode 100644 (file)
index b9e1956..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-CC=gcc
-CFLAGS=-Wall
-
-all: visual.o ../math/math.o
-
-clean:
-       rm -f *.o 
diff --git a/visual/visual.c b/visual/visual.c
deleted file mode 100644 (file)
index 73b4941..0000000
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * visual.c - visualization functions
- *
- * author: Frank Zirkelbach <frank.zirkelbach@physik.uni-augsburg.de>
- *
- */
-
-#define _GNU_SOURCE
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <string.h>
-
-#include "visual.h"
-#include "../moldyn.h"
-#include "../math/math.h"
-
-/* the pse, 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",
-};
-
-int visual_init(t_visual *v,char *filebase) {
-
-       char file[128+8];
-
-       strncpy(v->fb,filebase,128);
-       memset(file,0,128+8);
-       //sprintf(file,"%s/visualize.scr",v->fb); // obsolete!
-
-       /* obsolete!
-       v->fd=open(file,O_WRONLY|O_CREAT|O_EXCL,S_IRUSR|S_IWUSR);
-       if(v->fd<0) {
-               perror("open visual fd");
-               return -1;
-       }
-       dprintf(v->fd,"set write on\n");
-       */
-
-       return 0;
-}
-
-int visual_tini(t_visual *v) {
-
-       /* obsolete!
-       if(v->fd) {
-               dprintf(v->fd,"quit\n");
-               close(v->fd);
-       }
-       */
-
-       return 0;
-}
-
-int visual_atoms(t_visual *v,double time,t_atom *atom,int n) {
-
-       int i,fd;
-       char file[128+64];
-       t_3dvec dim;
-       double help;
-
-       dim.x=v->dim.x;
-       dim.y=v->dim.y;
-       dim.z=v->dim.z;
-
-       help=(dim.x+dim.y);
-
-       sprintf(file,"%s/atomic_conf_%07.f.xyz",v->fb,time);
-       fd=open(file,O_WRONLY|O_CREAT|O_TRUNC,S_IRUSR|S_IWUSR);
-       if(fd<0) {
-               perror("open visual save file fd");
-               return -1;
-       }
-
-       /* script file update */
-       /* obsolete!
-       dprintf(v->fd,"load xyz %s\n",file);
-       dprintf(v->fd,"spacefill 200\n");
-       dprintf(v->fd,"rotate x 100\n");
-       dprintf(v->fd,"rotate y 10\n");
-       dprintf(v->fd,"set ambient 20\n");
-       dprintf(v->fd,"set specular on\n");
-       dprintf(v->fd,"set boundbox on\n");
-       //dprintf(v->fd,"label\n");
-       sprintf(file,"%s/visualize_%07.f.ppm",v->fb,time);
-       dprintf(v->fd,"write ppm %s\n",file);
-       dprintf(v->fd,"zap\n");
-       */
-
-       /* write the actual data file */
-       //dprintf(fd,"%d\n",(dim.x==0)?n:n+8);
-       dprintf(fd,"# [P] %d %07.f <%f,%f,%f>\n",
-               n,time,help/40.0,help/40.0,-0.8*help);
-       for(i=0;i<n;i++)
-               dprintf(fd,"%s %f %f %f %s %f\n",pse_name[atom[i].element],
-                                                atom[i].r.x,
-                                                atom[i].r.y,
-                                                atom[i].r.z,
-                                                pse_col[atom[i].element],
-                                                atom[i].ekin);
-       if(dim.x) {
-               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
-                       -dim.x/2,-dim.y/2,-dim.z/2,
-                       dim.x/2,-dim.y/2,-dim.z/2);
-               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
-                       -dim.x/2,-dim.y/2,-dim.z/2,
-                       -dim.x/2,dim.y/2,-dim.z/2);
-               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
-                       dim.x/2,dim.y/2,-dim.z/2,
-                       dim.x/2,-dim.y/2,-dim.z/2);
-               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
-                       -dim.x/2,dim.y/2,-dim.z/2,
-                       dim.x/2,dim.y/2,-dim.z/2);
-
-               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
-                       -dim.x/2,-dim.y/2,dim.z/2,
-                       dim.x/2,-dim.y/2,dim.z/2);
-               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
-                       -dim.x/2,-dim.y/2,dim.z/2,
-                       -dim.x/2,dim.y/2,dim.z/2);
-               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
-                       dim.x/2,dim.y/2,dim.z/2,
-                       dim.x/2,-dim.y/2,dim.z/2);
-               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
-                       -dim.x/2,dim.y/2,dim.z/2,
-                       dim.x/2,dim.y/2,dim.z/2);
-
-               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
-                       -dim.x/2,-dim.y/2,dim.z/2,
-                       -dim.x/2,-dim.y/2,-dim.z/2);
-               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
-                       -dim.x/2,dim.y/2,dim.z/2,
-                       -dim.x/2,dim.y/2,-dim.z/2);
-               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
-                       dim.x/2,-dim.y/2,dim.z/2,
-                       dim.x/2,-dim.y/2,-dim.z/2);
-               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
-                       dim.x/2,dim.y/2,dim.z/2,
-                       dim.x/2,dim.y/2,-dim.z/2);
-       }
-
-       close(fd);
-
-       return 0;
-}
-
diff --git a/visual/visual.h b/visual/visual.h
deleted file mode 100644 (file)
index 416f82b..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * visual.h - visualization header file
- *                                  
- * author: Frank Zirkelbach <frank.zirkelbach@physik.uni-augsburg.de>
- *
- */
-
-#ifndef VISUAL_H
-#define VISUAL_H
-
-#include "../math/math.h"
-
-/* datatypes */
-
-typedef struct s_visual {
-       int fd;                 /* rasmol script file descriptor */
-       char fb[128];           /* basename of the save files */
-       t_3dvec dim;            /* dimensions of the simulation cell */
-} t_visual;
-
-#include "../moldyn.h"
-
-/* function prototypes */
-
-int visual_init(t_visual *v,char *filebase);
-int visual_tini(t_visual *v);
-int visual_atoms(t_visual *v,double time,t_atom *atom,int n);
-
-#endif
-
-