45#include "applications/dynamicProps/DirectionalRCorrFunc.hpp"
47#include "utils/Revision.hpp"
50 DirectionalRCorrFunc::DirectionalRCorrFunc(SimInfo* info,
51 const std::string& filename,
52 const std::string& sele1,
53 const std::string& sele2) :
54 ObjectACF<Vector3d>(info, filename, sele1, sele2) {
55 setCorrFuncType(
"DirectionalRCorrFunc");
56 setOutputName(
getPrefix(dumpFilename_) +
".drcorr");
57 setLabelString(
"r2\trparallel\trperpendicular");
58 positions_.resize(nFrames_);
59 rotMats_.resize(nFrames_);
62 int DirectionalRCorrFunc::computeProperty1(
int frame, StuntDouble* sd) {
63 positions_[frame].push_back(sd->getPos());
64 rotMats_[frame].push_back(sd->getA());
65 return positions_[frame].size() - 1;
68 Vector3d DirectionalRCorrFunc::calcCorrVal(
int frame1,
int frame2,
int id1,
70 Vector3d diff = positions_[frame2][id2] - positions_[frame1][id1];
76 Vector3d u1 = rotMats_[frame1][id1].getRow(2);
77 RealType u1l = u1.
length();
79 RealType rsq = diff.lengthSquare();
80 RealType rpar =
dot(diff, u1) / u1l;
81 RealType rpar2 = rpar * rpar;
82 RealType rperp2 = rsq - rpar2;
84 return Vector3d(rsq, rpar2, rperp2);
87 void DirectionalRCorrFunc::validateSelection(SelectionManager&) {
90 for (sd = seleMan1_.beginSelected(i); sd != NULL;
91 sd = seleMan1_.nextSelected(i)) {
92 if (!sd->isDirectional()) {
93 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
94 "DirectionalRCorrFunc::validateSelection Error: "
95 "at least one of the selected objects is not Directional\n");
Real length()
Returns the length of this vector.
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)