45#include "applications/dynamicProps/ChargeKineticCorrFunc.hpp"
48#include "types/FixedChargeAdapter.hpp"
49#include "types/FluctuatingChargeAdapter.hpp"
52 ChargeKineticCorrFunc::ChargeKineticCorrFunc(
SimInfo* info,
53 const std::string& filename,
54 const std::string& sele1,
55 const std::string& sele2,
56 const RealType cutoff) :
57 ObjectCCF<RealType>(info, filename, sele1, sele2),
59 setCorrFuncType(
"Charge - Kinetic Cross Correlation Function");
60 setOutputName(
getPrefix(dumpFilename_) +
".QKcorr");
62 charges_.resize(nFrames_);
63 kinetic_.resize(nFrames_);
82 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
83 "ChargeKineticCorrFunc::validateSelection Error: selection "
85 "\t is not a Directional object\n",
93 int ChargeKineticCorrFunc::computeProperty1(
int frame,
StuntDouble* sd) {
101 if (fca.isFixedCharge()) { q += fca.getCharge(); }
104 if (fqa.isFluctuatingCharge()) { q += atom->
getFlucQPos(); }
107 charges_[frame].push_back(propertyTemp);
108 sumCharge_ += propertyTemp;
110 return charges_[frame].size() - 1;
113 int ChargeKineticCorrFunc::computeProperty2(
int frame,
StuntDouble* sd) {
114 RealType kinetic(0.0);
120 kinetic += mass * (vel[0] * vel[0] + vel[1] * vel[1] + vel[2] * vel[2]);
135 angMom[j] * angMom[j] / I(j, j) + angMom[k] * angMom[k] / I(k, k);
137 kinetic += angMom[0] * angMom[0] / I(0, 0) +
138 angMom[1] * angMom[1] / I(1, 1) +
139 angMom[2] * angMom[2] / I(2, 2);
142 propertyTemp = 0.5 * kinetic;
143 kinetic_[frame].push_back(propertyTemp);
144 sumKinetic_ += propertyTemp;
146 return kinetic_[frame].size() - 1;
149 RealType ChargeKineticCorrFunc::calcCorrVal(
int frame1,
int frame2,
int id1,
156 return charges_[frame1][id1] * kinetic_[frame2][id2];
159 void ChargeKineticCorrFunc::postCorrelate() {
161 sumCharge_ /= RealType(chargeCount_);
164 sumKinetic_ /= RealType(kineticCount_);
166 RealType correlationOfAverages_ = sumCharge_ * sumKinetic_;
167 for (
unsigned int i = 0; i < nTimeBins_; ++i) {
169 histogram_[i] /= RealType(count_[i]);
173 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!"
Vector3d getVel()
Returns the current velocity of this stuntDouble.
int linearAxis()
Returns the linear axis of the rigidbody, atom and directional atom will always return -1.
RealType getMass()
Returns the mass of this stuntDouble.
virtual Mat3x3d getI()=0
Returns the inertia tensor of this stuntDouble.
virtual std::string getType()=0
Returns the name of this stuntDouble.
bool isLinear()
Tests the if this stuntDouble is a linear rigidbody.
Vector3d getPos()
Returns the current position of this stuntDouble.
RealType getFlucQPos()
Returns the current fluctuating charge of this stuntDouble.
Vector3d getJ()
Returns the current angular momentum of this stuntDouble (body -fixed).
int getGlobalIndex()
Returns the global index of this stuntDouble.
bool isDirectional()
Tests if this stuntDouble is a directional one.
Real length()
Returns the length of this vector.
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
std::string getPrefix(const std::string &str)
Real distance(const DynamicVector< Real > &v1, const DynamicVector< Real > &v2)
Returns the distance between two DynamicVectors.