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_ElecRFCut_VdwLJSw_GeomW4W4_VF_c
49 * Electrostatics interaction: ReactionField
50 * VdW interaction: LennardJones
51 * Geometry: Water4-Water4
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecRFCut_VdwLJSw_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
;
102 real rswitch
,swV3
,swV4
,swV5
,swF2
,swF3
,swF4
,d
,d2
,sw
,dsw
;
109 jindex
= nlist
->jindex
;
111 shiftidx
= nlist
->shift
;
113 shiftvec
= fr
->shift_vec
[0];
114 fshift
= fr
->fshift
[0];
115 facel
= fr
->ic
->epsfac
;
116 charge
= mdatoms
->chargeA
;
120 nvdwtype
= fr
->ntype
;
122 vdwtype
= mdatoms
->typeA
;
124 /* Setup water-specific parameters */
125 inr
= nlist
->iinr
[0];
126 iq1
= facel
*charge
[inr
+1];
127 iq2
= facel
*charge
[inr
+2];
128 iq3
= facel
*charge
[inr
+3];
129 vdwioffset0
= 2*nvdwtype
*vdwtype
[inr
+0];
134 vdwjidx0
= 2*vdwtype
[inr
+0];
135 c6_00
= vdwparam
[vdwioffset0
+vdwjidx0
];
136 c12_00
= vdwparam
[vdwioffset0
+vdwjidx0
+1];
147 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
148 rcutoff
= fr
->ic
->rcoulomb
;
149 rcutoff2
= rcutoff
*rcutoff
;
151 rswitch
= fr
->ic
->rvdw_switch
;
152 /* Setup switch parameters */
154 swV3
= -10.0/(d
*d
*d
);
155 swV4
= 15.0/(d
*d
*d
*d
);
156 swV5
= -6.0/(d
*d
*d
*d
*d
);
157 swF2
= -30.0/(d
*d
*d
);
158 swF3
= 60.0/(d
*d
*d
*d
);
159 swF4
= -30.0/(d
*d
*d
*d
*d
);
164 /* Start outer loop over neighborlists */
165 for(iidx
=0; iidx
<nri
; iidx
++)
167 /* Load shift vector for this list */
168 i_shift_offset
= DIM
*shiftidx
[iidx
];
169 shX
= shiftvec
[i_shift_offset
+XX
];
170 shY
= shiftvec
[i_shift_offset
+YY
];
171 shZ
= shiftvec
[i_shift_offset
+ZZ
];
173 /* Load limits for loop over neighbors */
174 j_index_start
= jindex
[iidx
];
175 j_index_end
= jindex
[iidx
+1];
177 /* Get outer coordinate index */
179 i_coord_offset
= DIM
*inr
;
181 /* Load i particle coords and add shift vector */
182 ix0
= shX
+ x
[i_coord_offset
+DIM
*0+XX
];
183 iy0
= shY
+ x
[i_coord_offset
+DIM
*0+YY
];
184 iz0
= shZ
+ x
[i_coord_offset
+DIM
*0+ZZ
];
185 ix1
= shX
+ x
[i_coord_offset
+DIM
*1+XX
];
186 iy1
= shY
+ x
[i_coord_offset
+DIM
*1+YY
];
187 iz1
= shZ
+ x
[i_coord_offset
+DIM
*1+ZZ
];
188 ix2
= shX
+ x
[i_coord_offset
+DIM
*2+XX
];
189 iy2
= shY
+ x
[i_coord_offset
+DIM
*2+YY
];
190 iz2
= shZ
+ x
[i_coord_offset
+DIM
*2+ZZ
];
191 ix3
= shX
+ x
[i_coord_offset
+DIM
*3+XX
];
192 iy3
= shY
+ x
[i_coord_offset
+DIM
*3+YY
];
193 iz3
= shZ
+ x
[i_coord_offset
+DIM
*3+ZZ
];
208 /* Reset potential sums */
212 /* Start inner kernel loop */
213 for(jidx
=j_index_start
; jidx
<j_index_end
; jidx
++)
215 /* Get j neighbor index, and coordinate index */
217 j_coord_offset
= DIM
*jnr
;
219 /* load j atom coordinates */
220 jx0
= x
[j_coord_offset
+DIM
*0+XX
];
221 jy0
= x
[j_coord_offset
+DIM
*0+YY
];
222 jz0
= x
[j_coord_offset
+DIM
*0+ZZ
];
223 jx1
= x
[j_coord_offset
+DIM
*1+XX
];
224 jy1
= x
[j_coord_offset
+DIM
*1+YY
];
225 jz1
= x
[j_coord_offset
+DIM
*1+ZZ
];
226 jx2
= x
[j_coord_offset
+DIM
*2+XX
];
227 jy2
= x
[j_coord_offset
+DIM
*2+YY
];
228 jz2
= x
[j_coord_offset
+DIM
*2+ZZ
];
229 jx3
= x
[j_coord_offset
+DIM
*3+XX
];
230 jy3
= x
[j_coord_offset
+DIM
*3+YY
];
231 jz3
= x
[j_coord_offset
+DIM
*3+ZZ
];
233 /* Calculate displacement vector */
265 /* Calculate squared distance and things based on it */
266 rsq00
= dx00
*dx00
+dy00
*dy00
+dz00
*dz00
;
267 rsq11
= dx11
*dx11
+dy11
*dy11
+dz11
*dz11
;
268 rsq12
= dx12
*dx12
+dy12
*dy12
+dz12
*dz12
;
269 rsq13
= dx13
*dx13
+dy13
*dy13
+dz13
*dz13
;
270 rsq21
= dx21
*dx21
+dy21
*dy21
+dz21
*dz21
;
271 rsq22
= dx22
*dx22
+dy22
*dy22
+dz22
*dz22
;
272 rsq23
= dx23
*dx23
+dy23
*dy23
+dz23
*dz23
;
273 rsq31
= dx31
*dx31
+dy31
*dy31
+dz31
*dz31
;
274 rsq32
= dx32
*dx32
+dy32
*dy32
+dz32
*dz32
;
275 rsq33
= dx33
*dx33
+dy33
*dy33
+dz33
*dz33
;
277 rinv00
= 1.0/sqrt(rsq00
);
278 rinv11
= 1.0/sqrt(rsq11
);
279 rinv12
= 1.0/sqrt(rsq12
);
280 rinv13
= 1.0/sqrt(rsq13
);
281 rinv21
= 1.0/sqrt(rsq21
);
282 rinv22
= 1.0/sqrt(rsq22
);
283 rinv23
= 1.0/sqrt(rsq23
);
284 rinv31
= 1.0/sqrt(rsq31
);
285 rinv32
= 1.0/sqrt(rsq32
);
286 rinv33
= 1.0/sqrt(rsq33
);
288 rinvsq00
= rinv00
*rinv00
;
289 rinvsq11
= rinv11
*rinv11
;
290 rinvsq12
= rinv12
*rinv12
;
291 rinvsq13
= rinv13
*rinv13
;
292 rinvsq21
= rinv21
*rinv21
;
293 rinvsq22
= rinv22
*rinv22
;
294 rinvsq23
= rinv23
*rinv23
;
295 rinvsq31
= rinv31
*rinv31
;
296 rinvsq32
= rinv32
*rinv32
;
297 rinvsq33
= rinv33
*rinv33
;
299 /**************************
300 * CALCULATE INTERACTIONS *
301 **************************/
308 /* LENNARD-JONES DISPERSION/REPULSION */
310 rinvsix
= rinvsq00
*rinvsq00
*rinvsq00
;
311 vvdw6
= c6_00
*rinvsix
;
312 vvdw12
= c12_00
*rinvsix
*rinvsix
;
313 vvdw
= vvdw12
*(1.0/12.0) - vvdw6
*(1.0/6.0);
314 fvdw
= (vvdw12
-vvdw6
)*rinvsq00
;
317 d
= (d
>0.0) ? d
: 0.0;
319 sw
= 1.0+d2
*d
*(swV3
+d
*(swV4
+d
*swV5
));
321 dsw
= d2
*(swF2
+d
*(swF3
+d
*swF4
));
323 /* Evaluate switch function */
324 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
325 fvdw
= fvdw
*sw
- rinv00
*vvdw
*dsw
;
328 /* Update potential sums from outer loop */
333 /* Calculate temporary vectorial force */
338 /* Update vectorial force */
342 f
[j_coord_offset
+DIM
*0+XX
] -= tx
;
343 f
[j_coord_offset
+DIM
*0+YY
] -= ty
;
344 f
[j_coord_offset
+DIM
*0+ZZ
] -= tz
;
348 /**************************
349 * CALCULATE INTERACTIONS *
350 **************************/
355 /* REACTION-FIELD ELECTROSTATICS */
356 velec
= qq11
*(rinv11
+krf
*rsq11
-crf
);
357 felec
= qq11
*(rinv11
*rinvsq11
-krf2
);
359 /* Update potential sums from outer loop */
364 /* Calculate temporary vectorial force */
369 /* Update vectorial force */
373 f
[j_coord_offset
+DIM
*1+XX
] -= tx
;
374 f
[j_coord_offset
+DIM
*1+YY
] -= ty
;
375 f
[j_coord_offset
+DIM
*1+ZZ
] -= tz
;
379 /**************************
380 * CALCULATE INTERACTIONS *
381 **************************/
386 /* REACTION-FIELD ELECTROSTATICS */
387 velec
= qq12
*(rinv12
+krf
*rsq12
-crf
);
388 felec
= qq12
*(rinv12
*rinvsq12
-krf2
);
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 **************************/
417 /* REACTION-FIELD ELECTROSTATICS */
418 velec
= qq13
*(rinv13
+krf
*rsq13
-crf
);
419 felec
= qq13
*(rinv13
*rinvsq13
-krf2
);
421 /* Update potential sums from outer loop */
426 /* Calculate temporary vectorial force */
431 /* Update vectorial force */
435 f
[j_coord_offset
+DIM
*3+XX
] -= tx
;
436 f
[j_coord_offset
+DIM
*3+YY
] -= ty
;
437 f
[j_coord_offset
+DIM
*3+ZZ
] -= tz
;
441 /**************************
442 * CALCULATE INTERACTIONS *
443 **************************/
448 /* REACTION-FIELD ELECTROSTATICS */
449 velec
= qq21
*(rinv21
+krf
*rsq21
-crf
);
450 felec
= qq21
*(rinv21
*rinvsq21
-krf2
);
452 /* Update potential sums from outer loop */
457 /* Calculate temporary vectorial force */
462 /* Update vectorial force */
466 f
[j_coord_offset
+DIM
*1+XX
] -= tx
;
467 f
[j_coord_offset
+DIM
*1+YY
] -= ty
;
468 f
[j_coord_offset
+DIM
*1+ZZ
] -= tz
;
472 /**************************
473 * CALCULATE INTERACTIONS *
474 **************************/
479 /* REACTION-FIELD ELECTROSTATICS */
480 velec
= qq22
*(rinv22
+krf
*rsq22
-crf
);
481 felec
= qq22
*(rinv22
*rinvsq22
-krf2
);
483 /* Update potential sums from outer loop */
488 /* Calculate temporary vectorial force */
493 /* Update vectorial force */
497 f
[j_coord_offset
+DIM
*2+XX
] -= tx
;
498 f
[j_coord_offset
+DIM
*2+YY
] -= ty
;
499 f
[j_coord_offset
+DIM
*2+ZZ
] -= tz
;
503 /**************************
504 * CALCULATE INTERACTIONS *
505 **************************/
510 /* REACTION-FIELD ELECTROSTATICS */
511 velec
= qq23
*(rinv23
+krf
*rsq23
-crf
);
512 felec
= qq23
*(rinv23
*rinvsq23
-krf2
);
514 /* Update potential sums from outer loop */
519 /* Calculate temporary vectorial force */
524 /* Update vectorial force */
528 f
[j_coord_offset
+DIM
*3+XX
] -= tx
;
529 f
[j_coord_offset
+DIM
*3+YY
] -= ty
;
530 f
[j_coord_offset
+DIM
*3+ZZ
] -= tz
;
534 /**************************
535 * CALCULATE INTERACTIONS *
536 **************************/
541 /* REACTION-FIELD ELECTROSTATICS */
542 velec
= qq31
*(rinv31
+krf
*rsq31
-crf
);
543 felec
= qq31
*(rinv31
*rinvsq31
-krf2
);
545 /* Update potential sums from outer loop */
550 /* Calculate temporary vectorial force */
555 /* Update vectorial force */
559 f
[j_coord_offset
+DIM
*1+XX
] -= tx
;
560 f
[j_coord_offset
+DIM
*1+YY
] -= ty
;
561 f
[j_coord_offset
+DIM
*1+ZZ
] -= tz
;
565 /**************************
566 * CALCULATE INTERACTIONS *
567 **************************/
572 /* REACTION-FIELD ELECTROSTATICS */
573 velec
= qq32
*(rinv32
+krf
*rsq32
-crf
);
574 felec
= qq32
*(rinv32
*rinvsq32
-krf2
);
576 /* Update potential sums from outer loop */
581 /* Calculate temporary vectorial force */
586 /* Update vectorial force */
590 f
[j_coord_offset
+DIM
*2+XX
] -= tx
;
591 f
[j_coord_offset
+DIM
*2+YY
] -= ty
;
592 f
[j_coord_offset
+DIM
*2+ZZ
] -= tz
;
596 /**************************
597 * CALCULATE INTERACTIONS *
598 **************************/
603 /* REACTION-FIELD ELECTROSTATICS */
604 velec
= qq33
*(rinv33
+krf
*rsq33
-crf
);
605 felec
= qq33
*(rinv33
*rinvsq33
-krf2
);
607 /* Update potential sums from outer loop */
612 /* Calculate temporary vectorial force */
617 /* Update vectorial force */
621 f
[j_coord_offset
+DIM
*3+XX
] -= tx
;
622 f
[j_coord_offset
+DIM
*3+YY
] -= ty
;
623 f
[j_coord_offset
+DIM
*3+ZZ
] -= tz
;
627 /* Inner loop uses 332 flops */
629 /* End of innermost loop */
632 f
[i_coord_offset
+DIM
*0+XX
] += fix0
;
633 f
[i_coord_offset
+DIM
*0+YY
] += fiy0
;
634 f
[i_coord_offset
+DIM
*0+ZZ
] += fiz0
;
638 f
[i_coord_offset
+DIM
*1+XX
] += fix1
;
639 f
[i_coord_offset
+DIM
*1+YY
] += fiy1
;
640 f
[i_coord_offset
+DIM
*1+ZZ
] += fiz1
;
644 f
[i_coord_offset
+DIM
*2+XX
] += fix2
;
645 f
[i_coord_offset
+DIM
*2+YY
] += fiy2
;
646 f
[i_coord_offset
+DIM
*2+ZZ
] += fiz2
;
650 f
[i_coord_offset
+DIM
*3+XX
] += fix3
;
651 f
[i_coord_offset
+DIM
*3+YY
] += fiy3
;
652 f
[i_coord_offset
+DIM
*3+ZZ
] += fiz3
;
656 fshift
[i_shift_offset
+XX
] += tx
;
657 fshift
[i_shift_offset
+YY
] += ty
;
658 fshift
[i_shift_offset
+ZZ
] += tz
;
661 /* Update potential energies */
662 kernel_data
->energygrp_elec
[ggid
] += velecsum
;
663 kernel_data
->energygrp_vdw
[ggid
] += vvdwsum
;
665 /* Increment number of inner iterations */
666 inneriter
+= j_index_end
- j_index_start
;
668 /* Outer loop uses 41 flops */
671 /* Increment number of outer iterations */
674 /* Update outer/inner flops */
676 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_VDW_W4W4_VF
,outeriter
*41 + inneriter
*332);
679 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSw_GeomW4W4_F_c
680 * Electrostatics interaction: ReactionField
681 * VdW interaction: LennardJones
682 * Geometry: Water4-Water4
683 * Calculate force/pot: Force
686 nb_kernel_ElecRFCut_VdwLJSw_GeomW4W4_F_c
687 (t_nblist
* gmx_restrict nlist
,
688 rvec
* gmx_restrict xx
,
689 rvec
* gmx_restrict ff
,
690 struct t_forcerec
* gmx_restrict fr
,
691 t_mdatoms
* gmx_restrict mdatoms
,
692 nb_kernel_data_t gmx_unused
* gmx_restrict kernel_data
,
693 t_nrnb
* gmx_restrict nrnb
)
695 int i_shift_offset
,i_coord_offset
,j_coord_offset
;
696 int j_index_start
,j_index_end
;
697 int nri
,inr
,ggid
,iidx
,jidx
,jnr
,outeriter
,inneriter
;
698 real shX
,shY
,shZ
,tx
,ty
,tz
,fscal
,rcutoff
,rcutoff2
;
699 int *iinr
,*jindex
,*jjnr
,*shiftidx
,*gid
;
700 real
*shiftvec
,*fshift
,*x
,*f
;
702 real ix0
,iy0
,iz0
,fix0
,fiy0
,fiz0
,iq0
,isai0
;
704 real ix1
,iy1
,iz1
,fix1
,fiy1
,fiz1
,iq1
,isai1
;
706 real ix2
,iy2
,iz2
,fix2
,fiy2
,fiz2
,iq2
,isai2
;
708 real ix3
,iy3
,iz3
,fix3
,fiy3
,fiz3
,iq3
,isai3
;
710 real jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
712 real jx1
,jy1
,jz1
,fjx1
,fjy1
,fjz1
,jq1
,isaj1
;
714 real jx2
,jy2
,jz2
,fjx2
,fjy2
,fjz2
,jq2
,isaj2
;
716 real jx3
,jy3
,jz3
,fjx3
,fjy3
,fjz3
,jq3
,isaj3
;
717 real dx00
,dy00
,dz00
,rsq00
,rinv00
,rinvsq00
,r00
,qq00
,c6_00
,c12_00
,cexp1_00
,cexp2_00
;
718 real dx11
,dy11
,dz11
,rsq11
,rinv11
,rinvsq11
,r11
,qq11
,c6_11
,c12_11
,cexp1_11
,cexp2_11
;
719 real dx12
,dy12
,dz12
,rsq12
,rinv12
,rinvsq12
,r12
,qq12
,c6_12
,c12_12
,cexp1_12
,cexp2_12
;
720 real dx13
,dy13
,dz13
,rsq13
,rinv13
,rinvsq13
,r13
,qq13
,c6_13
,c12_13
,cexp1_13
,cexp2_13
;
721 real dx21
,dy21
,dz21
,rsq21
,rinv21
,rinvsq21
,r21
,qq21
,c6_21
,c12_21
,cexp1_21
,cexp2_21
;
722 real dx22
,dy22
,dz22
,rsq22
,rinv22
,rinvsq22
,r22
,qq22
,c6_22
,c12_22
,cexp1_22
,cexp2_22
;
723 real dx23
,dy23
,dz23
,rsq23
,rinv23
,rinvsq23
,r23
,qq23
,c6_23
,c12_23
,cexp1_23
,cexp2_23
;
724 real dx31
,dy31
,dz31
,rsq31
,rinv31
,rinvsq31
,r31
,qq31
,c6_31
,c12_31
,cexp1_31
,cexp2_31
;
725 real dx32
,dy32
,dz32
,rsq32
,rinv32
,rinvsq32
,r32
,qq32
,c6_32
,c12_32
,cexp1_32
,cexp2_32
;
726 real dx33
,dy33
,dz33
,rsq33
,rinv33
,rinvsq33
,r33
,qq33
,c6_33
,c12_33
,cexp1_33
,cexp2_33
;
727 real velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
730 real rinvsix
,rvdw
,vvdw
,vvdw6
,vvdw12
,fvdw
,fvdw6
,fvdw12
,vvdwsum
,br
,vvdwexp
,sh_vdw_invrcut6
;
733 real rswitch
,swV3
,swV4
,swV5
,swF2
,swF3
,swF4
,d
,d2
,sw
,dsw
;
740 jindex
= nlist
->jindex
;
742 shiftidx
= nlist
->shift
;
744 shiftvec
= fr
->shift_vec
[0];
745 fshift
= fr
->fshift
[0];
746 facel
= fr
->ic
->epsfac
;
747 charge
= mdatoms
->chargeA
;
751 nvdwtype
= fr
->ntype
;
753 vdwtype
= mdatoms
->typeA
;
755 /* Setup water-specific parameters */
756 inr
= nlist
->iinr
[0];
757 iq1
= facel
*charge
[inr
+1];
758 iq2
= facel
*charge
[inr
+2];
759 iq3
= facel
*charge
[inr
+3];
760 vdwioffset0
= 2*nvdwtype
*vdwtype
[inr
+0];
765 vdwjidx0
= 2*vdwtype
[inr
+0];
766 c6_00
= vdwparam
[vdwioffset0
+vdwjidx0
];
767 c12_00
= vdwparam
[vdwioffset0
+vdwjidx0
+1];
778 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
779 rcutoff
= fr
->ic
->rcoulomb
;
780 rcutoff2
= rcutoff
*rcutoff
;
782 rswitch
= fr
->ic
->rvdw_switch
;
783 /* Setup switch parameters */
785 swV3
= -10.0/(d
*d
*d
);
786 swV4
= 15.0/(d
*d
*d
*d
);
787 swV5
= -6.0/(d
*d
*d
*d
*d
);
788 swF2
= -30.0/(d
*d
*d
);
789 swF3
= 60.0/(d
*d
*d
*d
);
790 swF4
= -30.0/(d
*d
*d
*d
*d
);
795 /* Start outer loop over neighborlists */
796 for(iidx
=0; iidx
<nri
; iidx
++)
798 /* Load shift vector for this list */
799 i_shift_offset
= DIM
*shiftidx
[iidx
];
800 shX
= shiftvec
[i_shift_offset
+XX
];
801 shY
= shiftvec
[i_shift_offset
+YY
];
802 shZ
= shiftvec
[i_shift_offset
+ZZ
];
804 /* Load limits for loop over neighbors */
805 j_index_start
= jindex
[iidx
];
806 j_index_end
= jindex
[iidx
+1];
808 /* Get outer coordinate index */
810 i_coord_offset
= DIM
*inr
;
812 /* Load i particle coords and add shift vector */
813 ix0
= shX
+ x
[i_coord_offset
+DIM
*0+XX
];
814 iy0
= shY
+ x
[i_coord_offset
+DIM
*0+YY
];
815 iz0
= shZ
+ x
[i_coord_offset
+DIM
*0+ZZ
];
816 ix1
= shX
+ x
[i_coord_offset
+DIM
*1+XX
];
817 iy1
= shY
+ x
[i_coord_offset
+DIM
*1+YY
];
818 iz1
= shZ
+ x
[i_coord_offset
+DIM
*1+ZZ
];
819 ix2
= shX
+ x
[i_coord_offset
+DIM
*2+XX
];
820 iy2
= shY
+ x
[i_coord_offset
+DIM
*2+YY
];
821 iz2
= shZ
+ x
[i_coord_offset
+DIM
*2+ZZ
];
822 ix3
= shX
+ x
[i_coord_offset
+DIM
*3+XX
];
823 iy3
= shY
+ x
[i_coord_offset
+DIM
*3+YY
];
824 iz3
= shZ
+ x
[i_coord_offset
+DIM
*3+ZZ
];
839 /* Start inner kernel loop */
840 for(jidx
=j_index_start
; jidx
<j_index_end
; jidx
++)
842 /* Get j neighbor index, and coordinate index */
844 j_coord_offset
= DIM
*jnr
;
846 /* load j atom coordinates */
847 jx0
= x
[j_coord_offset
+DIM
*0+XX
];
848 jy0
= x
[j_coord_offset
+DIM
*0+YY
];
849 jz0
= x
[j_coord_offset
+DIM
*0+ZZ
];
850 jx1
= x
[j_coord_offset
+DIM
*1+XX
];
851 jy1
= x
[j_coord_offset
+DIM
*1+YY
];
852 jz1
= x
[j_coord_offset
+DIM
*1+ZZ
];
853 jx2
= x
[j_coord_offset
+DIM
*2+XX
];
854 jy2
= x
[j_coord_offset
+DIM
*2+YY
];
855 jz2
= x
[j_coord_offset
+DIM
*2+ZZ
];
856 jx3
= x
[j_coord_offset
+DIM
*3+XX
];
857 jy3
= x
[j_coord_offset
+DIM
*3+YY
];
858 jz3
= x
[j_coord_offset
+DIM
*3+ZZ
];
860 /* Calculate displacement vector */
892 /* Calculate squared distance and things based on it */
893 rsq00
= dx00
*dx00
+dy00
*dy00
+dz00
*dz00
;
894 rsq11
= dx11
*dx11
+dy11
*dy11
+dz11
*dz11
;
895 rsq12
= dx12
*dx12
+dy12
*dy12
+dz12
*dz12
;
896 rsq13
= dx13
*dx13
+dy13
*dy13
+dz13
*dz13
;
897 rsq21
= dx21
*dx21
+dy21
*dy21
+dz21
*dz21
;
898 rsq22
= dx22
*dx22
+dy22
*dy22
+dz22
*dz22
;
899 rsq23
= dx23
*dx23
+dy23
*dy23
+dz23
*dz23
;
900 rsq31
= dx31
*dx31
+dy31
*dy31
+dz31
*dz31
;
901 rsq32
= dx32
*dx32
+dy32
*dy32
+dz32
*dz32
;
902 rsq33
= dx33
*dx33
+dy33
*dy33
+dz33
*dz33
;
904 rinv00
= 1.0/sqrt(rsq00
);
905 rinv11
= 1.0/sqrt(rsq11
);
906 rinv12
= 1.0/sqrt(rsq12
);
907 rinv13
= 1.0/sqrt(rsq13
);
908 rinv21
= 1.0/sqrt(rsq21
);
909 rinv22
= 1.0/sqrt(rsq22
);
910 rinv23
= 1.0/sqrt(rsq23
);
911 rinv31
= 1.0/sqrt(rsq31
);
912 rinv32
= 1.0/sqrt(rsq32
);
913 rinv33
= 1.0/sqrt(rsq33
);
915 rinvsq00
= rinv00
*rinv00
;
916 rinvsq11
= rinv11
*rinv11
;
917 rinvsq12
= rinv12
*rinv12
;
918 rinvsq13
= rinv13
*rinv13
;
919 rinvsq21
= rinv21
*rinv21
;
920 rinvsq22
= rinv22
*rinv22
;
921 rinvsq23
= rinv23
*rinv23
;
922 rinvsq31
= rinv31
*rinv31
;
923 rinvsq32
= rinv32
*rinv32
;
924 rinvsq33
= rinv33
*rinv33
;
926 /**************************
927 * CALCULATE INTERACTIONS *
928 **************************/
935 /* LENNARD-JONES DISPERSION/REPULSION */
937 rinvsix
= rinvsq00
*rinvsq00
*rinvsq00
;
938 vvdw6
= c6_00
*rinvsix
;
939 vvdw12
= c12_00
*rinvsix
*rinvsix
;
940 vvdw
= vvdw12
*(1.0/12.0) - vvdw6
*(1.0/6.0);
941 fvdw
= (vvdw12
-vvdw6
)*rinvsq00
;
944 d
= (d
>0.0) ? d
: 0.0;
946 sw
= 1.0+d2
*d
*(swV3
+d
*(swV4
+d
*swV5
));
948 dsw
= d2
*(swF2
+d
*(swF3
+d
*swF4
));
950 /* Evaluate switch function */
951 /* fscal'=f'/r=-(v*sw)'/r=-(v'*sw+v*dsw)/r=-v'*sw/r-v*dsw/r=fscal*sw-v*dsw/r */
952 fvdw
= fvdw
*sw
- rinv00
*vvdw
*dsw
;
956 /* Calculate temporary vectorial force */
961 /* Update vectorial force */
965 f
[j_coord_offset
+DIM
*0+XX
] -= tx
;
966 f
[j_coord_offset
+DIM
*0+YY
] -= ty
;
967 f
[j_coord_offset
+DIM
*0+ZZ
] -= tz
;
971 /**************************
972 * CALCULATE INTERACTIONS *
973 **************************/
978 /* REACTION-FIELD ELECTROSTATICS */
979 felec
= qq11
*(rinv11
*rinvsq11
-krf2
);
983 /* Calculate temporary vectorial force */
988 /* Update vectorial force */
992 f
[j_coord_offset
+DIM
*1+XX
] -= tx
;
993 f
[j_coord_offset
+DIM
*1+YY
] -= ty
;
994 f
[j_coord_offset
+DIM
*1+ZZ
] -= tz
;
998 /**************************
999 * CALCULATE INTERACTIONS *
1000 **************************/
1005 /* REACTION-FIELD ELECTROSTATICS */
1006 felec
= qq12
*(rinv12
*rinvsq12
-krf2
);
1010 /* Calculate temporary vectorial force */
1015 /* Update vectorial force */
1019 f
[j_coord_offset
+DIM
*2+XX
] -= tx
;
1020 f
[j_coord_offset
+DIM
*2+YY
] -= ty
;
1021 f
[j_coord_offset
+DIM
*2+ZZ
] -= tz
;
1025 /**************************
1026 * CALCULATE INTERACTIONS *
1027 **************************/
1032 /* REACTION-FIELD ELECTROSTATICS */
1033 felec
= qq13
*(rinv13
*rinvsq13
-krf2
);
1037 /* Calculate temporary vectorial force */
1042 /* Update vectorial force */
1046 f
[j_coord_offset
+DIM
*3+XX
] -= tx
;
1047 f
[j_coord_offset
+DIM
*3+YY
] -= ty
;
1048 f
[j_coord_offset
+DIM
*3+ZZ
] -= tz
;
1052 /**************************
1053 * CALCULATE INTERACTIONS *
1054 **************************/
1059 /* REACTION-FIELD ELECTROSTATICS */
1060 felec
= qq21
*(rinv21
*rinvsq21
-krf2
);
1064 /* Calculate temporary vectorial force */
1069 /* Update vectorial force */
1073 f
[j_coord_offset
+DIM
*1+XX
] -= tx
;
1074 f
[j_coord_offset
+DIM
*1+YY
] -= ty
;
1075 f
[j_coord_offset
+DIM
*1+ZZ
] -= tz
;
1079 /**************************
1080 * CALCULATE INTERACTIONS *
1081 **************************/
1086 /* REACTION-FIELD ELECTROSTATICS */
1087 felec
= qq22
*(rinv22
*rinvsq22
-krf2
);
1091 /* Calculate temporary vectorial force */
1096 /* Update vectorial force */
1100 f
[j_coord_offset
+DIM
*2+XX
] -= tx
;
1101 f
[j_coord_offset
+DIM
*2+YY
] -= ty
;
1102 f
[j_coord_offset
+DIM
*2+ZZ
] -= tz
;
1106 /**************************
1107 * CALCULATE INTERACTIONS *
1108 **************************/
1113 /* REACTION-FIELD ELECTROSTATICS */
1114 felec
= qq23
*(rinv23
*rinvsq23
-krf2
);
1118 /* Calculate temporary vectorial force */
1123 /* Update vectorial force */
1127 f
[j_coord_offset
+DIM
*3+XX
] -= tx
;
1128 f
[j_coord_offset
+DIM
*3+YY
] -= ty
;
1129 f
[j_coord_offset
+DIM
*3+ZZ
] -= tz
;
1133 /**************************
1134 * CALCULATE INTERACTIONS *
1135 **************************/
1140 /* REACTION-FIELD ELECTROSTATICS */
1141 felec
= qq31
*(rinv31
*rinvsq31
-krf2
);
1145 /* Calculate temporary vectorial force */
1150 /* Update vectorial force */
1154 f
[j_coord_offset
+DIM
*1+XX
] -= tx
;
1155 f
[j_coord_offset
+DIM
*1+YY
] -= ty
;
1156 f
[j_coord_offset
+DIM
*1+ZZ
] -= tz
;
1160 /**************************
1161 * CALCULATE INTERACTIONS *
1162 **************************/
1167 /* REACTION-FIELD ELECTROSTATICS */
1168 felec
= qq32
*(rinv32
*rinvsq32
-krf2
);
1172 /* Calculate temporary vectorial force */
1177 /* Update vectorial force */
1181 f
[j_coord_offset
+DIM
*2+XX
] -= tx
;
1182 f
[j_coord_offset
+DIM
*2+YY
] -= ty
;
1183 f
[j_coord_offset
+DIM
*2+ZZ
] -= tz
;
1187 /**************************
1188 * CALCULATE INTERACTIONS *
1189 **************************/
1194 /* REACTION-FIELD ELECTROSTATICS */
1195 felec
= qq33
*(rinv33
*rinvsq33
-krf2
);
1199 /* Calculate temporary vectorial force */
1204 /* Update vectorial force */
1208 f
[j_coord_offset
+DIM
*3+XX
] -= tx
;
1209 f
[j_coord_offset
+DIM
*3+YY
] -= ty
;
1210 f
[j_coord_offset
+DIM
*3+ZZ
] -= tz
;
1214 /* Inner loop uses 285 flops */
1216 /* End of innermost loop */
1219 f
[i_coord_offset
+DIM
*0+XX
] += fix0
;
1220 f
[i_coord_offset
+DIM
*0+YY
] += fiy0
;
1221 f
[i_coord_offset
+DIM
*0+ZZ
] += fiz0
;
1225 f
[i_coord_offset
+DIM
*1+XX
] += fix1
;
1226 f
[i_coord_offset
+DIM
*1+YY
] += fiy1
;
1227 f
[i_coord_offset
+DIM
*1+ZZ
] += fiz1
;
1231 f
[i_coord_offset
+DIM
*2+XX
] += fix2
;
1232 f
[i_coord_offset
+DIM
*2+YY
] += fiy2
;
1233 f
[i_coord_offset
+DIM
*2+ZZ
] += fiz2
;
1237 f
[i_coord_offset
+DIM
*3+XX
] += fix3
;
1238 f
[i_coord_offset
+DIM
*3+YY
] += fiy3
;
1239 f
[i_coord_offset
+DIM
*3+ZZ
] += fiz3
;
1243 fshift
[i_shift_offset
+XX
] += tx
;
1244 fshift
[i_shift_offset
+YY
] += ty
;
1245 fshift
[i_shift_offset
+ZZ
] += tz
;
1247 /* Increment number of inner iterations */
1248 inneriter
+= j_index_end
- j_index_start
;
1250 /* Outer loop uses 39 flops */
1253 /* Increment number of outer iterations */
1256 /* Update outer/inner flops */
1258 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_VDW_W4W4_F
,outeriter
*39 + inneriter
*285);