# | 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] Vardeman & Gezelter, in progress (2009). |
40 | */ | |
41 | ||
42 | #include <algorithm> | |
# | Line 44 | Line 44 | |
44 | #include "RadialDistrFunc.hpp" | |
45 | #include "io/DumpReader.hpp" | |
46 | #include "primitives/Molecule.hpp" | |
47 | < | namespace oopse { |
47 | > | namespace OpenMD { |
48 | ||
49 | < | RadialDistrFunc:: RadialDistrFunc(SimInfo* info, const std::string& filename, const std::string& sele1, const std::string& sele2) |
50 | < | : info_(info), currentSnapshot_(NULL), dumpFilename_(filename), step_(1), |
51 | < | selectionScript1_(sele1), selectionScript2_(sele2), evaluator1_(info), evaluator2_(info), |
52 | < | seleMan1_(info), seleMan2_(info), common_(info), sele1_minus_common_(info), sele2_minus_common_(info){ |
49 | > | RadialDistrFunc::RadialDistrFunc(SimInfo* info, const std::string& filename, const std::string& sele1, const std::string& sele2) |
50 | > | : StaticAnalyser(info, filename), |
51 | > | selectionScript1_(sele1), selectionScript2_(sele2), evaluator1_(info), evaluator2_(info), |
52 | > | seleMan1_(info), seleMan2_(info), common_(info), sele1_minus_common_(info), sele2_minus_common_(info){ |
53 | ||
54 | < | evaluator1_.loadScriptString(sele1); |
55 | < | evaluator2_.loadScriptString(sele2); |
54 | > | evaluator1_.loadScriptString(sele1); |
55 | > | evaluator2_.loadScriptString(sele2); |
56 | ||
57 | < | if (!evaluator1_.isDynamic()) { |
58 | < | seleMan1_.setSelectionSet(evaluator1_.evaluate()); |
59 | < | } |
60 | < | if (!evaluator2_.isDynamic()) { |
61 | < | seleMan2_.setSelectionSet(evaluator2_.evaluate()); |
62 | < | } |
57 | > | if (!evaluator1_.isDynamic()) { |
58 | > | seleMan1_.setSelectionSet(evaluator1_.evaluate()); |
59 | > | validateSelection1(seleMan1_); |
60 | > | } |
61 | > | if (!evaluator2_.isDynamic()) { |
62 | > | seleMan2_.setSelectionSet(evaluator2_.evaluate()); |
63 | > | validateSelection2(seleMan2_); |
64 | > | } |
65 | ||
66 | < | if (!evaluator1_.isDynamic() && !evaluator2_.isDynamic()) { |
66 | > | if (!evaluator1_.isDynamic() && !evaluator2_.isDynamic()) { |
67 | //if all selections are static, we can precompute the number of real pairs | |
68 | common_ = seleMan1_ & seleMan2_; | |
69 | sele1_minus_common_ = seleMan1_ - common_; | |
# | Line 72 | Line 74 | RadialDistrFunc:: RadialDistrFunc(SimInfo* info | |
74 | int nIntersect = common_.getSelectionCount(); | |
75 | ||
76 | nPairs_ = nSelected1 * nSelected2 - (nIntersect +1) * nIntersect/2; | |
77 | < | } |
77 | > | } |
78 | ||
79 | < | } |
79 | > | } |
80 | ||
81 | < | void RadialDistrFunc::process() { |
81 | > | void RadialDistrFunc::process() { |
82 | Molecule* mol; | |
83 | RigidBody* rb; | |
84 | SimInfo::MoleculeIterator mi; | |
# | Line 89 | Line 91 | void RadialDistrFunc::process() { | |
91 | nProcessed_ = nFrames / step_; | |
92 | ||
93 | for (int i = 0; i < nFrames; i += step_) { | |
94 | < | reader.readFrame(i); |
95 | < | currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot(); |
94 | > | reader.readFrame(i); |
95 | > | currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot(); |
96 | ||
97 | < | if (evaluator1_.isDynamic()) { |
98 | < | seleMan1_.setSelectionSet(evaluator1_.evaluate()); |
99 | < | } |
100 | < | if (evaluator2_.isDynamic()) { |
101 | < | seleMan2_.setSelectionSet(evaluator2_.evaluate()); |
102 | < | } |
97 | > | if (evaluator1_.isDynamic()) { |
98 | > | seleMan1_.setSelectionSet(evaluator1_.evaluate()); |
99 | > | validateSelection1(seleMan1_); |
100 | > | } |
101 | > | if (evaluator2_.isDynamic()) { |
102 | > | seleMan2_.setSelectionSet(evaluator2_.evaluate()); |
103 | > | validateSelection2(seleMan2_); |
104 | > | } |
105 | ||
106 | < | for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) { |
106 | > | for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) { |
107 | ||
108 | < | //change the positions of atoms which belong to the rigidbodies |
109 | < | for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
110 | < | rb->updateAtoms(); |
111 | < | } |
112 | < | } |
108 | > | //change the positions of atoms which belong to the rigidbodies |
109 | > | for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
110 | > | rb->updateAtoms(); |
111 | > | } |
112 | > | } |
113 | ||
114 | < | initalizeHistogram(); |
114 | > | initalizeHistogram(); |
115 | ||
116 | ||
117 | ||
118 | < | //selections may overlap. |
119 | < | // |
120 | < | // |s1 -c | c | |
121 | < | // | c |s2 - c| |
122 | < | // |
123 | < | // s1 : number of selected stuntdoubles in selection1 |
124 | < | // s2 : number of selected stuntdoubles in selection2 |
125 | < | // c : number of intersect stuntdouble between selection1 and selection2 |
126 | < | //when loop over the pairs, we can divide the looping into 3 stages |
127 | < | //stage 1 : [s1-c] [s2] |
128 | < | //stage 2 : [c] [s2 - c] |
129 | < | //stage 3 : [c] [c] |
130 | < | //stage 1 and stage 2 are completly non-overlapping |
131 | < | //stage 3 are completely overlapping |
118 | > | //selections may overlap. |
119 | > | // |
120 | > | // |s1 -c | c | |
121 | > | // | c |s2 - c| |
122 | > | // |
123 | > | // s1 : number of selected stuntdoubles in selection1 |
124 | > | // s2 : number of selected stuntdoubles in selection2 |
125 | > | // c : number of intersect stuntdouble between selection1 and selection2 |
126 | > | //when loop over the pairs, we can divide the looping into 3 stages |
127 | > | //stage 1 : [s1-c] [s2] |
128 | > | //stage 2 : [c] [s2 - c] |
129 | > | //stage 3 : [c] [c] |
130 | > | //stage 1 and stage 2 are completly non-overlapping |
131 | > | //stage 3 are completely overlapping |
132 | ||
133 | < | if (evaluator1_.isDynamic() || evaluator2_.isDynamic()) { |
134 | < | |
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(); |
136 | < | int nIntersect = common_.getSelectionCount(); |
133 | > | if (evaluator1_.isDynamic() || evaluator2_.isDynamic()) { |
134 | > | common_ = seleMan1_ & seleMan2_; |
135 | > | sele1_minus_common_ = seleMan1_ - common_; |
136 | > | sele2_minus_common_ = seleMan2_ - common_; |
137 | > | int nSelected1 = seleMan1_.getSelectionCount(); |
138 | > | int nSelected2 = seleMan2_.getSelectionCount(); |
139 | > | int nIntersect = common_.getSelectionCount(); |
140 | ||
141 | < | nPairs_ = nSelected1 * nSelected2 - (nIntersect +1) * nIntersect/2; |
142 | < | } |
143 | < | |
144 | < | processNonOverlapping(sele1_minus_common_, seleMan2_); |
145 | < | processNonOverlapping(common_, sele2_minus_common_); |
146 | < | processOverlapping(common_); |
141 | > | nPairs_ = nSelected1 * nSelected2 - (nIntersect +1) * nIntersect/2; |
142 | > | } |
143 | > | processNonOverlapping(sele1_minus_common_, seleMan2_); |
144 | > | processNonOverlapping(common_, sele2_minus_common_); |
145 | > | processOverlapping(common_); |
146 | > | |
147 | > | processHistogram(); |
148 | ||
145 | – | |
146 | – | processHistogram(); |
147 | – | |
149 | } | |
150 | ||
151 | postProcess(); | |
152 | ||
153 | writeRdf(); | |
154 | < | } |
154 | > | } |
155 | ||
156 | < | void RadialDistrFunc::processNonOverlapping( SelectionManager& sman1, SelectionManager& sman2) { |
156 | > | void RadialDistrFunc::processNonOverlapping( SelectionManager& sman1, SelectionManager& sman2) { |
157 | StuntDouble* sd1; | |
158 | StuntDouble* sd2; | |
159 | int i; | |
# | Line 160 | Line 161 | void RadialDistrFunc::processNonOverlapping( Selection | |
161 | ||
162 | for (sd1 = sman1.beginSelected(i); sd1 != NULL; sd1 = sman1.nextSelected(i)) { | |
163 | ||
164 | < | for (sd2 = sman2.beginSelected(j); sd2 != NULL; sd2 = sman2.nextSelected(j)) { |
165 | < | collectHistogram(sd1, sd2); |
166 | < | } |
164 | > | for (sd2 = sman2.beginSelected(j); sd2 != NULL; sd2 = sman2.nextSelected(j)) { |
165 | > | collectHistogram(sd1, sd2); |
166 | > | } |
167 | } | |
168 | ||
169 | < | } |
169 | > | } |
170 | ||
171 | < | void RadialDistrFunc::processOverlapping( SelectionManager& sman) { |
171 | > | void RadialDistrFunc::processOverlapping( SelectionManager& sman) { |
172 | StuntDouble* sd1; | |
173 | StuntDouble* sd2; | |
174 | int i; | |
# | Line 178 | Line 179 | void RadialDistrFunc::processOverlapping( SelectionMan | |
179 | // for (int j = i + 1; j < n; ++j) {} | |
180 | ||
181 | for (sd1 = sman.beginSelected(i); sd1 != NULL; sd1 = sman.nextSelected(i)) { | |
182 | < | for (j = i, sd2 = sman.nextSelected(j); sd2 != NULL; sd2 = sman.nextSelected(j)) { |
183 | < | collectHistogram(sd1, sd2); |
184 | < | } |
182 | > | for (j = i, sd2 = sman.nextSelected(j); sd2 != NULL; sd2 = sman.nextSelected(j)) { |
183 | > | collectHistogram(sd1, sd2); |
184 | > | } |
185 | } | |
186 | ||
187 | < | } |
187 | > | } |
188 | ||
189 | } |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |