48#include "applications/dynamicProps/CollectiveDipoleDisplacement.hpp"
50#include "types/FixedChargeAdapter.hpp"
51#include "types/FluctuatingChargeAdapter.hpp"
52#include "utils/Revision.hpp"
56 CollectiveDipoleDisplacement::CollectiveDipoleDisplacement(
57 SimInfo* info,
const string& filename,
const string& sele1,
58 const std::string& sele2) :
59 SystemACF<Vector3d>(info, filename, sele1, sele2) {
60 setCorrFuncType(
"Collective Dipole Displacement Function");
61 setOutputName(
getPrefix(dumpFilename_) +
".ddisp");
63 std::stringstream label;
64 label <<
"<|Mtrans(t)-Mtrans(0)|^2>\t"
65 <<
"<|Mtot(t)-Mtot(0)|^2>\t"
66 <<
"<|Mrot(t)-Mrot(0)|^2>";
67 const std::string labelString = label.str();
68 setLabelString(labelString);
70 CRcm_.resize(nFrames_, V3Zero);
71 CRtot_.resize(nFrames_, V3Zero);
72 CRrot_.resize(nFrames_, V3Zero);
75 thermo_ =
new Thermo(info_);
78 void CollectiveDipoleDisplacement::computeProperty1(
int frame) {
79 SimInfo::MoleculeIterator mi;
81 Molecule::AtomIterator ai;
87 Vector3d r(0.0), rcm(0.0), rcq(0.0);
89 for (mol = info_->beginMolecule(mi); mol != NULL;
90 mol = info_->nextMolecule(mi)) {
96 for (atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) {
98 atype = atom->getAtomType();
99 FixedChargeAdapter fca = FixedChargeAdapter(atype);
100 if (fca.isFixedCharge()) q = fca.getCharge();
101 FluctuatingChargeAdapter fqa = FluctuatingChargeAdapter(atype);
102 if (fqa.isFluctuatingCharge()) q += atom->getFlucQPos();
116 if (qtot <= std::numeric_limits<RealType>::min()) {
122 CRcm_[frame] += qtot * rcm;
123 CRtot_[frame] += qtot * rcq;
124 CRrot_[frame] += qtot * (rcq - rcm);
128 RealType vol = thermo_->getVolume();
130 CRcm_[frame] /= (vol * Constants::chargeDensityConvert);
131 CRtot_[frame] /= (vol * Constants::chargeDensityConvert);
132 CRrot_[frame] /= (vol * Constants::chargeDensityConvert);
135 Vector3d CollectiveDipoleDisplacement::calcCorrVal(
int frame1,
int frame2) {
137 RealType dcm, dtot, drot;
138 diff = CRcm_[frame2] - CRcm_[frame1];
140 diff = CRtot_[frame2] - CRtot_[frame1];
141 dtot = diff.lengthSquare();
142 diff = CRrot_[frame2] - CRrot_[frame1];
143 drot = diff.lengthSquare();
145 return Vector3d(dcm, dtot, drot);
One of the heavy-weight classes of OpenMD, SimInfo maintains objects and variables relating to the cu...
Real lengthSquare() const
Returns the squared 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)