2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014.2015,2017,2018, 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_VdwNone_GeomW4P1_VF_c
49 * Electrostatics interaction: Ewald
50 * VdW interaction: None
51 * Geometry: Water4-Particle
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecEwSh_VdwNone_GeomW4P1_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 ix1
,iy1
,iz1
,fix1
,fiy1
,fiz1
,iq1
,isai1
;
73 real ix2
,iy2
,iz2
,fix2
,fiy2
,fiz2
,iq2
,isai2
;
75 real ix3
,iy3
,iz3
,fix3
,fiy3
,fiz3
,iq3
,isai3
;
77 real jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
78 real dx10
,dy10
,dz10
,rsq10
,rinv10
,rinvsq10
,r10
,qq10
,c6_10
,c12_10
,cexp1_10
,cexp2_10
;
79 real dx20
,dy20
,dz20
,rsq20
,rinv20
,rinvsq20
,r20
,qq20
,c6_20
,c12_20
,cexp1_20
,cexp2_20
;
80 real dx30
,dy30
,dz30
,rsq30
,rinv30
,rinvsq30
,r30
,qq30
,c6_30
,c12_30
,cexp1_30
,cexp2_30
;
81 real velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
84 real ewtabscale
,eweps
,sh_ewald
,ewrt
,ewtabhalfspace
;
92 jindex
= nlist
->jindex
;
94 shiftidx
= nlist
->shift
;
96 shiftvec
= fr
->shift_vec
[0];
97 fshift
= fr
->fshift
[0];
98 facel
= fr
->ic
->epsfac
;
99 charge
= mdatoms
->chargeA
;
101 sh_ewald
= fr
->ic
->sh_ewald
;
102 ewtab
= fr
->ic
->tabq_coul_FDV0
;
103 ewtabscale
= fr
->ic
->tabq_scale
;
104 ewtabhalfspace
= 0.5/ewtabscale
;
106 /* Setup water-specific parameters */
107 inr
= nlist
->iinr
[0];
108 iq1
= facel
*charge
[inr
+1];
109 iq2
= facel
*charge
[inr
+2];
110 iq3
= facel
*charge
[inr
+3];
112 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
113 rcutoff
= fr
->ic
->rcoulomb
;
114 rcutoff2
= rcutoff
*rcutoff
;
119 /* Start outer loop over neighborlists */
120 for(iidx
=0; iidx
<nri
; iidx
++)
122 /* Load shift vector for this list */
123 i_shift_offset
= DIM
*shiftidx
[iidx
];
124 shX
= shiftvec
[i_shift_offset
+XX
];
125 shY
= shiftvec
[i_shift_offset
+YY
];
126 shZ
= shiftvec
[i_shift_offset
+ZZ
];
128 /* Load limits for loop over neighbors */
129 j_index_start
= jindex
[iidx
];
130 j_index_end
= jindex
[iidx
+1];
132 /* Get outer coordinate index */
134 i_coord_offset
= DIM
*inr
;
136 /* Load i particle coords and add shift vector */
137 ix1
= shX
+ x
[i_coord_offset
+DIM
*1+XX
];
138 iy1
= shY
+ x
[i_coord_offset
+DIM
*1+YY
];
139 iz1
= shZ
+ x
[i_coord_offset
+DIM
*1+ZZ
];
140 ix2
= shX
+ x
[i_coord_offset
+DIM
*2+XX
];
141 iy2
= shY
+ x
[i_coord_offset
+DIM
*2+YY
];
142 iz2
= shZ
+ x
[i_coord_offset
+DIM
*2+ZZ
];
143 ix3
= shX
+ x
[i_coord_offset
+DIM
*3+XX
];
144 iy3
= shY
+ x
[i_coord_offset
+DIM
*3+YY
];
145 iz3
= shZ
+ x
[i_coord_offset
+DIM
*3+ZZ
];
157 /* Reset potential sums */
160 /* Start inner kernel loop */
161 for(jidx
=j_index_start
; jidx
<j_index_end
; jidx
++)
163 /* Get j neighbor index, and coordinate index */
165 j_coord_offset
= DIM
*jnr
;
167 /* load j atom coordinates */
168 jx0
= x
[j_coord_offset
+DIM
*0+XX
];
169 jy0
= x
[j_coord_offset
+DIM
*0+YY
];
170 jz0
= x
[j_coord_offset
+DIM
*0+ZZ
];
172 /* Calculate displacement vector */
183 /* Calculate squared distance and things based on it */
184 rsq10
= dx10
*dx10
+dy10
*dy10
+dz10
*dz10
;
185 rsq20
= dx20
*dx20
+dy20
*dy20
+dz20
*dz20
;
186 rsq30
= dx30
*dx30
+dy30
*dy30
+dz30
*dz30
;
188 rinv10
= 1.0/sqrt(rsq10
);
189 rinv20
= 1.0/sqrt(rsq20
);
190 rinv30
= 1.0/sqrt(rsq30
);
192 rinvsq10
= rinv10
*rinv10
;
193 rinvsq20
= rinv20
*rinv20
;
194 rinvsq30
= rinv30
*rinv30
;
196 /* Load parameters for j particles */
199 /**************************
200 * CALCULATE INTERACTIONS *
201 **************************/
210 /* EWALD ELECTROSTATICS */
212 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
213 ewrt
= r10
*ewtabscale
;
217 felec
= ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
218 velec
= qq10
*((rinv10
-sh_ewald
)-(ewtab
[ewitab
+2]-ewtabhalfspace
*eweps
*(ewtab
[ewitab
]+felec
)));
219 felec
= qq10
*rinv10
*(rinvsq10
-felec
);
221 /* Update potential sums from outer loop */
226 /* Calculate temporary vectorial force */
231 /* Update vectorial force */
235 f
[j_coord_offset
+DIM
*0+XX
] -= tx
;
236 f
[j_coord_offset
+DIM
*0+YY
] -= ty
;
237 f
[j_coord_offset
+DIM
*0+ZZ
] -= tz
;
241 /**************************
242 * CALCULATE INTERACTIONS *
243 **************************/
252 /* EWALD ELECTROSTATICS */
254 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
255 ewrt
= r20
*ewtabscale
;
259 felec
= ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
260 velec
= qq20
*((rinv20
-sh_ewald
)-(ewtab
[ewitab
+2]-ewtabhalfspace
*eweps
*(ewtab
[ewitab
]+felec
)));
261 felec
= qq20
*rinv20
*(rinvsq20
-felec
);
263 /* Update potential sums from outer loop */
268 /* Calculate temporary vectorial force */
273 /* Update vectorial force */
277 f
[j_coord_offset
+DIM
*0+XX
] -= tx
;
278 f
[j_coord_offset
+DIM
*0+YY
] -= ty
;
279 f
[j_coord_offset
+DIM
*0+ZZ
] -= tz
;
283 /**************************
284 * CALCULATE INTERACTIONS *
285 **************************/
294 /* EWALD ELECTROSTATICS */
296 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
297 ewrt
= r30
*ewtabscale
;
301 felec
= ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
302 velec
= qq30
*((rinv30
-sh_ewald
)-(ewtab
[ewitab
+2]-ewtabhalfspace
*eweps
*(ewtab
[ewitab
]+felec
)));
303 felec
= qq30
*rinv30
*(rinvsq30
-felec
);
305 /* Update potential sums from outer loop */
310 /* Calculate temporary vectorial force */
315 /* Update vectorial force */
319 f
[j_coord_offset
+DIM
*0+XX
] -= tx
;
320 f
[j_coord_offset
+DIM
*0+YY
] -= ty
;
321 f
[j_coord_offset
+DIM
*0+ZZ
] -= tz
;
325 /* Inner loop uses 126 flops */
327 /* End of innermost loop */
330 f
[i_coord_offset
+DIM
*1+XX
] += fix1
;
331 f
[i_coord_offset
+DIM
*1+YY
] += fiy1
;
332 f
[i_coord_offset
+DIM
*1+ZZ
] += fiz1
;
336 f
[i_coord_offset
+DIM
*2+XX
] += fix2
;
337 f
[i_coord_offset
+DIM
*2+YY
] += fiy2
;
338 f
[i_coord_offset
+DIM
*2+ZZ
] += fiz2
;
342 f
[i_coord_offset
+DIM
*3+XX
] += fix3
;
343 f
[i_coord_offset
+DIM
*3+YY
] += fiy3
;
344 f
[i_coord_offset
+DIM
*3+ZZ
] += fiz3
;
348 fshift
[i_shift_offset
+XX
] += tx
;
349 fshift
[i_shift_offset
+YY
] += ty
;
350 fshift
[i_shift_offset
+ZZ
] += tz
;
353 /* Update potential energies */
354 kernel_data
->energygrp_elec
[ggid
] += velecsum
;
356 /* Increment number of inner iterations */
357 inneriter
+= j_index_end
- j_index_start
;
359 /* Outer loop uses 31 flops */
362 /* Increment number of outer iterations */
365 /* Update outer/inner flops */
367 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_W4_VF
,outeriter
*31 + inneriter
*126);
370 * Gromacs nonbonded kernel: nb_kernel_ElecEwSh_VdwNone_GeomW4P1_F_c
371 * Electrostatics interaction: Ewald
372 * VdW interaction: None
373 * Geometry: Water4-Particle
374 * Calculate force/pot: Force
377 nb_kernel_ElecEwSh_VdwNone_GeomW4P1_F_c
378 (t_nblist
* gmx_restrict nlist
,
379 rvec
* gmx_restrict xx
,
380 rvec
* gmx_restrict ff
,
381 struct t_forcerec
* gmx_restrict fr
,
382 t_mdatoms
* gmx_restrict mdatoms
,
383 nb_kernel_data_t gmx_unused
* gmx_restrict kernel_data
,
384 t_nrnb
* gmx_restrict nrnb
)
386 int i_shift_offset
,i_coord_offset
,j_coord_offset
;
387 int j_index_start
,j_index_end
;
388 int nri
,inr
,ggid
,iidx
,jidx
,jnr
,outeriter
,inneriter
;
389 real shX
,shY
,shZ
,tx
,ty
,tz
,fscal
,rcutoff
,rcutoff2
;
390 int *iinr
,*jindex
,*jjnr
,*shiftidx
,*gid
;
391 real
*shiftvec
,*fshift
,*x
,*f
;
393 real ix1
,iy1
,iz1
,fix1
,fiy1
,fiz1
,iq1
,isai1
;
395 real ix2
,iy2
,iz2
,fix2
,fiy2
,fiz2
,iq2
,isai2
;
397 real ix3
,iy3
,iz3
,fix3
,fiy3
,fiz3
,iq3
,isai3
;
399 real jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
400 real dx10
,dy10
,dz10
,rsq10
,rinv10
,rinvsq10
,r10
,qq10
,c6_10
,c12_10
,cexp1_10
,cexp2_10
;
401 real dx20
,dy20
,dz20
,rsq20
,rinv20
,rinvsq20
,r20
,qq20
,c6_20
,c12_20
,cexp1_20
,cexp2_20
;
402 real dx30
,dy30
,dz30
,rsq30
,rinv30
,rinvsq30
,r30
,qq30
,c6_30
,c12_30
,cexp1_30
,cexp2_30
;
403 real velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
406 real ewtabscale
,eweps
,sh_ewald
,ewrt
,ewtabhalfspace
;
414 jindex
= nlist
->jindex
;
416 shiftidx
= nlist
->shift
;
418 shiftvec
= fr
->shift_vec
[0];
419 fshift
= fr
->fshift
[0];
420 facel
= fr
->ic
->epsfac
;
421 charge
= mdatoms
->chargeA
;
423 sh_ewald
= fr
->ic
->sh_ewald
;
424 ewtab
= fr
->ic
->tabq_coul_F
;
425 ewtabscale
= fr
->ic
->tabq_scale
;
426 ewtabhalfspace
= 0.5/ewtabscale
;
428 /* Setup water-specific parameters */
429 inr
= nlist
->iinr
[0];
430 iq1
= facel
*charge
[inr
+1];
431 iq2
= facel
*charge
[inr
+2];
432 iq3
= facel
*charge
[inr
+3];
434 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
435 rcutoff
= fr
->ic
->rcoulomb
;
436 rcutoff2
= rcutoff
*rcutoff
;
441 /* Start outer loop over neighborlists */
442 for(iidx
=0; iidx
<nri
; iidx
++)
444 /* Load shift vector for this list */
445 i_shift_offset
= DIM
*shiftidx
[iidx
];
446 shX
= shiftvec
[i_shift_offset
+XX
];
447 shY
= shiftvec
[i_shift_offset
+YY
];
448 shZ
= shiftvec
[i_shift_offset
+ZZ
];
450 /* Load limits for loop over neighbors */
451 j_index_start
= jindex
[iidx
];
452 j_index_end
= jindex
[iidx
+1];
454 /* Get outer coordinate index */
456 i_coord_offset
= DIM
*inr
;
458 /* Load i particle coords and add shift vector */
459 ix1
= shX
+ x
[i_coord_offset
+DIM
*1+XX
];
460 iy1
= shY
+ x
[i_coord_offset
+DIM
*1+YY
];
461 iz1
= shZ
+ x
[i_coord_offset
+DIM
*1+ZZ
];
462 ix2
= shX
+ x
[i_coord_offset
+DIM
*2+XX
];
463 iy2
= shY
+ x
[i_coord_offset
+DIM
*2+YY
];
464 iz2
= shZ
+ x
[i_coord_offset
+DIM
*2+ZZ
];
465 ix3
= shX
+ x
[i_coord_offset
+DIM
*3+XX
];
466 iy3
= shY
+ x
[i_coord_offset
+DIM
*3+YY
];
467 iz3
= shZ
+ x
[i_coord_offset
+DIM
*3+ZZ
];
479 /* Start inner kernel loop */
480 for(jidx
=j_index_start
; jidx
<j_index_end
; jidx
++)
482 /* Get j neighbor index, and coordinate index */
484 j_coord_offset
= DIM
*jnr
;
486 /* load j atom coordinates */
487 jx0
= x
[j_coord_offset
+DIM
*0+XX
];
488 jy0
= x
[j_coord_offset
+DIM
*0+YY
];
489 jz0
= x
[j_coord_offset
+DIM
*0+ZZ
];
491 /* Calculate displacement vector */
502 /* Calculate squared distance and things based on it */
503 rsq10
= dx10
*dx10
+dy10
*dy10
+dz10
*dz10
;
504 rsq20
= dx20
*dx20
+dy20
*dy20
+dz20
*dz20
;
505 rsq30
= dx30
*dx30
+dy30
*dy30
+dz30
*dz30
;
507 rinv10
= 1.0/sqrt(rsq10
);
508 rinv20
= 1.0/sqrt(rsq20
);
509 rinv30
= 1.0/sqrt(rsq30
);
511 rinvsq10
= rinv10
*rinv10
;
512 rinvsq20
= rinv20
*rinv20
;
513 rinvsq30
= rinv30
*rinv30
;
515 /* Load parameters for j particles */
518 /**************************
519 * CALCULATE INTERACTIONS *
520 **************************/
529 /* EWALD ELECTROSTATICS */
531 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
532 ewrt
= r10
*ewtabscale
;
535 felec
= (1.0-eweps
)*ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
536 felec
= qq10
*rinv10
*(rinvsq10
-felec
);
540 /* Calculate temporary vectorial force */
545 /* Update vectorial force */
549 f
[j_coord_offset
+DIM
*0+XX
] -= tx
;
550 f
[j_coord_offset
+DIM
*0+YY
] -= ty
;
551 f
[j_coord_offset
+DIM
*0+ZZ
] -= tz
;
555 /**************************
556 * CALCULATE INTERACTIONS *
557 **************************/
566 /* EWALD ELECTROSTATICS */
568 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
569 ewrt
= r20
*ewtabscale
;
572 felec
= (1.0-eweps
)*ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
573 felec
= qq20
*rinv20
*(rinvsq20
-felec
);
577 /* Calculate temporary vectorial force */
582 /* Update vectorial force */
586 f
[j_coord_offset
+DIM
*0+XX
] -= tx
;
587 f
[j_coord_offset
+DIM
*0+YY
] -= ty
;
588 f
[j_coord_offset
+DIM
*0+ZZ
] -= tz
;
592 /**************************
593 * CALCULATE INTERACTIONS *
594 **************************/
603 /* EWALD ELECTROSTATICS */
605 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
606 ewrt
= r30
*ewtabscale
;
609 felec
= (1.0-eweps
)*ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
610 felec
= qq30
*rinv30
*(rinvsq30
-felec
);
614 /* Calculate temporary vectorial force */
619 /* Update vectorial force */
623 f
[j_coord_offset
+DIM
*0+XX
] -= tx
;
624 f
[j_coord_offset
+DIM
*0+YY
] -= ty
;
625 f
[j_coord_offset
+DIM
*0+ZZ
] -= tz
;
629 /* Inner loop uses 102 flops */
631 /* End of innermost loop */
634 f
[i_coord_offset
+DIM
*1+XX
] += fix1
;
635 f
[i_coord_offset
+DIM
*1+YY
] += fiy1
;
636 f
[i_coord_offset
+DIM
*1+ZZ
] += fiz1
;
640 f
[i_coord_offset
+DIM
*2+XX
] += fix2
;
641 f
[i_coord_offset
+DIM
*2+YY
] += fiy2
;
642 f
[i_coord_offset
+DIM
*2+ZZ
] += fiz2
;
646 f
[i_coord_offset
+DIM
*3+XX
] += fix3
;
647 f
[i_coord_offset
+DIM
*3+YY
] += fiy3
;
648 f
[i_coord_offset
+DIM
*3+ZZ
] += fiz3
;
652 fshift
[i_shift_offset
+XX
] += tx
;
653 fshift
[i_shift_offset
+YY
] += ty
;
654 fshift
[i_shift_offset
+ZZ
] += tz
;
656 /* Increment number of inner iterations */
657 inneriter
+= j_index_end
- j_index_start
;
659 /* Outer loop uses 30 flops */
662 /* Increment number of outer iterations */
665 /* Update outer/inner flops */
667 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_W4_F
,outeriter
*30 + inneriter
*102);