X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=moldyn.c;h=82749b2f10abf978c9636e213585e21c8393741a;hb=85abe46fecc79a3d7885ff6124186b2be2ca96ac;hp=b507d65354dabcf690628bc8bc31846962542fe3;hpb=3ffe2a08e25fc091b6241885055450009267e2d8;p=physik%2Fposic.git diff --git a/moldyn.c b/moldyn.c index b507d65..82749b2 100644 --- a/moldyn.c +++ b/moldyn.c @@ -87,25 +87,26 @@ int thermal_init(t_atom *atom,t_random *random,int count,double t) { /* gaussian distribution of velocities */ v3_zero(&p_total); for(i=0;ipotential(moldyn)); +} + +double get_total_energy(t_moldyn *moldyn) { + + double e; + + e=get_e_kin(moldyn->atom,moldyn->count); + e+=get_e_pot(moldyn); + + return e; +} + +t_3dvec get_total_p(t_atom *atom, int count) { + + t_3dvec p,p_total; + int i; + + v3_zero(&p_total); + for(i=0;ipot_params; + atom=moldyn->atom; + count=moldyn->count; + eps=params->epsilon; + sig6=params->sigma6; + sig12=params->sigma12; + + u=0.0; + for(i=0;iatom; + count=moldyn->count; + params=moldyn->pot_params; + + for(i=0;idim)); + d=v3_absolute_square(&distance); + if(d<=moldyn->cutoff_square) { + h1=1.0/d; /* 1/r^2 */ + d=h1*h1; /* 1/r^4 */ + h2=d*d; /* 1/r^8 */ + h1*=d; /* 1/r^6 */ + h1*=h2; /* 1/r^14 */ + } + } + } + + return 0; +} +