2 * Copyright (c) Erik Lindahl, David van der Spoel 2003
4 * This file is generated automatically at compile time
5 * by the program mknb in the Gromacs distribution.
7 * Options used when generation this file:
11 * Software invsqrt: no
20 #ifdef GMX_THREAD_SHM_FDECOMP
21 #include<thread_mpi.h>
23 #define ALMOST_ZERO 1e-30
24 #define ALMOST_ONE 1-(1e-30)
27 #include "nb_kernel220_adress.h"
32 * Gromacs nonbonded kernel nb_kernel220_adress_cg
33 * Coulomb interaction: Reaction field
34 * VdW interaction: Buckingham
35 * water optimization: No
36 * Calculate forces: yes
38 void nb_kernel220_adress_cg(
72 int nri,ntype,nthreads;
73 real facel,krf,crf,tabscale,gbtabscale;
74 int n,ii,is3,ii3,k,nj0,nj1,jnr,j3,ggid;
75 int nn0,nn1,nouter,ninner;
87 real ix1,iy1,iz1,fix1,fiy1,fiz1;
89 real dx11,dy11,dz11,rsq11,rinv11;
91 real weight_cg1, weight_cg2, weight_product;
96 nthreads = *p_nthreads;
100 tabscale = *p_tabscale;
106 #ifdef GMX_THREAD_SHM_FDECOMP
107 tMPI_Thread_mutex_lock((tMPI_Thread_mutex_t *)mtx);
109 nn1 = nn0+(nri-nn0)/(2*nthreads)+10;
111 tMPI_Thread_mutex_unlock((tMPI_Thread_mutex_t *)mtx);
118 for(n=nn0; (n<nn1); n++)
122 shY = shiftvec[is3+1];
123 shZ = shiftvec[is3+2];
128 ix1 = shX + pos[ii3+0];
129 iy1 = shY + pos[ii3+1];
130 iz1 = shZ + pos[ii3+2];
131 iq = facel*charge[ii];
132 nti = 3*ntype*type[ii];
140 for(k=nj0; (k<nj1); k++)
143 weight_cg2 = wf[jnr];
144 weight_product = weight_cg1*weight_cg2;
145 if (weight_product < ALMOST_ZERO) {
148 else if (weight_product >= ALMOST_ONE)
150 /* force is zero, skip this molecule */
155 hybscal = 1.0 - weight_product;
164 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
165 rinv11 = 1.0/sqrt(rsq11);
167 tj = nti+3*type[jnr];
169 cexp1 = vdwparam[tj+1];
170 cexp2 = vdwparam[tj+2];
171 rinvsq = rinv11*rinv11;
173 vcoul = qq*(rinv11+krsq-crf);
175 rinvsix = rinvsq*rinvsq*rinvsq;
177 br = cexp2*rsq11*rinv11;
178 Vvdwexp = cexp1*exp(-br);
179 Vvdwtot = Vvdwtot+Vvdwexp-Vvdw6;
180 fscal = (qq*(rinv11-2.0*krsq)+br*Vvdwexp-6.0*Vvdw6)*rinvsq;
188 faction[j3+0] = faction[j3+0] - tx;
189 faction[j3+1] = faction[j3+1] - ty;
190 faction[j3+2] = faction[j3+2] - tz;
193 faction[ii3+0] = faction[ii3+0] + fix1;
194 faction[ii3+1] = faction[ii3+1] + fiy1;
195 faction[ii3+2] = faction[ii3+2] + fiz1;
196 fshift[is3] = fshift[is3]+fix1;
197 fshift[is3+1] = fshift[is3+1]+fiy1;
198 fshift[is3+2] = fshift[is3+2]+fiz1;
200 Vc[ggid] = Vc[ggid] + vctot;
201 Vvdw[ggid] = Vvdw[ggid] + Vvdwtot;
202 ninner = ninner + nj1 - nj0;
205 nouter = nouter + nn1 - nn0;
218 * Gromacs nonbonded kernel nb_kernel220_adress_ex
219 * Coulomb interaction: Reaction field
220 * VdW interaction: Buckingham
221 * water optimization: No
222 * Calculate forces: yes
224 void nb_kernel220_adress_ex(
258 int nri,ntype,nthreads;
259 real facel,krf,crf,tabscale,gbtabscale;
260 int n,ii,is3,ii3,k,nj0,nj1,jnr,j3,ggid;
261 int nn0,nn1,nouter,ninner;
273 real ix1,iy1,iz1,fix1,fiy1,fiz1;
275 real dx11,dy11,dz11,rsq11,rinv11;
277 real weight_cg1, weight_cg2, weight_product;
282 nthreads = *p_nthreads;
286 tabscale = *p_tabscale;
292 #ifdef GMX_THREAD_SHM_FDECOMP
293 tMPI_Thread_mutex_lock((tMPI_Thread_mutex_t *)mtx);
295 nn1 = nn0+(nri-nn0)/(2*nthreads)+10;
297 tMPI_Thread_mutex_unlock((tMPI_Thread_mutex_t *)mtx);
304 for(n=nn0; (n<nn1); n++)
308 shY = shiftvec[is3+1];
309 shZ = shiftvec[is3+2];
314 ix1 = shX + pos[ii3+0];
315 iy1 = shY + pos[ii3+1];
316 iz1 = shZ + pos[ii3+2];
317 iq = facel*charge[ii];
318 nti = 3*ntype*type[ii];
326 for(k=nj0; (k<nj1); k++)
329 weight_cg2 = wf[jnr];
330 weight_product = weight_cg1*weight_cg2;
331 if (weight_product < ALMOST_ZERO) {
332 /* force is zero, skip this molecule */
335 else if (weight_product >= ALMOST_ONE)
341 hybscal = weight_product;
350 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11;
351 rinv11 = 1.0/sqrt(rsq11);
353 tj = nti+3*type[jnr];
355 cexp1 = vdwparam[tj+1];
356 cexp2 = vdwparam[tj+2];
357 rinvsq = rinv11*rinv11;
359 vcoul = qq*(rinv11+krsq-crf);
361 rinvsix = rinvsq*rinvsq*rinvsq;
363 br = cexp2*rsq11*rinv11;
364 Vvdwexp = cexp1*exp(-br);
365 Vvdwtot = Vvdwtot+Vvdwexp-Vvdw6;
366 fscal = (qq*(rinv11-2.0*krsq)+br*Vvdwexp-6.0*Vvdw6)*rinvsq;
368 if(force_cap>0 && (fabs(fscal)> force_cap)){
369 fscal=force_cap*fscal/fabs(fscal);
377 faction[j3+0] = faction[j3+0] - tx;
378 faction[j3+1] = faction[j3+1] - ty;
379 faction[j3+2] = faction[j3+2] - tz;
382 faction[ii3+0] = faction[ii3+0] + fix1;
383 faction[ii3+1] = faction[ii3+1] + fiy1;
384 faction[ii3+2] = faction[ii3+2] + fiz1;
385 fshift[is3] = fshift[is3]+fix1;
386 fshift[is3+1] = fshift[is3+1]+fiy1;
387 fshift[is3+2] = fshift[is3+2]+fiz1;
389 Vc[ggid] = Vc[ggid] + vctot;
390 Vvdw[ggid] = Vvdw[ggid] + Vvdwtot;
391 ninner = ninner + nj1 - nj0;
394 nouter = nouter + nn1 - nn0;