2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013, 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 "types/simple.h"
50 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwLJ_GeomW4P1_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: LennardJones
53 * Geometry: Water4-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRF_VdwLJ_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];
123 /* Start outer loop over neighborlists */
124 for(iidx=0; iidx<nri; iidx++)
126 /* Load shift vector for this list */
127 i_shift_offset = DIM*shiftidx[iidx];
128 shX = shiftvec[i_shift_offset+XX];
129 shY = shiftvec[i_shift_offset+YY];
130 shZ = shiftvec[i_shift_offset+ZZ];
132 /* Load limits for loop over neighbors */
133 j_index_start = jindex[iidx];
134 j_index_end = jindex[iidx+1];
136 /* Get outer coordinate index */
138 i_coord_offset = DIM*inr;
140 /* Load i particle coords and add shift vector */
141 ix0 = shX + x[i_coord_offset+DIM*0+XX];
142 iy0 = shY + x[i_coord_offset+DIM*0+YY];
143 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
144 ix1 = shX + x[i_coord_offset+DIM*1+XX];
145 iy1 = shY + x[i_coord_offset+DIM*1+YY];
146 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
147 ix2 = shX + x[i_coord_offset+DIM*2+XX];
148 iy2 = shY + x[i_coord_offset+DIM*2+YY];
149 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
150 ix3 = shX + x[i_coord_offset+DIM*3+XX];
151 iy3 = shY + x[i_coord_offset+DIM*3+YY];
152 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
167 /* Reset potential sums */
171 /* Start inner kernel loop */
172 for(jidx=j_index_start; jidx<j_index_end; jidx++)
174 /* Get j neighbor index, and coordinate index */
176 j_coord_offset = DIM*jnr;
178 /* load j atom coordinates */
179 jx0 = x[j_coord_offset+DIM*0+XX];
180 jy0 = x[j_coord_offset+DIM*0+YY];
181 jz0 = x[j_coord_offset+DIM*0+ZZ];
183 /* Calculate displacement vector */
197 /* Calculate squared distance and things based on it */
198 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
199 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
200 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
201 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
203 rinv10 = gmx_invsqrt(rsq10);
204 rinv20 = gmx_invsqrt(rsq20);
205 rinv30 = gmx_invsqrt(rsq30);
207 rinvsq00 = 1.0/rsq00;
208 rinvsq10 = rinv10*rinv10;
209 rinvsq20 = rinv20*rinv20;
210 rinvsq30 = rinv30*rinv30;
212 /* Load parameters for j particles */
214 vdwjidx0 = 2*vdwtype[jnr+0];
216 /**************************
217 * CALCULATE INTERACTIONS *
218 **************************/
220 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
221 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
223 /* LENNARD-JONES DISPERSION/REPULSION */
225 rinvsix = rinvsq00*rinvsq00*rinvsq00;
226 vvdw6 = c6_00*rinvsix;
227 vvdw12 = c12_00*rinvsix*rinvsix;
228 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
229 fvdw = (vvdw12-vvdw6)*rinvsq00;
231 /* Update potential sums from outer loop */
236 /* Calculate temporary vectorial force */
241 /* Update vectorial force */
245 f[j_coord_offset+DIM*0+XX] -= tx;
246 f[j_coord_offset+DIM*0+YY] -= ty;
247 f[j_coord_offset+DIM*0+ZZ] -= tz;
249 /**************************
250 * CALCULATE INTERACTIONS *
251 **************************/
255 /* REACTION-FIELD ELECTROSTATICS */
256 velec = qq10*(rinv10+krf*rsq10-crf);
257 felec = qq10*(rinv10*rinvsq10-krf2);
259 /* Update potential sums from outer loop */
264 /* Calculate temporary vectorial force */
269 /* Update vectorial force */
273 f[j_coord_offset+DIM*0+XX] -= tx;
274 f[j_coord_offset+DIM*0+YY] -= ty;
275 f[j_coord_offset+DIM*0+ZZ] -= tz;
277 /**************************
278 * CALCULATE INTERACTIONS *
279 **************************/
283 /* REACTION-FIELD ELECTROSTATICS */
284 velec = qq20*(rinv20+krf*rsq20-crf);
285 felec = qq20*(rinv20*rinvsq20-krf2);
287 /* Update potential sums from outer loop */
292 /* Calculate temporary vectorial force */
297 /* Update vectorial force */
301 f[j_coord_offset+DIM*0+XX] -= tx;
302 f[j_coord_offset+DIM*0+YY] -= ty;
303 f[j_coord_offset+DIM*0+ZZ] -= tz;
305 /**************************
306 * CALCULATE INTERACTIONS *
307 **************************/
311 /* REACTION-FIELD ELECTROSTATICS */
312 velec = qq30*(rinv30+krf*rsq30-crf);
313 felec = qq30*(rinv30*rinvsq30-krf2);
315 /* Update potential sums from outer loop */
320 /* Calculate temporary vectorial force */
325 /* Update vectorial force */
329 f[j_coord_offset+DIM*0+XX] -= tx;
330 f[j_coord_offset+DIM*0+YY] -= ty;
331 f[j_coord_offset+DIM*0+ZZ] -= tz;
333 /* Inner loop uses 128 flops */
335 /* End of innermost loop */
338 f[i_coord_offset+DIM*0+XX] += fix0;
339 f[i_coord_offset+DIM*0+YY] += fiy0;
340 f[i_coord_offset+DIM*0+ZZ] += fiz0;
344 f[i_coord_offset+DIM*1+XX] += fix1;
345 f[i_coord_offset+DIM*1+YY] += fiy1;
346 f[i_coord_offset+DIM*1+ZZ] += fiz1;
350 f[i_coord_offset+DIM*2+XX] += fix2;
351 f[i_coord_offset+DIM*2+YY] += fiy2;
352 f[i_coord_offset+DIM*2+ZZ] += fiz2;
356 f[i_coord_offset+DIM*3+XX] += fix3;
357 f[i_coord_offset+DIM*3+YY] += fiy3;
358 f[i_coord_offset+DIM*3+ZZ] += fiz3;
362 fshift[i_shift_offset+XX] += tx;
363 fshift[i_shift_offset+YY] += ty;
364 fshift[i_shift_offset+ZZ] += tz;
367 /* Update potential energies */
368 kernel_data->energygrp_elec[ggid] += velecsum;
369 kernel_data->energygrp_vdw[ggid] += vvdwsum;
371 /* Increment number of inner iterations */
372 inneriter += j_index_end - j_index_start;
374 /* Outer loop uses 41 flops */
377 /* Increment number of outer iterations */
380 /* Update outer/inner flops */
382 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*128);
385 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwLJ_GeomW4P1_F_c
386 * Electrostatics interaction: ReactionField
387 * VdW interaction: LennardJones
388 * Geometry: Water4-Particle
389 * Calculate force/pot: Force
392 nb_kernel_ElecRF_VdwLJ_GeomW4P1_F_c
393 (t_nblist * gmx_restrict nlist,
394 rvec * gmx_restrict xx,
395 rvec * gmx_restrict ff,
396 t_forcerec * gmx_restrict fr,
397 t_mdatoms * gmx_restrict mdatoms,
398 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
399 t_nrnb * gmx_restrict nrnb)
401 int i_shift_offset,i_coord_offset,j_coord_offset;
402 int j_index_start,j_index_end;
403 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
404 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
405 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
406 real *shiftvec,*fshift,*x,*f;
408 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
410 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
412 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
414 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
416 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
417 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
418 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
419 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
420 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
421 real velec,felec,velecsum,facel,crf,krf,krf2;
424 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
433 jindex = nlist->jindex;
435 shiftidx = nlist->shift;
437 shiftvec = fr->shift_vec[0];
438 fshift = fr->fshift[0];
440 charge = mdatoms->chargeA;
444 nvdwtype = fr->ntype;
446 vdwtype = mdatoms->typeA;
448 /* Setup water-specific parameters */
449 inr = nlist->iinr[0];
450 iq1 = facel*charge[inr+1];
451 iq2 = facel*charge[inr+2];
452 iq3 = facel*charge[inr+3];
453 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
458 /* Start outer loop over neighborlists */
459 for(iidx=0; iidx<nri; iidx++)
461 /* Load shift vector for this list */
462 i_shift_offset = DIM*shiftidx[iidx];
463 shX = shiftvec[i_shift_offset+XX];
464 shY = shiftvec[i_shift_offset+YY];
465 shZ = shiftvec[i_shift_offset+ZZ];
467 /* Load limits for loop over neighbors */
468 j_index_start = jindex[iidx];
469 j_index_end = jindex[iidx+1];
471 /* Get outer coordinate index */
473 i_coord_offset = DIM*inr;
475 /* Load i particle coords and add shift vector */
476 ix0 = shX + x[i_coord_offset+DIM*0+XX];
477 iy0 = shY + x[i_coord_offset+DIM*0+YY];
478 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
479 ix1 = shX + x[i_coord_offset+DIM*1+XX];
480 iy1 = shY + x[i_coord_offset+DIM*1+YY];
481 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
482 ix2 = shX + x[i_coord_offset+DIM*2+XX];
483 iy2 = shY + x[i_coord_offset+DIM*2+YY];
484 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
485 ix3 = shX + x[i_coord_offset+DIM*3+XX];
486 iy3 = shY + x[i_coord_offset+DIM*3+YY];
487 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
502 /* Start inner kernel loop */
503 for(jidx=j_index_start; jidx<j_index_end; jidx++)
505 /* Get j neighbor index, and coordinate index */
507 j_coord_offset = DIM*jnr;
509 /* load j atom coordinates */
510 jx0 = x[j_coord_offset+DIM*0+XX];
511 jy0 = x[j_coord_offset+DIM*0+YY];
512 jz0 = x[j_coord_offset+DIM*0+ZZ];
514 /* Calculate displacement vector */
528 /* Calculate squared distance and things based on it */
529 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
530 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
531 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
532 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
534 rinv10 = gmx_invsqrt(rsq10);
535 rinv20 = gmx_invsqrt(rsq20);
536 rinv30 = gmx_invsqrt(rsq30);
538 rinvsq00 = 1.0/rsq00;
539 rinvsq10 = rinv10*rinv10;
540 rinvsq20 = rinv20*rinv20;
541 rinvsq30 = rinv30*rinv30;
543 /* Load parameters for j particles */
545 vdwjidx0 = 2*vdwtype[jnr+0];
547 /**************************
548 * CALCULATE INTERACTIONS *
549 **************************/
551 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
552 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
554 /* LENNARD-JONES DISPERSION/REPULSION */
556 rinvsix = rinvsq00*rinvsq00*rinvsq00;
557 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
561 /* Calculate temporary vectorial force */
566 /* Update vectorial force */
570 f[j_coord_offset+DIM*0+XX] -= tx;
571 f[j_coord_offset+DIM*0+YY] -= ty;
572 f[j_coord_offset+DIM*0+ZZ] -= tz;
574 /**************************
575 * CALCULATE INTERACTIONS *
576 **************************/
580 /* REACTION-FIELD ELECTROSTATICS */
581 felec = qq10*(rinv10*rinvsq10-krf2);
585 /* Calculate temporary vectorial force */
590 /* Update vectorial force */
594 f[j_coord_offset+DIM*0+XX] -= tx;
595 f[j_coord_offset+DIM*0+YY] -= ty;
596 f[j_coord_offset+DIM*0+ZZ] -= tz;
598 /**************************
599 * CALCULATE INTERACTIONS *
600 **************************/
604 /* REACTION-FIELD ELECTROSTATICS */
605 felec = qq20*(rinv20*rinvsq20-krf2);
609 /* Calculate temporary vectorial force */
614 /* Update vectorial force */
618 f[j_coord_offset+DIM*0+XX] -= tx;
619 f[j_coord_offset+DIM*0+YY] -= ty;
620 f[j_coord_offset+DIM*0+ZZ] -= tz;
622 /**************************
623 * CALCULATE INTERACTIONS *
624 **************************/
628 /* REACTION-FIELD ELECTROSTATICS */
629 felec = qq30*(rinv30*rinvsq30-krf2);
633 /* Calculate temporary vectorial force */
638 /* Update vectorial force */
642 f[j_coord_offset+DIM*0+XX] -= tx;
643 f[j_coord_offset+DIM*0+YY] -= ty;
644 f[j_coord_offset+DIM*0+ZZ] -= tz;
646 /* Inner loop uses 108 flops */
648 /* End of innermost loop */
651 f[i_coord_offset+DIM*0+XX] += fix0;
652 f[i_coord_offset+DIM*0+YY] += fiy0;
653 f[i_coord_offset+DIM*0+ZZ] += fiz0;
657 f[i_coord_offset+DIM*1+XX] += fix1;
658 f[i_coord_offset+DIM*1+YY] += fiy1;
659 f[i_coord_offset+DIM*1+ZZ] += fiz1;
663 f[i_coord_offset+DIM*2+XX] += fix2;
664 f[i_coord_offset+DIM*2+YY] += fiy2;
665 f[i_coord_offset+DIM*2+ZZ] += fiz2;
669 f[i_coord_offset+DIM*3+XX] += fix3;
670 f[i_coord_offset+DIM*3+YY] += fiy3;
671 f[i_coord_offset+DIM*3+ZZ] += fiz3;
675 fshift[i_shift_offset+XX] += tx;
676 fshift[i_shift_offset+YY] += ty;
677 fshift[i_shift_offset+ZZ] += tz;
679 /* Increment number of inner iterations */
680 inneriter += j_index_end - j_index_start;
682 /* Outer loop uses 39 flops */
685 /* Increment number of outer iterations */
688 /* Update outer/inner flops */
690 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*108);