45#include "applications/dynamicProps/ChargeOrientationCorrFunc.hpp"
49#include "types/FixedChargeAdapter.hpp"
50#include "types/FluctuatingChargeAdapter.hpp"
53 ChargeOrientationCorrFunc::ChargeOrientationCorrFunc(
54 SimInfo* info,
const std::string& filename,
const std::string& sele1,
55 const std::string& sele2,
const RealType dipoleX,
const RealType dipoleY,
56 const RealType dipoleZ,
const RealType cutOff,
const int axis) :
57 ObjectCCF<RealType>(info, filename, sele1, sele2),
60 "Charge - Orientation Order Parameter Cross Correlation Function");
61 setOutputName(
getPrefix(dumpFilename_) +
".QScorr");
63 charges_.resize(nFrames_);
64 CosTheta_.resize(nFrames_);
71 dipoleVector_ =
Vector3d(dipoleX, dipoleY, dipoleZ);
72 dipoleVector_.normalize();
91 void ChargeOrientationCorrFunc::validateSelection(
SelectionManager& seleMan) {
103 painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
104 "ChargeOrientationCorrFunc::validateSelection Error: selection "
106 "\t is not a Directional object\n",
108 painCave.isFatal = 1;
114 int ChargeOrientationCorrFunc::computeProperty1(
int frame,
StuntDouble* sd) {
116 Atom* atom =
static_cast<Atom*
>(sd);
121 if (fca.isFixedCharge()) { q += fca.getCharge(); }
124 if (fqa.isFluctuatingCharge()) { q += atom->
getFlucQPos(); }
127 charges_[frame].push_back(propertyTemp);
128 sumCharge_ += propertyTemp;
130 return charges_[frame].size() - 1;
133 int ChargeOrientationCorrFunc::computeProperty2(
int frame,
StuntDouble* sd) {
136 RealType ctheta(0.0);
139 rotatedDipoleVector = rotMat * dipoleVector_;
141 ctheta =
dot(rotatedDipoleVector, refAxis_);
143 propertyTemp = ctheta;
144 CosTheta_[frame].push_back(propertyTemp);
145 sumCosTheta_ += propertyTemp;
147 return CosTheta_[frame].size() - 1;
150 RealType ChargeOrientationCorrFunc::calcCorrVal(
int frame1,
int frame2,
152 return charges_[frame1][id1] * CosTheta_[frame2][id2];
155 void ChargeOrientationCorrFunc::postCorrelate() {
157 sumCharge_ /= RealType(chargeCount_);
160 sumCosTheta_ /= RealType(CosThetaCount_);
162 RealType correlationOfAverages_ = sumCharge_ * sumCosTheta_;
163 for (
unsigned int i = 0; i < nTimeBins_; ++i) {
165 histogram_[i] /= RealType(count_[i]);
169 histogram_[i] -= correlationOfAverages_;
AtomType * getAtomType()
Returns the AtomType of this Atom.
AtomType is what OpenMD looks to for unchanging data about an atom.
StuntDouble * nextSelected(int &i)
Finds the next selected StuntDouble in the selection.
StuntDouble * beginSelected(int &i)
Finds the first selected StuntDouble in the selection.
One of the heavy-weight classes of OpenMD, SimInfo maintains objects and variables relating to the cu...
"Don't move, or you're dead! Stand up! Captain, we've got them!"
RotMat3x3d getA()
Returns the current rotation matrix of this stuntDouble.
virtual std::string getType()=0
Returns the name of this stuntDouble.
RealType getFlucQPos()
Returns the current fluctuating charge of this stuntDouble.
int getGlobalIndex()
Returns the global index of this stuntDouble.
bool isDirectional()
Tests if this stuntDouble is a directional one.
void normalize()
Normalizes this vector in place.
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
Real dot(const DynamicVector< Real > &v1, const DynamicVector< Real > &v2)
Returns the dot product of two DynamicVectors.
std::string getPrefix(const std::string &str)