ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/applications/staticProps/RadialDistrFunc.cpp
Revision: 1665
Committed: Tue Nov 22 20:38:56 2011 UTC (13 years, 6 months ago) by gezelter
File size: 6925 byte(s)
Log Message:
updated copyright notices

File Contents

# Content
1 /*
2 * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3 *
4 * The University of Notre Dame grants you ("Licensee") a
5 * non-exclusive, royalty free, license to use, modify and
6 * redistribute this software in source and binary code form, provided
7 * that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
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.
16 *
17 * This software is provided "AS IS," without a warranty of any
18 * kind. All express or implied conditions, representations and
19 * warranties, including any implied warranty of merchantability,
20 * fitness for a particular purpose or non-infringement, are hereby
21 * excluded. The University of Notre Dame and its licensors shall not
22 * be liable for any damages suffered by licensee as a result of
23 * using, modifying or distributing the software or its
24 * derivatives. In no event will the University of Notre Dame or its
25 * licensors be liable for any lost revenue, profit or data, or for
26 * direct, indirect, special, consequential, incidental or punitive
27 * damages, however caused and regardless of the theory of liability,
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>
44
45 #include "RadialDistrFunc.hpp"
46 #include "io/DumpReader.hpp"
47 #include "primitives/Molecule.hpp"
48 namespace OpenMD {
49
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);
57
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 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 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;
86 Molecule::RigidBodyIterator rbIter;
87
88 preProcess();
89
90 DumpReader reader(info_, dumpFilename_);
91 int nFrames = reader.getNFrames();
92 nProcessed_ = nFrames / step_;
93
94 for (int i = 0; i < nFrames; i += step_) {
95 reader.readFrame(i);
96 currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot();
97
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)) {
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 }
114
115 initalizeHistogram();
116
117
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 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 }
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 }

Properties

Name Value
svn:keywords Author Id Revision Date