| 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.22 2006-12-20 21:03:11 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" | 
| 83 | 
  | 
    // W_6 for icosahedral clusters is 11 / sqrt(4199) = 0.169754, so we'll | 
| 84 | 
  | 
    // use values for MinW_ and MaxW_ that are slightly larger than this: | 
| 85 | 
  | 
 | 
| 86 | 
< | 
    MinW_ = -0.25; | 
| 87 | 
< | 
    MaxW_ = 0.25; | 
| 86 | 
> | 
    MinW_ = -1.1; | 
| 87 | 
> | 
    MaxW_ = 1.1; | 
| 88 | 
  | 
    deltaW_ = (MaxW_ - MinW_) / nbins; | 
| 89 | 
  | 
 | 
| 90 | 
  | 
    // Make arrays for Wigner3jm | 
| 105 | 
  | 
        for (int ii = 0; ii < 2*l + 1; ii++){ | 
| 106 | 
  | 
          THRCOF[ii] = 0.0; | 
| 107 | 
  | 
        } | 
| 108 | 
< | 
             | 
| 108 | 
> | 
 | 
| 109 | 
  | 
        // Get Wigner coefficients | 
| 110 | 
  | 
        Wigner3jm(&lPass, &lPass, &lPass,  | 
| 111 | 
  | 
                  &m1Pass, &m2m, &m2M,  | 
| 114 | 
  | 
        m2Min[lm] = (int)floor(m2m); | 
| 115 | 
  | 
        m2Max[lm] = (int)floor(m2M); | 
| 116 | 
  | 
         | 
| 117 | 
< | 
        for (int mmm = 0; mmm < (int)(m2M - m2m); mmm++) { | 
| 117 | 
> | 
        for (int mmm = 0; mmm <= (int)(m2M - m2m); mmm++) { | 
| 118 | 
  | 
          w3j[lm].push_back(THRCOF[mmm]); | 
| 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++) { | 
| 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); | 
| 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))                 | 
| 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++) { | 
| 277 | 
  | 
          w[l] = 0.0; | 
| 278 | 
  | 
          for (int m1 = -l; m1 <= l; m1++) { | 
| 279 | 
  | 
            std::pair<int,int> lm = std::make_pair(l, m1); | 
| 280 | 
< | 
            for (int mmm = 0; mmm < (m2Max[lm] - m2Min[lm]); mmm++) { | 
| 280 | 
> | 
            for (int mmm = 0; mmm <= (m2Max[lm] - m2Min[lm]); mmm++) { | 
| 281 | 
  | 
              int m2 = m2Min[lm] + mmm; | 
| 282 | 
  | 
              int m3 = -m1-m2; | 
| 283 | 
  | 
              w[l] += w3j[lm][mmm] * q[lm] *  | 
| 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 | 
  | 
      } | 
| 322 | 
  | 
      W[l] = 0.0; | 
| 323 | 
  | 
      for (int m1 = -l; m1 <= l; m1++) { | 
| 324 | 
  | 
        std::pair<int,int> lm = std::make_pair(l, m1); | 
| 325 | 
< | 
        for (int mmm = 0; mmm < (m2Max[lm] - m2Min[lm]); mmm++) { | 
| 325 | 
> | 
        for (int mmm = 0; mmm <= (m2Max[lm] - m2Min[lm]); mmm++) { | 
| 326 | 
  | 
          int m2 = m2Min[lm] + mmm; | 
| 327 | 
  | 
          int m3 = -m1-m2; | 
| 328 | 
  | 
          W[l] += w3j[lm][mmm] * QBar[lm] *  | 
| 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();   | 
| 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 | 
  | 
      } | 
| 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 | 
  | 
      } |