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.
42 #include "../nb_kernel.h"
43 #include "types/simple.h"
44 #include "gromacs/math/vec.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW4P1_VF_c
49 * Electrostatics interaction: Coulomb
50 * VdW interaction: LennardJones
51 * Geometry: Water4-Particle
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecCoul_VdwLJ_GeomW4P1_VF_c
56 (t_nblist * gmx_restrict nlist,
57 rvec * gmx_restrict xx,
58 rvec * gmx_restrict ff,
59 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;
80 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
81 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
82 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
83 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
84 real velec,felec,velecsum,facel,crf,krf,krf2;
87 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
96 jindex = nlist->jindex;
98 shiftidx = nlist->shift;
100 shiftvec = fr->shift_vec[0];
101 fshift = fr->fshift[0];
103 charge = mdatoms->chargeA;
104 nvdwtype = fr->ntype;
106 vdwtype = mdatoms->typeA;
108 /* Setup water-specific parameters */
109 inr = nlist->iinr[0];
110 iq1 = facel*charge[inr+1];
111 iq2 = facel*charge[inr+2];
112 iq3 = facel*charge[inr+3];
113 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
118 /* Start outer loop over neighborlists */
119 for(iidx=0; iidx<nri; iidx++)
121 /* Load shift vector for this list */
122 i_shift_offset = DIM*shiftidx[iidx];
123 shX = shiftvec[i_shift_offset+XX];
124 shY = shiftvec[i_shift_offset+YY];
125 shZ = shiftvec[i_shift_offset+ZZ];
127 /* Load limits for loop over neighbors */
128 j_index_start = jindex[iidx];
129 j_index_end = jindex[iidx+1];
131 /* Get outer coordinate index */
133 i_coord_offset = DIM*inr;
135 /* Load i particle coords and add shift vector */
136 ix0 = shX + x[i_coord_offset+DIM*0+XX];
137 iy0 = shY + x[i_coord_offset+DIM*0+YY];
138 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
139 ix1 = shX + x[i_coord_offset+DIM*1+XX];
140 iy1 = shY + x[i_coord_offset+DIM*1+YY];
141 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
142 ix2 = shX + x[i_coord_offset+DIM*2+XX];
143 iy2 = shY + x[i_coord_offset+DIM*2+YY];
144 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
145 ix3 = shX + x[i_coord_offset+DIM*3+XX];
146 iy3 = shY + x[i_coord_offset+DIM*3+YY];
147 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
162 /* Reset potential sums */
166 /* Start inner kernel loop */
167 for(jidx=j_index_start; jidx<j_index_end; jidx++)
169 /* Get j neighbor index, and coordinate index */
171 j_coord_offset = DIM*jnr;
173 /* load j atom coordinates */
174 jx0 = x[j_coord_offset+DIM*0+XX];
175 jy0 = x[j_coord_offset+DIM*0+YY];
176 jz0 = x[j_coord_offset+DIM*0+ZZ];
178 /* Calculate displacement vector */
192 /* Calculate squared distance and things based on it */
193 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
194 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
195 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
196 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
198 rinv10 = gmx_invsqrt(rsq10);
199 rinv20 = gmx_invsqrt(rsq20);
200 rinv30 = gmx_invsqrt(rsq30);
202 rinvsq00 = 1.0/rsq00;
203 rinvsq10 = rinv10*rinv10;
204 rinvsq20 = rinv20*rinv20;
205 rinvsq30 = rinv30*rinv30;
207 /* Load parameters for j particles */
209 vdwjidx0 = 2*vdwtype[jnr+0];
211 /**************************
212 * CALCULATE INTERACTIONS *
213 **************************/
215 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
216 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
218 /* LENNARD-JONES DISPERSION/REPULSION */
220 rinvsix = rinvsq00*rinvsq00*rinvsq00;
221 vvdw6 = c6_00*rinvsix;
222 vvdw12 = c12_00*rinvsix*rinvsix;
223 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
224 fvdw = (vvdw12-vvdw6)*rinvsq00;
226 /* Update potential sums from outer loop */
231 /* Calculate temporary vectorial force */
236 /* Update vectorial force */
240 f[j_coord_offset+DIM*0+XX] -= tx;
241 f[j_coord_offset+DIM*0+YY] -= ty;
242 f[j_coord_offset+DIM*0+ZZ] -= tz;
244 /**************************
245 * CALCULATE INTERACTIONS *
246 **************************/
250 /* COULOMB ELECTROSTATICS */
252 felec = velec*rinvsq10;
254 /* Update potential sums from outer loop */
259 /* Calculate temporary vectorial force */
264 /* Update vectorial force */
268 f[j_coord_offset+DIM*0+XX] -= tx;
269 f[j_coord_offset+DIM*0+YY] -= ty;
270 f[j_coord_offset+DIM*0+ZZ] -= tz;
272 /**************************
273 * CALCULATE INTERACTIONS *
274 **************************/
278 /* COULOMB ELECTROSTATICS */
280 felec = velec*rinvsq20;
282 /* Update potential sums from outer loop */
287 /* Calculate temporary vectorial force */
292 /* Update vectorial force */
296 f[j_coord_offset+DIM*0+XX] -= tx;
297 f[j_coord_offset+DIM*0+YY] -= ty;
298 f[j_coord_offset+DIM*0+ZZ] -= tz;
300 /**************************
301 * CALCULATE INTERACTIONS *
302 **************************/
306 /* COULOMB ELECTROSTATICS */
308 felec = velec*rinvsq30;
310 /* Update potential sums from outer loop */
315 /* Calculate temporary vectorial force */
320 /* Update vectorial force */
324 f[j_coord_offset+DIM*0+XX] -= tx;
325 f[j_coord_offset+DIM*0+YY] -= ty;
326 f[j_coord_offset+DIM*0+ZZ] -= tz;
328 /* Inner loop uses 116 flops */
330 /* End of innermost loop */
333 f[i_coord_offset+DIM*0+XX] += fix0;
334 f[i_coord_offset+DIM*0+YY] += fiy0;
335 f[i_coord_offset+DIM*0+ZZ] += fiz0;
339 f[i_coord_offset+DIM*1+XX] += fix1;
340 f[i_coord_offset+DIM*1+YY] += fiy1;
341 f[i_coord_offset+DIM*1+ZZ] += fiz1;
345 f[i_coord_offset+DIM*2+XX] += fix2;
346 f[i_coord_offset+DIM*2+YY] += fiy2;
347 f[i_coord_offset+DIM*2+ZZ] += fiz2;
351 f[i_coord_offset+DIM*3+XX] += fix3;
352 f[i_coord_offset+DIM*3+YY] += fiy3;
353 f[i_coord_offset+DIM*3+ZZ] += fiz3;
357 fshift[i_shift_offset+XX] += tx;
358 fshift[i_shift_offset+YY] += ty;
359 fshift[i_shift_offset+ZZ] += tz;
362 /* Update potential energies */
363 kernel_data->energygrp_elec[ggid] += velecsum;
364 kernel_data->energygrp_vdw[ggid] += vvdwsum;
366 /* Increment number of inner iterations */
367 inneriter += j_index_end - j_index_start;
369 /* Outer loop uses 41 flops */
372 /* Increment number of outer iterations */
375 /* Update outer/inner flops */
377 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*116);
380 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwLJ_GeomW4P1_F_c
381 * Electrostatics interaction: Coulomb
382 * VdW interaction: LennardJones
383 * Geometry: Water4-Particle
384 * Calculate force/pot: Force
387 nb_kernel_ElecCoul_VdwLJ_GeomW4P1_F_c
388 (t_nblist * gmx_restrict nlist,
389 rvec * gmx_restrict xx,
390 rvec * gmx_restrict ff,
391 t_forcerec * gmx_restrict fr,
392 t_mdatoms * gmx_restrict mdatoms,
393 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
394 t_nrnb * gmx_restrict nrnb)
396 int i_shift_offset,i_coord_offset,j_coord_offset;
397 int j_index_start,j_index_end;
398 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
399 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
400 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
401 real *shiftvec,*fshift,*x,*f;
403 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
405 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
407 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
409 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
411 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
412 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
413 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
414 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
415 real dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
416 real velec,felec,velecsum,facel,crf,krf,krf2;
419 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
428 jindex = nlist->jindex;
430 shiftidx = nlist->shift;
432 shiftvec = fr->shift_vec[0];
433 fshift = fr->fshift[0];
435 charge = mdatoms->chargeA;
436 nvdwtype = fr->ntype;
438 vdwtype = mdatoms->typeA;
440 /* Setup water-specific parameters */
441 inr = nlist->iinr[0];
442 iq1 = facel*charge[inr+1];
443 iq2 = facel*charge[inr+2];
444 iq3 = facel*charge[inr+3];
445 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
450 /* Start outer loop over neighborlists */
451 for(iidx=0; iidx<nri; iidx++)
453 /* Load shift vector for this list */
454 i_shift_offset = DIM*shiftidx[iidx];
455 shX = shiftvec[i_shift_offset+XX];
456 shY = shiftvec[i_shift_offset+YY];
457 shZ = shiftvec[i_shift_offset+ZZ];
459 /* Load limits for loop over neighbors */
460 j_index_start = jindex[iidx];
461 j_index_end = jindex[iidx+1];
463 /* Get outer coordinate index */
465 i_coord_offset = DIM*inr;
467 /* Load i particle coords and add shift vector */
468 ix0 = shX + x[i_coord_offset+DIM*0+XX];
469 iy0 = shY + x[i_coord_offset+DIM*0+YY];
470 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
471 ix1 = shX + x[i_coord_offset+DIM*1+XX];
472 iy1 = shY + x[i_coord_offset+DIM*1+YY];
473 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
474 ix2 = shX + x[i_coord_offset+DIM*2+XX];
475 iy2 = shY + x[i_coord_offset+DIM*2+YY];
476 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
477 ix3 = shX + x[i_coord_offset+DIM*3+XX];
478 iy3 = shY + x[i_coord_offset+DIM*3+YY];
479 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
494 /* Start inner kernel loop */
495 for(jidx=j_index_start; jidx<j_index_end; jidx++)
497 /* Get j neighbor index, and coordinate index */
499 j_coord_offset = DIM*jnr;
501 /* load j atom coordinates */
502 jx0 = x[j_coord_offset+DIM*0+XX];
503 jy0 = x[j_coord_offset+DIM*0+YY];
504 jz0 = x[j_coord_offset+DIM*0+ZZ];
506 /* Calculate displacement vector */
520 /* Calculate squared distance and things based on it */
521 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
522 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
523 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
524 rsq30 = dx30*dx30+dy30*dy30+dz30*dz30;
526 rinv10 = gmx_invsqrt(rsq10);
527 rinv20 = gmx_invsqrt(rsq20);
528 rinv30 = gmx_invsqrt(rsq30);
530 rinvsq00 = 1.0/rsq00;
531 rinvsq10 = rinv10*rinv10;
532 rinvsq20 = rinv20*rinv20;
533 rinvsq30 = rinv30*rinv30;
535 /* Load parameters for j particles */
537 vdwjidx0 = 2*vdwtype[jnr+0];
539 /**************************
540 * CALCULATE INTERACTIONS *
541 **************************/
543 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
544 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
546 /* LENNARD-JONES DISPERSION/REPULSION */
548 rinvsix = rinvsq00*rinvsq00*rinvsq00;
549 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
553 /* Calculate temporary vectorial force */
558 /* Update vectorial force */
562 f[j_coord_offset+DIM*0+XX] -= tx;
563 f[j_coord_offset+DIM*0+YY] -= ty;
564 f[j_coord_offset+DIM*0+ZZ] -= tz;
566 /**************************
567 * CALCULATE INTERACTIONS *
568 **************************/
572 /* COULOMB ELECTROSTATICS */
574 felec = velec*rinvsq10;
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 /**************************
592 * CALCULATE INTERACTIONS *
593 **************************/
597 /* COULOMB ELECTROSTATICS */
599 felec = velec*rinvsq20;
603 /* Calculate temporary vectorial force */
608 /* Update vectorial force */
612 f[j_coord_offset+DIM*0+XX] -= tx;
613 f[j_coord_offset+DIM*0+YY] -= ty;
614 f[j_coord_offset+DIM*0+ZZ] -= tz;
616 /**************************
617 * CALCULATE INTERACTIONS *
618 **************************/
622 /* COULOMB ELECTROSTATICS */
624 felec = velec*rinvsq30;
628 /* Calculate temporary vectorial force */
633 /* Update vectorial force */
637 f[j_coord_offset+DIM*0+XX] -= tx;
638 f[j_coord_offset+DIM*0+YY] -= ty;
639 f[j_coord_offset+DIM*0+ZZ] -= tz;
641 /* Inner loop uses 108 flops */
643 /* End of innermost loop */
646 f[i_coord_offset+DIM*0+XX] += fix0;
647 f[i_coord_offset+DIM*0+YY] += fiy0;
648 f[i_coord_offset+DIM*0+ZZ] += fiz0;
652 f[i_coord_offset+DIM*1+XX] += fix1;
653 f[i_coord_offset+DIM*1+YY] += fiy1;
654 f[i_coord_offset+DIM*1+ZZ] += fiz1;
658 f[i_coord_offset+DIM*2+XX] += fix2;
659 f[i_coord_offset+DIM*2+YY] += fiy2;
660 f[i_coord_offset+DIM*2+ZZ] += fiz2;
664 f[i_coord_offset+DIM*3+XX] += fix3;
665 f[i_coord_offset+DIM*3+YY] += fiy3;
666 f[i_coord_offset+DIM*3+ZZ] += fiz3;
670 fshift[i_shift_offset+XX] += tx;
671 fshift[i_shift_offset+YY] += ty;
672 fshift[i_shift_offset+ZZ] += tz;
674 /* Increment number of inner iterations */
675 inneriter += j_index_end - j_index_start;
677 /* Outer loop uses 39 flops */
680 /* Increment number of outer iterations */
683 /* Update outer/inner flops */
685 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*108);