NAMD
ComputeLjPmeSerial.C
Go to the documentation of this file.
1 
7 #include "InfoStream.h"
8 #include "Node.h"
9 #include "PatchMap.h"
10 #include "PatchMap.inl"
11 #include "AtomMap.h"
12 #include "ComputeLjPmeSerial.h"
13 #include "ComputeLjPmeSerialMgr.decl.h"
14 #include "PatchMgr.h"
15 #include "Molecule.h"
16 #include "ReductionMgr.h"
17 #include "ComputeMgr.h"
18 #include "ComputeMgr.decl.h"
19 // #define DEBUGM
20 #define MIN_DEBUG_LEVEL 3
21 #include "Debug.h"
22 #include "SimParameters.h"
23 #include "Parameters.h"
24 #include "LJTable.h"
25 #include "WorkDistrib.h"
26 #include "varsizemsg.h"
27 #include "LjPmeCompute.h"
28 #include <stdlib.h>
29 #include <stdio.h>
30 #include <errno.h>
31 
32 
35  short vdwType;
36  int id;
37 };
38 
40 
41 class LjPmeSerialCoordMsg : public CMessage_LjPmeSerialCoordMsg {
42 public:
44  int numAtoms;
47 };
48 
49 class LjPmeSerialForceMsg : public CMessage_LjPmeSerialForceMsg {
50 public:
56 };
57 
58 class ComputeLjPmeSerialMgr : public CBase_ComputeLjPmeSerialMgr {
59 public:
62 
63  void setCompute(ComputeLjPmeSerial *c) { ljPmeCompute = c; }
64 
68  void getLJparameters(const int &i, const int &j,
69  Real &A, Real &B, Real &A14, Real &B14);
71  void get_vdw_parameters(Real &sigma, Real &epsilon, Real &sigma14,
72  Real &epsilon14, Index index);
73  void setLJparameters();
74 
75 private:
76  CProxy_ComputeLjPmeSerialMgr ljPmeProxy;
77  ComputeLjPmeSerial *ljPmeCompute;
78 
79  int numSources;
80  int numArrived;
81  LjPmeSerialCoordMsg **coordMsgs;
82  int numAtoms;
83  int table_dim; // dimension of LJ table
84  LjPmeSerialAtom *coord;
85  LjPmeSerialForce *forceNonbond, *forceSlow;
86  LjPmeSerialForceMsg *oldmsg;
87 
88  LjPmeCompute LjPme;
89  double *ljPmeCoord; // stores atomic coordinate and equivalent of q in LJ-PME
90  double *ljForceSlow; // slow LJ-PME force
91  double *ljForceNonbond; // fast LJ-PME force
92  double *ljParameter; // eps & sigma for nonbonded LJ paramters
93  double *ljParameter14; // eps & sigma for 1-4 LJ paramters
94  double oldNonbondedScaling; // check if nonbonded scaling has changed
95  double oldSoluteScaling; // check if solute VDW scaling has changed
96  int *atomType;
97  Bool initialized;
98 };
99 
101  ljPmeProxy(thisgroup), ljPmeCompute(0), numSources(0), numArrived(0),
102  coordMsgs(0), coord(0), forceNonbond(0), forceSlow(0), oldmsg(0),
103  numAtoms(0), ljPmeCoord(0), ljForceSlow(0), ljForceNonbond(0),
104  ljParameter(0), ljParameter14(0), atomType(0)
105 {
106  initialized = false;
107  CkpvAccess(BOCclass_group).computeLjPmeSerialMgr = thisgroup;
108 }
109 
111 {
112  initialized = false;
113  for (int i=0; i < numSources; i++) delete coordMsgs[i];
114  delete [] coordMsgs;
115  delete [] coord;
116  delete [] forceNonbond;
117  delete [] forceSlow;
118  delete oldmsg;
119  // extra
120  if (ljPmeCoord) delete[] ljPmeCoord;
121  if (ljForceSlow) delete[] ljForceSlow;
122  if (ljForceNonbond) delete[] ljForceNonbond;
123  if (ljParameter) delete[] ljParameter;
124  if (ljParameter14) delete[] ljParameter14;
125  if (atomType) delete[] atomType;
126 }
127 
129 
132 {
133  CProxy_ComputeLjPmeSerialMgr::ckLocalBranch(
134  CkpvAccess(BOCclass_group).computeLjPmeSerialMgr)->setCompute(this);
136 }
137 
138 void ComputeLjPmeSerialMgr::getLJparameters(const int &i, const int &j,
139  Real &A, Real &B, Real &A14, Real &B14) {
140 
141  Parameters *params = Node::Object()->parameters;
143  int useGeom = simParams->vdwGeometricSigma;
144  Bool tabulatedEnergies = simParams->tabulatedEnergies;
145  Bool soluteScalingOn = simParams->soluteScalingOn;
146  BigReal soluteScalingFactor = simParams->soluteScalingFactorVdw;
147  unsigned int table_dim_org = params->get_num_vdw_params();
148  int ss_dim = Node::Object()->molecule->ss_num_vdw_params;
149  int K = -1;
150  int *ss_vdw_type = Node::Object()->molecule->ss_vdw_type;
151  // BigReal sigma_max;
152  // We need the A and B parameters for the Van der Waals. These can
153  // be explicitly be specified for this pair or calculated from the
154  // sigma and epsilon values for the two atom types
155  // printf("Looking at interaction of %i with %i\n", i, j);
156  if ( tabulatedEnergies && params->get_table_pair_params(i,j,&K)) {
157 
158  if ( K < 0 ) { NAMD_bug(
159  "LJPME::compute_vdw_params: energy table index is negative");
160  }
161  A = -1 - K;
162  B = 0;
163  A14 = -1 - K;
164  B14 = 0;
165  } else if (params->get_vdw_pair_params(i,j, &A, &B, &A14, &B14)) {
166  if ( tabulatedEnergies && ( A < 0 || A14 < 0 ) ) {
167  NAMD_die("LJ A is negative with tabulatedEnergies enabled");
168  }
169  } else {
170  // We didn't find explicit parameters for this pair. So instead,
171  // get the parameters for each atom type separately and use them
172  // to calculate the values we need
173  Real sigma_i, sigma_i14, epsilon_i, epsilon_i14;
174  Real sigma_j, sigma_j14, epsilon_j, epsilon_j14;
175 
176  if (!soluteScalingOn) {
177  params->get_vdw_params(&sigma_i, &epsilon_i, &sigma_i14,
178  &epsilon_i14,i);
179  params->get_vdw_params(&sigma_j, &epsilon_j, &sigma_j14,
180  &epsilon_j14,j);
181  } else {
182  int i_type = (i >= table_dim_org)? ss_vdw_type[i-table_dim_org]:i;
183  int j_type = (j >= table_dim_org)? ss_vdw_type[j-table_dim_org]:j;
184  params->get_vdw_params(&sigma_i, &epsilon_i, &sigma_i14,
185  &epsilon_i14,i_type);
186  params->get_vdw_params(&sigma_j, &epsilon_j, &sigma_j14,
187  &epsilon_j14,j_type);
188  }
189 
190  BigReal sigma_ij =
191  useGeom ? sqrt(sigma_i*sigma_j) : 0.5*(sigma_i+sigma_j);
192  BigReal sigma_ij14 =
193  useGeom ? sqrt(sigma_i14*sigma_j14) : 0.5 * (sigma_i14+sigma_j14);
194  BigReal epsilon_ij = sqrt(epsilon_i*epsilon_j);
195  BigReal epsilon_ij14 = sqrt(epsilon_i14*epsilon_j14);
196 
197  // Calculate sigma^6
198  sigma_ij *= sigma_ij*sigma_ij;
199  sigma_ij *= sigma_ij;
200  sigma_ij14 *= sigma_ij14*sigma_ij14;
201  sigma_ij14 *= sigma_ij14;
202 
203  // Calculate LJ constants A & B
204  B = 4.0 * sigma_ij * epsilon_ij;
205  A = B * sigma_ij;
206  B14 = 4.0 * sigma_ij14 * epsilon_ij14;
207  A14 = B14 * sigma_ij14;
208 
209  if (soluteScalingOn) {
210  if (i >= table_dim_org && i < (table_dim_org+ss_dim) && j < table_dim_org) {
211  A *= sqrt(soluteScalingFactor);
212  B *= sqrt(soluteScalingFactor);
213  A14 *= sqrt(soluteScalingFactor);
214  B14 *= sqrt(soluteScalingFactor);
215  }
216  if (i < table_dim_org && j >= table_dim_org && j < (table_dim_org+ss_dim)) {
217  A *= sqrt(soluteScalingFactor);
218  B *= sqrt(soluteScalingFactor);
219  A14 *= sqrt(soluteScalingFactor);
220  B14 *= sqrt(soluteScalingFactor);
221  }
222  if (i >=table_dim_org && i < (table_dim_org+ss_dim) && j >= table_dim_org && j < (table_dim_org+ss_dim)) {
223  A *= soluteScalingFactor;
224  B *= soluteScalingFactor;
225  A14 *= soluteScalingFactor;
226  B14 *= soluteScalingFactor;
227  }
228  }
229 
230  if ( tabulatedEnergies && ( A < 0 || A14 < 0 ) ) {
231  NAMD_die("LJPME: LJ A is negative with tabulatedEnergies enabled");
232  }
233  }
234 }
235 
236 void ComputeLjPmeSerialMgr::get_vdw_parameters(Real &sigma, Real &epsilon, Real &sigma14,
237  Real &epsilon14, Index index) {
238  // Get the index index interaction
239  Real A, B, A14, B14;
240  this->getLJparameters(index, index, A, B, A14, B14);
241  // Copied from get_vdw_params in Paramters.h
242  sigma = sqrt(cbrt(A)) / sqrt(cbrt(B));
243  epsilon = B*B / (4*A);
244 
245  sigma14 = sqrt(cbrt(A14)) / sqrt(cbrt(B14));
246  epsilon14 = B14*B14 / (4*A14);
247 }
248 
251  Real scaling = simParams->nonbondedScaling;
252  // These won't change
253  for (int i = 0; i < table_dim; i++) {
254  for (int j = i; j < table_dim; j++) {
255  int index_ij = 2*(i*table_dim+j);
256  int index_ji = 2*(j*table_dim+i);
257  Real A, B, A14, B14;
258  this->getLJparameters(i, j, A, B, A14, B14);
259  ljParameter[index_ij] = scaling * A; // repulsion
260  ljParameter[index_ij+1] = scaling * B; // attraction
261  ljParameter14[index_ij] = scaling * A14; // 1-4 repulsion
262  ljParameter14[index_ij+1] = scaling * B14; // 1-4 attraction
263  // Copy to transpose entry
264  ljParameter[index_ji] = ljParameter[index_ij];
265  ljParameter[index_ji+1] = ljParameter[index_ij+1];
266  ljParameter14[index_ji] = ljParameter14[index_ij];
267  ljParameter14[index_ji+1] = ljParameter14[index_ij+1];
268 
269  //printf("Table Dim: %d, i: %d, j: %d \n", table_dim, i, j);
270  //printf("A: %3.6f, B: %3.6f, A14: %3.6f, B14: %3.6f \n", A, B, A14, B14);
271  }
272  }
273 
274  // Store the dispersion part of LJ using Geometric sigma combining rules
275  for (int i = 0; i < numAtoms; i++) {
276  Real sigma, sigma_14, epsilon, epsilon_14;
277  atomType[i] = coord[i].vdwType;
278  this->get_vdw_parameters(sigma, epsilon, sigma_14,
279  epsilon_14, coord[i].vdwType);
280  // printf("VDWtype: %d, eps: %3.6f, sigma: %3.6f, eps14: %3.6f, sigma14: %3.6f \n",
281  // atomType[i], epsilon, sigma, epsilon_14, sigma_14);
282 
283  // store sqrt(4*eps*sig^6) = 2*sqrt(eps)*sigma^3
284  ljPmeCoord[4*i+3] = 2.0*sigma*sigma*sigma*sqrt(scaling * epsilon);
285  }
286 }
287 
289 {
291 
292  // For now we do the LJ-PME calculation every steps
293 
294  // Skip computations if nothing to do.
295  // if ( ! patchList[0].p->flags.doFullElectrostatics )
296  // {
297  // for (ap = ap.begin(); ap != ap.end(); ap++) {
298  // CompAtom *x = (*ap).positionBox->open();
299  // Results *r = (*ap).forceBox->open();
300  // (*ap).positionBox->close(&x);
301  // (*ap).forceBox->close(&r);
302  // }
303  // reduction->submit();
304  // return;
305  // }
306 
307  // allocate message
308  int numLocalAtoms = 0;
309  for (ap = ap.begin(); ap != ap.end(); ap++) {
310  numLocalAtoms += (*ap).p->getNumAtoms();
311  }
312 
313  LjPmeSerialCoordMsg *msg = new (numLocalAtoms, 0) LjPmeSerialCoordMsg;
314  msg->sourceNode = CkMyPe();
315  msg->numAtoms = numLocalAtoms;
316  msg->lattice = patchList[0].p->flags.lattice;
317  LjPmeSerialAtom *data_ptr = msg->coord;
318 
319  // get positions
320  for (ap = ap.begin(); ap != ap.end(); ap++) {
321  CompAtom *x = (*ap).positionBox->open();
322  CompAtomExt *xExt = (*ap).p->getCompAtomExtInfo();
323  if ( patchList[0].p->flags.doMolly ) {
324  (*ap).positionBox->close(&x);
325  x = (*ap).avgPositionBox->open();
326  }
327  int numAtoms = (*ap).p->getNumAtoms();
328 
329  for(int i=0; i < numAtoms; i++)
330  {
331  data_ptr->position = x[i].position;
332  data_ptr->vdwType = x[i].vdwType;
333  data_ptr->id = xExt[i].id;
334  ++data_ptr;
335  }
336 
337  if ( patchList[0].p->flags.doMolly ) { (*ap).avgPositionBox->close(&x); }
338  else { (*ap).positionBox->close(&x); }
339  }
340 
341  CProxy_ComputeLjPmeSerialMgr ljPmeProxy(
342  CkpvAccess(BOCclass_group).computeLjPmeSerialMgr);
343  ljPmeProxy[0].recvCoord(msg);
344 }
345 
346 
349  Parameters *params = Node::Object()->parameters;
350  if ( ! numSources ) {
351  numSources = (PatchMap::Object())->numNodesWithPatches();
352  coordMsgs = new LjPmeSerialCoordMsg*[numSources];
353  for ( int i=0; i<numSources; ++i ) { coordMsgs[i] = 0; }
354  numArrived = 0;
355  numAtoms = Node::Object()->molecule->numAtoms;
356  // Allocate memory to receive coords and send force
357  coord = new LjPmeSerialAtom[numAtoms];
358  forceNonbond = new LjPmeSerialForce[numAtoms];
359  forceSlow = new LjPmeSerialForce[numAtoms];
360  }
361 
362  // Receive the message at store using global atom index
363  for (int i=0; i < msg->numAtoms; ++i) {
364  coord[msg->coord[i].id] = msg->coord[i];
365  }
366  coordMsgs[numArrived] = msg;
367  ++numArrived;
368 
369  if ( numArrived < numSources ) return;
370  numArrived = 0;
371 
372  //###########################################
373  // ALL DATA ARRIVED --- CALCULATE FORCES
374  Lattice lattice = msg->lattice;
375 
376  if(!initialized) {
377  initialized = true;
378  // Allocate memory for LJ-PME
379  table_dim = params->get_num_vdw_params();
380  ljParameter = new double[2*table_dim*table_dim];
381  ljParameter14 = new double[2*table_dim*table_dim];
382  ljPmeCoord = new double[4*numAtoms];
383  ljForceSlow = new double[3*numAtoms];
384  ljForceNonbond = new double[3*numAtoms];
385  atomType = new int[numAtoms];
386 
387  if (ljPmeCoord==0 || ljForceSlow==0 || ljForceNonbond==0 || ljParameter==0
388  || ljParameter==0 || atomType == 0) {
389  NAMD_die("can't allocate LJ-PME atom buffers");
390  }
391 
392  // Set the data for LJPME compute. To save memory, all arrays in LjPmeCompute
393  // are pointing to arrayes in ComputeLjPmeSerialMgr class
394  LjPme.initialize(ljPmeCoord, ljParameter, ljParameter14, atomType,
395  ljForceNonbond, ljForceSlow, table_dim, numAtoms);
396  // Set LJ parameters
397  this->setLJparameters();
398  oldNonbondedScaling = simParams->nonbondedScaling;
399  oldSoluteScaling = simParams->soluteScalingFactorVdw;
400  }
401 
402  // Nonbonded scaling or solute VDW scaling has changed, so update the LJ parameters
403  if((simParams->nonbondedScaling != oldNonbondedScaling) ||
404  (simParams->soluteScalingOn && (simParams->soluteScalingFactorVdw != oldSoluteScaling))) {
405  this->setLJparameters();
406  oldNonbondedScaling = simParams->nonbondedScaling;
407  oldSoluteScaling = simParams->soluteScalingFactorVdw;
408  }
409 
410  // Update the coordinates and initialize the forces to zero
411  for (int i = 0; i < numAtoms; i++) {
412  ljPmeCoord[4*i ] = coord[i].position.x;
413  ljPmeCoord[4*i+1] = coord[i].position.y;
414  ljPmeCoord[4*i+2] = coord[i].position.z;
415  // Initialize the force to zero
416  ljForceSlow[3*i ] = 0.0;
417  ljForceSlow[3*i+1] = 0.0;
418  ljForceSlow[3*i+2] = 0.0;
419  ljForceNonbond[3*i ] = 0.0;
420  ljForceNonbond[3*i+1] = 0.0;
421  ljForceNonbond[3*i+2] = 0.0;
422  }
423 
425  double energySlow, energyNonbond;
426  double virialSlow[3][3], virialNonbond[3][3];
427  LjPme.computeLJpotential(simParams->LJPMEEwaldCoefficient,
428  simParams->cutoff,
429  lattice,
430  virialNonbond,
431  virialSlow,
432  energyNonbond,
433  energySlow,
434  true,
435  true);
436 
437  if (0) {
438  printf("LJ-PME: E_nb: %6.12f, E_rec: %6.12f, E_sum: %6.12f! \n",
439  energyNonbond, energySlow, energyNonbond+energySlow);
440  printf("LJ-PME: virial_nb: [%3.6f, %3.6f, %3.6f, %3.6f, %3.6f, %3.6f] \n",
441  virialNonbond[0][0], virialNonbond[0][1], virialNonbond[0][2],
442  virialNonbond[1][1], virialNonbond[1][2], virialNonbond[2][2]);
443  printf("LJ-PME: virial_slow: [%3.6f, %3.6f, %3.6f, %3.6f, %3.6f, %3.6f] \n",
444  virialSlow[0][0], virialSlow[0][1], virialSlow[0][2],
445  virialSlow[1][1], virialSlow[1][2], virialSlow[2][2]);
446  }
447 
448  for (int i = 0; i < numAtoms; i++) {
449  forceSlow[i].x = ljForceSlow[3*i ];
450  forceSlow[i].y = ljForceSlow[3*i+1];
451  forceSlow[i].z = ljForceSlow[3*i+2];
452 
453  forceNonbond[i].x = ljForceNonbond[3*i ];
454  forceNonbond[i].y = ljForceNonbond[3*i+1];
455  forceNonbond[i].z = ljForceNonbond[3*i+2];
456 
457  if (0) {
458  forceNonbond[i].x = 0.0;
459  forceNonbond[i].y = 0.0;
460  forceNonbond[i].z = 0.0;
461  double fx = forceNonbond[i].x + forceSlow[i].x;
462  double fy = forceNonbond[i].y + forceSlow[i].y;
463  double fz = forceNonbond[i].z + forceSlow[i].z;
464  printf("LJ-PME send: atom %5d<-> nb: (%3.6f,%3.6f,%3.6f), slow:(%3.6f,%3.6f,%3.6f), sum:(%3.6f,%3.6f,%3.6f)! \n", i,
465  forceNonbond[i].x, forceNonbond[i].y, forceNonbond[i].z,
466  forceSlow[i].x, forceSlow[i].y, forceSlow[i].z,
467  fx, fy, fz);
468  }
469  }
470 
471  // distribute forces
472  for (int j=0; j < numSources; j++) {
473  LjPmeSerialCoordMsg *cmsg = coordMsgs[j];
474  coordMsgs[j] = 0;
475  LjPmeSerialForceMsg *fmsg = new (cmsg->numAtoms, cmsg->numAtoms, 0) LjPmeSerialForceMsg;
476 
477  for (int i=0; i < cmsg->numAtoms; i++) {
478  fmsg->forceSlow[i] = forceSlow[cmsg->coord[i].id];
479  fmsg->forceNonbond[i] = forceNonbond[cmsg->coord[i].id];
480  }
481 
482  if ( ! j ) { // set virial and energy only for first message
483  fmsg->energyNonbond = energyNonbond;
484  fmsg->energySlow = energySlow;
485  for (int k=0; k < 3; k++) {
486  for (int l=0; l < 3; l++) {
487  fmsg->virialSlow[k][l] = virialSlow[k][l];
488  fmsg->virialNonbond[k][l] = virialNonbond[k][l];
489  }
490  }
491  }
492  else { // set other messages to zero, add into reduction only once
493  fmsg->energyNonbond = 0;
494  fmsg->energySlow = 0;
495  for (int k=0; k < 3; k++) {
496  for (int l=0; l < 3; l++) {
497  fmsg->virialSlow[k][l] = 0;
498  fmsg->virialNonbond[k][l] = 0;
499  }
500  }
501  }
502 
503  ljPmeProxy[cmsg->sourceNode].recvForce(fmsg);
504  delete cmsg;
505  }
506 }
507 
509  ljPmeCompute->saveResults(msg);
510  delete oldmsg;
511  oldmsg = msg;
512 }
513 
515 {
517 
518  LjPmeSerialForce *results_Nonbond_ptr = msg->forceNonbond;
519  LjPmeSerialForce *results_Slow_ptr = msg->forceSlow;
520 
521  // add in forces
522  for (ap = ap.begin(); ap != ap.end(); ap++) {
523  Results *r = (*ap).forceBox->open();
524  Force *fSlow = r->f[Results::slow];
525  Force *fNonbond = r->f[Results::nbond];
526  int numAtoms = (*ap).p->getNumAtoms();
527 
528  for(int i=0; i<numAtoms; ++i) {
529  fSlow[i].x += results_Slow_ptr->x;
530  fSlow[i].y += results_Slow_ptr->y;
531  fSlow[i].z += results_Slow_ptr->z;
532  fNonbond[i].x += results_Nonbond_ptr->x;
533  fNonbond[i].y += results_Nonbond_ptr->y;
534  fNonbond[i].z += results_Nonbond_ptr->z;
535  ++results_Slow_ptr;
536  ++results_Nonbond_ptr;
537  }
538 
539  (*ap).forceBox->close(&r);
540  }
541 
542  // reduction->item(REDUCTION_LJ_ENERGY) += msg->energyNonbond;
543  // reduction->item(REDUCTION_ELECT_ENERGY_SLOW) += msg->energySlow;
544 
545  // reduction->item(REDUCTION_VIRIAL_SLOW_XX) += msg->virialSlow[0][0];
546  // reduction->item(REDUCTION_VIRIAL_SLOW_XY) += msg->virialSlow[0][1];
547  // reduction->item(REDUCTION_VIRIAL_SLOW_XZ) += msg->virialSlow[0][2];
548  // reduction->item(REDUCTION_VIRIAL_SLOW_YX) += msg->virialSlow[1][0];
549  // reduction->item(REDUCTION_VIRIAL_SLOW_YY) += msg->virialSlow[1][1];
550  // reduction->item(REDUCTION_VIRIAL_SLOW_YZ) += msg->virialSlow[1][2];
551  // reduction->item(REDUCTION_VIRIAL_SLOW_ZX) += msg->virialSlow[2][0];
552  // reduction->item(REDUCTION_VIRIAL_SLOW_ZY) += msg->virialSlow[2][1];
553  // reduction->item(REDUCTION_VIRIAL_SLOW_ZZ) += msg->virialSlow[2][2];
554 
555  // reduction->item(REDUCTION_VIRIAL_NBOND_XX) += msg->virialNonbond[0][0];
556  // reduction->item(REDUCTION_VIRIAL_NBOND_XY) += msg->virialNonbond[0][1];
557  // reduction->item(REDUCTION_VIRIAL_NBOND_XZ) += msg->virialNonbond[0][2];
558  // reduction->item(REDUCTION_VIRIAL_NBOND_YX) += msg->virialNonbond[1][0];
559  // reduction->item(REDUCTION_VIRIAL_NBOND_YY) += msg->virialNonbond[1][1];
560  // reduction->item(REDUCTION_VIRIAL_NBOND_YZ) += msg->virialNonbond[1][2];
561  // reduction->item(REDUCTION_VIRIAL_NBOND_ZX) += msg->virialNonbond[2][0];
562  // reduction->item(REDUCTION_VIRIAL_NBOND_ZY) += msg->virialNonbond[2][1];
563  // reduction->item(REDUCTION_VIRIAL_NBOND_ZZ) += msg->virialNonbond[2][2];
564 
565  reduction->item(REDUCTION_LJ_ENERGY) += msg->energyNonbond + msg->energySlow;
566 
567  reduction->item(REDUCTION_VIRIAL_NBOND_XX) += msg->virialNonbond[0][0] + msg->virialSlow[0][0];
568  reduction->item(REDUCTION_VIRIAL_NBOND_XY) += msg->virialNonbond[0][1] + msg->virialSlow[0][1];
569  reduction->item(REDUCTION_VIRIAL_NBOND_XZ) += msg->virialNonbond[0][2] + msg->virialSlow[0][2];
570  reduction->item(REDUCTION_VIRIAL_NBOND_YX) += msg->virialNonbond[1][0] + msg->virialSlow[1][0];
571  reduction->item(REDUCTION_VIRIAL_NBOND_YY) += msg->virialNonbond[1][1] + msg->virialSlow[1][1];
572  reduction->item(REDUCTION_VIRIAL_NBOND_YZ) += msg->virialNonbond[1][2] + msg->virialSlow[1][2];
573  reduction->item(REDUCTION_VIRIAL_NBOND_ZX) += msg->virialNonbond[2][0] + msg->virialSlow[2][0];
574  reduction->item(REDUCTION_VIRIAL_NBOND_ZY) += msg->virialNonbond[2][1] + msg->virialSlow[2][1];
575  reduction->item(REDUCTION_VIRIAL_NBOND_ZZ) += msg->virialNonbond[2][2] + msg->virialSlow[2][2];
576  reduction->submit();
577 }
578 
579 #include "ComputeLjPmeSerialMgr.def.h"
580 
static Node * Object()
Definition: Node.h:86
void recvForce(LjPmeSerialForceMsg *)
void computeLJpotential(const double &alphaLJ, const double &cutoff, const Lattice &lattice, double virialNonbonded[][3], double virialSlow[][3], double &energyNonbond, double &energySlow, bool doEnergy, bool doSlow)
Definition: LjPmeCompute.C:34
void setCompute(ComputeLjPmeSerial *c)
int32 ComputeID
Definition: NamdTypes.h:278
static PatchMap * Object()
Definition: PatchMap.h:27
Definition: Vector.h:72
SimParameters * simParameters
Definition: Node.h:181
ComputeHomePatchList patchList
float Real
Definition: common.h:118
BigReal & item(int i)
Definition: ReductionMgr.h:313
BigReal z
Definition: Vector.h:74
Position position
Definition: NamdTypes.h:77
SubmitReduction * willSubmit(int setID, int size=-1)
Definition: ReductionMgr.C:366
LjPmeSerialForce * forceSlow
ResizeArrayIter< T > begin(void) const
BigReal virialSlow[3][3]
static ReductionMgr * Object(void)
Definition: ReductionMgr.h:279
LjPmeSerialAtom * coord
void saveResults(LjPmeSerialForceMsg *)
uint32 id
Definition: NamdTypes.h:156
int Index
Definition: structures.h:26
Force LjPmeSerialForce
void NAMD_bug(const char *err_msg)
Definition: common.C:195
int16 vdwType
Definition: NamdTypes.h:79
int Bool
Definition: common.h:142
Force * f[maxNumForces]
Definition: PatchTypes.h:146
LjPmeSerialForce * forceNonbond
void get_vdw_parameters(Real &sigma, Real &epsilon, Real &sigma14, Real &epsilon14, Index index)
BigReal x
Definition: Vector.h:74
void getLJparameters(const int &i, const int &j, Real &A, Real &B, Real &A14, Real &B14)
int numAtoms
Definition: Molecule.h:585
void recvCoord(LjPmeSerialCoordMsg *)
int get_vdw_pair_params(Index ind1, Index ind2, Real *, Real *, Real *, Real *)
Definition: Parameters.C:4646
void NAMD_die(const char *err_msg)
Definition: common.C:147
ComputeLjPmeSerial(ComputeID c)
int get_num_vdw_params(void)
Definition: Parameters.h:604
int get_table_pair_params(Index, Index, int *)
Definition: Parameters.C:4556
Parameters * parameters
Definition: Node.h:180
#define simParams
Definition: Output.C:129
BigReal y
Definition: Vector.h:74
int * ss_vdw_type
Definition: Molecule.h:485
void submit(void)
Definition: ReductionMgr.h:324
void initialize(const double *pmeCoord, const double *parameter, const double *parameter14, const int *type, double *forceNonbond, double *forceSlow, const int &ljTableDim, const int &nAtoms)
Definition: LjPmeCompute.C:13
void get_vdw_params(Real *sigma, Real *epsilon, Real *sigma14, Real *epsilon14, Index index)
Definition: Parameters.h:570
ResizeArrayIter< T > end(void) const
Molecule * molecule
Definition: Node.h:179
#define cbrt(x)
Definition: Parameters.h:51
int ss_num_vdw_params
Definition: Molecule.h:484
double BigReal
Definition: common.h:123
BigReal virialNonbond[3][3]