45#include "applications/dynamicProps/ForTorCorrFunc.hpp"
50 ForTorCorrFunc::ForTorCorrFunc(SimInfo* info,
const std::string& filename,
51 const std::string& sele1,
52 const std::string& sele2) :
53 ObjectCCF<Mat3x3d>(info, filename, sele1, sele2) {
54 setCorrFuncType(
"Force - Torque Correlation Function");
55 setOutputName(
getPrefix(dumpFilename_) +
".ftcorr");
57 forces_.resize(nFrames_);
58 torques_.resize(nFrames_);
66 propertyTemp = V3Zero;
69 void ForTorCorrFunc::validateSelection(SelectionManager& seleMan) {
73 for (sd = seleMan.beginSelected(i); sd != NULL;
74 sd = seleMan.nextSelected(i)) {
75 if (!sd->isDirectional()) {
76 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
77 "ForTorCorrFunc::validateSelection Error: selection "
79 "\t is not a Directional object\n",
80 sd->getGlobalIndex(), sd->getType().c_str());
87 int ForTorCorrFunc::computeProperty1(
int frame, StuntDouble* sd) {
88 Mat3x3d A = sd->getA();
89 Vector3d f = sd->getFrc();
91 forces_[frame].push_back(propertyTemp);
92 sumForces_ += propertyTemp;
94 return forces_[frame].size() - 1;
97 int ForTorCorrFunc::computeProperty2(
int frame, StuntDouble* sd) {
98 Mat3x3d A = sd->getA();
99 Vector3d t = sd->getTrq();
100 propertyTemp = A * t;
101 torques_[frame].push_back(propertyTemp);
102 sumTorques_ += propertyTemp;
104 return torques_[frame].size() - 1;
107 Mat3x3d ForTorCorrFunc::calcCorrVal(
int frame1,
int frame2,
int id1,
109 return outProduct(forces_[frame1][id1], torques_[frame2][id2]);
112 void ForTorCorrFunc::postCorrelate() {
114 sumForces_ /= RealType(forcesCount_);
117 sumTorques_ /= RealType(torquesCount_);
119 Mat3x3d correlationOfAverages_ = outProduct(sumForces_, sumTorques_);
121 for (
unsigned int i = 0; i < nTimeBins_; ++i) {
123 histogram_[i] /= RealType(count_[i]);
127 histogram_[i] -= correlationOfAverages_;
129 histogram_[i] = M3Zero;
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
std::string getPrefix(const std::string &str)