Remove nb-parameters from t_forcerec
[gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_c / nb_kernel_ElecCoul_VdwBham_GeomW3W3_c.c
blob3a2bc1e637e59470c2caec96d6f09ce6e0872b08
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014.2015,2017, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 * Note: this file was generated by the GROMACS c kernel generator.
38 #include "gmxpre.h"
40 #include "config.h"
42 #include <math.h>
44 #include "../nb_kernel.h"
45 #include "gromacs/gmxlib/nrnb.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwBham_GeomW3W3_VF_c
49 * Electrostatics interaction: Coulomb
50 * VdW interaction: Buckingham
51 * Geometry: Water3-Water3
52 * Calculate force/pot: PotentialAndForce
54 void
55 nb_kernel_ElecCoul_VdwBham_GeomW3W3_VF_c
56 (t_nblist * gmx_restrict nlist,
57 rvec * gmx_restrict xx,
58 rvec * gmx_restrict ff,
59 struct t_forcerec * gmx_restrict fr,
60 t_mdatoms * gmx_restrict mdatoms,
61 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
62 t_nrnb * gmx_restrict nrnb)
64 int i_shift_offset,i_coord_offset,j_coord_offset;
65 int j_index_start,j_index_end;
66 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
67 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
68 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
69 real *shiftvec,*fshift,*x,*f;
70 int vdwioffset0;
71 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
72 int vdwioffset1;
73 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
74 int vdwioffset2;
75 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
76 int vdwjidx0;
77 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
78 int vdwjidx1;
79 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
80 int vdwjidx2;
81 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
82 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
83 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
84 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
85 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
86 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
87 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
88 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
89 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
90 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
91 real velec,felec,velecsum,facel,crf,krf,krf2;
92 real *charge;
93 int nvdwtype;
94 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
95 int *vdwtype;
96 real *vdwparam;
98 x = xx[0];
99 f = ff[0];
101 nri = nlist->nri;
102 iinr = nlist->iinr;
103 jindex = nlist->jindex;
104 jjnr = nlist->jjnr;
105 shiftidx = nlist->shift;
106 gid = nlist->gid;
107 shiftvec = fr->shift_vec[0];
108 fshift = fr->fshift[0];
109 facel = fr->ic->epsfac;
110 charge = mdatoms->chargeA;
111 nvdwtype = fr->ntype;
112 vdwparam = fr->nbfp;
113 vdwtype = mdatoms->typeA;
115 /* Setup water-specific parameters */
116 inr = nlist->iinr[0];
117 iq0 = facel*charge[inr+0];
118 iq1 = facel*charge[inr+1];
119 iq2 = facel*charge[inr+2];
120 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
122 jq0 = charge[inr+0];
123 jq1 = charge[inr+1];
124 jq2 = charge[inr+2];
125 vdwjidx0 = 3*vdwtype[inr+0];
126 qq00 = iq0*jq0;
127 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
128 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
129 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
130 qq01 = iq0*jq1;
131 qq02 = iq0*jq2;
132 qq10 = iq1*jq0;
133 qq11 = iq1*jq1;
134 qq12 = iq1*jq2;
135 qq20 = iq2*jq0;
136 qq21 = iq2*jq1;
137 qq22 = iq2*jq2;
139 outeriter = 0;
140 inneriter = 0;
142 /* Start outer loop over neighborlists */
143 for(iidx=0; iidx<nri; iidx++)
145 /* Load shift vector for this list */
146 i_shift_offset = DIM*shiftidx[iidx];
147 shX = shiftvec[i_shift_offset+XX];
148 shY = shiftvec[i_shift_offset+YY];
149 shZ = shiftvec[i_shift_offset+ZZ];
151 /* Load limits for loop over neighbors */
152 j_index_start = jindex[iidx];
153 j_index_end = jindex[iidx+1];
155 /* Get outer coordinate index */
156 inr = iinr[iidx];
157 i_coord_offset = DIM*inr;
159 /* Load i particle coords and add shift vector */
160 ix0 = shX + x[i_coord_offset+DIM*0+XX];
161 iy0 = shY + x[i_coord_offset+DIM*0+YY];
162 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
163 ix1 = shX + x[i_coord_offset+DIM*1+XX];
164 iy1 = shY + x[i_coord_offset+DIM*1+YY];
165 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
166 ix2 = shX + x[i_coord_offset+DIM*2+XX];
167 iy2 = shY + x[i_coord_offset+DIM*2+YY];
168 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
170 fix0 = 0.0;
171 fiy0 = 0.0;
172 fiz0 = 0.0;
173 fix1 = 0.0;
174 fiy1 = 0.0;
175 fiz1 = 0.0;
176 fix2 = 0.0;
177 fiy2 = 0.0;
178 fiz2 = 0.0;
180 /* Reset potential sums */
181 velecsum = 0.0;
182 vvdwsum = 0.0;
184 /* Start inner kernel loop */
185 for(jidx=j_index_start; jidx<j_index_end; jidx++)
187 /* Get j neighbor index, and coordinate index */
188 jnr = jjnr[jidx];
189 j_coord_offset = DIM*jnr;
191 /* load j atom coordinates */
192 jx0 = x[j_coord_offset+DIM*0+XX];
193 jy0 = x[j_coord_offset+DIM*0+YY];
194 jz0 = x[j_coord_offset+DIM*0+ZZ];
195 jx1 = x[j_coord_offset+DIM*1+XX];
196 jy1 = x[j_coord_offset+DIM*1+YY];
197 jz1 = x[j_coord_offset+DIM*1+ZZ];
198 jx2 = x[j_coord_offset+DIM*2+XX];
199 jy2 = x[j_coord_offset+DIM*2+YY];
200 jz2 = x[j_coord_offset+DIM*2+ZZ];
202 /* Calculate displacement vector */
203 dx00 = ix0 - jx0;
204 dy00 = iy0 - jy0;
205 dz00 = iz0 - jz0;
206 dx01 = ix0 - jx1;
207 dy01 = iy0 - jy1;
208 dz01 = iz0 - jz1;
209 dx02 = ix0 - jx2;
210 dy02 = iy0 - jy2;
211 dz02 = iz0 - jz2;
212 dx10 = ix1 - jx0;
213 dy10 = iy1 - jy0;
214 dz10 = iz1 - jz0;
215 dx11 = ix1 - jx1;
216 dy11 = iy1 - jy1;
217 dz11 = iz1 - jz1;
218 dx12 = ix1 - jx2;
219 dy12 = iy1 - jy2;
220 dz12 = iz1 - jz2;
221 dx20 = ix2 - jx0;
222 dy20 = iy2 - jy0;
223 dz20 = iz2 - jz0;
224 dx21 = ix2 - jx1;
225 dy21 = iy2 - jy1;
226 dz21 = iz2 - jz1;
227 dx22 = ix2 - jx2;
228 dy22 = iy2 - jy2;
229 dz22 = iz2 - jz2;
231 /* Calculate squared distance and things based on it */
232 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
233 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
234 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
235 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
236 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
237 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
238 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
239 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
240 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
242 rinv00 = 1.0/sqrt(rsq00);
243 rinv01 = 1.0/sqrt(rsq01);
244 rinv02 = 1.0/sqrt(rsq02);
245 rinv10 = 1.0/sqrt(rsq10);
246 rinv11 = 1.0/sqrt(rsq11);
247 rinv12 = 1.0/sqrt(rsq12);
248 rinv20 = 1.0/sqrt(rsq20);
249 rinv21 = 1.0/sqrt(rsq21);
250 rinv22 = 1.0/sqrt(rsq22);
252 rinvsq00 = rinv00*rinv00;
253 rinvsq01 = rinv01*rinv01;
254 rinvsq02 = rinv02*rinv02;
255 rinvsq10 = rinv10*rinv10;
256 rinvsq11 = rinv11*rinv11;
257 rinvsq12 = rinv12*rinv12;
258 rinvsq20 = rinv20*rinv20;
259 rinvsq21 = rinv21*rinv21;
260 rinvsq22 = rinv22*rinv22;
262 /**************************
263 * CALCULATE INTERACTIONS *
264 **************************/
266 r00 = rsq00*rinv00;
268 /* COULOMB ELECTROSTATICS */
269 velec = qq00*rinv00;
270 felec = velec*rinvsq00;
272 /* BUCKINGHAM DISPERSION/REPULSION */
273 rinvsix = rinvsq00*rinvsq00*rinvsq00;
274 vvdw6 = c6_00*rinvsix;
275 br = cexp2_00*r00;
276 vvdwexp = cexp1_00*exp(-br);
277 vvdw = vvdwexp - vvdw6*(1.0/6.0);
278 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
280 /* Update potential sums from outer loop */
281 velecsum += velec;
282 vvdwsum += vvdw;
284 fscal = felec+fvdw;
286 /* Calculate temporary vectorial force */
287 tx = fscal*dx00;
288 ty = fscal*dy00;
289 tz = fscal*dz00;
291 /* Update vectorial force */
292 fix0 += tx;
293 fiy0 += ty;
294 fiz0 += tz;
295 f[j_coord_offset+DIM*0+XX] -= tx;
296 f[j_coord_offset+DIM*0+YY] -= ty;
297 f[j_coord_offset+DIM*0+ZZ] -= tz;
299 /**************************
300 * CALCULATE INTERACTIONS *
301 **************************/
303 /* COULOMB ELECTROSTATICS */
304 velec = qq01*rinv01;
305 felec = velec*rinvsq01;
307 /* Update potential sums from outer loop */
308 velecsum += velec;
310 fscal = felec;
312 /* Calculate temporary vectorial force */
313 tx = fscal*dx01;
314 ty = fscal*dy01;
315 tz = fscal*dz01;
317 /* Update vectorial force */
318 fix0 += tx;
319 fiy0 += ty;
320 fiz0 += tz;
321 f[j_coord_offset+DIM*1+XX] -= tx;
322 f[j_coord_offset+DIM*1+YY] -= ty;
323 f[j_coord_offset+DIM*1+ZZ] -= tz;
325 /**************************
326 * CALCULATE INTERACTIONS *
327 **************************/
329 /* COULOMB ELECTROSTATICS */
330 velec = qq02*rinv02;
331 felec = velec*rinvsq02;
333 /* Update potential sums from outer loop */
334 velecsum += velec;
336 fscal = felec;
338 /* Calculate temporary vectorial force */
339 tx = fscal*dx02;
340 ty = fscal*dy02;
341 tz = fscal*dz02;
343 /* Update vectorial force */
344 fix0 += tx;
345 fiy0 += ty;
346 fiz0 += tz;
347 f[j_coord_offset+DIM*2+XX] -= tx;
348 f[j_coord_offset+DIM*2+YY] -= ty;
349 f[j_coord_offset+DIM*2+ZZ] -= tz;
351 /**************************
352 * CALCULATE INTERACTIONS *
353 **************************/
355 /* COULOMB ELECTROSTATICS */
356 velec = qq10*rinv10;
357 felec = velec*rinvsq10;
359 /* Update potential sums from outer loop */
360 velecsum += velec;
362 fscal = felec;
364 /* Calculate temporary vectorial force */
365 tx = fscal*dx10;
366 ty = fscal*dy10;
367 tz = fscal*dz10;
369 /* Update vectorial force */
370 fix1 += tx;
371 fiy1 += ty;
372 fiz1 += tz;
373 f[j_coord_offset+DIM*0+XX] -= tx;
374 f[j_coord_offset+DIM*0+YY] -= ty;
375 f[j_coord_offset+DIM*0+ZZ] -= tz;
377 /**************************
378 * CALCULATE INTERACTIONS *
379 **************************/
381 /* COULOMB ELECTROSTATICS */
382 velec = qq11*rinv11;
383 felec = velec*rinvsq11;
385 /* Update potential sums from outer loop */
386 velecsum += velec;
388 fscal = felec;
390 /* Calculate temporary vectorial force */
391 tx = fscal*dx11;
392 ty = fscal*dy11;
393 tz = fscal*dz11;
395 /* Update vectorial force */
396 fix1 += tx;
397 fiy1 += ty;
398 fiz1 += tz;
399 f[j_coord_offset+DIM*1+XX] -= tx;
400 f[j_coord_offset+DIM*1+YY] -= ty;
401 f[j_coord_offset+DIM*1+ZZ] -= tz;
403 /**************************
404 * CALCULATE INTERACTIONS *
405 **************************/
407 /* COULOMB ELECTROSTATICS */
408 velec = qq12*rinv12;
409 felec = velec*rinvsq12;
411 /* Update potential sums from outer loop */
412 velecsum += velec;
414 fscal = felec;
416 /* Calculate temporary vectorial force */
417 tx = fscal*dx12;
418 ty = fscal*dy12;
419 tz = fscal*dz12;
421 /* Update vectorial force */
422 fix1 += tx;
423 fiy1 += ty;
424 fiz1 += tz;
425 f[j_coord_offset+DIM*2+XX] -= tx;
426 f[j_coord_offset+DIM*2+YY] -= ty;
427 f[j_coord_offset+DIM*2+ZZ] -= tz;
429 /**************************
430 * CALCULATE INTERACTIONS *
431 **************************/
433 /* COULOMB ELECTROSTATICS */
434 velec = qq20*rinv20;
435 felec = velec*rinvsq20;
437 /* Update potential sums from outer loop */
438 velecsum += velec;
440 fscal = felec;
442 /* Calculate temporary vectorial force */
443 tx = fscal*dx20;
444 ty = fscal*dy20;
445 tz = fscal*dz20;
447 /* Update vectorial force */
448 fix2 += tx;
449 fiy2 += ty;
450 fiz2 += tz;
451 f[j_coord_offset+DIM*0+XX] -= tx;
452 f[j_coord_offset+DIM*0+YY] -= ty;
453 f[j_coord_offset+DIM*0+ZZ] -= tz;
455 /**************************
456 * CALCULATE INTERACTIONS *
457 **************************/
459 /* COULOMB ELECTROSTATICS */
460 velec = qq21*rinv21;
461 felec = velec*rinvsq21;
463 /* Update potential sums from outer loop */
464 velecsum += velec;
466 fscal = felec;
468 /* Calculate temporary vectorial force */
469 tx = fscal*dx21;
470 ty = fscal*dy21;
471 tz = fscal*dz21;
473 /* Update vectorial force */
474 fix2 += tx;
475 fiy2 += ty;
476 fiz2 += tz;
477 f[j_coord_offset+DIM*1+XX] -= tx;
478 f[j_coord_offset+DIM*1+YY] -= ty;
479 f[j_coord_offset+DIM*1+ZZ] -= tz;
481 /**************************
482 * CALCULATE INTERACTIONS *
483 **************************/
485 /* COULOMB ELECTROSTATICS */
486 velec = qq22*rinv22;
487 felec = velec*rinvsq22;
489 /* Update potential sums from outer loop */
490 velecsum += velec;
492 fscal = felec;
494 /* Calculate temporary vectorial force */
495 tx = fscal*dx22;
496 ty = fscal*dy22;
497 tz = fscal*dz22;
499 /* Update vectorial force */
500 fix2 += tx;
501 fiy2 += ty;
502 fiz2 += tz;
503 f[j_coord_offset+DIM*2+XX] -= tx;
504 f[j_coord_offset+DIM*2+YY] -= ty;
505 f[j_coord_offset+DIM*2+ZZ] -= tz;
507 /* Inner loop uses 282 flops */
509 /* End of innermost loop */
511 tx = ty = tz = 0;
512 f[i_coord_offset+DIM*0+XX] += fix0;
513 f[i_coord_offset+DIM*0+YY] += fiy0;
514 f[i_coord_offset+DIM*0+ZZ] += fiz0;
515 tx += fix0;
516 ty += fiy0;
517 tz += fiz0;
518 f[i_coord_offset+DIM*1+XX] += fix1;
519 f[i_coord_offset+DIM*1+YY] += fiy1;
520 f[i_coord_offset+DIM*1+ZZ] += fiz1;
521 tx += fix1;
522 ty += fiy1;
523 tz += fiz1;
524 f[i_coord_offset+DIM*2+XX] += fix2;
525 f[i_coord_offset+DIM*2+YY] += fiy2;
526 f[i_coord_offset+DIM*2+ZZ] += fiz2;
527 tx += fix2;
528 ty += fiy2;
529 tz += fiz2;
530 fshift[i_shift_offset+XX] += tx;
531 fshift[i_shift_offset+YY] += ty;
532 fshift[i_shift_offset+ZZ] += tz;
534 ggid = gid[iidx];
535 /* Update potential energies */
536 kernel_data->energygrp_elec[ggid] += velecsum;
537 kernel_data->energygrp_vdw[ggid] += vvdwsum;
539 /* Increment number of inner iterations */
540 inneriter += j_index_end - j_index_start;
542 /* Outer loop uses 32 flops */
545 /* Increment number of outer iterations */
546 outeriter += nri;
548 /* Update outer/inner flops */
550 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_VF,outeriter*32 + inneriter*282);
553 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwBham_GeomW3W3_F_c
554 * Electrostatics interaction: Coulomb
555 * VdW interaction: Buckingham
556 * Geometry: Water3-Water3
557 * Calculate force/pot: Force
559 void
560 nb_kernel_ElecCoul_VdwBham_GeomW3W3_F_c
561 (t_nblist * gmx_restrict nlist,
562 rvec * gmx_restrict xx,
563 rvec * gmx_restrict ff,
564 struct t_forcerec * gmx_restrict fr,
565 t_mdatoms * gmx_restrict mdatoms,
566 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
567 t_nrnb * gmx_restrict nrnb)
569 int i_shift_offset,i_coord_offset,j_coord_offset;
570 int j_index_start,j_index_end;
571 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
572 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
573 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
574 real *shiftvec,*fshift,*x,*f;
575 int vdwioffset0;
576 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
577 int vdwioffset1;
578 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
579 int vdwioffset2;
580 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
581 int vdwjidx0;
582 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
583 int vdwjidx1;
584 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
585 int vdwjidx2;
586 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
587 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
588 real dx01,dy01,dz01,rsq01,rinv01,rinvsq01,r01,qq01,c6_01,c12_01,cexp1_01,cexp2_01;
589 real dx02,dy02,dz02,rsq02,rinv02,rinvsq02,r02,qq02,c6_02,c12_02,cexp1_02,cexp2_02;
590 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
591 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
592 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
593 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
594 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
595 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
596 real velec,felec,velecsum,facel,crf,krf,krf2;
597 real *charge;
598 int nvdwtype;
599 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
600 int *vdwtype;
601 real *vdwparam;
603 x = xx[0];
604 f = ff[0];
606 nri = nlist->nri;
607 iinr = nlist->iinr;
608 jindex = nlist->jindex;
609 jjnr = nlist->jjnr;
610 shiftidx = nlist->shift;
611 gid = nlist->gid;
612 shiftvec = fr->shift_vec[0];
613 fshift = fr->fshift[0];
614 facel = fr->ic->epsfac;
615 charge = mdatoms->chargeA;
616 nvdwtype = fr->ntype;
617 vdwparam = fr->nbfp;
618 vdwtype = mdatoms->typeA;
620 /* Setup water-specific parameters */
621 inr = nlist->iinr[0];
622 iq0 = facel*charge[inr+0];
623 iq1 = facel*charge[inr+1];
624 iq2 = facel*charge[inr+2];
625 vdwioffset0 = 3*nvdwtype*vdwtype[inr+0];
627 jq0 = charge[inr+0];
628 jq1 = charge[inr+1];
629 jq2 = charge[inr+2];
630 vdwjidx0 = 3*vdwtype[inr+0];
631 qq00 = iq0*jq0;
632 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
633 cexp1_00 = vdwparam[vdwioffset0+vdwjidx0+1];
634 cexp2_00 = vdwparam[vdwioffset0+vdwjidx0+2];
635 qq01 = iq0*jq1;
636 qq02 = iq0*jq2;
637 qq10 = iq1*jq0;
638 qq11 = iq1*jq1;
639 qq12 = iq1*jq2;
640 qq20 = iq2*jq0;
641 qq21 = iq2*jq1;
642 qq22 = iq2*jq2;
644 outeriter = 0;
645 inneriter = 0;
647 /* Start outer loop over neighborlists */
648 for(iidx=0; iidx<nri; iidx++)
650 /* Load shift vector for this list */
651 i_shift_offset = DIM*shiftidx[iidx];
652 shX = shiftvec[i_shift_offset+XX];
653 shY = shiftvec[i_shift_offset+YY];
654 shZ = shiftvec[i_shift_offset+ZZ];
656 /* Load limits for loop over neighbors */
657 j_index_start = jindex[iidx];
658 j_index_end = jindex[iidx+1];
660 /* Get outer coordinate index */
661 inr = iinr[iidx];
662 i_coord_offset = DIM*inr;
664 /* Load i particle coords and add shift vector */
665 ix0 = shX + x[i_coord_offset+DIM*0+XX];
666 iy0 = shY + x[i_coord_offset+DIM*0+YY];
667 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
668 ix1 = shX + x[i_coord_offset+DIM*1+XX];
669 iy1 = shY + x[i_coord_offset+DIM*1+YY];
670 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
671 ix2 = shX + x[i_coord_offset+DIM*2+XX];
672 iy2 = shY + x[i_coord_offset+DIM*2+YY];
673 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
675 fix0 = 0.0;
676 fiy0 = 0.0;
677 fiz0 = 0.0;
678 fix1 = 0.0;
679 fiy1 = 0.0;
680 fiz1 = 0.0;
681 fix2 = 0.0;
682 fiy2 = 0.0;
683 fiz2 = 0.0;
685 /* Start inner kernel loop */
686 for(jidx=j_index_start; jidx<j_index_end; jidx++)
688 /* Get j neighbor index, and coordinate index */
689 jnr = jjnr[jidx];
690 j_coord_offset = DIM*jnr;
692 /* load j atom coordinates */
693 jx0 = x[j_coord_offset+DIM*0+XX];
694 jy0 = x[j_coord_offset+DIM*0+YY];
695 jz0 = x[j_coord_offset+DIM*0+ZZ];
696 jx1 = x[j_coord_offset+DIM*1+XX];
697 jy1 = x[j_coord_offset+DIM*1+YY];
698 jz1 = x[j_coord_offset+DIM*1+ZZ];
699 jx2 = x[j_coord_offset+DIM*2+XX];
700 jy2 = x[j_coord_offset+DIM*2+YY];
701 jz2 = x[j_coord_offset+DIM*2+ZZ];
703 /* Calculate displacement vector */
704 dx00 = ix0 - jx0;
705 dy00 = iy0 - jy0;
706 dz00 = iz0 - jz0;
707 dx01 = ix0 - jx1;
708 dy01 = iy0 - jy1;
709 dz01 = iz0 - jz1;
710 dx02 = ix0 - jx2;
711 dy02 = iy0 - jy2;
712 dz02 = iz0 - jz2;
713 dx10 = ix1 - jx0;
714 dy10 = iy1 - jy0;
715 dz10 = iz1 - jz0;
716 dx11 = ix1 - jx1;
717 dy11 = iy1 - jy1;
718 dz11 = iz1 - jz1;
719 dx12 = ix1 - jx2;
720 dy12 = iy1 - jy2;
721 dz12 = iz1 - jz2;
722 dx20 = ix2 - jx0;
723 dy20 = iy2 - jy0;
724 dz20 = iz2 - jz0;
725 dx21 = ix2 - jx1;
726 dy21 = iy2 - jy1;
727 dz21 = iz2 - jz1;
728 dx22 = ix2 - jx2;
729 dy22 = iy2 - jy2;
730 dz22 = iz2 - jz2;
732 /* Calculate squared distance and things based on it */
733 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
734 rsq01 = dx01*dx01+dy01*dy01+dz01*dz01;
735 rsq02 = dx02*dx02+dy02*dy02+dz02*dz02;
736 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
737 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
738 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
739 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
740 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
741 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
743 rinv00 = 1.0/sqrt(rsq00);
744 rinv01 = 1.0/sqrt(rsq01);
745 rinv02 = 1.0/sqrt(rsq02);
746 rinv10 = 1.0/sqrt(rsq10);
747 rinv11 = 1.0/sqrt(rsq11);
748 rinv12 = 1.0/sqrt(rsq12);
749 rinv20 = 1.0/sqrt(rsq20);
750 rinv21 = 1.0/sqrt(rsq21);
751 rinv22 = 1.0/sqrt(rsq22);
753 rinvsq00 = rinv00*rinv00;
754 rinvsq01 = rinv01*rinv01;
755 rinvsq02 = rinv02*rinv02;
756 rinvsq10 = rinv10*rinv10;
757 rinvsq11 = rinv11*rinv11;
758 rinvsq12 = rinv12*rinv12;
759 rinvsq20 = rinv20*rinv20;
760 rinvsq21 = rinv21*rinv21;
761 rinvsq22 = rinv22*rinv22;
763 /**************************
764 * CALCULATE INTERACTIONS *
765 **************************/
767 r00 = rsq00*rinv00;
769 /* COULOMB ELECTROSTATICS */
770 velec = qq00*rinv00;
771 felec = velec*rinvsq00;
773 /* BUCKINGHAM DISPERSION/REPULSION */
774 rinvsix = rinvsq00*rinvsq00*rinvsq00;
775 vvdw6 = c6_00*rinvsix;
776 br = cexp2_00*r00;
777 vvdwexp = cexp1_00*exp(-br);
778 fvdw = (br*vvdwexp-vvdw6)*rinvsq00;
780 fscal = felec+fvdw;
782 /* Calculate temporary vectorial force */
783 tx = fscal*dx00;
784 ty = fscal*dy00;
785 tz = fscal*dz00;
787 /* Update vectorial force */
788 fix0 += tx;
789 fiy0 += ty;
790 fiz0 += tz;
791 f[j_coord_offset+DIM*0+XX] -= tx;
792 f[j_coord_offset+DIM*0+YY] -= ty;
793 f[j_coord_offset+DIM*0+ZZ] -= tz;
795 /**************************
796 * CALCULATE INTERACTIONS *
797 **************************/
799 /* COULOMB ELECTROSTATICS */
800 velec = qq01*rinv01;
801 felec = velec*rinvsq01;
803 fscal = felec;
805 /* Calculate temporary vectorial force */
806 tx = fscal*dx01;
807 ty = fscal*dy01;
808 tz = fscal*dz01;
810 /* Update vectorial force */
811 fix0 += tx;
812 fiy0 += ty;
813 fiz0 += tz;
814 f[j_coord_offset+DIM*1+XX] -= tx;
815 f[j_coord_offset+DIM*1+YY] -= ty;
816 f[j_coord_offset+DIM*1+ZZ] -= tz;
818 /**************************
819 * CALCULATE INTERACTIONS *
820 **************************/
822 /* COULOMB ELECTROSTATICS */
823 velec = qq02*rinv02;
824 felec = velec*rinvsq02;
826 fscal = felec;
828 /* Calculate temporary vectorial force */
829 tx = fscal*dx02;
830 ty = fscal*dy02;
831 tz = fscal*dz02;
833 /* Update vectorial force */
834 fix0 += tx;
835 fiy0 += ty;
836 fiz0 += tz;
837 f[j_coord_offset+DIM*2+XX] -= tx;
838 f[j_coord_offset+DIM*2+YY] -= ty;
839 f[j_coord_offset+DIM*2+ZZ] -= tz;
841 /**************************
842 * CALCULATE INTERACTIONS *
843 **************************/
845 /* COULOMB ELECTROSTATICS */
846 velec = qq10*rinv10;
847 felec = velec*rinvsq10;
849 fscal = felec;
851 /* Calculate temporary vectorial force */
852 tx = fscal*dx10;
853 ty = fscal*dy10;
854 tz = fscal*dz10;
856 /* Update vectorial force */
857 fix1 += tx;
858 fiy1 += ty;
859 fiz1 += tz;
860 f[j_coord_offset+DIM*0+XX] -= tx;
861 f[j_coord_offset+DIM*0+YY] -= ty;
862 f[j_coord_offset+DIM*0+ZZ] -= tz;
864 /**************************
865 * CALCULATE INTERACTIONS *
866 **************************/
868 /* COULOMB ELECTROSTATICS */
869 velec = qq11*rinv11;
870 felec = velec*rinvsq11;
872 fscal = felec;
874 /* Calculate temporary vectorial force */
875 tx = fscal*dx11;
876 ty = fscal*dy11;
877 tz = fscal*dz11;
879 /* Update vectorial force */
880 fix1 += tx;
881 fiy1 += ty;
882 fiz1 += tz;
883 f[j_coord_offset+DIM*1+XX] -= tx;
884 f[j_coord_offset+DIM*1+YY] -= ty;
885 f[j_coord_offset+DIM*1+ZZ] -= tz;
887 /**************************
888 * CALCULATE INTERACTIONS *
889 **************************/
891 /* COULOMB ELECTROSTATICS */
892 velec = qq12*rinv12;
893 felec = velec*rinvsq12;
895 fscal = felec;
897 /* Calculate temporary vectorial force */
898 tx = fscal*dx12;
899 ty = fscal*dy12;
900 tz = fscal*dz12;
902 /* Update vectorial force */
903 fix1 += tx;
904 fiy1 += ty;
905 fiz1 += tz;
906 f[j_coord_offset+DIM*2+XX] -= tx;
907 f[j_coord_offset+DIM*2+YY] -= ty;
908 f[j_coord_offset+DIM*2+ZZ] -= tz;
910 /**************************
911 * CALCULATE INTERACTIONS *
912 **************************/
914 /* COULOMB ELECTROSTATICS */
915 velec = qq20*rinv20;
916 felec = velec*rinvsq20;
918 fscal = felec;
920 /* Calculate temporary vectorial force */
921 tx = fscal*dx20;
922 ty = fscal*dy20;
923 tz = fscal*dz20;
925 /* Update vectorial force */
926 fix2 += tx;
927 fiy2 += ty;
928 fiz2 += tz;
929 f[j_coord_offset+DIM*0+XX] -= tx;
930 f[j_coord_offset+DIM*0+YY] -= ty;
931 f[j_coord_offset+DIM*0+ZZ] -= tz;
933 /**************************
934 * CALCULATE INTERACTIONS *
935 **************************/
937 /* COULOMB ELECTROSTATICS */
938 velec = qq21*rinv21;
939 felec = velec*rinvsq21;
941 fscal = felec;
943 /* Calculate temporary vectorial force */
944 tx = fscal*dx21;
945 ty = fscal*dy21;
946 tz = fscal*dz21;
948 /* Update vectorial force */
949 fix2 += tx;
950 fiy2 += ty;
951 fiz2 += tz;
952 f[j_coord_offset+DIM*1+XX] -= tx;
953 f[j_coord_offset+DIM*1+YY] -= ty;
954 f[j_coord_offset+DIM*1+ZZ] -= tz;
956 /**************************
957 * CALCULATE INTERACTIONS *
958 **************************/
960 /* COULOMB ELECTROSTATICS */
961 velec = qq22*rinv22;
962 felec = velec*rinvsq22;
964 fscal = felec;
966 /* Calculate temporary vectorial force */
967 tx = fscal*dx22;
968 ty = fscal*dy22;
969 tz = fscal*dz22;
971 /* Update vectorial force */
972 fix2 += tx;
973 fiy2 += ty;
974 fiz2 += tz;
975 f[j_coord_offset+DIM*2+XX] -= tx;
976 f[j_coord_offset+DIM*2+YY] -= ty;
977 f[j_coord_offset+DIM*2+ZZ] -= tz;
979 /* Inner loop uses 270 flops */
981 /* End of innermost loop */
983 tx = ty = tz = 0;
984 f[i_coord_offset+DIM*0+XX] += fix0;
985 f[i_coord_offset+DIM*0+YY] += fiy0;
986 f[i_coord_offset+DIM*0+ZZ] += fiz0;
987 tx += fix0;
988 ty += fiy0;
989 tz += fiz0;
990 f[i_coord_offset+DIM*1+XX] += fix1;
991 f[i_coord_offset+DIM*1+YY] += fiy1;
992 f[i_coord_offset+DIM*1+ZZ] += fiz1;
993 tx += fix1;
994 ty += fiy1;
995 tz += fiz1;
996 f[i_coord_offset+DIM*2+XX] += fix2;
997 f[i_coord_offset+DIM*2+YY] += fiy2;
998 f[i_coord_offset+DIM*2+ZZ] += fiz2;
999 tx += fix2;
1000 ty += fiy2;
1001 tz += fiz2;
1002 fshift[i_shift_offset+XX] += tx;
1003 fshift[i_shift_offset+YY] += ty;
1004 fshift[i_shift_offset+ZZ] += tz;
1006 /* Increment number of inner iterations */
1007 inneriter += j_index_end - j_index_start;
1009 /* Outer loop uses 30 flops */
1012 /* Increment number of outer iterations */
1013 outeriter += nri;
1015 /* Update outer/inner flops */
1017 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3W3_F,outeriter*30 + inneriter*270);