ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/applications/staticProps/BondOrderParameter.cpp
(Generate patch)

Comparing trunk/OOPSE-4/src/applications/staticProps/BondOrderParameter.cpp (file contents):
Revision 3024 by gezelter, Tue Sep 26 14:33:56 2006 UTC vs.
Revision 3079 by gezelter, Tue Nov 21 20:44:54 2006 UTC

# Line 37 | Line 37
37   * arising out of the use of or inability to use software, even if the
38   * University of Notre Dame has been advised of the possibility of
39   * such damages.
40 + *
41 + *  BondOrderParameter.cpp
42 + *  OOPSE-4
43 + *
44 + *  Created by J. Daniel Gezelter on 09/26/06.
45 + *  @author  J. Daniel Gezelter
46 + *  @version $Id: BondOrderParameter.cpp,v 1.21 2006-11-21 20:44:54 gezelter Exp $
47 + *
48   */
41
42
43 /* Creates orientational bond order parameters as outlined by
44 *     Bond-orientaional order in liquids and glasses, Steinhart,Nelson,Ronchetti
45 *     Phys Rev B, 28,784,1983
46 *
47 */
49  
50   #include "applications/staticProps/BondOrderParameter.hpp"
51   #include "utils/simError.h"
# Line 118 | Line 119 | namespace oopse {
119          }
120        }
121      }
122 +    delete [] THRCOF;
123 +    THRCOF = NULL;
124    }
125    
126    BondOrderParameter::~BondOrderParameter() {
127      Q_histogram_.clear();
128      W_histogram_.clear();
129 +    for (int l = 0; l <= lMax_; l++) {
130 +      for (int m = -l; m <= l; m++) {
131 +        w3j[std::make_pair(l,m)].clear();
132 +      }
133 +    }
134 +    w3j.clear();
135 +    m2Min.clear();
136 +    m2Max.clear();
137    }
138 <
138 >  
139    void BondOrderParameter::initalizeHistogram() {
140      for (int bin = 0; bin < nBins_; bin++) {
141        for (int l = 0; l <= lMax_; l++) {
# Line 175 | Line 186 | namespace oopse {
186      Q.resize(lMax_+1);
187      W.resize(lMax_+1);
188      W_hat.resize(lMax_+1);
189 +    Nbonds = 0;
190  
191      for (int istep = 0; istep < nFrames; istep += step_) {
192        reader.readFrame(istep);
# Line 219 | Line 231 | namespace oopse {
231              if (atom->getGlobalIndex() != myIndex) {
232  
233                vec = sd->getPos() - atom->getPos();      
234 <              currentSnapshot_->wrapVector(vec);
234 >
235 >              if (usePeriodicBoundaryConditions_)
236 >                currentSnapshot_->wrapVector(vec);
237                
238                // Calculate "bonds" and build Q_lm(r) where
239                //      Q_lm = Y_lm(theta(r),phi(r))                
# Line 248 | Line 262 | namespace oopse {
262          }
263          
264          
251        for (int l = 0; l <= lMax_; l++) {        
252          q_l[l] = 0.0;
253          for(int m = -l; m <= l; m++) {
254            q_l[l] += norm(q[std::make_pair(l,m)]);
255          }    
256          q_l[l] *= 4.0*NumericConstant::PI/(RealType)(2*l + 1);
257          q_l[l] = sqrt(q_l[l])/(RealType)nBonds;
258        }
259
260        // Find second order invariant Q_l
261        
265          for (int l = 0; l <= lMax_; l++) {
266            q2[l] = 0.0;
267            for (int m = -l; m <= l; m++){
268 +            q[std::make_pair(l,m)] /= (RealType)nBonds;            
269              q2[l] += norm(q[std::make_pair(l,m)]);
270            }
271 <          q_l[l] = sqrt(q2[l] * 4.0 * NumericConstant::PI /
268 <                        (RealType)(2*l + 1))/(RealType)nBonds;
271 >          q_l[l] = sqrt(q2[l] * 4.0 * NumericConstant::PI / (RealType)(2*l + 1));
272          }
273 <
273 >        
274          // Find Third Order Invariant W_l
275      
276          for (int l = 0; l <= lMax_; l++) {
# Line 290 | Line 293 | namespace oopse {
293          Nbonds += nBonds;
294          for (int l = 0; l <= lMax_;  l++) {
295            for (int m = -l; m <= l; m++) {
296 <            QBar[std::make_pair(l,m)] += q[std::make_pair(l,m)];
296 >            QBar[std::make_pair(l,m)] += (RealType)nBonds*q[std::make_pair(l,m)];
297            }
298          }
299        }
# Line 357 | Line 360 | namespace oopse {
360          Wcount_[l]++;      
361        } else {
362          sprintf( painCave.errMsg,
363 <                 "Re[w_hat] value outside reasonable range\n");
363 >                 "Re[w_hat] value (%lf) outside reasonable range\n", real(what[l]));
364          painCave.severity = OOPSE_ERROR;
365          painCave.isFatal = 1;
366          simError();  
# Line 385 | Line 388 | namespace oopse {
388          RealType Qval = MinQ_ + (i + 0.5) * deltaQ_;              
389          osq << Qval;
390          for (int l = 0; l <= lMax_; l++) {
391 <          osq << "\t" << (RealType)Q_histogram_[std::make_pair(i,l)] / (RealType)Qcount_[l];
391 >
392 >          osq << "\t" << (RealType)Q_histogram_[std::make_pair(i,l)]/(RealType)Qcount_[l]/deltaQ_;
393          }
394          osq << "\n";
395        }
# Line 406 | Line 410 | namespace oopse {
410        osw << "# selection: (" << selectionScript_ << ")\n";
411        osw << "# \n";
412        for (int l = 0; l <= lMax_; l++) {
413 <        osw << "# <W_" << l << ">: " << real(What[l]) << "\n";
413 >        osw << "# <W_" << l << ">: " << real(What[l]) << "\t" << imag(What[l]) << "\n";
414        }
415        // Normalize by number of frames and write it out:
416        for (int i = 0; i < nBins_; ++i) {
417          RealType Wval = MinW_ + (i + 0.5) * deltaW_;              
418          osw << Wval;
419          for (int l = 0; l <= lMax_; l++) {
420 <          osw << "\t" << (RealType)W_histogram_[std::make_pair(i,l)] / (RealType)Wcount_[l];
420 >
421 >          osw << "\t" << (RealType)W_histogram_[std::make_pair(i,l)]/(RealType)Wcount_[l]/deltaW_;
422          }
423          osw << "\n";
424        }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines