X-Git-Url: https://hackdaworld.org/gitweb/?a=blobdiff_plain;f=moldyn.c;h=b507d65354dabcf690628bc8bc31846962542fe3;hb=3ffe2a08e25fc091b6241885055450009267e2d8;hp=e96cdd4bd66e32632087321d07d12173024bec24;hpb=b040d775deb32173e6536464a3e2ad95a6a5bd55;p=physik%2Fposic.git diff --git a/moldyn.c b/moldyn.c index e96cdd4..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, @@ -63,38 +65,83 @@ int create_lattice(unsigned char type,int element,double mass,double lc, return ret; } -int thermal_init(t_atom *atom,int count,double t) { +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 e,c,v; - - e=.0; + double v,sigma; + t_3dvec p_total,delta; + /* gaussian distribution of velocities */ + v3_zero(&p_total); for(i=0;i