--- branches/development/src/primitives/RigidBody.cpp 2012/07/06 22:01:58 1767 +++ branches/development/src/primitives/RigidBody.cpp 2013/01/29 19:10:04 1842 @@ -74,9 +74,7 @@ namespace OpenMD { void RigidBody::setA(const RotMat3x3d& a, int snapshotNo) { ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_] = a; - - //((snapshotMan_->getSnapshot(snapshotNo))->*storage_).electroFrame[localIndex_] = a.transpose() * sU_; - + for (unsigned int i = 0 ; i < atoms_.size(); ++i){ if (atoms_[i]->isDirectional()) { atoms_[i]->setA(refOrients_[i].transpose() * a, snapshotNo); @@ -94,7 +92,8 @@ namespace OpenMD { Vector3d force; Vector3d torque; Vector3d myEuler; - RealType phi, theta, psi; + RealType phi, theta; + // RealType psi; RealType cphi, sphi, ctheta, stheta; Vector3d ephi; Vector3d etheta; @@ -106,7 +105,7 @@ namespace OpenMD { phi = myEuler[0]; theta = myEuler[1]; - psi = myEuler[2]; + // psi = myEuler[2]; cphi = cos(phi); sphi = sin(phi); @@ -227,8 +226,12 @@ namespace OpenMD { Vector3d apos; Vector3d rpos; Vector3d frc(0.0); - Vector3d trq(0.0); + Vector3d trq(0.0); + Vector3d ef(0.0); Vector3d pos = this->getPos(); + + int sl = ((snapshotMan_->getCurrentSnapshot())->*storage_).getStorageLayout(); + for (unsigned int i = 0; i < atoms_.size(); i++) { afrc = atoms_[i]->getFrc(); @@ -247,10 +250,20 @@ namespace OpenMD { if (atoms_[i]->isDirectional()) { atrq = atoms_[i]->getTrq(); trq += atrq; - } + } + + if (sl & DataStorage::dslElectricField) { + ef += atoms_[i]->getElectricField(); + } } addFrc(frc); addTrq(trq); + + if (sl & DataStorage::dslElectricField) { + ef /= atoms_.size(); + setElectricField(ef); + } + } Mat3x3d RigidBody::calcForcesAndTorquesAndVirial() { @@ -260,10 +273,14 @@ namespace OpenMD { Vector3d rpos; Vector3d dfrc; Vector3d frc(0.0); - Vector3d trq(0.0); + Vector3d trq(0.0); + Vector3d ef(0.0); + Vector3d pos = this->getPos(); Mat3x3d tau_(0.0); + int sl = ((snapshotMan_->getCurrentSnapshot())->*storage_).getStorageLayout(); + for (unsigned int i = 0; i < atoms_.size(); i++) { afrc = atoms_[i]->getFrc(); @@ -283,6 +300,9 @@ namespace OpenMD { atrq = atoms_[i]->getTrq(); trq += atrq; } + if (sl & DataStorage::dslElectricField) { + ef += atoms_[i]->getElectricField(); + } tau_(0,0) -= rpos[0]*afrc[0]; tau_(0,1) -= rpos[0]*afrc[1]; @@ -297,6 +317,12 @@ namespace OpenMD { } addFrc(frc); addTrq(trq); + + if (sl & DataStorage::dslElectricField) { + ef /= atoms_.size(); + setElectricField(ef); + } + return tau_; }