BondElem Class Reference

#include <ComputeBonds.h>

List of all members.

Public Types

 size = 2
 bondEnergyIndex
 bondEnergyIndex_f
 bondEnergyIndex_ti_1
 bondEnergyIndex_ti_2
 virialIndex
 reductionDataSize
 reductionChecksumLabel = REDUCTION_BOND_CHECKSUM
enum  { size = 2 }
enum  {
  bondEnergyIndex, bondEnergyIndex_f, bondEnergyIndex_ti_1, bondEnergyIndex_ti_2,
  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 
virialIndex 
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 ,
int  ,
BigReal ,
BigReal  
) [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(), 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, 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->alchLambda2;
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) { // for Drude bonds
00093       BigReal drudeBondLen = simParams->drudeBondLen;
00094       BigReal drudeBondConst = simParams->drudeBondConst;
00095       if ( (drudeBondConst > 0) && ( ! simParams->drudeHardWallOn ) &&
00096           (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     //  Add the energy from this bond to the total energy
00112     energy = k*diff*diff;
00113 
00114     //  Determine the magnitude of the force
00115     diff *= -2.0*k;
00116 
00117     //  Scale the force vector accordingly
00118     scal = (diff/r);
00119   }
00120 
00121   //fepb - BKR scaling of alchemical bonded terms
00122   //       NB: TI derivative is the _unscaled_ energy.
00123   if ( simParams->alchOn ) {
00124     switch ( mol->get_fep_bonded_type(atomID, 2) ) {
00125     case 1:
00126       reduction[bondEnergyIndex_ti_1] += energy;
00127       reduction[bondEnergyIndex_f] += (bond_lambda_12 - bond_lambda_1)*energy;
00128       energy *= bond_lambda_1;
00129       scal *= bond_lambda_1;
00130       break;
00131     case 2:
00132       reduction[bondEnergyIndex_ti_2] += energy;
00133       reduction[bondEnergyIndex_f] += (bond_lambda_22 - bond_lambda_2)*energy;
00134       energy *= bond_lambda_2;
00135       scal *= bond_lambda_2;
00136       break;
00137     }
00138   }
00139   //fepe
00140   const Force f12 = scal * r12;
00141 
00142 
00143   //  Now add the forces to each force vector
00144   p[0]->f[localIndex[0]] += f12;
00145   p[1]->f[localIndex[1]] -= f12;
00146 
00147   DebugM(3, "::computeForce() -- ending with delta energy " << energy << std::endl);
00148   reduction[bondEnergyIndex] += energy;
00149   reduction[virialIndex_XX] += f12.x * r12.x;
00150   reduction[virialIndex_XY] += f12.x * r12.y;
00151   reduction[virialIndex_XZ] += f12.x * r12.z;
00152   reduction[virialIndex_YX] += f12.y * r12.x;
00153   reduction[virialIndex_YY] += f12.y * r12.y;
00154   reduction[virialIndex_YZ] += f12.y * r12.z;
00155   reduction[virialIndex_ZX] += f12.z * r12.x;
00156   reduction[virialIndex_ZY] += f12.z * r12.y;
00157   reduction[virialIndex_ZZ] += f12.z * r12.z;
00158 
00159   if (pressureProfileData) {
00160     BigReal z1 = p[0]->x[localIndex[0]].position.z;
00161     BigReal z2 = p[1]->x[localIndex[1]].position.z;
00162     int n1 = (int)floor((z1-pressureProfileMin)/pressureProfileThickness);
00163     int n2 = (int)floor((z2-pressureProfileMin)/pressureProfileThickness);
00164     pp_clamp(n1, pressureProfileSlabs);
00165     pp_clamp(n2, pressureProfileSlabs);
00166     int p1 = p[0]->x[localIndex[0]].partition;
00167     int p2 = p[1]->x[localIndex[1]].partition;
00168     int pn = pressureProfileAtomTypes;
00169     pp_reduction(pressureProfileSlabs,
00170                 n1, n2, 
00171                 p1, p2, pn, 
00172                 f12.x * r12.x, f12.y * r12.y, f12.z * r12.z,
00173                 pressureProfileData);
00174   } 
00175 
00176  }
00177 }

void BondElem::getMoleculePointers ( Molecule ,
int *  ,
int32 ***  ,
Bond **   
) [static]

Definition at line 25 of file ComputeBonds.C.

References Molecule::bonds, Molecule::bondsByAtom, 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 ,
const BondValue **   
) [static]

Definition at line 36 of file ComputeBonds.C.

References p.

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 ,
SubmitReduction  
) [static]

Definition at line 179 of file ComputeBonds.C.

References ADD_TENSOR, bondEnergyIndex, bondEnergyIndex_f, bondEnergyIndex_ti_1, bondEnergyIndex_ti_2, SubmitReduction::item(), REDUCTION_BOND_ENERGY, REDUCTION_BONDED_ENERGY_F, REDUCTION_BONDED_ENERGY_TI_1, REDUCTION_BONDED_ENERGY_TI_2, REDUCTION_VIRIAL_NORMAL, and virialIndex.

00180 {
00181   reduction->item(REDUCTION_BOND_ENERGY) += data[bondEnergyIndex];
00182   reduction->item(REDUCTION_BONDED_ENERGY_F) += data[bondEnergyIndex_f];
00183   reduction->item(REDUCTION_BONDED_ENERGY_TI_1) += data[bondEnergyIndex_ti_1];
00184   reduction->item(REDUCTION_BONDED_ENERGY_TI_2) += data[bondEnergyIndex_ti_2];
00185   ADD_TENSOR(reduction,REDUCTION_VIRIAL_NORMAL,data,virialIndex);
00186 }


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(), and getParameterPointers().

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:
Generated on Sat Sep 23 01:17:17 2017 for NAMD by  doxygen 1.4.7