48#include "applications/dynamicProps/LegendreCorrFunc.hpp"
53#include "utils/Revision.hpp"
54#include "utils/simError.h"
57 LegendreCorrFunc::LegendreCorrFunc(
SimInfo* info,
const std::string& filename,
58 const std::string& sele1,
59 const std::string& sele2,
int order) :
60 ObjectACF<Vector3d>(info, filename, sele1, sele2),
61 order_(order), doOffset_(false) {
62 setCorrFuncType(
"Legendre Correlation Function");
63 setOutputName(
getPrefix(dumpFilename_) +
".lcorr");
65 std::stringstream params;
66 params <<
" order = " << order_;
67 const std::string paramString = params.str();
68 setParameterString(paramString);
70 setLabelString(
"Pn(costheta_x)\tPn(costheta_y)\tPn(costheta_z)");
72 LegendrePolynomial polynomial(order);
73 legendre_ = polynomial.getLegendrePolynomial(order);
75 rotMats_.resize(nFrames_);
78 LegendreCorrFunc::LegendreCorrFunc(SimInfo* info,
const std::string& filename,
79 const std::string& sele1,
80 const std::string& sele2,
83 ObjectACF<Vector3d>(info, filename, sele1, sele2), doOffset_(true),
84 seleOffset_(seleOffset), order_(order) {
85 setCorrFuncType(
"Legendre Correlation Function");
86 setOutputName(
getPrefix(dumpFilename_) +
".lcorr");
88 std::stringstream params;
89 params <<
" order = " << order_;
90 params <<
" seleoffset = " << seleOffset_;
91 const std::string paramString = params.str();
92 setParameterString(paramString);
94 setLabelString(
"Pn(costheta_x)\tPn(costheta_y)\tPn(costheta_z)");
96 LegendrePolynomial polynomial(order);
97 legendre_ = polynomial.getLegendrePolynomial(order);
99 vectors_.resize(nFrames_);
102 int LegendreCorrFunc::computeProperty1(
int frame, StuntDouble* sd) {
104 int sd2Index = sd->getGlobalIndex() + seleOffset_;
105 StuntDouble* sd2= info_->getIOIndexToIntegrableObject(sd2Index);
106 vectors_[frame].push_back(sd->getPos() - sd2->getPos());
107 return vectors_[frame].size() - 1;
109 rotMats_[frame].push_back(sd->getA());
110 return rotMats_[frame].size() - 1;
114 Vector3d LegendreCorrFunc::calcCorrVal(
int frame1,
int frame2,
int id1,
118 Vector3d v1z = vectors_[frame1][id1];
119 Vector3d v2z = vectors_[frame2][id2];
121 legendre_.evaluate(
dot(v1z, v2z) / (v1z.length() * v2z.length()));
122 return Vector3d(0, 0, uz);
132 Vector3d v1x = rotMats_[frame1][id1].getRow(0);
133 Vector3d v1y = rotMats_[frame1][id1].getRow(1);
134 Vector3d v1z = rotMats_[frame1][id1].getRow(2);
136 Vector3d v2x = rotMats_[frame2][id2].getRow(0);
137 Vector3d v2y = rotMats_[frame2][id2].getRow(1);
138 Vector3d v2z = rotMats_[frame2][id2].getRow(2);
141 legendre_.evaluate(
dot(v1x, v2x) / (v1x.length() * v2x.length()));
143 legendre_.evaluate(
dot(v1y, v2y) / (v1y.length() * v2y.length()));
145 legendre_.evaluate(
dot(v1z, v2z) / (v1z.length() * v2z.length()));
147 return Vector3d(ux, uy, uz);
151 void LegendreCorrFunc::validateSelection(SelectionManager&) {
155 for (sd = seleMan1_.beginSelected(i); sd != NULL;
156 sd = seleMan1_.nextSelected(i)) {
157 if (!sd->isDirectional()) {
158 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
159 "LegendreCorrFunc::validateSelection Error: "
160 "at least one of the selected objects is not Directional\n");
161 painCave.isFatal = 1;
One of the heavy-weight classes of OpenMD, SimInfo maintains objects and variables relating to the cu...
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)