| 51 | 
  | 
#include "io/DumpReader.hpp" | 
| 52 | 
  | 
#include "primitives/Molecule.hpp" | 
| 53 | 
  | 
#include "utils/NumericConstant.hpp" | 
| 54 | 
< | 
#include "math/RealSphericalHarmonic.hpp" | 
| 54 | 
> | 
 | 
| 55 | 
  | 
namespace oopse { | 
| 56 | 
  | 
 | 
| 57 | 
– | 
 | 
| 57 | 
  | 
  BondOrderParameter::BondOrderParameter(SimInfo* info,  | 
| 58 | 
  | 
                                         const std::string& filename,  | 
| 59 | 
  | 
                                         const std::string& sele, | 
| 60 | 
< | 
                                         double rCut, int lNumber, int nbins) | 
| 62 | 
< | 
    : StaticAnalyser(info, filename), selectionScript_(sele),  | 
| 63 | 
< | 
      evaluator_(info), seleMan_(info){ | 
| 60 | 
> | 
                                         double rCut, int nbins) : StaticAnalyser(info, filename), selectionScript_(sele), evaluator_(info), seleMan_(info){ | 
| 61 | 
  | 
     | 
| 62 | 
< | 
    setOutputName(getPrefix(filename) + ".obo"); | 
| 62 | 
> | 
    setOutputName(getPrefix(filename) + ".bo"); | 
| 63 | 
  | 
 | 
| 64 | 
  | 
    evaluator_.loadScriptString(sele); | 
| 65 | 
  | 
    if (!evaluator_.isDynamic()) { | 
| 68 | 
  | 
 | 
| 69 | 
  | 
    // Set up cutoff radius and order of the Legendre Polynomial: | 
| 70 | 
  | 
 | 
| 74 | 
– | 
    lNumber_ = lNumber; | 
| 71 | 
  | 
    rCut_ = rCut; | 
| 72 | 
< | 
    mSize_ = 2*lNumber_+1;     | 
| 72 | 
> | 
    nBins_ = nbins; | 
| 73 | 
> | 
    Qcount_.resize(lMax_+1); | 
| 74 | 
> | 
    Wcount_.resize(lMax_+1); | 
| 75 | 
  | 
 | 
| 76 | 
< | 
    deltaQ_ = 1.0 / nbins; | 
| 79 | 
< | 
    deltaW_ = 2.0 / nbins; | 
| 76 | 
> | 
    // Q can take values from 0 to 1 | 
| 77 | 
  | 
 | 
| 78 | 
< | 
    Q_histogram_.resize(nbins); | 
| 79 | 
< | 
    W_histogram_.resize(nbins); | 
| 78 | 
> | 
    MinQ_ = 0.0; | 
| 79 | 
> | 
    MaxQ_ = 1.1; | 
| 80 | 
> | 
    deltaQ_ = (MaxQ_ - MinQ_) / nbins; | 
| 81 | 
  | 
 | 
| 82 | 
+ | 
    // W_6 for icosahedral clusters is 11 / sqrt(4199) = 0.169754, so we'll | 
| 83 | 
+ | 
    // use values for MinW_ and MaxW_ that are slightly larger than this: | 
| 84 | 
+ | 
 | 
| 85 | 
+ | 
    MinW_ = -0.25; | 
| 86 | 
+ | 
    MaxW_ = 0.25; | 
| 87 | 
+ | 
    deltaW_ = (MaxW_ - MinW_) / nbins; | 
| 88 | 
  | 
  } | 
| 89 | 
  | 
 | 
| 90 | 
+ | 
  BondOrderParameter::~BondOrderParameter() { | 
| 91 | 
+ | 
    Q_histogram_.clear(); | 
| 92 | 
+ | 
    W_histogram_.clear(); | 
| 93 | 
+ | 
  } | 
| 94 | 
+ | 
 | 
| 95 | 
  | 
  void BondOrderParameter::initalizeHistogram() { | 
| 96 | 
< | 
    std::fill(Q_histogram_.begin(), Q_histogram_.end(), 0); | 
| 97 | 
< | 
    std::fill(W_histogram_.begin(), W_histogram_.end(), 0); | 
| 96 | 
> | 
    for (int bin = 0; bin < nBins_; bin++) { | 
| 97 | 
> | 
      for (int l = 0; l <= lMax_; l++) { | 
| 98 | 
> | 
        Q_histogram_[std::make_pair(bin,l)] = 0; | 
| 99 | 
> | 
        W_histogram_[std::make_pair(bin,l)] = 0; | 
| 100 | 
> | 
      } | 
| 101 | 
> | 
    } | 
| 102 | 
  | 
  } | 
| 103 | 
  | 
 | 
| 104 | 
  | 
  void BondOrderParameter::process() { | 
| 105 | 
  | 
    Molecule* mol; | 
| 106 | 
  | 
    Atom* atom; | 
| 107 | 
  | 
    RigidBody* rb; | 
| 108 | 
+ | 
    int myIndex; | 
| 109 | 
  | 
    SimInfo::MoleculeIterator mi; | 
| 110 | 
  | 
    Molecule::RigidBodyIterator rbIter; | 
| 111 | 
  | 
    Molecule::AtomIterator ai; | 
| 112 | 
  | 
    StuntDouble* sd; | 
| 113 | 
< | 
    RealType theta; | 
| 113 | 
> | 
    Vector3d vec; | 
| 114 | 
> | 
    RealType costheta; | 
| 115 | 
  | 
    RealType phi; | 
| 116 | 
  | 
    RealType r; | 
| 117 | 
  | 
    RealType dist; | 
| 118 | 
< | 
    std::map<int, RealType> QBar_lm; | 
| 119 | 
< | 
    RealType QSq_l; | 
| 120 | 
< | 
    RealType Q_l; | 
| 121 | 
< | 
    int nBonds; | 
| 122 | 
< | 
    RealSphericalHarmonic sphericalHarmonic; | 
| 118 | 
> | 
    std::map<std::pair<int,int>,ComplexType> q; | 
| 119 | 
> | 
    std::vector<RealType> q_l; | 
| 120 | 
> | 
    std::vector<RealType> q2; | 
| 121 | 
> | 
    std::vector<ComplexType> w; | 
| 122 | 
> | 
    std::vector<ComplexType> w_hat; | 
| 123 | 
> | 
    std::map<std::pair<int,int>,ComplexType> QBar; | 
| 124 | 
> | 
    std::vector<RealType> Q2; | 
| 125 | 
> | 
    std::vector<RealType> Q; | 
| 126 | 
> | 
    std::vector<ComplexType> W; | 
| 127 | 
> | 
    std::vector<ComplexType> W_hat; | 
| 128 | 
> | 
    int nBonds, Nbonds; | 
| 129 | 
> | 
    SphericalHarmonic sphericalHarmonic; | 
| 130 | 
  | 
    int i, j; | 
| 131 | 
< | 
   | 
| 132 | 
< | 
    // Set the l for the spherical harmonic, it doesn't change | 
| 133 | 
< | 
    sphericalHarmonic.setL(lNumber_); | 
| 131 | 
> | 
    // Make arrays for Wigner3jm | 
| 132 | 
> | 
    double* THRCOF = new double[2*lMax_+1]; | 
| 133 | 
> | 
    // Variables for Wigner routine | 
| 134 | 
> | 
    double lPass, m1Pass, m2Min, m2Max; | 
| 135 | 
> | 
    int error, m1, m2, m3, mSize; | 
| 136 | 
> | 
    mSize = 2*lMax_+1; | 
| 137 | 
  | 
 | 
| 113 | 
– | 
 | 
| 138 | 
  | 
    DumpReader reader(info_, dumpFilename_);     | 
| 139 | 
  | 
    int nFrames = reader.getNFrames(); | 
| 140 | 
+ | 
    frameCounter_ = 0; | 
| 141 | 
  | 
 | 
| 142 | 
+ | 
    q_l.resize(lMax_+1); | 
| 143 | 
+ | 
    q2.resize(lMax_+1); | 
| 144 | 
+ | 
    w.resize(lMax_+1); | 
| 145 | 
+ | 
    w_hat.resize(lMax_+1); | 
| 146 | 
  | 
 | 
| 147 | 
+ | 
    Q2.resize(lMax_+1); | 
| 148 | 
+ | 
    Q.resize(lMax_+1); | 
| 149 | 
+ | 
    W.resize(lMax_+1); | 
| 150 | 
+ | 
    W_hat.resize(lMax_+1); | 
| 151 | 
+ | 
 | 
| 152 | 
  | 
    for (int istep = 0; istep < nFrames; istep += step_) { | 
| 153 | 
  | 
      reader.readFrame(istep); | 
| 154 | 
+ | 
      frameCounter_++; | 
| 155 | 
  | 
      currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot(); | 
| 156 | 
  | 
       | 
| 157 | 
  | 
      if (evaluator_.isDynamic()) { | 
| 166 | 
  | 
             rb = mol->nextRigidBody(rbIter)) { | 
| 167 | 
  | 
          rb->updateAtoms(); | 
| 168 | 
  | 
        }         | 
| 169 | 
< | 
      }       | 
| 170 | 
< | 
       | 
| 169 | 
> | 
      }            | 
| 170 | 
> | 
             | 
| 171 | 
  | 
      // outer loop is over the selected StuntDoubles: | 
| 172 | 
  | 
 | 
| 173 | 
  | 
      for (sd = seleMan_.beginSelected(i); sd != NULL;  | 
| 174 | 
  | 
           sd = seleMan_.nextSelected(i)) { | 
| 175 | 
  | 
 | 
| 176 | 
< | 
        // For this central atom, zero out nBonds and QBar_lm | 
| 142 | 
< | 
 | 
| 176 | 
> | 
        myIndex = sd->getGlobalIndex(); | 
| 177 | 
  | 
        nBonds = 0; | 
| 178 | 
< | 
        | 
| 179 | 
< | 
        for (int m = -lNumber_; m <= lNumber_; m++) { | 
| 180 | 
< | 
          QBar_lm[m] = 0.0; | 
| 178 | 
> | 
         | 
| 179 | 
> | 
        for (int l = 0; l <= lMax_; l++) { | 
| 180 | 
> | 
          for (int m = -l; m <= l; m++) { | 
| 181 | 
> | 
            q[std::make_pair(l,m)] = 0.0; | 
| 182 | 
> | 
          } | 
| 183 | 
  | 
        } | 
| 184 | 
  | 
         | 
| 185 | 
  | 
        // inner loop is over all other atoms in the system: | 
| 189 | 
  | 
          for (atom = mol->beginAtom(ai); atom != NULL;  | 
| 190 | 
  | 
               atom = mol->nextAtom(ai)) { | 
| 191 | 
  | 
 | 
| 192 | 
+ | 
            if (atom->getGlobalIndex() != myIndex) { | 
| 193 | 
  | 
 | 
| 194 | 
< | 
            Vector3d vec = sd->getPos() - atom->getPos();        | 
| 195 | 
< | 
            currentSnapshot_->wrapVector(vec); | 
| 196 | 
< | 
             | 
| 197 | 
< | 
            // Calculate "bonds" and build Q_lm(r) where  | 
| 198 | 
< | 
            //      Q_lm = Y_lm(theta(r),phi(r))                 | 
| 199 | 
< | 
            // The spherical harmonics are wrt any arbitrary coordinate | 
| 200 | 
< | 
            // system, we choose standard spherical coordinates  | 
| 201 | 
< | 
             | 
| 202 | 
< | 
            r = sqrt(pow(vec.x(),2)+pow(vec.y(),2)+pow(vec.z(),2)); | 
| 203 | 
< | 
             | 
| 204 | 
< | 
            // Check to see if neighbor is in bond cutoff  | 
| 205 | 
< | 
             | 
| 206 | 
< | 
            if (r < rCut_) {             | 
| 207 | 
< | 
              theta = atan2(vec.y(), vec.x()); | 
| 208 | 
< | 
              phi = acos(vec.z()/r); | 
| 209 | 
< | 
              for(int m = -lNumber_; m <= lNumber_; m++){ | 
| 210 | 
< | 
                sphericalHarmonic.setM(m); | 
| 211 | 
< | 
                QBar_lm[m] += sphericalHarmonic.getValueAt(theta,phi); | 
| 212 | 
< | 
              } | 
| 213 | 
< | 
              nBonds++; | 
| 214 | 
< | 
            }   | 
| 194 | 
> | 
              vec = sd->getPos() - atom->getPos();        | 
| 195 | 
> | 
              currentSnapshot_->wrapVector(vec); | 
| 196 | 
> | 
               | 
| 197 | 
> | 
              // Calculate "bonds" and build Q_lm(r) where  | 
| 198 | 
> | 
              //      Q_lm = Y_lm(theta(r),phi(r))                 | 
| 199 | 
> | 
              // The spherical harmonics are wrt any arbitrary coordinate | 
| 200 | 
> | 
              // system, we choose standard spherical coordinates  | 
| 201 | 
> | 
               | 
| 202 | 
> | 
              r = vec.length(); | 
| 203 | 
> | 
               | 
| 204 | 
> | 
              // Check to see if neighbor is in bond cutoff  | 
| 205 | 
> | 
               | 
| 206 | 
> | 
              if (r < rCut_) {  | 
| 207 | 
> | 
                costheta = vec.z() / r;  | 
| 208 | 
> | 
                phi = atan2(vec.y(), vec.x()); | 
| 209 | 
> | 
 | 
| 210 | 
> | 
                for (int l = 0; l <= lMax_; l++) { | 
| 211 | 
> | 
                  sphericalHarmonic.setL(l); | 
| 212 | 
> | 
                  for(int m = -l; m <= l; m++){ | 
| 213 | 
> | 
                    sphericalHarmonic.setM(m); | 
| 214 | 
> | 
                    q[std::make_pair(l,m)] += sphericalHarmonic.getValueAt(costheta, phi); | 
| 215 | 
> | 
                  } | 
| 216 | 
> | 
                } | 
| 217 | 
> | 
                nBonds++; | 
| 218 | 
> | 
              }   | 
| 219 | 
> | 
            } | 
| 220 | 
  | 
          } | 
| 221 | 
  | 
        } | 
| 222 | 
  | 
         | 
| 223 | 
< | 
        // Normalize Qbar | 
| 224 | 
< | 
        for (int m = -lNumber_;m <= lNumber_; m++){ | 
| 225 | 
< | 
          QBar_lm[m] /= nBonds;  | 
| 223 | 
> | 
         | 
| 224 | 
> | 
        for (int l = 0; l <= lMax_; l++) {          | 
| 225 | 
> | 
          q_l[l] = 0.0; | 
| 226 | 
> | 
          for(int m = -l; m <= l; m++) {  | 
| 227 | 
> | 
            q_l[l] += norm(q[std::make_pair(l,m)]); | 
| 228 | 
> | 
          }      | 
| 229 | 
> | 
          q_l[l] *= 4.0*NumericConstant::PI/(RealType)(2*l + 1); | 
| 230 | 
> | 
          q_l[l] = sqrt(q_l[l])/(RealType)nBonds; | 
| 231 | 
  | 
        } | 
| 232 | 
  | 
 | 
| 233 | 
  | 
        // Find second order invariant Q_l | 
| 234 | 
< | 
 | 
| 235 | 
< | 
        QSq_l = 0.0; | 
| 236 | 
< | 
        for (int m = -lNumber_; m <= lNumber_; m++){ | 
| 237 | 
< | 
          QSq_l += pow(QBar_lm[m], 2);   | 
| 234 | 
> | 
         | 
| 235 | 
> | 
        for (int l = 0; l <= lMax_; l++) { | 
| 236 | 
> | 
          q2[l] = 0.0; | 
| 237 | 
> | 
          for (int m = -l; m <= l; m++){ | 
| 238 | 
> | 
            q2[l] += norm(q[std::make_pair(l,m)]); | 
| 239 | 
> | 
          } | 
| 240 | 
> | 
          q_l[l] = sqrt(q2[l] * 4.0 * NumericConstant::PI /  | 
| 241 | 
> | 
                        (RealType)(2*l + 1))/(RealType)nBonds; | 
| 242 | 
  | 
        } | 
| 192 | 
– | 
        Q_l = sqrt(QSq_l*(4.0 * NumericConstant::PI / (2.0*(RealType)lNumber_ + 1))); | 
| 193 | 
– | 
      | 
| 194 | 
– | 
        // Find Third Order Invariant W_l | 
| 243 | 
  | 
 | 
| 244 | 
< | 
        // Make arrays for Wigner3jm | 
| 245 | 
< | 
        double* THRCOF = new double[mSize_]; | 
| 246 | 
< | 
        // Variables for Wigner routine | 
| 247 | 
< | 
        double l_ = (double)lNumber_; | 
| 248 | 
< | 
        double m2Min, m2Max; | 
| 249 | 
< | 
        int error, m1, m2, m3; | 
| 250 | 
< | 
 | 
| 251 | 
< | 
        RealType W_l; | 
| 252 | 
< | 
        RealType W_l_hat; | 
| 253 | 
< | 
        W_l = 0.0; | 
| 254 | 
< | 
        for (int m1 = -lNumber_; m1 <= lNumber_; m1++) { | 
| 255 | 
< | 
          // Zero work array | 
| 256 | 
< | 
          for (int ii = 0; ii < mSize_; ii++){ | 
| 257 | 
< | 
            THRCOF[i] = 0.0; | 
| 244 | 
> | 
        // Find Third Order Invariant W_l | 
| 245 | 
> | 
     | 
| 246 | 
> | 
        for (int l = 0; l <= lMax_; l++) { | 
| 247 | 
> | 
          w[l] = 0.0; | 
| 248 | 
> | 
          lPass = (double)l; | 
| 249 | 
> | 
          for (int m1 = -l; m1 <= l; m1++) { | 
| 250 | 
> | 
            // Zero work array | 
| 251 | 
> | 
            for (int ii = 0; ii < 2*l + 1; ii++){ | 
| 252 | 
> | 
              THRCOF[ii] = 0.0; | 
| 253 | 
> | 
            } | 
| 254 | 
> | 
            // Get Wigner coefficients | 
| 255 | 
> | 
            m1Pass = (double)m1; | 
| 256 | 
> | 
             | 
| 257 | 
> | 
            Wigner3jm(&lPass, &lPass, &lPass,  | 
| 258 | 
> | 
                      &m1Pass, &m2Min, &m2Max,  | 
| 259 | 
> | 
                      THRCOF, &mSize, &error); | 
| 260 | 
> | 
             | 
| 261 | 
> | 
            for (int mmm = 0; mmm < (int)(m2Max - m2Min); mmm++) { | 
| 262 | 
> | 
              m2 = (int)floor(m2Min) + mmm; | 
| 263 | 
> | 
              m3 = -m1-m2; | 
| 264 | 
> | 
              w[l] += THRCOF[mmm] *  | 
| 265 | 
> | 
                q[std::make_pair(l,m1)] *  | 
| 266 | 
> | 
                q[std::make_pair(l,m2)] *  | 
| 267 | 
> | 
                q[std::make_pair(l,m3)]; | 
| 268 | 
> | 
            } | 
| 269 | 
  | 
          } | 
| 270 | 
< | 
          // Get Wigner coefficients | 
| 271 | 
< | 
          Wigner3jm(&l_, &l_, &l_, &(double)m1, &m2Min, &m2Max, THRCOF, &mSize_, &error); | 
| 272 | 
< | 
          for (int m_index = 1; i < (int)(m2Max - m2Min-1.0); m_index++) { | 
| 273 | 
< | 
            m2 = floor(m2Min) + m_index - 1; | 
| 274 | 
< | 
            m3 = -m1-m2; | 
| 275 | 
< | 
            W_l += THRCOF[m_index]*QBar_lm[m1+lNumber_]*QBar_lm[m2+lNumber_]*QBar_lm[m3+lNumber_]; | 
| 270 | 
> | 
           | 
| 271 | 
> | 
          w_hat[l] = w[l] / pow(q2[l], 1.5); | 
| 272 | 
> | 
        } | 
| 273 | 
> | 
 | 
| 274 | 
> | 
        collectHistogram(q_l, w_hat); | 
| 275 | 
> | 
         | 
| 276 | 
> | 
        Nbonds += nBonds; | 
| 277 | 
> | 
        for (int l = 0; l <= lMax_;  l++) { | 
| 278 | 
> | 
          for (int m = -l; m <= l; m++) { | 
| 279 | 
> | 
            QBar[std::make_pair(l,m)] += q[std::make_pair(l,m)]; | 
| 280 | 
  | 
          } | 
| 281 | 
  | 
        } | 
| 219 | 
– | 
 | 
| 220 | 
– | 
        W_l_hat = W_l / pow(QSq_l, 1.5); | 
| 221 | 
– | 
 | 
| 222 | 
– | 
        // accumulate histogram data for Q_l and W_l_hat: | 
| 223 | 
– | 
 | 
| 224 | 
– | 
        collectHistogram(Q_l, W_l_hat); | 
| 225 | 
– | 
                 | 
| 282 | 
  | 
      } | 
| 283 | 
  | 
    } | 
| 284 | 
+ | 
       | 
| 285 | 
+ | 
    // Normalize Qbar2 | 
| 286 | 
+ | 
    for (int l = 0; l <= lMax_; l++) { | 
| 287 | 
+ | 
      for (int m = -l; m <= l; m++){ | 
| 288 | 
+ | 
        QBar[std::make_pair(l,m)] /= Nbonds; | 
| 289 | 
+ | 
      } | 
| 290 | 
+ | 
    } | 
| 291 | 
  | 
     | 
| 292 | 
< | 
    // Normalize by number of frames | 
| 293 | 
< | 
    for (int m = -lNumber_; m <= lNumber_; m++){ | 
| 294 | 
< | 
      QBar_lm[m] /=  nFrames;    | 
| 292 | 
> | 
    // Find second order invariant Q_l | 
| 293 | 
> | 
     | 
| 294 | 
> | 
    for (int l = 0; l <= lMax_; l++) { | 
| 295 | 
> | 
      Q2[l] = 0.0; | 
| 296 | 
> | 
      for (int m = -l; m <= l; m++){ | 
| 297 | 
> | 
        Q2[l] += norm(QBar[std::make_pair(l,m)]); | 
| 298 | 
> | 
      } | 
| 299 | 
> | 
      Q[l] = sqrt(Q2[l] * 4.0 * NumericConstant::PI / (RealType)(2*l + 1)); | 
| 300 | 
  | 
    } | 
| 301 | 
  | 
     | 
| 302 | 
< | 
      | 
| 235 | 
< | 
      | 
| 236 | 
< | 
      | 
| 237 | 
< | 
      | 
| 238 | 
< | 
    writeOrderParameter(); | 
| 302 | 
> | 
    // Find Third Order Invariant W_l | 
| 303 | 
  | 
     | 
| 304 | 
+ | 
    for (int l = 0; l <= lMax_; l++) { | 
| 305 | 
+ | 
      W[l] = 0.0; | 
| 306 | 
+ | 
      lPass = (double)l; | 
| 307 | 
+ | 
      for (int m1 = -l; m1 <= l; m1++) { | 
| 308 | 
+ | 
        // Zero work array | 
| 309 | 
+ | 
        for (int ii = 0; ii < 2*l + 1; ii++){ | 
| 310 | 
+ | 
          THRCOF[ii] = 0.0; | 
| 311 | 
+ | 
        } | 
| 312 | 
+ | 
        // Get Wigner coefficients | 
| 313 | 
+ | 
        m1Pass = (double)m1; | 
| 314 | 
+ | 
         | 
| 315 | 
+ | 
        Wigner3jm(&lPass, &lPass, &lPass,  | 
| 316 | 
+ | 
                  &m1Pass, &m2Min, &m2Max,  | 
| 317 | 
+ | 
                  THRCOF, &mSize, &error); | 
| 318 | 
+ | 
         | 
| 319 | 
+ | 
        for (int mmm = 0; mmm < (int)(m2Max - m2Min); mmm++) { | 
| 320 | 
+ | 
          m2 = (int)floor(m2Min) + mmm; | 
| 321 | 
+ | 
          m3 = -m1-m2; | 
| 322 | 
+ | 
          W[l] += THRCOF[mmm] *  | 
| 323 | 
+ | 
            QBar[std::make_pair(l,m1)] *  | 
| 324 | 
+ | 
            QBar[std::make_pair(l,m2)] *  | 
| 325 | 
+ | 
            QBar[std::make_pair(l,m3)]; | 
| 326 | 
+ | 
        } | 
| 327 | 
+ | 
      } | 
| 328 | 
+ | 
       | 
| 329 | 
+ | 
      W_hat[l] = W[l] / pow(Q2[l], 1.5); | 
| 330 | 
+ | 
    } | 
| 331 | 
+ | 
     | 
| 332 | 
+ | 
    writeOrderParameter(Q, W_hat);     | 
| 333 | 
  | 
  } | 
| 334 | 
  | 
 | 
| 335 | 
< | 
   | 
| 336 | 
< | 
  void BondOrderParameter::processHistogram() { | 
| 244 | 
< | 
     | 
| 245 | 
< | 
    int nPairs = getNPairs(); | 
| 246 | 
< | 
    RealType volume = info_->getSnapshotManager()->getCurrentSnapshot()->getVolume(); | 
| 247 | 
< | 
    RealType pairDensity = nPairs /volume * 2.0; | 
| 248 | 
< | 
    RealType pairConstant = ( 4.0 * NumericConstant::PI * pairDensity ) / 3.0; | 
| 335 | 
> | 
  void BondOrderParameter::collectHistogram(std::vector<RealType> q,  | 
| 336 | 
> | 
                                            std::vector<ComplexType> what) { | 
| 337 | 
  | 
 | 
| 338 | 
< | 
    for(int i = 0 ; i < histogram_.size(); ++i){ | 
| 338 | 
> | 
    for (int l = 0; l <= lMax_; l++) { | 
| 339 | 
> | 
      if (q[l] >= MinQ_ && q[l] < MaxQ_) { | 
| 340 | 
> | 
        int qbin = (q[l] - MinQ_) / deltaQ_; | 
| 341 | 
> | 
        Q_histogram_[std::make_pair(qbin,l)] += 1; | 
| 342 | 
> | 
        Qcount_[l]++;       | 
| 343 | 
> | 
      } else { | 
| 344 | 
> | 
        sprintf( painCave.errMsg, | 
| 345 | 
> | 
                 "q_l value outside reasonable range\n"); | 
| 346 | 
> | 
        painCave.severity = OOPSE_ERROR; | 
| 347 | 
> | 
        painCave.isFatal = 1; | 
| 348 | 
> | 
        simError();   | 
| 349 | 
> | 
      } | 
| 350 | 
> | 
    } | 
| 351 | 
  | 
 | 
| 352 | 
< | 
      RealType rLower = i * deltaR_; | 
| 353 | 
< | 
      RealType rUpper = rLower + deltaR_; | 
| 354 | 
< | 
      RealType volSlice = ( rUpper * rUpper * rUpper ) - ( rLower * rLower * rLower ); | 
| 355 | 
< | 
      RealType nIdeal = volSlice * pairConstant; | 
| 356 | 
< | 
 | 
| 357 | 
< | 
      avgGofr_[i] += histogram_[i] / nIdeal;     | 
| 352 | 
> | 
    for (int l = 0; l <= lMax_; l++) { | 
| 353 | 
> | 
      if (real(what[l]) >= MinW_ && real(what[l]) < MaxW_) { | 
| 354 | 
> | 
        int wbin = (real(what[l]) - MinW_) / deltaW_; | 
| 355 | 
> | 
        W_histogram_[std::make_pair(wbin,l)] += 1; | 
| 356 | 
> | 
        Wcount_[l]++;       | 
| 357 | 
> | 
      } else { | 
| 358 | 
> | 
        sprintf( painCave.errMsg, | 
| 359 | 
> | 
                 "Re[w_hat] value outside reasonable range\n"); | 
| 360 | 
> | 
        painCave.severity = OOPSE_ERROR; | 
| 361 | 
> | 
        painCave.isFatal = 1; | 
| 362 | 
> | 
        simError();   | 
| 363 | 
> | 
      } | 
| 364 | 
  | 
    } | 
| 365 | 
  | 
 | 
| 366 | 
< | 
  } | 
| 366 | 
> | 
  }   | 
| 367 | 
  | 
 | 
| 262 | 
– | 
  void BondOrderParameter::collectHistogram(RealType Q_l, RealType W_l_hat) { | 
| 368 | 
  | 
 | 
| 369 | 
< | 
    if (Q_l < MaxQ_) { | 
| 370 | 
< | 
      int whichBin = Q_l / deltaQ_; | 
| 371 | 
< | 
      Q_histogram_[whichBin] += 1; | 
| 372 | 
< | 
    } | 
| 268 | 
< | 
    if (W_l_hat < MaxW_) { | 
| 269 | 
< | 
      int whichBin = W_l_hat / deltaW_; | 
| 270 | 
< | 
      W_histogram_[whichBin] += 1; | 
| 271 | 
< | 
    } | 
| 272 | 
< | 
  } | 
| 273 | 
< | 
   | 
| 369 | 
> | 
  void BondOrderParameter::writeOrderParameter(std::vector<RealType> Q,  | 
| 370 | 
> | 
                                               std::vector<ComplexType> What) { | 
| 371 | 
> | 
     | 
| 372 | 
> | 
    std::ofstream osq((getOutputFileName() + "q").c_str()); | 
| 373 | 
  | 
 | 
| 374 | 
< | 
  void BondOrderParameter::writeOrderParameter() { | 
| 374 | 
> | 
    if (osq.is_open()) { | 
| 375 | 
> | 
       | 
| 376 | 
> | 
      osq << "# Bond Order Parameters\n"; | 
| 377 | 
> | 
      osq << "# selection: (" << selectionScript_ << ")\n"; | 
| 378 | 
> | 
      osq << "# \n"; | 
| 379 | 
> | 
      for (int l = 0; l <= lMax_; l++) { | 
| 380 | 
> | 
        osq << "# <Q_" << l << ">: " << Q[l] << "\n"; | 
| 381 | 
> | 
      } | 
| 382 | 
> | 
      // Normalize by number of frames and write it out: | 
| 383 | 
> | 
      for (int i = 0; i < nBins_; ++i) { | 
| 384 | 
> | 
        RealType Qval = MinQ_ + (i + 0.5) * deltaQ_;                | 
| 385 | 
> | 
        osq << Qval; | 
| 386 | 
> | 
        for (int l = 0; l <= lMax_; l++) { | 
| 387 | 
> | 
          osq << "\t" << (RealType)Q_histogram_[std::make_pair(i,l)] / (RealType)Qcount_[l]; | 
| 388 | 
> | 
        } | 
| 389 | 
> | 
        osq << "\n"; | 
| 390 | 
> | 
      } | 
| 391 | 
  | 
 | 
| 392 | 
< | 
    std::ofstream os(getOutputFileName().c_str()); | 
| 278 | 
< | 
    os << "#Bond Order Parameter\n"; | 
| 279 | 
< | 
    os << "#selection: (" << selectionScript_ << ")\n"; | 
| 392 | 
> | 
      osq.close(); | 
| 393 | 
  | 
 | 
| 394 | 
< | 
    for (std::size_t i = 0; i < orderParams_.size(); ++i) { | 
| 395 | 
< | 
      os <<  orderParams_[i].p2 << "\t" | 
| 396 | 
< | 
         <<  orderParams_[i].director[0] << "\t" | 
| 397 | 
< | 
         <<  orderParams_[i].director[1] << "\t" | 
| 398 | 
< | 
         <<  orderParams_[i].director[2] << "\t" | 
| 286 | 
< | 
         <<  orderParams_[i].angle << "\n"; | 
| 287 | 
< | 
 | 
| 394 | 
> | 
    } else { | 
| 395 | 
> | 
      sprintf(painCave.errMsg, "BondOrderParameter: unable to open %s\n",  | 
| 396 | 
> | 
              (getOutputFileName() + "q").c_str()); | 
| 397 | 
> | 
      painCave.isFatal = 1; | 
| 398 | 
> | 
      simError();   | 
| 399 | 
  | 
    } | 
| 289 | 
– | 
  } | 
| 400 | 
  | 
 | 
| 401 | 
+ | 
    std::ofstream osw((getOutputFileName() + "w").c_str()); | 
| 402 | 
  | 
 | 
| 403 | 
+ | 
    if (osw.is_open()) { | 
| 404 | 
+ | 
      osw << "# Bond Order Parameters\n"; | 
| 405 | 
+ | 
      osw << "# selection: (" << selectionScript_ << ")\n"; | 
| 406 | 
+ | 
      osw << "# \n"; | 
| 407 | 
+ | 
      for (int l = 0; l <= lMax_; l++) { | 
| 408 | 
+ | 
        osw << "# <W_" << l << ">: " << real(What[l]) << "\n"; | 
| 409 | 
+ | 
      } | 
| 410 | 
+ | 
      // Normalize by number of frames and write it out: | 
| 411 | 
+ | 
      for (int i = 0; i < nBins_; ++i) { | 
| 412 | 
+ | 
        RealType Wval = MinW_ + (i + 0.5) * deltaW_;                | 
| 413 | 
+ | 
        osw << Wval; | 
| 414 | 
+ | 
        for (int l = 0; l <= lMax_; l++) { | 
| 415 | 
+ | 
          osw << "\t" << (RealType)W_histogram_[std::make_pair(i,l)] / (RealType)Wcount_[l]; | 
| 416 | 
+ | 
        } | 
| 417 | 
+ | 
        osw << "\n"; | 
| 418 | 
+ | 
      } | 
| 419 | 
  | 
 | 
| 420 | 
+ | 
      osw.close(); | 
| 421 | 
+ | 
    } else { | 
| 422 | 
+ | 
      sprintf(painCave.errMsg, "BondOrderParameter: unable to open %s\n",  | 
| 423 | 
+ | 
              (getOutputFileName() + "w").c_str()); | 
| 424 | 
+ | 
      painCave.isFatal = 1; | 
| 425 | 
+ | 
      simError();   | 
| 426 | 
+ | 
    } | 
| 427 | 
+ | 
        | 
| 428 | 
+ | 
  } | 
| 429 | 
  | 
} |