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

#include <ComputeBonds.h>

Public Types

enum  { size = 2 }
 
enum  {
  bondEnergyIndex, bondEnergyIndex_f, bondEnergyIndex_ti_1, bondEnergyIndex_ti_2,
  TENSOR =(virialIndex), reductionDataSize
}
 
enum  { reductionChecksumLabel = REDUCTION_BOND_CHECKSUM }
 

Public Member Functions

int hash () const
 
 BondElem ()
 
 BondElem (AtomID atom0, const TupleSignature *sig, const BondValue *v)
 
 BondElem (const Bond *a, const BondValue *v)
 
 BondElem (AtomID atom0, AtomID atom1)
 
 ~BondElem ()
 
int operator== (const BondElem &a) const
 
int operator< (const BondElem &a) const
 

Static Public Member Functions

static void computeForce (BondElem *, int, BigReal *, BigReal *)
 
static void getMoleculePointers (Molecule *, int *, int32 ***, Bond **)
 
static void getParameterPointers (Parameters *, const BondValue **)
 
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 BondValuevalue
 

Static Public Attributes

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

Detailed Description

Definition at line 20 of file ComputeBonds.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
size 

Definition at line 23 of file ComputeBonds.h.

23 { size = 2 };

◆ anonymous enum

anonymous enum
Enumerator
bondEnergyIndex 
bondEnergyIndex_f 
bondEnergyIndex_ti_1 
bondEnergyIndex_ti_2 
TENSOR 
reductionDataSize 

Definition at line 48 of file ComputeBonds.h.

◆ anonymous enum

anonymous enum
Enumerator
reductionChecksumLabel 

Definition at line 50 of file ComputeBonds.h.

Constructor & Destructor Documentation

◆ BondElem() [1/4]

BondElem::BondElem ( )
inline

Definition at line 12 of file ComputeBonds.inl.

12 { ; }

◆ BondElem() [2/4]

BondElem::BondElem ( AtomID  atom0,
const TupleSignature sig,
const BondValue v 
)
inline

Definition at line 14 of file ComputeBonds.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 }
AtomID atomID[size]
Definition: ComputeBonds.h:24
Index tupleParamType
Definition: structures.h:204
const BondValue * value
Definition: ComputeBonds.h:46

◆ BondElem() [3/4]

BondElem::BondElem ( const Bond a,
const BondValue v 
)
inline

Definition at line 20 of file ComputeBonds.inl.

References bond::atom1, bond::atom2, atomID, bond::bond_type, and value.

21  {
22  atomID[0] = a->atom1;
23  atomID[1] = a->atom2;
24  value = &v[a->bond_type];
25  }
AtomID atomID[size]
Definition: ComputeBonds.h:24
int32 atom1
Definition: structures.h:50
const BondValue * value
Definition: ComputeBonds.h:46
Index bond_type
Definition: structures.h:52
int32 atom2
Definition: structures.h:51

◆ BondElem() [4/4]

BondElem::BondElem ( AtomID  atom0,
AtomID  atom1 
)
inline

Definition at line 27 of file ComputeBonds.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  }
AtomID atomID[size]
Definition: ComputeBonds.h:24
int32 AtomID
Definition: NamdTypes.h:35

◆ ~BondElem()

BondElem::~BondElem ( )
inline

Definition at line 57 of file ComputeBonds.h.

57 {};

Member Function Documentation

◆ computeForce()

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

Definition at line 40 of file ComputeBonds.C.

References atomID, bondEnergyIndex, bondEnergyIndex_f, bondEnergyIndex_ti_1, bondEnergyIndex_ti_2, DebugM, Lattice::delta(), TuplePatchElem::f, Patch::flags, Molecule::get_fep_bonded_type(), BondValue::k, Patch::lattice, Vector::length(), Vector::length2(), localIndex, Node::molecule, Node::Object(), p, TuplePatchElem::p, CompAtom::partition, CompAtom::position, pp_clamp(), pp_reduction(), pressureProfileAtomTypes, pressureProfileMin, pressureProfileSlabs, pressureProfileThickness, scale, Node::simParameters, simParams, size, Flags::step, value, TuplePatchElem::x, Vector::x, BondValue::x0, BondValue::x1, Vector::y, and Vector::z.

42 {
44  const Lattice & lattice = tuples[0].p[0]->p->lattice;
45 
46  //fepb BKR
47  const int step = tuples[0].p[0]->p->flags.step;
48  const BigReal alchLambda = simParams->getCurrentLambda(step);
49  const BigReal alchLambda2 = simParams->getCurrentLambda2(step);
50  const BigReal bond_lambda_1 = simParams->getBondLambda(alchLambda);
51  const BigReal bond_lambda_2 = simParams->getBondLambda(1-alchLambda);
52  const BigReal bond_lambda_12 = simParams->getBondLambda(alchLambda2);
53  const BigReal bond_lambda_22 = simParams->getBondLambda(1-alchLambda2);
54  Molecule *const mol = Node::Object()->molecule;
55  //fepe
56 
57  for ( int ituple=0; ituple<ntuple; ++ituple ) {
58  const BondElem &tup = tuples[ituple];
59  enum { size = 2 };
60  const AtomID (&atomID)[size](tup.atomID);
61  const int (&localIndex)[size](tup.localIndex);
62  TuplePatchElem * const(&p)[size](tup.p);
63  const Real (&scale)(tup.scale);
64  const BondValue * const(&value)(tup.value);
65 
66 #if defined(DEBUG_PROTOCELL)
67  if ((PRMIN <= atomID[0] && atomID[0] <= PRMAX) &&
68  (PRMIN <= atomID[1] && atomID[1] <= PRMAX)) {
69  int i = atomID[0];
70  int j = atomID[1];
71  if (atomID[1] < atomID[0]) {
72  i = atomID[1];
73  j = atomID[0];
74  }
75  double k = value->k;
76  double r0 = value->x0;
77  CkPrintf("%11d %11d k=%g r0=%g\n", i, j, k, r0);
78  }
79 #endif
80 
81  DebugM(1, "::computeForce() localIndex = " << localIndex[0] << " "
82  << localIndex[1] << std::endl);
83 
84  // skip Lonepair bonds (other k=0. bonds have been filtered out)
85  if (0. == value->k) continue;
86 
87  BigReal scal; // force scaling
88  BigReal energy; // energy from the bond
89 
90  //DebugM(3, "::computeForce() -- starting with bond type " << bondType << std::endl);
91 
92  // get the bond information
93  Real k = value->k * scale;
94  Real x0 = value->x0;
95  Real x1 = value->x1;
96 
97  // compute vectors between atoms and their distances
98  const Vector r12 = lattice.delta(p[0]->x[localIndex[0]].position,
99  p[1]->x[localIndex[1]].position);
100 
101  if (0. == x0) {
102  BigReal r2 = r12.length2();
103  scal = -2.0*k; // bond interaction for equilibrium length 0
104  energy = k*r2;
105  // TODO: Instead flag by mass for Drude particles, otherwise mixing and
106  // matching Drude and alchemical "twin" particles will likely not work as
107  // expected.
108  if( simParams->drudeOn && !simParams->drudeHardWallOn ) { // for Drude bonds
109  BigReal drudeBondLen = simParams->drudeBondLen;
110  BigReal drudeBondConst = simParams->drudeBondConst;
111  if ( drudeBondConst > 0 && r2 > drudeBondLen*drudeBondLen ) {
112  // add a quartic restraining potential to keep Drude bond short
113  BigReal r = sqrt(r2);
114  BigReal diff = r - drudeBondLen;
115  BigReal diff2 = diff*diff;
116 
117  scal += -4*drudeBondConst * diff2 * diff / r;
118  energy += drudeBondConst * diff2 * diff2;
119  }
120  }
121  }
122  else {
123  BigReal r = r12.length(); // Distance between atoms
124  BigReal diff = r - x0; // Compare it to the rest bond
125 
126  if (x1) {
127  // in this case, the bond represents a harmonic wall potential
128  // where x0 is the lower wall and x1 is the upper
129  diff = (r > x1 ? r - x1 : (r > x0 ? 0 : diff));
130  }
131 
132  // Add the energy from this bond to the total energy
133  energy = k*diff*diff;
134 
135  // Determine the magnitude of the force
136  diff *= -2.0*k;
137 
138  // Scale the force vector accordingly
139  scal = (diff/r);
140  }
141 
142  //fepb - BKR scaling of alchemical bonded terms
143  // NB: TI derivative is the _unscaled_ energy.
144  if ( simParams->alchOn && !simParams->singleTopology) {
145  switch ( mol->get_fep_bonded_type(atomID, 2) ) {
146  case 1:
147  reduction[bondEnergyIndex_ti_1] += energy;
148  reduction[bondEnergyIndex_f] += (bond_lambda_12 - bond_lambda_1)*energy;
149  energy *= bond_lambda_1;
150  scal *= bond_lambda_1;
151  break;
152  case 2:
153  reduction[bondEnergyIndex_ti_2] += energy;
154  reduction[bondEnergyIndex_f] += (bond_lambda_22 - bond_lambda_2)*energy;
155  energy *= bond_lambda_2;
156  scal *= bond_lambda_2;
157  break;
158  }
159  }
160  //fepe
161  const Force f12 = scal * r12;
162 
163 
164  // Now add the forces to each force vector
165  p[0]->f[localIndex[0]] += f12;
166  p[1]->f[localIndex[1]] -= f12;
167 
168  DebugM(3, "::computeForce() -- ending with delta energy " << energy << std::endl);
169  reduction[bondEnergyIndex] += energy;
170  reduction[virialIndex_XX] += f12.x * r12.x;
171  reduction[virialIndex_XY] += f12.x * r12.y;
172  reduction[virialIndex_XZ] += f12.x * r12.z;
173  reduction[virialIndex_YX] += f12.y * r12.x;
174  reduction[virialIndex_YY] += f12.y * r12.y;
175  reduction[virialIndex_YZ] += f12.y * r12.z;
176  reduction[virialIndex_ZX] += f12.z * r12.x;
177  reduction[virialIndex_ZY] += f12.z * r12.y;
178  reduction[virialIndex_ZZ] += f12.z * r12.z;
179 
180  if (pressureProfileData) {
181  BigReal z1 = p[0]->x[localIndex[0]].position.z;
182  BigReal z2 = p[1]->x[localIndex[1]].position.z;
183  int n1 = (int)floor((z1-pressureProfileMin)/pressureProfileThickness);
184  int n2 = (int)floor((z2-pressureProfileMin)/pressureProfileThickness);
187  int p1 = p[0]->x[localIndex[0]].partition;
188  int p2 = p[1]->x[localIndex[1]].partition;
189  int pn = pressureProfileAtomTypes;
191  n1, n2,
192  p1, p2, pn,
193  f12.x * r12.x, f12.y * r12.y, f12.z * r12.z,
194  pressureProfileData);
195  }
196 
197  }
198 }
static Node * Object()
Definition: Node.h:86
Lattice & lattice
Definition: Patch.h:127
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:72
SimParameters * simParameters
Definition: Node.h:181
float Real
Definition: common.h:118
#define DebugM(x, y)
Definition: Debug.h:75
BigReal z
Definition: Vector.h:74
Position position
Definition: NamdTypes.h:77
static int pressureProfileAtomTypes
Definition: ComputeBonds.h:39
Real scale
Definition: ComputeBonds.h:27
Molecule stores the structural information for the system.
Definition: Molecule.h:175
AtomID atomID[size]
Definition: ComputeBonds.h:24
static BigReal pressureProfileMin
Definition: ComputeBonds.h:41
static BigReal pressureProfileThickness
Definition: ComputeBonds.h:40
Flags flags
Definition: Patch.h:128
void pp_clamp(int &n, int nslabs)
int localIndex[size]
Definition: ComputeBonds.h:25
NAMD_HOST_DEVICE BigReal length(void) const
Definition: Vector.h:202
NAMD_HOST_DEVICE BigReal length2(void) const
Definition: Vector.h:206
uint8 partition
Definition: NamdTypes.h:80
BigReal x
Definition: Vector.h:74
int get_fep_bonded_type(const int *atomID, unsigned int order) const
Definition: Molecule.h:1477
static int pressureProfileSlabs
Definition: ComputeBonds.h:38
#define simParams
Definition: Output.C:129
int32 AtomID
Definition: NamdTypes.h:35
BigReal y
Definition: Vector.h:74
const BondValue * value
Definition: ComputeBonds.h:46
TuplePatchElem * p[size]
Definition: ComputeBonds.h:26
Molecule * molecule
Definition: Node.h:179
double BigReal
Definition: common.h:123
NAMD_HOST_DEVICE Vector delta(const Position &pos1, const Position &pos2) const
Definition: Lattice.h:149
int step
Definition: PatchTypes.h:16

◆ getMoleculePointers()

void BondElem::getMoleculePointers ( Molecule mol,
int *  count,
int32 ***  byatom,
Bond **  structarray 
)
static

Definition at line 25 of file ComputeBonds.C.

References NAMD_die(), and Molecule::numBonds.

26 {
27 #ifdef MEM_OPT_VERSION
28  NAMD_die("Should not be called in BondElem::getMoleculePointers in memory optimized version!");
29 #else
30  *count = mol->numBonds;
31  *byatom = mol->bondsByAtom;
32  *structarray = mol->bonds;
33 #endif
34 }
int numBonds
Definition: Molecule.h:588
void NAMD_die(const char *err_msg)
Definition: common.C:147

◆ getParameterPointers()

void BondElem::getParameterPointers ( Parameters p,
const BondValue **  v 
)
static

Definition at line 36 of file ComputeBonds.C.

References p.

36  {
37  *v = p->bond_array;
38 }
TuplePatchElem * p[size]
Definition: ComputeBonds.h:26

◆ getTupleInfo()

static void BondElem::getTupleInfo ( AtomSignature sig,
int *  count,
TupleSignature **  t 
)
inlinestatic

Definition at line 32 of file ComputeBonds.h.

References AtomSignature::bondCnt, and AtomSignature::bondSigs.

32  {
33  *count = sig->bondCnt;
34  *t = sig->bondSigs;
35  }
TupleSignature * bondSigs
Definition: structures.h:335

◆ hash()

int BondElem::hash ( void  ) const
inline

Definition at line 43 of file ComputeBonds.h.

References atomID.

43 { return 0x7FFFFFFF & ( (atomID[0]<<16) + (atomID[1])); }
AtomID atomID[size]
Definition: ComputeBonds.h:24

◆ operator<()

int BondElem::operator< ( const BondElem a) const
inline

Definition at line 41 of file ComputeBonds.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]
Definition: ComputeBonds.h:24

◆ operator==()

int BondElem::operator== ( const BondElem a) const
inline

Definition at line 36 of file ComputeBonds.inl.

References atomID.

37  {
38  return (a.atomID[0] == atomID[0] && a.atomID[1] == atomID[1]);
39  }
AtomID atomID[size]
Definition: ComputeBonds.h:24

◆ submitReductionData()

void BondElem::submitReductionData ( BigReal data,
SubmitReduction reduction 
)
static

Member Data Documentation

◆ atomID

AtomID BondElem::atomID[size]

Definition at line 24 of file ComputeBonds.h.

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

◆ localIndex

int BondElem::localIndex[size]

Definition at line 25 of file ComputeBonds.h.

Referenced by computeForce().

◆ p

TuplePatchElem* BondElem::p[size]

Definition at line 26 of file ComputeBonds.h.

Referenced by computeForce(), and getParameterPointers().

◆ pressureProfileAtomTypes

int BondElem::pressureProfileAtomTypes = 1
static

Definition at line 39 of file ComputeBonds.h.

Referenced by computeForce().

◆ pressureProfileMin

BigReal BondElem::pressureProfileMin = 0
static

Definition at line 41 of file ComputeBonds.h.

Referenced by computeForce().

◆ pressureProfileSlabs

int BondElem::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 38 of file ComputeBonds.h.

Referenced by computeForce().

◆ pressureProfileThickness

BigReal BondElem::pressureProfileThickness = 0
static

Definition at line 40 of file ComputeBonds.h.

Referenced by computeForce().

◆ scale

Real BondElem::scale

Definition at line 27 of file ComputeBonds.h.

Referenced by computeForce().

◆ value

const BondValue* BondElem::value

Definition at line 46 of file ComputeBonds.h.

Referenced by BondElem(), and computeForce().


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