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

Lattice Class Reference

#include <Lattice.h>

List of all members.

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

int index (int i=0, int j=0, int k=0)


Constructor & Destructor Documentation

Lattice::Lattice void   )  [inline]
 

Definition at line 28 of file Lattice.h.

00028                 : a1(0,0,0), a2(0,0,0), a3(0,0,0),
00029                   b1(0,0,0), b2(0,0,0), b3(0,0,0),
00030                   o(0,0,0), p1(0), p2(0), p3(0) {};


Member Function Documentation

Vector Lattice::a  )  const [inline]
 

Definition at line 241 of file Lattice.h.

Referenced by HomePatch::doMarginCheck(), GridforceGrid::initialize(), ComputePmeMgr::initialize(), ComputePmeMgr::initialize_pencils(), Controller::printEnergies(), ComputeExtMgr::recvCoord(), PatchMap::sizeGrid(), and Controller::writeExtendedSystemData().

00241 { return a1; }

int Lattice::a_p  )  const [inline]
 

Definition at line 262 of file Lattice.h.

Referenced by calc_fulldirect(), Controller::printEnergies(), ComputeExtMgr::recvCoord(), PatchMap::sizeGrid(), Controller::writeExtendedSystemData(), and Controller::writeExtendedSystemLabels().

00262 { return p1; }

Vector Lattice::a_r  )  const [inline]
 

Definition at line 257 of file Lattice.h.

Referenced by HomePatch::doMarginCheck(), ComputePmeMgr::initialize(), ComputePmeMgr::initialize_pencils(), WorkDistrib::patchMapInit(), scale_coordinates(), scale_forces(), and PatchMap::sizeGrid().

00257 { return b1; }

Position Lattice::apply_transform Position  data,
const Transform t
const [inline]
 

Definition at line 140 of file Lattice.h.

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

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

00141   {
00142     return ( data + t.i*a1 + t.j*a2 + t.k*a3 );
00143   }

Vector Lattice::b  )  const [inline]
 

Definition at line 242 of file Lattice.h.

Referenced by HomePatch::doMarginCheck(), GridforceGrid::initialize(), ComputePmeMgr::initialize_pencils(), Controller::printEnergies(), ComputeExtMgr::recvCoord(), PatchMap::sizeGrid(), and Controller::writeExtendedSystemData().

00242 { return a2; }

int Lattice::b_p  )  const [inline]
 

Definition at line 263 of file Lattice.h.

Referenced by calc_fulldirect(), Controller::printEnergies(), ComputeExtMgr::recvCoord(), PatchMap::sizeGrid(), Controller::writeExtendedSystemData(), and Controller::writeExtendedSystemLabels().

00263 { return p2; }

Vector Lattice::b_r  )  const [inline]
 

Definition at line 258 of file Lattice.h.

Referenced by HomePatch::doMarginCheck(), ComputePmeMgr::initialize_pencils(), WorkDistrib::patchMapInit(), scale_coordinates(), scale_forces(), and PatchMap::sizeGrid().

00258 { return b2; }

Vector Lattice::c  )  const [inline]
 

Definition at line 243 of file Lattice.h.

Referenced by ComputeNonbondedSelf::doForce(), ComputeNonbondedPair::doForce(), HomePatch::doMarginCheck(), ComputeHomeTuples< BondElem, Bond, BondValue >::doWork(), ComputeEwald::doWork(), GridforceGrid::initialize(), Controller::langevinPiston1(), Controller::langevinPiston2(), Controller::printEnergies(), HomePatch::rattle1(), ComputeExtMgr::recvCoord(), PatchMap::sizeGrid(), Sequencer::submitHalfstep(), Sequencer::submitReductions(), and Controller::writeExtendedSystemData().

00243 { return a3; }

int Lattice::c_p  )  const [inline]
 

Definition at line 264 of file Lattice.h.

Referenced by calc_fulldirect(), Controller::printEnergies(), ComputeExtMgr::recvCoord(), PatchMap::sizeGrid(), Controller::writeExtendedSystemData(), and Controller::writeExtendedSystemLabels().

00264 { return p3; }

Vector Lattice::c_r  )  const [inline]
 

Definition at line 259 of file Lattice.h.

Referenced by HomePatch::doMarginCheck(), WorkDistrib::patchMapInit(), scale_coordinates(), scale_forces(), and PatchMap::sizeGrid().

00259 { return b3; }

Vector Lattice::delta const Position pos1  )  const [inline]
 

Definition at line 188 of file Lattice.h.

References Position.

00189   {
00190     Vector diff = pos1 - o;
00191     Vector result = diff;
00192     if ( p1 ) result -= a1*floor(0.5 + b1*diff);
00193     if ( p2 ) result -= a2*floor(0.5 + b2*diff);
00194     if ( p3 ) result -= a3*floor(0.5 + b3*diff);
00195     return result;
00196   }

Vector Lattice::delta const Position pos1,
const Position pos2
const [inline]
 

Definition at line 152 of file Lattice.h.

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

Referenced by ImproperElem::computeForce(), DihedralElem::computeForce(), CrosstermElem::computeForce(), BondElem::computeForce(), AngleElem::computeForce(), and ComputeGridForce::doForce().

00153   {
00154     Vector diff = pos1 - pos2;
00155 #ifdef ARCH_POWERPC   //Prevents stack temporaries
00156     Vector result = diff;
00157     if ( p1 ) {
00158       BigReal fval = floor(0.5 + b1*diff); 
00159       result.x -= a1.x *fval;    
00160       result.y -= a1.y *fval;    
00161       result.z -= a1.z *fval;    
00162     }
00163     if ( p2 ) {
00164       BigReal fval = floor(0.5 + b2*diff);
00165       result.x -= a2.x * fval;
00166       result.y -= a2.y * fval;
00167       result.z -= a2.z * fval;
00168     }
00169     if ( p3 ) {
00170       BigReal fval = floor(0.5 + b3*diff);
00171       result.x -= a3.x * fval;
00172       result.y -= a3.y * fval;
00173       result.z -= a3.z * fval;
00174     }
00175     return result;
00176 #else
00177     BigReal f1 = p1 ? floor(0.5 + b1*diff) : 0.;
00178     BigReal f2 = p2 ? floor(0.5 + b2*diff) : 0.;
00179     BigReal f3 = p3 ? floor(0.5 + b3*diff) : 0.;
00180     diff.x -= f1*a1.x + f2*a2.x + f3*a3.x;
00181     diff.y -= f1*a1.y + f2*a2.y + f3*a3.y;
00182     diff.z -= f1*a1.z + f2*a2.z + f3*a3.z;
00183     return diff;
00184 #endif
00185   }

int Lattice::index int  i = 0,
int  j = 0,
int  k = 0
[inline, static]
 

Definition at line 33 of file Lattice.h.

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

00034   {
00035     return 9 * (k+1) + 3 * (j+1) + (i+1);
00036   }

Position Lattice::nearest Position  data,
ScaledPosition  ref,
Transform t
const [inline]
 

Definition at line 115 of file Lattice.h.

References BigReal, Transform::i, Transform::j, Transform::k, Position, ScaledPosition, Vector::x, Vector::y, and Vector::z.

00116   {
00117     ScaledPosition sn = scale(data);
00118     if ( p1 ) {
00119       BigReal tmp = sn.x - ref.x;
00120       BigReal rit = floor(0.5 + tmp);
00121       sn.x -= rit;
00122       t->i -= (int) rit;
00123     }
00124     if ( p2 ) {
00125       BigReal tmp = sn.y - ref.y;
00126       BigReal rit = floor(0.5 + tmp);
00127       sn.y -= rit;
00128       t->j -= (int) rit;
00129     }
00130     if ( p3 ) {
00131       BigReal tmp = sn.z - ref.z;
00132       BigReal rit = floor(0.5 + tmp);
00133       sn.z -= rit;
00134       t->k -= (int) rit;
00135     }
00136     return unscale(sn);
00137   }

Position Lattice::nearest Position  data,
ScaledPosition  ref
const [inline]
 

Definition at line 98 of file Lattice.h.

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

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

00099   {
00100     ScaledPosition sn = scale(data);
00101     if ( p1 ) {
00102       sn.x -= floor(0.5 + sn.x - ref.x);
00103     }
00104     if ( p2 ) {
00105       sn.y -= floor(0.5 + sn.y - ref.y);
00106     }
00107     if ( p3 ) {
00108       sn.z -= floor(0.5 + sn.z - ref.z);
00109     }
00110     return unscale(sn);
00111   }

Vector Lattice::offset int  i  )  const [inline]
 

Definition at line 235 of file Lattice.h.

Referenced by ComputeNonbondedPair::doForce().

00236   {
00237     return ( (i%3-1) * a1 + ((i/3)%3-1) * a2 + (i/9-1) * a3 );
00238   }

Vector Lattice::origin  )  const [inline]
 

Definition at line 251 of file Lattice.h.

Referenced by ComputeNonbondedSelf::doForce(), ComputeNonbondedPair::doForce(), ComputeEField::doForce(), ComputeHomeTuples< BondElem, Bond, BondValue >::doWork(), ComputeEwald::doWork(), WorkDistrib::patchMapInit(), Controller::printEnergies(), HomePatch::rattle1(), Controller::receivePressure(), scale_coordinates(), Sequencer::submitHalfstep(), Sequencer::submitReductions(), and Controller::writeExtendedSystemData().

00252   {
00253     return o;
00254   }

int Lattice::orthogonal  )  const [inline]
 

Definition at line 246 of file Lattice.h.

00246                          {
00247     return ( ! ( a1.y || a1.z || a2.x || a2.z || a3.x || a3.y ) );
00248   }

void Lattice::rescale Position p,
Tensor  factor
const [inline]
 

Definition at line 77 of file Lattice.h.

References Position.

00078   {
00079     p -= o;
00080     p = factor * p;
00081     p += o;
00082   }

void Lattice::rescale Tensor  factor  )  [inline]
 

Definition at line 68 of file Lattice.h.

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

00069   {
00070     a1 = factor * a1;
00071     a2 = factor * a2;
00072     a3 = factor * a3;
00073     recalculate();
00074   }

Position Lattice::reverse_transform Position  data,
const Transform t
const [inline]
 

Definition at line 146 of file Lattice.h.

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

Referenced by HomePatch::depositMigration(), ComputeStir::doForce(), ComputeGridForce::doForce(), ComputeEField::doForce(), ComputeConsTorque::doForce(), ComputeConsForce::doForce(), PatchMgr::moveAllBy(), PatchMgr::moveAtom(), ComputeGlobal::recvResults(), and CollectionMgr::submitPositions().

00147   {
00148     return ( data - t.i*a1 - t.j*a2 - t.k*a3 );
00149   }

ScaledPosition Lattice::scale Position  p  )  const [inline]
 

Definition at line 91 of file Lattice.h.

References Position, and ScaledPosition.

Referenced by PatchMap::assignToPatch(), HomePatch::doAtomMigration(), and HomePatch::doMarginCheck().

00092   {
00093     p -= o;
00094     return Vector(b1*p,b2*p,b3*p);
00095   }

void Lattice::set Vector  A,
Vector  B,
Vector  C,
Position  Origin
[inline]
 

Definition at line 45 of file Lattice.h.

References Vector::length(), and Position.

00046   {
00047     a1 = A; a2 = B; a3 = C; o = Origin;
00048     p1 = ( a1.length2() ? 1 : 0 );
00049     p2 = ( a2.length2() ? 1 : 0 );
00050     p3 = ( a3.length2() ? 1 : 0 );
00051     if ( ! p1 ) a1 = Vector(1.0,0.0,0.0);
00052     if ( ! p2 ) {
00053       Vector u1 = a1 / a1.length();
00054       Vector e_z(0.0,0.0,1.0);
00055       if ( fabs(e_z * u1) < 0.9 ) { a2 = cross(e_z,a1); }
00056       else { a2 = cross(Vector(1.0,0.0,0.0),a1); }
00057       a2 /= a2.length();
00058     }
00059     if ( ! p3 ) {
00060       a3 = cross(a1,a2);
00061       a3 /= a3.length();
00062     }
00063     if ( volume() < 0.0 ) a3 *= -1.0;
00064     recalculate();
00065   }

void Lattice::set Vector  A,
Vector  B,
Vector  C
[inline]
 

Definition at line 39 of file Lattice.h.

00040   {
00041     set(A,B,C,o);
00042   }

Position Lattice::unscale ScaledPosition  s  )  const [inline]
 

Definition at line 85 of file Lattice.h.

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

Referenced by HomePatch::doPairlistCheck().

00086   {
00087     return (o + a1*s.x + a2*s.y + a3*s.z);
00088   }

BigReal Lattice::volume void   )  const [inline]
 

Definition at line 266 of file Lattice.h.

References BigReal.

Referenced by PressureProfileReduction::getData(), Controller::langevinPiston1(), Controller::langevinPiston2(), Controller::printEnergies(), Controller::receivePressure(), and ComputeEwald::recvResults().

00267   {
00268     return ( p1 && p2 && p3 ? cross(a1,a2) * a3 : 0.0 );
00269   }

Vector Lattice::wrap_delta const Position pos1  )  const [inline]
 

Definition at line 199 of file Lattice.h.

References Position.

Referenced by ComputeGridForce::doForce(), ComputeEwald::doWork(), and wrap_coor_int().

00200   {
00201     Vector diff = pos1 - o;
00202     Vector result(0.,0.,0.);
00203     if ( p1 ) result -= a1*floor(0.5 + b1*diff);
00204     if ( p2 ) result -= a2*floor(0.5 + b2*diff);
00205     if ( p3 ) result -= a3*floor(0.5 + b3*diff);
00206     return result;
00207   }

Vector Lattice::wrap_nearest_delta Position  pos1  )  const [inline]
 

Definition at line 210 of file Lattice.h.

References BigReal, Vector::length2(), and Position.

Referenced by wrap_coor_int().

00211   {
00212     Vector diff = pos1 - o;
00213     Vector result0(0.,0.,0.);
00214     if ( p1 ) result0 -= a1*floor(0.5 + b1*diff);
00215     if ( p2 ) result0 -= a2*floor(0.5 + b2*diff);
00216     if ( p3 ) result0 -= a3*floor(0.5 + b3*diff);
00217     diff += result0;
00218     BigReal dist = diff.length2();
00219     Vector result(0.,0.,0.);
00220     for ( int i1=-p1; i1<=p1; ++i1 ) {
00221       for ( int i2 =-p2; i2<=p2; ++i2 ) {
00222         for ( int i3 =-p3; i3<=p3; ++i3 ) {
00223           Vector newresult = i1*a1+i2*a2+i3*a3;
00224           BigReal newdist = (diff+newresult).length2();
00225           if ( newdist < dist ) {
00226             dist = newdist;
00227             result = newresult;
00228           }
00229         }
00230       }
00231     }
00232     return result0 + result;
00233   }


The documentation for this class was generated from the following file:
Generated on Fri Jul 25 04:07:21 2008 for NAMD by  doxygen 1.3.9.1