| 71 | 
  | 
 | 
| 72 | 
  | 
    lNumber_ = lNumber; | 
| 73 | 
  | 
    rCut_ = rCut; | 
| 74 | 
< | 
    mSize_ = 2*lNumber_+1;     | 
| 74 | 
> | 
    mSize_ = 2*lNumber_+1;    | 
| 75 | 
> | 
 | 
| 76 | 
> | 
    // Q can take values from 0 to 1 | 
| 77 | 
> | 
 | 
| 78 | 
> | 
    MinQ_ = 0.0; | 
| 79 | 
> | 
    MaxQ_ = 3.0; | 
| 80 | 
> | 
    deltaQ_ = (MaxQ_ - MinQ_) / nbins; | 
| 81 | 
> | 
    Q_histogram_.resize(nbins); | 
| 82 | 
> | 
 | 
| 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.18; | 
| 87 | 
> | 
    MaxW_ = 0.18; | 
| 88 | 
> | 
    deltaW_ = (MaxW_ - MinW_) / nbins; | 
| 89 | 
> | 
    W_histogram_.resize(nbins); | 
| 90 | 
> | 
 | 
| 91 | 
  | 
  } | 
| 92 | 
  | 
 | 
| 93 | 
  | 
  BondOrderParameter::~BondOrderParameter() { | 
| 94 | 
+ | 
    Q_histogram_.clear(); | 
| 95 | 
+ | 
    W_histogram_.clear(); | 
| 96 | 
  | 
  } | 
| 97 | 
  | 
 | 
| 98 | 
+ | 
  void BondOrderParameter::initalizeHistogram() { | 
| 99 | 
+ | 
    std::fill(Q_histogram_.begin(), Q_histogram_.end(), 0); | 
| 100 | 
+ | 
    std::fill(W_histogram_.begin(), W_histogram_.end(), 0); | 
| 101 | 
+ | 
  } | 
| 102 | 
+ | 
 | 
| 103 | 
  | 
  void BondOrderParameter::process() { | 
| 104 | 
  | 
    Molecule* mol; | 
| 105 | 
  | 
    Atom* atom; | 
| 114 | 
  | 
    RealType phi; | 
| 115 | 
  | 
    RealType r; | 
| 116 | 
  | 
    RealType dist; | 
| 117 | 
+ | 
    std::map<int,ComplexType> q_lm; | 
| 118 | 
  | 
    std::map<int,ComplexType> QBar_lm; | 
| 119 | 
  | 
    RealType QSq_l; | 
| 120 | 
  | 
    RealType Q_l; | 
| 121 | 
  | 
    ComplexType W_l; | 
| 122 | 
  | 
    ComplexType W_l_hat; | 
| 123 | 
< | 
    int nBonds; | 
| 123 | 
> | 
    int nBonds, Nbonds; | 
| 124 | 
  | 
    SphericalHarmonic sphericalHarmonic; | 
| 125 | 
  | 
    int i, j; | 
| 126 | 
  | 
    // Make arrays for Wigner3jm | 
| 154 | 
  | 
             rb = mol->nextRigidBody(rbIter)) { | 
| 155 | 
  | 
          rb->updateAtoms(); | 
| 156 | 
  | 
        }         | 
| 157 | 
< | 
      }       | 
| 158 | 
< | 
       | 
| 135 | 
< | 
      nBonds = 0; | 
| 136 | 
< | 
       | 
| 137 | 
< | 
      for (int m = -lNumber_; m <= lNumber_; m++) { | 
| 138 | 
< | 
        QBar_lm[m] = 0.0; | 
| 139 | 
< | 
      } | 
| 140 | 
< | 
       | 
| 157 | 
> | 
      }            | 
| 158 | 
> | 
             | 
| 159 | 
  | 
      // outer loop is over the selected StuntDoubles: | 
| 160 | 
  | 
 | 
| 161 | 
  | 
      for (sd = seleMan_.beginSelected(i); sd != NULL;  | 
| 162 | 
  | 
           sd = seleMan_.nextSelected(i)) { | 
| 163 | 
  | 
 | 
| 164 | 
  | 
        myIndex = sd->getGlobalIndex(); | 
| 165 | 
+ | 
        nBonds = 0; | 
| 166 | 
+ | 
        for (int m = -lNumber_; m <= lNumber_; m++) { | 
| 167 | 
+ | 
          q_lm[m] = 0.0; | 
| 168 | 
+ | 
        } | 
| 169 | 
  | 
         | 
| 170 | 
  | 
        // inner loop is over all other atoms in the system: | 
| 171 | 
  | 
         | 
| 194 | 
  | 
                 | 
| 195 | 
  | 
                for(int m = -lNumber_; m <= lNumber_; m++){ | 
| 196 | 
  | 
                  sphericalHarmonic.setM(m); | 
| 197 | 
< | 
                  QBar_lm[m] += sphericalHarmonic.getValueAt(costheta, phi); | 
| 197 | 
> | 
                  q_lm[m] += sphericalHarmonic.getValueAt(costheta, phi); | 
| 198 | 
  | 
                } | 
| 199 | 
  | 
                nBonds++; | 
| 200 | 
  | 
              }   | 
| 201 | 
  | 
            } | 
| 202 | 
  | 
          } | 
| 203 | 
  | 
        } | 
| 204 | 
< | 
      }       | 
| 204 | 
> | 
        RealType ql = 0.0; | 
| 205 | 
> | 
        for(int m=-lNumber_; m<=lNumber_; m++) {           | 
| 206 | 
> | 
          ql += norm(QBar_lm[m]); | 
| 207 | 
> | 
        }         | 
| 208 | 
> | 
        ql *= 4.0*NumericConstant::PI/(RealType)(2*lNumber_+1); | 
| 209 | 
> | 
        collectHistogram(sqrt(ql)/(RealType)nBonds); | 
| 210 | 
> | 
 | 
| 211 | 
> | 
        Nbonds += nBonds; | 
| 212 | 
> | 
        for (int m=-lNumber_; m<=lNumber_; m++) { | 
| 213 | 
> | 
          QBar_lm[m] += q_lm[m]; | 
| 214 | 
> | 
        } | 
| 215 | 
> | 
      } | 
| 216 | 
  | 
    } | 
| 217 | 
  | 
 | 
| 218 | 
  | 
    // Normalize Qbar2 | 
| 219 | 
  | 
    for (int m = -lNumber_;m <= lNumber_; m++){ | 
| 220 | 
< | 
      QBar_lm[m] /= nBonds; | 
| 220 | 
> | 
      QBar_lm[m] /= Nbonds; | 
| 221 | 
  | 
    } | 
| 222 | 
  | 
     | 
| 223 | 
  | 
    // Find second order invariant Q_l | 
| 257 | 
  | 
    writeOrderParameter(Q_l, real(W_l_hat));     | 
| 258 | 
  | 
  } | 
| 259 | 
  | 
 | 
| 260 | 
+ | 
  void BondOrderParameter::collectHistogram(RealType q_l) { | 
| 261 | 
  | 
 | 
| 262 | 
+ | 
    if (q_l >= MinQ_ && q_l < MaxQ_) { | 
| 263 | 
+ | 
      int qbin = (q_l - MinQ_) / deltaQ_; | 
| 264 | 
+ | 
      Q_histogram_[qbin] += 1; | 
| 265 | 
+ | 
      Qcount_++; | 
| 266 | 
+ | 
      sumQ_ += q_l; | 
| 267 | 
+ | 
      sumQ2_ += q_l * q_l; | 
| 268 | 
+ | 
    } else { | 
| 269 | 
+ | 
      sprintf( painCave.errMsg, | 
| 270 | 
+ | 
               "q_l value outside reasonable range\n"); | 
| 271 | 
+ | 
      painCave.severity = OOPSE_ERROR; | 
| 272 | 
+ | 
      painCave.isFatal = 1; | 
| 273 | 
+ | 
      simError();   | 
| 274 | 
+ | 
    } | 
| 275 | 
+ | 
 | 
| 276 | 
+ | 
  }   | 
| 277 | 
+ | 
 | 
| 278 | 
+ | 
 | 
| 279 | 
  | 
  void BondOrderParameter::writeOrderParameter(RealType ql, RealType Wlhat) { | 
| 280 | 
  | 
 | 
| 281 | 
  | 
    std::ofstream os(getOutputFileName().c_str()); | 
| 287 | 
  | 
      os << "# \n"; | 
| 288 | 
  | 
      os << "# <Q_" << lNumber_ << ">: " << ql << "\n"; | 
| 289 | 
  | 
      os << "# <W_" << lNumber_ << ">: " << Wlhat << "\n"; | 
| 290 | 
+ | 
      // Normalize by number of frames and write it out: | 
| 291 | 
+ | 
      for (int i = 0; i < Q_histogram_.size(); ++i) { | 
| 292 | 
+ | 
        RealType Qval = MinQ_ + (i + 0.5) * deltaQ_; | 
| 293 | 
+ | 
        osq << Qval << "\t" << (RealType)Q_histogram_[i] / (RealType)Qcount_ << "\n"; | 
| 294 | 
+ | 
      } | 
| 295 | 
+ | 
 | 
| 296 | 
  | 
      os.close(); | 
| 297 | 
  | 
 | 
| 298 | 
  | 
    } else { |