+t_3dvec get_total_p(t_atom *atom, int count) {
+
+ t_3dvec p,p_total;
+ int i;
+
+ v3_zero(&p_total);
+ for(i=0;i<count;i++) {
+ v3_scale(&p,&(atom[i].v),atom[i].mass);
+ v3_add(&p_total,&p_total,&p);
+ }
+
+ return p_total;
+}
+
+double potential_lennard_jones_2(t_moldyn *moldyn,void *ptr) {
+
+ t_lj_params *params;
+ t_atom *atom;
+ int i,j;
+ int count;
+ t_3dvec distance;
+ double d,help;
+ double u;
+ double eps,sig6,sig12;
+
+ params=ptr;
+ atom=moldyn->atom;
+ count=moldyn->count;
+ eps=params->epsilon;
+ sig6=params->sigma6;
+ sig12=params->sigma12;
+
+ u=0.0;
+ for(i=0;i<count;i++) {
+ for(j=0;j<i;j++) {
+ v3_sub(&distance,&(atom[j].r),&(atom[i].r));
+ d=v3_absolute_square(&distance); /* 1/r^2 */
+ help=d*d; /* 1/r^4 */
+ help*=d; /* 1/r^6 */
+ d=help*help; /* 1/r^12 */
+ u+=eps*(sig12*d-sig6*help);
+ }
+ }
+
+ return u;
+}
+
+