--- trunk/src/applications/staticProps/ObjectCount.cpp 2010/10/19 18:40:54 1513 +++ trunk/src/applications/staticProps/ObjectCount.cpp 2012/08/22 02:28:28 1782 @@ -36,7 +36,8 @@ * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). - * [4] Vardeman & Gezelter, in progress (2009). + * [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). + * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). */ #include @@ -68,8 +69,13 @@ void ObjectCount::process() { SimInfo::MoleculeIterator mi; Molecule::RigidBodyIterator rbIter; + counts_.clear(); + counts_.resize(10, 0); DumpReader reader(info_, dumpFilename_); int nFrames = reader.getNFrames(); + unsigned long int nsum = 0; + unsigned long int n2sum = 0; + for (int i = 0; i < nFrames; i += step_) { reader.readFrame(i); currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot(); @@ -87,30 +93,20 @@ void ObjectCount::process() { seleMan_.setSelectionSet(evaluator_.evaluate()); } - int count = 0; - int k; + unsigned int count = seleMan_.getSelectionCount(); - for (StuntDouble* sd = seleMan_.beginSelected(k); - sd != NULL; sd = seleMan_.nextSelected(k)) { - count++; + if (counts_.size() <= count) { + counts_.resize(count, 0); } - - if (counts_.size() < count) counts_.resize(count); + counts_[count]++; + + nsum += count; + n2sum += count * count; } int nProcessed = nFrames /step_; - vector::iterator it; - unsigned long int n; - unsigned long int nsum = 0; - unsigned long int n2sum = 0; - for (it = counts_.begin(); it != counts_.end(); ++it) { - n = (*it); - nsum += n; - n2sum += n*n; - } - nAvg = nsum / nProcessed; n2Avg = n2sum / nProcessed; sDev = sqrt(n2Avg - nAvg*nAvg); @@ -125,11 +121,11 @@ void ObjectCount::process() { ofs << "# = "<< nAvg << "\n"; ofs << "# = " << n2Avg << "\n"; ofs << "# sqrt( - ^2) = " << sDev << "\n"; - ofs << "# N\tcount(N)\n"; + ofs << "# N\tcounts[N]\n"; + for (unsigned int i = 0; i < counts_.size(); ++i) { + ofs << i << "\t" << counts_[i] << "\n"; + } - for (int i = 0; i < counts_.size(); ++i) { - ofs << i <<"\t" << counts_[i]<< std::endl; - } } else { sprintf(painCave.errMsg, "ObjectCount: unable to open %s\n", outputFilename_.c_str());