memset(moldyn,0,sizeof(t_moldyn));
+ moldyn->argc=argc;
+ moldyn->args=argv;
+
rand_init(&(moldyn->random),NULL,1);
moldyn->random.status|=RAND_STAT_VERBOSE;
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);
}
*
*/
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
#include <math.h>
#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 <infile> -o <outfile>\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<argc;i++) {
+
+ if(argv[i][0]!='-') {
+ usage();
+ return -1;
+ }
+
+ switch(argv[i][1]) {
+ case 'h':
+ usage();
+ return 1;
+ case 'i':
+ strncpy(infile,argv[++i],FILEMAX);
+ break;
+ case 'o':
+ strncpy(outfile,argv[++i],FILEMAX);
+ break;
+ case 'd':
+ mode=DISPLACEMENT;
+ break;
+ case 'v':
+ mode=VELOCITY;
+ break;
+ default:
+ usage();
+ return -1;
+ }
+
+ }
+
+ /* open infile */
+ if(!strcmp(infile,"")) {
+ printf("no infile specified!\n");
+ return -1;
+ }
+ printf("infile -> %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;i<md.count;i++) {
+printf("%d ",i);
+ dprintf(outfd,"%s %f %f %f",pse[atom[i].element],
+ atom[i].r.x,atom[i].r.y,atom[i].r.z);
+ if(mode&DISPLACEMENT) {
+ v3_sub(&dist,&(atom[i].r),&(atom[i].r_0));
+ check_per_bound(&md,&dist);
+ dprintf(outfd," %f",v3_norm(&dist));
+ }
+ if(mode&VELOCITY) {
+ dprintf(outfd," %f",atom[i].ekin);
+ }
+ dprintf(outfd,"\n");
+ }
+
+ /* free memory & close file descriptors */
+
+end:
+ free(md.atom);
+ close(infd);
+ close(outfd);
return 0;
}
#define INJECT 1
#define NR_ATOMS 1
-#define R_C 2.0
+#define R_C 1.0
#define T_C 10.0
-#define LCNT 2
+#define LCNT 5
typedef struct s_hp {
int a_count; /* atom count */
u8 quit; /* quit mark */
+ int argc; /* arg count */
+ char **argv; /* args */
} t_hp;
int hook(void *moldyn,void *hook_params) {
r.x=(rand_get_double(&(md->random))-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;i<md->count;i++) {
int main(int argc,char **argv) {
/* check argv */
- if(argc!=3) {
- printf("[sic] usage: %s <logdir> <temperatur>\n",argv[0]);
- return -1;
- }
+ //if(argc!=3) {
+ // printf("[sic] usage: %s <logdir> <temperatur>\n",argv[0]);
+ // return -1;
+ //}
/* main moldyn structure */
t_moldyn md;
/* schedule hook function */
memset(&hookparam,0,sizeof(t_hp));
+ hookparam.argc=argc;
+ hookparam.argv=argv;
moldyn_set_schedule_hook(&md,&hook,&hookparam);
/* activate logging */