NAMD
Public Member Functions | Static Public Member Functions | List of all members
Lattice Class Reference

#include <Lattice.h>

Public Member Functions

 Lattice (void)
 
void set (Vector A, Vector B, Vector C)
 
void set (Vector A, Vector B, Vector C, Position Origin)
 
void rescale (Tensor factor)
 
void rescale (Position &p, Tensor factor) const
 
Position unscale (ScaledPosition s) const
 
ScaledPosition scale (Position p) const
 
Position nearest (Position data, ScaledPosition ref) const
 
Position nearest (Position data, ScaledPosition ref, Transform *t) const
 
Position apply_transform (Position data, const Transform &t) const
 
Position reverse_transform (Position data, const Transform &t) const
 
Vector delta (const Position &pos1, const Position &pos2) const
 
Vector delta (const Position &pos1) const
 
Vector wrap_delta (const Position &pos1) const
 
Vector wrap_nearest_delta (Position pos1) const
 
Vector offset (int i) const
 
Vector a () const
 
Vector b () const
 
Vector c () const
 
int orthogonal () const
 
Vector origin () const
 
Vector a_r () const
 
Vector b_r () const
 
Vector c_r () const
 
int a_p () const
 
int b_p () const
 
int c_p () const
 
BigReal volume (void) const
 

Static Public Member Functions

static int index (int i=0, int j=0, int k=0)
 
static int offset_a (int i)
 
static int offset_b (int i)
 
static int offset_c (int i)
 

Detailed Description

Definition at line 17 of file Lattice.h.

Constructor & Destructor Documentation

Lattice::Lattice ( void  )
inline

Definition at line 20 of file Lattice.h.

20  : a1(0,0,0), a2(0,0,0), a3(0,0,0),
21  b1(0,0,0), b2(0,0,0), b3(0,0,0),
22  o(0,0,0), p1(0), p2(0), p3(0) {};

Member Function Documentation

Vector Lattice::a ( ) const
inline
int Lattice::a_p ( ) const
inline
Vector Lattice::a_r ( ) const
inline
Position Lattice::apply_transform ( Position  data,
const Transform t 
) const
inline

Definition at line 132 of file Lattice.h.

References Transform::i, Transform::j, and Transform::k.

Referenced by Sequencer::berendsenPressure(), WorkDistrib::createAtomLists(), HomePatch::depositMigration(), Sequencer::langevinPiston(), PatchMgr::moveAllBy(), and PatchMgr::moveAtom().

133  {
134  return ( data + t.i*a1 + t.j*a2 + t.k*a3 );
135  }
signed char j
Definition: NamdTypes.h:38
signed char i
Definition: NamdTypes.h:38
signed char k
Definition: NamdTypes.h:38
Vector Lattice::b ( ) const
inline
int Lattice::b_p ( ) const
inline
Vector Lattice::b_r ( ) const
inline
Vector Lattice::c ( ) const
inline
int Lattice::c_p ( ) const
inline
Vector Lattice::c_r ( ) const
inline
Vector Lattice::delta ( const Position pos1,
const Position pos2 
) const
inline

Definition at line 144 of file Lattice.h.

References namdnearbyint, Vector::x, Vector::y, and Vector::z.

Referenced by AngleElem::computeForce(), CrosstermElem::computeForce(), ImproperElem::computeForce(), DihedralElem::computeForce(), TholeElem::computeForce(), AnisoElem::computeForce(), BondElem::computeForce(), ExclElem::computeForce(), GromacsPairElem::computeForce(), ComputeRestraints::doForce(), colvarproxy_namd::position_distance(), and ComputeQM::processFullQM().

145  {
146  Vector diff = pos1 - pos2;
147 #ifdef ARCH_POWERPC //Prevents stack temporaries
148  Vector result = diff;
149  if ( p1 ) {
150  BigReal fval = namdnearbyint(b1*diff);
151  result.x -= a1.x *fval;
152  result.y -= a1.y *fval;
153  result.z -= a1.z *fval;
154  }
155  if ( p2 ) {
156  BigReal fval = namdnearbyint(b2*diff);
157  result.x -= a2.x * fval;
158  result.y -= a2.y * fval;
159  result.z -= a2.z * fval;
160  }
161  if ( p3 ) {
162  BigReal fval = namdnearbyint(b3*diff);
163  result.x -= a3.x * fval;
164  result.y -= a3.y * fval;
165  result.z -= a3.z * fval;
166  }
167  return result;
168 #else
169  BigReal f1 = p1 ? namdnearbyint(b1*diff) : 0.;
170  BigReal f2 = p2 ? namdnearbyint(b2*diff) : 0.;
171  BigReal f3 = p3 ? namdnearbyint(b3*diff) : 0.;
172  diff.x -= f1*a1.x + f2*a2.x + f3*a3.x;
173  diff.y -= f1*a1.y + f2*a2.y + f3*a3.y;
174  diff.z -= f1*a1.z + f2*a2.z + f3*a3.z;
175  return diff;
176 #endif
177  }
#define namdnearbyint(x)
Definition: common.h:74
Definition: Vector.h:64
BigReal z
Definition: Vector.h:66
BigReal x
Definition: Vector.h:66
BigReal y
Definition: Vector.h:66
double BigReal
Definition: common.h:112
Vector Lattice::delta ( const Position pos1) const
inline

Definition at line 195 of file Lattice.h.

References namdnearbyint.

196  {
197  Vector diff = pos1 - o;
198  Vector result = diff;
199  if ( p1 ) result -= a1*namdnearbyint(b1*diff);
200  if ( p2 ) result -= a2*namdnearbyint(b2*diff);
201  if ( p3 ) result -= a3*namdnearbyint(b3*diff);
202  return result;
203  }
#define namdnearbyint(x)
Definition: common.h:74
Definition: Vector.h:64
static int Lattice::index ( int  i = 0,
int  j = 0,
int  k = 0 
)
inlinestatic

Definition at line 25 of file Lattice.h.

Referenced by PatchMap::downstreamNeighbors(), PatchMap::getPatchesInOctet(), PatchMap::oneAwayNeighbors(), PatchMap::oneOrTwoAwayNeighbors(), and PatchMap::upstreamNeighbors().

26  {
27  return 9 * (k+1) + 3 * (j+1) + (i+1);
28  }
Position Lattice::nearest ( Position  data,
ScaledPosition  ref 
) const
inline

Definition at line 90 of file Lattice.h.

References namdnearbyint, scale(), unscale(), Vector::x, Vector::y, and Vector::z.

Referenced by WorkDistrib::createAtomLists(), and HomePatch::depositMigration().

91  {
92  ScaledPosition sn = scale(data);
93  if ( p1 ) {
94  sn.x -= namdnearbyint(sn.x - ref.x);
95  }
96  if ( p2 ) {
97  sn.y -= namdnearbyint(sn.y - ref.y);
98  }
99  if ( p3 ) {
100  sn.z -= namdnearbyint(sn.z - ref.z);
101  }
102  return unscale(sn);
103  }
#define namdnearbyint(x)
Definition: common.h:74
Definition: Vector.h:64
BigReal z
Definition: Vector.h:66
BigReal x
Definition: Vector.h:66
Position unscale(ScaledPosition s) const
Definition: Lattice.h:77
BigReal y
Definition: Vector.h:66
ScaledPosition scale(Position p) const
Definition: Lattice.h:83
Position Lattice::nearest ( Position  data,
ScaledPosition  ref,
Transform t 
) const
inline

Definition at line 107 of file Lattice.h.

References Transform::i, Transform::j, Transform::k, namdnearbyint, scale(), unscale(), Vector::x, Vector::y, and Vector::z.

108  {
109  ScaledPosition sn = scale(data);
110  if ( p1 ) {
111  BigReal tmp = sn.x - ref.x;
112  BigReal rit = namdnearbyint(tmp);
113  sn.x -= rit;
114  t->i -= (int) rit;
115  }
116  if ( p2 ) {
117  BigReal tmp = sn.y - ref.y;
118  BigReal rit = namdnearbyint(tmp);
119  sn.y -= rit;
120  t->j -= (int) rit;
121  }
122  if ( p3 ) {
123  BigReal tmp = sn.z - ref.z;
124  BigReal rit = namdnearbyint(tmp);
125  sn.z -= rit;
126  t->k -= (int) rit;
127  }
128  return unscale(sn);
129  }
#define namdnearbyint(x)
Definition: common.h:74
signed char j
Definition: NamdTypes.h:38
signed char i
Definition: NamdTypes.h:38
Definition: Vector.h:64
BigReal z
Definition: Vector.h:66
signed char k
Definition: NamdTypes.h:38
BigReal x
Definition: Vector.h:66
Position unscale(ScaledPosition s) const
Definition: Lattice.h:77
BigReal y
Definition: Vector.h:66
ScaledPosition scale(Position p) const
Definition: Lattice.h:83
double BigReal
Definition: common.h:112
Vector Lattice::offset ( int  i) const
inline

Definition at line 242 of file Lattice.h.

Referenced by ComputeNonbondedPair::doForce().

243  {
244  return ( (i%3-1) * a1 + ((i/3)%3-1) * a2 + (i/9-1) * a3 );
245  }
static int Lattice::offset_a ( int  i)
inlinestatic

Definition at line 247 of file Lattice.h.

Referenced by registerUserEventsForAllComputeObjs().

247 { return (i%3-1); }
static int Lattice::offset_b ( int  i)
inlinestatic

Definition at line 248 of file Lattice.h.

Referenced by registerUserEventsForAllComputeObjs().

248 { return ((i/3)%3-1); }
static int Lattice::offset_c ( int  i)
inlinestatic

Definition at line 249 of file Lattice.h.

Referenced by registerUserEventsForAllComputeObjs().

249 { return (i/9-1); }
Vector Lattice::origin ( ) const
inline
int Lattice::orthogonal ( ) const
inline

Definition at line 257 of file Lattice.h.

References Vector::x, Vector::y, and Vector::z.

Referenced by colvarproxy_namd::calculate(), and PmeKSpace::compute_energy().

257  {
258  return ( ! ( a1.y || a1.z || a2.x || a2.z || a3.x || a3.y ) );
259  }
BigReal z
Definition: Vector.h:66
BigReal x
Definition: Vector.h:66
BigReal y
Definition: Vector.h:66
void Lattice::rescale ( Tensor  factor)
inline

Definition at line 60 of file Lattice.h.

Referenced by Sequencer::berendsenPressure(), Controller::berendsenPressure(), Sequencer::langevinPiston(), Controller::langevinPiston1(), Sequencer::multigratorPressure(), and Controller::multigratorPressure().

61  {
62  a1 = factor * a1;
63  a2 = factor * a2;
64  a3 = factor * a3;
65  recalculate();
66  }
void Lattice::rescale ( Position p,
Tensor  factor 
) const
inline

Definition at line 69 of file Lattice.h.

70  {
71  p -= o;
72  p = factor * p;
73  p += o;
74  }
Position Lattice::reverse_transform ( Position  data,
const Transform t 
) const
inline
ScaledPosition Lattice::scale ( Position  p) const
inline
void Lattice::set ( Vector  A,
Vector  B,
Vector  C 
)
inline

Definition at line 31 of file Lattice.h.

Referenced by get_lattice_from_ts(), and SimParameters::readExtendedSystem().

32  {
33  set(A,B,C,o);
34  }
void set(Vector A, Vector B, Vector C)
Definition: Lattice.h:31
void Lattice::set ( Vector  A,
Vector  B,
Vector  C,
Position  Origin 
)
inline

Definition at line 37 of file Lattice.h.

References A, B, cross(), Vector::length(), Vector::length2(), and volume().

38  {
39  a1 = A; a2 = B; a3 = C; o = Origin;
40  p1 = ( a1.length2() ? 1 : 0 );
41  p2 = ( a2.length2() ? 1 : 0 );
42  p3 = ( a3.length2() ? 1 : 0 );
43  if ( ! p1 ) a1 = Vector(1.0,0.0,0.0);
44  if ( ! p2 ) {
45  Vector u1 = a1 / a1.length();
46  Vector e_z(0.0,0.0,1.0);
47  if ( fabs(e_z * u1) < 0.9 ) { a2 = cross(e_z,a1); }
48  else { a2 = cross(Vector(1.0,0.0,0.0),a1); }
49  a2 /= a2.length();
50  }
51  if ( ! p3 ) {
52  a3 = cross(a1,a2);
53  a3 /= a3.length();
54  }
55  if ( volume() < 0.0 ) a3 *= -1.0;
56  recalculate();
57  }
const BigReal A
Definition: Vector.h:64
__device__ __forceinline__ float3 cross(const float3 v1, const float3 v2)
BigReal length(void) const
Definition: Vector.h:169
AtomID Origin
Definition: ComputeQM.h:110
BigReal volume(void) const
Definition: Lattice.h:277
BigReal length2(void) const
Definition: Vector.h:173
const BigReal B
Position Lattice::unscale ( ScaledPosition  s) const
inline

Definition at line 77 of file Lattice.h.

References Vector::x, Vector::y, and Vector::z.

Referenced by ComputeNonbondedPair::doForce(), HomePatch::doPairlistCheck(), ComputeNonbondedCUDA::doWork(), Patch::forceBoxClosed(), nearest(), Patch::positionsReady(), and HomePatch::positionsReady().

78  {
79  return (o + a1*s.x + a2*s.y + a3*s.z);
80  }
BigReal z
Definition: Vector.h:66
BigReal x
Definition: Vector.h:66
BigReal y
Definition: Vector.h:66
BigReal Lattice::volume ( void  ) const
inline
Vector Lattice::wrap_delta ( const Position pos1) const
inline

Definition at line 206 of file Lattice.h.

References namdnearbyint.

Referenced by ComputeEwald::doWork(), ParallelIOMgr::recvFinalClusterCoor(), wrap_coor_int(), and GridforceGrid::wrap_position().

207  {
208  Vector diff = pos1 - o;
209  Vector result(0.,0.,0.);
210  if ( p1 ) result -= a1*namdnearbyint(b1*diff);
211  if ( p2 ) result -= a2*namdnearbyint(b2*diff);
212  if ( p3 ) result -= a3*namdnearbyint(b3*diff);
213  return result;
214  }
#define namdnearbyint(x)
Definition: common.h:74
Definition: Vector.h:64
Vector Lattice::wrap_nearest_delta ( Position  pos1) const
inline

Definition at line 217 of file Lattice.h.

References Vector::length2(), and namdnearbyint.

Referenced by ParallelIOMgr::recvFinalClusterCoor(), and wrap_coor_int().

218  {
219  Vector diff = pos1 - o;
220  Vector result0(0.,0.,0.);
221  if ( p1 ) result0 -= a1*namdnearbyint(b1*diff);
222  if ( p2 ) result0 -= a2*namdnearbyint(b2*diff);
223  if ( p3 ) result0 -= a3*namdnearbyint(b3*diff);
224  diff += result0;
225  BigReal dist = diff.length2();
226  Vector result(0.,0.,0.);
227  for ( int i1=-p1; i1<=p1; ++i1 ) {
228  for ( int i2 =-p2; i2<=p2; ++i2 ) {
229  for ( int i3 =-p3; i3<=p3; ++i3 ) {
230  Vector newresult = i1*a1+i2*a2+i3*a3;
231  BigReal newdist = (diff+newresult).length2();
232  if ( newdist < dist ) {
233  dist = newdist;
234  result = newresult;
235  }
236  }
237  }
238  }
239  return result0 + result;
240  }
#define namdnearbyint(x)
Definition: common.h:74
Definition: Vector.h:64
BigReal length2(void) const
Definition: Vector.h:173
double BigReal
Definition: common.h:112

The documentation for this class was generated from the following file: