45#include "applications/dynamicProps/TorForCorrFunc.hpp"
48 TorForCorrFunc::TorForCorrFunc(SimInfo* info,
const std::string& filename,
49 const std::string& sele1,
50 const std::string& sele2) :
51 ObjectCCF<Mat3x3d>(info, filename, sele1, sele2) {
52 setCorrFuncType(
"Torque - Force Cross Correlation Function");
53 setOutputName(
getPrefix(dumpFilename_) +
".tfcorr");
55 forces_.resize(nFrames_);
56 torques_.resize(nFrames_);
64 void TorForCorrFunc::validateSelection(SelectionManager& seleMan) {
68 for (sd = seleMan.beginSelected(i); sd != NULL;
69 sd = seleMan.nextSelected(i)) {
70 if (!sd->isDirectional()) {
71 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
72 "TorForCorrFunc::validateSelection Error: selection "
74 "\t is not a Directional object\n",
75 sd->getGlobalIndex(), sd->getType().c_str());
82 int TorForCorrFunc::computeProperty1(
int frame, StuntDouble* sd) {
83 Mat3x3d A = sd->getA();
84 Vector3d t = sd->getTrq();
86 torques_[frame].push_back(propertyTemp);
87 sumTorques_ += propertyTemp;
89 return torques_[frame].size() - 1;
92 int TorForCorrFunc::computeProperty2(
int frame, StuntDouble* sd) {
93 Mat3x3d A = sd->getA();
94 Vector3d f = sd->getFrc();
96 forces_[frame].push_back(propertyTemp);
97 sumForces_ += propertyTemp;
99 return forces_[frame].size() - 1;
102 Mat3x3d TorForCorrFunc::calcCorrVal(
int frame1,
int frame2,
int id1,
104 return outProduct(torques_[frame1][id1], forces_[frame2][id2]);
107 void TorForCorrFunc::postCorrelate() {
109 sumForces_ /= RealType(forcesCount_);
112 sumTorques_ /= RealType(torquesCount_);
114 Mat3x3d correlationOfAverages_ = outProduct(sumTorques_, sumForces_);
115 for (
unsigned int i = 0; i < nTimeBins_; ++i) {
117 histogram_[i] /= RealType(count_[i]);
121 histogram_[i] -= correlationOfAverages_;
123 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)