ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/applications/staticProps/ObjectCount.cpp
(Generate patch)

Comparing trunk/src/applications/staticProps/ObjectCount.cpp (file contents):
Revision 1513 by gezelter, Tue Oct 19 18:40:54 2010 UTC vs.
Revision 1879 by gezelter, Sun Jun 16 15:15:42 2013 UTC

# Line 35 | Line 35
35   *                                                                      
36   * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).            
37   * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).          
38 < * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008).          
39 < * [4]  Vardeman & Gezelter, in progress (2009).                        
38 > * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).          
39 > * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40 > * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   */
42  
43   #include <algorithm>
# Line 68 | Line 69 | void ObjectCount::process() {
69    SimInfo::MoleculeIterator mi;
70    Molecule::RigidBodyIterator rbIter;
71    
72 +  counts_.clear();
73 +  counts_.resize(10, 0);
74    DumpReader reader(info_, dumpFilename_);    
75    int nFrames = reader.getNFrames();
76 +  unsigned long int nsum = 0;
77 +  unsigned long int n2sum = 0;
78 +
79    for (int i = 0; i < nFrames; i += step_) {
80      reader.readFrame(i);
81      currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot();
# Line 87 | Line 93 | void ObjectCount::process() {
93          seleMan_.setSelectionSet(evaluator_.evaluate());
94      }
95          
96 <    int count = 0;
91 <    int k;
96 >    unsigned int count = seleMan_.getSelectionCount();
97  
98 <    for (StuntDouble* sd = seleMan_.beginSelected(k);
99 <         sd != NULL; sd = seleMan_.nextSelected(k)) {
95 <      count++;
98 >    if (counts_.size() <= count)  {
99 >      counts_.resize(count, 0);
100      }
101 <    
98 <    if (counts_.size() < count) counts_.resize(count);
101 >
102      counts_[count]++;
103 +
104 +    nsum += count;
105 +    n2sum += count * count;
106    }
107    
108    int nProcessed = nFrames /step_;
109  
104  vector<int>::iterator it;
105  unsigned long int n;
106  unsigned long int nsum = 0;
107  unsigned long int n2sum = 0;
108  for (it = counts_.begin(); it != counts_.end(); ++it) {
109    n = (*it);
110    nsum += n;
111    n2sum += n*n;
112  }
113
110    nAvg = nsum / nProcessed;
111    n2Avg = n2sum / nProcessed;
112    sDev = sqrt(n2Avg - nAvg*nAvg);
# Line 125 | Line 121 | void ObjectCount::process() {
121        ofs << "# <N> = "<< nAvg << "\n";
122        ofs << "# <N^2> = " << n2Avg << "\n";
123        ofs << "# sqrt(<N^2> - <N>^2)  = " << sDev << "\n";
124 <      ofs << "# N\tcount(N)\n";
124 >      ofs << "# N\tcounts[N]\n";
125 >      for (unsigned int i = 0; i < counts_.size(); ++i) {
126 >        ofs << i << "\t" << counts_[i] << "\n";
127 >      }
128        
130      for (int i = 0; i < counts_.size(); ++i) {
131        ofs << i <<"\t" << counts_[i]<< std::endl;
132      }        
129      } else {
130        
131        sprintf(painCave.errMsg, "ObjectCount: unable to open %s\n", outputFilename_.c_str());

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines