/*************************************************************************** forcefunc.c - description ------------------- begin : Tue Sep 6 22:01:58 2005 copyright : (C) 2005 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 #include #include #ifdef IX86 #define x86trunc(a,b) asm("fld %1 ; fistpl %0" : "=m" (*&b) : "f" (a)); #else #define x86trunc(a,b) {b = (int)a;} #endif /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional NONE Elec CUTOFF NONE VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void force_xxtn_d (const int *first, const int *second, const int *boundary, 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 i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 d2inv; double d6inv; double d12inv; double frac; double fvdw; double A, B; const double one = 1.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; fvdw = A * d12inv - B * d6inv; frac = fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional NONE Elec CUTOFF NONE VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void force_xxtn_f (const int *first, const int *second, const int *boundary, 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 i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 d2inv; float d6inv; float d12inv; float frac; float fvdw; float A, B; const float one = 1.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; fvdw = A * d12inv - B * d6inv; frac = fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional NONE Elec CUTOFF NONE VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void force_xxsn_d (const int *first, const int *second, const int *boundary, 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 i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 fvdw; double nb6; double nb12; double A, B; 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; frac = fvdw;; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional NONE Elec CUTOFF NONE VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void force_xxsn_f (const int *first, const int *second, const int *boundary, 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 i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 frac; float fvdw; float nb6; float nb12; float A, B; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * c6inv; const float c18inv = c12inv * c6inv; const float one = 1.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; frac = fvdw;; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional NONE Elec CUTOFF NONE VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void force_xxswn_d (const int *first, const int *second, const int *boundary, 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 i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 d2inv; double d6inv; double d12inv; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double A, B; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double one = 1.0; const double two = 2.0; const double three = 3.0; const double four = 4.0; const double six_inv = 1.0 / 6.0; const double twelve_inv = 1.0 / 12.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional NONE Elec CUTOFF NONE VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void force_xxswn_f (const int *first, const int *second, const int *boundary, 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 i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 d2inv; float d6inv; float d12inv; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float A, B; 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional NONE Elec CUTOFF NONE VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void pbcforce_xxtn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double frac; double fvdw; double A, B; const double one = 1.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; fvdw = A * d12inv - B * d6inv; frac = fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional NONE Elec CUTOFF NONE VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type double CPU CPUPlain ***************************************************************************/ void vpbcforce_xxtn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const int *type_code, const int type_size, double *fvir, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double frac; double fvdw; double A, B; const double one = 1.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; fvdw = A * d12inv - B * d6inv; frac = fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional NONE Elec CUTOFF NONE VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void pbcforce_xxtn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float frac; float fvdw; float A, B; const float one = 1.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; fvdw = A * d12inv - B * d6inv; frac = fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional NONE Elec CUTOFF NONE VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type float CPU CPUPlain ***************************************************************************/ void vpbcforce_xxtn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const int *type_code, const int type_size, float *fvir, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float frac; float fvdw; float A, B; const float one = 1.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; fvdw = A * d12inv - B * d6inv; frac = fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional NONE Elec CUTOFF NONE VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void pbcforce_xxsn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d6; double d2inv; double d6inv; double d12inv; double frac; double fvdw; double nb6; double nb12; double A, B; 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; frac = fvdw;; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional NONE Elec CUTOFF NONE VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type double CPU CPUPlain ***************************************************************************/ void vpbcforce_xxsn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const int *type_code, const int type_size, double *fvir, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d6; double d2inv; double d6inv; double d12inv; double frac; double fvdw; double nb6; double nb12; double A, B; 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; frac = fvdw;; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional NONE Elec CUTOFF NONE VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void pbcforce_xxsn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d6; float d2inv; float d6inv; float d12inv; float frac; float fvdw; float nb6; float nb12; float A, B; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * c6inv; const float c18inv = c12inv * c6inv; const float one = 1.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; frac = fvdw;; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional NONE Elec CUTOFF NONE VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type float CPU CPUPlain ***************************************************************************/ void vpbcforce_xxsn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const int *type_code, const int type_size, float *fvir, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d6; float d2inv; float d6inv; float d12inv; float frac; float fvdw; float nb6; float nb12; float A, B; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * c6inv; const float c18inv = c12inv * c6inv; const float one = 1.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; frac = fvdw;; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional NONE Elec CUTOFF NONE VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void pbcforce_xxswn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double A, B; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double one = 1.0; const double two = 2.0; const double three = 3.0; const double four = 4.0; const double six_inv = 1.0 / 6.0; const double twelve_inv = 1.0 / 12.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional NONE Elec CUTOFF NONE VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type double CPU CPUPlain ***************************************************************************/ void vpbcforce_xxswn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const int *type_code, const int type_size, double *fvir, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double A, B; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double one = 1.0; const double two = 2.0; const double three = 3.0; const double four = 4.0; const double six_inv = 1.0 / 6.0; const double twelve_inv = 1.0 / 12.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional NONE Elec CUTOFF NONE VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void pbcforce_xxswn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float A, B; 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional NONE Elec CUTOFF NONE VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type float CPU CPUPlain ***************************************************************************/ void vpbcforce_xxswn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const int *type_code, const int type_size, float *fvir, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float A, B; 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF TABLE VDW Functional LJ VDW CUTOFF TABLE SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void force_cttn_d(const int * first, const int * second, const int * boundarry, const int natoms, const double * coor, double * force, const double * charge, const int * type_code, const int type_size, const double * vdw_data, const double * sdata_force){ 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 d; double dinv; double dt; double frac; double nb6,nb12; double nbelec; double A,B,q1,q2; double eps,eps2; int tc1,tc2; int data_pos; int spline_pos; int n0; const double one = 1.0; const double two = 2.0; const double three = 3.0; const double four = 4.0; const double six_inv = 1.0/6.0; const double twelve_inv = 1.0/12.0; const double density = 2000; int i,j; for(i = 0;i c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } frac = frac + felec * 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void force_ctswn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 dinv; float d2inv; float d6inv; float d12inv; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float A, B; float q1, q2; const float c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrtf (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = q1 * q2 * dinv; fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } frac = frac + felec * 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void force_cstn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 dinv; double d2inv; double d6inv; double d12inv; double esh; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2inv = 1.0 / c2; const double one = 1.0; const double four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrt (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = q1 * q2 * esh * dinv * (esh * d2inv + four * c2inv); fvdw = A * d12inv - B * d6inv; frac = felec + fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void force_cstn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 dinv; float d2inv; float d6inv; float d12inv; float esh; float frac; float fvdw; float felec; float A, B; float q1, q2; const float c2inv = 1.0 / c2; const float one = 1.0; const float four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrtf (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = q1 * q2 * esh * dinv * (esh * d2inv + four * c2inv); fvdw = A * d12inv - B * d6inv; frac = felec + fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void force_cssn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 dinv; double d2inv; double d6inv; double d12inv; double esh; double frac; double fvdw; double felec; double nb6; double nb12; double A, B; double q1, q2; 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; const double four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrt (d2); d2inv = dinv * dinv; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = q1 * q2 * esh * dinv * (esh * d2inv + four * c2inv); nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; frac = (felec + fvdw); 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void force_cssn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 dinv; float d2inv; float d6inv; float d12inv; float esh; float frac; float fvdw; float felec; float nb6; float nb12; float A, B; float q1, q2; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * c6inv; const float c18inv = c12inv * c6inv; const float one = 1.0; const float four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrtf (d2); d2inv = dinv * dinv; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = q1 * q2 * esh * dinv * (esh * d2inv + four * c2inv); nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; frac = (felec + fvdw); 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void force_csswn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 dinv; double d2inv; double d6inv; double d12inv; double esh; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2inv = 1.0 / c2; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double one = 1.0; const double two = 2.0; const double three = 3.0; const double four = 4.0; const double six_inv = 1.0 / 6.0; const double twelve_inv = 1.0 / 12.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrt (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = q1 * q2 * esh * dinv * (esh * d2inv + four * c2inv); fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } frac = frac + felec; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void force_csswn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 dinv; float d2inv; float d6inv; float d12inv; float esh; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float A, B; float q1, q2; const float c2inv = 1.0 / c2; 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrtf (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = q1 * q2 * esh * dinv * (esh * d2inv + four * c2inv); fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } frac = frac + felec; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void force_cswtn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 dinv; double d2inv; double d6inv; double d12inv; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double two = 2.0; const double three = 3.0; const double four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrt (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; fvdw = A * d12inv - B * d6inv; felec = q1 * q2 * dinv; frac = felec * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - felec * sw1;; frac = frac * c2diffinv * sh1; } frac = frac + fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void force_cswtn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 dinv; float d2inv; float d6inv; float d12inv; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float A, B; float q1, q2; const float c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const float two = 2.0; const float three = 3.0; const float four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrtf (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; fvdw = A * d12inv - B * d6inv; felec = q1 * q2 * dinv; frac = felec * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - felec * sw1;; frac = frac * c2diffinv * sh1; } frac = frac + fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void force_cswsn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 dinv; double d2inv; double d6inv; double d12inv; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double nb6; double nb12; double A, B; double q1, q2; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * c6inv; const double c18inv = c12inv * c6inv; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double two = 2.0; const double three = 3.0; const double four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrt (d2); d2inv = dinv * dinv; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; felec = q1 * q2 * dinv; frac = felec * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - felec * sw1;; frac = frac * c2diffinv * sh1; } frac = frac + fvdw; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void force_cswsn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 dinv; float d2inv; float d6inv; float d12inv; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float nb6; float nb12; float A, B; float q1, q2; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * c6inv; const float c18inv = c12inv * c6inv; const float c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const float two = 2.0; const float three = 3.0; const float four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrtf (d2); d2inv = dinv * dinv; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; felec = q1 * q2 * dinv; frac = felec * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - felec * sw1;; frac = frac * c2diffinv * sh1; } frac = frac + fvdw; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void force_cswswn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 dinv; double d2inv; double d6inv; double d12inv; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double two = 2.0; const double three = 3.0; const double four = 4.0; const double six_inv = 1.0 / 6.0; const double twelve_inv = 1.0 / 12.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrt (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = q1 * q2 * dinv; fvdw = A * d12inv - B * d6inv; frac = (felec + fvdw) * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv + felec) * sw1; frac = frac * c2diffinv * sh1; } 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void force_cswswn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 dinv; float d2inv; float d6inv; float d12inv; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float A, B; float q1, q2; const float c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrtf (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = q1 * q2 * dinv; fvdw = A * d12inv - B * d6inv; frac = (felec + fvdw) * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv + felec) * sw1; frac = frac * c2diffinv * sh1; } 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void force_rttn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 d2inv; double d6inv; double d12inv; double frac; double fvdw; double felec; double A, B; double q1, q2; const double one = 1.0; const double two = 2.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = two * q1 * q2 * d2inv; fvdw = A * d12inv - B * d6inv; frac = (felec + fvdw) * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void force_rttn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 d2inv; float d6inv; float d12inv; float frac; float fvdw; float felec; float A, B; float q1, q2; const float one = 1.0; const float two = 2.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = two * q1 * q2 * d2inv; fvdw = A * d12inv - B * d6inv; frac = (felec + fvdw) * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void force_rtsn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 fvdw; double felec; double nb6; double nb12; double A, B; double q1, q2; 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; const double two = 2.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = two * q1 * q2 * d2inv; nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; frac = felec * d2inv + fvdw; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void force_rtsn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 frac; float fvdw; float felec; float nb6; float nb12; float A, B; float q1, q2; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * c6inv; const float c18inv = c12inv * c6inv; const float one = 1.0; const float two = 2.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = two * q1 * q2 * d2inv; nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; frac = felec * d2inv + fvdw; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void force_rtswn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 d2inv; double d6inv; double d12inv; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double one = 1.0; const double two = 2.0; const double three = 3.0; const double four = 4.0; const double six_inv = 1.0 / 6.0; const double twelve_inv = 1.0 / 12.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = two * q1 * q2 * d2inv; fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } frac = frac + felec * 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void force_rtswn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 d2inv; float d6inv; float d12inv; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float A, B; float q1, q2; 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = two * q1 * q2 * d2inv; fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } frac = frac + felec * 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void force_rstn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 d2inv; double d6inv; double d12inv; double esh; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2inv = 1.0 / c2; const double one = 1.0; const double two = 2.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = two * q1 * q2 * esh * d2inv * (esh * d2inv + two * c2inv); fvdw = A * d12inv - B * d6inv; frac = felec + fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void force_rstn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 d2inv; float d6inv; float d12inv; float esh; float frac; float fvdw; float felec; float A, B; float q1, q2; const float c2inv = 1.0 / c2; const float one = 1.0; const float two = 2.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = two * q1 * q2 * esh * d2inv * (esh * d2inv + two * c2inv); fvdw = A * d12inv - B * d6inv; frac = felec + fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void force_rssn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 esh; double frac; double fvdw; double felec; double nb6; double nb12; double A, B; double q1, q2; 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; const double two = 2.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = two * q1 * q2 * esh * d2inv * (esh * d2inv + two * c2inv); nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; frac = (felec + fvdw); 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void force_rssn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 esh; float frac; float fvdw; float felec; float nb6; float nb12; float A, B; float q1, q2; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * c6inv; const float c18inv = c12inv * c6inv; const float one = 1.0; const float two = 2.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = two * q1 * q2 * esh * d2inv * (esh * d2inv + two * c2inv); nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; frac = (felec + fvdw); 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void force_rsswn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 d2inv; double d6inv; double d12inv; double esh; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2inv = 1.0 / c2; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double one = 1.0; const double two = 2.0; const double three = 3.0; const double four = 4.0; const double six_inv = 1.0 / 6.0; const double twelve_inv = 1.0 / 12.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = two * q1 * q2 * esh * d2inv * (esh * d2inv + two * c2inv); fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } frac = frac + felec; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void force_rsswn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 d2inv; float d6inv; float d12inv; float esh; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float A, B; float q1, q2; const float c2inv = 1.0 / c2; 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = two * q1 * q2 * esh * d2inv * (esh * d2inv + two * c2inv); fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } frac = frac + felec; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void force_rswtn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 d2inv; double d6inv; double d12inv; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double one = 1.0; const double two = 2.0; const double three = 3.0; const double four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; fvdw = A * d12inv - B * d6inv; felec = two * q1 * q2 * d2inv; frac = felec * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - 0.5 * felec * sw1;; frac = frac * c2diffinv * sh1; } frac = frac + fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void force_rswtn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 d2inv; float d6inv; float d12inv; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float A, B; float q1, q2; 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; fvdw = A * d12inv - B * d6inv; felec = two * q1 * q2 * d2inv; frac = felec * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - 0.5 * felec * sw1;; frac = frac * c2diffinv * sh1; } frac = frac + fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void force_rswsn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double nb6; double nb12; double A, B; double q1, q2; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * c6inv; const double c18inv = c12inv * c6inv; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double one = 1.0; const double two = 2.0; const double three = 3.0; const double four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; felec = two * q1 * q2 * d2inv; frac = felec * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - 0.5 * felec * sw1;; frac = frac * c2diffinv * sh1; } frac = frac + fvdw; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void force_rswsn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 fvdw; float felec; float nb6; float nb12; float A, B; float q1, q2; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * c6inv; const float c18inv = c12inv * c6inv; 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; felec = two * q1 * q2 * d2inv; frac = felec * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - 0.5 * felec * sw1;; frac = frac * c2diffinv * sh1; } frac = frac + fvdw; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void force_rswswn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 d2inv; double d6inv; double d12inv; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double one = 1.0; const double two = 2.0; const double three = 3.0; const double four = 4.0; const double six_inv = 1.0 / 6.0; const double twelve_inv = 1.0 / 12.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = two * q1 * q2 * d2inv; fvdw = A * d12inv - B * d6inv; frac = (felec + fvdw) * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv + 0.5 * felec) * sw1; frac = frac * c2diffinv * sh1; } 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PLAIN Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void force_rswswn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; 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 d2inv; float d6inv; float d12inv; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float A, B; float q1, q2; 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; ix = coor[fpos]; iy = coor[fpos + 1]; iz = coor[fpos + 2]; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = two * q1 * q2 * d2inv; fvdw = A * d12inv - B * d6inv; frac = (felec + fvdw) * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv + 0.5 * felec) * sw1; frac = frac * c2diffinv * sh1; } 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void pbcforce_cttn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double dinv; double d2inv; double d6inv; double d12inv; double frac; double fvdw; double felec; double A, B; double q1, q2; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrt (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = q1 * q2 * dinv; fvdw = A * d12inv - B * d6inv; frac = (felec + fvdw) * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type double CPU CPUPlain ***************************************************************************/ void vpbcforce_cttn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double dinv; double d2inv; double d6inv; double d12inv; double frac; double fvdw; double felec; double A, B; double q1, q2; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrt (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = q1 * q2 * dinv; fvdw = A * d12inv - B * d6inv; frac = (felec + fvdw) * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void pbcforce_cttn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float dinv; float d2inv; float d6inv; float d12inv; float frac; float fvdw; float felec; float A, B; float q1, q2; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrtf (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = q1 * q2 * dinv; fvdw = A * d12inv - B * d6inv; frac = (felec + fvdw) * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type float CPU CPUPlain ***************************************************************************/ void vpbcforce_cttn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float dinv; float d2inv; float d6inv; float d12inv; float frac; float fvdw; float felec; float A, B; float q1, q2; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrtf (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = q1 * q2 * dinv; fvdw = A * d12inv - B * d6inv; frac = (felec + fvdw) * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void pbcforce_ctsn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d6; double dinv; double d2inv; double d6inv; double d12inv; double frac; double fvdw; double felec; double nb6; double nb12; double A, B; double q1, q2; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * c6inv; const double c18inv = c12inv * c6inv; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrt (d2); d2inv = dinv * dinv; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = q1 * q2 * dinv; nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; frac = felec * d2inv + fvdw; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type double CPU CPUPlain ***************************************************************************/ void vpbcforce_ctsn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d6; double dinv; double d2inv; double d6inv; double d12inv; double frac; double fvdw; double felec; double nb6; double nb12; double A, B; double q1, q2; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * c6inv; const double c18inv = c12inv * c6inv; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrt (d2); d2inv = dinv * dinv; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = q1 * q2 * dinv; nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; frac = felec * d2inv + fvdw; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void pbcforce_ctsn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d6; float dinv; float d2inv; float d6inv; float d12inv; float frac; float fvdw; float felec; float nb6; float nb12; float A, B; float q1, q2; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * c6inv; const float c18inv = c12inv * c6inv; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrtf (d2); d2inv = dinv * dinv; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = q1 * q2 * dinv; nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; frac = felec * d2inv + fvdw; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type float CPU CPUPlain ***************************************************************************/ void vpbcforce_ctsn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d6; float dinv; float d2inv; float d6inv; float d12inv; float frac; float fvdw; float felec; float nb6; float nb12; float A, B; float q1, q2; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * c6inv; const float c18inv = c12inv * c6inv; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrtf (d2); d2inv = dinv * dinv; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = q1 * q2 * dinv; nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; frac = felec * d2inv + fvdw; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void pbcforce_ctswn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double dinv; double d2inv; double d6inv; double d12inv; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double two = 2.0; const double three = 3.0; const double four = 4.0; const double six_inv = 1.0 / 6.0; const double twelve_inv = 1.0 / 12.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrt (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = q1 * q2 * dinv; fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } frac = frac + felec * 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type double CPU CPUPlain ***************************************************************************/ void vpbcforce_ctswn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double dinv; double d2inv; double d6inv; double d12inv; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double two = 2.0; const double three = 3.0; const double four = 4.0; const double six_inv = 1.0 / 6.0; const double twelve_inv = 1.0 / 12.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrt (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = q1 * q2 * dinv; fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } frac = frac + felec * 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void pbcforce_ctswn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float dinv; float d2inv; float d6inv; float d12inv; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float A, B; float q1, q2; const float c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrtf (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = q1 * q2 * dinv; fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } frac = frac + felec * 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type float CPU CPUPlain ***************************************************************************/ void vpbcforce_ctswn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float dinv; float d2inv; float d6inv; float d12inv; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float A, B; float q1, q2; const float c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrtf (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = q1 * q2 * dinv; fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } frac = frac + felec * 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void pbcforce_cstn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double dinv; double d2inv; double d6inv; double d12inv; double esh; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2inv = 1.0 / c2; const double one = 1.0; const double four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrt (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = q1 * q2 * esh * dinv * (esh * d2inv + four * c2inv); fvdw = A * d12inv - B * d6inv; frac = felec + fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type double CPU CPUPlain ***************************************************************************/ void vpbcforce_cstn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double dinv; double d2inv; double d6inv; double d12inv; double esh; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2inv = 1.0 / c2; const double one = 1.0; const double four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrt (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = q1 * q2 * esh * dinv * (esh * d2inv + four * c2inv); fvdw = A * d12inv - B * d6inv; frac = felec + fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void pbcforce_cstn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float dinv; float d2inv; float d6inv; float d12inv; float esh; float frac; float fvdw; float felec; float A, B; float q1, q2; const float c2inv = 1.0 / c2; const float one = 1.0; const float four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrtf (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = q1 * q2 * esh * dinv * (esh * d2inv + four * c2inv); fvdw = A * d12inv - B * d6inv; frac = felec + fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type float CPU CPUPlain ***************************************************************************/ void vpbcforce_cstn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float dinv; float d2inv; float d6inv; float d12inv; float esh; float frac; float fvdw; float felec; float A, B; float q1, q2; const float c2inv = 1.0 / c2; const float one = 1.0; const float four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrtf (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = q1 * q2 * esh * dinv * (esh * d2inv + four * c2inv); fvdw = A * d12inv - B * d6inv; frac = felec + fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void pbcforce_cssn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d6; double dinv; double d2inv; double d6inv; double d12inv; double esh; double frac; double fvdw; double felec; double nb6; double nb12; double A, B; double q1, q2; 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; const double four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrt (d2); d2inv = dinv * dinv; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = q1 * q2 * esh * dinv * (esh * d2inv + four * c2inv); nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; frac = (felec + fvdw); 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type double CPU CPUPlain ***************************************************************************/ void vpbcforce_cssn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d6; double dinv; double d2inv; double d6inv; double d12inv; double esh; double frac; double fvdw; double felec; double nb6; double nb12; double A, B; double q1, q2; 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; const double four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrt (d2); d2inv = dinv * dinv; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = q1 * q2 * esh * dinv * (esh * d2inv + four * c2inv); nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; frac = (felec + fvdw); 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void pbcforce_cssn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d6; float dinv; float d2inv; float d6inv; float d12inv; float esh; float frac; float fvdw; float felec; float nb6; float nb12; float A, B; float q1, q2; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * c6inv; const float c18inv = c12inv * c6inv; const float one = 1.0; const float four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrtf (d2); d2inv = dinv * dinv; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = q1 * q2 * esh * dinv * (esh * d2inv + four * c2inv); nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; frac = (felec + fvdw); 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type float CPU CPUPlain ***************************************************************************/ void vpbcforce_cssn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d6; float dinv; float d2inv; float d6inv; float d12inv; float esh; float frac; float fvdw; float felec; float nb6; float nb12; float A, B; float q1, q2; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * c6inv; const float c18inv = c12inv * c6inv; const float one = 1.0; const float four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrtf (d2); d2inv = dinv * dinv; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = q1 * q2 * esh * dinv * (esh * d2inv + four * c2inv); nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; frac = (felec + fvdw); 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void pbcforce_csswn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double dinv; double d2inv; double d6inv; double d12inv; double esh; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2inv = 1.0 / c2; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double one = 1.0; const double two = 2.0; const double three = 3.0; const double four = 4.0; const double six_inv = 1.0 / 6.0; const double twelve_inv = 1.0 / 12.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrt (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = q1 * q2 * esh * dinv * (esh * d2inv + four * c2inv); fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } frac = frac + felec; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type double CPU CPUPlain ***************************************************************************/ void vpbcforce_csswn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double dinv; double d2inv; double d6inv; double d12inv; double esh; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2inv = 1.0 / c2; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double one = 1.0; const double two = 2.0; const double three = 3.0; const double four = 4.0; const double six_inv = 1.0 / 6.0; const double twelve_inv = 1.0 / 12.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrt (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = q1 * q2 * esh * dinv * (esh * d2inv + four * c2inv); fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } frac = frac + felec; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void pbcforce_csswn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float dinv; float d2inv; float d6inv; float d12inv; float esh; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float A, B; float q1, q2; const float c2inv = 1.0 / c2; 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrtf (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = q1 * q2 * esh * dinv * (esh * d2inv + four * c2inv); fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } frac = frac + felec; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type float CPU CPUPlain ***************************************************************************/ void vpbcforce_csswn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float dinv; float d2inv; float d6inv; float d12inv; float esh; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float A, B; float q1, q2; const float c2inv = 1.0 / c2; 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrtf (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = q1 * q2 * esh * dinv * (esh * d2inv + four * c2inv); fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } frac = frac + felec; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void pbcforce_cswtn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double dinv; double d2inv; double d6inv; double d12inv; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double two = 2.0; const double three = 3.0; const double four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrt (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; fvdw = A * d12inv - B * d6inv; felec = q1 * q2 * dinv; frac = felec * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - felec * sw1;; frac = frac * c2diffinv * sh1; } frac = frac + fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type double CPU CPUPlain ***************************************************************************/ void vpbcforce_cswtn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double dinv; double d2inv; double d6inv; double d12inv; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double two = 2.0; const double three = 3.0; const double four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrt (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; fvdw = A * d12inv - B * d6inv; felec = q1 * q2 * dinv; frac = felec * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - felec * sw1;; frac = frac * c2diffinv * sh1; } frac = frac + fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void pbcforce_cswtn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float dinv; float d2inv; float d6inv; float d12inv; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float A, B; float q1, q2; const float c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const float two = 2.0; const float three = 3.0; const float four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrtf (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; fvdw = A * d12inv - B * d6inv; felec = q1 * q2 * dinv; frac = felec * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - felec * sw1;; frac = frac * c2diffinv * sh1; } frac = frac + fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type float CPU CPUPlain ***************************************************************************/ void vpbcforce_cswtn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float dinv; float d2inv; float d6inv; float d12inv; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float A, B; float q1, q2; const float c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const float two = 2.0; const float three = 3.0; const float four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrtf (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; fvdw = A * d12inv - B * d6inv; felec = q1 * q2 * dinv; frac = felec * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - felec * sw1;; frac = frac * c2diffinv * sh1; } frac = frac + fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void pbcforce_cswsn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d6; double dinv; double d2inv; double d6inv; double d12inv; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double nb6; double nb12; double A, B; double q1, q2; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * c6inv; const double c18inv = c12inv * c6inv; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double two = 2.0; const double three = 3.0; const double four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrt (d2); d2inv = dinv * dinv; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; felec = q1 * q2 * dinv; frac = felec * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - felec * sw1;; frac = frac * c2diffinv * sh1; } frac = frac + fvdw; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type double CPU CPUPlain ***************************************************************************/ void vpbcforce_cswsn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d6; double dinv; double d2inv; double d6inv; double d12inv; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double nb6; double nb12; double A, B; double q1, q2; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * c6inv; const double c18inv = c12inv * c6inv; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double two = 2.0; const double three = 3.0; const double four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrt (d2); d2inv = dinv * dinv; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; felec = q1 * q2 * dinv; frac = felec * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - felec * sw1;; frac = frac * c2diffinv * sh1; } frac = frac + fvdw; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void pbcforce_cswsn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d6; float dinv; float d2inv; float d6inv; float d12inv; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float nb6; float nb12; float A, B; float q1, q2; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * c6inv; const float c18inv = c12inv * c6inv; const float c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const float two = 2.0; const float three = 3.0; const float four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrtf (d2); d2inv = dinv * dinv; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; felec = q1 * q2 * dinv; frac = felec * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - felec * sw1;; frac = frac * c2diffinv * sh1; } frac = frac + fvdw; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type float CPU CPUPlain ***************************************************************************/ void vpbcforce_cswsn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d6; float dinv; float d2inv; float d6inv; float d12inv; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float nb6; float nb12; float A, B; float q1, q2; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * c6inv; const float c18inv = c12inv * c6inv; const float c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const float two = 2.0; const float three = 3.0; const float four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrtf (d2); d2inv = dinv * dinv; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; felec = q1 * q2 * dinv; frac = felec * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - felec * sw1;; frac = frac * c2diffinv * sh1; } frac = frac + fvdw; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void pbcforce_cswswn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double dinv; double d2inv; double d6inv; double d12inv; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double two = 2.0; const double three = 3.0; const double four = 4.0; const double six_inv = 1.0 / 6.0; const double twelve_inv = 1.0 / 12.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrt (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = q1 * q2 * dinv; fvdw = A * d12inv - B * d6inv; frac = (felec + fvdw) * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv + felec) * sw1; frac = frac * c2diffinv * sh1; } 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type double CPU CPUPlain ***************************************************************************/ void vpbcforce_cswswn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double dinv; double d2inv; double d6inv; double d12inv; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double two = 2.0; const double three = 3.0; const double four = 4.0; const double six_inv = 1.0 / 6.0; const double twelve_inv = 1.0 / 12.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrt (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = q1 * q2 * dinv; fvdw = A * d12inv - B * d6inv; frac = (felec + fvdw) * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv + felec) * sw1; frac = frac * c2diffinv * sh1; } 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void pbcforce_cswswn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float dinv; float d2inv; float d6inv; float d12inv; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float A, B; float q1, q2; const float c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrtf (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = q1 * q2 * dinv; fvdw = A * d12inv - B * d6inv; frac = (felec + fvdw) * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv + felec) * sw1; frac = frac * c2diffinv * sh1; } 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type float CPU CPUPlain ***************************************************************************/ void vpbcforce_cswswn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float dinv; float d2inv; float d6inv; float d12inv; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float A, B; float q1, q2; const float c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; dinv = invsqrtf (d2); d2inv = dinv * dinv; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = q1 * q2 * dinv; fvdw = A * d12inv - B * d6inv; frac = (felec + fvdw) * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv + felec) * sw1; frac = frac * c2diffinv * sh1; } 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void pbcforce_rttn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double frac; double fvdw; double felec; double A, B; double q1, q2; const double one = 1.0; const double two = 2.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = two * q1 * q2 * d2inv; fvdw = A * d12inv - B * d6inv; frac = (felec + fvdw) * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type double CPU CPUPlain ***************************************************************************/ void vpbcforce_rttn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double frac; double fvdw; double felec; double A, B; double q1, q2; const double one = 1.0; const double two = 2.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = two * q1 * q2 * d2inv; fvdw = A * d12inv - B * d6inv; frac = (felec + fvdw) * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void pbcforce_rttn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float frac; float fvdw; float felec; float A, B; float q1, q2; const float one = 1.0; const float two = 2.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = two * q1 * q2 * d2inv; fvdw = A * d12inv - B * d6inv; frac = (felec + fvdw) * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type float CPU CPUPlain ***************************************************************************/ void vpbcforce_rttn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float frac; float fvdw; float felec; float A, B; float q1, q2; const float one = 1.0; const float two = 2.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = two * q1 * q2 * d2inv; fvdw = A * d12inv - B * d6inv; frac = (felec + fvdw) * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void pbcforce_rtsn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d6; double d2inv; double d6inv; double d12inv; double frac; double fvdw; double felec; double nb6; double nb12; double A, B; double q1, q2; 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; const double two = 2.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = two * q1 * q2 * d2inv; nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; frac = felec * d2inv + fvdw; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type double CPU CPUPlain ***************************************************************************/ void vpbcforce_rtsn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d6; double d2inv; double d6inv; double d12inv; double frac; double fvdw; double felec; double nb6; double nb12; double A, B; double q1, q2; 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; const double two = 2.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = two * q1 * q2 * d2inv; nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; frac = felec * d2inv + fvdw; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void pbcforce_rtsn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d6; float d2inv; float d6inv; float d12inv; float frac; float fvdw; float felec; float nb6; float nb12; float A, B; float q1, q2; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * c6inv; const float c18inv = c12inv * c6inv; const float one = 1.0; const float two = 2.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = two * q1 * q2 * d2inv; nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; frac = felec * d2inv + fvdw; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type float CPU CPUPlain ***************************************************************************/ void vpbcforce_rtsn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d6; float d2inv; float d6inv; float d12inv; float frac; float fvdw; float felec; float nb6; float nb12; float A, B; float q1, q2; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * c6inv; const float c18inv = c12inv * c6inv; const float one = 1.0; const float two = 2.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = two * q1 * q2 * d2inv; nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; frac = felec * d2inv + fvdw; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void pbcforce_rtswn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double one = 1.0; const double two = 2.0; const double three = 3.0; const double four = 4.0; const double six_inv = 1.0 / 6.0; const double twelve_inv = 1.0 / 12.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = two * q1 * q2 * d2inv; fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } frac = frac + felec * 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type double CPU CPUPlain ***************************************************************************/ void vpbcforce_rtswn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double one = 1.0; const double two = 2.0; const double three = 3.0; const double four = 4.0; const double six_inv = 1.0 / 6.0; const double twelve_inv = 1.0 / 12.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = two * q1 * q2 * d2inv; fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } frac = frac + felec * 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void pbcforce_rtswn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float A, B; float q1, q2; 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = two * q1 * q2 * d2inv; fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } frac = frac + felec * 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF TRUNC VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type float CPU CPUPlain ***************************************************************************/ void vpbcforce_rtswn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float A, B; float q1, q2; 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = two * q1 * q2 * d2inv; fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } frac = frac + felec * 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void pbcforce_rstn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double esh; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2inv = 1.0 / c2; const double one = 1.0; const double two = 2.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = two * q1 * q2 * esh * d2inv * (esh * d2inv + two * c2inv); fvdw = A * d12inv - B * d6inv; frac = felec + fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type double CPU CPUPlain ***************************************************************************/ void vpbcforce_rstn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double esh; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2inv = 1.0 / c2; const double one = 1.0; const double two = 2.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = two * q1 * q2 * esh * d2inv * (esh * d2inv + two * c2inv); fvdw = A * d12inv - B * d6inv; frac = felec + fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void pbcforce_rstn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float esh; float frac; float fvdw; float felec; float A, B; float q1, q2; const float c2inv = 1.0 / c2; const float one = 1.0; const float two = 2.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = two * q1 * q2 * esh * d2inv * (esh * d2inv + two * c2inv); fvdw = A * d12inv - B * d6inv; frac = felec + fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type float CPU CPUPlain ***************************************************************************/ void vpbcforce_rstn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float esh; float frac; float fvdw; float felec; float A, B; float q1, q2; const float c2inv = 1.0 / c2; const float one = 1.0; const float two = 2.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = two * q1 * q2 * esh * d2inv * (esh * d2inv + two * c2inv); fvdw = A * d12inv - B * d6inv; frac = felec + fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void pbcforce_rssn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d6; double d2inv; double d6inv; double d12inv; double esh; double frac; double fvdw; double felec; double nb6; double nb12; double A, B; double q1, q2; 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; const double two = 2.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = two * q1 * q2 * esh * d2inv * (esh * d2inv + two * c2inv); nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; frac = (felec + fvdw); 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type double CPU CPUPlain ***************************************************************************/ void vpbcforce_rssn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d6; double d2inv; double d6inv; double d12inv; double esh; double frac; double fvdw; double felec; double nb6; double nb12; double A, B; double q1, q2; 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; const double two = 2.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = two * q1 * q2 * esh * d2inv * (esh * d2inv + two * c2inv); nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; frac = (felec + fvdw); 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void pbcforce_rssn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d6; float d2inv; float d6inv; float d12inv; float esh; float frac; float fvdw; float felec; float nb6; float nb12; float A, B; float q1, q2; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * c6inv; const float c18inv = c12inv * c6inv; const float one = 1.0; const float two = 2.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = two * q1 * q2 * esh * d2inv * (esh * d2inv + two * c2inv); nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; frac = (felec + fvdw); 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type float CPU CPUPlain ***************************************************************************/ void vpbcforce_rssn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d6; float d2inv; float d6inv; float d12inv; float esh; float frac; float fvdw; float felec; float nb6; float nb12; float A, B; float q1, q2; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * c6inv; const float c18inv = c12inv * c6inv; const float one = 1.0; const float two = 2.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = two * q1 * q2 * esh * d2inv * (esh * d2inv + two * c2inv); nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; frac = (felec + fvdw); 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void pbcforce_rsswn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double esh; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2inv = 1.0 / c2; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double one = 1.0; const double two = 2.0; const double three = 3.0; const double four = 4.0; const double six_inv = 1.0 / 6.0; const double twelve_inv = 1.0 / 12.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = two * q1 * q2 * esh * d2inv * (esh * d2inv + two * c2inv); fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } frac = frac + felec; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type double CPU CPUPlain ***************************************************************************/ void vpbcforce_rsswn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double esh; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2inv = 1.0 / c2; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double one = 1.0; const double two = 2.0; const double three = 3.0; const double four = 4.0; const double six_inv = 1.0 / 6.0; const double twelve_inv = 1.0 / 12.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = two * q1 * q2 * esh * d2inv * (esh * d2inv + two * c2inv); fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } frac = frac + felec; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void pbcforce_rsswn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float esh; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float A, B; float q1, q2; const float c2inv = 1.0 / c2; 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = two * q1 * q2 * esh * d2inv * (esh * d2inv + two * c2inv); fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } frac = frac + felec; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SHIFT VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type float CPU CPUPlain ***************************************************************************/ void vpbcforce_rsswn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float esh; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float A, B; float q1, q2; const float c2inv = 1.0 / c2; 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; esh = one - d2 * c2inv; felec = two * q1 * q2 * esh * d2inv * (esh * d2inv + two * c2inv); fvdw = A * d12inv - B * d6inv; frac = fvdw * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv) * sw1; frac = frac * c2diffinv * sh1; } frac = frac + felec; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void pbcforce_rswtn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double one = 1.0; const double two = 2.0; const double three = 3.0; const double four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; fvdw = A * d12inv - B * d6inv; felec = two * q1 * q2 * d2inv; frac = felec * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - 0.5 * felec * sw1;; frac = frac * c2diffinv * sh1; } frac = frac + fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type double CPU CPUPlain ***************************************************************************/ void vpbcforce_rswtn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double one = 1.0; const double two = 2.0; const double three = 3.0; const double four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; fvdw = A * d12inv - B * d6inv; felec = two * q1 * q2 * d2inv; frac = felec * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - 0.5 * felec * sw1;; frac = frac * c2diffinv * sh1; } frac = frac + fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void pbcforce_rswtn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float A, B; float q1, q2; 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; fvdw = A * d12inv - B * d6inv; felec = two * q1 * q2 * d2inv; frac = felec * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - 0.5 * felec * sw1;; frac = frac * c2diffinv * sh1; } frac = frac + fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF TRUNC SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type float CPU CPUPlain ***************************************************************************/ void vpbcforce_rswtn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float A, B; float q1, q2; 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; fvdw = A * d12inv - B * d6inv; felec = two * q1 * q2 * d2inv; frac = felec * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - 0.5 * felec * sw1;; frac = frac * c2diffinv * sh1; } frac = frac + fvdw * 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; } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void pbcforce_rswsn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d6; double d2inv; double d6inv; double d12inv; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double nb6; double nb12; double A, B; double q1, q2; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * c6inv; const double c18inv = c12inv * c6inv; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double one = 1.0; const double two = 2.0; const double three = 3.0; const double four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; felec = two * q1 * q2 * d2inv; frac = felec * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - 0.5 * felec * sw1;; frac = frac * c2diffinv * sh1; } frac = frac + fvdw; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type double CPU CPUPlain ***************************************************************************/ void vpbcforce_rswsn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d6; double d2inv; double d6inv; double d12inv; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double nb6; double nb12; double A, B; double q1, q2; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * c6inv; const double c18inv = c12inv * c6inv; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double one = 1.0; const double two = 2.0; const double three = 3.0; const double four = 4.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; felec = two * q1 * q2 * d2inv; frac = felec * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - 0.5 * felec * sw1;; frac = frac * c2diffinv * sh1; } frac = frac + fvdw; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void pbcforce_rswsn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d6; float d2inv; float d6inv; float d12inv; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float nb6; float nb12; float A, B; float q1, q2; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * c6inv; const float c18inv = c12inv * c6inv; 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; felec = two * q1 * q2 * d2inv; frac = felec * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - 0.5 * felec * sw1;; frac = frac * c2diffinv * sh1; } frac = frac + fvdw; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF SHIFT SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type float CPU CPUPlain ***************************************************************************/ void vpbcforce_rswsn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d6; float d2inv; float d6inv; float d12inv; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float nb6; float nb12; float A, B; float q1, q2; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * c6inv; const float c18inv = c12inv * c6inv; 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6 = d2 * d2 * d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; nb6 = B * (d6inv - d6 * c12inv);; nb12 = A * (d12inv - d6 * c18inv); fvdw = (nb12 - nb6) * d2inv; felec = two * q1 * q2 * d2inv; frac = felec * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - 0.5 * felec * sw1;; frac = frac * c2diffinv * sh1; } frac = frac + fvdw; 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type double CPU CPUPlain ***************************************************************************/ void pbcforce_rswswn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double one = 1.0; const double two = 2.0; const double three = 3.0; const double four = 4.0; const double six_inv = 1.0 / 6.0; const double twelve_inv = 1.0 / 12.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = two * q1 * q2 * d2inv; fvdw = A * d12inv - B * d6inv; frac = (felec + fvdw) * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv + 0.5 * felec) * sw1; frac = frac * c2diffinv * sh1; } 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type double CPU CPUPlain ***************************************************************************/ void vpbcforce_rswswn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, double *force, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; double fracX; double fracY; double fracZ; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double tx, ty, tz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double sh1; double sh2; double sw; double sw1; double frac; double fvdw; double felec; double A, B; double q1, q2; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double one = 1.0; const double two = 2.0; const double three = 3.0; const double four = 4.0; const double six_inv = 1.0 / 6.0; const double twelve_inv = 1.0 / 12.0; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = two * q1 * q2 * d2inv; fvdw = A * d12inv - B * d6inv; frac = (felec + fvdw) * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv + 0.5 * felec) * sw1; frac = frac * c2diffinv * sh1; } 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial no Float type float CPU CPUPlain ***************************************************************************/ void pbcforce_rswswn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float A, B; float q1, q2; 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = two * q1 * q2 * d2inv; fvdw = A * d12inv - B * d6inv; frac = (felec + fvdw) * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv + 0.5 * felec) * sw1; frac = frac * c2diffinv * sh1; } 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; } } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional RDIE Elec CUTOFF SWITCH VDW Functional LJ VDW CUTOFF SWITCH SOLVATION NONE Sol Functional SolvNone Geometry PBC Compute virial yes Float type float CPU CPUPlain ***************************************************************************/ void vpbcforce_rswswn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, float *force, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data) { int i; int j; int f; int fpos; int s; int spos; int bpos; int b1; int b2; int tc1; int tc2; int data_pos; float fracX; float fracY; float fracZ; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float tx, ty, tz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float sh1; float sh2; float sw; float sw1; float frac; float fvdw; float felec; float A, B; float q1, q2; 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; /* Start outer loop over neighborlists */ for (i = 0; (i < natoms); i++) { /* Initialize outer atom */ f = first[i]; fpos = COOR_DIM * f; bpos = 3 * box[i]; /* Load Shift vectors */ shX = sh_coor[COOR_DIM * i]; shY = sh_coor[COOR_DIM * i + 1]; shZ = sh_coor[COOR_DIM * i + 2]; ix = coor[fpos] + shX; iy = coor[fpos + 1] + shY; iz = coor[fpos + 2] + shZ; /* Load limits for loop over neighbors */ b1 = boundary[2 * i]; b2 = boundary[2 * i + 1]; /* Zero forces */ fracX = 0; fracY = 0; fracZ = 0; /* Load pars */ q1 = charge[f]; tc1 = type_code[f]; /* Inner loop */ for (j = b1; (j < b2); j++) { /* Load coor second */ s = second[j]; spos = COOR_DIM * s; jx = coor[spos]; jy = coor[spos + 1]; jz = coor[spos + 2]; /* Compute distances */ dx = ix - jx; dy = iy - jy; dz = iz - jz; d2 = dx * dx + dy * dy + dz * dz; /* Compute force */ if (d2 < c2) { q2 = charge[s]; tc2 = type_code[s]; data_pos = 4 * (type_size * tc1 + tc2); A = vdw_data[data_pos]; B = vdw_data[data_pos + 1]; d2inv = one / d2; d6inv = d2inv * d2inv * d2inv; d12inv = d6inv * d6inv; felec = two * q1 * q2 * d2inv; fvdw = A * d12inv - B * d6inv; frac = (felec + fvdw) * d2inv; if (d2 > c_on2) { sh1 = c2 - d2; sh2 = (c2 + two * d2 - three * c_on2); sw = sh1 * sh2; sw1 = four * (sh1 - sh2); frac = frac * sw - (twelve_inv * A * d12inv - six_inv * B * d6inv + 0.5 * felec) * sw1; frac = frac * c2diffinv * sh1; } 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; } } /* Assign to first */ force[fpos] = force[fpos] + fracX; force[fpos + 1] = force[fpos + 1] + fracY; force[fpos + 2] = force[fpos + 2] + fracZ; fvir[bpos] = fvir[bpos] + fracX; fvir[bpos + 1] = fvir[bpos + 1] + fracY; fvir[bpos + 2] = fvir[bpos + 2] + fracZ; } }