--- branches/development/src/primitives/DirectionalAtom.cpp 2011/11/22 20:38:56 1665 +++ branches/development/src/primitives/DirectionalAtom.cpp 2012/08/29 18:13:11 1787 @@ -41,16 +41,26 @@ */ #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; @@ -74,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) {