ExclElem Class Reference

#include <ComputeNonbondedCUDAExcl.h>

Inheritance diagram for ExclElem:

ComputeNonbondedUtil List of all members.

Public Types

 size = 2
 vdwEnergyIndex
 electEnergyIndex
 fullElectEnergyIndex
 virialIndex
 slowVirialIndex
 reductionDataSize
 reductionChecksumLabel = REDUCTION_EXCLUSION_CHECKSUM
enum  { size = 2 }
enum  {
  vdwEnergyIndex, electEnergyIndex, fullElectEnergyIndex, virialIndex,
  slowVirialIndex, reductionDataSize
}
enum  { reductionChecksumLabel = REDUCTION_EXCLUSION_CHECKSUM }

Public Member Functions

int hash () const
 ExclElem ()
 ExclElem (AtomID atom0, const TupleSignature *sig, const int *v)
 ExclElem (const Exclusion *a, const int *v)
 ExclElem (AtomID atom0, AtomID atom1)
 ~ExclElem ()
int operator== (const ExclElem &a) const
int operator< (const ExclElem &a) const

Static Public Member Functions

static void computeForce (ExclElem *, int, BigReal *, BigReal *)
static void getMoleculePointers (Molecule *, int *, int32 ***, Exclusion **)
static void getParameterPointers (Parameters *, const int **)
static void getTupleInfo (ExclusionSignature *sig, int *count, TupleSignature **t)
static void submitReductionData (BigReal *, SubmitReduction *)

Public Attributes

AtomID atomID [size]
int localIndex [size]
TuplePatchElemp [size]
Real scale
int modified

Static Public Attributes

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

Detailed Description

Definition at line 21 of file ComputeNonbondedCUDAExcl.h.


Member Enumeration Documentation

anonymous enum

Enumerator:
size 

Definition at line 24 of file ComputeNonbondedCUDAExcl.h.

00024 { size = 2 };

anonymous enum

Enumerator:
vdwEnergyIndex 
electEnergyIndex 
fullElectEnergyIndex 
virialIndex 
slowVirialIndex 
reductionDataSize 

Definition at line 51 of file ComputeNonbondedCUDAExcl.h.

anonymous enum

Enumerator:
reductionChecksumLabel 

Definition at line 53 of file ComputeNonbondedCUDAExcl.h.


Constructor & Destructor Documentation

ExclElem::ExclElem (  )  [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 ComputeNonbondedCUDAExcl.inl.

00012 { ; }

ExclElem::ExclElem ( AtomID  atom0,
const TupleSignature sig,
const int *  v 
) [inline]

Definition at line 14 of file ComputeNonbondedCUDAExcl.inl.

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

00014                                                                               {
00015     atomID[0] = atom0;
00016     atomID[1] = atom0 + sig->offset[0];
00017     modified = sig->tupleParamType;
00018 }

ExclElem::ExclElem ( const Exclusion a,
const int *  v 
) [inline]

Definition at line 20 of file ComputeNonbondedCUDAExcl.inl.

References Exclusion::atom1, Exclusion::atom2, atomID, Exclusion::modified, and modified.

00021   {
00022     atomID[0] = a->atom1;
00023     atomID[1] = a->atom2;
00024     modified = a->modified;
00025   }

ExclElem::ExclElem ( AtomID  atom0,
AtomID  atom1 
) [inline]

Definition at line 27 of file ComputeNonbondedCUDAExcl.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   }

ExclElem::~ExclElem (  )  [inline]

Definition at line 60 of file ComputeNonbondedCUDAExcl.h.

00060 {};


Member Function Documentation

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

Definition at line 41 of file ComputeNonbondedCUDAExcl.C.

References LJTable::TableEntry::A, A, atomID, LJTable::TableEntry::B, B, CompAtom::charge, COULOMB, ComputeNonbondedUtil::cutoff2, Lattice::delta(), ComputeNonbondedUtil::dielectric_1, diffa, Flags::doEnergy, Flags::doFullElectrostatics, Flags::doNonbonded, electEnergyIndex, Results::f, f, fast_a, fast_b, fast_c, fast_dir, ComputeNonbondedUtil::fast_table, Patch::flags, fullElectEnergyIndex, if(), kqq, Patch::lattice, Vector::length2(), lj_pars, ComputeNonbondedUtil::ljTable, localIndex, modified, Results::nbond, TuplePatchElem::p, p, p_j, CompAtom::position, TuplePatchElem::r, ComputeNonbondedUtil::r2_delta, ComputeNonbondedUtil::r2_delta_exp, ComputeNonbondedUtil::r2_table, scale, ComputeNonbondedUtil::scale14, ComputeNonbondedUtil::scaling, size, Results::slow, slow_b, slow_dir, ComputeNonbondedUtil::slow_table, table_four_i, table_i, ComputeNonbondedUtil::table_noshort, LJTable::table_row(), vdw_a, vdw_b, vdw_c, vdw_d, vdwEnergyIndex, CompAtom::vdwType, Vector::x, TuplePatchElem::x, Vector::y, and Vector::z.

00043 {
00044   const Lattice & lattice = tuples[0].p[0]->p->lattice;
00045   const Flags &flags = tuples[0].p[0]->p->flags;
00046   if ( ! flags.doNonbonded ) return;
00047   const int doFull = flags.doFullElectrostatics;
00048   const int doEnergy = flags.doEnergy;
00049 
00050   for ( int ituple=0; ituple<ntuple; ++ituple ) {
00051     const ExclElem &tup = tuples[ituple];
00052     enum { size = 2 };
00053     const AtomID (&atomID)[size](tup.atomID);
00054     const int    (&localIndex)[size](tup.localIndex);
00055     TuplePatchElem * const(&p)[size](tup.p);
00056     const Real (&scale)(tup.scale);
00057     const int (&modified)(tup.modified);
00058 
00059     const CompAtom &p_i = p[0]->x[localIndex[0]];
00060     const CompAtom &p_j = p[1]->x[localIndex[1]];
00061 
00062     // compute vectors between atoms and their distances
00063     const Vector r12 = lattice.delta(p_i.position, p_j.position);
00064     BigReal r2 = r12.length2();
00065 
00066     if ( r2 > cutoff2 ) continue;
00067 
00068     if ( modified && r2 < 1.0 ) r2 = 1.0;  // match CUDA interpolation
00069 
00070     r2 += r2_delta;
00071 
00072     union { double f; int64 i; } r2i;
00073     r2i.f = r2;
00074     const int r2_delta_expc = 64 * (r2_delta_exp - 1023);
00075     int table_i = (r2i.i >> (32+14)) + r2_delta_expc;  // table_i >= 0
00076 
00077     const BigReal* const table_four_i = table_noshort + 16*table_i;
00078 
00079     BigReal diffa = r2 - r2_table[table_i];
00080 
00081     BigReal fast_a = 0., fast_b = 0., fast_c = 0., fast_d = 0.;
00082     BigReal slow_a, slow_b, slow_c, slow_d;
00083 
00084   if ( modified ) {
00085 
00086     const LJTable::TableEntry * lj_pars =
00087             ljTable->table_row(p_i.vdwType) + 2 * p_j.vdwType;
00088 
00089     // modified - normal = correction
00090     const BigReal A = scaling * ( (lj_pars+1)->A - lj_pars->A );
00091     const BigReal B = scaling * ( (lj_pars+1)->B - lj_pars->B );
00092 
00093     BigReal vdw_d = A * table_four_i[0] - B * table_four_i[4];
00094     BigReal vdw_c = A * table_four_i[1] - B * table_four_i[5];
00095     BigReal vdw_b = A * table_four_i[2] - B * table_four_i[6];
00096     BigReal vdw_a = A * table_four_i[3] - B * table_four_i[7];
00097 
00098     const BigReal kqq = (1.0 - scale14) *
00099             COULOMB * p_i.charge * p_j.charge * scaling * dielectric_1;
00100 
00101     fast_a =      kqq * fast_table[4*table_i+0];  // not used!
00102     fast_b = 2. * kqq * fast_table[4*table_i+1];
00103     fast_c = 4. * kqq * fast_table[4*table_i+2];
00104     fast_d = 6. * kqq * fast_table[4*table_i+3];
00105 
00106     if ( doFull ) {
00107       slow_a =      kqq * slow_table[4*table_i+3];  // not used!
00108       slow_b = 2. * kqq * slow_table[4*table_i+2];
00109       slow_c = 4. * kqq * slow_table[4*table_i+1];
00110       slow_d = 6. * kqq * slow_table[4*table_i+0];
00111     }
00112 
00113     if ( doEnergy ) {
00114       reduction[vdwEnergyIndex] -=
00115                 ( ( diffa * (1./6.)*vdw_d + 0.25*vdw_c ) * diffa
00116                         + 0.5*vdw_b ) * diffa + vdw_a;
00117       reduction[electEnergyIndex] -=
00118                 ( ( diffa * (1./6.)*fast_d + 0.25*fast_c ) * diffa
00119                         + 0.5*fast_b ) * diffa + fast_a;
00120       if ( doFull ) {
00121         reduction[fullElectEnergyIndex] -=
00122                 ( ( diffa * (1./6.)*slow_d + 0.25*slow_c ) * diffa
00123                         + 0.5*slow_b ) * diffa + slow_a;
00124       }
00125     }
00126 
00127     fast_a += vdw_a;
00128     fast_b += vdw_b;
00129     fast_c += vdw_c;
00130     fast_d += vdw_d;
00131 
00132   } else if ( doFull ) {  // full exclusion
00133 
00134     const BigReal kqq = 
00135             COULOMB * p_i.charge * p_j.charge * scaling * dielectric_1;
00136 
00137     slow_d = kqq * ( table_four_i[8]  - table_four_i[12] );
00138     slow_c = kqq * ( table_four_i[9]  - table_four_i[13] );
00139     slow_b = kqq * ( table_four_i[10] - table_four_i[14] );
00140     slow_a = kqq * ( table_four_i[11] - table_four_i[15] );  // not used!
00141 
00142     if ( doEnergy ) {
00143       reduction[fullElectEnergyIndex] -=
00144                 ( ( diffa * (1./6.)*slow_d + 0.25*slow_c ) * diffa
00145                         + 0.5*slow_b ) * diffa + slow_a;
00146     }
00147   }
00148 
00149   register BigReal fast_dir =
00150                   (diffa * fast_d + fast_c) * diffa + fast_b;
00151 
00152   const Force f12 = fast_dir * r12;
00153 
00154   //  Now add the forces to each force vector
00155   p[0]->r->f[Results::nbond][localIndex[0]] += f12;
00156   p[1]->r->f[Results::nbond][localIndex[1]] -= f12;
00157 
00158   // reduction[nonbondedEnergyIndex] += energy;
00159   reduction[virialIndex_XX] += f12.x * r12.x;
00160   reduction[virialIndex_XY] += f12.x * r12.y;
00161   reduction[virialIndex_XZ] += f12.x * r12.z;
00162   reduction[virialIndex_YX] += f12.y * r12.x;
00163   reduction[virialIndex_YY] += f12.y * r12.y;
00164   reduction[virialIndex_YZ] += f12.y * r12.z;
00165   reduction[virialIndex_ZX] += f12.z * r12.x;
00166   reduction[virialIndex_ZY] += f12.z * r12.y;
00167   reduction[virialIndex_ZZ] += f12.z * r12.z;
00168 
00169   if ( doFull ) {
00170     register BigReal slow_dir =
00171                   (diffa * slow_d + slow_c) * diffa + slow_b;
00172 
00173     const Force slow_f12 = slow_dir * r12;
00174 
00175     p[0]->r->f[Results::slow][localIndex[0]] += slow_f12;
00176     p[1]->r->f[Results::slow][localIndex[1]] -= slow_f12;
00177 
00178     // reduction[nonbondedEnergyIndex] += energy;
00179     reduction[slowVirialIndex_XX] += slow_f12.x * r12.x;
00180     reduction[slowVirialIndex_XY] += slow_f12.x * r12.y;
00181     reduction[slowVirialIndex_XZ] += slow_f12.x * r12.z;
00182     reduction[slowVirialIndex_YX] += slow_f12.y * r12.x;
00183     reduction[slowVirialIndex_YY] += slow_f12.y * r12.y;
00184     reduction[slowVirialIndex_YZ] += slow_f12.y * r12.z;
00185     reduction[slowVirialIndex_ZX] += slow_f12.z * r12.x;
00186     reduction[slowVirialIndex_ZY] += slow_f12.z * r12.y;
00187     reduction[slowVirialIndex_ZZ] += slow_f12.z * r12.z;
00188   }
00189 
00190   }
00191 }

void ExclElem::getMoleculePointers ( Molecule ,
int *  ,
int32 ***  ,
Exclusion **   
) [static]

Definition at line 26 of file ComputeNonbondedCUDAExcl.C.

References Molecule::exclusions, Molecule::exclusionsByAtom, NAMD_die(), and Molecule::numExclusions.

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

void ExclElem::getParameterPointers ( Parameters ,
const int **   
) [static]

Definition at line 37 of file ComputeNonbondedCUDAExcl.C.

00037                                                                 {
00038   *v = 0;
00039 }

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

Definition at line 33 of file ComputeNonbondedCUDAExcl.h.

References ExclusionSignature::allExclCnt, and ExclusionSignature::allTuples.

00033                                                                                       {
00034 #ifdef NAMD_CUDA
00035         *count = sig->allExclCnt;
00036         *t = sig->allTuples;
00037 #endif
00038     }

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

Definition at line 46 of file ComputeNonbondedCUDAExcl.h.

References atomID.

00046 { return 0x7FFFFFFF & ( (atomID[0]<<16) + (atomID[1])); }

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

Definition at line 41 of file ComputeNonbondedCUDAExcl.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 ExclElem::operator== ( const ExclElem a  )  const [inline]

Definition at line 36 of file ComputeNonbondedCUDAExcl.inl.

References atomID.

00037   {
00038     return (a.atomID[0] == atomID[0] && a.atomID[1] == atomID[1]);
00039   }

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

Reimplemented from ComputeNonbondedUtil.

Definition at line 193 of file ComputeNonbondedCUDAExcl.C.

References ADD_TENSOR, electEnergyIndex, fullElectEnergyIndex, SubmitReduction::item(), REDUCTION_ELECT_ENERGY, REDUCTION_ELECT_ENERGY_SLOW, REDUCTION_LJ_ENERGY, REDUCTION_VIRIAL_NBOND, REDUCTION_VIRIAL_SLOW, slowVirialIndex, vdwEnergyIndex, and virialIndex.

00194 {
00195   reduction->item(REDUCTION_ELECT_ENERGY) += data[electEnergyIndex];
00196   reduction->item(REDUCTION_LJ_ENERGY) += data[vdwEnergyIndex];
00197   reduction->item(REDUCTION_ELECT_ENERGY_SLOW) += data[fullElectEnergyIndex];
00198   ADD_TENSOR(reduction,REDUCTION_VIRIAL_NBOND,data,virialIndex);
00199   ADD_TENSOR(reduction,REDUCTION_VIRIAL_SLOW,data,slowVirialIndex);
00200 }


Member Data Documentation

AtomID ExclElem::atomID[size]

Definition at line 25 of file ComputeNonbondedCUDAExcl.h.

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

int ExclElem::localIndex[size]

Definition at line 26 of file ComputeNonbondedCUDAExcl.h.

Referenced by computeForce().

int ExclElem::modified

Definition at line 49 of file ComputeNonbondedCUDAExcl.h.

Referenced by computeForce(), and ExclElem().

TuplePatchElem* ExclElem::p[size]

Definition at line 27 of file ComputeNonbondedCUDAExcl.h.

Referenced by computeForce().

int ExclElem::pressureProfileAtomTypes = 1 [static]

Reimplemented from ComputeNonbondedUtil.

Definition at line 42 of file ComputeNonbondedCUDAExcl.h.

BigReal ExclElem::pressureProfileMin = 0 [static]

Reimplemented from ComputeNonbondedUtil.

Definition at line 44 of file ComputeNonbondedCUDAExcl.h.

int ExclElem::pressureProfileSlabs = 0 [static]

Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by The Board of Trustees of the University of Illinois. All rights reserved.

Reimplemented from ComputeNonbondedUtil.

Definition at line 41 of file ComputeNonbondedCUDAExcl.h.

BigReal ExclElem::pressureProfileThickness = 0 [static]

Reimplemented from ComputeNonbondedUtil.

Definition at line 43 of file ComputeNonbondedCUDAExcl.h.

Real ExclElem::scale

Definition at line 28 of file ComputeNonbondedCUDAExcl.h.

Referenced by computeForce().


The documentation for this class was generated from the following files:
Generated on Tue Nov 21 01:17:18 2017 for NAMD by  doxygen 1.4.7