NAMD
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
GromacsPairElem Class Reference

#include <ComputeGromacsPair.h>

Public Types

enum  { size = 2 }
 
enum  { gromacsPairEnergyIndex, TENSOR =(virialIndex), reductionDataSize }
 
enum  { reductionChecksumLabel = REDUCTION_GRO_LJ_CHECKSUM }
 

Public Member Functions

int hash () const
 
 GromacsPairElem ()
 
 GromacsPairElem (AtomID atom0, const TupleSignature *sig, const GromacsPairValue *v)
 
 GromacsPairElem (const GromacsPair *a, const GromacsPairValue *v)
 
 GromacsPairElem (AtomID atom0, AtomID atom1)
 
 ~GromacsPairElem ()
 
int operator== (const GromacsPairElem &a) const
 
int operator< (const GromacsPairElem &a) const
 

Static Public Member Functions

static void computeForce (GromacsPairElem *, int, BigReal *, BigReal *)
 
static void getMoleculePointers (Molecule *, int *, int32 ***, GromacsPair **)
 
static void getParameterPointers (Parameters *, const GromacsPairValue **)
 
static void getTupleInfo (AtomSignature *sig, int *count, TupleSignature **t)
 
static void submitReductionData (BigReal *, SubmitReduction *)
 

Public Attributes

AtomID atomID [size]
 
int localIndex [size]
 
TuplePatchElemp [size]
 
Real scale
 
const GromacsPairValuevalue
 

Static Public Attributes

static int pressureProfileSlabs = 0
 
static int pressureProfileAtomTypes = 1
 
static BigReal pressureProfileThickness = 0
 
static BigReal pressureProfileMin = 0
 

Detailed Description

Definition at line 23 of file ComputeGromacsPair.h.

Member Enumeration Documentation

anonymous enum
Enumerator
size 

Definition at line 26 of file ComputeGromacsPair.h.

anonymous enum
Enumerator
gromacsPairEnergyIndex 
TENSOR 
reductionDataSize 

Definition at line 53 of file ComputeGromacsPair.h.

anonymous enum

Constructor & Destructor Documentation

GromacsPairElem::GromacsPairElem ( )
inline

Definition at line 12 of file ComputeGromacsPair.inl.

12 { ; }
GromacsPairElem::GromacsPairElem ( AtomID  atom0,
const TupleSignature sig,
const GromacsPairValue v 
)
inline

Definition at line 14 of file ComputeGromacsPair.inl.

References atomID, TupleSignature::offset, TupleSignature::tupleParamType, and value.

14  {
15  atomID[0] = atom0;
16  atomID[1] = atom0 + sig->offset[0];
17  value = &v[sig->tupleParamType];
18 }
const GromacsPairValue * value
AtomID atomID[size]
Index tupleParamType
Definition: structures.h:202
GromacsPairElem::GromacsPairElem ( const GromacsPair a,
const GromacsPairValue v 
)
inline

Definition at line 20 of file ComputeGromacsPair.inl.

References gromacsPair::atom1, gromacsPair::atom2, atomID, gromacsPair::gromacsPair_type, and value.

21  {
22  atomID[0] = a->atom1;
23  atomID[1] = a->atom2;
24  value = &v[a->gromacsPair_type];
25  }
const GromacsPairValue * value
int32 atom2
Definition: structures.h:95
AtomID atomID[size]
Index gromacsPair_type
Definition: structures.h:98
int32 atom1
Definition: structures.h:94
GromacsPairElem::GromacsPairElem ( AtomID  atom0,
AtomID  atom1 
)
inline

Definition at line 27 of file ComputeGromacsPair.inl.

References atomID.

28  {
29  if (atom0 > atom1) { // Swap end atoms so lowest is first!
30  AtomID tmp = atom1; atom1 = atom0; atom0 = tmp;
31  }
32  atomID[0] = atom0;
33  atomID[1] = atom1;
34  }
int AtomID
Definition: NamdTypes.h:29
AtomID atomID[size]
GromacsPairElem::~GromacsPairElem ( )
inline

Definition at line 61 of file ComputeGromacsPair.h.

61 {};

Member Function Documentation

void GromacsPairElem::computeForce ( GromacsPairElem tuples,
int  ntuple,
BigReal reduction,
BigReal pressureProfileData 
)
static

Definition at line 44 of file ComputeGromacsPair.C.

References atomID, SimParameters::cutoff, DebugM, Lattice::delta(), TuplePatchElem::f, gromacsPairEnergyIndex, Patch::lattice, Vector::length2(), localIndex, Node::Object(), p, TuplePatchElem::p, GromacsPairValue::pairC12, GromacsPairValue::pairC6, CompAtom::partition, CompAtom::position, pp_clamp(), pp_reduction(), pressureProfileAtomTypes, pressureProfileMin, pressureProfileSlabs, pressureProfileThickness, scale, Node::simParameters, simParams, size, value, TuplePatchElem::x, Vector::x, x, Vector::y, and Vector::z.

46 {
47  const Lattice & lattice = tuples[0].p[0]->p->lattice;
48 
49  for ( int ituple=0; ituple<ntuple; ++ituple ) {
50  const GromacsPairElem &tup = tuples[ituple];
51  enum { size = 2 };
52  const AtomID (&atomID)[size](tup.atomID);
53  const int (&localIndex)[size](tup.localIndex);
54  TuplePatchElem * const(&p)[size](tup.p);
55  const Real (&scale)(tup.scale);
56  const GromacsPairValue * const(&value)(tup.value);
57 
58  DebugM(1, "::computeforce() localIndex = " << localIndex [0] << " "
59  << localIndex[1] << std::endl);
60 
61  // compute vectors between atoms and their distances
62  const Vector r12 = lattice.delta(p[0]->x[localIndex[0]].position,
63  p[1]->x[localIndex[1]].position);
64 
65  if ( p[0]->patchID == p[1]->patchID && localIndex[0] == localIndex[1] ) {
66  continue;
67  }
69  BigReal cutoff = simParams->cutoff;
70  BigReal r12_len = r12.length2();
71  if ( r12_len == 0 ) continue;
72  //if ( r12_len > cutoff) {
73  //continue;
74  //}
75  BigReal ri2 = 1.0/r12_len;
76  BigReal ri = sqrt(ri2);
77  BigReal ri6 = ri2*ri2*ri2;
78  BigReal ri7 = ri*ri6;
79  BigReal ri8 = ri2*ri2*ri2*ri2;
80  BigReal ri12 = ri6*ri6;
81  BigReal ri13 = ri12*ri;
82  BigReal ri14 = ri12*ri2;
83 
84  BigReal energy = 0;
85  BigReal diff = 0;
86  BigReal pairC12 = value->pairC12;
87  BigReal pairC6 = value->pairC6;
88 
89  // Add the energy for the 12-6 LJ interaction to the total energy
90  energy = (pairC12*ri12) - (pairC6*ri6);
91  // This is a dirty hack; currently the code is looping over N^2 instead of N(N-1)/2
92  // This is happening because the LJ list is 2x long as it has to be
93  //energy *= 0.5;
94 
95  // Determine the magnitude of the force
96  diff = ((12*pairC12*ri14) - (6*pairC6*ri8));
97  // This is a dirty hack; currently the code is looping over N^2 instead of N(N-1)/2
98  // This is happening because the LJ list is 2x long as it has to be
99  //diff *= 0.5;
100  //std::cout << "Force: " << diff << " " << pairC12 << " " << pairC6 << " " << r12.length() << "\n";
101 
102  //Scale the force vector accordingly
103  const Force f12 = diff * r12;
104  //std::cout << "Atoms: " << localIndex[0] << " " << localIndex[1] << " " << f12.length() << " " << f12 << "\n";
105  //std::cout << "Force2: " << f12 << "\n";
106 
107  // Now add the forces to each force vector
108  p[0]->f[localIndex[0]] += f12;
109  p[1]->f[localIndex[1]] -= f12;
110 
111  DebugM(3, "::computeForce() -- ending with delta energy " << energy << std::endl);
112  reduction[gromacsPairEnergyIndex] += energy;
113  reduction[virialIndex_XX] += f12.x * r12.x;
114  reduction[virialIndex_XY] += f12.x * r12.y;
115  reduction[virialIndex_XZ] += f12.x * r12.z;
116  reduction[virialIndex_YX] += f12.y * r12.x;
117  reduction[virialIndex_YY] += f12.y * r12.y;
118  reduction[virialIndex_YZ] += f12.y * r12.z;
119  reduction[virialIndex_ZX] += f12.z * r12.x;
120  reduction[virialIndex_ZY] += f12.z * r12.y;
121  reduction[virialIndex_ZZ] += f12.z * r12.z;
122 
123  if (pressureProfileData) {
124  BigReal z1 = p[0]->x[localIndex[0]].position.z;
125  BigReal z2 = p[1]->x[localIndex[1]].position.z;
126  int n1 = (int)floor((z1-pressureProfileMin)/pressureProfileThickness);
127  int n2 = (int)floor((z2-pressureProfileMin)/pressureProfileThickness);
130  int p1 = p[0]->x[localIndex[0]].partition;
131  int p2 = p[1]->x[localIndex[1]].partition;
132  int pn = pressureProfileAtomTypes;
134  n1, n2,
135  p1, p2, pn,
136  f12.x * r12.x, f12.y * r12.y, f12.z * r12.z,
137  pressureProfileData);
138  }
139 
140  }
141 }
static Node * Object()
Definition: Node.h:86
unsigned char partition
Definition: NamdTypes.h:56
TuplePatchElem * p[size]
static int pressureProfileSlabs
const GromacsPairValue * value
int AtomID
Definition: NamdTypes.h:29
Lattice & lattice
Definition: Patch.h:126
void pp_reduction(int nslabs, int n1, int n2, int atype1, int atype2, int numtypes, BigReal vxx, BigReal vyy, BigReal vzz, BigReal *reduction)
Definition: Vector.h:64
SimParameters * simParameters
Definition: Node.h:178
float Real
Definition: common.h:107
#define DebugM(x, y)
Definition: Debug.h:59
BigReal z
Definition: Vector.h:66
Position position
Definition: NamdTypes.h:53
void pp_clamp(int &n, int nslabs)
Vector delta(const Position &pos1, const Position &pos2) const
Definition: Lattice.h:144
BigReal x
Definition: Vector.h:66
AtomID atomID[size]
BigReal length2(void) const
Definition: Vector.h:173
#define simParams
Definition: Output.C:127
BigReal y
Definition: Vector.h:66
static int pressureProfileAtomTypes
static BigReal pressureProfileThickness
gridSize x
static BigReal pressureProfileMin
double BigReal
Definition: common.h:112
void GromacsPairElem::getMoleculePointers ( Molecule mol,
int *  count,
int32 ***  byatom,
GromacsPair **  structarray 
)
static

Definition at line 27 of file ComputeGromacsPair.C.

References NAMD_die(), and Molecule::numLJPair.

28 {
29 #ifdef MEM_OPT_VERSION
30  NAMD_die("Should not be called in GromacsPairElem::getMoleculePointers in memory optimized version!");
31 #else
32  *count = mol->numLJPair;
33  *byatom = mol->gromacsPairByAtom;
34  *structarray = mol->gromacsPair;
35 #endif
36 }
void NAMD_die(const char *err_msg)
Definition: common.C:83
int numLJPair
Definition: Molecule.h:661
void GromacsPairElem::getParameterPointers ( Parameters p,
const GromacsPairValue **  v 
)
static

Definition at line 39 of file ComputeGromacsPair.C.

References Parameters::gromacsPair_array.

39  {
40  // JLai
41  *v=p->gromacsPair_array;
42 }
GromacsPairValue * gromacsPair_array
Definition: Parameters.h:247
static void GromacsPairElem::getTupleInfo ( AtomSignature sig,
int *  count,
TupleSignature **  t 
)
inlinestatic

Definition at line 37 of file ComputeGromacsPair.h.

References AtomSignature::gromacsPairCnt, and AtomSignature::gromacsPairSigs.

37  {
38  *count = sig->gromacsPairCnt;
39  *t = sig->gromacsPairSigs;
40  }
TupleSignature * gromacsPairSigs
Definition: structures.h:339
int gromacsPairCnt
Definition: structures.h:331
int GromacsPairElem::hash ( void  ) const
inline

Definition at line 48 of file ComputeGromacsPair.h.

References atomID.

48 { return 0x7FFFFFFF & ( (atomID[0]<<16) + (atomID[1])); }
AtomID atomID[size]
int GromacsPairElem::operator< ( const GromacsPairElem a) const
inline

Definition at line 41 of file ComputeGromacsPair.inl.

References atomID.

42  {
43  return (atomID[0] < a.atomID[0] ||
44  (atomID[0] == a.atomID[0] &&
45  (atomID[1] < a.atomID[1]) ));
46  }
AtomID atomID[size]
int GromacsPairElem::operator== ( const GromacsPairElem a) const
inline

Definition at line 36 of file ComputeGromacsPair.inl.

References atomID.

37  {
38  return (a.atomID[0] == atomID[0] && a.atomID[1] == atomID[1]);
39  }
AtomID atomID[size]
void GromacsPairElem::submitReductionData ( BigReal data,
SubmitReduction reduction 
)
static

Definition at line 143 of file ComputeGromacsPair.C.

References ADD_TENSOR, gromacsPairEnergyIndex, SubmitReduction::item(), and REDUCTION_GRO_LJ_ENERGY.

144 {
145  // JLai
147  ADD_TENSOR(reduction,REDUCTION_VIRIAL_NBOND,data,virialIndex);
148  return;
149 }
#define ADD_TENSOR(R, RL, D, DL)
Definition: ReductionMgr.h:32
BigReal & item(int i)
Definition: ReductionMgr.h:312

Member Data Documentation

AtomID GromacsPairElem::atomID[size]

Definition at line 27 of file ComputeGromacsPair.h.

Referenced by computeForce(), GromacsPairElem(), hash(), operator<(), and operator==().

int GromacsPairElem::localIndex[size]

Definition at line 28 of file ComputeGromacsPair.h.

Referenced by computeForce().

TuplePatchElem* GromacsPairElem::p[size]

Definition at line 29 of file ComputeGromacsPair.h.

Referenced by computeForce().

int GromacsPairElem::pressureProfileAtomTypes = 1
static

Definition at line 44 of file ComputeGromacsPair.h.

Referenced by computeForce().

BigReal GromacsPairElem::pressureProfileMin = 0
static

Definition at line 46 of file ComputeGromacsPair.h.

Referenced by computeForce().

int GromacsPairElem::pressureProfileSlabs = 0
static

Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by The Board of Trustees of the University of Illinois. All rights reserved.

Definition at line 43 of file ComputeGromacsPair.h.

Referenced by computeForce().

BigReal GromacsPairElem::pressureProfileThickness = 0
static

Definition at line 45 of file ComputeGromacsPair.h.

Referenced by computeForce().

Real GromacsPairElem::scale

Definition at line 30 of file ComputeGromacsPair.h.

Referenced by computeForce().

const GromacsPairValue* GromacsPairElem::value

Definition at line 51 of file ComputeGromacsPair.h.

Referenced by computeForce(), and GromacsPairElem().


The documentation for this class was generated from the following files: