/*************************************************************************** enefunc.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 energy_xxtn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double c2, const double c_on2, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double d2; double d2inv; double d6inv; double d12inv; double A, B; double evdw = 0; 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]; /* 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; evdw = evdw + A * d12inv - B * d6inv; } } *ene_vdw = *ene_vdw + evdw; } /*************************************************************************** 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 energy_xxtn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float c2, const float c_on2, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float d2; float d2inv; float d6inv; float d12inv; float A, B; float evdw = 0; 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]; /* 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; evdw = evdw + A * d12inv - B * d6inv; } } *ene_vdw = *ene_vdw + evdw; } /*************************************************************************** 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 energy_xxsn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double c2, const double c_on2, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double d2; double d6; double d2inv; double d6inv; double d12inv; double vsh; double nb6; double nb12; double A, B; double evdw = 0; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * 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]; /* 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; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; } /*************************************************************************** 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 energy_xxsn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float c2, const float c_on2, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float d2; float d6; float d2inv; float d6inv; float d12inv; float vsh; float nb6; float nb12; float A, B; float evdw = 0; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * 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]; /* 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; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; } /*************************************************************************** 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 energy_xxswn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double c2, const double c_on2, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double d2; double d2inv; double d6inv; double d12inv; double sw; double A, B; double evdw = 0; 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; /* 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]; /* 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; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; } /*************************************************************************** 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 energy_xxswn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float c2, const float c_on2, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float d2; float d2inv; float d6inv; float d12inv; float sw; float A, B; float evdw = 0; 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; /* 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]; /* 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; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; } /*************************************************************************** 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 pbcenergy_xxtn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double A, B; double evdw = 0; 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]; /* 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; evdw = evdw + A * d12inv - B * d6inv; } } *ene_vdw = *ene_vdw + evdw; } /*************************************************************************** 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 vpbcenergy_xxtn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const int *type_code, const int type_size, double *fvir, const double *vdw_data, double *ene_vdw, double *ene_cul) { 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 dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double A, B; double evdw = 0; 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]; /* 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; evdw = evdw + A * d12inv - B * d6inv; } } *ene_vdw = *ene_vdw + evdw; } /*************************************************************************** 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 pbcenergy_xxtn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float A, B; float evdw = 0; 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]; /* 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; evdw = evdw + A * d12inv - B * d6inv; } } *ene_vdw = *ene_vdw + evdw; } /*************************************************************************** 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 vpbcenergy_xxtn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const int *type_code, const int type_size, float *fvir, const float *vdw_data, float *ene_vdw, float *ene_cul) { 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 dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float A, B; float evdw = 0; 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]; /* 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; evdw = evdw + A * d12inv - B * d6inv; } } *ene_vdw = *ene_vdw + evdw; } /*************************************************************************** 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 pbcenergy_xxsn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d6; double d2inv; double d6inv; double d12inv; double vsh; double nb6; double nb12; double A, B; double evdw = 0; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * 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]; /* 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; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; } /*************************************************************************** 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 vpbcenergy_xxsn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const int *type_code, const int type_size, double *fvir, const double *vdw_data, double *ene_vdw, double *ene_cul) { 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 dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d6; double d2inv; double d6inv; double d12inv; double vsh; double nb6; double nb12; double A, B; double evdw = 0; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * 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]; /* 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; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; } /*************************************************************************** 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 pbcenergy_xxsn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d6; float d2inv; float d6inv; float d12inv; float vsh; float nb6; float nb12; float A, B; float evdw = 0; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * 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]; /* 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; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; } /*************************************************************************** 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 vpbcenergy_xxsn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const int *type_code, const int type_size, float *fvir, const float *vdw_data, float *ene_vdw, float *ene_cul) { 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 dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d6; float d2inv; float d6inv; float d12inv; float vsh; float nb6; float nb12; float A, B; float evdw = 0; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * 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]; /* 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; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; } /*************************************************************************** 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 pbcenergy_xxswn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double sw; double A, B; double evdw = 0; 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; /* 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]; /* 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; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; } /*************************************************************************** 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 vpbcenergy_xxswn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const int *type_code, const int type_size, double *fvir, const double *vdw_data, double *ene_vdw, double *ene_cul) { 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 dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double sw; double A, B; double evdw = 0; 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; /* 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]; /* 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; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; } /*************************************************************************** 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 pbcenergy_xxswn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float sw; float A, B; float evdw = 0; 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; /* 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]; /* 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; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; } /*************************************************************************** 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 vpbcenergy_xxswn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const int *type_code, const int type_size, float *fvir, const float *vdw_data, float *ene_vdw, float *ene_cul) { 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 dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float sw; float A, B; float evdw = 0; 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; /* 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]; /* 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; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE 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 energy_cttn_d(const int * first, const int * second, const int * boundarry, const int natoms, const double * coor, const double * charge, const int * type_code, const int type_size, const double * vdw_data, const double * sdata, double * ene_vdw, double * ene_cul){ int f; int fpos; int s; int spos; double dx,dy,dz; double ix,iy,iz; double jx,jy,jz; double d2; double d; double dinv; double dt; double A,B,q1,q2; double eps,eps2,eps3; int tc1,tc2; int data_pos; int spline_pos; int n0; double nb6; double nb12; double evdw =0, ecul=0; const double one = 1.0; const double two = 2.0; const double three = 3.0; const double density = 2000; /* const double h = (double)1/(double)density; */ /* const double hinv = 1/h; */ /* const int st = (int)hinv; */ int i,j; for(i = 0;ic2) continue; { //compute energy 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]; //now energy dinv = invsqrt(d2); d = d2*dinv; dt = density*d; x86trunc(dt,n0); spline_pos = 12*n0; eps = dt-n0; eps2 = eps*eps; eps3 = eps2*eps; ecul = ecul + q1*q2*(sdata[spline_pos] + eps*sdata[spline_pos+1]+ eps2*sdata[spline_pos+2] + eps3*sdata[spline_pos+3]); nb6 = B*(sdata[spline_pos+4] + eps*sdata[spline_pos+5]+ eps2*sdata[spline_pos+6] + eps3*sdata[spline_pos+7]); nb12 = A*(sdata[spline_pos+8] + eps*sdata[spline_pos+9]+ eps2*sdata[spline_pos+10] + eps3*sdata[spline_pos+11]); evdw = evdw + nb12-nb6; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul+ ecul; } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE 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 energy_cttn_f(const int * first, const int * second, const int * boundarry, const int natoms, const float * coor, const float * charge, const int * type_code, const int type_size, const float * vdw_data, const float * sdata, float * ene_vdw, float * ene_cul){ int f; int fpos; int s; int spos; float dx,dy,dz; float ix,iy,iz; float jx,jy,jz; float d2; float d; float dinv; float dt; float A,B,q1,q2; float eps,eps2,eps3; int tc1,tc2; int data_pos; int spline_pos; int n0; float nb6; float nb12; float evdw =0, ecul=0; const float one = 1.0; const float two = 2.0; const float three = 3.0; const float density = 500; /* const float h = (float)1/(float)density; */ /* const float hinv = 1/h; */ /* const int st = (int)hinv; */ int i,j; for(i = 0;ic2) continue; { //compute energy 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]; //now energy dinv = invsqrt(d2); d = d2*dinv; dt = density*d; x86trunc(dt,n0); //n0 = (int)dt; spline_pos = 12*n0; eps = dt-n0; eps2 = eps*eps; eps3 = eps2*eps; ecul = ecul + q1*q2*(sdata[spline_pos] + eps*sdata[spline_pos+1]+ eps2*sdata[spline_pos+2] + eps3*sdata[spline_pos+3]); spline_pos = spline_pos + 4; nb6 = B*(sdata[spline_pos] + eps*sdata[spline_pos+1]+ eps2*sdata[spline_pos+2] + eps3*sdata[spline_pos+3]); spline_pos = spline_pos + 4; nb12 = A*(sdata[spline_pos] + eps*sdata[spline_pos+1]+ eps2*sdata[spline_pos+2] + eps3*sdata[spline_pos+3]); evdw = evdw + nb12-nb6; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul+ ecul; } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE 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 energy_ctsn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double d2; double d6; double dinv; double d2inv; double d6inv; double d12inv; double vsh; double nb6; double nb12; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * 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]; /* 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; ecul = ecul + q1 * q2 * dinv; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** IMPLEMENTATION OF NB ENERGY Elec Functional CDIE 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 energy_ctsn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float d2; float d6; float dinv; float d2inv; float d6inv; float d12inv; float vsh; float nb6; float nb12; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * 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]; /* 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; ecul = ecul + q1 * q2 * dinv; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 double CPU CPUPlain ***************************************************************************/ void energy_ctswn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double d2; double dinv; double d2inv; double d6inv; double d12inv; double sw; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double two = 2.0; const double three = 3.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]; /* 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; ecul = ecul + q1 * q2 * dinv; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_ctswn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float d2; float dinv; float d2inv; float d6inv; float d12inv; float sw; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const float two = 2.0; const float three = 3.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]; /* 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; ecul = ecul + q1 * q2 * dinv; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_cstn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double d2; double dinv; double d2inv; double d6inv; double d12inv; double esh; double esh2; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2inv = 1.0 / c2; 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * dinv; evdw = evdw + A * d12inv - B * d6inv; } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_cstn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float d2; float dinv; float d2inv; float d6inv; float d12inv; float esh; float esh2; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2inv = 1.0 / c2; 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * dinv; evdw = evdw + A * d12inv - B * d6inv; } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_cssn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double d2; double d6; double dinv; double d2inv; double d6inv; double d12inv; double vsh; double esh; double esh2; double nb6; double nb12; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * dinv; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_cssn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float d2; float d6; float dinv; float d2inv; float d6inv; float d12inv; float vsh; float esh; float esh2; float nb6; float nb12; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * dinv; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_csswn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double d2; double dinv; double d2inv; double d6inv; double d12inv; double esh; double esh2; double sw; double A, B; double q1, q2; double evdw = 0; double ecul = 0; 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; /* 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * dinv; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_csswn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float d2; float dinv; float d2inv; float d6inv; float d12inv; float esh; float esh2; float sw; float A, B; float q1, q2; float evdw = 0; float ecul = 0; 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; /* 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * dinv; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_cswtn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double d2; double dinv; double d2inv; double d6inv; double d12inv; double sw; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double two = 2.0; const double three = 3.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]; /* 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; evdw = evdw + A * d12inv - B * d6inv; if (d2 < c_on2) { ecul = ecul + q1 * q2 * dinv; } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * dinv * sw; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_cswtn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float d2; float dinv; float d2inv; float d6inv; float d12inv; float sw; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const float two = 2.0; const float three = 3.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]; /* 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; evdw = evdw + A * d12inv - B * d6inv; if (d2 < c_on2) { ecul = ecul + q1 * q2 * dinv; } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * dinv * sw; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_cswsn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double d2; double d6; double dinv; double d2inv; double d6inv; double d12inv; double vsh; double sw; double nb6; double nb12; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * 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; /* 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]; /* 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; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; if (d2 < c_on2) { ecul = ecul + q1 * q2 * dinv; } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * dinv * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_cswsn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float d2; float d6; float dinv; float d2inv; float d6inv; float d12inv; float vsh; float sw; float nb6; float nb12; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * 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; /* 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]; /* 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; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; if (d2 < c_on2) { ecul = ecul + q1 * q2 * dinv; } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * dinv * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_cswswn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double d2; double dinv; double d2inv; double d6inv; double d12inv; double sw; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double two = 2.0; const double three = 3.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]; /* 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; if (d2 < c_on2) { ecul = ecul + q1 * q2 * dinv; evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * dinv * sw; evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_cswswn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float d2; float dinv; float d2inv; float d6inv; float d12inv; float sw; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const float two = 2.0; const float three = 3.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]; /* 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; if (d2 < c_on2) { ecul = ecul + q1 * q2 * dinv; evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * dinv * sw; evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_rttn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double d2; double d2inv; double d6inv; double d12inv; double A, B; double q1, q2; double evdw = 0; double ecul = 0; 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]; /* 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; ecul = ecul + q1 * q2 * d2inv; evdw = evdw + A * d12inv - B * d6inv; } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_rttn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float d2; float d2inv; float d6inv; float d12inv; float A, B; float q1, q2; float evdw = 0; float ecul = 0; 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]; /* 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; ecul = ecul + q1 * q2 * d2inv; evdw = evdw + A * d12inv - B * d6inv; } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_rtsn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double d2; double d6; double d2inv; double d6inv; double d12inv; double vsh; double nb6; double nb12; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * 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]; /* 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; ecul = ecul + q1 * q2 * d2inv; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_rtsn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float d2; float d6; float d2inv; float d6inv; float d12inv; float vsh; float nb6; float nb12; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * 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]; /* 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; ecul = ecul + q1 * q2 * d2inv; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_rtswn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double d2; double d2inv; double d6inv; double d12inv; double sw; double A, B; double q1, q2; double evdw = 0; double ecul = 0; 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; /* 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]; /* 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; ecul = ecul + q1 * q2 * d2inv; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_rtswn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float d2; float d2inv; float d6inv; float d12inv; float sw; float A, B; float q1, q2; float evdw = 0; float ecul = 0; 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; /* 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]; /* 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; ecul = ecul + q1 * q2 * d2inv; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_rstn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double d2; double d2inv; double d6inv; double d12inv; double esh; double esh2; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2inv = 1.0 / c2; 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * d2inv; evdw = evdw + A * d12inv - B * d6inv; } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_rstn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float d2; float d2inv; float d6inv; float d12inv; float esh; float esh2; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2inv = 1.0 / c2; 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * d2inv; evdw = evdw + A * d12inv - B * d6inv; } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_rssn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double d2; double d6; double d2inv; double d6inv; double d12inv; double vsh; double esh; double esh2; double nb6; double nb12; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * d2inv; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_rssn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float d2; float d6; float d2inv; float d6inv; float d12inv; float vsh; float esh; float esh2; float nb6; float nb12; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * d2inv; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_rsswn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double d2; double d2inv; double d6inv; double d12inv; double esh; double esh2; double sw; double A, B; double q1, q2; double evdw = 0; double ecul = 0; 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; /* 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * d2inv; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_rsswn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float d2; float d2inv; float d6inv; float d12inv; float esh; float esh2; float sw; float A, B; float q1, q2; float evdw = 0; float ecul = 0; 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; /* 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * d2inv; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_rswtn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double d2; double d2inv; double d6inv; double d12inv; double sw; double A, B; double q1, q2; double evdw = 0; double ecul = 0; 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; /* 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]; /* 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; evdw = evdw + A * d12inv - B * d6inv; if (d2 < c_on2) { ecul = ecul + q1 * q2 * d2inv; } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * d2inv * sw; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_rswtn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float d2; float d2inv; float d6inv; float d12inv; float sw; float A, B; float q1, q2; float evdw = 0; float ecul = 0; 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; /* 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]; /* 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; evdw = evdw + A * d12inv - B * d6inv; if (d2 < c_on2) { ecul = ecul + q1 * q2 * d2inv; } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * d2inv * sw; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_rswsn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double d2; double d6; double d2inv; double d6inv; double d12inv; double vsh; double sw; double nb6; double nb12; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * 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; /* 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]; /* 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; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; if (d2 < c_on2) { ecul = ecul + q1 * q2 * d2inv; } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * d2inv * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_rswsn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float d2; float d6; float d2inv; float d6inv; float d12inv; float vsh; float sw; float nb6; float nb12; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * 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; /* 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]; /* 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; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; if (d2 < c_on2) { ecul = ecul + q1 * q2 * d2inv; } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * d2inv * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_rswswn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double d2; double d2inv; double d6inv; double d12inv; double sw; double A, B; double q1, q2; double evdw = 0; double ecul = 0; 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; /* 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]; /* 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; if (d2 < c_on2) { ecul = ecul + q1 * q2 * d2inv; evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * d2inv * sw; evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 energy_rswswn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float d2; float d2inv; float d6inv; float d12inv; float sw; float A, B; float q1, q2; float evdw = 0; float ecul = 0; 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; /* 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]; /* 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; if (d2 < c_on2) { ecul = ecul + q1 * q2 * d2inv; evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * d2inv * sw; evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_cttn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double dinv; double d2inv; double d6inv; double d12inv; double A, B; double q1, q2; double evdw = 0; double ecul = 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]; /* 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; ecul = ecul + q1 * q2 * dinv; evdw = evdw + A * d12inv - B * d6inv; } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_cttn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data, double *ene_vdw, double *ene_cul) { 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 dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double dinv; double d2inv; double d6inv; double d12inv; double A, B; double q1, q2; double evdw = 0; double ecul = 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]; /* 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; ecul = ecul + q1 * q2 * dinv; evdw = evdw + A * d12inv - B * d6inv; } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_cttn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float dinv; float d2inv; float d6inv; float d12inv; float A, B; float q1, q2; float evdw = 0; float ecul = 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]; /* 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; ecul = ecul + q1 * q2 * dinv; evdw = evdw + A * d12inv - B * d6inv; } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_cttn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data, float *ene_vdw, float *ene_cul) { 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 dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float dinv; float d2inv; float d6inv; float d12inv; float A, B; float q1, q2; float evdw = 0; float ecul = 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]; /* 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; ecul = ecul + q1 * q2 * dinv; evdw = evdw + A * d12inv - B * d6inv; } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_ctsn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d6; double dinv; double d2inv; double d6inv; double d12inv; double vsh; double nb6; double nb12; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * 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]; /* 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; ecul = ecul + q1 * q2 * dinv; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_ctsn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data, double *ene_vdw, double *ene_cul) { 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 dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d6; double dinv; double d2inv; double d6inv; double d12inv; double vsh; double nb6; double nb12; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * 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]; /* 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; ecul = ecul + q1 * q2 * dinv; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_ctsn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d6; float dinv; float d2inv; float d6inv; float d12inv; float vsh; float nb6; float nb12; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * 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]; /* 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; ecul = ecul + q1 * q2 * dinv; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_ctsn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data, float *ene_vdw, float *ene_cul) { 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 dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d6; float dinv; float d2inv; float d6inv; float d12inv; float vsh; float nb6; float nb12; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * 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]; /* 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; ecul = ecul + q1 * q2 * dinv; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_ctswn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double dinv; double d2inv; double d6inv; double d12inv; double sw; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double two = 2.0; const double three = 3.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]; /* 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; ecul = ecul + q1 * q2 * dinv; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_ctswn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data, double *ene_vdw, double *ene_cul) { 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 dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double dinv; double d2inv; double d6inv; double d12inv; double sw; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double two = 2.0; const double three = 3.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]; /* 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; ecul = ecul + q1 * q2 * dinv; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_ctswn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float dinv; float d2inv; float d6inv; float d12inv; float sw; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const float two = 2.0; const float three = 3.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]; /* 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; ecul = ecul + q1 * q2 * dinv; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_ctswn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data, float *ene_vdw, float *ene_cul) { 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 dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float dinv; float d2inv; float d6inv; float d12inv; float sw; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const float two = 2.0; const float three = 3.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]; /* 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; ecul = ecul + q1 * q2 * dinv; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_cstn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double dinv; double d2inv; double d6inv; double d12inv; double esh; double esh2; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2inv = 1.0 / c2; 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * dinv; evdw = evdw + A * d12inv - B * d6inv; } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_cstn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data, double *ene_vdw, double *ene_cul) { 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 dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double dinv; double d2inv; double d6inv; double d12inv; double esh; double esh2; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2inv = 1.0 / c2; 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * dinv; evdw = evdw + A * d12inv - B * d6inv; } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_cstn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float dinv; float d2inv; float d6inv; float d12inv; float esh; float esh2; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2inv = 1.0 / c2; 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * dinv; evdw = evdw + A * d12inv - B * d6inv; } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_cstn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data, float *ene_vdw, float *ene_cul) { 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 dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float dinv; float d2inv; float d6inv; float d12inv; float esh; float esh2; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2inv = 1.0 / c2; 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * dinv; evdw = evdw + A * d12inv - B * d6inv; } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_cssn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d6; double dinv; double d2inv; double d6inv; double d12inv; double vsh; double esh; double esh2; double nb6; double nb12; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * dinv; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_cssn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data, double *ene_vdw, double *ene_cul) { 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 dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d6; double dinv; double d2inv; double d6inv; double d12inv; double vsh; double esh; double esh2; double nb6; double nb12; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * dinv; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_cssn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d6; float dinv; float d2inv; float d6inv; float d12inv; float vsh; float esh; float esh2; float nb6; float nb12; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * dinv; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_cssn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data, float *ene_vdw, float *ene_cul) { 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 dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d6; float dinv; float d2inv; float d6inv; float d12inv; float vsh; float esh; float esh2; float nb6; float nb12; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * dinv; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_csswn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double dinv; double d2inv; double d6inv; double d12inv; double esh; double esh2; double sw; double A, B; double q1, q2; double evdw = 0; double ecul = 0; 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; /* 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * dinv; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_csswn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data, double *ene_vdw, double *ene_cul) { 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 dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double dinv; double d2inv; double d6inv; double d12inv; double esh; double esh2; double sw; double A, B; double q1, q2; double evdw = 0; double ecul = 0; 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; /* 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * dinv; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_csswn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float dinv; float d2inv; float d6inv; float d12inv; float esh; float esh2; float sw; float A, B; float q1, q2; float evdw = 0; float ecul = 0; 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; /* 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * dinv; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_csswn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data, float *ene_vdw, float *ene_cul) { 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 dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float dinv; float d2inv; float d6inv; float d12inv; float esh; float esh2; float sw; float A, B; float q1, q2; float evdw = 0; float ecul = 0; 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; /* 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * dinv; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_cswtn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double dinv; double d2inv; double d6inv; double d12inv; double sw; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double two = 2.0; const double three = 3.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]; /* 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; evdw = evdw + A * d12inv - B * d6inv; if (d2 < c_on2) { ecul = ecul + q1 * q2 * dinv; } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * dinv * sw; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_cswtn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data, double *ene_vdw, double *ene_cul) { 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 dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double dinv; double d2inv; double d6inv; double d12inv; double sw; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double two = 2.0; const double three = 3.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]; /* 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; evdw = evdw + A * d12inv - B * d6inv; if (d2 < c_on2) { ecul = ecul + q1 * q2 * dinv; } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * dinv * sw; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_cswtn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float dinv; float d2inv; float d6inv; float d12inv; float sw; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const float two = 2.0; const float three = 3.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]; /* 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; evdw = evdw + A * d12inv - B * d6inv; if (d2 < c_on2) { ecul = ecul + q1 * q2 * dinv; } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * dinv * sw; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_cswtn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data, float *ene_vdw, float *ene_cul) { 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 dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float dinv; float d2inv; float d6inv; float d12inv; float sw; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const float two = 2.0; const float three = 3.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]; /* 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; evdw = evdw + A * d12inv - B * d6inv; if (d2 < c_on2) { ecul = ecul + q1 * q2 * dinv; } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * dinv * sw; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_cswsn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d6; double dinv; double d2inv; double d6inv; double d12inv; double vsh; double sw; double nb6; double nb12; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * 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; /* 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]; /* 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; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; if (d2 < c_on2) { ecul = ecul + q1 * q2 * dinv; } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * dinv * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_cswsn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data, double *ene_vdw, double *ene_cul) { 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 dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d6; double dinv; double d2inv; double d6inv; double d12inv; double vsh; double sw; double nb6; double nb12; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * 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; /* 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]; /* 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; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; if (d2 < c_on2) { ecul = ecul + q1 * q2 * dinv; } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * dinv * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_cswsn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d6; float dinv; float d2inv; float d6inv; float d12inv; float vsh; float sw; float nb6; float nb12; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * 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; /* 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]; /* 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; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; if (d2 < c_on2) { ecul = ecul + q1 * q2 * dinv; } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * dinv * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_cswsn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data, float *ene_vdw, float *ene_cul) { 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 dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d6; float dinv; float d2inv; float d6inv; float d12inv; float vsh; float sw; float nb6; float nb12; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * 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; /* 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]; /* 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; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; if (d2 < c_on2) { ecul = ecul + q1 * q2 * dinv; } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * dinv * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_cswswn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double dinv; double d2inv; double d6inv; double d12inv; double sw; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double two = 2.0; const double three = 3.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]; /* 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; if (d2 < c_on2) { ecul = ecul + q1 * q2 * dinv; evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * dinv * sw; evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_cswswn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data, double *ene_vdw, double *ene_cul) { 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 dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double dinv; double d2inv; double d6inv; double d12inv; double sw; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const double two = 2.0; const double three = 3.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]; /* 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; if (d2 < c_on2) { ecul = ecul + q1 * q2 * dinv; evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * dinv * sw; evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_cswswn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float dinv; float d2inv; float d6inv; float d12inv; float sw; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const float two = 2.0; const float three = 3.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]; /* 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; if (d2 < c_on2) { ecul = ecul + q1 * q2 * dinv; evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * dinv * sw; evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_cswswn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data, float *ene_vdw, float *ene_cul) { 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 dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float dinv; float d2inv; float d6inv; float d12inv; float sw; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2diffinv = 1.0 / ((c2 - c_on2) * (c2 - c_on2) * (c2 - c_on2)); const float two = 2.0; const float three = 3.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]; /* 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; if (d2 < c_on2) { ecul = ecul + q1 * q2 * dinv; evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * dinv * sw; evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_rttn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double A, B; double q1, q2; double evdw = 0; double ecul = 0; 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]; /* 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; ecul = ecul + q1 * q2 * d2inv; evdw = evdw + A * d12inv - B * d6inv; } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_rttn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data, double *ene_vdw, double *ene_cul) { 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 dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double A, B; double q1, q2; double evdw = 0; double ecul = 0; 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]; /* 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; ecul = ecul + q1 * q2 * d2inv; evdw = evdw + A * d12inv - B * d6inv; } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_rttn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float A, B; float q1, q2; float evdw = 0; float ecul = 0; 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]; /* 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; ecul = ecul + q1 * q2 * d2inv; evdw = evdw + A * d12inv - B * d6inv; } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_rttn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data, float *ene_vdw, float *ene_cul) { 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 dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float A, B; float q1, q2; float evdw = 0; float ecul = 0; 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]; /* 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; ecul = ecul + q1 * q2 * d2inv; evdw = evdw + A * d12inv - B * d6inv; } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_rtsn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d6; double d2inv; double d6inv; double d12inv; double vsh; double nb6; double nb12; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * 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]; /* 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; ecul = ecul + q1 * q2 * d2inv; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_rtsn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data, double *ene_vdw, double *ene_cul) { 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 dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d6; double d2inv; double d6inv; double d12inv; double vsh; double nb6; double nb12; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * 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]; /* 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; ecul = ecul + q1 * q2 * d2inv; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_rtsn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d6; float d2inv; float d6inv; float d12inv; float vsh; float nb6; float nb12; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * 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]; /* 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; ecul = ecul + q1 * q2 * d2inv; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_rtsn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data, float *ene_vdw, float *ene_cul) { 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 dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d6; float d2inv; float d6inv; float d12inv; float vsh; float nb6; float nb12; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * 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]; /* 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; ecul = ecul + q1 * q2 * d2inv; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_rtswn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double sw; double A, B; double q1, q2; double evdw = 0; double ecul = 0; 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; /* 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]; /* 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; ecul = ecul + q1 * q2 * d2inv; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_rtswn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data, double *ene_vdw, double *ene_cul) { 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 dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double sw; double A, B; double q1, q2; double evdw = 0; double ecul = 0; 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; /* 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]; /* 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; ecul = ecul + q1 * q2 * d2inv; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_rtswn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float sw; float A, B; float q1, q2; float evdw = 0; float ecul = 0; 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; /* 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]; /* 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; ecul = ecul + q1 * q2 * d2inv; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_rtswn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data, float *ene_vdw, float *ene_cul) { 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 dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float sw; float A, B; float q1, q2; float evdw = 0; float ecul = 0; 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; /* 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]; /* 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; ecul = ecul + q1 * q2 * d2inv; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_rstn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double esh; double esh2; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2inv = 1.0 / c2; 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * d2inv; evdw = evdw + A * d12inv - B * d6inv; } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_rstn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data, double *ene_vdw, double *ene_cul) { 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 dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double esh; double esh2; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2inv = 1.0 / c2; 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * d2inv; evdw = evdw + A * d12inv - B * d6inv; } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_rstn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float esh; float esh2; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2inv = 1.0 / c2; 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * d2inv; evdw = evdw + A * d12inv - B * d6inv; } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_rstn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data, float *ene_vdw, float *ene_cul) { 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 dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float esh; float esh2; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2inv = 1.0 / c2; 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * d2inv; evdw = evdw + A * d12inv - B * d6inv; } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_rssn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d6; double d2inv; double d6inv; double d12inv; double vsh; double esh; double esh2; double nb6; double nb12; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * d2inv; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_rssn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data, double *ene_vdw, double *ene_cul) { 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 dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d6; double d2inv; double d6inv; double d12inv; double vsh; double esh; double esh2; double nb6; double nb12; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * d2inv; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_rssn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d6; float d2inv; float d6inv; float d12inv; float vsh; float esh; float esh2; float nb6; float nb12; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * d2inv; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_rssn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data, float *ene_vdw, float *ene_cul) { 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 dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d6; float d2inv; float d6inv; float d12inv; float vsh; float esh; float esh2; float nb6; float nb12; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * d2inv; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_rsswn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double esh; double esh2; double sw; double A, B; double q1, q2; double evdw = 0; double ecul = 0; 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; /* 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * d2inv; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_rsswn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data, double *ene_vdw, double *ene_cul) { 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 dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double esh; double esh2; double sw; double A, B; double q1, q2; double evdw = 0; double ecul = 0; 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; /* 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * d2inv; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_rsswn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float esh; float esh2; float sw; float A, B; float q1, q2; float evdw = 0; float ecul = 0; 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; /* 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * d2inv; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_rsswn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data, float *ene_vdw, float *ene_cul) { 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 dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float esh; float esh2; float sw; float A, B; float q1, q2; float evdw = 0; float ecul = 0; 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; /* 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]; /* 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; esh2 = esh * esh; ecul = ecul + q1 * q2 * esh2 * d2inv; if (d2 < c_on2) { evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_rswtn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double sw; double A, B; double q1, q2; double evdw = 0; double ecul = 0; 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; /* 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]; /* 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; evdw = evdw + A * d12inv - B * d6inv; if (d2 < c_on2) { ecul = ecul + q1 * q2 * d2inv; } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * d2inv * sw; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_rswtn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data, double *ene_vdw, double *ene_cul) { 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 dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double sw; double A, B; double q1, q2; double evdw = 0; double ecul = 0; 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; /* 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]; /* 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; evdw = evdw + A * d12inv - B * d6inv; if (d2 < c_on2) { ecul = ecul + q1 * q2 * d2inv; } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * d2inv * sw; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_rswtn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float sw; float A, B; float q1, q2; float evdw = 0; float ecul = 0; 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; /* 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]; /* 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; evdw = evdw + A * d12inv - B * d6inv; if (d2 < c_on2) { ecul = ecul + q1 * q2 * d2inv; } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * d2inv * sw; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_rswtn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data, float *ene_vdw, float *ene_cul) { 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 dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float sw; float A, B; float q1, q2; float evdw = 0; float ecul = 0; 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; /* 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]; /* 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; evdw = evdw + A * d12inv - B * d6inv; if (d2 < c_on2) { ecul = ecul + q1 * q2 * d2inv; } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * d2inv * sw; } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_rswsn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d6; double d2inv; double d6inv; double d12inv; double vsh; double sw; double nb6; double nb12; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * 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; /* 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]; /* 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; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; if (d2 < c_on2) { ecul = ecul + q1 * q2 * d2inv; } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * d2inv * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_rswsn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data, double *ene_vdw, double *ene_cul) { 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 dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d6; double d2inv; double d6inv; double d12inv; double vsh; double sw; double nb6; double nb12; double A, B; double q1, q2; double evdw = 0; double ecul = 0; const double c2inv = 1.0 / c2; const double c6inv = c2inv * c2inv * c2inv; const double c12inv = c6inv * 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; /* 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]; /* 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; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; if (d2 < c_on2) { ecul = ecul + q1 * q2 * d2inv; } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * d2inv * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_rswsn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d6; float d2inv; float d6inv; float d12inv; float vsh; float sw; float nb6; float nb12; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * 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; /* 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]; /* 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; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; if (d2 < c_on2) { ecul = ecul + q1 * q2 * d2inv; } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * d2inv * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_rswsn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data, float *ene_vdw, float *ene_cul) { 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 dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d6; float d2inv; float d6inv; float d12inv; float vsh; float sw; float nb6; float nb12; float A, B; float q1, q2; float evdw = 0; float ecul = 0; const float c2inv = 1.0 / c2; const float c6inv = c2inv * c2inv * c2inv; const float c12inv = c6inv * 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; /* 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]; /* 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; vsh = one - d6 * c6inv; nb12 = A * (d12inv - c12inv * (one + vsh + vsh)); nb6 = B * (d6inv - c6inv * (one + vsh)); evdw = evdw + nb12 - nb6; if (d2 < c_on2) { ecul = ecul + q1 * q2 * d2inv; } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * d2inv * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_rswswn_d (const int *first, const int *second, const int *boundary, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, const double *vdw_data, double *ene_vdw, double *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; double dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double sw; double A, B; double q1, q2; double evdw = 0; double ecul = 0; 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; /* 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]; /* 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; if (d2 < c_on2) { ecul = ecul + q1 * q2 * d2inv; evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * d2inv * sw; evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_rswswn_d (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const double *coor, const double *sh_coor, const double c2, const double c_on2, const double *charge, const int *type_code, const int type_size, double *fvir, const double *vdw_data, double *ene_vdw, double *ene_cul) { 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 dx, dy, dz; double ix, iy, iz; double jx, jy, jz; double shX, shY, shZ; double d2; double d2inv; double d6inv; double d12inv; double sw; double A, B; double q1, q2; double evdw = 0; double ecul = 0; 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; /* 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]; /* 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; if (d2 < c_on2) { ecul = ecul + q1 * q2 * d2inv; evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * d2inv * sw; evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 pbcenergy_rswswn_f (const int *first, const int *second, const int *boundary, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, const float *vdw_data, float *ene_vdw, float *ene_cul) { int i; int j; int f; int fpos; int s; int spos; int b1; int b2; int tc1; int tc2; int data_pos; float dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float sw; float A, B; float q1, q2; float evdw = 0; float ecul = 0; 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; /* 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]; /* 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; if (d2 < c_on2) { ecul = ecul + q1 * q2 * d2inv; evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * d2inv * sw; evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; } /*************************************************************************** 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 vpbcenergy_rswswn_f (const int *first, const int *second, const int *boundary, const int *box, const int natoms, const float *coor, const float *sh_coor, const float c2, const float c_on2, const float *charge, const int *type_code, const int type_size, float *fvir, const float *vdw_data, float *ene_vdw, float *ene_cul) { 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 dx, dy, dz; float ix, iy, iz; float jx, jy, jz; float shX, shY, shZ; float d2; float d2inv; float d6inv; float d12inv; float sw; float A, B; float q1, q2; float evdw = 0; float ecul = 0; 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; /* 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]; /* 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; if (d2 < c_on2) { ecul = ecul + q1 * q2 * d2inv; evdw = evdw + (A * d12inv - B * d6inv); } else { sw = c2diffinv * (c2 - d2) * (c2 - d2) * (c2 + two * d2 - three * c_on2); ecul = ecul + q1 * q2 * d2inv * sw; evdw = evdw + (A * d12inv - B * d6inv) * sw; } } } } *ene_vdw = *ene_vdw + evdw; *ene_cul = *ene_cul + ecul; }