45#include "RadialDistrFunc.hpp"
54 RadialDistrFunc::RadialDistrFunc(SimInfo* info,
const std::string& filename,
55 const std::string& sele1,
56 const std::string& sele2,
58 StaticAnalyser(info, filename, nbins),
59 selectionScript1_(sele1), selectionScript2_(sele2), evaluator1_(info),
60 evaluator2_(info), seleMan1_(info), seleMan2_(info),
61 sele1_minus_common_(info), sele2_minus_common_(info), common_(info) {
62 evaluator1_.loadScriptString(sele1);
63 evaluator2_.loadScriptString(sele2);
65 if (!evaluator1_.isDynamic()) {
66 seleMan1_.setSelectionSet(evaluator1_.evaluate());
67 validateSelection1(seleMan1_);
69 if (!evaluator2_.isDynamic()) {
70 seleMan2_.setSelectionSet(evaluator2_.evaluate());
71 validateSelection2(seleMan2_);
74 if (!evaluator1_.isDynamic() && !evaluator2_.isDynamic()) {
77 common_ = seleMan1_ & seleMan2_;
78 sele1_minus_common_ = seleMan1_ - common_;
79 sele2_minus_common_ = seleMan2_ - common_;
81 nSelected1_ = seleMan1_.getSelectionCount();
82 nSelected2_ = seleMan2_.getSelectionCount();
83 int nIntersect = common_.getSelectionCount();
85 nPairs_ = nSelected1_ * nSelected2_ - (nIntersect + 1) * nIntersect / 2;
89 void RadialDistrFunc::process() {
92 DumpReader reader(info_, dumpFilename_);
93 int nFrames = reader.getNFrames();
94 nProcessed_ = nFrames / step_;
96 for (
int i = 0; i < nFrames; i += step_) {
98 currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot();
100 if (evaluator1_.isDynamic()) {
101 seleMan1_.setSelectionSet(evaluator1_.evaluate());
102 validateSelection1(seleMan1_);
104 if (evaluator2_.isDynamic()) {
105 seleMan2_.setSelectionSet(evaluator2_.evaluate());
106 validateSelection2(seleMan2_);
109 initializeHistogram();
132 if (evaluator1_.isDynamic() || evaluator2_.isDynamic()) {
133 common_ = seleMan1_ & seleMan2_;
134 sele1_minus_common_ = seleMan1_ - common_;
135 sele2_minus_common_ = seleMan2_ - common_;
136 nSelected1_ = seleMan1_.getSelectionCount();
137 nSelected2_ = seleMan2_.getSelectionCount();
138 int nIntersect = common_.getSelectionCount();
140 nPairs_ = nSelected1_ * nSelected2_ - (nIntersect + 1) * nIntersect / 2;
143 processNonOverlapping(sele1_minus_common_, seleMan2_);
144 processNonOverlapping(common_, sele2_minus_common_);
145 processOverlapping(common_);
155 void RadialDistrFunc::processNonOverlapping(SelectionManager& sman1,
156 SelectionManager& sman2) {
167 for (sd1 = sman1.beginSelected(i); sd1 != NULL;
168 sd1 = sman1.nextSelected(i)) {
169 for (sd2 = sman2.beginSelected(j); sd2 != NULL;
170 sd2 = sman2.nextSelected(j)) {
171 collectHistogram(sd1, sd2);
176 void RadialDistrFunc::processOverlapping(SelectionManager& sman) {
187 for (sd1 = sman.beginSelected(i); sd1 != NULL; sd1 = sman.nextSelected(i)) {
188 for (j = i, sd2 = sman.nextSelected(j); sd2 != NULL;
189 sd2 = sman.nextSelected(j)) {
190 collectHistogram(sd1, sd2);
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.