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 "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
48 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwNone_GeomW3P1_VF_c
49 * Electrostatics interaction: ReactionField
50 * VdW interaction: None
51 * Geometry: Water3-Particle
52 * Calculate force/pot: PotentialAndForce
55 nb_kernel_ElecRFCut_VdwNone_GeomW3P1_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 jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
78 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
79 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
80 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
81 real velec,felec,velecsum,facel,crf,krf,krf2;
89 jindex = nlist->jindex;
91 shiftidx = nlist->shift;
93 shiftvec = fr->shift_vec[0];
94 fshift = fr->fshift[0];
96 charge = mdatoms->chargeA;
101 /* Setup water-specific parameters */
102 inr = nlist->iinr[0];
103 iq0 = facel*charge[inr+0];
104 iq1 = facel*charge[inr+1];
105 iq2 = facel*charge[inr+2];
107 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
108 rcutoff = fr->rcoulomb;
109 rcutoff2 = rcutoff*rcutoff;
114 /* Start outer loop over neighborlists */
115 for(iidx=0; iidx<nri; iidx++)
117 /* Load shift vector for this list */
118 i_shift_offset = DIM*shiftidx[iidx];
119 shX = shiftvec[i_shift_offset+XX];
120 shY = shiftvec[i_shift_offset+YY];
121 shZ = shiftvec[i_shift_offset+ZZ];
123 /* Load limits for loop over neighbors */
124 j_index_start = jindex[iidx];
125 j_index_end = jindex[iidx+1];
127 /* Get outer coordinate index */
129 i_coord_offset = DIM*inr;
131 /* Load i particle coords and add shift vector */
132 ix0 = shX + x[i_coord_offset+DIM*0+XX];
133 iy0 = shY + x[i_coord_offset+DIM*0+YY];
134 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
135 ix1 = shX + x[i_coord_offset+DIM*1+XX];
136 iy1 = shY + x[i_coord_offset+DIM*1+YY];
137 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
138 ix2 = shX + x[i_coord_offset+DIM*2+XX];
139 iy2 = shY + x[i_coord_offset+DIM*2+YY];
140 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
152 /* Reset potential sums */
155 /* Start inner kernel loop */
156 for(jidx=j_index_start; jidx<j_index_end; jidx++)
158 /* Get j neighbor index, and coordinate index */
160 j_coord_offset = DIM*jnr;
162 /* load j atom coordinates */
163 jx0 = x[j_coord_offset+DIM*0+XX];
164 jy0 = x[j_coord_offset+DIM*0+YY];
165 jz0 = x[j_coord_offset+DIM*0+ZZ];
167 /* Calculate displacement vector */
178 /* Calculate squared distance and things based on it */
179 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
180 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
181 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
183 rinv00 = gmx_invsqrt(rsq00);
184 rinv10 = gmx_invsqrt(rsq10);
185 rinv20 = gmx_invsqrt(rsq20);
187 rinvsq00 = rinv00*rinv00;
188 rinvsq10 = rinv10*rinv10;
189 rinvsq20 = rinv20*rinv20;
191 /* Load parameters for j particles */
194 /**************************
195 * CALCULATE INTERACTIONS *
196 **************************/
203 /* REACTION-FIELD ELECTROSTATICS */
204 velec = qq00*(rinv00+krf*rsq00-crf);
205 felec = qq00*(rinv00*rinvsq00-krf2);
207 /* 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;
227 /**************************
228 * CALCULATE INTERACTIONS *
229 **************************/
236 /* REACTION-FIELD ELECTROSTATICS */
237 velec = qq10*(rinv10+krf*rsq10-crf);
238 felec = qq10*(rinv10*rinvsq10-krf2);
240 /* Update potential sums from outer loop */
245 /* Calculate temporary vectorial force */
250 /* Update vectorial force */
254 f[j_coord_offset+DIM*0+XX] -= tx;
255 f[j_coord_offset+DIM*0+YY] -= ty;
256 f[j_coord_offset+DIM*0+ZZ] -= tz;
260 /**************************
261 * CALCULATE INTERACTIONS *
262 **************************/
269 /* REACTION-FIELD ELECTROSTATICS */
270 velec = qq20*(rinv20+krf*rsq20-crf);
271 felec = qq20*(rinv20*rinvsq20-krf2);
273 /* Update potential sums from outer loop */
278 /* Calculate temporary vectorial force */
283 /* Update vectorial force */
287 f[j_coord_offset+DIM*0+XX] -= tx;
288 f[j_coord_offset+DIM*0+YY] -= ty;
289 f[j_coord_offset+DIM*0+ZZ] -= tz;
293 /* Inner loop uses 96 flops */
295 /* End of innermost loop */
298 f[i_coord_offset+DIM*0+XX] += fix0;
299 f[i_coord_offset+DIM*0+YY] += fiy0;
300 f[i_coord_offset+DIM*0+ZZ] += fiz0;
304 f[i_coord_offset+DIM*1+XX] += fix1;
305 f[i_coord_offset+DIM*1+YY] += fiy1;
306 f[i_coord_offset+DIM*1+ZZ] += fiz1;
310 f[i_coord_offset+DIM*2+XX] += fix2;
311 f[i_coord_offset+DIM*2+YY] += fiy2;
312 f[i_coord_offset+DIM*2+ZZ] += fiz2;
316 fshift[i_shift_offset+XX] += tx;
317 fshift[i_shift_offset+YY] += ty;
318 fshift[i_shift_offset+ZZ] += tz;
321 /* Update potential energies */
322 kernel_data->energygrp_elec[ggid] += velecsum;
324 /* Increment number of inner iterations */
325 inneriter += j_index_end - j_index_start;
327 /* Outer loop uses 31 flops */
330 /* Increment number of outer iterations */
333 /* Update outer/inner flops */
335 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_VF,outeriter*31 + inneriter*96);
338 * Gromacs nonbonded kernel: nb_kernel_ElecRFCut_VdwNone_GeomW3P1_F_c
339 * Electrostatics interaction: ReactionField
340 * VdW interaction: None
341 * Geometry: Water3-Particle
342 * Calculate force/pot: Force
345 nb_kernel_ElecRFCut_VdwNone_GeomW3P1_F_c
346 (t_nblist * gmx_restrict nlist,
347 rvec * gmx_restrict xx,
348 rvec * gmx_restrict ff,
349 t_forcerec * gmx_restrict fr,
350 t_mdatoms * gmx_restrict mdatoms,
351 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
352 t_nrnb * gmx_restrict nrnb)
354 int i_shift_offset,i_coord_offset,j_coord_offset;
355 int j_index_start,j_index_end;
356 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
357 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
358 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
359 real *shiftvec,*fshift,*x,*f;
361 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
363 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
365 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
367 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
368 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
369 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
370 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
371 real velec,felec,velecsum,facel,crf,krf,krf2;
379 jindex = nlist->jindex;
381 shiftidx = nlist->shift;
383 shiftvec = fr->shift_vec[0];
384 fshift = fr->fshift[0];
386 charge = mdatoms->chargeA;
391 /* Setup water-specific parameters */
392 inr = nlist->iinr[0];
393 iq0 = facel*charge[inr+0];
394 iq1 = facel*charge[inr+1];
395 iq2 = facel*charge[inr+2];
397 /* When we use explicit cutoffs the value must be identical for elec and VdW, so use elec as an arbitrary choice */
398 rcutoff = fr->rcoulomb;
399 rcutoff2 = rcutoff*rcutoff;
404 /* Start outer loop over neighborlists */
405 for(iidx=0; iidx<nri; iidx++)
407 /* Load shift vector for this list */
408 i_shift_offset = DIM*shiftidx[iidx];
409 shX = shiftvec[i_shift_offset+XX];
410 shY = shiftvec[i_shift_offset+YY];
411 shZ = shiftvec[i_shift_offset+ZZ];
413 /* Load limits for loop over neighbors */
414 j_index_start = jindex[iidx];
415 j_index_end = jindex[iidx+1];
417 /* Get outer coordinate index */
419 i_coord_offset = DIM*inr;
421 /* Load i particle coords and add shift vector */
422 ix0 = shX + x[i_coord_offset+DIM*0+XX];
423 iy0 = shY + x[i_coord_offset+DIM*0+YY];
424 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
425 ix1 = shX + x[i_coord_offset+DIM*1+XX];
426 iy1 = shY + x[i_coord_offset+DIM*1+YY];
427 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
428 ix2 = shX + x[i_coord_offset+DIM*2+XX];
429 iy2 = shY + x[i_coord_offset+DIM*2+YY];
430 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
442 /* Start inner kernel loop */
443 for(jidx=j_index_start; jidx<j_index_end; jidx++)
445 /* Get j neighbor index, and coordinate index */
447 j_coord_offset = DIM*jnr;
449 /* load j atom coordinates */
450 jx0 = x[j_coord_offset+DIM*0+XX];
451 jy0 = x[j_coord_offset+DIM*0+YY];
452 jz0 = x[j_coord_offset+DIM*0+ZZ];
454 /* Calculate displacement vector */
465 /* Calculate squared distance and things based on it */
466 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
467 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
468 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
470 rinv00 = gmx_invsqrt(rsq00);
471 rinv10 = gmx_invsqrt(rsq10);
472 rinv20 = gmx_invsqrt(rsq20);
474 rinvsq00 = rinv00*rinv00;
475 rinvsq10 = rinv10*rinv10;
476 rinvsq20 = rinv20*rinv20;
478 /* Load parameters for j particles */
481 /**************************
482 * CALCULATE INTERACTIONS *
483 **************************/
490 /* REACTION-FIELD ELECTROSTATICS */
491 felec = qq00*(rinv00*rinvsq00-krf2);
495 /* Calculate temporary vectorial force */
500 /* Update vectorial force */
504 f[j_coord_offset+DIM*0+XX] -= tx;
505 f[j_coord_offset+DIM*0+YY] -= ty;
506 f[j_coord_offset+DIM*0+ZZ] -= tz;
510 /**************************
511 * CALCULATE INTERACTIONS *
512 **************************/
519 /* REACTION-FIELD ELECTROSTATICS */
520 felec = qq10*(rinv10*rinvsq10-krf2);
524 /* Calculate temporary vectorial force */
529 /* Update vectorial force */
533 f[j_coord_offset+DIM*0+XX] -= tx;
534 f[j_coord_offset+DIM*0+YY] -= ty;
535 f[j_coord_offset+DIM*0+ZZ] -= tz;
539 /**************************
540 * CALCULATE INTERACTIONS *
541 **************************/
548 /* REACTION-FIELD ELECTROSTATICS */
549 felec = qq20*(rinv20*rinvsq20-krf2);
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;
568 /* Inner loop uses 81 flops */
570 /* End of innermost loop */
573 f[i_coord_offset+DIM*0+XX] += fix0;
574 f[i_coord_offset+DIM*0+YY] += fiy0;
575 f[i_coord_offset+DIM*0+ZZ] += fiz0;
579 f[i_coord_offset+DIM*1+XX] += fix1;
580 f[i_coord_offset+DIM*1+YY] += fiy1;
581 f[i_coord_offset+DIM*1+ZZ] += fiz1;
585 f[i_coord_offset+DIM*2+XX] += fix2;
586 f[i_coord_offset+DIM*2+YY] += fiy2;
587 f[i_coord_offset+DIM*2+ZZ] += fiz2;
591 fshift[i_shift_offset+XX] += tx;
592 fshift[i_shift_offset+YY] += ty;
593 fshift[i_shift_offset+ZZ] += tz;
595 /* Increment number of inner iterations */
596 inneriter += j_index_end - j_index_start;
598 /* Outer loop uses 30 flops */
601 /* Increment number of outer iterations */
604 /* Update outer/inner flops */
606 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_F,outeriter*30 + inneriter*81);