2 * Note: this file was generated by the Gromacs c kernel generator.
4 * This source code is part of
8 * Copyright (c) 2001-2012, The GROMACS Development Team
10 * Gromacs is a library for molecular simulation and trajectory analysis,
11 * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for
12 * a full list of developers and information, check out http://www.gromacs.org
14 * This program is free software; you can redistribute it and/or modify it under
15 * the terms of the GNU Lesser General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at your option) any
19 * To help fund GROMACS development, we humbly ask that you cite
20 * the papers people have written on it - you can find them on the website.
28 #include "../nb_kernel.h"
29 #include "types/simple.h"
34 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwLJ_GeomW3P1_VF_c
35 * Electrostatics interaction: ReactionField
36 * VdW interaction: LennardJones
37 * Geometry: Water3-Particle
38 * Calculate force/pot: PotentialAndForce
41 nb_kernel_ElecRF_VdwLJ_GeomW3P1_VF_c
42 (t_nblist * gmx_restrict nlist,
43 rvec * gmx_restrict xx,
44 rvec * gmx_restrict ff,
45 t_forcerec * gmx_restrict fr,
46 t_mdatoms * gmx_restrict mdatoms,
47 nb_kernel_data_t * gmx_restrict kernel_data,
48 t_nrnb * gmx_restrict nrnb)
50 int i_shift_offset,i_coord_offset,j_coord_offset;
51 int j_index_start,j_index_end;
52 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
53 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
54 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
55 real *shiftvec,*fshift,*x,*f;
57 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
59 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
61 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
63 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
64 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
65 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
66 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
67 real velec,felec,velecsum,facel,crf,krf,krf2;
70 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
79 jindex = nlist->jindex;
81 shiftidx = nlist->shift;
83 shiftvec = fr->shift_vec[0];
84 fshift = fr->fshift[0];
86 charge = mdatoms->chargeA;
92 vdwtype = mdatoms->typeA;
94 /* Setup water-specific parameters */
96 iq0 = facel*charge[inr+0];
97 iq1 = facel*charge[inr+1];
98 iq2 = facel*charge[inr+2];
99 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
104 /* Start outer loop over neighborlists */
105 for(iidx=0; iidx<nri; iidx++)
107 /* Load shift vector for this list */
108 i_shift_offset = DIM*shiftidx[iidx];
109 shX = shiftvec[i_shift_offset+XX];
110 shY = shiftvec[i_shift_offset+YY];
111 shZ = shiftvec[i_shift_offset+ZZ];
113 /* Load limits for loop over neighbors */
114 j_index_start = jindex[iidx];
115 j_index_end = jindex[iidx+1];
117 /* Get outer coordinate index */
119 i_coord_offset = DIM*inr;
121 /* Load i particle coords and add shift vector */
122 ix0 = shX + x[i_coord_offset+DIM*0+XX];
123 iy0 = shY + x[i_coord_offset+DIM*0+YY];
124 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
125 ix1 = shX + x[i_coord_offset+DIM*1+XX];
126 iy1 = shY + x[i_coord_offset+DIM*1+YY];
127 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
128 ix2 = shX + x[i_coord_offset+DIM*2+XX];
129 iy2 = shY + x[i_coord_offset+DIM*2+YY];
130 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
142 /* Reset potential sums */
146 /* Start inner kernel loop */
147 for(jidx=j_index_start; jidx<j_index_end; jidx++)
149 /* Get j neighbor index, and coordinate index */
151 j_coord_offset = DIM*jnr;
153 /* load j atom coordinates */
154 jx0 = x[j_coord_offset+DIM*0+XX];
155 jy0 = x[j_coord_offset+DIM*0+YY];
156 jz0 = x[j_coord_offset+DIM*0+ZZ];
158 /* Calculate displacement vector */
169 /* Calculate squared distance and things based on it */
170 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
171 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
172 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
174 rinv00 = gmx_invsqrt(rsq00);
175 rinv10 = gmx_invsqrt(rsq10);
176 rinv20 = gmx_invsqrt(rsq20);
178 rinvsq00 = rinv00*rinv00;
179 rinvsq10 = rinv10*rinv10;
180 rinvsq20 = rinv20*rinv20;
182 /* Load parameters for j particles */
184 vdwjidx0 = 2*vdwtype[jnr+0];
186 /**************************
187 * CALCULATE INTERACTIONS *
188 **************************/
191 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
192 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
194 /* REACTION-FIELD ELECTROSTATICS */
195 velec = qq00*(rinv00+krf*rsq00-crf);
196 felec = qq00*(rinv00*rinvsq00-krf2);
198 /* LENNARD-JONES DISPERSION/REPULSION */
200 rinvsix = rinvsq00*rinvsq00*rinvsq00;
201 vvdw6 = c6_00*rinvsix;
202 vvdw12 = c12_00*rinvsix*rinvsix;
203 vvdw = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
204 fvdw = (vvdw12-vvdw6)*rinvsq00;
206 /* Update potential sums from outer loop */
212 /* Calculate temporary vectorial force */
217 /* Update vectorial force */
221 f[j_coord_offset+DIM*0+XX] -= tx;
222 f[j_coord_offset+DIM*0+YY] -= ty;
223 f[j_coord_offset+DIM*0+ZZ] -= tz;
225 /**************************
226 * CALCULATE INTERACTIONS *
227 **************************/
231 /* REACTION-FIELD ELECTROSTATICS */
232 velec = qq10*(rinv10+krf*rsq10-crf);
233 felec = qq10*(rinv10*rinvsq10-krf2);
235 /* Update potential sums from outer loop */
240 /* Calculate temporary vectorial force */
245 /* Update vectorial force */
249 f[j_coord_offset+DIM*0+XX] -= tx;
250 f[j_coord_offset+DIM*0+YY] -= ty;
251 f[j_coord_offset+DIM*0+ZZ] -= tz;
253 /**************************
254 * CALCULATE INTERACTIONS *
255 **************************/
259 /* REACTION-FIELD ELECTROSTATICS */
260 velec = qq20*(rinv20+krf*rsq20-crf);
261 felec = qq20*(rinv20*rinvsq20-krf2);
263 /* Update potential sums from outer loop */
268 /* Calculate temporary vectorial force */
273 /* Update vectorial force */
277 f[j_coord_offset+DIM*0+XX] -= tx;
278 f[j_coord_offset+DIM*0+YY] -= ty;
279 f[j_coord_offset+DIM*0+ZZ] -= tz;
281 /* Inner loop uses 108 flops */
283 /* End of innermost loop */
286 f[i_coord_offset+DIM*0+XX] += fix0;
287 f[i_coord_offset+DIM*0+YY] += fiy0;
288 f[i_coord_offset+DIM*0+ZZ] += fiz0;
292 f[i_coord_offset+DIM*1+XX] += fix1;
293 f[i_coord_offset+DIM*1+YY] += fiy1;
294 f[i_coord_offset+DIM*1+ZZ] += fiz1;
298 f[i_coord_offset+DIM*2+XX] += fix2;
299 f[i_coord_offset+DIM*2+YY] += fiy2;
300 f[i_coord_offset+DIM*2+ZZ] += fiz2;
304 fshift[i_shift_offset+XX] += tx;
305 fshift[i_shift_offset+YY] += ty;
306 fshift[i_shift_offset+ZZ] += tz;
309 /* Update potential energies */
310 kernel_data->energygrp_elec[ggid] += velecsum;
311 kernel_data->energygrp_vdw[ggid] += vvdwsum;
313 /* Increment number of inner iterations */
314 inneriter += j_index_end - j_index_start;
316 /* Outer loop uses 32 flops */
319 /* Increment number of outer iterations */
322 /* Update outer/inner flops */
324 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_VF,outeriter*32 + inneriter*108);
327 * Gromacs nonbonded kernel: nb_kernel_ElecRF_VdwLJ_GeomW3P1_F_c
328 * Electrostatics interaction: ReactionField
329 * VdW interaction: LennardJones
330 * Geometry: Water3-Particle
331 * Calculate force/pot: Force
334 nb_kernel_ElecRF_VdwLJ_GeomW3P1_F_c
335 (t_nblist * gmx_restrict nlist,
336 rvec * gmx_restrict xx,
337 rvec * gmx_restrict ff,
338 t_forcerec * gmx_restrict fr,
339 t_mdatoms * gmx_restrict mdatoms,
340 nb_kernel_data_t * gmx_restrict kernel_data,
341 t_nrnb * gmx_restrict nrnb)
343 int i_shift_offset,i_coord_offset,j_coord_offset;
344 int j_index_start,j_index_end;
345 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
346 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
347 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
348 real *shiftvec,*fshift,*x,*f;
350 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
352 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
354 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
356 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
357 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
358 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
359 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
360 real velec,felec,velecsum,facel,crf,krf,krf2;
363 real rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
372 jindex = nlist->jindex;
374 shiftidx = nlist->shift;
376 shiftvec = fr->shift_vec[0];
377 fshift = fr->fshift[0];
379 charge = mdatoms->chargeA;
383 nvdwtype = fr->ntype;
385 vdwtype = mdatoms->typeA;
387 /* Setup water-specific parameters */
388 inr = nlist->iinr[0];
389 iq0 = facel*charge[inr+0];
390 iq1 = facel*charge[inr+1];
391 iq2 = facel*charge[inr+2];
392 vdwioffset0 = 2*nvdwtype*vdwtype[inr+0];
397 /* Start outer loop over neighborlists */
398 for(iidx=0; iidx<nri; iidx++)
400 /* Load shift vector for this list */
401 i_shift_offset = DIM*shiftidx[iidx];
402 shX = shiftvec[i_shift_offset+XX];
403 shY = shiftvec[i_shift_offset+YY];
404 shZ = shiftvec[i_shift_offset+ZZ];
406 /* Load limits for loop over neighbors */
407 j_index_start = jindex[iidx];
408 j_index_end = jindex[iidx+1];
410 /* Get outer coordinate index */
412 i_coord_offset = DIM*inr;
414 /* Load i particle coords and add shift vector */
415 ix0 = shX + x[i_coord_offset+DIM*0+XX];
416 iy0 = shY + x[i_coord_offset+DIM*0+YY];
417 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
418 ix1 = shX + x[i_coord_offset+DIM*1+XX];
419 iy1 = shY + x[i_coord_offset+DIM*1+YY];
420 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
421 ix2 = shX + x[i_coord_offset+DIM*2+XX];
422 iy2 = shY + x[i_coord_offset+DIM*2+YY];
423 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
435 /* Start inner kernel loop */
436 for(jidx=j_index_start; jidx<j_index_end; jidx++)
438 /* Get j neighbor index, and coordinate index */
440 j_coord_offset = DIM*jnr;
442 /* load j atom coordinates */
443 jx0 = x[j_coord_offset+DIM*0+XX];
444 jy0 = x[j_coord_offset+DIM*0+YY];
445 jz0 = x[j_coord_offset+DIM*0+ZZ];
447 /* Calculate displacement vector */
458 /* Calculate squared distance and things based on it */
459 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
460 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
461 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
463 rinv00 = gmx_invsqrt(rsq00);
464 rinv10 = gmx_invsqrt(rsq10);
465 rinv20 = gmx_invsqrt(rsq20);
467 rinvsq00 = rinv00*rinv00;
468 rinvsq10 = rinv10*rinv10;
469 rinvsq20 = rinv20*rinv20;
471 /* Load parameters for j particles */
473 vdwjidx0 = 2*vdwtype[jnr+0];
475 /**************************
476 * CALCULATE INTERACTIONS *
477 **************************/
480 c6_00 = vdwparam[vdwioffset0+vdwjidx0];
481 c12_00 = vdwparam[vdwioffset0+vdwjidx0+1];
483 /* REACTION-FIELD ELECTROSTATICS */
484 felec = qq00*(rinv00*rinvsq00-krf2);
486 /* LENNARD-JONES DISPERSION/REPULSION */
488 rinvsix = rinvsq00*rinvsq00*rinvsq00;
489 fvdw = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
493 /* Calculate temporary vectorial force */
498 /* Update vectorial force */
502 f[j_coord_offset+DIM*0+XX] -= tx;
503 f[j_coord_offset+DIM*0+YY] -= ty;
504 f[j_coord_offset+DIM*0+ZZ] -= tz;
506 /**************************
507 * CALCULATE INTERACTIONS *
508 **************************/
512 /* REACTION-FIELD ELECTROSTATICS */
513 felec = qq10*(rinv10*rinvsq10-krf2);
517 /* Calculate temporary vectorial force */
522 /* Update vectorial force */
526 f[j_coord_offset+DIM*0+XX] -= tx;
527 f[j_coord_offset+DIM*0+YY] -= ty;
528 f[j_coord_offset+DIM*0+ZZ] -= tz;
530 /**************************
531 * CALCULATE INTERACTIONS *
532 **************************/
536 /* REACTION-FIELD ELECTROSTATICS */
537 felec = qq20*(rinv20*rinvsq20-krf2);
541 /* Calculate temporary vectorial force */
546 /* Update vectorial force */
550 f[j_coord_offset+DIM*0+XX] -= tx;
551 f[j_coord_offset+DIM*0+YY] -= ty;
552 f[j_coord_offset+DIM*0+ZZ] -= tz;
554 /* Inner loop uses 88 flops */
556 /* End of innermost loop */
559 f[i_coord_offset+DIM*0+XX] += fix0;
560 f[i_coord_offset+DIM*0+YY] += fiy0;
561 f[i_coord_offset+DIM*0+ZZ] += fiz0;
565 f[i_coord_offset+DIM*1+XX] += fix1;
566 f[i_coord_offset+DIM*1+YY] += fiy1;
567 f[i_coord_offset+DIM*1+ZZ] += fiz1;
571 f[i_coord_offset+DIM*2+XX] += fix2;
572 f[i_coord_offset+DIM*2+YY] += fiy2;
573 f[i_coord_offset+DIM*2+ZZ] += fiz2;
577 fshift[i_shift_offset+XX] += tx;
578 fshift[i_shift_offset+YY] += ty;
579 fshift[i_shift_offset+ZZ] += tz;
581 /* Increment number of inner iterations */
582 inneriter += j_index_end - j_index_start;
584 /* Outer loop uses 30 flops */
587 /* Increment number of outer iterations */
590 /* Update outer/inner flops */
592 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W3_F,outeriter*30 + inneriter*88);