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

AngleElem Class Reference

#include <ComputeAngles.h>

List of all members.

Public Types

enum  { size = 3 }
enum  { angleEnergyIndex, virialIndex, reductionDataSize }
enum  { reductionChecksumLabel = REDUCTION_ANGLE_CHECKSUM }

Public Member Functions

void computeForce (BigReal *, BigReal *)
int hash () const
 AngleElem ()
 AngleElem (AtomID atom0, const TupleSignature *sig, const AngleValue *v)
 AngleElem (const Angle *a, const AngleValue *v)
 AngleElem (AtomID atom0, AtomID atom1, AtomID atom2)
 ~AngleElem ()
int operator== (const AngleElem &a) const
int operator< (const AngleElem &a) const

Static Public Member Functions

void getMoleculePointers (Molecule *, int *, int32 ***, Angle **)
void getParameterPointers (Parameters *, const AngleValue **)
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 AngleValuevalue

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 19 of file ComputeAngles.h.

00019 { size = 3 };

anonymous enum
 

Enumeration values:
angleEnergyIndex 
virialIndex 
reductionDataSize 

Definition at line 46 of file ComputeAngles.h.

00046 { angleEnergyIndex, TENSOR(virialIndex), reductionDataSize };

anonymous enum
 

Enumeration values:
reductionChecksumLabel 

Definition at line 47 of file ComputeAngles.h.


Constructor & Destructor Documentation

AngleElem::AngleElem  )  [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 ComputeAngles.inl.

00012 { ; }

AngleElem::AngleElem AtomID  atom0,
const TupleSignature sig,
const AngleValue v
[inline]
 

Definition at line 14 of file ComputeAngles.inl.

References atomID, TupleSignature::offset, TupleSignature::tupleParamType, and value.

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

AngleElem::AngleElem const Angle a,
const AngleValue v
[inline]
 

Definition at line 21 of file ComputeAngles.inl.

References Angle, angle::angle_type, angle::atom1, angle::atom2, angle::atom3, atomID, and value.

00022   {
00023     atomID[0] = a->atom1;
00024     atomID[1] = a->atom2;
00025     atomID[2] = a->atom3;
00026     value = &v[a->angle_type];
00027   }

AngleElem::AngleElem AtomID  atom0,
AtomID  atom1,
AtomID  atom2
[inline]
 

Definition at line 29 of file ComputeAngles.inl.

References atomID, and AtomID.

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

AngleElem::~AngleElem  )  [inline]
 

Definition at line 54 of file ComputeAngles.h.

00054 { };


Member Function Documentation

void AngleElem::computeForce BigReal ,
BigReal
 

Definition at line 47 of file ComputeAngles.C.

References BigReal, DebugM, Lattice::delta(), TuplePatchElem::f, Force, AngleValue::k, AngleValue::k_ub, Patch::lattice, Vector::length(), localIndex, NAMD_die(), AngleValue::normal, TuplePatchElem::p, p, CompAtom::partition, CompAtom::position, Position, pp_clamp(), pp_reduction(), pressureProfileMin, pressureProfileSlabs, pressureProfileThickness, AngleValue::r_ub, Vector::rlength(), AngleValue::theta0, value, Vector::x, TuplePatchElem::x, Vector::y, and Vector::z.

00048 {
00049   DebugM(3, "::computeForce() localIndex = " << localIndex[0] << " "
00050                << localIndex[1] << " " << localIndex[2] << std::endl);
00051 
00052   const Position & pos1 = p[0]->x[localIndex[0]].position;
00053   const Lattice & lattice = p[0]->p->lattice;
00054   const Position & pos2 = p[1]->x[localIndex[1]].position;
00055   Vector r12 = lattice.delta(pos1,pos2);
00056   register BigReal d12inv = r12.rlength();
00057   const Position & pos3 = p[2]->x[localIndex[2]].position;
00058   Vector r32 = lattice.delta(pos3,pos2);
00059   register BigReal d32inv = r32.rlength();
00060   int normal = value->normal;
00061 
00062   BigReal cos_theta = (r12*r32)*(d12inv*d32inv);
00063   //  Make sure that the cosine value is acceptable.  With roundoff, you
00064   //  can get values like 1.0+2e-16, which makes acos puke.  So instead,
00065   //  just set these kinds of values to exactly 1.0
00066   if (cos_theta > 1.0) cos_theta = 1.0;
00067   else if (cos_theta < -1.0) cos_theta = -1.0;
00068 
00069   BigReal k = value->k * scale;
00070   BigReal theta0 = value->theta0;
00071 
00072   //  Get theta
00073   BigReal theta = acos(cos_theta);
00074 
00075   //  Compare it to the rest angle
00076   BigReal diff;
00077 
00078   if (normal == 1) {
00079     diff = theta - theta0;
00080   } else {
00081     diff = cos_theta - cos(theta0);
00082   }
00083   
00084   //  Add the energy from this angle to the total energy
00085   BigReal energy = k *diff*diff;
00086 
00087   //  Normalize vector r12 and r32
00088   //BigReal d12inv = 1. / d12;
00089   //BigReal d32inv = 1. / d32;
00090 
00091 
00092   //  Calculate constant factor 2k(theta-theta0)/sin(theta)
00093   BigReal sin_theta = sqrt(1.0 - cos_theta*cos_theta);
00094   if (normal != 1) {
00095     diff *= (2.0* k);
00096   } else if ( sin_theta < 1.e-6 ) {
00097     // catch case where bonds are parallel
00098     // this gets the force approximately right for theta0 of 0 or pi
00099     // and at least avoids small division for other values
00100     if ( diff < 0. ) diff = 2.0 * k;
00101     else diff = -2.0 * k;
00102   } else { 
00103     diff *= (-2.0* k) / sin_theta; 
00104   }
00105   BigReal c1 = diff * d12inv;
00106   BigReal c2 = diff * d32inv;
00107 
00108   //  Calculate the actual forces
00109   Force force1 = c1*(r12*(d12inv*cos_theta) - r32*d32inv);
00110   Force force2 = force1;
00111   Force force3 = c2*(r32*(d32inv*cos_theta) - r12*d12inv);
00112   force2 += force3;  force2 *= -1;
00113 
00114   //  Check to see if we need to do the Urey-Bradley term
00115   if (value->k_ub)
00116   {
00117         //  Non-zero k_ub value, so calculate the harmonic
00118         //  potential between the 1-3 atoms
00119 
00120   if (normal != 1) {
00121     NAMD_die("ERROR: Can't use cosAngles with Urey-Bradley angles");
00122   }
00123         BigReal k_ub = value->k_ub;
00124         BigReal r_ub = value->r_ub;
00125         Vector r13 = r12 - r32;
00126         BigReal d13 = r13.length();
00127         diff = d13- r_ub;
00128 
00129         energy += k_ub *diff*diff;
00130 
00131         diff *= -2.0*k_ub / d13;
00132         r13 *= diff;
00133 
00134         force1 += r13;
00135         force3 -= r13;
00136   }
00137 
00138   p[0]->f[localIndex[0]].x += force1.x;
00139   p[0]->f[localIndex[0]].y += force1.y;
00140   p[0]->f[localIndex[0]].z += force1.z;
00141 
00142   p[1]->f[localIndex[1]].x += force2.x;
00143   p[1]->f[localIndex[1]].y += force2.y;
00144   p[1]->f[localIndex[1]].z += force2.z;
00145 
00146   p[2]->f[localIndex[2]].x += force3.x;
00147   p[2]->f[localIndex[2]].y += force3.y;
00148   p[2]->f[localIndex[2]].z += force3.z;
00149 
00150   DebugM(3, "::computeForce() -- ending with delta energy " << energy << std::endl);
00151 
00152   reduction[angleEnergyIndex] += energy;
00153   reduction[virialIndex_XX] += ( force1.x * r12.x + force3.x * r32.x );
00154   reduction[virialIndex_XY] += ( force1.x * r12.y + force3.x * r32.y );
00155   reduction[virialIndex_XZ] += ( force1.x * r12.z + force3.x * r32.z );
00156   reduction[virialIndex_YX] += ( force1.y * r12.x + force3.y * r32.x );
00157   reduction[virialIndex_YY] += ( force1.y * r12.y + force3.y * r32.y );
00158   reduction[virialIndex_YZ] += ( force1.y * r12.z + force3.y * r32.z );
00159   reduction[virialIndex_ZX] += ( force1.z * r12.x + force3.z * r32.x );
00160   reduction[virialIndex_ZY] += ( force1.z * r12.y + force3.z * r32.y );
00161   reduction[virialIndex_ZZ] += ( force1.z * r12.z + force3.z * r32.z );
00162 
00163   if (pressureProfileData) {
00164     BigReal z1 = p[0]->x[localIndex[0]].position.z;
00165     BigReal z2 = p[1]->x[localIndex[1]].position.z;
00166     BigReal z3 = p[2]->x[localIndex[2]].position.z;
00167     int n1 = (int)floor((z1-pressureProfileMin)/pressureProfileThickness);
00168     int n2 = (int)floor((z2-pressureProfileMin)/pressureProfileThickness);
00169     int n3 = (int)floor((z3-pressureProfileMin)/pressureProfileThickness);
00170     pp_clamp(n1, pressureProfileSlabs);
00171     pp_clamp(n2, pressureProfileSlabs);
00172     pp_clamp(n3, pressureProfileSlabs);
00173     int p1 = p[0]->x[localIndex[0]].partition;
00174     int p2 = p[1]->x[localIndex[1]].partition;
00175     int p3 = p[2]->x[localIndex[2]].partition;
00176     int pn = pressureProfileAtomTypes;
00177     pp_reduction(pressureProfileSlabs, n1, n2, 
00178                 p1, p2, pn,
00179                 force1.x * r12.x, force1.y * r12.y, force1.z * r12.z,
00180                 pressureProfileData);
00181     pp_reduction(pressureProfileSlabs, n3, n2, 
00182                 p3, p2, pn,
00183                 force3.x * r32.x, force3.y * r32.y, force3.z * r32.z,
00184                 pressureProfileData);
00185   }
00186 }

void AngleElem::getMoleculePointers Molecule ,
int *  ,
int32 ***  ,
Angle ** 
[static]
 

Definition at line 32 of file ComputeAngles.C.

References Angle, int32, and NAMD_die().

00033 {
00034 #ifdef MEM_OPT_VERSION
00035   NAMD_die("Should not be called in AngleElem::getMoleculePointers in memory optimized version!");
00036 #else
00037   *count = mol->numAngles;
00038   *byatom = mol->anglesByAtom;
00039   *structarray = mol->angles;
00040 #endif
00041 }

void AngleElem::getParameterPointers Parameters ,
const AngleValue ** 
[static]
 

Definition at line 43 of file ComputeAngles.C.

References Parameters::angle_array.

00043                                                                         {
00044   *v = p->angle_array;
00045 }

void AngleElem::getTupleInfo AtomSignature sig,
int *  count,
TupleSignature **  t
[inline, static]
 

Definition at line 28 of file ComputeAngles.h.

References AtomSignature::angleCnt, and AtomSignature::angleSigs.

00028                                                                                  {
00029         *count = sig->angleCnt;
00030         *t = sig->angleSigs;
00031     }

int AngleElem::hash void   )  const [inline]
 

Definition at line 42 of file ComputeAngles.h.

00042                    { 
00043     return 0x7FFFFFFF & ((atomID[0]<<22) + (atomID[1]<<11) + (atomID[2])); 
00044   }

int AngleElem::operator< const AngleElem a  )  const [inline]
 

Definition at line 45 of file ComputeAngles.inl.

References atomID.

00046   {
00047     return (atomID[0] < a.atomID[0] ||
00048             (atomID[0] == a.atomID[0] &&
00049             (atomID[1] < a.atomID[1] ||
00050             (atomID[1] == a.atomID[1] &&
00051              atomID[2] < a.atomID[2]) )));
00052   }

int AngleElem::operator== const AngleElem a  )  const [inline]
 

Definition at line 39 of file ComputeAngles.inl.

References atomID.

00040   {
00041     return (a.atomID[0] == atomID[0] && a.atomID[1] == atomID[1] &&
00042         a.atomID[2] == atomID[2]);
00043   }

void AngleElem::submitReductionData BigReal ,
SubmitReduction
[static]
 

Definition at line 189 of file ComputeAngles.C.

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

00190 {
00191   reduction->item(REDUCTION_ANGLE_ENERGY) += data[angleEnergyIndex];
00192   ADD_TENSOR(reduction,REDUCTION_VIRIAL_NORMAL,data,virialIndex);
00193 }


Member Data Documentation

AtomID AngleElem::atomID[size]
 

Definition at line 20 of file ComputeAngles.h.

Referenced by AngleElem(), operator<(), and operator==().

int AngleElem::localIndex[size]
 

Definition at line 21 of file ComputeAngles.h.

Referenced by computeForce().

TuplePatchElem* AngleElem::p[size]
 

Definition at line 22 of file ComputeAngles.h.

Referenced by computeForce().

int AngleElem::pressureProfileAtomTypes = 1 [static]
 

Definition at line 27 of file ComputeAngles.C.

BigReal AngleElem::pressureProfileMin = 0 [static]
 

Definition at line 29 of file ComputeAngles.C.

Referenced by computeForce().

int AngleElem::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 26 of file ComputeAngles.C.

Referenced by computeForce().

BigReal AngleElem::pressureProfileThickness = 0 [static]
 

Definition at line 28 of file ComputeAngles.C.

Referenced by computeForce().

Real AngleElem::scale
 

Definition at line 23 of file ComputeAngles.h.

const AngleValue* AngleElem::value
 

Definition at line 40 of file ComputeAngles.h.

Referenced by AngleElem(), 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