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

Comparing:
trunk/src/applications/staticProps/RadialDistrFunc.cpp (file contents), Revision 318 by tim, Sun Feb 13 06:57:48 2005 UTC vs.
branches/development/src/applications/staticProps/RadialDistrFunc.cpp (file contents), Revision 1665 by gezelter, Tue Nov 22 20:38:56 2011 UTC

# Line 6 | Line 6
6   * redistribute this software in source and binary code form, provided
7   * that the following conditions are met:
8   *
9 < * 1. Acknowledgement of the program authors must be made in any
10 < *    publication of scientific results based in part on use of the
11 < *    program.  An acceptable form of acknowledgement is citation of
12 < *    the article in which the program was described (Matthew
13 < *    A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14 < *    J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15 < *    Parallel Simulation Engine for Molecular Dynamics,"
16 < *    J. Comput. Chem. 26, pp. 252-271 (2005))
17 < *
18 < * 2. Redistributions of source code must retain the above copyright
9 > * 1. Redistributions of source code must retain the above copyright
10   *    notice, this list of conditions and the following disclaimer.
11   *
12 < * 3. Redistributions in binary form must reproduce the above copyright
12 > * 2. Redistributions in binary form must reproduce the above copyright
13   *    notice, this list of conditions and the following disclaimer in the
14   *    documentation and/or other materials provided with the
15   *    distribution.
# Line 37 | Line 28
28   * arising out of the use of or inability to use software, even if the
29   * University of Notre Dame has been advised of the possibility of
30   * such damages.
31 + *
32 + * SUPPORT OPEN SCIENCE!  If you use OpenMD or its source code in your
33 + * research, please cite the appropriate papers when you publish your
34 + * work.  Good starting points are:
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]  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 44 | Line 45
45   #include "RadialDistrFunc.hpp"
46   #include "io/DumpReader.hpp"
47   #include "primitives/Molecule.hpp"
48 < namespace oopse {
48 > namespace OpenMD {
49  
50 < RadialDistrFunc::        RadialDistrFunc(SimInfo* info, const std::string& filename, const std::string& sele1, const std::string& sele2)
51 <        : info_(info), currentSnapshot_(NULL), dumpFilename_(filename), step_(1),
52 <          selectionScript1_(sele1), selectionScript2_(sele2), evaluator1_(info), evaluator2_(info), seleMan1_(info), seleMan2_(info){
50 >  RadialDistrFunc::RadialDistrFunc(SimInfo* info, const std::string& filename, const std::string& sele1, const std::string& sele2)
51 >    : StaticAnalyser(info, filename),
52 >      selectionScript1_(sele1), selectionScript2_(sele2), evaluator1_(info), evaluator2_(info),
53 >      seleMan1_(info), seleMan2_(info), common_(info), sele1_minus_common_(info), sele2_minus_common_(info){
54            
55 <    evaluator1_.loadScriptString(sele1);
56 <    evaluator2_.loadScriptString(sele2);
55 >      evaluator1_.loadScriptString(sele1);
56 >      evaluator2_.loadScriptString(sele2);
57  
58 <    if (!evaluator1_.isDynamic()) {
59 <            seleMan1_.setSelectionSet(evaluator1_.evaluate());
60 <    }
61 <    if (!evaluator2_.isDynamic()) {
62 <            seleMan2_.setSelectionSet(evaluator2_.evaluate());
63 <    }
58 >      if (!evaluator1_.isDynamic()) {
59 >        seleMan1_.setSelectionSet(evaluator1_.evaluate());
60 >        validateSelection1(seleMan1_);
61 >      }
62 >      if (!evaluator2_.isDynamic()) {
63 >        seleMan2_.setSelectionSet(evaluator2_.evaluate());
64 >        validateSelection2(seleMan2_);
65 >      }
66  
67 < }
67 >      if (!evaluator1_.isDynamic() && !evaluator2_.isDynamic()) {
68 >        //if all selections are static,  we can precompute the number of real pairs    
69 >        common_ = seleMan1_ & seleMan2_;
70 >        sele1_minus_common_ = seleMan1_ - common_;
71 >        sele2_minus_common_ = seleMan2_ - common_;      
72  
73 < void RadialDistrFunc::process() {
73 >        int nSelected1 = seleMan1_.getSelectionCount();
74 >        int nSelected2 = seleMan2_.getSelectionCount();
75 >        int nIntersect = common_.getSelectionCount();
76 >        
77 >        nPairs_ = nSelected1 * nSelected2 - (nIntersect +1) * nIntersect/2;            
78 >      }
79 >    
80 >    }
81 >
82 >  void RadialDistrFunc::process() {
83      Molecule* mol;
84      RigidBody* rb;
85      SimInfo::MoleculeIterator mi;
# Line 72 | Line 89 | void RadialDistrFunc::process() {
89      
90      DumpReader reader(info_, dumpFilename_);    
91      int nFrames = reader.getNFrames();
92 <    nProcessed_ = nFrames / step_ + 1;
92 >    nProcessed_ = nFrames / step_;
93 >
94      for (int i = 0; i < nFrames; i += step_) {
95 <        reader.readFrame(i);
96 <        currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot();
95 >      reader.readFrame(i);
96 >      currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot();
97  
98 <        if (evaluator1_.isDynamic()) {
99 <            seleMan1_.setSelectionSet(evaluator1_.evaluate());
100 <        }
101 <        if (evaluator2_.isDynamic()) {
102 <            seleMan2_.setSelectionSet(evaluator2_.evaluate());
103 <        }
98 >      if (evaluator1_.isDynamic()) {
99 >        seleMan1_.setSelectionSet(evaluator1_.evaluate());
100 >        validateSelection1(seleMan1_);
101 >      }
102 >      if (evaluator2_.isDynamic()) {
103 >        seleMan2_.setSelectionSet(evaluator2_.evaluate());
104 >        validateSelection2(seleMan2_);
105 >      }
106  
107 <        for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) {
107 >      for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) {
108  
109 <            //change the positions of atoms which belong to the rigidbodies
110 <            for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) {
111 <                rb->updateAtoms();
112 <            }
113 <        }
109 >        //change the positions of atoms which belong to the rigidbodies
110 >        for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) {
111 >          rb->updateAtoms();
112 >        }
113 >      }
114          
115 <        initalizeHistogram();
115 >      initalizeHistogram();
116  
97        StuntDouble* sd1;
98        int j;
99        for (sd1 = seleMan1_.beginSelected(j); sd1 != NULL; sd1 = seleMan1_.nextSelected(j)) {
117  
118 <            StuntDouble* sd2;
119 <            int k;
120 <            for (sd2 = seleMan2_.beginSelected(k); sd2 != NULL; sd2 = seleMan2_.nextSelected(k)) {
121 <                collectHistogram(sd1, sd2);
122 <            }            
123 <        }
118 >        
119 >      //selections may overlap.
120 >      //
121 >      // |s1 -c | c |
122 >      //            | c |s2 - c|
123 >      //
124 >      // s1 : number of selected stuntdoubles in selection1
125 >      // s2 : number of selected stuntdoubles in selection2
126 >      // c   : number of intersect stuntdouble between selection1 and selection2
127 >      //when loop over the pairs, we can divide the looping into 3 stages
128 >      //stage 1 :     [s1-c]      [s2]
129 >      //stage 2 :     [c]            [s2 - c]
130 >      //stage 3 :     [c]            [c]
131 >      //stage 1 and stage 2 are completly non-overlapping
132 >      //stage 3 are completely overlapping
133  
134 <        processHistogram();
134 >      if (evaluator1_.isDynamic() || evaluator2_.isDynamic()) {
135 >        common_ = seleMan1_ & seleMan2_;
136 >        sele1_minus_common_ = seleMan1_ - common_;
137 >        sele2_minus_common_ = seleMan2_ - common_;            
138 >        int nSelected1 = seleMan1_.getSelectionCount();
139 >        int nSelected2 = seleMan2_.getSelectionCount();
140 >        int nIntersect = common_.getSelectionCount();
141 >            
142 >        nPairs_ = nSelected1 * nSelected2 - (nIntersect +1) * nIntersect/2;
143 >      }
144 >      processNonOverlapping(sele1_minus_common_, seleMan2_);
145 >      processNonOverlapping(common_, sele2_minus_common_);        
146 >      processOverlapping(common_);
147 >      
148 >      processHistogram();
149          
150      }
151  
152      postProcess();
153  
154      writeRdf();
155 < }
155 >  }
156  
157 +  void RadialDistrFunc::processNonOverlapping( SelectionManager& sman1, SelectionManager& sman2) {
158 +    StuntDouble* sd1;
159 +    StuntDouble* sd2;
160 +    int i;    
161 +    int j;
162 +    
163 +    for (sd1 = sman1.beginSelected(i); sd1 != NULL; sd1 = sman1.nextSelected(i)) {
164 +
165 +      for (sd2 = sman2.beginSelected(j); sd2 != NULL; sd2 = sman2.nextSelected(j)) {
166 +        collectHistogram(sd1, sd2);
167 +      }            
168 +    }
169 +
170 +  }
171 +
172 +  void RadialDistrFunc::processOverlapping( SelectionManager& sman) {
173 +    StuntDouble* sd1;
174 +    StuntDouble* sd2;
175 +    int i;    
176 +    int j;
177 +
178 +    //basically, it is the same as below loop
179 +    //for (int i = 0;  i < n; ++i )
180 +    //  for (int j = i + 1; j < n; ++j) {}
181 +    
182 +    for (sd1 = sman.beginSelected(i); sd1 != NULL; sd1 = sman.nextSelected(i)) {                    
183 +      for (j  = i, sd2 = sman.nextSelected(j); sd2 != NULL; sd2 = sman.nextSelected(j)) {
184 +        collectHistogram(sd1, sd2);
185 +      }            
186 +    }
187 +
188 +  }
189 +
190   }

Comparing:
trunk/src/applications/staticProps/RadialDistrFunc.cpp (property svn:keywords), Revision 318 by tim, Sun Feb 13 06:57:48 2005 UTC vs.
branches/development/src/applications/staticProps/RadialDistrFunc.cpp (property svn:keywords), Revision 1665 by gezelter, Tue Nov 22 20:38:56 2011 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines