| 39 | 
  | 
 * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010). | 
| 40 | 
  | 
 * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). | 
| 41 | 
  | 
 */ | 
| 42 | 
+ | 
 | 
| 43 | 
+ | 
#include "config.h" | 
| 44 | 
+ | 
 | 
| 45 | 
+ | 
#ifdef IS_MPI | 
| 46 | 
+ | 
#include <mpi.h> | 
| 47 | 
+ | 
#endif | 
| 48 | 
  | 
  | 
| 49 | 
  | 
#include "io/DumpWriter.hpp" | 
| 50 | 
  | 
#include "primitives/Molecule.hpp" | 
| 58 | 
  | 
#ifdef _MSC_VER | 
| 59 | 
  | 
#define isnan(x) _isnan((x)) | 
| 60 | 
  | 
#define isinf(x) (!_finite(x) && !_isnan(x)) | 
| 55 | 
– | 
#endif | 
| 56 | 
– | 
 | 
| 57 | 
– | 
#ifdef IS_MPI | 
| 58 | 
– | 
#include <mpi.h> | 
| 61 | 
  | 
#endif | 
| 62 | 
  | 
 | 
| 63 | 
  | 
using namespace std; | 
| 336 | 
  | 
           mol = info_->nextMolecule(mi)) { | 
| 337 | 
  | 
                | 
| 338 | 
  | 
        for (sd = mol->beginIntegrableObject(ii); sd != NULL;   | 
| 339 | 
< | 
             sd = mol->nextIntegrableObject(ii)) {       | 
| 340 | 
< | 
           | 
| 339 | 
> | 
           sd = mol->nextIntegrableObject(ii)) {         | 
| 340 | 
> | 
 | 
| 341 | 
  | 
          int ioIndex = sd->getGlobalIntegrableObjectIndex(); | 
| 342 | 
  | 
          // do one for the IO itself | 
| 343 | 
  | 
          os << prepareSiteLine(sd, ioIndex, 0); | 
| 627 | 
  | 
  } | 
| 628 | 
  | 
 | 
| 629 | 
  | 
  std::string DumpWriter::prepareSiteLine(StuntDouble* sd, int ioIndex, int siteIndex) { | 
| 630 | 
< | 
         | 
| 630 | 
> | 
    int storageLayout = info_->getSnapshotManager()->getStorageLayout(); | 
| 631 | 
  | 
 | 
| 632 | 
  | 
    std::string id; | 
| 633 | 
  | 
    std::string type; | 
| 643 | 
  | 
    } | 
| 644 | 
  | 
               | 
| 645 | 
  | 
    if (needFlucQ_) { | 
| 646 | 
< | 
      type += "cw"; | 
| 647 | 
< | 
      RealType fqPos = sd->getFlucQPos(); | 
| 648 | 
< | 
      if (isinf(fqPos) || isnan(fqPos) ) {       | 
| 649 | 
< | 
        sprintf( painCave.errMsg, | 
| 650 | 
< | 
                 "DumpWriter detected a numerical error writing the" | 
| 651 | 
< | 
                 " fluctuating charge for object %s", id.c_str());       | 
| 652 | 
< | 
        painCave.isFatal = 1; | 
| 653 | 
< | 
        simError(); | 
| 654 | 
< | 
      } | 
| 655 | 
< | 
      sprintf(tempBuffer, " %13e ", fqPos); | 
| 656 | 
< | 
      line += tempBuffer; | 
| 657 | 
< | 
     | 
| 658 | 
< | 
      RealType fqVel = sd->getFlucQVel(); | 
| 657 | 
< | 
      if (isinf(fqVel) || isnan(fqVel) ) {       | 
| 658 | 
< | 
        sprintf( painCave.errMsg, | 
| 659 | 
< | 
                 "DumpWriter detected a numerical error writing the" | 
| 660 | 
< | 
                 " fluctuating charge velocity for object %s", id.c_str());       | 
| 661 | 
< | 
        painCave.isFatal = 1; | 
| 662 | 
< | 
        simError(); | 
| 663 | 
< | 
      } | 
| 664 | 
< | 
      sprintf(tempBuffer, " %13e ", fqVel); | 
| 665 | 
< | 
      line += tempBuffer; | 
| 646 | 
> | 
      if (storageLayout & DataStorage::dslFlucQPosition) { | 
| 647 | 
> | 
        type += "c"; | 
| 648 | 
> | 
        RealType fqPos = sd->getFlucQPos(); | 
| 649 | 
> | 
        if (isinf(fqPos) || isnan(fqPos) ) {       | 
| 650 | 
> | 
          sprintf( painCave.errMsg, | 
| 651 | 
> | 
                   "DumpWriter detected a numerical error writing the" | 
| 652 | 
> | 
                   " fluctuating charge for object %s", id.c_str());       | 
| 653 | 
> | 
          painCave.isFatal = 1; | 
| 654 | 
> | 
          simError(); | 
| 655 | 
> | 
        } | 
| 656 | 
> | 
        sprintf(tempBuffer, " %13e ", fqPos); | 
| 657 | 
> | 
        line += tempBuffer; | 
| 658 | 
> | 
      }  | 
| 659 | 
  | 
 | 
| 660 | 
< | 
      if (needForceVector_) { | 
| 661 | 
< | 
        type += "g"; | 
| 662 | 
< | 
        RealType fqFrc = sd->getFlucQFrc();         | 
| 663 | 
< | 
        if (isinf(fqFrc) || isnan(fqFrc) ) {       | 
| 660 | 
> | 
      if (storageLayout & DataStorage::dslFlucQVelocity) { | 
| 661 | 
> | 
        type += "w";     | 
| 662 | 
> | 
        RealType fqVel = sd->getFlucQVel(); | 
| 663 | 
> | 
        if (isinf(fqVel) || isnan(fqVel) ) {       | 
| 664 | 
  | 
          sprintf( painCave.errMsg, | 
| 665 | 
  | 
                   "DumpWriter detected a numerical error writing the" | 
| 666 | 
< | 
                   " fluctuating charge force for object %s", id.c_str());       | 
| 666 | 
> | 
                   " fluctuating charge velocity for object %s", id.c_str());       | 
| 667 | 
  | 
          painCave.isFatal = 1; | 
| 668 | 
  | 
          simError(); | 
| 669 | 
  | 
        } | 
| 670 | 
< | 
        sprintf(tempBuffer, " %13e ", fqFrc);         | 
| 670 | 
> | 
        sprintf(tempBuffer, " %13e ", fqVel); | 
| 671 | 
  | 
        line += tempBuffer; | 
| 672 | 
  | 
      } | 
| 680 | 
– | 
    } | 
| 673 | 
  | 
 | 
| 674 | 
+ | 
      if (needForceVector_) { | 
| 675 | 
+ | 
        if (storageLayout & DataStorage::dslFlucQForce) {           | 
| 676 | 
+ | 
          type += "g"; | 
| 677 | 
+ | 
          RealType fqFrc = sd->getFlucQFrc();         | 
| 678 | 
+ | 
          if (isinf(fqFrc) || isnan(fqFrc) ) {       | 
| 679 | 
+ | 
            sprintf( painCave.errMsg, | 
| 680 | 
+ | 
                     "DumpWriter detected a numerical error writing the" | 
| 681 | 
+ | 
                     " fluctuating charge force for object %s", id.c_str());       | 
| 682 | 
+ | 
            painCave.isFatal = 1; | 
| 683 | 
+ | 
            simError(); | 
| 684 | 
+ | 
          } | 
| 685 | 
+ | 
          sprintf(tempBuffer, " %13e ", fqFrc);         | 
| 686 | 
+ | 
          line += tempBuffer; | 
| 687 | 
+ | 
        } | 
| 688 | 
+ | 
      } | 
| 689 | 
+ | 
    } | 
| 690 | 
+ | 
     | 
| 691 | 
  | 
    if (needElectricField_) { | 
| 692 | 
< | 
      type += "e"; | 
| 693 | 
< | 
      Vector3d eField= sd->getElectricField(); | 
| 694 | 
< | 
      if (isinf(eField[0]) || isnan(eField[0]) ||  | 
| 695 | 
< | 
          isinf(eField[1]) || isnan(eField[1]) ||  | 
| 696 | 
< | 
          isinf(eField[2]) || isnan(eField[2]) ) {       | 
| 697 | 
< | 
        sprintf( painCave.errMsg, | 
| 698 | 
< | 
                 "DumpWriter detected a numerical error writing the electric" | 
| 699 | 
< | 
                 " field for object %s", id.c_str());       | 
| 700 | 
< | 
        painCave.isFatal = 1; | 
| 701 | 
< | 
        simError(); | 
| 692 | 
> | 
      if (storageLayout & DataStorage::dslElectricField) { | 
| 693 | 
> | 
        type += "e"; | 
| 694 | 
> | 
        Vector3d eField= sd->getElectricField(); | 
| 695 | 
> | 
        if (isinf(eField[0]) || isnan(eField[0]) ||  | 
| 696 | 
> | 
            isinf(eField[1]) || isnan(eField[1]) ||  | 
| 697 | 
> | 
            isinf(eField[2]) || isnan(eField[2]) ) {       | 
| 698 | 
> | 
          sprintf( painCave.errMsg, | 
| 699 | 
> | 
                   "DumpWriter detected a numerical error writing the electric" | 
| 700 | 
> | 
                   " field for object %s", id.c_str());       | 
| 701 | 
> | 
          painCave.isFatal = 1; | 
| 702 | 
> | 
          simError(); | 
| 703 | 
> | 
        } | 
| 704 | 
> | 
        sprintf(tempBuffer, " %13e %13e %13e", | 
| 705 | 
> | 
                eField[0], eField[1], eField[2]); | 
| 706 | 
> | 
        line += tempBuffer; | 
| 707 | 
  | 
      } | 
| 694 | 
– | 
      sprintf(tempBuffer, " %13e %13e %13e", | 
| 695 | 
– | 
              eField[0], eField[1], eField[2]); | 
| 696 | 
– | 
      line += tempBuffer; | 
| 708 | 
  | 
    } | 
| 709 | 
  | 
 | 
| 710 | 
  | 
 | 
| 711 | 
  | 
    if (needParticlePot_) { | 
| 712 | 
< | 
      type += "u"; | 
| 713 | 
< | 
      RealType particlePot = sd->getParticlePot(); | 
| 714 | 
< | 
      if (isinf(particlePot) || isnan(particlePot)) {       | 
| 715 | 
< | 
        sprintf( painCave.errMsg, | 
| 716 | 
< | 
                 "DumpWriter detected a numerical error writing the particle " | 
| 717 | 
< | 
                 " potential for object %s", id.c_str());       | 
| 718 | 
< | 
        painCave.isFatal = 1; | 
| 719 | 
< | 
        simError(); | 
| 712 | 
> | 
      if (storageLayout & DataStorage::dslParticlePot) { | 
| 713 | 
> | 
        type += "u"; | 
| 714 | 
> | 
        RealType particlePot = sd->getParticlePot(); | 
| 715 | 
> | 
        if (isinf(particlePot) || isnan(particlePot)) {       | 
| 716 | 
> | 
          sprintf( painCave.errMsg, | 
| 717 | 
> | 
                   "DumpWriter detected a numerical error writing the particle " | 
| 718 | 
> | 
                   " potential for object %s", id.c_str());       | 
| 719 | 
> | 
          painCave.isFatal = 1; | 
| 720 | 
> | 
          simError(); | 
| 721 | 
> | 
        } | 
| 722 | 
> | 
        sprintf(tempBuffer, " %13e", particlePot); | 
| 723 | 
> | 
        line += tempBuffer; | 
| 724 | 
  | 
      } | 
| 710 | 
– | 
      sprintf(tempBuffer, " %13e", particlePot); | 
| 711 | 
– | 
      line += tempBuffer; | 
| 725 | 
  | 
    } | 
| 726 | 
< | 
     | 
| 714 | 
< | 
 | 
| 726 | 
> | 
    | 
| 727 | 
  | 
    sprintf(tempBuffer, "%s %7s %s\n", id.c_str(), type.c_str(), line.c_str()); | 
| 728 | 
  | 
    return std::string(tempBuffer); | 
| 729 | 
  | 
  } |