45#include "applications/dynamicProps/DipoleCorrFunc.hpp"
50#include "types/MultipoleAdapter.hpp"
51#include "utils/Revision.hpp"
52#include "utils/simError.h"
55 DipoleCorrFunc::DipoleCorrFunc(SimInfo* info,
const std::string& filename,
56 const std::string& sele1,
57 const std::string& sele2) :
58 ObjectACF<RealType>(info, filename, sele1, sele2) {
59 setCorrFuncType(
"Dipole Correlation Function");
60 setOutputName(
getPrefix(dumpFilename_) +
".dcorr");
61 setLabelString(
"<D(0).D(t)>");
62 dipoles_.resize(nFrames_);
65 int DipoleCorrFunc::computeProperty1(
int frame, StuntDouble* sd) {
66 dipoles_[frame].push_back(sd->getDipole());
67 return dipoles_[frame].size() - 1;
70 RealType DipoleCorrFunc::calcCorrVal(
int frame1,
int frame2,
int id1,
72 Vector3d v1 = dipoles_[frame1][id1];
73 Vector3d v2 = dipoles_[frame2][id2];
74 return dot(v1, v2) / (v1.length() * v2.length());
77 void DipoleCorrFunc::validateSelection(SelectionManager&) {
80 for (sd = seleMan1_.beginSelected(i); sd != NULL;
81 sd = seleMan1_.nextSelected(i)) {
82 AtomType* at =
static_cast<Atom*
>(sd)->getAtomType();
83 MultipoleAdapter ma = MultipoleAdapter(at);
86 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
87 "DipoleCorrFunc::validateSelection Error: selected atoms do\n"
88 "\tnot have a dipole\n");
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)