/*************************************************************************** forcefuncvdw.c - description ------------------- begin : Fri Mar 18 12:25:42 2005 copyright : (C) 2002 by Cavalli Andrea email : cavalli@bioc.unizh.ch **************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #define COOR_DIM 4 void force_xxsn_d(const int * first, const int * second, const int * boundarry, const int natoms, const double * coor, double * force, const double c2, const double c_on2, const int * type_code, const int type_size, const double * vdw_data){ int f; int fpos; int s; int spos; int b1,b2; double fracX; double fracY; double fracZ; double dx,dy,dz; double ix,iy,iz; double jx,jy,jz; double tx,ty,tz; double d2; double d6; double d2inv; double d6inv; double d12inv; double frac; double nb6; double nb12; double A,B; int tc1,tc2; int data_pos; const double c2inv = 1.0/c2; const double c6inv = c2inv*c2inv*c2inv; const double c12inv = c6inv*c6inv; const double c18inv = c12inv*c6inv; const double one = 1.0; int i,j; for(i = 0;ic_on2){ sh1 = c2-d2; sh2 = (c2+two*d2-three*c_on2); sw = sh1*sh2; sw1= four*(sh1-sh2); frac = nbvdw*sw*d2inv-(twelve_inv*A*d12inv-six_inv*B*d6inv)*sw1; frac = frac*c2diffinv*sh1; } else frac = nbvdw*d2inv; tx = frac*dx; ty = frac*dy; tz = frac*dz; fracX = fracX - tx; fracY = fracY - ty; fracZ = fracZ - tz; force[spos] = force[spos] + tx; force[spos+1] = force[spos+1] + ty; force[spos+2] = force[spos+2] + tz; } } force[fpos] = force[fpos] + fracX; force[fpos+1] = force[fpos+1] + fracY; force[fpos+2] = force[fpos+2] + fracZ; } } void force_xxswn_f(const int * first, const int * second, const int * boundarry, const int natoms, const float * coor, float * force, const float c2, const float c_on2, const int * type_code, const int type_size, const float * vdw_data){ int f; int fpos; int s; int spos; int b1,b2; float fracX; float fracY; float fracZ; float dx,dy,dz; float ix,iy,iz; float jx,jy,jz; float tx,ty,tz; float d2; float d6; float d2inv; float d6inv; float d12inv; float sh1; float sh2; float sw; float sw1; float frac; float nbvdw; float A,B; int tc1,tc2; int data_pos; const float c2diffinv = 1.0/((c2-c_on2)*(c2-c_on2)*(c2-c_on2)); const float one = 1.0; const float two = 2.0; const float three = 3.0; const float four = 4.0; const float six_inv = 1.0/6.0; const float twelve_inv = 1.0/12.0; int i,j; for(i = 0;ic_on2){ sh1 = c2-d2; sh2 = (c2+two*d2-three*c_on2); sw = sh1*sh2; sw1= four*(sh1-sh2); frac = nbvdw*sw*d2inv-(twelve_inv*A*d12inv-six_inv*B*d6inv)*sw1; frac = frac*c2diffinv*sh1; } else frac = nbvdw*d2inv; tx = frac*dx; ty = frac*dy; tz = frac*dz; fracX = fracX - tx; fracY = fracY - ty; fracZ = fracZ - tz; force[spos] = force[spos] + tx; force[spos+1] = force[spos+1] + ty; force[spos+2] = force[spos+2] + tz; } } force[fpos] = force[fpos] + fracX; force[fpos+1] = force[fpos+1] + fracY; force[fpos+2] = force[fpos+2] + fracZ; } }