| 50 | 
  | 
 | 
| 51 | 
  | 
#ifdef IS_MPI | 
| 52 | 
  | 
#include <mpi.h> | 
| 53 | 
< | 
#endif //is_mpi | 
| 53 | 
> | 
#endif | 
| 54 | 
  | 
 | 
| 55 | 
  | 
using namespace std; | 
| 56 | 
  | 
namespace OpenMD { | 
| 65 | 
  | 
    needFlucQ_         = simParams->getOutputFluctuatingCharges(); | 
| 66 | 
  | 
    needElectricField_ = simParams->getOutputElectricField(); | 
| 67 | 
  | 
 | 
| 68 | 
+ | 
    if (needParticlePot_ || needFlucQ_ || needElectricField_) { | 
| 69 | 
+ | 
      doSiteData_ = true; | 
| 70 | 
+ | 
    } else { | 
| 71 | 
+ | 
      doSiteData_ = false; | 
| 72 | 
+ | 
    } | 
| 73 | 
+ | 
 | 
| 74 | 
  | 
    createDumpFile_ = true; | 
| 75 | 
  | 
#ifdef HAVE_LIBZ | 
| 76 | 
  | 
    if (needCompression_) { | 
| 114 | 
  | 
    needFlucQ_         = simParams->getOutputFluctuatingCharges(); | 
| 115 | 
  | 
    needElectricField_ = simParams->getOutputElectricField(); | 
| 116 | 
  | 
 | 
| 117 | 
+ | 
    if (needParticlePot_ || needFlucQ_ || needElectricField_) { | 
| 118 | 
+ | 
      doSiteData_ = true; | 
| 119 | 
+ | 
    } else { | 
| 120 | 
+ | 
      doSiteData_ = false; | 
| 121 | 
+ | 
    } | 
| 122 | 
+ | 
 | 
| 123 | 
  | 
    createDumpFile_ = true; | 
| 124 | 
  | 
#ifdef HAVE_LIBZ | 
| 125 | 
  | 
    if (needCompression_) { | 
| 163 | 
  | 
    needFlucQ_         = simParams->getOutputFluctuatingCharges(); | 
| 164 | 
  | 
    needElectricField_ = simParams->getOutputElectricField(); | 
| 165 | 
  | 
 | 
| 166 | 
+ | 
    if (needParticlePot_ || needFlucQ_ || needElectricField_) { | 
| 167 | 
+ | 
      doSiteData_ = true; | 
| 168 | 
+ | 
    } else { | 
| 169 | 
+ | 
      doSiteData_ = false; | 
| 170 | 
+ | 
    } | 
| 171 | 
+ | 
 | 
| 172 | 
  | 
#ifdef HAVE_LIBZ | 
| 173 | 
  | 
    if (needCompression_) { | 
| 174 | 
  | 
      filename_ += ".gz"; | 
| 257 | 
  | 
            hmat(0, 2), hmat(1, 2), hmat(2, 2)); | 
| 258 | 
  | 
    os << buffer; | 
| 259 | 
  | 
 | 
| 260 | 
< | 
    RealType chi = s->getChi(); | 
| 261 | 
< | 
    RealType integralOfChiDt = s->getIntegralOfChiDt(); | 
| 262 | 
< | 
    if (isinf(chi) || isnan(chi) ||  | 
| 263 | 
< | 
        isinf(integralOfChiDt) || isnan(integralOfChiDt)) {       | 
| 260 | 
> | 
    pair<RealType, RealType> thermostat = s->getThermostat(); | 
| 261 | 
> | 
 | 
| 262 | 
> | 
    if (isinf(thermostat.first)  || isnan(thermostat.first) ||  | 
| 263 | 
> | 
        isinf(thermostat.second) || isnan(thermostat.second)) {       | 
| 264 | 
  | 
      sprintf( painCave.errMsg, | 
| 265 | 
  | 
               "DumpWriter detected a numerical error writing the thermostat"); | 
| 266 | 
  | 
      painCave.isFatal = 1; | 
| 267 | 
  | 
      simError(); | 
| 268 | 
  | 
    } | 
| 269 | 
< | 
    sprintf(buffer, "  Thermostat: %.10g , %.10g\n", chi, integralOfChiDt); | 
| 269 | 
> | 
    sprintf(buffer, "  Thermostat: %.10g , %.10g\n", thermostat.first,  | 
| 270 | 
> | 
            thermostat.second); | 
| 271 | 
  | 
    os << buffer; | 
| 272 | 
  | 
 | 
| 273 | 
  | 
    Mat3x3d eta; | 
| 274 | 
< | 
    eta = s->getEta(); | 
| 274 | 
> | 
    eta = s->getBarostat(); | 
| 275 | 
  | 
 | 
| 276 | 
  | 
    for (unsigned int i = 0; i < 3; i++) { | 
| 277 | 
  | 
      for (unsigned int j = 0; j < 3; j++) { | 
| 303 | 
  | 
    StuntDouble* integrableObject; | 
| 304 | 
  | 
    SimInfo::MoleculeIterator mi; | 
| 305 | 
  | 
    Molecule::IntegrableObjectIterator ii; | 
| 306 | 
+ | 
    RigidBody::AtomIterator ai; | 
| 307 | 
+ | 
    Atom* atom; | 
| 308 | 
  | 
 | 
| 309 | 
  | 
#ifndef IS_MPI | 
| 310 | 
  | 
    os << "  <Snapshot>\n"; | 
| 322 | 
  | 
      } | 
| 323 | 
  | 
    }     | 
| 324 | 
  | 
    os << "    </StuntDoubles>\n"; | 
| 325 | 
< | 
     | 
| 325 | 
> | 
 | 
| 326 | 
> | 
    if (doSiteData_) { | 
| 327 | 
> | 
      os << "    <SiteData>\n"; | 
| 328 | 
> | 
      for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) { | 
| 329 | 
> | 
                | 
| 330 | 
> | 
        for (integrableObject = mol->beginIntegrableObject(ii); integrableObject != NULL;   | 
| 331 | 
> | 
           integrableObject = mol->nextIntegrableObject(ii)) {   | 
| 332 | 
> | 
 | 
| 333 | 
> | 
          int ioIndex = integrableObject->getGlobalIntegrableObjectIndex(); | 
| 334 | 
> | 
          // do one for the IO itself | 
| 335 | 
> | 
          os << prepareSiteLine(integrableObject, ioIndex, 0); | 
| 336 | 
> | 
 | 
| 337 | 
> | 
          if (integrableObject->isRigidBody()) { | 
| 338 | 
> | 
             | 
| 339 | 
> | 
            RigidBody* rb = static_cast<RigidBody*>(integrableObject); | 
| 340 | 
> | 
            int siteIndex = 0; | 
| 341 | 
> | 
            for (atom = rb->beginAtom(ai); atom != NULL;   | 
| 342 | 
> | 
                 atom = rb->nextAtom(ai)) {                                              | 
| 343 | 
> | 
              os << prepareSiteLine(atom, ioIndex, siteIndex); | 
| 344 | 
> | 
              siteIndex++; | 
| 345 | 
> | 
            } | 
| 346 | 
> | 
          } | 
| 347 | 
> | 
        } | 
| 348 | 
> | 
      }     | 
| 349 | 
> | 
      os << "    </SiteData>\n"; | 
| 350 | 
> | 
    } | 
| 351 | 
  | 
    os << "  </Snapshot>\n"; | 
| 352 | 
  | 
 | 
| 353 | 
  | 
    os.flush(); | 
| 516 | 
  | 
      }       | 
| 517 | 
  | 
    } | 
| 518 | 
  | 
 | 
| 519 | 
< | 
    if (needParticlePot_) { | 
| 520 | 
< | 
      type += "u"; | 
| 521 | 
< | 
      RealType particlePot = integrableObject->getParticlePot(); | 
| 522 | 
< | 
      if (isinf(particlePot) || isnan(particlePot)) {       | 
| 523 | 
< | 
        sprintf( painCave.errMsg, | 
| 524 | 
< | 
                 "DumpWriter detected a numerical error writing the particle " | 
| 525 | 
< | 
                 " potential for object %d", index);       | 
| 526 | 
< | 
        painCave.isFatal = 1; | 
| 527 | 
< | 
        simError(); | 
| 528 | 
< | 
      } | 
| 529 | 
< | 
      sprintf(tempBuffer, " %13e", particlePot); | 
| 530 | 
< | 
      line += tempBuffer; | 
| 519 | 
> | 
    sprintf(tempBuffer, "%10d %7s %s\n", index, type.c_str(), line.c_str()); | 
| 520 | 
> | 
    return std::string(tempBuffer); | 
| 521 | 
> | 
  } | 
| 522 | 
> | 
 | 
| 523 | 
> | 
  std::string DumpWriter::prepareSiteLine(StuntDouble* integrableObject, int ioIndex, int siteIndex) { | 
| 524 | 
> | 
         | 
| 525 | 
> | 
 | 
| 526 | 
> | 
    std::string id; | 
| 527 | 
> | 
    std::string type; | 
| 528 | 
> | 
    std::string line; | 
| 529 | 
> | 
    char tempBuffer[4096]; | 
| 530 | 
> | 
 | 
| 531 | 
> | 
    if (integrableObject->isRigidBody()) { | 
| 532 | 
> | 
      sprintf(tempBuffer, "%10d           ", ioIndex); | 
| 533 | 
> | 
      id = std::string(tempBuffer); | 
| 534 | 
> | 
    } else { | 
| 535 | 
> | 
      sprintf(tempBuffer, "%10d %10d", ioIndex, siteIndex); | 
| 536 | 
> | 
      id = std::string(tempBuffer); | 
| 537 | 
  | 
    } | 
| 538 | 
< | 
     | 
| 538 | 
> | 
               | 
| 539 | 
  | 
    if (needFlucQ_) { | 
| 540 | 
  | 
      type += "cw"; | 
| 541 | 
  | 
      RealType fqPos = integrableObject->getFlucQPos(); | 
| 542 | 
  | 
      if (isinf(fqPos) || isnan(fqPos) ) {       | 
| 543 | 
  | 
        sprintf( painCave.errMsg, | 
| 544 | 
  | 
                 "DumpWriter detected a numerical error writing the" | 
| 545 | 
< | 
                 " fluctuating charge for object %d", index);       | 
| 545 | 
> | 
                 " fluctuating charge for object %s", id.c_str());       | 
| 546 | 
  | 
        painCave.isFatal = 1; | 
| 547 | 
  | 
        simError(); | 
| 548 | 
  | 
      } | 
| 553 | 
  | 
      if (isinf(fqVel) || isnan(fqVel) ) {       | 
| 554 | 
  | 
        sprintf( painCave.errMsg, | 
| 555 | 
  | 
                 "DumpWriter detected a numerical error writing the" | 
| 556 | 
< | 
                 " fluctuating charge velocity for object %d", index);       | 
| 556 | 
> | 
                 " fluctuating charge velocity for object %s", id.c_str());       | 
| 557 | 
  | 
        painCave.isFatal = 1; | 
| 558 | 
  | 
        simError(); | 
| 559 | 
  | 
      } | 
| 566 | 
  | 
        if (isinf(fqFrc) || isnan(fqFrc) ) {       | 
| 567 | 
  | 
          sprintf( painCave.errMsg, | 
| 568 | 
  | 
                   "DumpWriter detected a numerical error writing the" | 
| 569 | 
< | 
                   " fluctuating charge force for object %d", index);       | 
| 569 | 
> | 
                   " fluctuating charge force for object %s", id.c_str());       | 
| 570 | 
  | 
          painCave.isFatal = 1; | 
| 571 | 
  | 
          simError(); | 
| 572 | 
  | 
        } | 
| 583 | 
  | 
          isinf(eField[2]) || isnan(eField[2]) ) {       | 
| 584 | 
  | 
        sprintf( painCave.errMsg, | 
| 585 | 
  | 
                 "DumpWriter detected a numerical error writing the electric" | 
| 586 | 
< | 
                 " field for object %d", index);       | 
| 586 | 
> | 
                 " field for object %s", id.c_str());       | 
| 587 | 
  | 
        painCave.isFatal = 1; | 
| 588 | 
  | 
        simError(); | 
| 589 | 
  | 
      } | 
| 592 | 
  | 
      line += tempBuffer; | 
| 593 | 
  | 
    } | 
| 594 | 
  | 
 | 
| 595 | 
< | 
    sprintf(tempBuffer, "%10d %7s %s\n", index, type.c_str(), line.c_str()); | 
| 595 | 
> | 
 | 
| 596 | 
> | 
    if (needParticlePot_) { | 
| 597 | 
> | 
      type += "u"; | 
| 598 | 
> | 
      RealType particlePot = integrableObject->getParticlePot(); | 
| 599 | 
> | 
      if (isinf(particlePot) || isnan(particlePot)) {       | 
| 600 | 
> | 
        sprintf( painCave.errMsg, | 
| 601 | 
> | 
                 "DumpWriter detected a numerical error writing the particle " | 
| 602 | 
> | 
                 " potential for object %s", id.c_str());       | 
| 603 | 
> | 
        painCave.isFatal = 1; | 
| 604 | 
> | 
        simError(); | 
| 605 | 
> | 
      } | 
| 606 | 
> | 
      sprintf(tempBuffer, " %13e", particlePot); | 
| 607 | 
> | 
      line += tempBuffer; | 
| 608 | 
> | 
    } | 
| 609 | 
> | 
     | 
| 610 | 
> | 
 | 
| 611 | 
> | 
    sprintf(tempBuffer, "%s %7s %s\n", id.c_str(), type.c_str(), line.c_str()); | 
| 612 | 
  | 
    return std::string(tempBuffer); | 
| 613 | 
  | 
  } | 
| 614 | 
  | 
 | 
| 689 | 
  | 
    newOStream = new std::ofstream(filename.c_str()); | 
| 690 | 
  | 
#endif | 
| 691 | 
  | 
    //write out MetaData first | 
| 692 | 
< | 
    (*newOStream) << "<OpenMD version=1>" << std::endl; | 
| 692 | 
> | 
    (*newOStream) << "<OpenMD version=2>" << std::endl; | 
| 693 | 
  | 
    (*newOStream) << "  <MetaData>" << std::endl; | 
| 694 | 
  | 
    (*newOStream) << info_->getRawMetaData(); | 
| 695 | 
  | 
    (*newOStream) << "  </MetaData>" << std::endl; |