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_ElecRF_VdwLJ_GeomW4W4_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: LennardJones
53 * Geometry: Water4-Water4
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRF_VdwLJ_GeomW4W4_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;
83 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
85 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
87 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
88 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
89 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
90 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
91 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
92 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
93 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
94 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
95 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
96 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
97 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
98 real velec,felec,velecsum,facel,crf,krf,krf2;
101 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
110 jindex = nlist->jindex;
112 shiftidx = nlist->shift;
114 shiftvec = fr->shift_vec[0];
115 fshift = fr->fshift[0];
117 charge = mdatoms->chargeA;
121 nvdwtype = fr->ntype;
123 vdwtype = mdatoms->typeA;
125 /* Setup water-specific parameters */
126 inr = nlist->iinr[0];
127 iq1 = facel*charge[inr+1];
128 iq2 = facel*charge[inr+2];
129 iq3 = facel*charge[inr+3];
130 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
135 vdwjidx0 = 2*vdwtype[inr+0];
136 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
137 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
151 /* Start outer loop over neighborlists */
152 for(iidx=0; iidx<nri; iidx++)
154 /* Load shift vector for this list */
155 i_shift_offset = DIM*shiftidx[iidx];
156 shX = shiftvec[i_shift_offset+XX];
157 shY = shiftvec[i_shift_offset+YY];
158 shZ = shiftvec[i_shift_offset+ZZ];
160 /* Load limits for loop over neighbors */
161 j_index_start = jindex[iidx];
162 j_index_end = jindex[iidx+1];
164 /* Get outer coordinate index */
166 i_coord_offset = DIM*inr;
168 /* Load i particle coords and add shift vector */
169 ix0 = shX + x[i_coord_offset+DIM*0+XX];
170 iy0 = shY + x[i_coord_offset+DIM*0+YY];
171 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
172 ix1 = shX + x[i_coord_offset+DIM*1+XX];
173 iy1 = shY + x[i_coord_offset+DIM*1+YY];
174 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
175 ix2 = shX + x[i_coord_offset+DIM*2+XX];
176 iy2 = shY + x[i_coord_offset+DIM*2+YY];
177 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
178 ix3 = shX + x[i_coord_offset+DIM*3+XX];
179 iy3 = shY + x[i_coord_offset+DIM*3+YY];
180 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
195 /* Reset potential sums */
199 /* Start inner kernel loop */
200 for(jidx=j_index_start; jidx<j_index_end; jidx++)
202 /* Get j neighbor index, and coordinate index */
204 j_coord_offset = DIM*jnr;
206 /* load j atom coordinates */
207 jx0 = x[j_coord_offset+DIM*0+XX];
208 jy0 = x[j_coord_offset+DIM*0+YY];
209 jz0 = x[j_coord_offset+DIM*0+ZZ];
210 jx1 = x[j_coord_offset+DIM*1+XX];
211 jy1 = x[j_coord_offset+DIM*1+YY];
212 jz1 = x[j_coord_offset+DIM*1+ZZ];
213 jx2 = x[j_coord_offset+DIM*2+XX];
214 jy2 = x[j_coord_offset+DIM*2+YY];
215 jz2 = x[j_coord_offset+DIM*2+ZZ];
216 jx3 = x[j_coord_offset+DIM*3+XX];
217 jy3 = x[j_coord_offset+DIM*3+YY];
218 jz3 = x[j_coord_offset+DIM*3+ZZ];
220 /* Calculate displacement vector */
252 /* Calculate squared distance and things based on it */
253 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
254 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
255 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
256 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
257 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
258 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
259 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
260 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
261 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
262 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
264 rinv11 = gmx_invsqrt(rsq11);
265 rinv12 = gmx_invsqrt(rsq12);
266 rinv13 = gmx_invsqrt(rsq13);
267 rinv21 = gmx_invsqrt(rsq21);
268 rinv22 = gmx_invsqrt(rsq22);
269 rinv23 = gmx_invsqrt(rsq23);
270 rinv31 = gmx_invsqrt(rsq31);
271 rinv32 = gmx_invsqrt(rsq32);
272 rinv33 = gmx_invsqrt(rsq33);
274 rinvsq00 = 1.0/rsq00;
275 rinvsq11 = rinv11*rinv11;
276 rinvsq12 = rinv12*rinv12;
277 rinvsq13 = rinv13*rinv13;
278 rinvsq21 = rinv21*rinv21;
279 rinvsq22 = rinv22*rinv22;
280 rinvsq23 = rinv23*rinv23;
281 rinvsq31 = rinv31*rinv31;
282 rinvsq32 = rinv32*rinv32;
283 rinvsq33 = rinv33*rinv33;
285 /**************************
286 * CALCULATE INTERACTIONS *
287 **************************/
289 /* LENNARD-JONES DISPERSION/REPULSION */
291 rinvsix = rinvsq00*rinvsq00*rinvsq00;
292 vvdw6 = c6_00*rinvsix;
293 vvdw12 = c12_00*rinvsix*rinvsix;
294 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
295 fvdw = (vvdw12-vvdw6)*rinvsq00;
297 /* Update potential sums from outer loop */
302 /* Calculate temporary vectorial force */
307 /* Update vectorial force */
311 f[j_coord_offset+DIM*0+XX] -= tx;
312 f[j_coord_offset+DIM*0+YY] -= ty;
313 f[j_coord_offset+DIM*0+ZZ] -= tz;
315 /**************************
316 * CALCULATE INTERACTIONS *
317 **************************/
319 /* REACTION-FIELD ELECTROSTATICS */
320 velec = qq11*(rinv11+krf*rsq11-crf);
321 felec = qq11*(rinv11*rinvsq11-krf2);
323 /* Update potential sums from outer loop */
328 /* Calculate temporary vectorial force */
333 /* Update vectorial force */
337 f[j_coord_offset+DIM*1+XX] -= tx;
338 f[j_coord_offset+DIM*1+YY] -= ty;
339 f[j_coord_offset+DIM*1+ZZ] -= tz;
341 /**************************
342 * CALCULATE INTERACTIONS *
343 **************************/
345 /* REACTION-FIELD ELECTROSTATICS */
346 velec = qq12*(rinv12+krf*rsq12-crf);
347 felec = qq12*(rinv12*rinvsq12-krf2);
349 /* Update potential sums from outer loop */
354 /* Calculate temporary vectorial force */
359 /* Update vectorial force */
363 f[j_coord_offset+DIM*2+XX] -= tx;
364 f[j_coord_offset+DIM*2+YY] -= ty;
365 f[j_coord_offset+DIM*2+ZZ] -= tz;
367 /**************************
368 * CALCULATE INTERACTIONS *
369 **************************/
371 /* REACTION-FIELD ELECTROSTATICS */
372 velec = qq13*(rinv13+krf*rsq13-crf);
373 felec = qq13*(rinv13*rinvsq13-krf2);
375 /* Update potential sums from outer loop */
380 /* Calculate temporary vectorial force */
385 /* Update vectorial force */
389 f[j_coord_offset+DIM*3+XX] -= tx;
390 f[j_coord_offset+DIM*3+YY] -= ty;
391 f[j_coord_offset+DIM*3+ZZ] -= tz;
393 /**************************
394 * CALCULATE INTERACTIONS *
395 **************************/
397 /* REACTION-FIELD ELECTROSTATICS */
398 velec = qq21*(rinv21+krf*rsq21-crf);
399 felec = qq21*(rinv21*rinvsq21-krf2);
401 /* Update potential sums from outer loop */
406 /* Calculate temporary vectorial force */
411 /* Update vectorial force */
415 f[j_coord_offset+DIM*1+XX] -= tx;
416 f[j_coord_offset+DIM*1+YY] -= ty;
417 f[j_coord_offset+DIM*1+ZZ] -= tz;
419 /**************************
420 * CALCULATE INTERACTIONS *
421 **************************/
423 /* REACTION-FIELD ELECTROSTATICS */
424 velec = qq22*(rinv22+krf*rsq22-crf);
425 felec = qq22*(rinv22*rinvsq22-krf2);
427 /* Update potential sums from outer loop */
432 /* Calculate temporary vectorial force */
437 /* Update vectorial force */
441 f[j_coord_offset+DIM*2+XX] -= tx;
442 f[j_coord_offset+DIM*2+YY] -= ty;
443 f[j_coord_offset+DIM*2+ZZ] -= tz;
445 /**************************
446 * CALCULATE INTERACTIONS *
447 **************************/
449 /* REACTION-FIELD ELECTROSTATICS */
450 velec = qq23*(rinv23+krf*rsq23-crf);
451 felec = qq23*(rinv23*rinvsq23-krf2);
453 /* Update potential sums from outer loop */
458 /* Calculate temporary vectorial force */
463 /* Update vectorial force */
467 f[j_coord_offset+DIM*3+XX] -= tx;
468 f[j_coord_offset+DIM*3+YY] -= ty;
469 f[j_coord_offset+DIM*3+ZZ] -= tz;
471 /**************************
472 * CALCULATE INTERACTIONS *
473 **************************/
475 /* REACTION-FIELD ELECTROSTATICS */
476 velec = qq31*(rinv31+krf*rsq31-crf);
477 felec = qq31*(rinv31*rinvsq31-krf2);
479 /* Update potential sums from outer loop */
484 /* Calculate temporary vectorial force */
489 /* Update vectorial force */
493 f[j_coord_offset+DIM*1+XX] -= tx;
494 f[j_coord_offset+DIM*1+YY] -= ty;
495 f[j_coord_offset+DIM*1+ZZ] -= tz;
497 /**************************
498 * CALCULATE INTERACTIONS *
499 **************************/
501 /* REACTION-FIELD ELECTROSTATICS */
502 velec = qq32*(rinv32+krf*rsq32-crf);
503 felec = qq32*(rinv32*rinvsq32-krf2);
505 /* Update potential sums from outer loop */
510 /* Calculate temporary vectorial force */
515 /* Update vectorial force */
519 f[j_coord_offset+DIM*2+XX] -= tx;
520 f[j_coord_offset+DIM*2+YY] -= ty;
521 f[j_coord_offset+DIM*2+ZZ] -= tz;
523 /**************************
524 * CALCULATE INTERACTIONS *
525 **************************/
527 /* REACTION-FIELD ELECTROSTATICS */
528 velec = qq33*(rinv33+krf*rsq33-crf);
529 felec = qq33*(rinv33*rinvsq33-krf2);
531 /* Update potential sums from outer loop */
536 /* Calculate temporary vectorial force */
541 /* Update vectorial force */
545 f[j_coord_offset+DIM*3+XX] -= tx;
546 f[j_coord_offset+DIM*3+YY] -= ty;
547 f[j_coord_offset+DIM*3+ZZ] -= tz;
549 /* Inner loop uses 311 flops */
551 /* End of innermost loop */
554 f[i_coord_offset+DIM*0+XX] += fix0;
555 f[i_coord_offset+DIM*0+YY] += fiy0;
556 f[i_coord_offset+DIM*0+ZZ] += fiz0;
560 f[i_coord_offset+DIM*1+XX] += fix1;
561 f[i_coord_offset+DIM*1+YY] += fiy1;
562 f[i_coord_offset+DIM*1+ZZ] += fiz1;
566 f[i_coord_offset+DIM*2+XX] += fix2;
567 f[i_coord_offset+DIM*2+YY] += fiy2;
568 f[i_coord_offset+DIM*2+ZZ] += fiz2;
572 f[i_coord_offset+DIM*3+XX] += fix3;
573 f[i_coord_offset+DIM*3+YY] += fiy3;
574 f[i_coord_offset+DIM*3+ZZ] += fiz3;
578 fshift[i_shift_offset+XX] += tx;
579 fshift[i_shift_offset+YY] += ty;
580 fshift[i_shift_offset+ZZ] += tz;
583 /* Update potential energies */
584 kernel_data->energygrp_elec[ggid] += velecsum;
585 kernel_data->energygrp_vdw[ggid] += vvdwsum;
587 /* Increment number of inner iterations */
588 inneriter += j_index_end - j_index_start;
590 /* Outer loop uses 41 flops */
593 /* Increment number of outer iterations */
596 /* Update outer/inner flops */
598 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*41 + inneriter*311);
601 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwLJ_GeomW4W4_F_c
602 * Electrostatics interaction: ReactionField
603 * VdW interaction: LennardJones
604 * Geometry: Water4-Water4
605 * Calculate force/pot: Force
608 nb_kernel_ElecRF_VdwLJ_GeomW4W4_F_c
609 (t_nblist * gmx_restrict nlist,
610 rvec * gmx_restrict xx,
611 rvec * gmx_restrict ff,
612 t_forcerec * gmx_restrict fr,
613 t_mdatoms * gmx_restrict mdatoms,
614 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
615 t_nrnb * gmx_restrict nrnb)
617 int i_shift_offset,i_coord_offset,j_coord_offset;
618 int j_index_start,j_index_end;
619 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
620 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
621 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
622 real *shiftvec,*fshift,*x,*f;
624 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
626 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
628 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
630 real ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
632 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
634 real jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
636 real jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
638 real jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
639 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
640 real dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
641 real dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
642 real dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
643 real dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
644 real dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
645 real dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
646 real dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
647 real dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
648 real dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
649 real velec,felec,velecsum,facel,crf,krf,krf2;
652 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
661 jindex = nlist->jindex;
663 shiftidx = nlist->shift;
665 shiftvec = fr->shift_vec[0];
666 fshift = fr->fshift[0];
668 charge = mdatoms->chargeA;
672 nvdwtype = fr->ntype;
674 vdwtype = mdatoms->typeA;
676 /* Setup water-specific parameters */
677 inr = nlist->iinr[0];
678 iq1 = facel*charge[inr+1];
679 iq2 = facel*charge[inr+2];
680 iq3 = facel*charge[inr+3];
681 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
686 vdwjidx0 = 2*vdwtype[inr+0];
687 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
688 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
702 /* Start outer loop over neighborlists */
703 for(iidx=0; iidx<nri; iidx++)
705 /* Load shift vector for this list */
706 i_shift_offset = DIM*shiftidx[iidx];
707 shX = shiftvec[i_shift_offset+XX];
708 shY = shiftvec[i_shift_offset+YY];
709 shZ = shiftvec[i_shift_offset+ZZ];
711 /* Load limits for loop over neighbors */
712 j_index_start = jindex[iidx];
713 j_index_end = jindex[iidx+1];
715 /* Get outer coordinate index */
717 i_coord_offset = DIM*inr;
719 /* Load i particle coords and add shift vector */
720 ix0 = shX + x[i_coord_offset+DIM*0+XX];
721 iy0 = shY + x[i_coord_offset+DIM*0+YY];
722 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
723 ix1 = shX + x[i_coord_offset+DIM*1+XX];
724 iy1 = shY + x[i_coord_offset+DIM*1+YY];
725 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
726 ix2 = shX + x[i_coord_offset+DIM*2+XX];
727 iy2 = shY + x[i_coord_offset+DIM*2+YY];
728 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
729 ix3 = shX + x[i_coord_offset+DIM*3+XX];
730 iy3 = shY + x[i_coord_offset+DIM*3+YY];
731 iz3 = shZ + x[i_coord_offset+DIM*3+ZZ];
746 /* Start inner kernel loop */
747 for(jidx=j_index_start; jidx<j_index_end; jidx++)
749 /* Get j neighbor index, and coordinate index */
751 j_coord_offset = DIM*jnr;
753 /* load j atom coordinates */
754 jx0 = x[j_coord_offset+DIM*0+XX];
755 jy0 = x[j_coord_offset+DIM*0+YY];
756 jz0 = x[j_coord_offset+DIM*0+ZZ];
757 jx1 = x[j_coord_offset+DIM*1+XX];
758 jy1 = x[j_coord_offset+DIM*1+YY];
759 jz1 = x[j_coord_offset+DIM*1+ZZ];
760 jx2 = x[j_coord_offset+DIM*2+XX];
761 jy2 = x[j_coord_offset+DIM*2+YY];
762 jz2 = x[j_coord_offset+DIM*2+ZZ];
763 jx3 = x[j_coord_offset+DIM*3+XX];
764 jy3 = x[j_coord_offset+DIM*3+YY];
765 jz3 = x[j_coord_offset+DIM*3+ZZ];
767 /* Calculate displacement vector */
799 /* Calculate squared distance and things based on it */
800 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
801 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
802 rsq12 = dx12*dx12+dy12*dy12+dz12*dz12;
803 rsq13 = dx13*dx13+dy13*dy13+dz13*dz13;
804 rsq21 = dx21*dx21+dy21*dy21+dz21*dz21;
805 rsq22 = dx22*dx22+dy22*dy22+dz22*dz22;
806 rsq23 = dx23*dx23+dy23*dy23+dz23*dz23;
807 rsq31 = dx31*dx31+dy31*dy31+dz31*dz31;
808 rsq32 = dx32*dx32+dy32*dy32+dz32*dz32;
809 rsq33 = dx33*dx33+dy33*dy33+dz33*dz33;
811 rinv11 = gmx_invsqrt(rsq11);
812 rinv12 = gmx_invsqrt(rsq12);
813 rinv13 = gmx_invsqrt(rsq13);
814 rinv21 = gmx_invsqrt(rsq21);
815 rinv22 = gmx_invsqrt(rsq22);
816 rinv23 = gmx_invsqrt(rsq23);
817 rinv31 = gmx_invsqrt(rsq31);
818 rinv32 = gmx_invsqrt(rsq32);
819 rinv33 = gmx_invsqrt(rsq33);
821 rinvsq00 = 1.0/rsq00;
822 rinvsq11 = rinv11*rinv11;
823 rinvsq12 = rinv12*rinv12;
824 rinvsq13 = rinv13*rinv13;
825 rinvsq21 = rinv21*rinv21;
826 rinvsq22 = rinv22*rinv22;
827 rinvsq23 = rinv23*rinv23;
828 rinvsq31 = rinv31*rinv31;
829 rinvsq32 = rinv32*rinv32;
830 rinvsq33 = rinv33*rinv33;
832 /**************************
833 * CALCULATE INTERACTIONS *
834 **************************/
836 /* LENNARD-JONES DISPERSION/REPULSION */
838 rinvsix = rinvsq00*rinvsq00*rinvsq00;
839 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
843 /* Calculate temporary vectorial force */
848 /* Update vectorial force */
852 f[j_coord_offset+DIM*0+XX] -= tx;
853 f[j_coord_offset+DIM*0+YY] -= ty;
854 f[j_coord_offset+DIM*0+ZZ] -= tz;
856 /**************************
857 * CALCULATE INTERACTIONS *
858 **************************/
860 /* REACTION-FIELD ELECTROSTATICS */
861 felec = qq11*(rinv11*rinvsq11-krf2);
865 /* Calculate temporary vectorial force */
870 /* Update vectorial force */
874 f[j_coord_offset+DIM*1+XX] -= tx;
875 f[j_coord_offset+DIM*1+YY] -= ty;
876 f[j_coord_offset+DIM*1+ZZ] -= tz;
878 /**************************
879 * CALCULATE INTERACTIONS *
880 **************************/
882 /* REACTION-FIELD ELECTROSTATICS */
883 felec = qq12*(rinv12*rinvsq12-krf2);
887 /* Calculate temporary vectorial force */
892 /* Update vectorial force */
896 f[j_coord_offset+DIM*2+XX] -= tx;
897 f[j_coord_offset+DIM*2+YY] -= ty;
898 f[j_coord_offset+DIM*2+ZZ] -= tz;
900 /**************************
901 * CALCULATE INTERACTIONS *
902 **************************/
904 /* REACTION-FIELD ELECTROSTATICS */
905 felec = qq13*(rinv13*rinvsq13-krf2);
909 /* Calculate temporary vectorial force */
914 /* Update vectorial force */
918 f[j_coord_offset+DIM*3+XX] -= tx;
919 f[j_coord_offset+DIM*3+YY] -= ty;
920 f[j_coord_offset+DIM*3+ZZ] -= tz;
922 /**************************
923 * CALCULATE INTERACTIONS *
924 **************************/
926 /* REACTION-FIELD ELECTROSTATICS */
927 felec = qq21*(rinv21*rinvsq21-krf2);
931 /* Calculate temporary vectorial force */
936 /* Update vectorial force */
940 f[j_coord_offset+DIM*1+XX] -= tx;
941 f[j_coord_offset+DIM*1+YY] -= ty;
942 f[j_coord_offset+DIM*1+ZZ] -= tz;
944 /**************************
945 * CALCULATE INTERACTIONS *
946 **************************/
948 /* REACTION-FIELD ELECTROSTATICS */
949 felec = qq22*(rinv22*rinvsq22-krf2);
953 /* Calculate temporary vectorial force */
958 /* Update vectorial force */
962 f[j_coord_offset+DIM*2+XX] -= tx;
963 f[j_coord_offset+DIM*2+YY] -= ty;
964 f[j_coord_offset+DIM*2+ZZ] -= tz;
966 /**************************
967 * CALCULATE INTERACTIONS *
968 **************************/
970 /* REACTION-FIELD ELECTROSTATICS */
971 felec = qq23*(rinv23*rinvsq23-krf2);
975 /* Calculate temporary vectorial force */
980 /* Update vectorial force */
984 f[j_coord_offset+DIM*3+XX] -= tx;
985 f[j_coord_offset+DIM*3+YY] -= ty;
986 f[j_coord_offset+DIM*3+ZZ] -= tz;
988 /**************************
989 * CALCULATE INTERACTIONS *
990 **************************/
992 /* REACTION-FIELD ELECTROSTATICS */
993 felec = qq31*(rinv31*rinvsq31-krf2);
997 /* Calculate temporary vectorial force */
1002 /* Update vectorial force */
1006 f[j_coord_offset+DIM*1+XX] -= tx;
1007 f[j_coord_offset+DIM*1+YY] -= ty;
1008 f[j_coord_offset+DIM*1+ZZ] -= tz;
1010 /**************************
1011 * CALCULATE INTERACTIONS *
1012 **************************/
1014 /* REACTION-FIELD ELECTROSTATICS */
1015 felec = qq32*(rinv32*rinvsq32-krf2);
1019 /* Calculate temporary vectorial force */
1024 /* Update vectorial force */
1028 f[j_coord_offset+DIM*2+XX] -= tx;
1029 f[j_coord_offset+DIM*2+YY] -= ty;
1030 f[j_coord_offset+DIM*2+ZZ] -= tz;
1032 /**************************
1033 * CALCULATE INTERACTIONS *
1034 **************************/
1036 /* REACTION-FIELD ELECTROSTATICS */
1037 felec = qq33*(rinv33*rinvsq33-krf2);
1041 /* Calculate temporary vectorial force */
1046 /* Update vectorial force */
1050 f[j_coord_offset+DIM*3+XX] -= tx;
1051 f[j_coord_offset+DIM*3+YY] -= ty;
1052 f[j_coord_offset+DIM*3+ZZ] -= tz;
1054 /* Inner loop uses 261 flops */
1056 /* End of innermost loop */
1059 f[i_coord_offset+DIM*0+XX] += fix0;
1060 f[i_coord_offset+DIM*0+YY] += fiy0;
1061 f[i_coord_offset+DIM*0+ZZ] += fiz0;
1065 f[i_coord_offset+DIM*1+XX] += fix1;
1066 f[i_coord_offset+DIM*1+YY] += fiy1;
1067 f[i_coord_offset+DIM*1+ZZ] += fiz1;
1071 f[i_coord_offset+DIM*2+XX] += fix2;
1072 f[i_coord_offset+DIM*2+YY] += fiy2;
1073 f[i_coord_offset+DIM*2+ZZ] += fiz2;
1077 f[i_coord_offset+DIM*3+XX] += fix3;
1078 f[i_coord_offset+DIM*3+YY] += fiy3;
1079 f[i_coord_offset+DIM*3+ZZ] += fiz3;
1083 fshift[i_shift_offset+XX] += tx;
1084 fshift[i_shift_offset+YY] += ty;
1085 fshift[i_shift_offset+ZZ] += tz;
1087 /* Increment number of inner iterations */
1088 inneriter += j_index_end - j_index_start;
1090 /* Outer loop uses 39 flops */
1093 /* Increment number of outer iterations */
1096 /* Update outer/inner flops */
1098 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*39 + inneriter*261);