BondElem Class Reference

#include <ComputeBonds.h>

List of all members.

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.

00023 { 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]

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

Definition at line 12 of file ComputeBonds.inl.

00012 { ; }

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.

00014                                                                                     {
00015     atomID[0] = atom0;
00016     atomID[1] = atom0 + sig->offset[0];
00017     value = &v[sig->tupleParamType];
00018 }

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.

00021   {
00022     atomID[0] = a->atom1;
00023     atomID[1] = a->atom2;
00024     value = &v[a->bond_type];
00025   }

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

Definition at line 27 of file ComputeBonds.inl.

References atomID.

00028   {
00029     if (atom0 > atom1) {  // Swap end atoms so lowest is first!
00030       AtomID tmp = atom1; atom1 = atom0; atom0 = tmp; 
00031     }
00032     atomID[0] = atom0;
00033     atomID[1] = atom1;
00034   }

BondElem::~BondElem (  )  [inline]

Definition at line 57 of file ComputeBonds.h.

00057 {};


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(), TuplePatchElem::p, 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, Vector::y, and Vector::z.

00042 {
00043  SimParameters *const simParams = Node::Object()->simParameters;
00044  const Lattice & lattice = tuples[0].p[0]->p->lattice;
00045 
00046  //fepb BKR
00047  const int step = tuples[0].p[0]->p->flags.step;
00048  const BigReal alchLambda = simParams->getCurrentLambda(step);
00049  const BigReal alchLambda2 = simParams->getCurrentLambda2(step);
00050  const BigReal bond_lambda_1 = simParams->getBondLambda(alchLambda);
00051  const BigReal bond_lambda_2 = simParams->getBondLambda(1-alchLambda);
00052  const BigReal bond_lambda_12 = simParams->getBondLambda(alchLambda2);
00053  const BigReal bond_lambda_22 = simParams->getBondLambda(1-alchLambda2);
00054  Molecule *const mol = Node::Object()->molecule;
00055  //fepe
00056 
00057  for ( int ituple=0; ituple<ntuple; ++ituple ) {
00058   const BondElem &tup = tuples[ituple];
00059   enum { size = 2 };
00060   const AtomID (&atomID)[size](tup.atomID);
00061   const int    (&localIndex)[size](tup.localIndex);
00062   TuplePatchElem * const(&p)[size](tup.p);
00063   const Real (&scale)(tup.scale);
00064   const BondValue * const(&value)(tup.value);
00065 
00066   DebugM(1, "::computeForce() localIndex = " << localIndex[0] << " "
00067                << localIndex[1] << std::endl);
00068 
00069   // skip Lonepair bonds (other k=0. bonds have been filtered out)
00070   if (0. == value->k) continue;
00071 
00072   BigReal scal;         // force scaling
00073   BigReal energy;       // energy from the bond
00074 
00075   //DebugM(3, "::computeForce() -- starting with bond type " << bondType << std::endl);
00076 
00077   // get the bond information
00078   Real k = value->k * scale;
00079   Real x0 = value->x0;
00080 
00081   // compute vectors between atoms and their distances
00082   const Vector r12 = lattice.delta(p[0]->x[localIndex[0]].position,
00083                                         p[1]->x[localIndex[1]].position);
00084 
00085   if (0. == x0) {
00086     BigReal r2 = r12.length2();
00087     scal = -2.0*k;    // bond interaction for equilibrium length 0
00088     energy = k*r2;
00089     // TODO: Instead flag by mass for Drude particles, otherwise mixing and 
00090     // matching Drude and alchemical "twin" particles will likely not work as 
00091     // expected.
00092     if( simParams->drudeOn && !simParams->drudeHardWallOn ) { // for Drude bonds
00093       BigReal drudeBondLen = simParams->drudeBondLen;
00094       BigReal drudeBondConst = simParams->drudeBondConst;
00095       if ( drudeBondConst > 0 && r2 > drudeBondLen*drudeBondLen ) {
00096         // add a quartic restraining potential to keep Drude bond short
00097         BigReal r = sqrt(r2);
00098         BigReal diff = r - drudeBondLen;
00099         BigReal diff2 = diff*diff;
00100 
00101         scal += -4*drudeBondConst * diff2 * diff / r;
00102         energy += drudeBondConst * diff2 * diff2;
00103       }
00104     }
00105   }
00106   else {
00107     BigReal r = r12.length();  // Distance between atoms
00108     BigReal diff = r - x0;     // Compare it to the rest bond
00109 
00110     //  Add the energy from this bond to the total energy
00111     energy = k*diff*diff;
00112 
00113     //  Determine the magnitude of the force
00114     diff *= -2.0*k;
00115 
00116     //  Scale the force vector accordingly
00117     scal = (diff/r);
00118   }
00119 
00120   //fepb - BKR scaling of alchemical bonded terms
00121   //       NB: TI derivative is the _unscaled_ energy.
00122   if ( simParams->alchOn ) {
00123     switch ( mol->get_fep_bonded_type(atomID, 2) ) {
00124     case 1:
00125       reduction[bondEnergyIndex_ti_1] += energy;
00126       reduction[bondEnergyIndex_f] += (bond_lambda_12 - bond_lambda_1)*energy;
00127       energy *= bond_lambda_1;
00128       scal *= bond_lambda_1;
00129       break;
00130     case 2:
00131       reduction[bondEnergyIndex_ti_2] += energy;
00132       reduction[bondEnergyIndex_f] += (bond_lambda_22 - bond_lambda_2)*energy;
00133       energy *= bond_lambda_2;
00134       scal *= bond_lambda_2;
00135       break;
00136     }
00137   }
00138   //fepe
00139   const Force f12 = scal * r12;
00140 
00141 
00142   //  Now add the forces to each force vector
00143   p[0]->f[localIndex[0]] += f12;
00144   p[1]->f[localIndex[1]] -= f12;
00145 
00146   DebugM(3, "::computeForce() -- ending with delta energy " << energy << std::endl);
00147   reduction[bondEnergyIndex] += energy;
00148   reduction[virialIndex_XX] += f12.x * r12.x;
00149   reduction[virialIndex_XY] += f12.x * r12.y;
00150   reduction[virialIndex_XZ] += f12.x * r12.z;
00151   reduction[virialIndex_YX] += f12.y * r12.x;
00152   reduction[virialIndex_YY] += f12.y * r12.y;
00153   reduction[virialIndex_YZ] += f12.y * r12.z;
00154   reduction[virialIndex_ZX] += f12.z * r12.x;
00155   reduction[virialIndex_ZY] += f12.z * r12.y;
00156   reduction[virialIndex_ZZ] += f12.z * r12.z;
00157 
00158   if (pressureProfileData) {
00159     BigReal z1 = p[0]->x[localIndex[0]].position.z;
00160     BigReal z2 = p[1]->x[localIndex[1]].position.z;
00161     int n1 = (int)floor((z1-pressureProfileMin)/pressureProfileThickness);
00162     int n2 = (int)floor((z2-pressureProfileMin)/pressureProfileThickness);
00163     pp_clamp(n1, pressureProfileSlabs);
00164     pp_clamp(n2, pressureProfileSlabs);
00165     int p1 = p[0]->x[localIndex[0]].partition;
00166     int p2 = p[1]->x[localIndex[1]].partition;
00167     int pn = pressureProfileAtomTypes;
00168     pp_reduction(pressureProfileSlabs,
00169                 n1, n2, 
00170                 p1, p2, pn, 
00171                 f12.x * r12.x, f12.y * r12.y, f12.z * r12.z,
00172                 pressureProfileData);
00173   } 
00174 
00175  }
00176 }

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.

00026 {
00027 #ifdef MEM_OPT_VERSION
00028   NAMD_die("Should not be called in BondElem::getMoleculePointers in memory optimized version!");
00029 #else
00030   *count = mol->numBonds;
00031   *byatom = mol->bondsByAtom;
00032   *structarray = mol->bonds;
00033 #endif
00034 }

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

Definition at line 36 of file ComputeBonds.C.

References Parameters::bond_array.

00036                                                                       {
00037   *v = p->bond_array;
00038 }

static void BondElem::getTupleInfo ( AtomSignature sig,
int *  count,
TupleSignature **  t 
) [inline, static]

Definition at line 32 of file ComputeBonds.h.

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

00032                                                                                  {
00033         *count = sig->bondCnt;
00034         *t = sig->bondSigs;
00035     }

int BondElem::hash ( void   )  const [inline]

Definition at line 43 of file ComputeBonds.h.

References atomID.

00043 { return 0x7FFFFFFF & ( (atomID[0]<<16) + (atomID[1])); }

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

Definition at line 41 of file ComputeBonds.inl.

References atomID.

00042   {
00043     return (atomID[0] < a.atomID[0] ||
00044             (atomID[0] == a.atomID[0] &&
00045             (atomID[1] < a.atomID[1]) ));
00046   }

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

Definition at line 36 of file ComputeBonds.inl.

References atomID.

00037   {
00038     return (a.atomID[0] == atomID[0] && a.atomID[1] == atomID[1]);
00039   }

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

Member Data Documentation

Definition at line 24 of file ComputeBonds.h.

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

Definition at line 25 of file ComputeBonds.h.

Referenced by computeForce().

Definition at line 26 of file ComputeBonds.h.

Referenced by computeForce().

Definition at line 39 of file ComputeBonds.h.

Referenced by computeForce().

Definition at line 41 of file ComputeBonds.h.

Referenced by computeForce().

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

Definition at line 40 of file ComputeBonds.h.

Referenced by computeForce().

Definition at line 27 of file ComputeBonds.h.

Referenced by computeForce().

Definition at line 46 of file ComputeBonds.h.

Referenced by BondElem(), and computeForce().


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

Generated on 22 Apr 2019 for NAMD by  doxygen 1.6.1