Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

BondElem Class Reference

#include <ComputeBonds.h>

List of all members.

Public Types

enum  { size = 2 }
enum  { bondEnergyIndex, virialIndex, reductionDataSize }
enum  { reductionChecksumLabel = REDUCTION_BOND_CHECKSUM }

Public Member Functions

void computeForce (BigReal *, BigReal *)
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

void getMoleculePointers (Molecule *, int *, int32 ***, Bond **)
void getParameterPointers (Parameters *, const BondValue **)
void getTupleInfo (AtomSignature *sig, int *count, TupleSignature **t)
void submitReductionData (BigReal *, SubmitReduction *)

Public Attributes

AtomID atomID [size]
int localIndex [size]
TuplePatchElemp [size]
Real scale
const BondValuevalue

Static Public Attributes

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


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
size 

Definition at line 23 of file ComputeBonds.h.

00023 { size = 2 };

anonymous enum
 

Enumeration values:
bondEnergyIndex 
virialIndex 
reductionDataSize 

Definition at line 48 of file ComputeBonds.h.

00048 { bondEnergyIndex, TENSOR(virialIndex), reductionDataSize };

anonymous enum
 

Enumeration values:
reductionChecksumLabel 

Definition at line 49 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::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, and 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 56 of file ComputeBonds.h.

00056 {};


Member Function Documentation

void BondElem::computeForce BigReal ,
BigReal
 

Definition at line 40 of file ComputeBonds.C.

References BigReal, DebugM, Lattice::delta(), SimParameters::drudeBondConst, SimParameters::drudeBondLen, TuplePatchElem::f, Force, BondValue::k, Patch::lattice, Vector::length(), Vector::length2(), localIndex, Node::Object(), TuplePatchElem::p, p, CompAtom::partition, CompAtom::position, pp_clamp(), pp_reduction(), pressureProfileMin, pressureProfileSlabs, pressureProfileThickness, Real, Node::simParameters, simParams, value, TuplePatchElem::x, Vector::x, BondValue::x0, Vector::y, and Vector::z.

00042 {
00043   DebugM(1, "::computeForce() localIndex = " << localIndex[0] << " "
00044                << localIndex[1] << std::endl);
00045 
00046   // skip Lonepair bonds (other k=0. bonds have been filtered out)
00047   if (0. == value->k) return;
00048 
00049   BigReal scal;         // force scaling
00050   BigReal energy;       // energy from the bond
00051 
00052   //DebugM(3, "::computeForce() -- starting with bond type " << bondType << std::endl);
00053 
00054   // get the bond information
00055   Real k = value->k * scale;
00056   Real x0 = value->x0;
00057 
00058   // compute vectors between atoms and their distances
00059   const Lattice & lattice = p[0]->p->lattice;
00060   const Vector r12 = lattice.delta(p[0]->x[localIndex[0]].position,
00061                                         p[1]->x[localIndex[1]].position);
00062 
00063   if (0. == x0) {  // for Drude bonds
00064     SimParameters *simParams = Node::Object()->simParameters;
00065     BigReal drudeBondLen = simParams->drudeBondLen;
00066     BigReal drudeBondConst = simParams->drudeBondConst;
00067 
00068     BigReal r2 = r12.length2();
00069 
00070     scal = -2.0*k;    // bond interaction for equilibrium length 0
00071     energy = k * r2;
00072 
00073     if (drudeBondConst > 0 && r2 > drudeBondLen*drudeBondLen) {
00074       // add a quartic restraining potential to keep Drude bond short
00075       BigReal r = sqrt(r2);
00076       BigReal diff = r - drudeBondLen;
00077       BigReal diff2 = diff*diff;
00078 
00079       scal += -4*drudeBondConst * diff2 * diff / r;
00080       energy += drudeBondConst * diff2 * diff2;
00081     }
00082   }
00083   else {
00084     BigReal r = r12.length();  // Distance between atoms
00085     BigReal diff = r - x0;     // Compare it to the rest bond
00086 
00087     //  Add the energy from this bond to the total energy
00088     energy = k*diff*diff;
00089 
00090     //  Determine the magnitude of the force
00091     diff *= -2.0*k;
00092 
00093     //  Scale the force vector accordingly
00094     scal = (diff/r);
00095   }
00096   const Force f12 = scal * r12;
00097 
00098 
00099   //  Now add the forces to each force vector
00100   p[0]->f[localIndex[0]] += f12;
00101   p[1]->f[localIndex[1]] -= f12;
00102 
00103   DebugM(3, "::computeForce() -- ending with delta energy " << energy << std::endl);
00104   reduction[bondEnergyIndex] += energy;
00105   reduction[virialIndex_XX] += f12.x * r12.x;
00106   reduction[virialIndex_XY] += f12.x * r12.y;
00107   reduction[virialIndex_XZ] += f12.x * r12.z;
00108   reduction[virialIndex_YX] += f12.y * r12.x;
00109   reduction[virialIndex_YY] += f12.y * r12.y;
00110   reduction[virialIndex_YZ] += f12.y * r12.z;
00111   reduction[virialIndex_ZX] += f12.z * r12.x;
00112   reduction[virialIndex_ZY] += f12.z * r12.y;
00113   reduction[virialIndex_ZZ] += f12.z * r12.z;
00114 
00115   if (pressureProfileData) {
00116     BigReal z1 = p[0]->x[localIndex[0]].position.z;
00117     BigReal z2 = p[1]->x[localIndex[1]].position.z;
00118     int n1 = (int)floor((z1-pressureProfileMin)/pressureProfileThickness);
00119     int n2 = (int)floor((z2-pressureProfileMin)/pressureProfileThickness);
00120     pp_clamp(n1, pressureProfileSlabs);
00121     pp_clamp(n2, pressureProfileSlabs);
00122     int p1 = p[0]->x[localIndex[0]].partition;
00123     int p2 = p[1]->x[localIndex[1]].partition;
00124     int pn = pressureProfileAtomTypes;
00125     pp_reduction(pressureProfileSlabs,
00126                 n1, n2, 
00127                 p1, p2, pn, 
00128                 f12.x * r12.x, f12.y * r12.y, f12.z * r12.z,
00129                 pressureProfileData);
00130   } 
00131 }

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

Definition at line 25 of file ComputeBonds.C.

References Bond, int32, and NAMD_die().

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 Parameters::bond_array.

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

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.

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 133 of file ComputeBonds.C.

References ADD_TENSOR, SubmitReduction::item(), REDUCTION_BOND_ENERGY, REDUCTION_VIRIAL_NORMAL, and virialIndex.

00134 {
00135   reduction->item(REDUCTION_BOND_ENERGY) += data[bondEnergyIndex];
00136   ADD_TENSOR(reduction,REDUCTION_VIRIAL_NORMAL,data,virialIndex);
00137 }


Member Data Documentation

AtomID BondElem::atomID[size]
 

Definition at line 24 of file ComputeBonds.h.

Referenced by BondElem(), 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 20 of file ComputeBonds.C.

BigReal BondElem::pressureProfileMin = 0 [static]
 

Definition at line 22 of file ComputeBonds.C.

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 19 of file ComputeBonds.C.

Referenced by computeForce().

BigReal BondElem::pressureProfileThickness = 0 [static]
 

Definition at line 21 of file ComputeBonds.C.

Referenced by computeForce().

Real BondElem::scale
 

Definition at line 27 of file ComputeBonds.h.

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 Fri May 25 04:07:19 2012 for NAMD by  doxygen 1.3.9.1