--- trunk/src/primitives/DirectionalAtom.cpp 2009/11/25 20:02:06 1390 +++ trunk/src/primitives/DirectionalAtom.cpp 2013/06/16 15:15:42 1879 @@ -35,21 +35,32 @@ * * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). - * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). - * [4] Vardeman & Gezelter, in progress (2009). + * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). + * [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). + * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). */ #include "primitives/DirectionalAtom.hpp" +#include "types/DirectionalAdapter.hpp" +#include "types/MultipoleAdapter.hpp" #include "utils/simError.h" namespace OpenMD { - DirectionalAtom::DirectionalAtom(DirectionalAtomType* dAtomType) - : Atom(dAtomType){ + DirectionalAtom::DirectionalAtom(AtomType* dAtomType) + : Atom(dAtomType) { objType_= otDAtom; - if (dAtomType->isMultipole()) { - electroBodyFrame_ = dAtomType->getElectroBodyFrame(); + + DirectionalAdapter da = DirectionalAdapter(dAtomType); + I_ = da.getI(); + + MultipoleAdapter ma = MultipoleAdapter(dAtomType); + if (ma.isDipole()) { + dipole_ = ma.getDipole(); } - + if (ma.isQuadrupole()) { + quadrupole_ = ma.getQuadrupole(); + } + // Check if one of the diagonal inertia tensor of this directional // atom is zero: int nLinearAxis = 0; @@ -73,31 +84,58 @@ namespace OpenMD { } Mat3x3d DirectionalAtom::getI() { - return static_cast(getAtomType())->getI(); + return I_; } void DirectionalAtom::setPrevA(const RotMat3x3d& a) { ((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_] = a; + if (atomType_->isMultipole()) { - ((snapshotMan_->getPrevSnapshot())->*storage_).electroFrame[localIndex_] = a.transpose() * electroBodyFrame_; + RotMat3x3d atrans = a.transpose(); + + if (atomType_->isDipole()) { + ((snapshotMan_->getPrevSnapshot())->*storage_).dipole[localIndex_] = atrans * dipole_; + } + + if (atomType_->isQuadrupole()) { + ((snapshotMan_->getPrevSnapshot())->*storage_).quadrupole[localIndex_] = atrans * quadrupole_ * a; + } } } void DirectionalAtom::setA(const RotMat3x3d& a) { ((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_] = a; - + if (atomType_->isMultipole()) { - ((snapshotMan_->getCurrentSnapshot())->*storage_).electroFrame[localIndex_] = a.transpose() * electroBodyFrame_; + RotMat3x3d atrans = a.transpose(); + + if (atomType_->isDipole()) { + ((snapshotMan_->getCurrentSnapshot())->*storage_).dipole[localIndex_] = atrans * dipole_; + } + + if (atomType_->isQuadrupole()) { + ((snapshotMan_->getCurrentSnapshot())->*storage_).quadrupole[localIndex_] = atrans * quadrupole_ * a; + } } + } void DirectionalAtom::setA(const RotMat3x3d& a, int snapshotNo) { ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_] = a; - + if (atomType_->isMultipole()) { - ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).electroFrame[localIndex_] = a.transpose() * electroBodyFrame_; + RotMat3x3d atrans = a.transpose(); + + if (atomType_->isDipole()) { + ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).dipole[localIndex_] = atrans * dipole_; + } + + if (atomType_->isQuadrupole()) { + ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).quadrupole[localIndex_] = atrans * quadrupole_ * a; + } } + } void DirectionalAtom::rotateBy(const RotMat3x3d& m) { @@ -109,7 +147,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; @@ -121,7 +160,7 @@ namespace OpenMD { phi = myEuler[0]; theta = myEuler[1]; - psi = myEuler[2]; + // psi = myEuler[2]; cphi = cos(phi); sphi = sin(phi); @@ -134,10 +173,14 @@ namespace OpenMD { ephi[1] = 0.0; ephi[2] = 1.0; - etheta[0] = -sphi; - etheta[1] = cphi; - etheta[2] = 0.0; + //etheta[0] = -sphi; + //etheta[1] = cphi; + //etheta[2] = 0.0; + etheta[0] = cphi; + etheta[1] = sphi; + etheta[2] = 0.0; + epsi[0] = stheta * cphi; epsi[1] = stheta * sphi; epsi[2] = ctheta;