NAMD
Macros | Functions
ComputeNonbondedBase2KNL.h File Reference

Go to the source code of this file.

Macros

#define p_j   (p_1+j)
 
#define pFlt_j   (pFlt_1+j)
 
#define lj_pars   (lj_row+lj_index)
 

Functions

 for (k=0;k< npairi;++k)
 

Macro Definition Documentation

◆ lj_pars

#define lj_pars   (lj_row+lj_index)

Referenced by for().

◆ p_j

#define p_j   (p_1+j)

Referenced by for().

◆ pFlt_j

#define pFlt_j   (pFlt_1+j)

Referenced by for().

Function Documentation

◆ for()

for ( )

Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by The Board of Trustees of the University of Illinois. All rights reserved.

Definition at line 53 of file ComputeNonbondedBase2KNL.h.

References electEnergy, ENERGY, f_j, fullf_j, LAM, LES, lj_pars, MODIFIED, NORMAL, NOSHORT, p_ij_x, p_ij_y, p_ij_z, p_j, and pFlt_j.

53  {
54 
55  const float r2 = r2list_f[k];
56  const float r_1 = 1.f / sqrtf(r2);
57  const float r_2 = r_1 * r_1;
58  const float knl_table_r_1 =
59  r_1 > KNL_TABLE_MAX_R_1 ? KNL_TABLE_MAX_R_1 : r_1;
60  const float knl_table_f = (KNL_TABLE_FACTOR-2) * knl_table_r_1;
61  const int knl_table_i = knl_table_f;
62  const float knl_diff = knl_table_f - knl_table_i;
63 
64  const int j = pairlisti[k];
65  //register const CompAtom *p_j = p_1 + j;
66 #define p_j (p_1+j)
67 #define pFlt_j (pFlt_1+j)
68 
69 #if (VDW_SWITCH_MODE == VDW_SWITCH_MODE_FORCE) || (VDW_SWITCH_MODE == VDW_SWITCH_MODE_MARTINI)
70 #if 0
71  int table_i = (r2iilist[2*k] >> 14) + r2_delta_expc; // table_i >= 0
72 
73  float diffa = r2list[k] - r2_table[table_i];
74  //const BigReal* const table_four_i = table_four + 16*table_i;
75 #define table_four_i (table_four + 16*table_i)
76 #endif
77 #endif
78 
79  //const LJTable::TableEntry * lj_pars =
80  // lj_row + 2 * p_j->vdwType MODIFIED(+ 1);
81  const int lj_index = 2 * pFlt_j->vdwType MODIFIED(+ 1);
82 #define lj_pars (lj_row+lj_index)
83 
84 #if ( SHORT( 1+ ) 0 )
85  //Force *f_j = f_1 + j;
86 #define f_j (f_1+j)
87 #endif
88 
89 #if ( FULL( 1+ ) 0 )
90  //Force *fullf_j = fullf_1 + j;
91 #define fullf_j (fullf_1+j)
92 #endif
93 
94  float kqq = kq_i_f * p_j->charge;
95 
96  LES( float lambda_pair = lambda_table_i[p_j->partition]; )
97 
98  register const float p_ij_x = xlist[k];
99  register const float p_ij_y = ylist[k];
100  register const float p_ij_z = zlist[k];
101 
102  const float A = scaling_f * lj_pars->A;
103  const float B = scaling_f * lj_pars->B;
104 
105 #if VDW_SWITCH_MODE == VDW_SWITCH_MODE_FORCE
106  { int vdw_switch_mode_force; } // for preprocessor debugging only
107  float vdw_b = 0.f;
108  {
109  const float r_6 = r_2 * r_2 * r_2;
110  float vdwa_energy, vdwb_energy, vdwa_gradient, vdwb_gradient;
111  // from Steinbach & Brooks, JCC 15, pgs 667-683, 1994, eqns 10-13
112  if ( r2 > switchOn2_f ) {
113  const float tmpa = r_6 - cutoff_6_f;
114  vdwa_energy = k_vdwa_f * tmpa * tmpa;
115  const float tmpb = r_1 * r_2 - cutoff_3_f;
116  vdwb_energy = k_vdwb_f * tmpb * tmpb;
117  vdwa_gradient = -6.f * k_vdwa_f * tmpa * r_2 * r_6;
118  vdwb_gradient = -3.f * k_vdwb_f * tmpb * r_2 * r_2 * r_1;
119  } else {
120  const float r_12 = r_6 * r_6;
121  vdwa_energy = r_12 + v_vdwa_f;
122  vdwb_energy = r_6 + v_vdwb_f;
123  vdwa_gradient = -6.f * r_2 * r_12;
124  vdwb_gradient = -3.f * r_2 * r_6;
125  }
126  vdw_b = -2.f * ( A * vdwa_gradient - B * vdwb_gradient );
127  ENERGY(
128  vdwEnergy += A * vdwa_energy - B * vdwb_energy;
129  )
130  }
131 #elif VDW_SWITCH_MODE == VDW_SWITCH_MODE_MARTINI
132  { int vdw_switch_mode_martini; } // for preprocessor debugging only
133  float vdw_b = 0.f;
134  {
135  const float r = r2 * r_1;
136  const float r12 = (r-switchOn_f)*(r-switchOn_f);
137  const float r13 = (r-switchOn_f)*(r-switchOn_f)*(r-switchOn_f);
138 
139  ENERGY(
140  const float LJshifttempA = -(1.f/3.f)*A12_f*r13 - (1.f/4.f)*B12_f*r12*r12 - C12_f;
141  const float LJshifttempB = -(1.f/3.f)*A6_f*r13 - (1.f/4.f)*B6_f*r12*r12 - C6_f;
142  const float shiftValA = ( r > switchOn_f ? LJshifttempA : -C12_f);
143  const float shiftValB = ( r > switchOn_f ? LJshifttempB : -C6_f);
144  )
145 
146  const float LJdshifttempA = -A12_f*r12 - B12_f*r13;
147  const float LJdshifttempB = -A6_f*r12 - B6_f*r13;
148  const float dshiftValA = ( r > switchOn_f ? LJdshifttempA*0.5f*r_1 : 0 );
149  const float dshiftValB = ( r > switchOn_f ? LJdshifttempB*0.5f*r_1 : 0 );
150 
151  const float r_6 = r_2 * r_2 * r_2;
152  const float r_12 = r_6 * r_6;
153 
154  ENERGY(
155  const float vdwa_energy = r_12 + shiftValA;
156  const float vdwb_energy = r_6 + shiftValB;
157  )
158 
159  const float vdwa_gradient = -6.f * r_2 * r_12 + dshiftValA ;
160  const float vdwb_gradient = -3.f * r_2 * r_6 + dshiftValB;
161 
162  vdw_b = -2.f * ( A * vdwa_gradient - B * vdwb_gradient );
163  ENERGY(
164  vdwEnergy += A * vdwa_energy - B * vdwb_energy;
165  )
166  }
167 #elif VDW_SWITCH_MODE == VDW_SWITCH_MODE_ENERGY
168  { int vdw_switch_mode_energy; } // for preprocessor debugging only
169  float vdw_b = 0.f;
170  {
171  const float r_6 = r_2 * r_2 * r_2;
172  const float r_12 = r_6 * r_6;
173  const float c2 = cutoff2_f-r2;
174  const float c4 = c2*(c3_f-2.f*c2);
175  const float switchVal = // used for Lennard-Jones
176  ( r2 > switchOn2_f ? c2*c4*c1_f : 1.f );
177  const float dSwitchVal = // d switchVal / d r2
178  ( r2 > switchOn2_f ? 2.f*c1_f*(c2*c2-c4) : 0.f );
179  const float vdwa_gradient = ( dSwitchVal - 6.f * switchVal * r_2 ) * r_12;
180  const float vdwb_gradient = ( dSwitchVal - 3.f * switchVal * r_2 ) * r_6;
181  vdw_b = -2.f * ( A * vdwa_gradient - B * vdwb_gradient );
182  ENERGY(
183  vdwEnergy += switchVal * ( A * r_12 - B * r_6 );
184  )
185  }
186 #else
187 #error VDW_SWITCH_MODE not recognized
188 #endif // VDW_SWITCH_MODE
189 
190 #if ( SHORT(1+) 0 ) // Short-range electrostatics
191 
192  NORMAL(
193  float fast_b = kqq * ( knl_fast_grad_table[knl_table_i] * (1.f-knl_diff) +
194  knl_fast_grad_table[knl_table_i+1] * knl_diff );
195  )
196 
197  {
198  ENERGY(
199  float fast_val = kqq * ( knl_fast_ener_table[knl_table_i] * (1.f-knl_diff) +
200  knl_fast_ener_table[knl_table_i+1] * knl_diff );
201  electEnergy -= LAM(lambda_pair *) fast_val;
202  ) //ENERGY
203  }
204 
205  // Combined short-range electrostatics and VdW force:
206  fast_b += vdw_b;
207 
208  float fast_dir = fast_b;
209 
210  float force_r = LAM(lambda_pair *) fast_dir;
211 
212  BigReal tmp_x = force_r * p_ij_x;
213  f_i_x += tmp_x;
214  f_j->x -= tmp_x;
215 
216  BigReal tmp_y = force_r * p_ij_y;
217  f_i_y += tmp_y;
218  f_j->y -= tmp_y;
219 
220  BigReal tmp_z = force_r * p_ij_z;
221  f_i_z += tmp_z;
222  f_j->z -= tmp_z;
223 
224 #endif // SHORT
225 
226 #if ( FULL( 1+ ) 0 )
227  #if ( SHORT( 1+ ) 0 )
228  float slow_b = kqq * ( knl_scor_grad_table[knl_table_i] * (1.f-knl_diff) +
229  knl_scor_grad_table[knl_table_i+1] * knl_diff );
230  ENERGY(
231  float slow_val = kqq * ( knl_scor_ener_table[knl_table_i] * (1.f-knl_diff) +
232  knl_scor_ener_table[knl_table_i+1] * knl_diff );
233  )
234  #else
235  float slow_b = kqq * ( knl_corr_grad_table[knl_table_i] * (1.f-knl_diff) +
236  knl_corr_grad_table[knl_table_i+1] * knl_diff );
237  ENERGY(
238  float slow_val = kqq * ( knl_corr_ener_table[knl_table_i] * (1.f-knl_diff) +
239  knl_corr_ener_table[knl_table_i+1] * knl_diff );
240  )
241  #endif
242 
243  ENERGY(
244  fullElectEnergy -= LAM(lambda_pair *) slow_val;
245  ) // ENERGY
246 
247 #if (NOSHORT(1+) 0)
248  slow_b += vdw_b;
249 #endif
250 
251  register float slow_dir = slow_b;
252  float fullforce_r = slow_dir LAM(* lambda_pair);
253 
254  {
255  BigReal ftmp_x = fullforce_r * p_ij_x;
256  fullf_i_x += ftmp_x;
257  fullf_j->x -= ftmp_x;
258  BigReal ftmp_y = fullforce_r * p_ij_y;
259  fullf_i_y += ftmp_y;
260  fullf_j->y -= ftmp_y;
261  BigReal ftmp_z = fullforce_r * p_ij_z;
262  fullf_i_z += ftmp_z;
263  fullf_j->z -= ftmp_z;
264  }
265 #endif //FULL
266 
267  } // for pairlist
#define NORMAL(X)
#define lj_pars
#define LAM(X)
#define pFlt_j
register BigReal electEnergy
#define NOSHORT(X)
#define f_j
register const BigReal p_ij_z
#define p_j
#define fullf_j
register const BigReal p_ij_x
#define ENERGY(X)
#define LES(X)
k< npairi;++k) { TABENERGY(const int numtypes=simParams->tableNumTypes;const float table_spacing=simParams->tableSpacing;const int npertype=(int)(namdnearbyint(simParams->tableMaxDist/simParams->tableSpacing)+1);) int table_i=(r2iilist[2 *k] >> 14)+r2_delta_expc;const int j=pairlisti[k];#define p_j BigReal diffa=r2list[k] - r2_table[table_i];#define table_four_i const int lj_index=2 *p_j-> vdwType MODIFIED(+1)
register const BigReal p_ij_y
double BigReal
Definition: common.h:123