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_ElecCoul_VdwNone_GeomW3P1_VF_c
51 * Electrostatics interaction: Coulomb
52 * VdW interaction: None
53 * Geometry: Water3-Particle
54 * Calculate force/pot: PotentialAndForce
57 nb_kernel_ElecCoul_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;
100 /* Setup water-specific parameters */
101 inr = nlist->iinr[0];
102 iq0 = facel*charge[inr+0];
103 iq1 = facel*charge[inr+1];
104 iq2 = facel*charge[inr+2];
109 /* Start outer loop over neighborlists */
110 for(iidx=0; iidx<nri; iidx++)
112 /* Load shift vector for this list */
113 i_shift_offset = DIM*shiftidx[iidx];
114 shX = shiftvec[i_shift_offset+XX];
115 shY = shiftvec[i_shift_offset+YY];
116 shZ = shiftvec[i_shift_offset+ZZ];
118 /* Load limits for loop over neighbors */
119 j_index_start = jindex[iidx];
120 j_index_end = jindex[iidx+1];
122 /* Get outer coordinate index */
124 i_coord_offset = DIM*inr;
126 /* Load i particle coords and add shift vector */
127 ix0 = shX + x[i_coord_offset+DIM*0+XX];
128 iy0 = shY + x[i_coord_offset+DIM*0+YY];
129 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
130 ix1 = shX + x[i_coord_offset+DIM*1+XX];
131 iy1 = shY + x[i_coord_offset+DIM*1+YY];
132 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
133 ix2 = shX + x[i_coord_offset+DIM*2+XX];
134 iy2 = shY + x[i_coord_offset+DIM*2+YY];
135 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
147 /* Reset potential sums */
150 /* Start inner kernel loop */
151 for(jidx=j_index_start; jidx<j_index_end; jidx++)
153 /* Get j neighbor index, and coordinate index */
155 j_coord_offset = DIM*jnr;
157 /* load j atom coordinates */
158 jx0 = x[j_coord_offset+DIM*0+XX];
159 jy0 = x[j_coord_offset+DIM*0+YY];
160 jz0 = x[j_coord_offset+DIM*0+ZZ];
162 /* Calculate displacement vector */
173 /* Calculate squared distance and things based on it */
174 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
175 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
176 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
178 rinv00 = gmx_invsqrt(rsq00);
179 rinv10 = gmx_invsqrt(rsq10);
180 rinv20 = gmx_invsqrt(rsq20);
182 rinvsq00 = rinv00*rinv00;
183 rinvsq10 = rinv10*rinv10;
184 rinvsq20 = rinv20*rinv20;
186 /* Load parameters for j particles */
189 /**************************
190 * CALCULATE INTERACTIONS *
191 **************************/
195 /* COULOMB ELECTROSTATICS */
197 felec = velec*rinvsq00;
199 /* Update potential sums from outer loop */
204 /* Calculate temporary vectorial force */
209 /* Update vectorial force */
213 f[j_coord_offset+DIM*0+XX] -= tx;
214 f[j_coord_offset+DIM*0+YY] -= ty;
215 f[j_coord_offset+DIM*0+ZZ] -= tz;
217 /**************************
218 * CALCULATE INTERACTIONS *
219 **************************/
223 /* COULOMB ELECTROSTATICS */
225 felec = velec*rinvsq10;
227 /* Update potential sums from outer loop */
232 /* Calculate temporary vectorial force */
237 /* Update vectorial force */
241 f[j_coord_offset+DIM*0+XX] -= tx;
242 f[j_coord_offset+DIM*0+YY] -= ty;
243 f[j_coord_offset+DIM*0+ZZ] -= tz;
245 /**************************
246 * CALCULATE INTERACTIONS *
247 **************************/
251 /* COULOMB ELECTROSTATICS */
253 felec = velec*rinvsq20;
255 /* Update potential sums from outer loop */
260 /* Calculate temporary vectorial force */
265 /* Update vectorial force */
269 f[j_coord_offset+DIM*0+XX] -= tx;
270 f[j_coord_offset+DIM*0+YY] -= ty;
271 f[j_coord_offset+DIM*0+ZZ] -= tz;
273 /* Inner loop uses 84 flops */
275 /* End of innermost loop */
278 f[i_coord_offset+DIM*0+XX] += fix0;
279 f[i_coord_offset+DIM*0+YY] += fiy0;
280 f[i_coord_offset+DIM*0+ZZ] += fiz0;
284 f[i_coord_offset+DIM*1+XX] += fix1;
285 f[i_coord_offset+DIM*1+YY] += fiy1;
286 f[i_coord_offset+DIM*1+ZZ] += fiz1;
290 f[i_coord_offset+DIM*2+XX] += fix2;
291 f[i_coord_offset+DIM*2+YY] += fiy2;
292 f[i_coord_offset+DIM*2+ZZ] += fiz2;
296 fshift[i_shift_offset+XX] += tx;
297 fshift[i_shift_offset+YY] += ty;
298 fshift[i_shift_offset+ZZ] += tz;
301 /* Update potential energies */
302 kernel_data->energygrp_elec[ggid] += velecsum;
304 /* Increment number of inner iterations */
305 inneriter += j_index_end - j_index_start;
307 /* Outer loop uses 31 flops */
310 /* Increment number of outer iterations */
313 /* Update outer/inner flops */
315 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_VF,outeriter*31 + inneriter*84);
318 * Gromacs nonbonded kernel: nb_kernel_ElecCoul_VdwNone_GeomW3P1_F_c
319 * Electrostatics interaction: Coulomb
320 * VdW interaction: None
321 * Geometry: Water3-Particle
322 * Calculate force/pot: Force
325 nb_kernel_ElecCoul_VdwNone_GeomW3P1_F_c
326 (t_nblist * gmx_restrict nlist,
327 rvec * gmx_restrict xx,
328 rvec * gmx_restrict ff,
329 t_forcerec * gmx_restrict fr,
330 t_mdatoms * gmx_restrict mdatoms,
331 nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
332 t_nrnb * gmx_restrict nrnb)
334 int i_shift_offset,i_coord_offset,j_coord_offset;
335 int j_index_start,j_index_end;
336 int nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
337 real shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
338 int *iinr,*jindex,*jjnr,*shiftidx,*gid;
339 real *shiftvec,*fshift,*x,*f;
341 real ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
343 real ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
345 real ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
347 real jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
348 real dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
349 real dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
350 real dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
351 real velec,felec,velecsum,facel,crf,krf,krf2;
359 jindex = nlist->jindex;
361 shiftidx = nlist->shift;
363 shiftvec = fr->shift_vec[0];
364 fshift = fr->fshift[0];
366 charge = mdatoms->chargeA;
368 /* Setup water-specific parameters */
369 inr = nlist->iinr[0];
370 iq0 = facel*charge[inr+0];
371 iq1 = facel*charge[inr+1];
372 iq2 = facel*charge[inr+2];
377 /* Start outer loop over neighborlists */
378 for(iidx=0; iidx<nri; iidx++)
380 /* Load shift vector for this list */
381 i_shift_offset = DIM*shiftidx[iidx];
382 shX = shiftvec[i_shift_offset+XX];
383 shY = shiftvec[i_shift_offset+YY];
384 shZ = shiftvec[i_shift_offset+ZZ];
386 /* Load limits for loop over neighbors */
387 j_index_start = jindex[iidx];
388 j_index_end = jindex[iidx+1];
390 /* Get outer coordinate index */
392 i_coord_offset = DIM*inr;
394 /* Load i particle coords and add shift vector */
395 ix0 = shX + x[i_coord_offset+DIM*0+XX];
396 iy0 = shY + x[i_coord_offset+DIM*0+YY];
397 iz0 = shZ + x[i_coord_offset+DIM*0+ZZ];
398 ix1 = shX + x[i_coord_offset+DIM*1+XX];
399 iy1 = shY + x[i_coord_offset+DIM*1+YY];
400 iz1 = shZ + x[i_coord_offset+DIM*1+ZZ];
401 ix2 = shX + x[i_coord_offset+DIM*2+XX];
402 iy2 = shY + x[i_coord_offset+DIM*2+YY];
403 iz2 = shZ + x[i_coord_offset+DIM*2+ZZ];
415 /* Start inner kernel loop */
416 for(jidx=j_index_start; jidx<j_index_end; jidx++)
418 /* Get j neighbor index, and coordinate index */
420 j_coord_offset = DIM*jnr;
422 /* load j atom coordinates */
423 jx0 = x[j_coord_offset+DIM*0+XX];
424 jy0 = x[j_coord_offset+DIM*0+YY];
425 jz0 = x[j_coord_offset+DIM*0+ZZ];
427 /* Calculate displacement vector */
438 /* Calculate squared distance and things based on it */
439 rsq00 = dx00*dx00+dy00*dy00+dz00*dz00;
440 rsq10 = dx10*dx10+dy10*dy10+dz10*dz10;
441 rsq20 = dx20*dx20+dy20*dy20+dz20*dz20;
443 rinv00 = gmx_invsqrt(rsq00);
444 rinv10 = gmx_invsqrt(rsq10);
445 rinv20 = gmx_invsqrt(rsq20);
447 rinvsq00 = rinv00*rinv00;
448 rinvsq10 = rinv10*rinv10;
449 rinvsq20 = rinv20*rinv20;
451 /* Load parameters for j particles */
454 /**************************
455 * CALCULATE INTERACTIONS *
456 **************************/
460 /* COULOMB ELECTROSTATICS */
462 felec = velec*rinvsq00;
466 /* Calculate temporary vectorial force */
471 /* Update vectorial force */
475 f[j_coord_offset+DIM*0+XX] -= tx;
476 f[j_coord_offset+DIM*0+YY] -= ty;
477 f[j_coord_offset+DIM*0+ZZ] -= tz;
479 /**************************
480 * CALCULATE INTERACTIONS *
481 **************************/
485 /* COULOMB ELECTROSTATICS */
487 felec = velec*rinvsq10;
491 /* Calculate temporary vectorial force */
496 /* Update vectorial force */
500 f[j_coord_offset+DIM*0+XX] -= tx;
501 f[j_coord_offset+DIM*0+YY] -= ty;
502 f[j_coord_offset+DIM*0+ZZ] -= tz;
504 /**************************
505 * CALCULATE INTERACTIONS *
506 **************************/
510 /* COULOMB ELECTROSTATICS */
512 felec = velec*rinvsq20;
516 /* Calculate temporary vectorial force */
521 /* Update vectorial force */
525 f[j_coord_offset+DIM*0+XX] -= tx;
526 f[j_coord_offset+DIM*0+YY] -= ty;
527 f[j_coord_offset+DIM*0+ZZ] -= tz;
529 /* Inner loop uses 81 flops */
531 /* End of innermost loop */
534 f[i_coord_offset+DIM*0+XX] += fix0;
535 f[i_coord_offset+DIM*0+YY] += fiy0;
536 f[i_coord_offset+DIM*0+ZZ] += fiz0;
540 f[i_coord_offset+DIM*1+XX] += fix1;
541 f[i_coord_offset+DIM*1+YY] += fiy1;
542 f[i_coord_offset+DIM*1+ZZ] += fiz1;
546 f[i_coord_offset+DIM*2+XX] += fix2;
547 f[i_coord_offset+DIM*2+YY] += fiy2;
548 f[i_coord_offset+DIM*2+ZZ] += fiz2;
552 fshift[i_shift_offset+XX] += tx;
553 fshift[i_shift_offset+YY] += ty;
554 fshift[i_shift_offset+ZZ] += tz;
556 /* Increment number of inner iterations */
557 inneriter += j_index_end - j_index_start;
559 /* Outer loop uses 30 flops */
562 /* Increment number of outer iterations */
565 /* Update outer/inner flops */
567 inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W3_F,outeriter*30 + inneriter*81);