--- trunk/src/applications/staticProps/GofRAngle.cpp 2012/08/22 18:43:27 1785 +++ trunk/src/applications/staticProps/GofRAngle.cpp 2013/06/16 15:15:42 1879 @@ -35,7 +35,7 @@ * * [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). + * [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). */ @@ -43,6 +43,8 @@ #include #include #include "applications/staticProps/GofRAngle.hpp" +#include "primitives/Atom.hpp" +#include "types/MultipoleAdapter.hpp" #include "utils/simError.h" namespace OpenMD { @@ -107,13 +109,13 @@ namespace OpenMD { currentSnapshot_->wrapVector(r12); RealType distance = r12.length(); - int whichRBin = distance / deltaR_; + int whichRBin = int(distance / deltaR_); if (distance <= len_) { RealType cosAngle = evaluateAngle(sd1, sd2); RealType halfBin = (nAngleBins_ - 1) * 0.5; - int whichThetaBin = halfBin * (cosAngle + 1.0); + int whichThetaBin = int(halfBin * (cosAngle + 1.0)); ++histogram_[whichRBin][whichThetaBin]; ++npairs_; @@ -129,10 +131,10 @@ namespace OpenMD { rdfStream << "#nRBins = " << nRBins_ << "\t maxLen = " << len_ << "deltaR = " << deltaR_ <<"\n"; rdfStream << "#nAngleBins =" << nAngleBins_ << "deltaCosAngle = " << deltaCosAngle_ << "\n"; for (unsigned int i = 0; i < avgGofr_.size(); ++i) { - RealType r = deltaR_ * (i + 0.5); + // RealType r = deltaR_ * (i + 0.5); for(unsigned int j = 0; j < avgGofr_[i].size(); ++j) { - RealType cosAngle = -1.0 + (j + 0.5)*deltaCosAngle_; + // RealType cosAngle = -1.0 + (j + 0.5)*deltaCosAngle_; rdfStream << avgGofr_[i][j]/nProcessed_ << "\t"; } @@ -157,14 +159,39 @@ namespace OpenMD { currentSnapshot_->wrapVector(r12); r12.normalize(); - Vector3d dipole = sd1->getElectroFrame().getColumn(2); - dipole.normalize(); - return dot(r12, dipole); + + AtomType* atype1 = static_cast(sd1)->getAtomType(); + MultipoleAdapter ma1 = MultipoleAdapter(atype1); + Vector3d vec; + if (ma1.isDipole() ) + vec = sd1->getDipole(); + else + vec = sd1->getA().transpose() * V3Z; + vec.normalize(); + + return dot(r12, vec); } RealType GofROmega::evaluateAngle(StuntDouble* sd1, StuntDouble* sd2) { - Vector3d v1 = sd1->getElectroFrame().getColumn(2); - Vector3d v2 = sd2->getElectroFrame().getColumn(2); + + AtomType* atype1 = static_cast(sd1)->getAtomType(); + AtomType* atype2 = static_cast(sd2)->getAtomType(); + + MultipoleAdapter ma1 = MultipoleAdapter(atype1); + MultipoleAdapter ma2 = MultipoleAdapter(atype2); + + Vector3d v1, v2; + + if (ma1.isDipole() ) + v1 = sd1->getDipole(); + else + v1 = sd1->getA().transpose() * V3Z; + + if (ma2.isDipole() ) + v2 = sd2->getDipole(); + else + v2 = sd2->getA().transpose() * V3Z; + v1.normalize(); v2.normalize(); return dot(v1, v2);