| 1 | chuckv | 1128 | /* | 
| 2 |  |  | * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. | 
| 3 |  |  | * | 
| 4 |  |  | * The University of Notre Dame grants you ("Licensee") a | 
| 5 |  |  | * non-exclusive, royalty free, license to use, modify and | 
| 6 |  |  | * redistribute this software in source and binary code form, provided | 
| 7 |  |  | * that the following conditions are met: | 
| 8 |  |  | * | 
| 9 | gezelter | 1390 | * 1. Redistributions of source code must retain the above copyright | 
| 10 | chuckv | 1128 | *    notice, this list of conditions and the following disclaimer. | 
| 11 |  |  | * | 
| 12 | gezelter | 1390 | * 2. Redistributions in binary form must reproduce the above copyright | 
| 13 | chuckv | 1128 | *    notice, this list of conditions and the following disclaimer in the | 
| 14 |  |  | *    documentation and/or other materials provided with the | 
| 15 |  |  | *    distribution. | 
| 16 |  |  | * | 
| 17 |  |  | * This software is provided "AS IS," without a warranty of any | 
| 18 |  |  | * kind. All express or implied conditions, representations and | 
| 19 |  |  | * warranties, including any implied warranty of merchantability, | 
| 20 |  |  | * fitness for a particular purpose or non-infringement, are hereby | 
| 21 |  |  | * excluded.  The University of Notre Dame and its licensors shall not | 
| 22 |  |  | * be liable for any damages suffered by licensee as a result of | 
| 23 |  |  | * using, modifying or distributing the software or its | 
| 24 |  |  | * derivatives. In no event will the University of Notre Dame or its | 
| 25 |  |  | * licensors be liable for any lost revenue, profit or data, or for | 
| 26 |  |  | * direct, indirect, special, consequential, incidental or punitive | 
| 27 |  |  | * damages, however caused and regardless of the theory of liability, | 
| 28 |  |  | * arising out of the use of or inability to use software, even if the | 
| 29 |  |  | * University of Notre Dame has been advised of the possibility of | 
| 30 |  |  | * such damages. | 
| 31 |  |  | * | 
| 32 | gezelter | 1390 | * 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 | gezelter | 1879 | * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). | 
| 39 | gezelter | 1782 | * [4] Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010). | 
| 40 |  |  | * [4] , Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). * | 
| 41 | chuckv | 1128 | *  Created by J. Daniel Gezelter on 09/26/06. | 
| 42 |  |  | *  @author  J. Daniel Gezelter | 
| 43 | gezelter | 1442 | *  @version $Id$ | 
| 44 | chuckv | 1128 | * | 
| 45 |  |  | */ | 
| 46 |  |  |  | 
| 47 |  |  | #include "applications/staticProps/BOPofR.hpp" | 
| 48 |  |  | #include "utils/simError.h" | 
| 49 |  |  | #include "io/DumpReader.hpp" | 
| 50 |  |  | #include "primitives/Molecule.hpp" | 
| 51 |  |  | #include "utils/NumericConstant.hpp" | 
| 52 | gezelter | 1782 | #include "math/Wigner3jm.hpp" | 
| 53 |  |  | #include "brains/Thermo.hpp" | 
| 54 | chuckv | 1128 |  | 
| 55 | gezelter | 1782 | using namespace MATPACK; | 
| 56 | gezelter | 1390 | namespace OpenMD { | 
| 57 | chuckv | 1128 |  | 
| 58 | gezelter | 1992 | 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 | chuckv | 1128 |  | 
| 64 |  |  | setOutputName(getPrefix(filename) + ".bo"); | 
| 65 | gezelter | 1992 |  | 
| 66 | chuckv | 1128 | evaluator_.loadScriptString(sele); | 
| 67 |  |  | if (!evaluator_.isDynamic()) { | 
| 68 |  |  | seleMan_.setSelectionSet(evaluator_.evaluate()); | 
| 69 |  |  | } | 
| 70 | gezelter | 1992 |  | 
| 71 | chuckv | 1128 | // Set up cutoff radius and order of the Legendre Polynomial: | 
| 72 | gezelter | 1992 |  | 
| 73 | chuckv | 1128 | rCut_ = rCut; | 
| 74 |  |  | nBins_ = nbins; | 
| 75 |  |  | len_ = len; | 
| 76 | gezelter | 1992 |  | 
| 77 | chuckv | 1128 | deltaR_ = len_/nBins_; | 
| 78 |  |  | RCount_.resize(nBins_); | 
| 79 |  |  | WofR_.resize(nBins_); | 
| 80 |  |  | QofR_.resize(nBins_); | 
| 81 | chuckv | 1137 |  | 
| 82 | gezelter | 1992 | for (int i = 0; i < nBins_; i++){ | 
| 83 |  |  | RCount_[i] = 0; | 
| 84 |  |  | WofR_[i] = 0; | 
| 85 |  |  | QofR_[i] = 0; | 
| 86 |  |  | } | 
| 87 |  |  |  | 
| 88 | chuckv | 1128 | // Make arrays for Wigner3jm | 
| 89 | gezelter | 1782 | RealType* THRCOF = new RealType[2*lMax_+1]; | 
| 90 | chuckv | 1128 | // Variables for Wigner routine | 
| 91 | gezelter | 1782 | RealType lPass, m1Pass, m2m, m2M; | 
| 92 | chuckv | 1128 | int error, mSize; | 
| 93 |  |  | mSize = 2*lMax_+1; | 
| 94 |  |  |  | 
| 95 |  |  | for (int l = 0; l <= lMax_; l++) { | 
| 96 | gezelter | 1782 | lPass = (RealType)l; | 
| 97 | chuckv | 1128 | for (int m1 = -l; m1 <= l; m1++) { | 
| 98 | gezelter | 1782 | m1Pass = (RealType)m1; | 
| 99 | chuckv | 1128 |  | 
| 100 |  |  | std::pair<int,int> lm = std::make_pair(l, m1); | 
| 101 |  |  |  | 
| 102 |  |  | // Zero work array | 
| 103 |  |  | for (int ii = 0; ii < 2*l + 1; ii++){ | 
| 104 |  |  | THRCOF[ii] = 0.0; | 
| 105 |  |  | } | 
| 106 |  |  |  | 
| 107 |  |  | // Get Wigner coefficients | 
| 108 | gezelter | 1782 | Wigner3jm(lPass, lPass, lPass, | 
| 109 |  |  | m1Pass, m2m, m2M, | 
| 110 |  |  | THRCOF, mSize, error); | 
| 111 | chuckv | 1128 |  | 
| 112 |  |  | m2Min[lm] = (int)floor(m2m); | 
| 113 |  |  | m2Max[lm] = (int)floor(m2M); | 
| 114 |  |  |  | 
| 115 |  |  | for (int mmm = 0; mmm <= (int)(m2M - m2m); mmm++) { | 
| 116 |  |  | w3j[lm].push_back(THRCOF[mmm]); | 
| 117 |  |  | } | 
| 118 |  |  | } | 
| 119 |  |  | } | 
| 120 |  |  |  | 
| 121 |  |  | delete [] THRCOF; | 
| 122 | chuckv | 1137 | THRCOF = NULL; | 
| 123 | chuckv | 1128 |  | 
| 124 |  |  | } | 
| 125 |  |  |  | 
| 126 |  |  | BOPofR::~BOPofR() { | 
| 127 | gezelter | 1992 | /* | 
| 128 |  |  | std::cerr << "Freeing stuff" << std::endl; | 
| 129 | chuckv | 1128 | 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 |  |  | std::cerr << "w3j made free...." << std::endl; | 
| 135 |  |  | for (int bin = 0; bin < nBins_; bin++) { | 
| 136 |  |  | QofR_[bin].clear(); | 
| 137 |  |  | WofR_[bin].clear(); | 
| 138 |  |  | RCount_[bin].clear(); | 
| 139 |  |  | } | 
| 140 |  |  | std::cout << "R arrays made free...." << std::endl; | 
| 141 |  |  | w3j.clear(); | 
| 142 |  |  | m2Min.clear(); | 
| 143 |  |  | m2Max.clear(); | 
| 144 |  |  | RCount_.clear(); | 
| 145 |  |  | WofR_.clear(); | 
| 146 |  |  | QofR_.clear(); | 
| 147 |  |  | */ | 
| 148 |  |  | } | 
| 149 |  |  |  | 
| 150 |  |  |  | 
| 151 | jmichalk | 1785 | void BOPofR::initializeHistogram() { | 
| 152 | gezelter | 1992 | for (int i = 0; i < nBins_; i++){ | 
| 153 |  |  | RCount_[i] = 0; | 
| 154 |  |  | WofR_[i] = 0; | 
| 155 |  |  | QofR_[i] = 0; | 
| 156 |  |  | } | 
| 157 | chuckv | 1128 | } | 
| 158 | gezelter | 1992 |  | 
| 159 |  |  |  | 
| 160 | chuckv | 1128 | void BOPofR::process() { | 
| 161 |  |  | Molecule* mol; | 
| 162 |  |  | Atom* atom; | 
| 163 |  |  | RigidBody* rb; | 
| 164 |  |  | int myIndex; | 
| 165 |  |  | SimInfo::MoleculeIterator mi; | 
| 166 |  |  | Molecule::RigidBodyIterator rbIter; | 
| 167 |  |  | Molecule::AtomIterator ai; | 
| 168 |  |  | StuntDouble* sd; | 
| 169 |  |  | Vector3d vec; | 
| 170 |  |  | RealType costheta; | 
| 171 |  |  | RealType phi; | 
| 172 |  |  | RealType r; | 
| 173 |  |  | Vector3d rCOM; | 
| 174 |  |  | RealType distCOM; | 
| 175 |  |  | Vector3d pos; | 
| 176 |  |  | Vector3d CenterOfMass; | 
| 177 |  |  | std::map<std::pair<int,int>,ComplexType> q; | 
| 178 |  |  | std::vector<RealType> q_l; | 
| 179 |  |  | std::vector<RealType> q2; | 
| 180 |  |  | std::vector<ComplexType> w; | 
| 181 |  |  | std::vector<ComplexType> w_hat; | 
| 182 |  |  | std::vector<RealType> Q2; | 
| 183 |  |  | std::vector<RealType> Q; | 
| 184 |  |  | std::vector<ComplexType> W; | 
| 185 |  |  | std::vector<ComplexType> W_hat; | 
| 186 | gezelter | 1793 | int nBonds; | 
| 187 | chuckv | 1128 | SphericalHarmonic sphericalHarmonic; | 
| 188 | gezelter | 1782 | int i; | 
| 189 |  |  |  | 
| 190 | chuckv | 1128 | DumpReader reader(info_, dumpFilename_); | 
| 191 |  |  | int nFrames = reader.getNFrames(); | 
| 192 |  |  | frameCounter_ = 0; | 
| 193 |  |  |  | 
| 194 | gezelter | 1782 | Thermo thermo(info_); | 
| 195 |  |  |  | 
| 196 | chuckv | 1128 | q_l.resize(lMax_+1); | 
| 197 |  |  | q2.resize(lMax_+1); | 
| 198 |  |  | w.resize(lMax_+1); | 
| 199 |  |  | w_hat.resize(lMax_+1); | 
| 200 |  |  |  | 
| 201 |  |  | Q2.resize(lMax_+1); | 
| 202 |  |  | Q.resize(lMax_+1); | 
| 203 |  |  | W.resize(lMax_+1); | 
| 204 |  |  | W_hat.resize(lMax_+1); | 
| 205 |  |  |  | 
| 206 |  |  | for (int istep = 0; istep < nFrames; istep += step_) { | 
| 207 |  |  | reader.readFrame(istep); | 
| 208 |  |  | frameCounter_++; | 
| 209 |  |  | currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot(); | 
| 210 | gezelter | 1782 | CenterOfMass = thermo.getCom(); | 
| 211 | chuckv | 1128 | if (evaluator_.isDynamic()) { | 
| 212 |  |  | seleMan_.setSelectionSet(evaluator_.evaluate()); | 
| 213 |  |  | } | 
| 214 |  |  |  | 
| 215 |  |  | // update the positions of atoms which belong to the rigidbodies | 
| 216 |  |  |  | 
| 217 |  |  | for (mol = info_->beginMolecule(mi); mol != NULL; | 
| 218 |  |  | mol = info_->nextMolecule(mi)) { | 
| 219 |  |  | for (rb = mol->beginRigidBody(rbIter); rb != NULL; | 
| 220 |  |  | rb = mol->nextRigidBody(rbIter)) { | 
| 221 |  |  | rb->updateAtoms(); | 
| 222 |  |  | } | 
| 223 |  |  | } | 
| 224 |  |  |  | 
| 225 |  |  | // outer loop is over the selected StuntDoubles: | 
| 226 |  |  |  | 
| 227 |  |  | for (sd = seleMan_.beginSelected(i); sd != NULL; | 
| 228 |  |  | sd = seleMan_.nextSelected(i)) { | 
| 229 |  |  |  | 
| 230 |  |  | myIndex = sd->getGlobalIndex(); | 
| 231 |  |  |  | 
| 232 |  |  | nBonds = 0; | 
| 233 |  |  |  | 
| 234 |  |  | for (int l = 0; l <= lMax_; l++) { | 
| 235 |  |  | for (int m = -l; m <= l; m++) { | 
| 236 |  |  | q[std::make_pair(l,m)] = 0.0; | 
| 237 |  |  | } | 
| 238 |  |  | } | 
| 239 |  |  | pos = sd->getPos(); | 
| 240 |  |  | rCOM = CenterOfMass - pos; | 
| 241 |  |  | if (usePeriodicBoundaryConditions_) | 
| 242 |  |  | currentSnapshot_->wrapVector(rCOM); | 
| 243 |  |  | distCOM = rCOM.length(); | 
| 244 |  |  |  | 
| 245 |  |  | // inner loop is over all other atoms in the system: | 
| 246 |  |  |  | 
| 247 |  |  | for (mol = info_->beginMolecule(mi); mol != NULL; | 
| 248 |  |  | mol = info_->nextMolecule(mi)) { | 
| 249 |  |  | for (atom = mol->beginAtom(ai); atom != NULL; | 
| 250 |  |  | atom = mol->nextAtom(ai)) { | 
| 251 |  |  |  | 
| 252 |  |  | if (atom->getGlobalIndex() != myIndex) { | 
| 253 |  |  | vec = pos - atom->getPos(); | 
| 254 |  |  |  | 
| 255 |  |  | if (usePeriodicBoundaryConditions_) | 
| 256 |  |  | currentSnapshot_->wrapVector(vec); | 
| 257 |  |  |  | 
| 258 |  |  | // Calculate "bonds" and build Q_lm(r) where | 
| 259 |  |  | //      Q_lm = Y_lm(theta(r),phi(r)) | 
| 260 |  |  | // The spherical harmonics are wrt any arbitrary coordinate | 
| 261 |  |  | // system, we choose standard spherical coordinates | 
| 262 |  |  |  | 
| 263 |  |  | r = vec.length(); | 
| 264 |  |  |  | 
| 265 |  |  | // Check to see if neighbor is in bond cutoff | 
| 266 |  |  |  | 
| 267 |  |  | if (r < rCut_) { | 
| 268 |  |  | costheta = vec.z() / r; | 
| 269 |  |  | phi = atan2(vec.y(), vec.x()); | 
| 270 |  |  |  | 
| 271 |  |  | for (int l = 0; l <= lMax_; l++) { | 
| 272 |  |  | sphericalHarmonic.setL(l); | 
| 273 |  |  | for(int m = -l; m <= l; m++){ | 
| 274 |  |  | sphericalHarmonic.setM(m); | 
| 275 |  |  | q[std::make_pair(l,m)] += sphericalHarmonic.getValueAt(costheta, phi); | 
| 276 |  |  | } | 
| 277 |  |  | } | 
| 278 |  |  | nBonds++; | 
| 279 |  |  | } | 
| 280 |  |  | } | 
| 281 |  |  | } | 
| 282 |  |  | } | 
| 283 |  |  |  | 
| 284 |  |  |  | 
| 285 |  |  | for (int l = 0; l <= lMax_; l++) { | 
| 286 |  |  | q2[l] = 0.0; | 
| 287 |  |  | for (int m = -l; m <= l; m++){ | 
| 288 |  |  | q[std::make_pair(l,m)] /= (RealType)nBonds; | 
| 289 |  |  | q2[l] += norm(q[std::make_pair(l,m)]); | 
| 290 |  |  | } | 
| 291 |  |  | q_l[l] = sqrt(q2[l] * 4.0 * NumericConstant::PI / (RealType)(2*l + 1)); | 
| 292 |  |  | } | 
| 293 |  |  |  | 
| 294 |  |  | // Find Third Order Invariant W_l | 
| 295 |  |  |  | 
| 296 |  |  | for (int l = 0; l <= lMax_; l++) { | 
| 297 |  |  | w[l] = 0.0; | 
| 298 |  |  | for (int m1 = -l; m1 <= l; m1++) { | 
| 299 |  |  | std::pair<int,int> lm = std::make_pair(l, m1); | 
| 300 |  |  | for (int mmm = 0; mmm <= (m2Max[lm] - m2Min[lm]); mmm++) { | 
| 301 |  |  | int m2 = m2Min[lm] + mmm; | 
| 302 |  |  | int m3 = -m1-m2; | 
| 303 |  |  | w[l] += w3j[lm][mmm] * q[lm] * | 
| 304 |  |  | q[std::make_pair(l,m2)] *  q[std::make_pair(l,m3)]; | 
| 305 |  |  | } | 
| 306 |  |  | } | 
| 307 |  |  |  | 
| 308 | gezelter | 1782 | w_hat[l] = w[l] / pow(q2[l], RealType(1.5)); | 
| 309 | chuckv | 1128 | } | 
| 310 |  |  |  | 
| 311 |  |  | collectHistogram(q_l, w_hat, distCOM); | 
| 312 | chuckv | 1137 |  | 
| 313 | gezelter | 1992 | //  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 | chuckv | 1128 | } | 
| 316 |  |  | } | 
| 317 | gezelter | 1992 |  | 
| 318 | chuckv | 1128 | writeOrderParameter(); | 
| 319 |  |  | } | 
| 320 | gezelter | 1992 |  | 
| 321 | chuckv | 1128 |  | 
| 322 |  |  |  | 
| 323 | gezelter | 1992 | 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 | chuckv | 1128 | if ( distCOM < len_){ | 
| 336 |  |  | // Figure out where this distance goes... | 
| 337 | gezelter | 1790 | int whichBin = int(distCOM / deltaR_); | 
| 338 | chuckv | 1137 | RCount_[whichBin]++; | 
| 339 |  |  |  | 
| 340 |  |  | if(real(what[6]) < -0.15){ | 
| 341 | gezelter | 1992 | WofR_[whichBin]++; | 
| 342 | chuckv | 1128 | } | 
| 343 | gezelter | 1992 | if(q[6] > 0.5){ | 
| 344 | chuckv | 1137 | QofR_[whichBin]++; | 
| 345 | gezelter | 1992 | } | 
| 346 |  |  | } | 
| 347 | chuckv | 1128 | } | 
| 348 |  |  |  | 
| 349 | gezelter | 1992 | 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 | chuckv | 1128 |  | 
| 359 | gezelter | 1992 | 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 | chuckv | 1128 | 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 | gezelter | 1992 |  | 
| 378 | chuckv | 1128 | for (int i = 0; i < nBins_; ++i) { | 
| 379 |  |  | RealType Rval = (i + 0.5) * deltaR_; | 
| 380 |  |  | osq << Rval; | 
| 381 | gezelter | 1992 | 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 | chuckv | 1128 | } | 
| 389 | gezelter | 1992 |  | 
| 390 | chuckv | 1128 | osq.close(); | 
| 391 | gezelter | 1992 |  | 
| 392 | chuckv | 1128 | } else { | 
| 393 |  |  | sprintf(painCave.errMsg, "BOPofR: unable to open %s\n", | 
| 394 |  |  | (getOutputFileName() + "q").c_str()); | 
| 395 |  |  | painCave.isFatal = 1; | 
| 396 |  |  | simError(); | 
| 397 |  |  | } | 
| 398 | gezelter | 1992 |  | 
| 399 | chuckv | 1128 | std::ofstream osw((getOutputFileName() + "wr").c_str()); | 
| 400 | gezelter | 1992 |  | 
| 401 | chuckv | 1128 | 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 | gezelter | 1992 | 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 | chuckv | 1128 | } | 
| 414 | gezelter | 1992 |  | 
| 415 | chuckv | 1128 | osw.close(); | 
| 416 |  |  | } else { | 
| 417 |  |  | sprintf(painCave.errMsg, "BOPofR: unable to open %s\n", | 
| 418 |  |  | (getOutputFileName() + "w").c_str()); | 
| 419 |  |  | painCave.isFatal = 1; | 
| 420 |  |  | simError(); | 
| 421 |  |  |  | 
| 422 |  |  | } | 
| 423 |  |  |  | 
| 424 |  |  | } | 
| 425 | gezelter | 1992 | 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 | chuckv | 1128 | } |