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

Comparing trunk/src/applications/staticProps/TetrahedralityParamZ.cpp (file contents):
Revision 1843 by gezelter, Tue Jan 29 20:58:08 2013 UTC vs.
Revision 1846 by gezelter, Thu Jan 31 15:55:47 2013 UTC

# Line 54 | Line 54 | namespace OpenMD {
54   namespace OpenMD {
55    TetrahedralityParamZ::TetrahedralityParamZ(SimInfo* info,  
56                                               const std::string& filename,
57 <                                             const std::string& sele,
57 >                                             const std::string& sele1,
58 >                                             const std::string& sele2,
59                                               double rCut, int nzbins)
60 <    : StaticAnalyser(info, filename), selectionScript_(sele), evaluator_(info),
61 <      seleMan_(info), nZBins_(nzbins) {
60 >    : StaticAnalyser(info, filename), selectionScript1_(sele1),
61 >      evaluator1_(info), seleMan1_(info), selectionScript2_(sele2),
62 >      evaluator2_(info), seleMan2_(info), nZBins_(nzbins) {
63      
64 <    evaluator_.loadScriptString(sele);
65 <    if (!evaluator_.isDynamic()) {
66 <      seleMan_.setSelectionSet(evaluator_.evaluate());
64 >    evaluator1_.loadScriptString(sele1);
65 >    if (!evaluator1_.isDynamic()) {
66 >      seleMan1_.setSelectionSet(evaluator1_.evaluate());
67      }
68 +    evaluator2_.loadScriptString(sele2);
69 +    if (!evaluator2_.isDynamic()) {
70 +      seleMan2_.setSelectionSet(evaluator2_.evaluate());
71 +    }
72      
73      // Set up cutoff radius:    
74      rCut_ = rCut;
# Line 91 | Line 97 | namespace OpenMD {
97      RigidBody* rb;
98      int myIndex;
99      SimInfo::MoleculeIterator mi;
94    Molecule::IntegrableObjectIterator ioi;
100      Molecule::RigidBodyIterator rbIter;
101      Vector3d vec;
102      Vector3d ri, rj, rk, rik, rkj;
# Line 99 | Line 104 | namespace OpenMD {
104      RealType cospsi;
105      RealType Qk;
106      std::vector<std::pair<RealType,StuntDouble*> > myNeighbors;
107 <    int isd;
107 >    int isd1;
108 >    int isd2;
109  
110      DumpReader reader(info_, dumpFilename_);    
111      int nFrames = reader.getNFrames();
# Line 113 | Line 119 | namespace OpenMD {
119        
120        RealType halfBoxZ_ = hmat(2,2) / 2.0;      
121  
122 <      if (evaluator_.isDynamic()) {
123 <        seleMan_.setSelectionSet(evaluator_.evaluate());
122 >      if (evaluator1_.isDynamic()) {
123 >        seleMan1_.setSelectionSet(evaluator1_.evaluate());
124        }
125        
126 +      if (evaluator2_.isDynamic()) {
127 +        seleMan2_.setSelectionSet(evaluator2_.evaluate());
128 +      }
129 +      
130        // update the positions of atoms which belong to the rigidbodies
131        for (mol = info_->beginMolecule(mi); mol != NULL;
132             mol = info_->nextMolecule(mi)) {
# Line 127 | Line 137 | namespace OpenMD {
137        }
138        
139        // outer loop is over the selected StuntDoubles:
140 <      for (sd = seleMan_.beginSelected(isd); sd != NULL;
141 <           sd = seleMan_.nextSelected(isd)) {
140 >      for (sd = seleMan1_.beginSelected(isd1); sd != NULL;
141 >           sd = seleMan1_.nextSelected(isd1)) {
142          
143          myIndex = sd->getGlobalIndex();
134
135        Qk = 1.0;        
136        myNeighbors.clear();
144          
145 <        // inner loop is over all StuntDoubles in the system:
146 <        
140 <        for (mol = info_->beginMolecule(mi); mol != NULL;
141 <             mol = info_->nextMolecule(mi)) {
145 >        Qk = 1.0;        
146 >        myNeighbors.clear();      
147  
148 <          for (sd2 = mol->beginIntegrableObject(ioi); sd2 != NULL;
149 <               sd2 = mol->nextIntegrableObject(ioi)) {
148 >        for (sd2 = seleMan2_.beginSelected(isd2); sd2 != NULL;
149 >             sd2 = seleMan2_.nextSelected(isd2)) {
150 >          
151 >          if (sd2->getGlobalIndex() != myIndex) {
152              
153 <            if (sd2->getGlobalIndex() != myIndex) {
154 <              
155 <              vec = sd->getPos() - sd2->getPos();      
156 <              
157 <              if (usePeriodicBoundaryConditions_)
158 <                currentSnapshot_->wrapVector(vec);
159 <              
160 <              r = vec.length();            
161 <
162 <              // Check to see if neighbor is in bond cutoff
163 <              
157 <              if (r < rCut_) {                
158 <                myNeighbors.push_back(std::make_pair(r,sd2));
159 <              }
153 >            vec = sd->getPos() - sd2->getPos();      
154 >            
155 >            if (usePeriodicBoundaryConditions_)
156 >              currentSnapshot_->wrapVector(vec);
157 >            
158 >            r = vec.length();            
159 >            
160 >            // Check to see if neighbor is in bond cutoff
161 >            
162 >            if (r < rCut_) {                
163 >              myNeighbors.push_back(std::make_pair(r,sd2));
164              }
165            }
166          }
# Line 170 | Line 174 | namespace OpenMD {
174          int nang = int (0.5 * (nbors * (nbors - 1)));
175          
176          rk = sd->getPos();
177 <
177 >        
178          for (int i = 0; i < nbors-1; i++) {      
179 <
179 >          
180            sdi = myNeighbors[i].second;
181            ri = sdi->getPos();
182            rik = rk - ri;
# Line 180 | Line 184 | namespace OpenMD {
184              currentSnapshot_->wrapVector(rik);
185            
186            rik.normalize();
187 <
187 >          
188            for (int j = i+1; j < nbors; j++) {      
189 <
189 >            
190              sdj = myNeighbors[j].second;
191              rj = sdj->getPos();
192              rkj = rk - rj;
# Line 191 | Line 195 | namespace OpenMD {
195              rkj.normalize();
196              
197              cospsi = dot(rik,rkj);          
198 <
198 >            
199              // Calculates scaled Qk for each molecule using calculated
200              // angles from 4 or fewer nearest neighbors.
201              Qk -=  (pow(cospsi + 1.0 / 3.0, 2) * 2.25 / nang);            
202            }
203          }
204 <
204 >        
205          if (nang > 0) {
206            if (usePeriodicBoundaryConditions_)
207              currentSnapshot_->wrapVector(rk);
# Line 226 | Line 230 | namespace OpenMD {
230      if (qZstream.is_open()) {
231        qZstream << "#Tetrahedrality Parameters (z)\n";
232        qZstream << "#nFrames:\t" << zBox_.size() << "\n";
233 <      qZstream << "#selection: (" << selectionScript_ << ")\n";
233 >      qZstream << "#selection 1: (" << selectionScript1_ << ")\n";
234 >      qZstream << "#selection 2: (" << selectionScript2_ << ")\n";
235        qZstream << "#z\tQk\n";
236        for (unsigned int i = 0; i < sliceQ_.size(); ++i) {
237          RealType z = zAve * (i+0.5) / sliceQ_.size();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines