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_ElecEw_VdwNone_GeomW3P1_VF_c
49 * Electrostatics interaction: Ewald
50 * VdW interaction: None
51 * Geometry: Water3-Particle
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecEw_VdwNone_GeomW3P1_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 jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
78 real dx00
,dy00
,dz00
,rsq00
,rinv00
,rinvsq00
,r00
,qq00
,c6_00
,c12_00
,cexp1_00
,cexp2_00
;
79 real dx10
,dy10
,dz10
,rsq10
,rinv10
,rinvsq10
,r10
,qq10
,c6_10
,c12_10
,cexp1_10
,cexp2_10
;
80 real dx20
,dy20
,dz20
,rsq20
,rinv20
,rinvsq20
,r20
,qq20
,c6_20
,c12_20
,cexp1_20
,cexp2_20
;
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 iq0
= facel
*charge
[inr
+0];
109 iq1
= facel
*charge
[inr
+1];
110 iq2
= facel
*charge
[inr
+2];
115 /* Start outer loop over neighborlists */
116 for(iidx
=0; iidx
<nri
; iidx
++)
118 /* Load shift vector for this list */
119 i_shift_offset
= DIM
*shiftidx
[iidx
];
120 shX
= shiftvec
[i_shift_offset
+XX
];
121 shY
= shiftvec
[i_shift_offset
+YY
];
122 shZ
= shiftvec
[i_shift_offset
+ZZ
];
124 /* Load limits for loop over neighbors */
125 j_index_start
= jindex
[iidx
];
126 j_index_end
= jindex
[iidx
+1];
128 /* Get outer coordinate index */
130 i_coord_offset
= DIM
*inr
;
132 /* Load i particle coords and add shift vector */
133 ix0
= shX
+ x
[i_coord_offset
+DIM
*0+XX
];
134 iy0
= shY
+ x
[i_coord_offset
+DIM
*0+YY
];
135 iz0
= shZ
+ x
[i_coord_offset
+DIM
*0+ZZ
];
136 ix1
= shX
+ x
[i_coord_offset
+DIM
*1+XX
];
137 iy1
= shY
+ x
[i_coord_offset
+DIM
*1+YY
];
138 iz1
= shZ
+ x
[i_coord_offset
+DIM
*1+ZZ
];
139 ix2
= shX
+ x
[i_coord_offset
+DIM
*2+XX
];
140 iy2
= shY
+ x
[i_coord_offset
+DIM
*2+YY
];
141 iz2
= shZ
+ x
[i_coord_offset
+DIM
*2+ZZ
];
153 /* Reset potential sums */
156 /* Start inner kernel loop */
157 for(jidx
=j_index_start
; jidx
<j_index_end
; jidx
++)
159 /* Get j neighbor index, and coordinate index */
161 j_coord_offset
= DIM
*jnr
;
163 /* load j atom coordinates */
164 jx0
= x
[j_coord_offset
+DIM
*0+XX
];
165 jy0
= x
[j_coord_offset
+DIM
*0+YY
];
166 jz0
= x
[j_coord_offset
+DIM
*0+ZZ
];
168 /* Calculate displacement vector */
179 /* Calculate squared distance and things based on it */
180 rsq00
= dx00
*dx00
+dy00
*dy00
+dz00
*dz00
;
181 rsq10
= dx10
*dx10
+dy10
*dy10
+dz10
*dz10
;
182 rsq20
= dx20
*dx20
+dy20
*dy20
+dz20
*dz20
;
184 rinv00
= 1.0/sqrt(rsq00
);
185 rinv10
= 1.0/sqrt(rsq10
);
186 rinv20
= 1.0/sqrt(rsq20
);
188 rinvsq00
= rinv00
*rinv00
;
189 rinvsq10
= rinv10
*rinv10
;
190 rinvsq20
= rinv20
*rinv20
;
192 /* Load parameters for j particles */
195 /**************************
196 * CALCULATE INTERACTIONS *
197 **************************/
203 /* EWALD ELECTROSTATICS */
205 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
206 ewrt
= r00
*ewtabscale
;
210 felec
= ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
211 velec
= qq00
*(rinv00
-(ewtab
[ewitab
+2]-ewtabhalfspace
*eweps
*(ewtab
[ewitab
]+felec
)));
212 felec
= qq00
*rinv00
*(rinvsq00
-felec
);
214 /* Update potential sums from outer loop */
219 /* Calculate temporary vectorial force */
224 /* Update vectorial force */
228 f
[j_coord_offset
+DIM
*0+XX
] -= tx
;
229 f
[j_coord_offset
+DIM
*0+YY
] -= ty
;
230 f
[j_coord_offset
+DIM
*0+ZZ
] -= tz
;
232 /**************************
233 * CALCULATE INTERACTIONS *
234 **************************/
240 /* EWALD ELECTROSTATICS */
242 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
243 ewrt
= r10
*ewtabscale
;
247 felec
= ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
248 velec
= qq10
*(rinv10
-(ewtab
[ewitab
+2]-ewtabhalfspace
*eweps
*(ewtab
[ewitab
]+felec
)));
249 felec
= qq10
*rinv10
*(rinvsq10
-felec
);
251 /* Update potential sums from outer loop */
256 /* Calculate temporary vectorial force */
261 /* Update vectorial force */
265 f
[j_coord_offset
+DIM
*0+XX
] -= tx
;
266 f
[j_coord_offset
+DIM
*0+YY
] -= ty
;
267 f
[j_coord_offset
+DIM
*0+ZZ
] -= tz
;
269 /**************************
270 * CALCULATE INTERACTIONS *
271 **************************/
277 /* EWALD ELECTROSTATICS */
279 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
280 ewrt
= r20
*ewtabscale
;
284 felec
= ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
285 velec
= qq20
*(rinv20
-(ewtab
[ewitab
+2]-ewtabhalfspace
*eweps
*(ewtab
[ewitab
]+felec
)));
286 felec
= qq20
*rinv20
*(rinvsq20
-felec
);
288 /* Update potential sums from outer loop */
293 /* Calculate temporary vectorial force */
298 /* Update vectorial force */
302 f
[j_coord_offset
+DIM
*0+XX
] -= tx
;
303 f
[j_coord_offset
+DIM
*0+YY
] -= ty
;
304 f
[j_coord_offset
+DIM
*0+ZZ
] -= tz
;
306 /* Inner loop uses 123 flops */
308 /* End of innermost loop */
311 f
[i_coord_offset
+DIM
*0+XX
] += fix0
;
312 f
[i_coord_offset
+DIM
*0+YY
] += fiy0
;
313 f
[i_coord_offset
+DIM
*0+ZZ
] += fiz0
;
317 f
[i_coord_offset
+DIM
*1+XX
] += fix1
;
318 f
[i_coord_offset
+DIM
*1+YY
] += fiy1
;
319 f
[i_coord_offset
+DIM
*1+ZZ
] += fiz1
;
323 f
[i_coord_offset
+DIM
*2+XX
] += fix2
;
324 f
[i_coord_offset
+DIM
*2+YY
] += fiy2
;
325 f
[i_coord_offset
+DIM
*2+ZZ
] += fiz2
;
329 fshift
[i_shift_offset
+XX
] += tx
;
330 fshift
[i_shift_offset
+YY
] += ty
;
331 fshift
[i_shift_offset
+ZZ
] += tz
;
334 /* Update potential energies */
335 kernel_data
->energygrp_elec
[ggid
] += velecsum
;
337 /* Increment number of inner iterations */
338 inneriter
+= j_index_end
- j_index_start
;
340 /* Outer loop uses 31 flops */
343 /* Increment number of outer iterations */
346 /* Update outer/inner flops */
348 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_W3_VF
,outeriter
*31 + inneriter
*123);
351 * Gromacs nonbonded kernel: nb_kernel_ElecEw_VdwNone_GeomW3P1_F_c
352 * Electrostatics interaction: Ewald
353 * VdW interaction: None
354 * Geometry: Water3-Particle
355 * Calculate force/pot: Force
358 nb_kernel_ElecEw_VdwNone_GeomW3P1_F_c
359 (t_nblist
* gmx_restrict nlist
,
360 rvec
* gmx_restrict xx
,
361 rvec
* gmx_restrict ff
,
362 struct t_forcerec
* gmx_restrict fr
,
363 t_mdatoms
* gmx_restrict mdatoms
,
364 nb_kernel_data_t gmx_unused
* gmx_restrict kernel_data
,
365 t_nrnb
* gmx_restrict nrnb
)
367 int i_shift_offset
,i_coord_offset
,j_coord_offset
;
368 int j_index_start
,j_index_end
;
369 int nri
,inr
,ggid
,iidx
,jidx
,jnr
,outeriter
,inneriter
;
370 real shX
,shY
,shZ
,tx
,ty
,tz
,fscal
,rcutoff
,rcutoff2
;
371 int *iinr
,*jindex
,*jjnr
,*shiftidx
,*gid
;
372 real
*shiftvec
,*fshift
,*x
,*f
;
374 real ix0
,iy0
,iz0
,fix0
,fiy0
,fiz0
,iq0
,isai0
;
376 real ix1
,iy1
,iz1
,fix1
,fiy1
,fiz1
,iq1
,isai1
;
378 real ix2
,iy2
,iz2
,fix2
,fiy2
,fiz2
,iq2
,isai2
;
380 real jx0
,jy0
,jz0
,fjx0
,fjy0
,fjz0
,jq0
,isaj0
;
381 real dx00
,dy00
,dz00
,rsq00
,rinv00
,rinvsq00
,r00
,qq00
,c6_00
,c12_00
,cexp1_00
,cexp2_00
;
382 real dx10
,dy10
,dz10
,rsq10
,rinv10
,rinvsq10
,r10
,qq10
,c6_10
,c12_10
,cexp1_10
,cexp2_10
;
383 real dx20
,dy20
,dz20
,rsq20
,rinv20
,rinvsq20
,r20
,qq20
,c6_20
,c12_20
,cexp1_20
,cexp2_20
;
384 real velec
,felec
,velecsum
,facel
,crf
,krf
,krf2
;
387 real ewtabscale
,eweps
,sh_ewald
,ewrt
,ewtabhalfspace
;
395 jindex
= nlist
->jindex
;
397 shiftidx
= nlist
->shift
;
399 shiftvec
= fr
->shift_vec
[0];
400 fshift
= fr
->fshift
[0];
401 facel
= fr
->ic
->epsfac
;
402 charge
= mdatoms
->chargeA
;
404 sh_ewald
= fr
->ic
->sh_ewald
;
405 ewtab
= fr
->ic
->tabq_coul_F
;
406 ewtabscale
= fr
->ic
->tabq_scale
;
407 ewtabhalfspace
= 0.5/ewtabscale
;
409 /* Setup water-specific parameters */
410 inr
= nlist
->iinr
[0];
411 iq0
= facel
*charge
[inr
+0];
412 iq1
= facel
*charge
[inr
+1];
413 iq2
= facel
*charge
[inr
+2];
418 /* Start outer loop over neighborlists */
419 for(iidx
=0; iidx
<nri
; iidx
++)
421 /* Load shift vector for this list */
422 i_shift_offset
= DIM
*shiftidx
[iidx
];
423 shX
= shiftvec
[i_shift_offset
+XX
];
424 shY
= shiftvec
[i_shift_offset
+YY
];
425 shZ
= shiftvec
[i_shift_offset
+ZZ
];
427 /* Load limits for loop over neighbors */
428 j_index_start
= jindex
[iidx
];
429 j_index_end
= jindex
[iidx
+1];
431 /* Get outer coordinate index */
433 i_coord_offset
= DIM
*inr
;
435 /* Load i particle coords and add shift vector */
436 ix0
= shX
+ x
[i_coord_offset
+DIM
*0+XX
];
437 iy0
= shY
+ x
[i_coord_offset
+DIM
*0+YY
];
438 iz0
= shZ
+ x
[i_coord_offset
+DIM
*0+ZZ
];
439 ix1
= shX
+ x
[i_coord_offset
+DIM
*1+XX
];
440 iy1
= shY
+ x
[i_coord_offset
+DIM
*1+YY
];
441 iz1
= shZ
+ x
[i_coord_offset
+DIM
*1+ZZ
];
442 ix2
= shX
+ x
[i_coord_offset
+DIM
*2+XX
];
443 iy2
= shY
+ x
[i_coord_offset
+DIM
*2+YY
];
444 iz2
= shZ
+ x
[i_coord_offset
+DIM
*2+ZZ
];
456 /* Start inner kernel loop */
457 for(jidx
=j_index_start
; jidx
<j_index_end
; jidx
++)
459 /* Get j neighbor index, and coordinate index */
461 j_coord_offset
= DIM
*jnr
;
463 /* load j atom coordinates */
464 jx0
= x
[j_coord_offset
+DIM
*0+XX
];
465 jy0
= x
[j_coord_offset
+DIM
*0+YY
];
466 jz0
= x
[j_coord_offset
+DIM
*0+ZZ
];
468 /* Calculate displacement vector */
479 /* Calculate squared distance and things based on it */
480 rsq00
= dx00
*dx00
+dy00
*dy00
+dz00
*dz00
;
481 rsq10
= dx10
*dx10
+dy10
*dy10
+dz10
*dz10
;
482 rsq20
= dx20
*dx20
+dy20
*dy20
+dz20
*dz20
;
484 rinv00
= 1.0/sqrt(rsq00
);
485 rinv10
= 1.0/sqrt(rsq10
);
486 rinv20
= 1.0/sqrt(rsq20
);
488 rinvsq00
= rinv00
*rinv00
;
489 rinvsq10
= rinv10
*rinv10
;
490 rinvsq20
= rinv20
*rinv20
;
492 /* Load parameters for j particles */
495 /**************************
496 * CALCULATE INTERACTIONS *
497 **************************/
503 /* EWALD ELECTROSTATICS */
505 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
506 ewrt
= r00
*ewtabscale
;
509 felec
= (1.0-eweps
)*ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
510 felec
= qq00
*rinv00
*(rinvsq00
-felec
);
514 /* Calculate temporary vectorial force */
519 /* Update vectorial force */
523 f
[j_coord_offset
+DIM
*0+XX
] -= tx
;
524 f
[j_coord_offset
+DIM
*0+YY
] -= ty
;
525 f
[j_coord_offset
+DIM
*0+ZZ
] -= tz
;
527 /**************************
528 * CALCULATE INTERACTIONS *
529 **************************/
535 /* EWALD ELECTROSTATICS */
537 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
538 ewrt
= r10
*ewtabscale
;
541 felec
= (1.0-eweps
)*ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
542 felec
= qq10
*rinv10
*(rinvsq10
-felec
);
546 /* Calculate temporary vectorial force */
551 /* Update vectorial force */
555 f
[j_coord_offset
+DIM
*0+XX
] -= tx
;
556 f
[j_coord_offset
+DIM
*0+YY
] -= ty
;
557 f
[j_coord_offset
+DIM
*0+ZZ
] -= tz
;
559 /**************************
560 * CALCULATE INTERACTIONS *
561 **************************/
567 /* EWALD ELECTROSTATICS */
569 /* Calculate Ewald table index by multiplying r with scale and truncate to integer */
570 ewrt
= r20
*ewtabscale
;
573 felec
= (1.0-eweps
)*ewtab
[ewitab
]+eweps
*ewtab
[ewitab
+1];
574 felec
= qq20
*rinv20
*(rinvsq20
-felec
);
578 /* Calculate temporary vectorial force */
583 /* Update vectorial force */
587 f
[j_coord_offset
+DIM
*0+XX
] -= tx
;
588 f
[j_coord_offset
+DIM
*0+YY
] -= ty
;
589 f
[j_coord_offset
+DIM
*0+ZZ
] -= tz
;
591 /* Inner loop uses 102 flops */
593 /* End of innermost loop */
596 f
[i_coord_offset
+DIM
*0+XX
] += fix0
;
597 f
[i_coord_offset
+DIM
*0+YY
] += fiy0
;
598 f
[i_coord_offset
+DIM
*0+ZZ
] += fiz0
;
602 f
[i_coord_offset
+DIM
*1+XX
] += fix1
;
603 f
[i_coord_offset
+DIM
*1+YY
] += fiy1
;
604 f
[i_coord_offset
+DIM
*1+ZZ
] += fiz1
;
608 f
[i_coord_offset
+DIM
*2+XX
] += fix2
;
609 f
[i_coord_offset
+DIM
*2+YY
] += fiy2
;
610 f
[i_coord_offset
+DIM
*2+ZZ
] += fiz2
;
614 fshift
[i_shift_offset
+XX
] += tx
;
615 fshift
[i_shift_offset
+YY
] += ty
;
616 fshift
[i_shift_offset
+ZZ
] += tz
;
618 /* Increment number of inner iterations */
619 inneriter
+= j_index_end
- j_index_start
;
621 /* Outer loop uses 30 flops */
624 /* Increment number of outer iterations */
627 /* Update outer/inner flops */
629 inc_nrnb(nrnb
,eNR_NBKERNEL_ELEC_W3_F
,outeriter
*30 + inneriter
*102);