X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=moldyn.c;h=b507d65354dabcf690628bc8bc31846962542fe3;hb=3ffe2a08e25fc091b6241885055450009267e2d8;hp=ba3c1a30c8c2bd995a2ac2264d9a79984db01015;hpb=706aed2512544b99ff34308fdb673b19ee884ce0;p=physik%2Fposic.git diff --git a/moldyn.c b/moldyn.c index ba3c1a3..b507d65 100644 --- a/moldyn.c +++ b/moldyn.c @@ -9,9 +9,11 @@ #include #include +#include #include "math/math.h" #include "init/init.h" +#include "random/random.h" int create_lattice(unsigned char type,int element,double mass,double lc, @@ -42,8 +44,8 @@ int create_lattice(unsigned char type,int element,double mass,double lc, 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 +53,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 +65,83 @@ int create_lattice(unsigned char type,int element,double mass,double lc, return ret; } +int destroy_lattice(t_atom *atom) { + + if(atom) free(atom); + + return 0; +} + +int thermal_init(t_atom *atom,t_random *random,int count,double t) { + + /* + * - gaussian distribution of velocities + * - zero total momentum + * - velocity scaling (E = 3/2 N k T), E: kinetic energy + */ + + int i; + double v,sigma; + t_3dvec p_total,delta; + + /* gaussian distribution of velocities */ + v3_zero(&p_total); + for(i=0;i