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.
44 #include "../nb_kernel.h"
45 #include "gromacs/gmxlib/nrnb.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJSh_GeomW4W4_VF_c
49 * Electrostatics interaction: Ewald
50 * VdW interaction: LennardJones
51 * Geometry: Water4-Water4
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecEwSh_VdwLJSh_GeomW4W4_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
;
71 real ix0
,iy0
,iz0
,fix0
,fiy0
,fiz0
,iq0
,isai0
;
73 real ix1
,iy1
,iz1
,fix1
,fiy1
,fiz1
,iq1
,isai1
;
75 real ix2
,iy2
,iz2
,fix2
,fiy2
,fiz2
,iq2
,isai2
;
77 real ix3
,iy3
,iz3
,fix3
,fiy3
,fiz3
,iq3
,isai3
;
79 real jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
81 real jx1
,jy1
,jz1
,fjx1
,fjy1
,fjz1
,jq1
,isaj1
;
83 real jx2
,jy2
,jz2
,fjx2
,fjy2
,fjz2
,jq2
,isaj2
;
85 real jx3
,jy3
,jz3
,fjx3
,fjy3
,fjz3
,jq3
,isaj3
;
86 real dx00
,dy00
,dz00
,rsq00
,rinv00
,rinvsq00
,r00
,qq00
,c6_00
,c12_00
,cexp1_00
,cexp2_00
;
87 real dx11
,dy11
,dz11
,rsq11
,rinv11
,rinvsq11
,r11
,qq11
,c6_11
,c12_11
,cexp1_11
,cexp2_11
;
88 real dx12
,dy12
,dz12
,rsq12
,rinv12
,rinvsq12
,r12
,qq12
,c6_12
,c12_12
,cexp1_12
,cexp2_12
;
89 real dx13
,dy13
,dz13
,rsq13
,rinv13
,rinvsq13
,r13
,qq13
,c6_13
,c12_13
,cexp1_13
,cexp2_13
;
90 real dx21
,dy21
,dz21
,rsq21
,rinv21
,rinvsq21
,r21
,qq21
,c6_21
,c12_21
,cexp1_21
,cexp2_21
;
91 real dx22
,dy22
,dz22
,rsq22
,rinv22
,rinvsq22
,r22
,qq22
,c6_22
,c12_22
,cexp1_22
,cexp2_22
;
92 real dx23
,dy23
,dz23
,rsq23
,rinv23
,rinvsq23
,r23
,qq23
,c6_23
,c12_23
,cexp1_23
,cexp2_23
;
93 real dx31
,dy31
,dz31
,rsq31
,rinv31
,rinvsq31
,r31
,qq31
,c6_31
,c12_31
,cexp1_31
,cexp2_31
;
94 real dx32
,dy32
,dz32
,rsq32
,rinv32
,rinvsq32
,r32
,qq32
,c6_32
,c12_32
,cexp1_32
,cexp2_32
;
95 real dx33
,dy33
,dz33
,rsq33
,rinv33
,rinvsq33
,r33
,qq33
,c6_33
,c12_33
,cexp1_33
,cexp2_33
;
96 real velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
99 real rinvsix
,rvdw
,vvdw
,vvdw6
,vvdw12
,fvdw
,fvdw6
,fvdw12
,vvdwsum
,br
,vvdwexp
,sh_vdw_invrcut6
;
103 real ewtabscale
,eweps
,sh_ewald
,ewrt
,ewtabhalfspace
;
111 jindex
= nlist
->jindex
;
113 shiftidx
= nlist
->shift
;
115 shiftvec
= fr
->shift_vec
[0];
116 fshift
= fr
->fshift
[0];
117 facel
= fr
->ic
->epsfac
;
118 charge
= mdatoms
->chargeA
;
119 nvdwtype
= fr
->ntype
;
121 vdwtype
= mdatoms
->typeA
;
123 sh_ewald
= fr
->ic
->sh_ewald
;
124 ewtab
= fr
->ic
->tabq_coul_FDV0
;
125 ewtabscale
= fr
->ic
->tabq_scale
;
126 ewtabhalfspace
= 0.5/ewtabscale
;
128 /* Setup water-specific parameters */
129 inr
= nlist
->iinr
[0];
130 iq1
= facel
*charge
[inr
+1];
131 iq2
= facel
*charge
[inr
+2];
132 iq3
= facel
*charge
[inr
+3];
133 vdwioffset0
= 2*nvdwtype
*vdwtype
[inr
+0];
138 vdwjidx0
= 2*vdwtype
[inr
+0];
139 c6_00
= vdwparam
[vdwioffset0
+vdwjidx0
];
140 c12_00
= vdwparam
[vdwioffset0
+vdwjidx0
+1];
151 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
152 rcutoff
= fr
->ic
->rcoulomb
;
153 rcutoff2
= rcutoff
*rcutoff
;
155 sh_vdw_invrcut6
= fr
->ic
->sh_invrc6
;
161 /* Start outer loop over neighborlists */
162 for(iidx
=0; iidx
<nri
; iidx
++)
164 /* Load shift vector for this list */
165 i_shift_offset
= DIM
*shiftidx
[iidx
];
166 shX
= shiftvec
[i_shift_offset
+XX
];
167 shY
= shiftvec
[i_shift_offset
+YY
];
168 shZ
= shiftvec
[i_shift_offset
+ZZ
];
170 /* Load limits for loop over neighbors */
171 j_index_start
= jindex
[iidx
];
172 j_index_end
= jindex
[iidx
+1];
174 /* Get outer coordinate index */
176 i_coord_offset
= DIM
*inr
;
178 /* Load i particle coords and add shift vector */
179 ix0
= shX
+ x
[i_coord_offset
+DIM
*0+XX
];
180 iy0
= shY
+ x
[i_coord_offset
+DIM
*0+YY
];
181 iz0
= shZ
+ x
[i_coord_offset
+DIM
*0+ZZ
];
182 ix1
= shX
+ x
[i_coord_offset
+DIM
*1+XX
];
183 iy1
= shY
+ x
[i_coord_offset
+DIM
*1+YY
];
184 iz1
= shZ
+ x
[i_coord_offset
+DIM
*1+ZZ
];
185 ix2
= shX
+ x
[i_coord_offset
+DIM
*2+XX
];
186 iy2
= shY
+ x
[i_coord_offset
+DIM
*2+YY
];
187 iz2
= shZ
+ x
[i_coord_offset
+DIM
*2+ZZ
];
188 ix3
= shX
+ x
[i_coord_offset
+DIM
*3+XX
];
189 iy3
= shY
+ x
[i_coord_offset
+DIM
*3+YY
];
190 iz3
= shZ
+ x
[i_coord_offset
+DIM
*3+ZZ
];
205 /* Reset potential sums */
209 /* Start inner kernel loop */
210 for(jidx
=j_index_start
; jidx
<j_index_end
; jidx
++)
212 /* Get j neighbor index, and coordinate index */
214 j_coord_offset
= DIM
*jnr
;
216 /* load j atom coordinates */
217 jx0
= x
[j_coord_offset
+DIM
*0+XX
];
218 jy0
= x
[j_coord_offset
+DIM
*0+YY
];
219 jz0
= x
[j_coord_offset
+DIM
*0+ZZ
];
220 jx1
= x
[j_coord_offset
+DIM
*1+XX
];
221 jy1
= x
[j_coord_offset
+DIM
*1+YY
];
222 jz1
= x
[j_coord_offset
+DIM
*1+ZZ
];
223 jx2
= x
[j_coord_offset
+DIM
*2+XX
];
224 jy2
= x
[j_coord_offset
+DIM
*2+YY
];
225 jz2
= x
[j_coord_offset
+DIM
*2+ZZ
];
226 jx3
= x
[j_coord_offset
+DIM
*3+XX
];
227 jy3
= x
[j_coord_offset
+DIM
*3+YY
];
228 jz3
= x
[j_coord_offset
+DIM
*3+ZZ
];
230 /* Calculate displacement vector */
262 /* Calculate squared distance and things based on it */
263 rsq00
= dx00
*dx00
+dy00
*dy00
+dz00
*dz00
;
264 rsq11
= dx11
*dx11
+dy11
*dy11
+dz11
*dz11
;
265 rsq12
= dx12
*dx12
+dy12
*dy12
+dz12
*dz12
;
266 rsq13
= dx13
*dx13
+dy13
*dy13
+dz13
*dz13
;
267 rsq21
= dx21
*dx21
+dy21
*dy21
+dz21
*dz21
;
268 rsq22
= dx22
*dx22
+dy22
*dy22
+dz22
*dz22
;
269 rsq23
= dx23
*dx23
+dy23
*dy23
+dz23
*dz23
;
270 rsq31
= dx31
*dx31
+dy31
*dy31
+dz31
*dz31
;
271 rsq32
= dx32
*dx32
+dy32
*dy32
+dz32
*dz32
;
272 rsq33
= dx33
*dx33
+dy33
*dy33
+dz33
*dz33
;
274 rinv11
= 1.0/sqrt(rsq11
);
275 rinv12
= 1.0/sqrt(rsq12
);
276 rinv13
= 1.0/sqrt(rsq13
);
277 rinv21
= 1.0/sqrt(rsq21
);
278 rinv22
= 1.0/sqrt(rsq22
);
279 rinv23
= 1.0/sqrt(rsq23
);
280 rinv31
= 1.0/sqrt(rsq31
);
281 rinv32
= 1.0/sqrt(rsq32
);
282 rinv33
= 1.0/sqrt(rsq33
);
284 rinvsq00
= 1.0/rsq00
;
285 rinvsq11
= rinv11
*rinv11
;
286 rinvsq12
= rinv12
*rinv12
;
287 rinvsq13
= rinv13
*rinv13
;
288 rinvsq21
= rinv21
*rinv21
;
289 rinvsq22
= rinv22
*rinv22
;
290 rinvsq23
= rinv23
*rinv23
;
291 rinvsq31
= rinv31
*rinv31
;
292 rinvsq32
= rinv32
*rinv32
;
293 rinvsq33
= rinv33
*rinv33
;
295 /**************************
296 * CALCULATE INTERACTIONS *
297 **************************/
302 /* LENNARD-JONES DISPERSION/REPULSION */
304 rinvsix
= rinvsq00
*rinvsq00
*rinvsq00
;
305 vvdw6
= c6_00
*rinvsix
;
306 vvdw12
= c12_00
*rinvsix
*rinvsix
;
307 vvdw
= (vvdw12
- c12_00
*sh_vdw_invrcut6
*sh_vdw_invrcut6
)*(1.0/12.0) - (vvdw6
- c6_00
*sh_vdw_invrcut6
)*(1.0/6.0);
308 fvdw
= (vvdw12
-vvdw6
)*rinvsq00
;
310 /* Update potential sums from outer loop */
315 /* Calculate temporary vectorial force */
320 /* Update vectorial force */
324 f
[j_coord_offset
+DIM
*0+XX
] -= tx
;
325 f
[j_coord_offset
+DIM
*0+YY
] -= ty
;
326 f
[j_coord_offset
+DIM
*0+ZZ
] -= tz
;
330 /**************************
331 * CALCULATE INTERACTIONS *
332 **************************/
339 /* EWALD ELECTROSTATICS */
341 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
342 ewrt
= r11
*ewtabscale
;
346 felec
= ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
347 velec
= qq11
*((rinv11
-sh_ewald
)-(ewtab
[ewitab
+2]-ewtabhalfspace
*eweps
*(ewtab
[ewitab
]+felec
)));
348 felec
= qq11
*rinv11
*(rinvsq11
-felec
);
350 /* Update potential sums from outer loop */
355 /* Calculate temporary vectorial force */
360 /* Update vectorial force */
364 f
[j_coord_offset
+DIM
*1+XX
] -= tx
;
365 f
[j_coord_offset
+DIM
*1+YY
] -= ty
;
366 f
[j_coord_offset
+DIM
*1+ZZ
] -= tz
;
370 /**************************
371 * CALCULATE INTERACTIONS *
372 **************************/
379 /* EWALD ELECTROSTATICS */
381 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
382 ewrt
= r12
*ewtabscale
;
386 felec
= ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
387 velec
= qq12
*((rinv12
-sh_ewald
)-(ewtab
[ewitab
+2]-ewtabhalfspace
*eweps
*(ewtab
[ewitab
]+felec
)));
388 felec
= qq12
*rinv12
*(rinvsq12
-felec
);
390 /* Update potential sums from outer loop */
395 /* Calculate temporary vectorial force */
400 /* Update vectorial force */
404 f
[j_coord_offset
+DIM
*2+XX
] -= tx
;
405 f
[j_coord_offset
+DIM
*2+YY
] -= ty
;
406 f
[j_coord_offset
+DIM
*2+ZZ
] -= tz
;
410 /**************************
411 * CALCULATE INTERACTIONS *
412 **************************/
419 /* EWALD ELECTROSTATICS */
421 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
422 ewrt
= r13
*ewtabscale
;
426 felec
= ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
427 velec
= qq13
*((rinv13
-sh_ewald
)-(ewtab
[ewitab
+2]-ewtabhalfspace
*eweps
*(ewtab
[ewitab
]+felec
)));
428 felec
= qq13
*rinv13
*(rinvsq13
-felec
);
430 /* Update potential sums from outer loop */
435 /* Calculate temporary vectorial force */
440 /* Update vectorial force */
444 f
[j_coord_offset
+DIM
*3+XX
] -= tx
;
445 f
[j_coord_offset
+DIM
*3+YY
] -= ty
;
446 f
[j_coord_offset
+DIM
*3+ZZ
] -= tz
;
450 /**************************
451 * CALCULATE INTERACTIONS *
452 **************************/
459 /* EWALD ELECTROSTATICS */
461 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
462 ewrt
= r21
*ewtabscale
;
466 felec
= ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
467 velec
= qq21
*((rinv21
-sh_ewald
)-(ewtab
[ewitab
+2]-ewtabhalfspace
*eweps
*(ewtab
[ewitab
]+felec
)));
468 felec
= qq21
*rinv21
*(rinvsq21
-felec
);
470 /* Update potential sums from outer loop */
475 /* Calculate temporary vectorial force */
480 /* Update vectorial force */
484 f
[j_coord_offset
+DIM
*1+XX
] -= tx
;
485 f
[j_coord_offset
+DIM
*1+YY
] -= ty
;
486 f
[j_coord_offset
+DIM
*1+ZZ
] -= tz
;
490 /**************************
491 * CALCULATE INTERACTIONS *
492 **************************/
499 /* EWALD ELECTROSTATICS */
501 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
502 ewrt
= r22
*ewtabscale
;
506 felec
= ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
507 velec
= qq22
*((rinv22
-sh_ewald
)-(ewtab
[ewitab
+2]-ewtabhalfspace
*eweps
*(ewtab
[ewitab
]+felec
)));
508 felec
= qq22
*rinv22
*(rinvsq22
-felec
);
510 /* Update potential sums from outer loop */
515 /* Calculate temporary vectorial force */
520 /* Update vectorial force */
524 f
[j_coord_offset
+DIM
*2+XX
] -= tx
;
525 f
[j_coord_offset
+DIM
*2+YY
] -= ty
;
526 f
[j_coord_offset
+DIM
*2+ZZ
] -= tz
;
530 /**************************
531 * CALCULATE INTERACTIONS *
532 **************************/
539 /* EWALD ELECTROSTATICS */
541 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
542 ewrt
= r23
*ewtabscale
;
546 felec
= ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
547 velec
= qq23
*((rinv23
-sh_ewald
)-(ewtab
[ewitab
+2]-ewtabhalfspace
*eweps
*(ewtab
[ewitab
]+felec
)));
548 felec
= qq23
*rinv23
*(rinvsq23
-felec
);
550 /* Update potential sums from outer loop */
555 /* Calculate temporary vectorial force */
560 /* Update vectorial force */
564 f
[j_coord_offset
+DIM
*3+XX
] -= tx
;
565 f
[j_coord_offset
+DIM
*3+YY
] -= ty
;
566 f
[j_coord_offset
+DIM
*3+ZZ
] -= tz
;
570 /**************************
571 * CALCULATE INTERACTIONS *
572 **************************/
579 /* EWALD ELECTROSTATICS */
581 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
582 ewrt
= r31
*ewtabscale
;
586 felec
= ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
587 velec
= qq31
*((rinv31
-sh_ewald
)-(ewtab
[ewitab
+2]-ewtabhalfspace
*eweps
*(ewtab
[ewitab
]+felec
)));
588 felec
= qq31
*rinv31
*(rinvsq31
-felec
);
590 /* Update potential sums from outer loop */
595 /* Calculate temporary vectorial force */
600 /* Update vectorial force */
604 f
[j_coord_offset
+DIM
*1+XX
] -= tx
;
605 f
[j_coord_offset
+DIM
*1+YY
] -= ty
;
606 f
[j_coord_offset
+DIM
*1+ZZ
] -= tz
;
610 /**************************
611 * CALCULATE INTERACTIONS *
612 **************************/
619 /* EWALD ELECTROSTATICS */
621 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
622 ewrt
= r32
*ewtabscale
;
626 felec
= ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
627 velec
= qq32
*((rinv32
-sh_ewald
)-(ewtab
[ewitab
+2]-ewtabhalfspace
*eweps
*(ewtab
[ewitab
]+felec
)));
628 felec
= qq32
*rinv32
*(rinvsq32
-felec
);
630 /* Update potential sums from outer loop */
635 /* Calculate temporary vectorial force */
640 /* Update vectorial force */
644 f
[j_coord_offset
+DIM
*2+XX
] -= tx
;
645 f
[j_coord_offset
+DIM
*2+YY
] -= ty
;
646 f
[j_coord_offset
+DIM
*2+ZZ
] -= tz
;
650 /**************************
651 * CALCULATE INTERACTIONS *
652 **************************/
659 /* EWALD ELECTROSTATICS */
661 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
662 ewrt
= r33
*ewtabscale
;
666 felec
= ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
667 velec
= qq33
*((rinv33
-sh_ewald
)-(ewtab
[ewitab
+2]-ewtabhalfspace
*eweps
*(ewtab
[ewitab
]+felec
)));
668 felec
= qq33
*rinv33
*(rinvsq33
-felec
);
670 /* Update potential sums from outer loop */
675 /* Calculate temporary vectorial force */
680 /* Update vectorial force */
684 f
[j_coord_offset
+DIM
*3+XX
] -= tx
;
685 f
[j_coord_offset
+DIM
*3+YY
] -= ty
;
686 f
[j_coord_offset
+DIM
*3+ZZ
] -= tz
;
690 /* Inner loop uses 406 flops */
692 /* End of innermost loop */
695 f
[i_coord_offset
+DIM
*0+XX
] += fix0
;
696 f
[i_coord_offset
+DIM
*0+YY
] += fiy0
;
697 f
[i_coord_offset
+DIM
*0+ZZ
] += fiz0
;
701 f
[i_coord_offset
+DIM
*1+XX
] += fix1
;
702 f
[i_coord_offset
+DIM
*1+YY
] += fiy1
;
703 f
[i_coord_offset
+DIM
*1+ZZ
] += fiz1
;
707 f
[i_coord_offset
+DIM
*2+XX
] += fix2
;
708 f
[i_coord_offset
+DIM
*2+YY
] += fiy2
;
709 f
[i_coord_offset
+DIM
*2+ZZ
] += fiz2
;
713 f
[i_coord_offset
+DIM
*3+XX
] += fix3
;
714 f
[i_coord_offset
+DIM
*3+YY
] += fiy3
;
715 f
[i_coord_offset
+DIM
*3+ZZ
] += fiz3
;
719 fshift
[i_shift_offset
+XX
] += tx
;
720 fshift
[i_shift_offset
+YY
] += ty
;
721 fshift
[i_shift_offset
+ZZ
] += tz
;
724 /* Update potential energies */
725 kernel_data
->energygrp_elec
[ggid
] += velecsum
;
726 kernel_data
->energygrp_vdw
[ggid
] += vvdwsum
;
728 /* Increment number of inner iterations */
729 inneriter
+= j_index_end
- j_index_start
;
731 /* Outer loop uses 41 flops */
734 /* Increment number of outer iterations */
737 /* Update outer/inner flops */
739 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_VDW_W4W4_VF
,outeriter
*41 + inneriter
*406);
742 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwLJSh_GeomW4W4_F_c
743 * Electrostatics interaction: Ewald
744 * VdW interaction: LennardJones
745 * Geometry: Water4-Water4
746 * Calculate force/pot: Force
749 nb_kernel_ElecEwSh_VdwLJSh_GeomW4W4_F_c
750 (t_nblist
* gmx_restrict nlist
,
751 rvec
* gmx_restrict xx
,
752 rvec
* gmx_restrict ff
,
753 struct t_forcerec
* gmx_restrict fr
,
754 t_mdatoms
* gmx_restrict mdatoms
,
755 nb_kernel_data_t gmx_unused
* gmx_restrict kernel_data
,
756 t_nrnb
* gmx_restrict nrnb
)
758 int i_shift_offset
,i_coord_offset
,j_coord_offset
;
759 int j_index_start
,j_index_end
;
760 int nri
,inr
,ggid
,iidx
,jidx
,jnr
,outeriter
,inneriter
;
761 real shX
,shY
,shZ
,tx
,ty
,tz
,fscal
,rcutoff
,rcutoff2
;
762 int *iinr
,*jindex
,*jjnr
,*shiftidx
,*gid
;
763 real
*shiftvec
,*fshift
,*x
,*f
;
765 real ix0
,iy0
,iz0
,fix0
,fiy0
,fiz0
,iq0
,isai0
;
767 real ix1
,iy1
,iz1
,fix1
,fiy1
,fiz1
,iq1
,isai1
;
769 real ix2
,iy2
,iz2
,fix2
,fiy2
,fiz2
,iq2
,isai2
;
771 real ix3
,iy3
,iz3
,fix3
,fiy3
,fiz3
,iq3
,isai3
;
773 real jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
775 real jx1
,jy1
,jz1
,fjx1
,fjy1
,fjz1
,jq1
,isaj1
;
777 real jx2
,jy2
,jz2
,fjx2
,fjy2
,fjz2
,jq2
,isaj2
;
779 real jx3
,jy3
,jz3
,fjx3
,fjy3
,fjz3
,jq3
,isaj3
;
780 real dx00
,dy00
,dz00
,rsq00
,rinv00
,rinvsq00
,r00
,qq00
,c6_00
,c12_00
,cexp1_00
,cexp2_00
;
781 real dx11
,dy11
,dz11
,rsq11
,rinv11
,rinvsq11
,r11
,qq11
,c6_11
,c12_11
,cexp1_11
,cexp2_11
;
782 real dx12
,dy12
,dz12
,rsq12
,rinv12
,rinvsq12
,r12
,qq12
,c6_12
,c12_12
,cexp1_12
,cexp2_12
;
783 real dx13
,dy13
,dz13
,rsq13
,rinv13
,rinvsq13
,r13
,qq13
,c6_13
,c12_13
,cexp1_13
,cexp2_13
;
784 real dx21
,dy21
,dz21
,rsq21
,rinv21
,rinvsq21
,r21
,qq21
,c6_21
,c12_21
,cexp1_21
,cexp2_21
;
785 real dx22
,dy22
,dz22
,rsq22
,rinv22
,rinvsq22
,r22
,qq22
,c6_22
,c12_22
,cexp1_22
,cexp2_22
;
786 real dx23
,dy23
,dz23
,rsq23
,rinv23
,rinvsq23
,r23
,qq23
,c6_23
,c12_23
,cexp1_23
,cexp2_23
;
787 real dx31
,dy31
,dz31
,rsq31
,rinv31
,rinvsq31
,r31
,qq31
,c6_31
,c12_31
,cexp1_31
,cexp2_31
;
788 real dx32
,dy32
,dz32
,rsq32
,rinv32
,rinvsq32
,r32
,qq32
,c6_32
,c12_32
,cexp1_32
,cexp2_32
;
789 real dx33
,dy33
,dz33
,rsq33
,rinv33
,rinvsq33
,r33
,qq33
,c6_33
,c12_33
,cexp1_33
,cexp2_33
;
790 real velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
793 real rinvsix
,rvdw
,vvdw
,vvdw6
,vvdw12
,fvdw
,fvdw6
,fvdw12
,vvdwsum
,br
,vvdwexp
,sh_vdw_invrcut6
;
797 real ewtabscale
,eweps
,sh_ewald
,ewrt
,ewtabhalfspace
;
805 jindex
= nlist
->jindex
;
807 shiftidx
= nlist
->shift
;
809 shiftvec
= fr
->shift_vec
[0];
810 fshift
= fr
->fshift
[0];
811 facel
= fr
->ic
->epsfac
;
812 charge
= mdatoms
->chargeA
;
813 nvdwtype
= fr
->ntype
;
815 vdwtype
= mdatoms
->typeA
;
817 sh_ewald
= fr
->ic
->sh_ewald
;
818 ewtab
= fr
->ic
->tabq_coul_F
;
819 ewtabscale
= fr
->ic
->tabq_scale
;
820 ewtabhalfspace
= 0.5/ewtabscale
;
822 /* Setup water-specific parameters */
823 inr
= nlist
->iinr
[0];
824 iq1
= facel
*charge
[inr
+1];
825 iq2
= facel
*charge
[inr
+2];
826 iq3
= facel
*charge
[inr
+3];
827 vdwioffset0
= 2*nvdwtype
*vdwtype
[inr
+0];
832 vdwjidx0
= 2*vdwtype
[inr
+0];
833 c6_00
= vdwparam
[vdwioffset0
+vdwjidx0
];
834 c12_00
= vdwparam
[vdwioffset0
+vdwjidx0
+1];
845 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
846 rcutoff
= fr
->ic
->rcoulomb
;
847 rcutoff2
= rcutoff
*rcutoff
;
849 sh_vdw_invrcut6
= fr
->ic
->sh_invrc6
;
855 /* Start outer loop over neighborlists */
856 for(iidx
=0; iidx
<nri
; iidx
++)
858 /* Load shift vector for this list */
859 i_shift_offset
= DIM
*shiftidx
[iidx
];
860 shX
= shiftvec
[i_shift_offset
+XX
];
861 shY
= shiftvec
[i_shift_offset
+YY
];
862 shZ
= shiftvec
[i_shift_offset
+ZZ
];
864 /* Load limits for loop over neighbors */
865 j_index_start
= jindex
[iidx
];
866 j_index_end
= jindex
[iidx
+1];
868 /* Get outer coordinate index */
870 i_coord_offset
= DIM
*inr
;
872 /* Load i particle coords and add shift vector */
873 ix0
= shX
+ x
[i_coord_offset
+DIM
*0+XX
];
874 iy0
= shY
+ x
[i_coord_offset
+DIM
*0+YY
];
875 iz0
= shZ
+ x
[i_coord_offset
+DIM
*0+ZZ
];
876 ix1
= shX
+ x
[i_coord_offset
+DIM
*1+XX
];
877 iy1
= shY
+ x
[i_coord_offset
+DIM
*1+YY
];
878 iz1
= shZ
+ x
[i_coord_offset
+DIM
*1+ZZ
];
879 ix2
= shX
+ x
[i_coord_offset
+DIM
*2+XX
];
880 iy2
= shY
+ x
[i_coord_offset
+DIM
*2+YY
];
881 iz2
= shZ
+ x
[i_coord_offset
+DIM
*2+ZZ
];
882 ix3
= shX
+ x
[i_coord_offset
+DIM
*3+XX
];
883 iy3
= shY
+ x
[i_coord_offset
+DIM
*3+YY
];
884 iz3
= shZ
+ x
[i_coord_offset
+DIM
*3+ZZ
];
899 /* Start inner kernel loop */
900 for(jidx
=j_index_start
; jidx
<j_index_end
; jidx
++)
902 /* Get j neighbor index, and coordinate index */
904 j_coord_offset
= DIM
*jnr
;
906 /* load j atom coordinates */
907 jx0
= x
[j_coord_offset
+DIM
*0+XX
];
908 jy0
= x
[j_coord_offset
+DIM
*0+YY
];
909 jz0
= x
[j_coord_offset
+DIM
*0+ZZ
];
910 jx1
= x
[j_coord_offset
+DIM
*1+XX
];
911 jy1
= x
[j_coord_offset
+DIM
*1+YY
];
912 jz1
= x
[j_coord_offset
+DIM
*1+ZZ
];
913 jx2
= x
[j_coord_offset
+DIM
*2+XX
];
914 jy2
= x
[j_coord_offset
+DIM
*2+YY
];
915 jz2
= x
[j_coord_offset
+DIM
*2+ZZ
];
916 jx3
= x
[j_coord_offset
+DIM
*3+XX
];
917 jy3
= x
[j_coord_offset
+DIM
*3+YY
];
918 jz3
= x
[j_coord_offset
+DIM
*3+ZZ
];
920 /* Calculate displacement vector */
952 /* Calculate squared distance and things based on it */
953 rsq00
= dx00
*dx00
+dy00
*dy00
+dz00
*dz00
;
954 rsq11
= dx11
*dx11
+dy11
*dy11
+dz11
*dz11
;
955 rsq12
= dx12
*dx12
+dy12
*dy12
+dz12
*dz12
;
956 rsq13
= dx13
*dx13
+dy13
*dy13
+dz13
*dz13
;
957 rsq21
= dx21
*dx21
+dy21
*dy21
+dz21
*dz21
;
958 rsq22
= dx22
*dx22
+dy22
*dy22
+dz22
*dz22
;
959 rsq23
= dx23
*dx23
+dy23
*dy23
+dz23
*dz23
;
960 rsq31
= dx31
*dx31
+dy31
*dy31
+dz31
*dz31
;
961 rsq32
= dx32
*dx32
+dy32
*dy32
+dz32
*dz32
;
962 rsq33
= dx33
*dx33
+dy33
*dy33
+dz33
*dz33
;
964 rinv11
= 1.0/sqrt(rsq11
);
965 rinv12
= 1.0/sqrt(rsq12
);
966 rinv13
= 1.0/sqrt(rsq13
);
967 rinv21
= 1.0/sqrt(rsq21
);
968 rinv22
= 1.0/sqrt(rsq22
);
969 rinv23
= 1.0/sqrt(rsq23
);
970 rinv31
= 1.0/sqrt(rsq31
);
971 rinv32
= 1.0/sqrt(rsq32
);
972 rinv33
= 1.0/sqrt(rsq33
);
974 rinvsq00
= 1.0/rsq00
;
975 rinvsq11
= rinv11
*rinv11
;
976 rinvsq12
= rinv12
*rinv12
;
977 rinvsq13
= rinv13
*rinv13
;
978 rinvsq21
= rinv21
*rinv21
;
979 rinvsq22
= rinv22
*rinv22
;
980 rinvsq23
= rinv23
*rinv23
;
981 rinvsq31
= rinv31
*rinv31
;
982 rinvsq32
= rinv32
*rinv32
;
983 rinvsq33
= rinv33
*rinv33
;
985 /**************************
986 * CALCULATE INTERACTIONS *
987 **************************/
992 /* LENNARD-JONES DISPERSION/REPULSION */
994 rinvsix
= rinvsq00
*rinvsq00
*rinvsq00
;
995 fvdw
= (c12_00
*rinvsix
-c6_00
)*rinvsix
*rinvsq00
;
999 /* Calculate temporary vectorial force */
1004 /* Update vectorial force */
1008 f
[j_coord_offset
+DIM
*0+XX
] -= tx
;
1009 f
[j_coord_offset
+DIM
*0+YY
] -= ty
;
1010 f
[j_coord_offset
+DIM
*0+ZZ
] -= tz
;
1014 /**************************
1015 * CALCULATE INTERACTIONS *
1016 **************************/
1023 /* EWALD ELECTROSTATICS */
1025 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1026 ewrt
= r11
*ewtabscale
;
1028 eweps
= ewrt
-ewitab
;
1029 felec
= (1.0-eweps
)*ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
1030 felec
= qq11
*rinv11
*(rinvsq11
-felec
);
1034 /* Calculate temporary vectorial force */
1039 /* Update vectorial force */
1043 f
[j_coord_offset
+DIM
*1+XX
] -= tx
;
1044 f
[j_coord_offset
+DIM
*1+YY
] -= ty
;
1045 f
[j_coord_offset
+DIM
*1+ZZ
] -= tz
;
1049 /**************************
1050 * CALCULATE INTERACTIONS *
1051 **************************/
1058 /* EWALD ELECTROSTATICS */
1060 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1061 ewrt
= r12
*ewtabscale
;
1063 eweps
= ewrt
-ewitab
;
1064 felec
= (1.0-eweps
)*ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
1065 felec
= qq12
*rinv12
*(rinvsq12
-felec
);
1069 /* Calculate temporary vectorial force */
1074 /* Update vectorial force */
1078 f
[j_coord_offset
+DIM
*2+XX
] -= tx
;
1079 f
[j_coord_offset
+DIM
*2+YY
] -= ty
;
1080 f
[j_coord_offset
+DIM
*2+ZZ
] -= tz
;
1084 /**************************
1085 * CALCULATE INTERACTIONS *
1086 **************************/
1093 /* EWALD ELECTROSTATICS */
1095 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1096 ewrt
= r13
*ewtabscale
;
1098 eweps
= ewrt
-ewitab
;
1099 felec
= (1.0-eweps
)*ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
1100 felec
= qq13
*rinv13
*(rinvsq13
-felec
);
1104 /* Calculate temporary vectorial force */
1109 /* Update vectorial force */
1113 f
[j_coord_offset
+DIM
*3+XX
] -= tx
;
1114 f
[j_coord_offset
+DIM
*3+YY
] -= ty
;
1115 f
[j_coord_offset
+DIM
*3+ZZ
] -= tz
;
1119 /**************************
1120 * CALCULATE INTERACTIONS *
1121 **************************/
1128 /* EWALD ELECTROSTATICS */
1130 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1131 ewrt
= r21
*ewtabscale
;
1133 eweps
= ewrt
-ewitab
;
1134 felec
= (1.0-eweps
)*ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
1135 felec
= qq21
*rinv21
*(rinvsq21
-felec
);
1139 /* Calculate temporary vectorial force */
1144 /* Update vectorial force */
1148 f
[j_coord_offset
+DIM
*1+XX
] -= tx
;
1149 f
[j_coord_offset
+DIM
*1+YY
] -= ty
;
1150 f
[j_coord_offset
+DIM
*1+ZZ
] -= tz
;
1154 /**************************
1155 * CALCULATE INTERACTIONS *
1156 **************************/
1163 /* EWALD ELECTROSTATICS */
1165 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1166 ewrt
= r22
*ewtabscale
;
1168 eweps
= ewrt
-ewitab
;
1169 felec
= (1.0-eweps
)*ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
1170 felec
= qq22
*rinv22
*(rinvsq22
-felec
);
1174 /* Calculate temporary vectorial force */
1179 /* Update vectorial force */
1183 f
[j_coord_offset
+DIM
*2+XX
] -= tx
;
1184 f
[j_coord_offset
+DIM
*2+YY
] -= ty
;
1185 f
[j_coord_offset
+DIM
*2+ZZ
] -= tz
;
1189 /**************************
1190 * CALCULATE INTERACTIONS *
1191 **************************/
1198 /* EWALD ELECTROSTATICS */
1200 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1201 ewrt
= r23
*ewtabscale
;
1203 eweps
= ewrt
-ewitab
;
1204 felec
= (1.0-eweps
)*ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
1205 felec
= qq23
*rinv23
*(rinvsq23
-felec
);
1209 /* Calculate temporary vectorial force */
1214 /* Update vectorial force */
1218 f
[j_coord_offset
+DIM
*3+XX
] -= tx
;
1219 f
[j_coord_offset
+DIM
*3+YY
] -= ty
;
1220 f
[j_coord_offset
+DIM
*3+ZZ
] -= tz
;
1224 /**************************
1225 * CALCULATE INTERACTIONS *
1226 **************************/
1233 /* EWALD ELECTROSTATICS */
1235 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1236 ewrt
= r31
*ewtabscale
;
1238 eweps
= ewrt
-ewitab
;
1239 felec
= (1.0-eweps
)*ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
1240 felec
= qq31
*rinv31
*(rinvsq31
-felec
);
1244 /* Calculate temporary vectorial force */
1249 /* Update vectorial force */
1253 f
[j_coord_offset
+DIM
*1+XX
] -= tx
;
1254 f
[j_coord_offset
+DIM
*1+YY
] -= ty
;
1255 f
[j_coord_offset
+DIM
*1+ZZ
] -= tz
;
1259 /**************************
1260 * CALCULATE INTERACTIONS *
1261 **************************/
1268 /* EWALD ELECTROSTATICS */
1270 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1271 ewrt
= r32
*ewtabscale
;
1273 eweps
= ewrt
-ewitab
;
1274 felec
= (1.0-eweps
)*ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
1275 felec
= qq32
*rinv32
*(rinvsq32
-felec
);
1279 /* Calculate temporary vectorial force */
1284 /* Update vectorial force */
1288 f
[j_coord_offset
+DIM
*2+XX
] -= tx
;
1289 f
[j_coord_offset
+DIM
*2+YY
] -= ty
;
1290 f
[j_coord_offset
+DIM
*2+ZZ
] -= tz
;
1294 /**************************
1295 * CALCULATE INTERACTIONS *
1296 **************************/
1303 /* EWALD ELECTROSTATICS */
1305 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
1306 ewrt
= r33
*ewtabscale
;
1308 eweps
= ewrt
-ewitab
;
1309 felec
= (1.0-eweps
)*ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
1310 felec
= qq33
*rinv33
*(rinvsq33
-felec
);
1314 /* Calculate temporary vectorial force */
1319 /* Update vectorial force */
1323 f
[j_coord_offset
+DIM
*3+XX
] -= tx
;
1324 f
[j_coord_offset
+DIM
*3+YY
] -= ty
;
1325 f
[j_coord_offset
+DIM
*3+ZZ
] -= tz
;
1329 /* Inner loop uses 324 flops */
1331 /* End of innermost loop */
1334 f
[i_coord_offset
+DIM
*0+XX
] += fix0
;
1335 f
[i_coord_offset
+DIM
*0+YY
] += fiy0
;
1336 f
[i_coord_offset
+DIM
*0+ZZ
] += fiz0
;
1340 f
[i_coord_offset
+DIM
*1+XX
] += fix1
;
1341 f
[i_coord_offset
+DIM
*1+YY
] += fiy1
;
1342 f
[i_coord_offset
+DIM
*1+ZZ
] += fiz1
;
1346 f
[i_coord_offset
+DIM
*2+XX
] += fix2
;
1347 f
[i_coord_offset
+DIM
*2+YY
] += fiy2
;
1348 f
[i_coord_offset
+DIM
*2+ZZ
] += fiz2
;
1352 f
[i_coord_offset
+DIM
*3+XX
] += fix3
;
1353 f
[i_coord_offset
+DIM
*3+YY
] += fiy3
;
1354 f
[i_coord_offset
+DIM
*3+ZZ
] += fiz3
;
1358 fshift
[i_shift_offset
+XX
] += tx
;
1359 fshift
[i_shift_offset
+YY
] += ty
;
1360 fshift
[i_shift_offset
+ZZ
] += tz
;
1362 /* Increment number of inner iterations */
1363 inneriter
+= j_index_end
- j_index_start
;
1365 /* Outer loop uses 39 flops */
1368 /* Increment number of outer iterations */
1371 /* Update outer/inner flops */
1373 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_VDW_W4W4_F
,outeriter
*39 + inneriter
*324);