AnisoElem Class Reference

#include <ComputeAniso.h>

List of all members.

Public Types

 size = 4
 anisoEnergyIndex
 virialIndex
 reductionDataSize
 reductionChecksumLabel = REDUCTION_ANISO_CHECKSUM
enum  { size = 4 }
enum  { anisoEnergyIndex, virialIndex, reductionDataSize }
enum  { reductionChecksumLabel = REDUCTION_ANISO_CHECKSUM }

Public Member Functions

int hash () const
 AnisoElem ()
 AnisoElem (AtomID atom0, const TupleSignature *sig, const AnisoValue *v)
 AnisoElem (const Aniso *a, const AnisoValue *v)
 AnisoElem (AtomID atom0, AtomID atom1, AtomID atom2, AtomID atom3)
 ~AnisoElem ()
int operator== (const AnisoElem &a) const
int operator< (const AnisoElem &a) const

Static Public Member Functions

static void computeForce (AnisoElem *, int, BigReal *, BigReal *)
static void getMoleculePointers (Molecule *, int *, int32 ***, Aniso **)
static void getParameterPointers (Parameters *, const AnisoValue **)
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 AnisoValuevalue

Static Public Attributes

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


Detailed Description

Definition at line 18 of file ComputeAniso.h.


Member Enumeration Documentation

anonymous enum

Enumerator:
size 

Definition at line 21 of file ComputeAniso.h.

00021 { size = 4 };

anonymous enum

Enumerator:
anisoEnergyIndex 
virialIndex 
reductionDataSize 

Definition at line 49 of file ComputeAniso.h.

anonymous enum

Enumerator:
reductionChecksumLabel 

Definition at line 50 of file ComputeAniso.h.


Constructor & Destructor Documentation

AnisoElem::AnisoElem (  )  [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 ComputeAniso.inl.

00012 { ; }

AnisoElem::AnisoElem ( AtomID  atom0,
const TupleSignature sig,
const AnisoValue v 
) [inline]

Definition at line 14 of file ComputeAniso.inl.

References NAMD_die().

00014                                                                                        {
00015     NAMD_die("Can't use Aniso with memory optimized version of NAMD.");
00016     // atomID[0] = atom0;
00017     // atomID[1] = atom0 + sig->offset[0];
00018     // atomID[2] = atom0 + sig->offset[1];
00019     // atomID[3] = atom0 + sig->offset[2];
00020     // value = &v[sig->tupleParamType];
00021 }

AnisoElem::AnisoElem ( const Aniso a,
const AnisoValue v 
) [inline]

Definition at line 23 of file ComputeAniso.inl.

References aniso::atom1, aniso::atom2, aniso::atom3, aniso::atom4, atomID, and value.

00024   {
00025     atomID[0] = a->atom1;
00026     atomID[1] = a->atom2;
00027     atomID[2] = a->atom3;
00028     atomID[3] = a->atom4;
00029     value = a;  // expect v to be NULL
00030   }

AnisoElem::AnisoElem ( AtomID  atom0,
AtomID  atom1,
AtomID  atom2,
AtomID  atom3 
) [inline]

Definition at line 32 of file ComputeAniso.inl.

References atomID.

00034   {
00035     // do not rearrange atom ordering of Aniso
00036     // the first atom is special
00037     atomID[0] = atom0;
00038     atomID[1] = atom1;
00039     atomID[2] = atom2;
00040     atomID[3] = atom3;
00041   }

AnisoElem::~AnisoElem (  )  [inline]

Definition at line 57 of file ComputeAniso.h.

00057 {};


Member Function Documentation

void AnisoElem::computeForce ( AnisoElem ,
int  ,
BigReal ,
BigReal  
) [static]

Definition at line 41 of file ComputeAniso.C.

References anisoEnergyIndex, atomID, DebugM, Lattice::delta(), TuplePatchElem::f, aniso::k11, aniso::k22, aniso::k33, Patch::lattice, localIndex, TuplePatchElem::p, p, CompAtom::partition, CompAtom::position, pp_clamp(), pp_reduction(), pressureProfileAtomTypes, pressureProfileMin, pressureProfileSlabs, pressureProfileThickness, Vector::rlength(), scale, size, value, Vector::x, TuplePatchElem::x, Vector::y, and Vector::z.

00043 {
00044  const Lattice & lattice = tuples[0].p[0]->p->lattice;
00045 
00046  for ( int ituple=0; ituple<ntuple; ++ituple ) {
00047   const AnisoElem &tup = tuples[ituple];
00048   enum { size = 4 };
00049   const AtomID (&atomID)[size](tup.atomID);
00050   const int    (&localIndex)[size](tup.localIndex);
00051   TuplePatchElem * const(&p)[size](tup.p);
00052   const Real (&scale)(tup.scale);
00053   const AnisoValue * const(&value)(tup.value);
00054 
00055   DebugM(3, "::computeForce() localIndex = " << localIndex[0] << " "
00056                << localIndex[1] << " " << localIndex[2] << " "
00057                << localIndex[3] << std::endl);
00058 
00059 #ifdef CALCULATE_ANISO
00060   // used some comments from Ed Harder's implementation in CHARMM
00061 
00062   const BigReal kpar0  = 2*value->k11;  // force constants
00063   const BigReal kperp0 = 2*value->k22;
00064   const BigReal kiso0  = 2*value->k33;
00065 
00066   const Position & ri = p[0]->x[localIndex[0]].position;    // atom I
00067   const Position & rj = p[0]->x[localIndex[0]+1].position;  // atom I's Drude
00068   const Position & rl = p[1]->x[localIndex[1]].position;    // atom L
00069   const Position & rm = p[2]->x[localIndex[2]].position;    // atom M
00070   const Position & rn = p[3]->x[localIndex[3]].position;    // atom N
00071 
00072   // calculate parallel and perpendicular displacement vectors
00073   Vector r_il = lattice.delta(ri,rl);  // shortest vector image:  ri - rl
00074   Vector r_mn = lattice.delta(rm,rn);  // shortest vector image:  rm - rn
00075 
00076   BigReal r_il_invlen = r_il.rlength();  // need recip lengths of r_il, r_mn
00077   BigReal r_mn_invlen = r_mn.rlength();
00078 
00079   Vector u1 = r_il * r_il_invlen;  // normalize r_il, r_mn
00080   Vector u2 = r_mn * r_mn_invlen;
00081 
00082   Vector dr = rj - ri;  // Drude displacement vector (ri, rj are in same patch)
00083 
00084   BigReal dpar  = dr * u1;  // parallel displacement
00085   BigReal dperp = dr * u2;  // perpendicular displacement
00086 
00087   // aniso spring energy
00088   // kpar reduces response along carbonyl vector
00089   // kperp reduces response perp to bond vector
00090   //   (reg in and out of plane response)
00091   BigReal eaniso;
00092   eaniso = 0.5*kpar0*dpar*dpar + 0.5*kperp0*dperp*dperp + 0.5*kiso0*(dr*dr);
00093 
00094   // calculate force vectors in one direction only:
00095   // fi = -(fj + fl),  fn = -fm
00096 
00097   // force on atom j
00098   Vector fj = -kiso0 * dr;
00099   fj -= kpar0 * dpar * u1;
00100   fj -= kperp0 * dperp * u2;
00101 
00102   // force on atom l
00103   Vector fl = kpar0 * dpar * r_il_invlen * dr;
00104   fl -= kpar0 * dpar * dpar * r_il_invlen * u1;
00105 
00106   // force on atom m
00107   Vector fm = kperp0 * dperp * dperp * r_mn_invlen * u2;
00108   fm -= kperp0 * dperp * r_mn_invlen * dr;
00109 
00110   // accumulate forces
00111   p[0]->f[localIndex[0]] -= (fj + fl);
00112   p[0]->f[localIndex[0]+1] += fj;
00113   p[1]->f[localIndex[1]] += fl;
00114   p[2]->f[localIndex[2]] += fm;
00115   p[3]->f[localIndex[3]] -= fm;
00116 
00117   // update potential
00118   reduction[anisoEnergyIndex] += eaniso;
00119 
00120   // update virial
00121   reduction[virialIndex_XX] += fj.x * dr.x - fl.x * r_il.x + fm.x * r_mn.x;
00122   reduction[virialIndex_XY] += fj.x * dr.y - fl.x * r_il.y + fm.x * r_mn.y;
00123   reduction[virialIndex_XZ] += fj.x * dr.z - fl.x * r_il.z + fm.x * r_mn.z;
00124   reduction[virialIndex_YX] += fj.y * dr.x - fl.y * r_il.x + fm.y * r_mn.x;
00125   reduction[virialIndex_YY] += fj.y * dr.y - fl.y * r_il.y + fm.y * r_mn.y;
00126   reduction[virialIndex_YZ] += fj.y * dr.z - fl.y * r_il.z + fm.y * r_mn.z;
00127   reduction[virialIndex_ZX] += fj.z * dr.x - fl.z * r_il.x + fm.z * r_mn.x;
00128   reduction[virialIndex_ZY] += fj.z * dr.y - fl.z * r_il.y + fm.z * r_mn.y;
00129   reduction[virialIndex_ZZ] += fj.z * dr.z - fl.z * r_il.z + fm.z * r_mn.z;
00130 
00131   // update pressure profile data
00132   if (pressureProfileData) {
00133     BigReal zi = p[0]->x[localIndex[0]].position.z;
00134     BigReal zj = p[0]->x[localIndex[0]+1].position.z;
00135     BigReal zl = p[1]->x[localIndex[1]].position.z;
00136     BigReal zm = p[2]->x[localIndex[2]].position.z;
00137     BigReal zn = p[3]->x[localIndex[3]].position.z;
00138     int ni = (int)floor((zi-pressureProfileMin)/pressureProfileThickness);
00139     int nj = (int)floor((zj-pressureProfileMin)/pressureProfileThickness);
00140     int nl = (int)floor((zl-pressureProfileMin)/pressureProfileThickness);
00141     int nm = (int)floor((zm-pressureProfileMin)/pressureProfileThickness);
00142     int nn = (int)floor((zn-pressureProfileMin)/pressureProfileThickness);
00143     pp_clamp(ni, pressureProfileSlabs);
00144     pp_clamp(nj, pressureProfileSlabs);
00145     pp_clamp(nl, pressureProfileSlabs);
00146     pp_clamp(nm, pressureProfileSlabs);
00147     pp_clamp(nn, pressureProfileSlabs);
00148     int pi = p[0]->x[localIndex[0]].partition;
00149     int pj = p[0]->x[localIndex[0]+1].partition;
00150     int pl = p[1]->x[localIndex[1]].partition;
00151     int pm = p[2]->x[localIndex[2]].partition;
00152     int pn = p[3]->x[localIndex[3]].partition;
00153     int pt = pressureProfileAtomTypes;
00154     pp_reduction(pressureProfileSlabs, nj, ni,
00155         pj, pi, pt, fj.x * dr.x, fj.y * dr.y, fj.z * dr.z,
00156         pressureProfileData);
00157     pp_reduction(pressureProfileSlabs, ni, nl,
00158         pi, pl, pt, -fl.x * r_il.x, -fl.y * r_il.y, -fl.z * r_il.z,
00159         pressureProfileData);
00160     pp_reduction(pressureProfileSlabs, nm, nn,
00161         pm, pn, pt, fm.x * r_mn.x, fm.y * r_mn.y, fm.z * r_mn.z,
00162         pressureProfileData);
00163   }
00164 #endif
00165 
00166  }
00167 }

void AnisoElem::getMoleculePointers ( Molecule ,
int *  ,
int32 ***  ,
Aniso **   
) [static]

Definition at line 26 of file ComputeAniso.C.

References Molecule::anisos, Molecule::anisosByAtom, NAMD_die(), and Molecule::numAnisos.

00027 {
00028 #ifdef MEM_OPT_VERSION
00029   NAMD_die("Should not be called in AnisoElem::getMoleculePointers in memory optimized version!");
00030 #else
00031   *count = mol->numAnisos;
00032   *byatom = mol->anisosByAtom;
00033   *structarray = mol->anisos;
00034 #endif
00035 }

void AnisoElem::getParameterPointers ( Parameters ,
const AnisoValue **   
) [static]

Definition at line 37 of file ComputeAniso.C.

00037                                                                         {
00038   *v = NULL;  // parameters are stored in the structure
00039 }

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

Definition at line 30 of file ComputeAniso.h.

References NAMD_die().

00030                                                                                  {
00031         NAMD_die("Can't use Aniso with memory optimized version of NAMD.");
00032         // *count = sig->ansioCnt;
00033         // *t = sig->anisoSigs;
00034     }

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

Definition at line 45 of file ComputeAniso.h.

References atomID.

00045                    { 
00046     return 0x7FFFFFFF &((atomID[0]<<24) + (atomID[1]<<16) + (atomID[2]<<8) + atomID[3]);
00047   }

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

Definition at line 49 of file ComputeAniso.inl.

References atomID.

00050   {
00051     return  (atomID[0] < a.atomID[0] ||
00052             (atomID[0] == a.atomID[0] &&
00053             (atomID[1] < a.atomID[1] ||
00054             (atomID[1] == a.atomID[1] &&
00055             (atomID[2] < a.atomID[2] ||
00056             (atomID[2] == a.atomID[2] &&
00057              atomID[3] < a.atomID[3] 
00058              ))))));
00059   }

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

Definition at line 43 of file ComputeAniso.inl.

References atomID.

00044   {
00045     return (a.atomID[0] == atomID[0] && a.atomID[1] == atomID[1] &&
00046         a.atomID[2] == atomID[2] && a.atomID[3] == atomID[3]);
00047   }

void AnisoElem::submitReductionData ( BigReal ,
SubmitReduction  
) [static]

Definition at line 170 of file ComputeAniso.C.

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

00171 {
00172   reduction->item(REDUCTION_BOND_ENERGY) += data[anisoEnergyIndex];
00173   ADD_TENSOR(reduction,REDUCTION_VIRIAL_NORMAL,data,virialIndex);
00174 }


Member Data Documentation

AtomID AnisoElem::atomID[size]

Definition at line 22 of file ComputeAniso.h.

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

int AnisoElem::localIndex[size]

Definition at line 23 of file ComputeAniso.h.

Referenced by computeForce().

TuplePatchElem* AnisoElem::p[size]

Definition at line 24 of file ComputeAniso.h.

Referenced by computeForce().

int AnisoElem::pressureProfileAtomTypes = 1 [static]

Definition at line 38 of file ComputeAniso.h.

Referenced by computeForce().

BigReal AnisoElem::pressureProfileMin = 0 [static]

Definition at line 40 of file ComputeAniso.h.

Referenced by computeForce().

int AnisoElem::pressureProfileSlabs = 0 [static]

Definition at line 37 of file ComputeAniso.h.

Referenced by computeForce().

BigReal AnisoElem::pressureProfileThickness = 0 [static]

Definition at line 39 of file ComputeAniso.h.

Referenced by computeForce().

Real AnisoElem::scale

Definition at line 25 of file ComputeAniso.h.

Referenced by computeForce().

const AnisoValue* AnisoElem::value

Definition at line 43 of file ComputeAniso.h.

Referenced by AnisoElem(), and computeForce().


The documentation for this class was generated from the following files:
Generated on Mon Sep 25 01:17:16 2017 for NAMD by  doxygen 1.4.7