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_VdwNone_GeomW3P1_VF_c
51 * Electrostatics interaction: ReactionField
52 * VdW interaction: None
53 * Geometry: Water3-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecRFCut_VdwNone_GeomW3P1_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 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 velec,felec,velecsum,facel,crf,krf,krf2;
91 jindex = nlist->jindex;
93 shiftidx = nlist->shift;
95 shiftvec = fr->shift_vec[0];
96 fshift = fr->fshift[0];
98 charge = mdatoms->chargeA;
103 /* Setup water-specific parameters */
104 inr = nlist->iinr[0];
105 iq0 = facel*charge[inr+0];
106 iq1 = facel*charge[inr+1];
107 iq2 = facel*charge[inr+2];
109 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
110 rcutoff = fr->rcoulomb;
111 rcutoff2 = rcutoff*rcutoff;
116 /* Start outer loop over neighborlists */
117 for(iidx=0; iidx<nri; iidx++)
119 /* Load shift vector for this list */
120 i_shift_offset = DIM*shiftidx[iidx];
121 shX = shiftvec[i_shift_offset+XX];
122 shY = shiftvec[i_shift_offset+YY];
123 shZ = shiftvec[i_shift_offset+ZZ];
125 /* Load limits for loop over neighbors */
126 j_index_start = jindex[iidx];
127 j_index_end = jindex[iidx+1];
129 /* Get outer coordinate index */
131 i_coord_offset = DIM*inr;
133 /* Load i particle coords and add shift vector */
134 ix0 = shX + x[i_coord_offset+DIM*0+XX];
135 iy0 = shY + x[i_coord_offset+DIM*0+YY];
136 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
137 ix1 = shX + x[i_coord_offset+DIM*1+XX];
138 iy1 = shY + x[i_coord_offset+DIM*1+YY];
139 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
140 ix2 = shX + x[i_coord_offset+DIM*2+XX];
141 iy2 = shY + x[i_coord_offset+DIM*2+YY];
142 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
154 /* Reset potential sums */
157 /* Start inner kernel loop */
158 for(jidx=j_index_start; jidx<j_index_end; jidx++)
160 /* Get j neighbor index, and coordinate index */
162 j_coord_offset = DIM*jnr;
164 /* load j atom coordinates */
165 jx0 = x[j_coord_offset+DIM*0+XX];
166 jy0 = x[j_coord_offset+DIM*0+YY];
167 jz0 = x[j_coord_offset+DIM*0+ZZ];
169 /* Calculate displacement vector */
180 /* Calculate squared distance and things based on it */
181 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
182 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
183 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
185 rinv00 = gmx_invsqrt(rsq00);
186 rinv10 = gmx_invsqrt(rsq10);
187 rinv20 = gmx_invsqrt(rsq20);
189 rinvsq00 = rinv00*rinv00;
190 rinvsq10 = rinv10*rinv10;
191 rinvsq20 = rinv20*rinv20;
193 /* Load parameters for j particles */
196 /**************************
197 * CALCULATE INTERACTIONS *
198 **************************/
205 /* REACTION-FIELD ELECTROSTATICS */
206 velec = qq00*(rinv00+krf*rsq00-crf);
207 felec = qq00*(rinv00*rinvsq00-krf2);
209 /* Update potential sums from outer loop */
214 /* Calculate temporary vectorial force */
219 /* Update vectorial force */
223 f[j_coord_offset+DIM*0+XX] -= tx;
224 f[j_coord_offset+DIM*0+YY] -= ty;
225 f[j_coord_offset+DIM*0+ZZ] -= tz;
229 /**************************
230 * CALCULATE INTERACTIONS *
231 **************************/
238 /* REACTION-FIELD ELECTROSTATICS */
239 velec = qq10*(rinv10+krf*rsq10-crf);
240 felec = qq10*(rinv10*rinvsq10-krf2);
242 /* Update potential sums from outer loop */
247 /* Calculate temporary vectorial force */
252 /* Update vectorial force */
256 f[j_coord_offset+DIM*0+XX] -= tx;
257 f[j_coord_offset+DIM*0+YY] -= ty;
258 f[j_coord_offset+DIM*0+ZZ] -= tz;
262 /**************************
263 * CALCULATE INTERACTIONS *
264 **************************/
271 /* REACTION-FIELD ELECTROSTATICS */
272 velec = qq20*(rinv20+krf*rsq20-crf);
273 felec = qq20*(rinv20*rinvsq20-krf2);
275 /* Update potential sums from outer loop */
280 /* Calculate temporary vectorial force */
285 /* Update vectorial force */
289 f[j_coord_offset+DIM*0+XX] -= tx;
290 f[j_coord_offset+DIM*0+YY] -= ty;
291 f[j_coord_offset+DIM*0+ZZ] -= tz;
295 /* Inner loop uses 96 flops */
297 /* End of innermost loop */
300 f[i_coord_offset+DIM*0+XX] += fix0;
301 f[i_coord_offset+DIM*0+YY] += fiy0;
302 f[i_coord_offset+DIM*0+ZZ] += fiz0;
306 f[i_coord_offset+DIM*1+XX] += fix1;
307 f[i_coord_offset+DIM*1+YY] += fiy1;
308 f[i_coord_offset+DIM*1+ZZ] += fiz1;
312 f[i_coord_offset+DIM*2+XX] += fix2;
313 f[i_coord_offset+DIM*2+YY] += fiy2;
314 f[i_coord_offset+DIM*2+ZZ] += fiz2;
318 fshift[i_shift_offset+XX] += tx;
319 fshift[i_shift_offset+YY] += ty;
320 fshift[i_shift_offset+ZZ] += tz;
323 /* Update potential energies */
324 kernel_data->energygrp_elec[ggid] += velecsum;
326 /* Increment number of inner iterations */
327 inneriter += j_index_end - j_index_start;
329 /* Outer loop uses 31 flops */
332 /* Increment number of outer iterations */
335 /* Update outer/inner flops */
337 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_VF,outeriter*31 + inneriter*96);
340 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwNone_GeomW3P1_F_c
341 * Electrostatics interaction: ReactionField
342 * VdW interaction: None
343 * Geometry: Water3-Particle
344 * Calculate force/pot: Force
347 nb_kernel_ElecRFCut_VdwNone_GeomW3P1_F_c
348 (t_nblist * gmx_restrict nlist,
349 rvec * gmx_restrict xx,
350 rvec * gmx_restrict ff,
351 t_forcerec * gmx_restrict fr,
352 t_mdatoms * gmx_restrict mdatoms,
353 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
354 t_nrnb * gmx_restrict nrnb)
356 int i_shift_offset,i_coord_offset,j_coord_offset;
357 int j_index_start,j_index_end;
358 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
359 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
360 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
361 real *shiftvec,*fshift,*x,*f;
363 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
365 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
367 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
369 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
370 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
371 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
372 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
373 real velec,felec,velecsum,facel,crf,krf,krf2;
381 jindex = nlist->jindex;
383 shiftidx = nlist->shift;
385 shiftvec = fr->shift_vec[0];
386 fshift = fr->fshift[0];
388 charge = mdatoms->chargeA;
393 /* Setup water-specific parameters */
394 inr = nlist->iinr[0];
395 iq0 = facel*charge[inr+0];
396 iq1 = facel*charge[inr+1];
397 iq2 = facel*charge[inr+2];
399 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
400 rcutoff = fr->rcoulomb;
401 rcutoff2 = rcutoff*rcutoff;
406 /* Start outer loop over neighborlists */
407 for(iidx=0; iidx<nri; iidx++)
409 /* Load shift vector for this list */
410 i_shift_offset = DIM*shiftidx[iidx];
411 shX = shiftvec[i_shift_offset+XX];
412 shY = shiftvec[i_shift_offset+YY];
413 shZ = shiftvec[i_shift_offset+ZZ];
415 /* Load limits for loop over neighbors */
416 j_index_start = jindex[iidx];
417 j_index_end = jindex[iidx+1];
419 /* Get outer coordinate index */
421 i_coord_offset = DIM*inr;
423 /* Load i particle coords and add shift vector */
424 ix0 = shX + x[i_coord_offset+DIM*0+XX];
425 iy0 = shY + x[i_coord_offset+DIM*0+YY];
426 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
427 ix1 = shX + x[i_coord_offset+DIM*1+XX];
428 iy1 = shY + x[i_coord_offset+DIM*1+YY];
429 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
430 ix2 = shX + x[i_coord_offset+DIM*2+XX];
431 iy2 = shY + x[i_coord_offset+DIM*2+YY];
432 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
444 /* Start inner kernel loop */
445 for(jidx=j_index_start; jidx<j_index_end; jidx++)
447 /* Get j neighbor index, and coordinate index */
449 j_coord_offset = DIM*jnr;
451 /* load j atom coordinates */
452 jx0 = x[j_coord_offset+DIM*0+XX];
453 jy0 = x[j_coord_offset+DIM*0+YY];
454 jz0 = x[j_coord_offset+DIM*0+ZZ];
456 /* Calculate displacement vector */
467 /* Calculate squared distance and things based on it */
468 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
469 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
470 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
472 rinv00 = gmx_invsqrt(rsq00);
473 rinv10 = gmx_invsqrt(rsq10);
474 rinv20 = gmx_invsqrt(rsq20);
476 rinvsq00 = rinv00*rinv00;
477 rinvsq10 = rinv10*rinv10;
478 rinvsq20 = rinv20*rinv20;
480 /* Load parameters for j particles */
483 /**************************
484 * CALCULATE INTERACTIONS *
485 **************************/
492 /* REACTION-FIELD ELECTROSTATICS */
493 felec = qq00*(rinv00*rinvsq00-krf2);
497 /* Calculate temporary vectorial force */
502 /* Update vectorial force */
506 f[j_coord_offset+DIM*0+XX] -= tx;
507 f[j_coord_offset+DIM*0+YY] -= ty;
508 f[j_coord_offset+DIM*0+ZZ] -= tz;
512 /**************************
513 * CALCULATE INTERACTIONS *
514 **************************/
521 /* REACTION-FIELD ELECTROSTATICS */
522 felec = qq10*(rinv10*rinvsq10-krf2);
526 /* Calculate temporary vectorial force */
531 /* Update vectorial force */
535 f[j_coord_offset+DIM*0+XX] -= tx;
536 f[j_coord_offset+DIM*0+YY] -= ty;
537 f[j_coord_offset+DIM*0+ZZ] -= tz;
541 /**************************
542 * CALCULATE INTERACTIONS *
543 **************************/
550 /* REACTION-FIELD ELECTROSTATICS */
551 felec = qq20*(rinv20*rinvsq20-krf2);
555 /* Calculate temporary vectorial force */
560 /* Update vectorial force */
564 f[j_coord_offset+DIM*0+XX] -= tx;
565 f[j_coord_offset+DIM*0+YY] -= ty;
566 f[j_coord_offset+DIM*0+ZZ] -= tz;
570 /* Inner loop uses 81 flops */
572 /* End of innermost loop */
575 f[i_coord_offset+DIM*0+XX] += fix0;
576 f[i_coord_offset+DIM*0+YY] += fiy0;
577 f[i_coord_offset+DIM*0+ZZ] += fiz0;
581 f[i_coord_offset+DIM*1+XX] += fix1;
582 f[i_coord_offset+DIM*1+YY] += fiy1;
583 f[i_coord_offset+DIM*1+ZZ] += fiz1;
587 f[i_coord_offset+DIM*2+XX] += fix2;
588 f[i_coord_offset+DIM*2+YY] += fiy2;
589 f[i_coord_offset+DIM*2+ZZ] += fiz2;
593 fshift[i_shift_offset+XX] += tx;
594 fshift[i_shift_offset+YY] += ty;
595 fshift[i_shift_offset+ZZ] += tz;
597 /* Increment number of inner iterations */
598 inneriter += j_index_end - j_index_start;
600 /* Outer loop uses 30 flops */
603 /* Increment number of outer iterations */
606 /* Update outer/inner flops */
608 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_F,outeriter*30 + inneriter*81);