From e1348f10aff2c0bb1040108181d13fcb48db5af2 Mon Sep 17 00:00:00 2001 From: hackbard Date: Mon, 23 Jul 2007 17:09:26 +0200 Subject: [PATCH] added postproc stuff, sic mods (today i was a lazy ass!) --- Makefile | 7 ++- moldyn.c | 5 +- moldyn.h | 3 + postproc.c | 166 +++++++++++++++++++++++++++++++++++++++++++++++++++++ sic.c | 19 ++++-- 5 files changed, 191 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 72904f5..ee6e927 100644 --- a/Makefile +++ b/Makefile @@ -16,11 +16,14 @@ POT_SRC=potentials/tersoff.c POT_SRC+=potentials/albe.c POT_SRC+= potentials/lennard_jones.c potentials/harmonic_oscillator.c -all: sic fluctuation_calc +all: sic fluctuation_calc postproc sic: $(CC) $(CFLAGS) $(LDFLAGS) $(POT_SRC) $(SOURCE) sic.c -o sic +postproc: + $(CC) $(CFLAGS) $(LDFLAGS) $(POT_SRC) $(SOURCE) postproc.c -o postproc + .PHONY:clean clean: - rm -f sic + rm -f sic postproc diff --git a/moldyn.c b/moldyn.c index 7d27965..a310e91 100644 --- a/moldyn.c +++ b/moldyn.c @@ -24,6 +24,9 @@ int moldyn_init(t_moldyn *moldyn,int argc,char **argv) { memset(moldyn,0,sizeof(t_moldyn)); + moldyn->argc=argc; + moldyn->args=argv; + rand_init(&(moldyn->random),NULL,1); moldyn->random.status|=RAND_STAT_VERBOSE; @@ -1483,7 +1486,7 @@ return 0; printf("\rsched:%d, steps:%d, T:%3.1f/%3.1f P:%4.1f/%4.1f V:%6.1f", sched->count,i, moldyn->t,moldyn->t_avg, - moldyn->p_avg/BAR,moldyn->p/BAR, + moldyn->p_avg/BAR,moldyn->gp_avg/BAR, moldyn->volume); fflush(stdout); } diff --git a/moldyn.h b/moldyn.h index a595585..9f9d0f7 100644 --- a/moldyn.h +++ b/moldyn.h @@ -78,6 +78,9 @@ typedef struct s_moldyn_schedule { /* moldyn main structure */ typedef struct s_moldyn { + int argc; /* number of arguments */ + char **args; /* pointer to arguments */ + int count; /* total amount of atoms */ double mass; /* total system mass */ t_atom *atom; /* pointer to the atoms */ diff --git a/postproc.c b/postproc.c index 68e0918..18834af 100644 --- a/postproc.c +++ b/postproc.c @@ -5,15 +5,181 @@ * */ +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include + #include #include "moldyn.h" +#include "math/math.h" + +#define FILEMAX 127 +#define BUFMAX 127 + +#define DISPLACEMENT (1<<0) +#define VELOCITY (1<<1) + +static char *pse[]={ + "*", + "H", + "He", + "Li", + "Be", + "B", + "C", + "N", + "O", + "F", + "Ne", + "Na", + "Mg", + "Al", + "Si", + "P", + "S", + "Cl", + "Ar", +}; + +int usage(void) { + printf("usage:\n"); + printf(" -i -o \n"); + printf(" -d/v (displacement,velocity)\n"); + printf(" \n"); + return 1; +} int main(int argc,char **argv) { t_moldyn md; + t_atom *atom; + char infile[FILEMAX+1]; + int infd; + char outfile[FILEMAX+1]; + int outfd; + int ret,size; + unsigned char mode; + char buf[BUFMAX+1]; + t_3dvec dist; + int i; + + memset(infile,0,FILEMAX+1); + memset(outfile,0,FILEMAX+1); + memset(buf,0,BUFMAX+1); + mode=0; + + /* parse argv */ + for(i=1;i %s\n",infile); + + infd=open(infile,O_RDONLY); + if(infd<3) { + perror("infile"); + return infd; + } + + /* open outfile */ + if(!strcmp(outfile,"")) { + printf("no outfile specified!\n"); + return -1; + } + printf("outfile -> %s\n",outfile); + + outfd=open(outfile,O_WRONLY|O_CREAT); + if(outfd<3) { + perror("outfile"); + return outfd; + } + + /* read in data */ + + size=sizeof(t_moldyn); + ret=0; + while(size-ret) + ret+=read(infd,&md,size-ret); + printf("read %d bytes moldyn struct data\n",size); + + /* allocate memory for atoms */ + size=md.count*sizeof(t_atom); + md.atom=malloc(size); + if(md.atom==NULL) { + perror("malloc"); + goto end; + } + + /* read in atom data */ + + ret=0; + atom=md.atom; + while(size-ret) + ret+=read(infd,atom,size-ret); + printf("read %d bytes atom data\n",size); + + /* postprocess ... */ + dprintf(outfd,"%d\n",md.count+8); + dprintf(outfd,"atoms at time %f\n",md.time); + for(i=0;irandom))-0.5)*md->dim.x*0.37; r.y=(rand_get_double(&(md->random))-0.5)*md->dim.y*0.37; r.z=(rand_get_double(&(md->random))-0.5)*md->dim.z*0.37; + //r.x=(1.0*atoi(hp->argv[3])-4.5)/9.0*ALBE_LC_SI; + //r.y=(1.0*atoi(hp->argv[4])-4.5)/9.0*ALBE_LC_SI; + //r.z=(1.0*atoi(hp->argv[5])-4.5)/9.0*ALBE_LC_SI; /* assume valid coordinates */ run=0; for(i=0;icount;i++) { @@ -104,10 +109,10 @@ int hook(void *moldyn,void *hook_params) { int main(int argc,char **argv) { /* check argv */ - if(argc!=3) { - printf("[sic] usage: %s \n",argv[0]); - return -1; - } + //if(argc!=3) { + // printf("[sic] usage: %s \n",argv[0]); + // return -1; + //} /* main moldyn structure */ t_moldyn md; @@ -352,6 +357,8 @@ int main(int argc,char **argv) { /* schedule hook function */ memset(&hookparam,0,sizeof(t_hp)); + hookparam.argc=argc; + hookparam.argv=argv; moldyn_set_schedule_hook(&md,&hook,&hookparam); /* activate logging */ -- 2.20.1