2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014, 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/legacyheaders/types/simple.h"
46 #include "gromacs/math/vec.h"
47 #include "gromacs/legacyheaders/nrnb.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSh_GeomW4P1_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: LennardJones
53 * Geometry: Water4-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRFCut_VdwLJSh_GeomW4P1_VF_c
58 (t_nblist * gmx_restrict nlist,
59 rvec * gmx_restrict xx,
60 rvec * gmx_restrict ff,
61 t_forcerec * gmx_restrict fr,
62 t_mdatoms * gmx_restrict mdatoms,
63 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
64 t_nrnb * gmx_restrict nrnb)
66 int i_shift_offset,i_coord_offset,j_coord_offset;
67 int j_index_start,j_index_end;
68 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
69 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
70 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
71 real *shiftvec,*fshift,*x,*f;
73 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
75 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
77 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
79 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
81 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
82 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
83 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
84 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
85 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
86 real velec,felec,velecsum,facel,crf,krf,krf2;
89 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
98 jindex = nlist->jindex;
100 shiftidx = nlist->shift;
102 shiftvec = fr->shift_vec[0];
103 fshift = fr->fshift[0];
105 charge = mdatoms->chargeA;
109 nvdwtype = fr->ntype;
111 vdwtype = mdatoms->typeA;
113 /* Setup water-specific parameters */
114 inr = nlist->iinr[0];
115 iq1 = facel*charge[inr+1];
116 iq2 = facel*charge[inr+2];
117 iq3 = facel*charge[inr+3];
118 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
120 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
121 rcutoff = fr->rcoulomb;
122 rcutoff2 = rcutoff*rcutoff;
124 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
130 /* Start outer loop over neighborlists */
131 for(iidx=0; iidx<nri; iidx++)
133 /* Load shift vector for this list */
134 i_shift_offset = DIM*shiftidx[iidx];
135 shX = shiftvec[i_shift_offset+XX];
136 shY = shiftvec[i_shift_offset+YY];
137 shZ = shiftvec[i_shift_offset+ZZ];
139 /* Load limits for loop over neighbors */
140 j_index_start = jindex[iidx];
141 j_index_end = jindex[iidx+1];
143 /* Get outer coordinate index */
145 i_coord_offset = DIM*inr;
147 /* Load i particle coords and add shift vector */
148 ix0 = shX + x[i_coord_offset+DIM*0+XX];
149 iy0 = shY + x[i_coord_offset+DIM*0+YY];
150 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
151 ix1 = shX + x[i_coord_offset+DIM*1+XX];
152 iy1 = shY + x[i_coord_offset+DIM*1+YY];
153 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
154 ix2 = shX + x[i_coord_offset+DIM*2+XX];
155 iy2 = shY + x[i_coord_offset+DIM*2+YY];
156 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
157 ix3 = shX + x[i_coord_offset+DIM*3+XX];
158 iy3 = shY + x[i_coord_offset+DIM*3+YY];
159 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
174 /* Reset potential sums */
178 /* Start inner kernel loop */
179 for(jidx=j_index_start; jidx<j_index_end; jidx++)
181 /* Get j neighbor index, and coordinate index */
183 j_coord_offset = DIM*jnr;
185 /* load j atom coordinates */
186 jx0 = x[j_coord_offset+DIM*0+XX];
187 jy0 = x[j_coord_offset+DIM*0+YY];
188 jz0 = x[j_coord_offset+DIM*0+ZZ];
190 /* Calculate displacement vector */
204 /* Calculate squared distance and things based on it */
205 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
206 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
207 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
208 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
210 rinv10 = gmx_invsqrt(rsq10);
211 rinv20 = gmx_invsqrt(rsq20);
212 rinv30 = gmx_invsqrt(rsq30);
214 rinvsq00 = 1.0/rsq00;
215 rinvsq10 = rinv10*rinv10;
216 rinvsq20 = rinv20*rinv20;
217 rinvsq30 = rinv30*rinv30;
219 /* Load parameters for j particles */
221 vdwjidx0 = 2*vdwtype[jnr+0];
223 /**************************
224 * CALCULATE INTERACTIONS *
225 **************************/
230 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
231 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
233 /* LENNARD-JONES DISPERSION/REPULSION */
235 rinvsix = rinvsq00*rinvsq00*rinvsq00;
236 vvdw6 = c6_00*rinvsix;
237 vvdw12 = c12_00*rinvsix*rinvsix;
238 vvdw = (vvdw12 - c12_00*sh_vdw_invrcut6*sh_vdw_invrcut6)*(1.0/12.0) - (vvdw6 - c6_00*sh_vdw_invrcut6)*(1.0/6.0);
239 fvdw = (vvdw12-vvdw6)*rinvsq00;
241 /* Update potential sums from outer loop */
246 /* Calculate temporary vectorial force */
251 /* Update vectorial force */
255 f[j_coord_offset+DIM*0+XX] -= tx;
256 f[j_coord_offset+DIM*0+YY] -= ty;
257 f[j_coord_offset+DIM*0+ZZ] -= tz;
261 /**************************
262 * CALCULATE INTERACTIONS *
263 **************************/
270 /* REACTION-FIELD ELECTROSTATICS */
271 velec = qq10*(rinv10+krf*rsq10-crf);
272 felec = qq10*(rinv10*rinvsq10-krf2);
274 /* Update potential sums from outer loop */
279 /* Calculate temporary vectorial force */
284 /* Update vectorial force */
288 f[j_coord_offset+DIM*0+XX] -= tx;
289 f[j_coord_offset+DIM*0+YY] -= ty;
290 f[j_coord_offset+DIM*0+ZZ] -= tz;
294 /**************************
295 * CALCULATE INTERACTIONS *
296 **************************/
303 /* REACTION-FIELD ELECTROSTATICS */
304 velec = qq20*(rinv20+krf*rsq20-crf);
305 felec = qq20*(rinv20*rinvsq20-krf2);
307 /* Update potential sums from outer loop */
312 /* Calculate temporary vectorial force */
317 /* Update vectorial force */
321 f[j_coord_offset+DIM*0+XX] -= tx;
322 f[j_coord_offset+DIM*0+YY] -= ty;
323 f[j_coord_offset+DIM*0+ZZ] -= tz;
327 /**************************
328 * CALCULATE INTERACTIONS *
329 **************************/
336 /* REACTION-FIELD ELECTROSTATICS */
337 velec = qq30*(rinv30+krf*rsq30-crf);
338 felec = qq30*(rinv30*rinvsq30-krf2);
340 /* Update potential sums from outer loop */
345 /* Calculate temporary vectorial force */
350 /* Update vectorial force */
354 f[j_coord_offset+DIM*0+XX] -= tx;
355 f[j_coord_offset+DIM*0+YY] -= ty;
356 f[j_coord_offset+DIM*0+ZZ] -= tz;
360 /* Inner loop uses 133 flops */
362 /* End of innermost loop */
365 f[i_coord_offset+DIM*0+XX] += fix0;
366 f[i_coord_offset+DIM*0+YY] += fiy0;
367 f[i_coord_offset+DIM*0+ZZ] += fiz0;
371 f[i_coord_offset+DIM*1+XX] += fix1;
372 f[i_coord_offset+DIM*1+YY] += fiy1;
373 f[i_coord_offset+DIM*1+ZZ] += fiz1;
377 f[i_coord_offset+DIM*2+XX] += fix2;
378 f[i_coord_offset+DIM*2+YY] += fiy2;
379 f[i_coord_offset+DIM*2+ZZ] += fiz2;
383 f[i_coord_offset+DIM*3+XX] += fix3;
384 f[i_coord_offset+DIM*3+YY] += fiy3;
385 f[i_coord_offset+DIM*3+ZZ] += fiz3;
389 fshift[i_shift_offset+XX] += tx;
390 fshift[i_shift_offset+YY] += ty;
391 fshift[i_shift_offset+ZZ] += tz;
394 /* Update potential energies */
395 kernel_data->energygrp_elec[ggid] += velecsum;
396 kernel_data->energygrp_vdw[ggid] += vvdwsum;
398 /* Increment number of inner iterations */
399 inneriter += j_index_end - j_index_start;
401 /* Outer loop uses 41 flops */
404 /* Increment number of outer iterations */
407 /* Update outer/inner flops */
409 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*133);
412 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwLJSh_GeomW4P1_F_c
413 * Electrostatics interaction: ReactionField
414 * VdW interaction: LennardJones
415 * Geometry: Water4-Particle
416 * Calculate force/pot: Force
419 nb_kernel_ElecRFCut_VdwLJSh_GeomW4P1_F_c
420 (t_nblist * gmx_restrict nlist,
421 rvec * gmx_restrict xx,
422 rvec * gmx_restrict ff,
423 t_forcerec * gmx_restrict fr,
424 t_mdatoms * gmx_restrict mdatoms,
425 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
426 t_nrnb * gmx_restrict nrnb)
428 int i_shift_offset,i_coord_offset,j_coord_offset;
429 int j_index_start,j_index_end;
430 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
431 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
432 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
433 real *shiftvec,*fshift,*x,*f;
435 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
437 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
439 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
441 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
443 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
444 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
445 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
446 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
447 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
448 real velec,felec,velecsum,facel,crf,krf,krf2;
451 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
460 jindex = nlist->jindex;
462 shiftidx = nlist->shift;
464 shiftvec = fr->shift_vec[0];
465 fshift = fr->fshift[0];
467 charge = mdatoms->chargeA;
471 nvdwtype = fr->ntype;
473 vdwtype = mdatoms->typeA;
475 /* Setup water-specific parameters */
476 inr = nlist->iinr[0];
477 iq1 = facel*charge[inr+1];
478 iq2 = facel*charge[inr+2];
479 iq3 = facel*charge[inr+3];
480 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
482 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
483 rcutoff = fr->rcoulomb;
484 rcutoff2 = rcutoff*rcutoff;
486 sh_vdw_invrcut6 = fr->ic->sh_invrc6;
492 /* Start outer loop over neighborlists */
493 for(iidx=0; iidx<nri; iidx++)
495 /* Load shift vector for this list */
496 i_shift_offset = DIM*shiftidx[iidx];
497 shX = shiftvec[i_shift_offset+XX];
498 shY = shiftvec[i_shift_offset+YY];
499 shZ = shiftvec[i_shift_offset+ZZ];
501 /* Load limits for loop over neighbors */
502 j_index_start = jindex[iidx];
503 j_index_end = jindex[iidx+1];
505 /* Get outer coordinate index */
507 i_coord_offset = DIM*inr;
509 /* Load i particle coords and add shift vector */
510 ix0 = shX + x[i_coord_offset+DIM*0+XX];
511 iy0 = shY + x[i_coord_offset+DIM*0+YY];
512 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
513 ix1 = shX + x[i_coord_offset+DIM*1+XX];
514 iy1 = shY + x[i_coord_offset+DIM*1+YY];
515 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
516 ix2 = shX + x[i_coord_offset+DIM*2+XX];
517 iy2 = shY + x[i_coord_offset+DIM*2+YY];
518 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
519 ix3 = shX + x[i_coord_offset+DIM*3+XX];
520 iy3 = shY + x[i_coord_offset+DIM*3+YY];
521 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
536 /* Start inner kernel loop */
537 for(jidx=j_index_start; jidx<j_index_end; jidx++)
539 /* Get j neighbor index, and coordinate index */
541 j_coord_offset = DIM*jnr;
543 /* load j atom coordinates */
544 jx0 = x[j_coord_offset+DIM*0+XX];
545 jy0 = x[j_coord_offset+DIM*0+YY];
546 jz0 = x[j_coord_offset+DIM*0+ZZ];
548 /* Calculate displacement vector */
562 /* Calculate squared distance and things based on it */
563 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
564 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
565 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
566 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
568 rinv10 = gmx_invsqrt(rsq10);
569 rinv20 = gmx_invsqrt(rsq20);
570 rinv30 = gmx_invsqrt(rsq30);
572 rinvsq00 = 1.0/rsq00;
573 rinvsq10 = rinv10*rinv10;
574 rinvsq20 = rinv20*rinv20;
575 rinvsq30 = rinv30*rinv30;
577 /* Load parameters for j particles */
579 vdwjidx0 = 2*vdwtype[jnr+0];
581 /**************************
582 * CALCULATE INTERACTIONS *
583 **************************/
588 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
589 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
591 /* LENNARD-JONES DISPERSION/REPULSION */
593 rinvsix = rinvsq00*rinvsq00*rinvsq00;
594 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
598 /* Calculate temporary vectorial force */
603 /* Update vectorial force */
607 f[j_coord_offset+DIM*0+XX] -= tx;
608 f[j_coord_offset+DIM*0+YY] -= ty;
609 f[j_coord_offset+DIM*0+ZZ] -= tz;
613 /**************************
614 * CALCULATE INTERACTIONS *
615 **************************/
622 /* REACTION-FIELD ELECTROSTATICS */
623 felec = qq10*(rinv10*rinvsq10-krf2);
627 /* Calculate temporary vectorial force */
632 /* Update vectorial force */
636 f[j_coord_offset+DIM*0+XX] -= tx;
637 f[j_coord_offset+DIM*0+YY] -= ty;
638 f[j_coord_offset+DIM*0+ZZ] -= tz;
642 /**************************
643 * CALCULATE INTERACTIONS *
644 **************************/
651 /* REACTION-FIELD ELECTROSTATICS */
652 felec = qq20*(rinv20*rinvsq20-krf2);
656 /* Calculate temporary vectorial force */
661 /* Update vectorial force */
665 f[j_coord_offset+DIM*0+XX] -= tx;
666 f[j_coord_offset+DIM*0+YY] -= ty;
667 f[j_coord_offset+DIM*0+ZZ] -= tz;
671 /**************************
672 * CALCULATE INTERACTIONS *
673 **************************/
680 /* REACTION-FIELD ELECTROSTATICS */
681 felec = qq30*(rinv30*rinvsq30-krf2);
685 /* Calculate temporary vectorial force */
690 /* Update vectorial force */
694 f[j_coord_offset+DIM*0+XX] -= tx;
695 f[j_coord_offset+DIM*0+YY] -= ty;
696 f[j_coord_offset+DIM*0+ZZ] -= tz;
700 /* Inner loop uses 108 flops */
702 /* End of innermost loop */
705 f[i_coord_offset+DIM*0+XX] += fix0;
706 f[i_coord_offset+DIM*0+YY] += fiy0;
707 f[i_coord_offset+DIM*0+ZZ] += fiz0;
711 f[i_coord_offset+DIM*1+XX] += fix1;
712 f[i_coord_offset+DIM*1+YY] += fiy1;
713 f[i_coord_offset+DIM*1+ZZ] += fiz1;
717 f[i_coord_offset+DIM*2+XX] += fix2;
718 f[i_coord_offset+DIM*2+YY] += fiy2;
719 f[i_coord_offset+DIM*2+ZZ] += fiz2;
723 f[i_coord_offset+DIM*3+XX] += fix3;
724 f[i_coord_offset+DIM*3+YY] += fiy3;
725 f[i_coord_offset+DIM*3+ZZ] += fiz3;
729 fshift[i_shift_offset+XX] += tx;
730 fshift[i_shift_offset+YY] += ty;
731 fshift[i_shift_offset+ZZ] += tz;
733 /* Increment number of inner iterations */
734 inneriter += j_index_end - j_index_start;
736 /* Outer loop uses 39 flops */
739 /* Increment number of outer iterations */
742 /* Update outer/inner flops */
744 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*108);