X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=moldyn.c;h=e96cdd4bd66e32632087321d07d12173024bec24;hb=b040d775deb32173e6536464a3e2ad95a6a5bd55;hp=029f7c756bd8f31871b4e7da5ae51f887db68031;hpb=710717c4033bc5b8eb34644914e762a2834ae345;p=physik%2Fposic.git diff --git a/moldyn.c b/moldyn.c index 029f7c7..e96cdd4 100644 --- a/moldyn.c +++ b/moldyn.c @@ -15,13 +15,13 @@ 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) { int count; int ret; t_3dvec origin; - count=((dim->x/lc)*(dim->y/lc)*(dim->z/lc)); + count=a*b*c; if(type==FCC) count*=4; if(type==DIAMOND) count*=8; @@ -36,14 +36,14 @@ 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; printf("unknown lattice type (%02x)\n",type); + return -1; } /* debug */ @@ -51,6 +51,7 @@ int create_lattice(unsigned char type,int element,double mass,double lc, printf("ok, there is something wrong ...\n"); printf("calculated -> %d atoms\n",count); printf("created -> %d atoms\n",ret); + return -1; } while(count) { @@ -62,3 +63,38 @@ int create_lattice(unsigned char type,int element,double mass,double lc, return ret; } +int thermal_init(t_atom *atom,int count,double t) { + + /* + * - gaussian distribution of velocities + * - velocity scaling (E = 3/2 N k T), E: kinetic energy + */ + + int i; + double e,c,v; + + e=.0; + + for(i=0;i