48#include "MultiComponentRDF.hpp"
57 MultiComponentRDF::MultiComponentRDF(
SimInfo* info,
58 const std::string& filename,
59 const std::string& sele1,
60 const std::string& sele2,
63 selectionScript1_(sele1), selectionScript2_(sele2), evaluator1_(info),
64 evaluator2_(info), seleMan1_(info), seleMan2_(info),
65 sele1_minus_common_(info), sele2_minus_common_(info), common_(info) {
66 nPairs_.resize(MaxPairs);
68 evaluator1_.loadScriptString(sele1);
69 evaluator2_.loadScriptString(sele2);
71 if (!evaluator1_.isDynamic()) {
72 seleMan1_.setSelectionSet(evaluator1_.evaluate());
73 validateSelection1(seleMan1_);
75 if (!evaluator2_.isDynamic()) {
76 seleMan2_.setSelectionSet(evaluator2_.evaluate());
77 validateSelection2(seleMan2_);
82 if (!evaluator1_.isDynamic() && !evaluator2_.isDynamic()) { calcNPairs(); }
85 void MultiComponentRDF::calcNPairs() {
86 common_ = seleMan1_ & seleMan2_;
87 sele1_minus_common_ = seleMan1_ - common_;
88 sele2_minus_common_ = seleMan2_ - common_;
89 nSelected1_ = seleMan1_.getSelectionCount();
90 nSelected2_ = seleMan2_.getSelectionCount();
91 int nIntersect = common_.getSelectionCount();
93 nPairs_[OneOne] = nSelected1_ * (nSelected1_ - 1) / 2;
95 nSelected1_ * nSelected2_ - (nIntersect + 1) * nIntersect / 2;
96 nPairs_[TwoTwo] = nSelected2_ * (nSelected2_ - 1) / 2;
99 void MultiComponentRDF::process() {
102 DumpReader reader(info_, dumpFilename_);
103 int nFrames = reader.getNFrames();
104 nProcessed_ = nFrames / step_;
106 for (
int i = 0; i < nFrames; i += step_) {
108 currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot();
110 initializeHistograms();
112 if (evaluator1_.isDynamic()) {
113 seleMan1_.setSelectionSet(evaluator1_.evaluate());
114 validateSelection1(seleMan1_);
116 if (evaluator2_.isDynamic()) {
117 seleMan2_.setSelectionSet(evaluator2_.evaluate());
118 validateSelection2(seleMan2_);
142 if (evaluator1_.isDynamic() || evaluator2_.isDynamic()) { calcNPairs(); }
144 processNonOverlapping(sele1_minus_common_, seleMan2_, OneTwo);
145 processNonOverlapping(common_, sele2_minus_common_, OneTwo);
147 processOverlapping(common_, OneTwo);
148 processOverlapping(seleMan1_, OneOne);
149 processOverlapping(seleMan2_, TwoTwo);
159 void MultiComponentRDF::processNonOverlapping(SelectionManager& sman1,
160 SelectionManager& sman2,
172 for (sd1 = sman1.beginSelected(i); sd1 != NULL;
173 sd1 = sman1.nextSelected(i)) {
174 for (sd2 = sman2.beginSelected(j); sd2 != NULL;
175 sd2 = sman2.nextSelected(j)) {
176 collectHistograms(sd1, sd2, pairIndex);
181 void MultiComponentRDF::processOverlapping(SelectionManager& sman,
193 for (sd1 = sman.beginSelected(i); sd1 != NULL; sd1 = sman.nextSelected(i)) {
194 for (j = i, sd2 = sman.nextSelected(j); sd2 != NULL;
195 sd2 = sman.nextSelected(j)) {
196 collectHistograms(sd1, sd2, pairIndex);
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.