sc=params->spring_constant;
equi_dist=params->equilibrium_distance;
- v3_sub(&distance,&(ai->r),&(aj->r));
+ v3_sub(&distance,&(aj->r),&(ai->r));
if(bc) check_per_bound(moldyn,&distance);
d=v3_norm(&distance);
if(d<=moldyn->cutoff) {
/* energy is 1/2 (d-d0)^2, but we will add this twice ... */
moldyn->energy+=(0.25*sc*(d-equi_dist)*(d-equi_dist));
- v3_scale(&force,&distance,-sc*(1.0-(equi_dist/d)));
+ /* f = -grad E; grad r_ij = -1 1/r_ij distance */
+ v3_scale(&force,&distance,sc*(1.0-(equi_dist/d)));
v3_add(&(ai->f),&(ai->f),&force);
}
sig6=params->sigma6;
sig12=params->sigma12;
- v3_sub(&distance,&(ai->r),&(aj->r));
+ v3_sub(&distance,&(aj->r),&(ai->r));
if(bc) check_per_bound(moldyn,&distance);
d=v3_absolute_square(&distance); /* 1/r^2 */
if(d<=moldyn->cutoff_square) {
h1*=12*sig12;
d=+h1-h2;
d*=eps;
- v3_scale(&force,&distance,d);
+ v3_scale(&force,&distance,-1.0*d); /* f = - grad E */
v3_add(&(ai->f),&(ai->f),&force);
}
* therefore we need: R, S, A, lambda
*/
- v3_sub(&dist_ij,&(ai->r),&(aj->r));
+ v3_sub(&dist_ij,&(aj->r),&(ai->r));
if(bc) check_per_bound(moldyn,&dist_ij);
*
*/
- v3_sub(&dist_ik,&(ai->r),&(ak->r));
+ v3_sub(&dist_ik,&(ak->r),&(ai->r));
if(bc) check_per_bound(moldyn,&dist_ik);
d_ik=v3_norm(&dist_ik);