48#include "applications/dynamicProps/DirectionalRCorrFunc.hpp"
50#include "utils/Revision.hpp"
53 DirectionalRCorrFunc::DirectionalRCorrFunc(
SimInfo* info,
54 const std::string& filename,
55 const std::string& sele1,
56 const std::string& sele2) :
57 ObjectACF<Vector3d>(info, filename, sele1, sele2) {
58 setCorrFuncType(
"DirectionalRCorrFunc");
59 setOutputName(
getPrefix(dumpFilename_) +
".drcorr");
60 setLabelString(
"r2\trparallel\trperpendicular");
61 positions_.resize(nFrames_);
62 rotMats_.resize(nFrames_);
65 int DirectionalRCorrFunc::computeProperty1(
int frame, StuntDouble* sd) {
66 positions_[frame].push_back(sd->getPos());
67 rotMats_[frame].push_back(sd->getA());
68 return positions_[frame].size() - 1;
71 Vector3d DirectionalRCorrFunc::calcCorrVal(
int frame1,
int frame2,
int id1,
73 Vector3d diff = positions_[frame2][id2] - positions_[frame1][id1];
79 Vector3d u1 = rotMats_[frame1][id1].getRow(2);
80 RealType u1l = u1.
length();
82 RealType rsq = diff.lengthSquare();
83 RealType rpar =
dot(diff, u1) / u1l;
84 RealType rpar2 = rpar * rpar;
85 RealType rperp2 = rsq - rpar2;
87 return Vector3d(rsq, rpar2, rperp2);
90 void DirectionalRCorrFunc::validateSelection(SelectionManager&) {
93 for (sd = seleMan1_.beginSelected(i); sd != NULL;
94 sd = seleMan1_.nextSelected(i)) {
95 if (!sd->isDirectional()) {
96 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
97 "DirectionalRCorrFunc::validateSelection Error: "
98 "at least one of the selected objects is not Directional\n");
One of the heavy-weight classes of OpenMD, SimInfo maintains objects and variables relating to the cu...
Real length() const
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)