NAMD
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
AnisoElem Class Reference

#include <ComputeAniso.h>

Public Types

enum  { size = 4 }
 
enum  {
  anisoEnergyIndex, anisoEnergyIndex_f, anisoEnergyIndex_ti_1, anisoEnergyIndex_ti_2,
  TENSOR =(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.

21 { size = 4 };
anonymous enum
Enumerator
anisoEnergyIndex 
anisoEnergyIndex_f 
anisoEnergyIndex_ti_1 
anisoEnergyIndex_ti_2 
TENSOR 
reductionDataSize 

Definition at line 49 of file ComputeAniso.h.

anonymous enum
Enumerator
reductionChecksumLabel 

Definition at line 51 of file ComputeAniso.h.

Constructor & Destructor Documentation

AnisoElem::AnisoElem ( )
inline

Definition at line 12 of file ComputeAniso.inl.

12 { ; }
AnisoElem::AnisoElem ( AtomID  atom0,
const TupleSignature sig,
const AnisoValue v 
)
inline

Definition at line 14 of file ComputeAniso.inl.

References NAMD_die().

14  {
15  NAMD_die("Can't use Aniso with memory optimized version of NAMD.");
16  // atomID[0] = atom0;
17  // atomID[1] = atom0 + sig->offset[0];
18  // atomID[2] = atom0 + sig->offset[1];
19  // atomID[3] = atom0 + sig->offset[2];
20  // value = &v[sig->tupleParamType];
21 }
void NAMD_die(const char *err_msg)
Definition: common.C:85
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.

24  {
25  atomID[0] = a->atom1;
26  atomID[1] = a->atom2;
27  atomID[2] = a->atom3;
28  atomID[3] = a->atom4;
29  value = a; // expect v to be NULL
30  }
int32 atom2
Definition: structures.h:133
int32 atom3
Definition: structures.h:134
int32 atom1
Definition: structures.h:132
AtomID atomID[size]
Definition: ComputeAniso.h:22
int32 atom4
Definition: structures.h:135
const AnisoValue * value
Definition: ComputeAniso.h:43
AnisoElem::AnisoElem ( AtomID  atom0,
AtomID  atom1,
AtomID  atom2,
AtomID  atom3 
)
inline

Definition at line 32 of file ComputeAniso.inl.

References atomID.

34  {
35  // do not rearrange atom ordering of Aniso
36  // the first atom is special
37  atomID[0] = atom0;
38  atomID[1] = atom1;
39  atomID[2] = atom2;
40  atomID[3] = atom3;
41  }
AtomID atomID[size]
Definition: ComputeAniso.h:22
AnisoElem::~AnisoElem ( )
inline

Definition at line 58 of file ComputeAniso.h.

58 {};

Member Function Documentation

void AnisoElem::computeForce ( AnisoElem tuples,
int  ntuple,
BigReal reduction,
BigReal pressureProfileData 
)
static

Definition at line 41 of file ComputeAniso.C.

References SimParameters::alchOn, anisoEnergyIndex, anisoEnergyIndex_f, anisoEnergyIndex_ti_1, anisoEnergyIndex_ti_2, atomID, DebugM, Lattice::delta(), TuplePatchElem::f, Patch::flags, Molecule::get_fep_bonded_type(), SimParameters::getBondLambda(), SimParameters::getCurrentLambda(), SimParameters::getCurrentLambda2(), aniso::k11, aniso::k22, aniso::k33, Patch::lattice, localIndex, Node::molecule, Node::Object(), p, TuplePatchElem::p, CompAtom::partition, CompAtom::position, pp_clamp(), pp_reduction(), pressureProfileAtomTypes, pressureProfileMin, pressureProfileSlabs, pressureProfileThickness, Vector::rlength(), scale, Node::simParameters, simParams, SimParameters::singleTopology, size, Flags::step, value, TuplePatchElem::x, Vector::x, Vector::y, and Vector::z.

43 {
44  const Lattice & lattice = tuples[0].p[0]->p->lattice;
45 
46  //fepb BKR
48  const int step = tuples[0].p[0]->p->flags.step;
49  const BigReal alchLambda = simParams->getCurrentLambda(step);
50  const BigReal alchLambda2 = simParams->getCurrentLambda2(step);
51  const BigReal bond_lambda_1 = simParams->getBondLambda(alchLambda);
52  const BigReal bond_lambda_2 = simParams->getBondLambda(1-alchLambda);
53  const BigReal bond_lambda_12 = simParams->getBondLambda(alchLambda2);
54  const BigReal bond_lambda_22 = simParams->getBondLambda(1-alchLambda2);
55  Molecule *const mol = Node::Object()->molecule;
56  //fepe
57 
58  for ( int ituple=0; ituple<ntuple; ++ituple ) {
59  const AnisoElem &tup = tuples[ituple];
60  enum { size = 4 };
61  const AtomID (&atomID)[size](tup.atomID);
62  const int (&localIndex)[size](tup.localIndex);
63  TuplePatchElem * const(&p)[size](tup.p);
64  const Real (&scale)(tup.scale);
65  const AnisoValue * const(&value)(tup.value);
66 
67  DebugM(3, "::computeForce() localIndex = " << localIndex[0] << " "
68  << localIndex[1] << " " << localIndex[2] << " "
69  << localIndex[3] << std::endl);
70 
71 #ifdef CALCULATE_ANISO
72  // used some comments from Ed Harder's implementation in CHARMM
73 
74  const BigReal kpar0 = 2*value->k11; // force constants
75  const BigReal kperp0 = 2*value->k22;
76  const BigReal kiso0 = 2*value->k33;
77 
78  const Position & ri = p[0]->x[localIndex[0]].position; // atom I
79  const Position & rj = p[0]->x[localIndex[0]+1].position; // atom I's Drude
80  const Position & rl = p[1]->x[localIndex[1]].position; // atom L
81  const Position & rm = p[2]->x[localIndex[2]].position; // atom M
82  const Position & rn = p[3]->x[localIndex[3]].position; // atom N
83 
84  // calculate parallel and perpendicular displacement vectors
85  Vector r_il = lattice.delta(ri,rl); // shortest vector image: ri - rl
86  Vector r_mn = lattice.delta(rm,rn); // shortest vector image: rm - rn
87 
88  BigReal r_il_invlen = r_il.rlength(); // need recip lengths of r_il, r_mn
89  BigReal r_mn_invlen = r_mn.rlength();
90 
91  Vector u1 = r_il * r_il_invlen; // normalize r_il, r_mn
92  Vector u2 = r_mn * r_mn_invlen;
93 
94  Vector dr = rj - ri; // Drude displacement vector (ri, rj are in same patch)
95 
96  BigReal dpar = dr * u1; // parallel displacement
97  BigReal dperp = dr * u2; // perpendicular displacement
98 
99  // aniso spring energy
100  // kpar reduces response along carbonyl vector
101  // kperp reduces response perp to bond vector
102  // (reg in and out of plane response)
103  BigReal eaniso;
104  eaniso = 0.5*kpar0*dpar*dpar + 0.5*kperp0*dperp*dperp + 0.5*kiso0*(dr*dr);
105 
106  // calculate force vectors in one direction only:
107  // fi = -(fj + fl), fn = -fm
108 
109  // force on atom j
110  Vector fj = -kiso0 * dr;
111  fj -= kpar0 * dpar * u1;
112  fj -= kperp0 * dperp * u2;
113 
114  // force on atom l
115  Vector fl = kpar0 * dpar * r_il_invlen * dr;
116  fl -= kpar0 * dpar * dpar * r_il_invlen * u1;
117 
118  // force on atom m
119  Vector fm = kperp0 * dperp * dperp * r_mn_invlen * u2;
120  fm -= kperp0 * dperp * r_mn_invlen * dr;
121 
122  //fepb - BKR scaling of alchemical bonded terms
123  // NB: TI derivative is the _unscaled_ energy.
124  if ( simParams->alchOn && !simParams->singleTopology) {
125  switch ( mol->get_fep_bonded_type(atomID, 4) ) {
126  case 1:
127  reduction[anisoEnergyIndex_ti_1] += eaniso;
128  reduction[anisoEnergyIndex_f] += (bond_lambda_12 - bond_lambda_1)*eaniso;
129  eaniso *= bond_lambda_1;
130  fj *= bond_lambda_1;
131  fl *= bond_lambda_1;
132  fm *= bond_lambda_1;
133  break;
134  case 2:
135  reduction[anisoEnergyIndex_ti_2] += eaniso;
136  reduction[anisoEnergyIndex_f] += (bond_lambda_22 - bond_lambda_2)*eaniso;
137  eaniso *= bond_lambda_2;
138  fj *= bond_lambda_2;
139  fl *= bond_lambda_2;
140  fm *= bond_lambda_2;
141  break;
142  }
143  }
144  //fepe
145 
146  // accumulate forces
147  p[0]->f[localIndex[0]] -= (fj + fl);
148  p[0]->f[localIndex[0]+1] += fj;
149  p[1]->f[localIndex[1]] += fl;
150  p[2]->f[localIndex[2]] += fm;
151  p[3]->f[localIndex[3]] -= fm;
152 
153  // update potential
154  reduction[anisoEnergyIndex] += eaniso;
155 
156  // update virial
157  reduction[virialIndex_XX] += fj.x * dr.x - fl.x * r_il.x + fm.x * r_mn.x;
158  reduction[virialIndex_XY] += fj.x * dr.y - fl.x * r_il.y + fm.x * r_mn.y;
159  reduction[virialIndex_XZ] += fj.x * dr.z - fl.x * r_il.z + fm.x * r_mn.z;
160  reduction[virialIndex_YX] += fj.y * dr.x - fl.y * r_il.x + fm.y * r_mn.x;
161  reduction[virialIndex_YY] += fj.y * dr.y - fl.y * r_il.y + fm.y * r_mn.y;
162  reduction[virialIndex_YZ] += fj.y * dr.z - fl.y * r_il.z + fm.y * r_mn.z;
163  reduction[virialIndex_ZX] += fj.z * dr.x - fl.z * r_il.x + fm.z * r_mn.x;
164  reduction[virialIndex_ZY] += fj.z * dr.y - fl.z * r_il.y + fm.z * r_mn.y;
165  reduction[virialIndex_ZZ] += fj.z * dr.z - fl.z * r_il.z + fm.z * r_mn.z;
166 
167  // update pressure profile data
168  if (pressureProfileData) {
169  BigReal zi = p[0]->x[localIndex[0]].position.z;
170  BigReal zj = p[0]->x[localIndex[0]+1].position.z;
171  BigReal zl = p[1]->x[localIndex[1]].position.z;
172  BigReal zm = p[2]->x[localIndex[2]].position.z;
173  BigReal zn = p[3]->x[localIndex[3]].position.z;
174  int ni = (int)floor((zi-pressureProfileMin)/pressureProfileThickness);
175  int nj = (int)floor((zj-pressureProfileMin)/pressureProfileThickness);
176  int nl = (int)floor((zl-pressureProfileMin)/pressureProfileThickness);
177  int nm = (int)floor((zm-pressureProfileMin)/pressureProfileThickness);
178  int nn = (int)floor((zn-pressureProfileMin)/pressureProfileThickness);
184  int pi = p[0]->x[localIndex[0]].partition;
185  int pj = p[0]->x[localIndex[0]+1].partition;
186  int pl = p[1]->x[localIndex[1]].partition;
187  int pm = p[2]->x[localIndex[2]].partition;
188  int pn = p[3]->x[localIndex[3]].partition;
189  int pt = pressureProfileAtomTypes;
191  pj, pi, pt, fj.x * dr.x, fj.y * dr.y, fj.z * dr.z,
192  pressureProfileData);
194  pi, pl, pt, -fl.x * r_il.x, -fl.y * r_il.y, -fl.z * r_il.z,
195  pressureProfileData);
197  pm, pn, pt, fm.x * r_mn.x, fm.y * r_mn.y, fm.z * r_mn.z,
198  pressureProfileData);
199  }
200 #endif
201 
202  }
203 }
static Node * Object()
Definition: Node.h:86
unsigned char partition
Definition: NamdTypes.h:56
Real k11
Definition: structures.h:136
int AtomID
Definition: NamdTypes.h:29
Lattice & lattice
Definition: Patch.h:126
void pp_reduction(int nslabs, int n1, int n2, int atype1, int atype2, int numtypes, BigReal vxx, BigReal vyy, BigReal vzz, BigReal *reduction)
Definition: Vector.h:64
static BigReal pressureProfileMin
Definition: ComputeAniso.h:40
SimParameters * simParameters
Definition: Node.h:178
float Real
Definition: common.h:109
#define DebugM(x, y)
Definition: Debug.h:59
BigReal z
Definition: Vector.h:66
Position position
Definition: NamdTypes.h:53
static int pressureProfileSlabs
Definition: ComputeAniso.h:37
int get_fep_bonded_type(const int *atomID, unsigned int order) const
Definition: Molecule.h:1389
Real scale
Definition: ComputeAniso.h:25
static BigReal pressureProfileThickness
Definition: ComputeAniso.h:39
Flags flags
Definition: Patch.h:127
void pp_clamp(int &n, int nslabs)
BigReal rlength(void)
Definition: Vector.h:177
BigReal getBondLambda(const BigReal)
BigReal getCurrentLambda2(const int)
Vector delta(const Position &pos1, const Position &pos2) const
Definition: Lattice.h:144
BigReal x
Definition: Vector.h:66
int localIndex[size]
Definition: ComputeAniso.h:23
Real k22
Definition: structures.h:137
Real k33
Definition: structures.h:138
#define simParams
Definition: Output.C:127
static int pressureProfileAtomTypes
Definition: ComputeAniso.h:38
BigReal y
Definition: Vector.h:66
BigReal getCurrentLambda(const int)
AtomID atomID[size]
Definition: ComputeAniso.h:22
TuplePatchElem * p[size]
Definition: ComputeAniso.h:24
const AnisoValue * value
Definition: ComputeAniso.h:43
Molecule * molecule
Definition: Node.h:176
double BigReal
Definition: common.h:114
int step
Definition: PatchTypes.h:16
void AnisoElem::getMoleculePointers ( Molecule mol,
int *  count,
int32 ***  byatom,
Aniso **  structarray 
)
static

Definition at line 26 of file ComputeAniso.C.

References NAMD_die(), and Molecule::numAnisos.

27 {
28 #ifdef MEM_OPT_VERSION
29  NAMD_die("Should not be called in AnisoElem::getMoleculePointers in memory optimized version!");
30 #else
31  *count = mol->numAnisos;
32  *byatom = mol->anisosByAtom;
33  *structarray = mol->anisos;
34 #endif
35 }
int numAnisos
Number of anisotropic terms.
Definition: Molecule.h:584
void NAMD_die(const char *err_msg)
Definition: common.C:85
void AnisoElem::getParameterPointers ( Parameters p,
const AnisoValue **  v 
)
static

Definition at line 37 of file ComputeAniso.C.

37  {
38  *v = NULL; // parameters are stored in the structure
39 }
static void AnisoElem::getTupleInfo ( AtomSignature sig,
int *  count,
TupleSignature **  t 
)
inlinestatic

Definition at line 30 of file ComputeAniso.h.

References NAMD_die().

30  {
31  NAMD_die("Can't use Aniso with memory optimized version of NAMD.");
32  // *count = sig->ansioCnt;
33  // *t = sig->anisoSigs;
34  }
void NAMD_die(const char *err_msg)
Definition: common.C:85
int AnisoElem::hash ( void  ) const
inline

Definition at line 45 of file ComputeAniso.h.

References atomID.

45  {
46  return 0x7FFFFFFF &((atomID[0]<<24) + (atomID[1]<<16) + (atomID[2]<<8) + atomID[3]);
47  }
AtomID atomID[size]
Definition: ComputeAniso.h:22
int AnisoElem::operator< ( const AnisoElem a) const
inline

Definition at line 49 of file ComputeAniso.inl.

References atomID.

50  {
51  return (atomID[0] < a.atomID[0] ||
52  (atomID[0] == a.atomID[0] &&
53  (atomID[1] < a.atomID[1] ||
54  (atomID[1] == a.atomID[1] &&
55  (atomID[2] < a.atomID[2] ||
56  (atomID[2] == a.atomID[2] &&
57  atomID[3] < a.atomID[3]
58  ))))));
59  }
AtomID atomID[size]
Definition: ComputeAniso.h:22
int AnisoElem::operator== ( const AnisoElem a) const
inline

Definition at line 43 of file ComputeAniso.inl.

References atomID.

44  {
45  return (a.atomID[0] == atomID[0] && a.atomID[1] == atomID[1] &&
46  a.atomID[2] == atomID[2] && a.atomID[3] == atomID[3]);
47  }
AtomID atomID[size]
Definition: ComputeAniso.h:22
void AnisoElem::submitReductionData ( BigReal data,
SubmitReduction reduction 
)
static

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: