| 6 |
|
* redistribute this software in source and binary code form, provided |
| 7 |
|
* that the following conditions are met: |
| 8 |
|
* |
| 9 |
< |
* 1. Acknowledgement of the program authors must be made in any |
| 10 |
< |
* publication of scientific results based in part on use of the |
| 11 |
< |
* program. An acceptable form of acknowledgement is citation of |
| 12 |
< |
* the article in which the program was described (Matthew |
| 13 |
< |
* A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher |
| 14 |
< |
* J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented |
| 15 |
< |
* Parallel Simulation Engine for Molecular Dynamics," |
| 16 |
< |
* J. Comput. Chem. 26, pp. 252-271 (2005)) |
| 17 |
< |
* |
| 18 |
< |
* 2. Redistributions of source code must retain the above copyright |
| 9 |
> |
* 1. Redistributions of source code must retain the above copyright |
| 10 |
|
* notice, this list of conditions and the following disclaimer. |
| 11 |
|
* |
| 12 |
< |
* 3. Redistributions in binary form must reproduce the above copyright |
| 12 |
> |
* 2. Redistributions in binary form must reproduce the above copyright |
| 13 |
|
* notice, this list of conditions and the following disclaimer in the |
| 14 |
|
* documentation and/or other materials provided with the |
| 15 |
|
* distribution. |
| 29 |
|
* University of Notre Dame has been advised of the possibility of |
| 30 |
|
* such damages. |
| 31 |
|
* |
| 32 |
< |
* BondOrderParameter.cpp |
| 33 |
< |
* OOPSE-4 |
| 34 |
< |
* |
| 32 |
> |
* SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your |
| 33 |
> |
* research, please cite the appropriate papers when you publish your |
| 34 |
> |
* work. Good starting points are: |
| 35 |
> |
* |
| 36 |
> |
* [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |
| 37 |
> |
* [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). |
| 38 |
> |
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). |
| 39 |
> |
* [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). |
| 40 |
> |
* [4] , Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). * |
| 41 |
|
* Created by J. Daniel Gezelter on 09/26/06. |
| 42 |
|
* @author J. Daniel Gezelter |
| 43 |
< |
* @version $Id: BOPofR.cpp,v 1.3 2007-12-06 19:52:11 chuckv Exp $ |
| 43 |
> |
* @version $Id$ |
| 44 |
|
* |
| 45 |
|
*/ |
| 46 |
|
|
| 49 |
|
#include "io/DumpReader.hpp" |
| 50 |
|
#include "primitives/Molecule.hpp" |
| 51 |
|
#include "utils/NumericConstant.hpp" |
| 52 |
+ |
#include "math/Wigner3jm.hpp" |
| 53 |
+ |
#include "brains/Thermo.hpp" |
| 54 |
|
|
| 55 |
+ |
using namespace MATPACK; |
| 56 |
+ |
namespace OpenMD { |
| 57 |
|
|
| 58 |
< |
namespace oopse { |
| 59 |
< |
|
| 60 |
< |
BOPofR::BOPofR(SimInfo* info, const std::string& filename, const std::string& sele, double rCut, |
| 61 |
< |
int nbins, RealType len) : StaticAnalyser(info, filename), selectionScript_(sele), evaluator_(info), seleMan_(info){ |
| 58 |
> |
BOPofR::BOPofR(SimInfo* info, const std::string& filename, |
| 59 |
> |
const std::string& sele, double rCut, int nbins, |
| 60 |
> |
RealType len) : StaticAnalyser(info, filename), |
| 61 |
> |
selectionScript_(sele), |
| 62 |
> |
evaluator_(info), seleMan_(info) { |
| 63 |
|
|
| 64 |
|
setOutputName(getPrefix(filename) + ".bo"); |
| 65 |
< |
|
| 65 |
> |
|
| 66 |
|
evaluator_.loadScriptString(sele); |
| 67 |
|
if (!evaluator_.isDynamic()) { |
| 68 |
|
seleMan_.setSelectionSet(evaluator_.evaluate()); |
| 69 |
|
} |
| 70 |
< |
|
| 70 |
> |
|
| 71 |
|
// Set up cutoff radius and order of the Legendre Polynomial: |
| 72 |
< |
|
| 72 |
> |
|
| 73 |
|
rCut_ = rCut; |
| 74 |
|
nBins_ = nbins; |
| 75 |
|
len_ = len; |
| 76 |
< |
|
| 76 |
> |
|
| 77 |
|
deltaR_ = len_/nBins_; |
| 78 |
|
RCount_.resize(nBins_); |
| 79 |
|
WofR_.resize(nBins_); |
| 80 |
|
QofR_.resize(nBins_); |
| 81 |
|
|
| 82 |
< |
for (int i = 0; i < nBins_; i++){ |
| 83 |
< |
RCount_[i] = 0; |
| 84 |
< |
WofR_[i] = 0; |
| 85 |
< |
QofR_[i] = 0; |
| 86 |
< |
} |
| 87 |
< |
|
| 82 |
> |
for (int i = 0; i < nBins_; i++){ |
| 83 |
> |
RCount_[i] = 0; |
| 84 |
> |
WofR_[i] = 0; |
| 85 |
> |
QofR_[i] = 0; |
| 86 |
> |
} |
| 87 |
> |
|
| 88 |
|
// Make arrays for Wigner3jm |
| 89 |
< |
double* THRCOF = new double[2*lMax_+1]; |
| 89 |
> |
RealType* THRCOF = new RealType[2*lMax_+1]; |
| 90 |
|
// Variables for Wigner routine |
| 91 |
< |
double lPass, m1Pass, m2m, m2M; |
| 91 |
> |
RealType lPass, m1Pass, m2m, m2M; |
| 92 |
|
int error, mSize; |
| 93 |
|
mSize = 2*lMax_+1; |
| 94 |
|
|
| 95 |
|
for (int l = 0; l <= lMax_; l++) { |
| 96 |
< |
lPass = (double)l; |
| 96 |
> |
lPass = (RealType)l; |
| 97 |
|
for (int m1 = -l; m1 <= l; m1++) { |
| 98 |
< |
m1Pass = (double)m1; |
| 98 |
> |
m1Pass = (RealType)m1; |
| 99 |
|
|
| 100 |
|
std::pair<int,int> lm = std::make_pair(l, m1); |
| 101 |
|
|
| 105 |
|
} |
| 106 |
|
|
| 107 |
|
// Get Wigner coefficients |
| 108 |
< |
Wigner3jm(&lPass, &lPass, &lPass, |
| 109 |
< |
&m1Pass, &m2m, &m2M, |
| 110 |
< |
THRCOF, &mSize, &error); |
| 108 |
> |
Wigner3jm(lPass, lPass, lPass, |
| 109 |
> |
m1Pass, m2m, m2M, |
| 110 |
> |
THRCOF, mSize, error); |
| 111 |
|
|
| 112 |
|
m2Min[lm] = (int)floor(m2m); |
| 113 |
|
m2Max[lm] = (int)floor(m2M); |
| 124 |
|
} |
| 125 |
|
|
| 126 |
|
BOPofR::~BOPofR() { |
| 127 |
< |
/* |
| 128 |
< |
std::cerr << "Freeing stuff" << std::endl; |
| 127 |
> |
/* |
| 128 |
> |
std::cerr << "Freeing stuff" << std::endl; |
| 129 |
|
for (int l = 0; l <= lMax_; l++) { |
| 130 |
|
for (int m = -l; m <= l; m++) { |
| 131 |
|
w3j[std::make_pair(l,m)].clear(); |
| 148 |
|
} |
| 149 |
|
|
| 150 |
|
|
| 151 |
< |
void BOPofR::initalizeHistogram() { |
| 152 |
< |
for (int i = 0; i < nBins_; i++){ |
| 153 |
< |
RCount_[i] = 0; |
| 154 |
< |
WofR_[i] = 0; |
| 155 |
< |
QofR_[i] = 0; |
| 156 |
< |
} |
| 151 |
> |
void BOPofR::initializeHistogram() { |
| 152 |
> |
for (int i = 0; i < nBins_; i++){ |
| 153 |
> |
RCount_[i] = 0; |
| 154 |
> |
WofR_[i] = 0; |
| 155 |
> |
QofR_[i] = 0; |
| 156 |
> |
} |
| 157 |
|
} |
| 158 |
< |
|
| 159 |
< |
|
| 158 |
> |
|
| 159 |
> |
|
| 160 |
|
void BOPofR::process() { |
| 161 |
|
Molecule* mol; |
| 162 |
|
Atom* atom; |
| 170 |
|
RealType costheta; |
| 171 |
|
RealType phi; |
| 172 |
|
RealType r; |
| 171 |
– |
RealType dist; |
| 173 |
|
Vector3d rCOM; |
| 174 |
|
RealType distCOM; |
| 175 |
|
Vector3d pos; |
| 179 |
|
std::vector<RealType> q2; |
| 180 |
|
std::vector<ComplexType> w; |
| 181 |
|
std::vector<ComplexType> w_hat; |
| 181 |
– |
std::map<std::pair<int,int>,ComplexType> QBar; |
| 182 |
|
std::vector<RealType> Q2; |
| 183 |
|
std::vector<RealType> Q; |
| 184 |
|
std::vector<ComplexType> W; |
| 185 |
|
std::vector<ComplexType> W_hat; |
| 186 |
< |
int nBonds, Nbonds; |
| 186 |
> |
int nBonds; |
| 187 |
|
SphericalHarmonic sphericalHarmonic; |
| 188 |
< |
int i, j; |
| 189 |
< |
|
| 188 |
> |
int i; |
| 189 |
> |
|
| 190 |
|
DumpReader reader(info_, dumpFilename_); |
| 191 |
|
int nFrames = reader.getNFrames(); |
| 192 |
|
frameCounter_ = 0; |
| 193 |
|
|
| 194 |
+ |
Thermo thermo(info_); |
| 195 |
+ |
|
| 196 |
|
q_l.resize(lMax_+1); |
| 197 |
|
q2.resize(lMax_+1); |
| 198 |
|
w.resize(lMax_+1); |
| 202 |
|
Q.resize(lMax_+1); |
| 203 |
|
W.resize(lMax_+1); |
| 204 |
|
W_hat.resize(lMax_+1); |
| 203 |
– |
Nbonds = 0; |
| 205 |
|
|
| 206 |
|
for (int istep = 0; istep < nFrames; istep += step_) { |
| 207 |
|
reader.readFrame(istep); |
| 208 |
|
frameCounter_++; |
| 209 |
|
currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot(); |
| 210 |
< |
CenterOfMass = info_->getCom(); |
| 210 |
> |
CenterOfMass = thermo.getCom(); |
| 211 |
|
if (evaluator_.isDynamic()) { |
| 212 |
|
seleMan_.setSelectionSet(evaluator_.evaluate()); |
| 213 |
|
} |
| 305 |
|
} |
| 306 |
|
} |
| 307 |
|
|
| 308 |
< |
w_hat[l] = w[l] / pow(q2[l], 1.5); |
| 308 |
> |
w_hat[l] = w[l] / pow(q2[l], RealType(1.5)); |
| 309 |
|
} |
| 310 |
|
|
| 311 |
|
collectHistogram(q_l, w_hat, distCOM); |
| 312 |
|
|
| 313 |
< |
// printf( "%s %18.10g %18.10g %18.10g %18.10g \n", sd->getType().c_str(),pos[0],pos[1],pos[2],real(w_hat[6])); |
| 314 |
< |
|
| 313 |
> |
// printf( "%s %18.10g %18.10g %18.10g %18.10g \n", sd->getType().c_str(),pos[0],pos[1],pos[2],real(w_hat[6])); |
| 314 |
> |
|
| 315 |
|
} |
| 316 |
|
} |
| 317 |
< |
|
| 317 |
> |
|
| 318 |
|
writeOrderParameter(); |
| 319 |
|
} |
| 320 |
+ |
|
| 321 |
|
|
| 322 |
< |
void BOPofR::collectHistogram(std::vector<RealType> q, |
| 323 |
< |
std::vector<ComplexType> what, RealType distCOM) { |
| 324 |
< |
|
| 322 |
> |
|
| 323 |
> |
IcosahedralOfR::IcosahedralOfR(SimInfo* info, const std::string& filename, |
| 324 |
> |
const std::string& sele, double rCut, |
| 325 |
> |
int nbins, RealType len) : BOPofR(info, |
| 326 |
> |
filename, |
| 327 |
> |
sele, rCut, |
| 328 |
> |
nbins, len) { |
| 329 |
> |
} |
| 330 |
> |
|
| 331 |
> |
void IcosahedralOfR::collectHistogram(std::vector<RealType> q, |
| 332 |
> |
std::vector<ComplexType> what, |
| 333 |
> |
RealType distCOM) { |
| 334 |
> |
|
| 335 |
|
if ( distCOM < len_){ |
| 336 |
|
// Figure out where this distance goes... |
| 337 |
< |
int whichBin = distCOM / deltaR_; |
| 337 |
> |
int whichBin = int(distCOM / deltaR_); |
| 338 |
|
RCount_[whichBin]++; |
| 339 |
|
|
| 340 |
|
if(real(what[6]) < -0.15){ |
| 341 |
< |
WofR_[whichBin]++; |
| 341 |
> |
WofR_[whichBin]++; |
| 342 |
|
} |
| 343 |
< |
if(q[6] > 0.5){ |
| 343 |
> |
if(q[6] > 0.5){ |
| 344 |
|
QofR_[whichBin]++; |
| 345 |
< |
} |
| 346 |
< |
} |
| 335 |
< |
|
| 345 |
> |
} |
| 346 |
> |
} |
| 347 |
|
} |
| 348 |
|
|
| 349 |
< |
void BOPofR::writeOrderParameter() { |
| 349 |
> |
FCCOfR::FCCOfR(SimInfo* info, const std::string& filename, |
| 350 |
> |
const std::string& sele, double rCut, |
| 351 |
> |
int nbins, RealType len) : BOPofR(info, filename, sele, rCut, |
| 352 |
> |
nbins, len) {} |
| 353 |
> |
|
| 354 |
> |
|
| 355 |
> |
void FCCOfR::collectHistogram(std::vector<RealType> q, |
| 356 |
> |
std::vector<ComplexType> what, |
| 357 |
> |
RealType distCOM) { |
| 358 |
|
|
| 359 |
+ |
if ( distCOM < len_){ |
| 360 |
+ |
// Figure out where this distance goes... |
| 361 |
+ |
int whichBin = int(distCOM / deltaR_); |
| 362 |
+ |
RCount_[whichBin]++; |
| 363 |
+ |
|
| 364 |
+ |
if(real(what[4]) < -0.12){ |
| 365 |
+ |
WofR_[whichBin]++; |
| 366 |
+ |
} |
| 367 |
+ |
} |
| 368 |
+ |
} |
| 369 |
+ |
|
| 370 |
+ |
void IcosahedralOfR::writeOrderParameter() { |
| 371 |
+ |
|
| 372 |
|
std::ofstream osq((getOutputFileName() + "qr").c_str()); |
| 373 |
|
|
| 374 |
|
if (osq.is_open()) { |
| 375 |
|
|
| 376 |
|
// Normalize by number of frames and write it out: |
| 377 |
< |
|
| 377 |
> |
|
| 378 |
|
for (int i = 0; i < nBins_; ++i) { |
| 379 |
|
RealType Rval = (i + 0.5) * deltaR_; |
| 380 |
|
osq << Rval; |
| 381 |
< |
if (RCount_[i] == 0){ |
| 382 |
< |
osq << "\t" << 0; |
| 383 |
< |
osq << "\n"; |
| 384 |
< |
}else{ |
| 385 |
< |
osq << "\t" << (RealType)QofR_[i]/(RealType)RCount_[i]; |
| 386 |
< |
osq << "\n"; |
| 387 |
< |
} |
| 381 |
> |
if (RCount_[i] == 0){ |
| 382 |
> |
osq << "\t" << 0; |
| 383 |
> |
osq << "\n"; |
| 384 |
> |
}else{ |
| 385 |
> |
osq << "\t" << (RealType)QofR_[i]/(RealType)RCount_[i]; |
| 386 |
> |
osq << "\n"; |
| 387 |
> |
} |
| 388 |
|
} |
| 389 |
< |
|
| 389 |
> |
|
| 390 |
|
osq.close(); |
| 391 |
< |
|
| 391 |
> |
|
| 392 |
|
} else { |
| 393 |
|
sprintf(painCave.errMsg, "BOPofR: unable to open %s\n", |
| 394 |
|
(getOutputFileName() + "q").c_str()); |
| 395 |
|
painCave.isFatal = 1; |
| 396 |
|
simError(); |
| 397 |
|
} |
| 398 |
< |
|
| 398 |
> |
|
| 399 |
|
std::ofstream osw((getOutputFileName() + "wr").c_str()); |
| 400 |
< |
|
| 400 |
> |
|
| 401 |
|
if (osw.is_open()) { |
| 402 |
|
// Normalize by number of frames and write it out: |
| 403 |
|
for (int i = 0; i < nBins_; ++i) { |
| 404 |
|
RealType Rval = deltaR_ * (i + 0.5); |
| 405 |
|
osw << Rval; |
| 406 |
< |
if (RCount_[i] == 0){ |
| 407 |
< |
osw << "\t" << 0; |
| 408 |
< |
osw << "\n"; |
| 409 |
< |
}else{ |
| 410 |
< |
osw << "\t" << (RealType)WofR_[i]/(RealType)RCount_[i]; |
| 411 |
< |
osw << "\n"; |
| 412 |
< |
} |
| 406 |
> |
if (RCount_[i] == 0){ |
| 407 |
> |
osw << "\t" << 0; |
| 408 |
> |
osw << "\n"; |
| 409 |
> |
}else{ |
| 410 |
> |
osw << "\t" << (RealType)WofR_[i]/(RealType)RCount_[i]; |
| 411 |
> |
osw << "\n"; |
| 412 |
> |
} |
| 413 |
|
} |
| 414 |
< |
|
| 414 |
> |
|
| 415 |
|
osw.close(); |
| 416 |
|
} else { |
| 417 |
|
sprintf(painCave.errMsg, "BOPofR: unable to open %s\n", |
| 422 |
|
} |
| 423 |
|
|
| 424 |
|
} |
| 425 |
+ |
void FCCOfR::writeOrderParameter() { |
| 426 |
+ |
|
| 427 |
+ |
std::ofstream osw((getOutputFileName() + "wr").c_str()); |
| 428 |
+ |
|
| 429 |
+ |
if (osw.is_open()) { |
| 430 |
+ |
// Normalize by number of frames and write it out: |
| 431 |
+ |
for (int i = 0; i < nBins_; ++i) { |
| 432 |
+ |
RealType Rval = deltaR_ * (i + 0.5); |
| 433 |
+ |
osw << Rval; |
| 434 |
+ |
if (RCount_[i] == 0){ |
| 435 |
+ |
osw << "\t" << 0; |
| 436 |
+ |
osw << "\n"; |
| 437 |
+ |
}else{ |
| 438 |
+ |
osw << "\t" << (RealType)WofR_[i]/(RealType)RCount_[i]; |
| 439 |
+ |
osw << "\n"; |
| 440 |
+ |
} |
| 441 |
+ |
} |
| 442 |
+ |
|
| 443 |
+ |
osw.close(); |
| 444 |
+ |
} else { |
| 445 |
+ |
sprintf(painCave.errMsg, "BOPofR: unable to open %s\n", |
| 446 |
+ |
(getOutputFileName() + "w").c_str()); |
| 447 |
+ |
painCave.isFatal = 1; |
| 448 |
+ |
simError(); |
| 449 |
+ |
|
| 450 |
+ |
} |
| 451 |
+ |
|
| 452 |
+ |
} |
| 453 |
|
} |