From: hackbard Date: Mon, 27 Mar 2006 08:55:17 +0000 (+0000) Subject: init testing X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=706aed2512544b99ff34308fdb673b19ee884ce0;p=physik%2Fposic.git init testing --- diff --git a/init/init.c b/init/init.c index 1f62963..07b4dc6 100644 --- a/init/init.c +++ b/init/init.c @@ -9,13 +9,18 @@ #include "../moldyn.h" /* fcc lattice init */ -int fcc_init(t_3dvec *dim,double lc,t_atom *atom,t_3dvec *origin) { +int fcc_init(int a,int b,int c,double lc,t_atom *atom,t_3dvec *origin) { int count; int i,j; t_3dvec o,r,n; t_3dvec basis[3]; double help[3]; + double x,y,z; + + x=a*lc; + y=b*lc; + z=c*lc; if(origin) v3_copy(&o,origin); else v3_zero(&o); @@ -34,14 +39,16 @@ int fcc_init(t_3dvec *dim,double lc,t_atom *atom,t_3dvec *origin) { count=0; /* fill up the room */ - while(r.xx) { - while(r.yy) { - while(r.zz) { + while(r.xx+o.x)&&(n.yy+o.y)&&(n.zz+o.z)) { + if((n.xx/2.0; - help[1]=dim->y/2.0; - help[2]=dim->z/2.0; + help[0]=x/2.0; + help[1]=y/2.0; + help[2]=z/2.0; v3_set(&n,help); for(i=0;ix/lc)*(dim->y/lc)*(dim->z/lc)); + count=a*b*c; if(type==FCC) count*=4; if(type==DIAMOND) count*=8; @@ -36,10 +36,10 @@ int create_lattice(unsigned char type,int element,double mass,double lc, switch(type) { case FCC: - ret=fcc_init(dim,lc,*atom,&origin); + ret=fcc_init(a,b,c,lc,*atom,&origin); break; case DIAMOND: - ret=diamond_init(dim,lc,*atom,&origin); + ret=diamond_init(a,b,c,lc,*atom,&origin); break; default: ret=-1; diff --git a/moldyn.h b/moldyn.h index d72ac16..1f9800c 100644 --- a/moldyn.h +++ b/moldyn.h @@ -36,6 +36,6 @@ typedef struct s_atom { /* function prototypes */ int create_lattice(unsigned char type,int element,double mass,double lc, - t_3dvec *dim,t_atom **atom); + int a,int b,int c,t_atom **atom); #endif diff --git a/posic.c b/posic.c index 6973278..6d1256f 100644 --- a/posic.c +++ b/posic.c @@ -15,7 +15,7 @@ int main(int argc,char **argv) { t_atom *si; - t_3dvec dim; + int a,b,c; char fb[32]="saves/fcc_test"; @@ -23,15 +23,15 @@ int main(int argc,char **argv) { int count; - dim.x=LEN_X; - dim.y=LEN_Y; - dim.z=LEN_Z; + a=LEN_X; + b=LEN_Y; + c=LEN_Z; visual_init(&vis,fb); /* init */ printf("placing silicon atoms\n"); - count=create_lattice(FCC,Si,M_SI,LC_SI,&dim,&si); + count=create_lattice(FCC,Si,M_SI,LC_SI,a,b,c,&si); visual_atoms(&vis,0.0,si,count); diff --git a/posic.h b/posic.h index 1eb8e81..a26e668 100644 --- a/posic.h +++ b/posic.h @@ -17,19 +17,9 @@ #ifndef POSIC_H #define POSIC_H -#define LEN_X 50 -#define LX (1.0*LEN_X/2) -#define LEN_Y 50 -#define LY (1.0*LEN_Y/2) -#define LEN_Z 50 -#define LZ (1.0*LEN_Z/2) - #define RUNS 15000 #define TAU 0.001 -#define R_CUTOFF 20 -#define R2_CUTOFF (R_CUTOFF*R_CUTOFF) - #define SI_M 1 #define SI_LC 5.43105 #define LJ_SIGMA SI_LC @@ -37,6 +27,13 @@ #define LJ_SIGMA_06 (LJ_SIGMA_02*LJ_SIGMA_02*LJ_SIGMA_02) #define LJ_SIGMA_12 (LJ_SIGMA_06*LJ_SIGMA_06) +#define LEN_X 2 +#define LEN_Y 2 +#define LEN_Z 2 + +#define R_CUTOFF 20 +#define R2_CUTOFF (R_CUTOFF*R_CUTOFF) + #define AMOUNT_SI ((LEN_X/SI_LC)*(LEN_Y/SI_LC)*(LEN_Z/SI_LC)*2) #endif diff --git a/visual/visual.c b/visual/visual.c index 6ad527a..ce4ceaf 100644 --- a/visual/visual.c +++ b/visual/visual.c @@ -25,7 +25,7 @@ int visual_init(t_visual *v,char *filebase) { memset(file,0,128+8); sprintf(file,"%s.scr",v->fb); - v->fd=open(file,O_WRONLY); + v->fd=open(file,O_WRONLY|O_CREAT|O_TRUNC); if(v->fd<0) { perror("open visual fd"); return -1; @@ -69,7 +69,7 @@ int visual_atoms(t_visual *v,double time,t_atom *atom,int n) { }; sprintf(file,"%s-%.15f.xyz",v->fb,time); - fd=open(file,O_WRONLY); + fd=open(file,O_WRONLY|O_CREAT|O_TRUNC); if(fd<0) { perror("open visual save file fd"); return -1; @@ -87,8 +87,8 @@ int visual_atoms(t_visual *v,double time,t_atom *atom,int n) { dprintf(v->fd,"zap\n"); /* write the actual data file */ - dprintf(fd,"Atoms at time %.15f\n",time); dprintf(fd,"%d\n",n); + dprintf(fd,"atoms at time %.15f\n",time); for(i=0;i