45#include "MultiComponentRDF.hpp"
54 MultiComponentRDF::MultiComponentRDF(SimInfo* info,
55 const std::string& filename,
56 const std::string& sele1,
57 const std::string& sele2,
59 StaticAnalyser(info, filename, nbins),
60 selectionScript1_(sele1), selectionScript2_(sele2), evaluator1_(info),
61 evaluator2_(info), seleMan1_(info), seleMan2_(info),
62 sele1_minus_common_(info), sele2_minus_common_(info), common_(info) {
63 nPairs_.resize(MaxPairs);
65 evaluator1_.loadScriptString(sele1);
66 evaluator2_.loadScriptString(sele2);
68 if (!evaluator1_.isDynamic()) {
69 seleMan1_.setSelectionSet(evaluator1_.evaluate());
70 validateSelection1(seleMan1_);
72 if (!evaluator2_.isDynamic()) {
73 seleMan2_.setSelectionSet(evaluator2_.evaluate());
74 validateSelection2(seleMan2_);
79 if (!evaluator1_.isDynamic() && !evaluator2_.isDynamic()) { calcNPairs(); }
82 void MultiComponentRDF::calcNPairs() {
83 common_ = seleMan1_ & seleMan2_;
84 sele1_minus_common_ = seleMan1_ - common_;
85 sele2_minus_common_ = seleMan2_ - common_;
86 nSelected1_ = seleMan1_.getSelectionCount();
87 nSelected2_ = seleMan2_.getSelectionCount();
88 int nIntersect = common_.getSelectionCount();
90 nPairs_[OneOne] = nSelected1_ * (nSelected1_ - 1) / 2;
92 nSelected1_ * nSelected2_ - (nIntersect + 1) * nIntersect / 2;
93 nPairs_[TwoTwo] = nSelected2_ * (nSelected2_ - 1) / 2;
96 void MultiComponentRDF::process() {
99 DumpReader reader(info_, dumpFilename_);
100 int nFrames = reader.getNFrames();
101 nProcessed_ = nFrames / step_;
103 for (
int i = 0; i < nFrames; i += step_) {
105 currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot();
107 initializeHistograms();
109 if (evaluator1_.isDynamic()) {
110 seleMan1_.setSelectionSet(evaluator1_.evaluate());
111 validateSelection1(seleMan1_);
113 if (evaluator2_.isDynamic()) {
114 seleMan2_.setSelectionSet(evaluator2_.evaluate());
115 validateSelection2(seleMan2_);
139 if (evaluator1_.isDynamic() || evaluator2_.isDynamic()) { calcNPairs(); }
141 processNonOverlapping(sele1_minus_common_, seleMan2_, OneTwo);
142 processNonOverlapping(common_, sele2_minus_common_, OneTwo);
144 processOverlapping(common_, OneTwo);
145 processOverlapping(seleMan1_, OneOne);
146 processOverlapping(seleMan2_, TwoTwo);
156 void MultiComponentRDF::processNonOverlapping(SelectionManager& sman1,
157 SelectionManager& sman2,
169 for (sd1 = sman1.beginSelected(i); sd1 != NULL;
170 sd1 = sman1.nextSelected(i)) {
171 for (sd2 = sman2.beginSelected(j); sd2 != NULL;
172 sd2 = sman2.nextSelected(j)) {
173 collectHistograms(sd1, sd2, pairIndex);
178 void MultiComponentRDF::processOverlapping(SelectionManager& sman,
190 for (sd1 = sman.beginSelected(i); sd1 != NULL; sd1 = sman.nextSelected(i)) {
191 for (j = i, sd2 = sman.nextSelected(j); sd2 != NULL;
192 sd2 = sman.nextSelected(j)) {
193 collectHistograms(sd1, sd2, pairIndex);
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.