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, SimParameters::singleTopology, size, Flags::step, value, TuplePatchElem::x, Vector::x, BondValue::x0, BondValue::x1, 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   Real x1 = value->x1;
00081 
00082   // compute vectors between atoms and their distances
00083   const Vector r12 = lattice.delta(p[0]->x[localIndex[0]].position,
00084                                         p[1]->x[localIndex[1]].position);
00085 
00086   if (0. == x0) {
00087     BigReal r2 = r12.length2();
00088     scal = -2.0*k;    // bond interaction for equilibrium length 0
00089     energy = k*r2;
00090     // TODO: Instead flag by mass for Drude particles, otherwise mixing and 
00091     // matching Drude and alchemical "twin" particles will likely not work as 
00092     // expected.
00093     if( simParams->drudeOn && !simParams->drudeHardWallOn ) { // for Drude bonds
00094       BigReal drudeBondLen = simParams->drudeBondLen;
00095       BigReal drudeBondConst = simParams->drudeBondConst;
00096       if ( drudeBondConst > 0 && r2 > drudeBondLen*drudeBondLen ) {
00097         // add a quartic restraining potential to keep Drude bond short
00098         BigReal r = sqrt(r2);
00099         BigReal diff = r - drudeBondLen;
00100         BigReal diff2 = diff*diff;
00101 
00102         scal += -4*drudeBondConst * diff2 * diff / r;
00103         energy += drudeBondConst * diff2 * diff2;
00104       }
00105     }
00106   }
00107   else {
00108     BigReal r = r12.length();  // Distance between atoms
00109     BigReal diff = r - x0;     // Compare it to the rest bond
00110 
00111     if (x1) {
00112       // in this case, the bond represents a harmonic wall potential
00113       // where x0 is the lower wall and x1 is the upper
00114       diff = (r > x1 ? r - x1 : (r > x0 ? 0 : diff));
00115     }
00116 
00117     //  Add the energy from this bond to the total energy
00118     energy = k*diff*diff;
00119 
00120     //  Determine the magnitude of the force
00121     diff *= -2.0*k;
00122 
00123     //  Scale the force vector accordingly
00124     scal = (diff/r);
00125   }
00126 
00127   //fepb - BKR scaling of alchemical bonded terms
00128   //       NB: TI derivative is the _unscaled_ energy.
00129   if ( simParams->alchOn && !simParams->singleTopology) {
00130     switch ( mol->get_fep_bonded_type(atomID, 2) ) {
00131     case 1:
00132       reduction[bondEnergyIndex_ti_1] += energy;
00133       reduction[bondEnergyIndex_f] += (bond_lambda_12 - bond_lambda_1)*energy;
00134       energy *= bond_lambda_1;
00135       scal *= bond_lambda_1;
00136       break;
00137     case 2:
00138       reduction[bondEnergyIndex_ti_2] += energy;
00139       reduction[bondEnergyIndex_f] += (bond_lambda_22 - bond_lambda_2)*energy;
00140       energy *= bond_lambda_2;
00141       scal *= bond_lambda_2;
00142       break;
00143     }
00144   }
00145   //fepe
00146   const Force f12 = scal * r12;
00147 
00148 
00149   //  Now add the forces to each force vector
00150   p[0]->f[localIndex[0]] += f12;
00151   p[1]->f[localIndex[1]] -= f12;
00152 
00153   DebugM(3, "::computeForce() -- ending with delta energy " << energy << std::endl);
00154   reduction[bondEnergyIndex] += energy;
00155   reduction[virialIndex_XX] += f12.x * r12.x;
00156   reduction[virialIndex_XY] += f12.x * r12.y;
00157   reduction[virialIndex_XZ] += f12.x * r12.z;
00158   reduction[virialIndex_YX] += f12.y * r12.x;
00159   reduction[virialIndex_YY] += f12.y * r12.y;
00160   reduction[virialIndex_YZ] += f12.y * r12.z;
00161   reduction[virialIndex_ZX] += f12.z * r12.x;
00162   reduction[virialIndex_ZY] += f12.z * r12.y;
00163   reduction[virialIndex_ZZ] += f12.z * r12.z;
00164 
00165   if (pressureProfileData) {
00166     BigReal z1 = p[0]->x[localIndex[0]].position.z;
00167     BigReal z2 = p[1]->x[localIndex[1]].position.z;
00168     int n1 = (int)floor((z1-pressureProfileMin)/pressureProfileThickness);
00169     int n2 = (int)floor((z2-pressureProfileMin)/pressureProfileThickness);
00170     pp_clamp(n1, pressureProfileSlabs);
00171     pp_clamp(n2, pressureProfileSlabs);
00172     int p1 = p[0]->x[localIndex[0]].partition;
00173     int p2 = p[1]->x[localIndex[1]].partition;
00174     int pn = pressureProfileAtomTypes;
00175     pp_reduction(pressureProfileSlabs,
00176                 n1, n2, 
00177                 p1, p2, pn, 
00178                 f12.x * r12.x, f12.y * r12.y, f12.z * r12.z,
00179                 pressureProfileData);
00180   } 
00181 
00182  }
00183 }

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 3 Jun 2020 for NAMD by  doxygen 1.6.1