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
Enumerator
size 

Definition at line 23 of file ComputeBonds.h.

23 { size = 2 };
anonymous enum
Enumerator
bondEnergyIndex 
bondEnergyIndex_f 
bondEnergyIndex_ti_1 
bondEnergyIndex_ti_2 
TENSOR 
reductionDataSize 

Definition at line 48 of file ComputeBonds.h.

anonymous enum
Enumerator
reductionChecksumLabel 

Definition at line 50 of file ComputeBonds.h.

Constructor & Destructor Documentation

BondElem::BondElem ( )
inline

Definition at line 12 of file ComputeBonds.inl.

12 { ; }
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:202
const BondValue * value
Definition: ComputeBonds.h:46
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:48
const BondValue * value
Definition: ComputeBonds.h:46
Index bond_type
Definition: structures.h:50
int32 atom2
Definition: structures.h:49
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  }
int AtomID
Definition: NamdTypes.h:29
AtomID atomID[size]
Definition: ComputeBonds.h:24
BondElem::~BondElem ( )
inline

Definition at line 57 of file ComputeBonds.h.

57 {};

Member Function Documentation

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

Definition at line 40 of file ComputeBonds.C.

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

Definition at line 36 of file ComputeBonds.C.

References Parameters::bond_array.

36  {
37  *v = p->bond_array;
38 }
BondValue * bond_array
Definition: Parameters.h:243
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:333
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
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
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
void BondElem::submitReductionData ( BigReal data,
SubmitReduction reduction 
)
static

Member Data Documentation

AtomID BondElem::atomID[size]

Definition at line 24 of file ComputeBonds.h.

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

int BondElem::localIndex[size]

Definition at line 25 of file ComputeBonds.h.

Referenced by computeForce().

TuplePatchElem* BondElem::p[size]

Definition at line 26 of file ComputeBonds.h.

Referenced by computeForce().

int BondElem::pressureProfileAtomTypes = 1
static

Definition at line 39 of file ComputeBonds.h.

Referenced by computeForce().

BigReal BondElem::pressureProfileMin = 0
static

Definition at line 41 of file ComputeBonds.h.

Referenced by computeForce().

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().

BigReal BondElem::pressureProfileThickness = 0
static

Definition at line 40 of file ComputeBonds.h.

Referenced by computeForce().

Real BondElem::scale

Definition at line 27 of file ComputeBonds.h.

Referenced by computeForce().

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: