From c40d54eb3e319b17b2f6174c4eddcfd6ee3a407b Mon Sep 17 00:00:00 2001 From: hackbard Date: Tue, 9 Oct 2007 15:15:41 +0200 Subject: [PATCH] incorporated visual functions to moldyn api --- Makefile | 2 +- moldyn.c | 143 +++++++++++++++++++++++++++++++++++- moldyn.h | 14 +++- posic.h | 4 +- sic.c | 38 +++++++--- visual/Makefile | 7 -- visual/visual.c | 188 ------------------------------------------------ visual/visual.h | 31 -------- 8 files changed, 185 insertions(+), 242 deletions(-) delete mode 100644 visual/Makefile delete mode 100644 visual/visual.c delete mode 100644 visual/visual.h diff --git a/Makefile b/Makefile index bba7d4e..70f4a5d 100644 --- 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 diff --git a/moldyn.c b/moldyn.c index 41e022a..3c4d873 100644 --- a/moldyn.c +++ b/moldyn.c @@ -20,6 +20,58 @@ #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 #include "moldyn.h" -#include "posic.h" /* potential */ #include "potentials/harmonic_oscillator.h" @@ -37,11 +36,11 @@ #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;jrandom))-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 index b9e1956..0000000 --- a/visual/Makefile +++ /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 index 73b4941..0000000 --- a/visual/visual.c +++ /dev/null @@ -1,188 +0,0 @@ -/* - * visual.c - visualization functions - * - * author: Frank Zirkelbach - * - */ - -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include - -#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 - * - */ - -#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 - - -- 2.39.2