# | Line 36 | Line 36 | |
---|---|---|
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, 24107 (2008). | |
39 | < | * [4] Vardeman & Gezelter, in progress (2009). |
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 "io/DumpWriter.hpp" | |
# | Line 58 | Line 59 | namespace OpenMD { | |
59 | : info_(info), filename_(info->getDumpFileName()), eorFilename_(info->getFinalConfigFileName()){ | |
60 | ||
61 | Globals* simParams = info->getSimParams(); | |
62 | < | needCompression_ = simParams->getCompressDumpFile(); |
63 | < | needForceVector_ = simParams->getOutputForceVector(); |
62 | > | needCompression_ = simParams->getCompressDumpFile(); |
63 | > | needForceVector_ = simParams->getOutputForceVector(); |
64 | > | needParticlePot_ = simParams->getOutputParticlePotential(); |
65 | > | needFlucQ_ = simParams->getOutputFluctuatingCharges(); |
66 | > | needElectricField_ = simParams->getOutputElectricField(); |
67 | > | |
68 | createDumpFile_ = true; | |
69 | #ifdef HAVE_LIBZ | |
70 | if (needCompression_) { | |
# | Line 97 | Line 102 | namespace OpenMD { | |
102 | Globals* simParams = info->getSimParams(); | |
103 | eorFilename_ = filename_.substr(0, filename_.rfind(".")) + ".eor"; | |
104 | ||
105 | < | needCompression_ = simParams->getCompressDumpFile(); |
106 | < | needForceVector_ = simParams->getOutputForceVector(); |
105 | > | needCompression_ = simParams->getCompressDumpFile(); |
106 | > | needForceVector_ = simParams->getOutputForceVector(); |
107 | > | needParticlePot_ = simParams->getOutputParticlePotential(); |
108 | > | needFlucQ_ = simParams->getOutputFluctuatingCharges(); |
109 | > | needElectricField_ = simParams->getOutputElectricField(); |
110 | > | |
111 | createDumpFile_ = true; | |
112 | #ifdef HAVE_LIBZ | |
113 | if (needCompression_) { | |
# | Line 136 | Line 145 | namespace OpenMD { | |
145 | Globals* simParams = info->getSimParams(); | |
146 | eorFilename_ = filename_.substr(0, filename_.rfind(".")) + ".eor"; | |
147 | ||
148 | < | needCompression_ = simParams->getCompressDumpFile(); |
149 | < | needForceVector_ = simParams->getOutputForceVector(); |
150 | < | |
148 | > | needCompression_ = simParams->getCompressDumpFile(); |
149 | > | needForceVector_ = simParams->getOutputForceVector(); |
150 | > | needParticlePot_ = simParams->getOutputParticlePotential(); |
151 | > | needFlucQ_ = simParams->getOutputFluctuatingCharges(); |
152 | > | needElectricField_ = simParams->getOutputElectricField(); |
153 | > | |
154 | #ifdef HAVE_LIBZ | |
155 | if (needCompression_) { | |
156 | filename_ += ".gz"; | |
# | Line 306 | Line 318 | namespace OpenMD { | |
318 | } | |
319 | ||
320 | const int masterNode = 0; | |
321 | < | |
321 | > | int nProc; |
322 | > | MPI_Comm_size(MPI_COMM_WORLD, &nProc); |
323 | if (worldRank == masterNode) { | |
324 | os << " <Snapshot>\n"; | |
325 | writeFrameProperties(os, info_->getSnapshotManager()->getCurrentSnapshot()); | |
# | Line 314 | Line 327 | namespace OpenMD { | |
327 | ||
328 | os << buffer; | |
329 | ||
317 | – | int nProc; |
318 | – | MPI_Comm_size(MPI_COMM_WORLD, &nProc); |
330 | for (int i = 1; i < nProc; ++i) { | |
331 | ||
332 | // receive the length of the string buffer that was | |
333 | // prepared by processor i | |
334 | ||
335 | + | MPI_Bcast(&i, 1, MPI_INT,masterNode,MPI_COMM_WORLD); |
336 | int recvLength; | |
337 | MPI_Recv(&recvLength, 1, MPI_INT, i, 0, MPI_COMM_WORLD, &istatus); | |
338 | char* recvBuffer = new char[recvLength]; | |
# | Line 337 | Line 349 | namespace OpenMD { | |
349 | os.flush(); | |
350 | } else { | |
351 | int sendBufferLength = buffer.size() + 1; | |
352 | < | MPI_Send(&sendBufferLength, 1, MPI_INT, masterNode, 0, MPI_COMM_WORLD); |
353 | < | MPI_Send((void *)buffer.c_str(), sendBufferLength, MPI_CHAR, masterNode, 0, MPI_COMM_WORLD); |
352 | > | int myturn = 0; |
353 | > | for (int i = 1; i < nProc; ++i){ |
354 | > | MPI_Bcast(&myturn,1, MPI_INT,masterNode,MPI_COMM_WORLD); |
355 | > | if (myturn == worldRank){ |
356 | > | MPI_Send(&sendBufferLength, 1, MPI_INT, masterNode, 0, MPI_COMM_WORLD); |
357 | > | MPI_Send((void *)buffer.c_str(), sendBufferLength, MPI_CHAR, masterNode, 0, MPI_COMM_WORLD); |
358 | > | } |
359 | > | } |
360 | } | |
361 | ||
362 | #endif // is_mpi | |
# | Line 420 | Line 438 | namespace OpenMD { | |
438 | ||
439 | if (needForceVector_) { | |
440 | type += "f"; | |
441 | < | Vector3d frc; |
424 | < | |
425 | < | frc = integrableObject->getFrc(); |
426 | < | |
441 | > | Vector3d frc = integrableObject->getFrc(); |
442 | if (isinf(frc[0]) || isnan(frc[0]) || | |
443 | isinf(frc[1]) || isnan(frc[1]) || | |
444 | isinf(frc[2]) || isnan(frc[2]) ) { | |
# | Line 439 | Line 454 | namespace OpenMD { | |
454 | ||
455 | if (integrableObject->isDirectional()) { | |
456 | type += "t"; | |
457 | < | Vector3d trq; |
443 | < | |
444 | < | trq = integrableObject->getTrq(); |
445 | < | |
457 | > | Vector3d trq = integrableObject->getTrq(); |
458 | if (isinf(trq[0]) || isnan(trq[0]) || | |
459 | isinf(trq[1]) || isnan(trq[1]) || | |
460 | isinf(trq[2]) || isnan(trq[2]) ) { | |
# | Line 451 | Line 463 | namespace OpenMD { | |
463 | " for object %d", index); | |
464 | painCave.isFatal = 1; | |
465 | simError(); | |
466 | < | } |
455 | < | |
466 | > | } |
467 | sprintf(tempBuffer, " %13e %13e %13e", | |
468 | trq[0], trq[1], trq[2]); | |
469 | line += tempBuffer; | |
470 | } | |
471 | } | |
472 | + | |
473 | + | if (needParticlePot_) { |
474 | + | type += "u"; |
475 | + | RealType particlePot = integrableObject->getParticlePot(); |
476 | + | if (isinf(particlePot) || isnan(particlePot)) { |
477 | + | sprintf( painCave.errMsg, |
478 | + | "DumpWriter detected a numerical error writing the particle " |
479 | + | " potential for object %d", index); |
480 | + | painCave.isFatal = 1; |
481 | + | simError(); |
482 | + | } |
483 | + | sprintf(tempBuffer, " %13e", particlePot); |
484 | + | line += tempBuffer; |
485 | + | } |
486 | ||
487 | + | if (needFlucQ_) { |
488 | + | type += "cw"; |
489 | + | RealType fqPos = integrableObject->getFlucQPos(); |
490 | + | if (isinf(fqPos) || isnan(fqPos) ) { |
491 | + | sprintf( painCave.errMsg, |
492 | + | "DumpWriter detected a numerical error writing the" |
493 | + | " fluctuating charge for object %d", index); |
494 | + | painCave.isFatal = 1; |
495 | + | simError(); |
496 | + | } |
497 | + | sprintf(tempBuffer, " %13e ", fqPos); |
498 | + | line += tempBuffer; |
499 | + | |
500 | + | RealType fqVel = integrableObject->getFlucQVel(); |
501 | + | if (isinf(fqVel) || isnan(fqVel) ) { |
502 | + | sprintf( painCave.errMsg, |
503 | + | "DumpWriter detected a numerical error writing the" |
504 | + | " fluctuating charge velocity for object %d", index); |
505 | + | painCave.isFatal = 1; |
506 | + | simError(); |
507 | + | } |
508 | + | sprintf(tempBuffer, " %13e ", fqVel); |
509 | + | line += tempBuffer; |
510 | + | |
511 | + | if (needForceVector_) { |
512 | + | type += "g"; |
513 | + | RealType fqFrc = integrableObject->getFlucQFrc(); |
514 | + | if (isinf(fqFrc) || isnan(fqFrc) ) { |
515 | + | sprintf( painCave.errMsg, |
516 | + | "DumpWriter detected a numerical error writing the" |
517 | + | " fluctuating charge force for object %d", index); |
518 | + | painCave.isFatal = 1; |
519 | + | simError(); |
520 | + | } |
521 | + | sprintf(tempBuffer, " %13e ", fqFrc); |
522 | + | line += tempBuffer; |
523 | + | } |
524 | + | } |
525 | + | |
526 | + | if (needElectricField_) { |
527 | + | type += "e"; |
528 | + | Vector3d eField= integrableObject->getElectricField(); |
529 | + | if (isinf(eField[0]) || isnan(eField[0]) || |
530 | + | isinf(eField[1]) || isnan(eField[1]) || |
531 | + | isinf(eField[2]) || isnan(eField[2]) ) { |
532 | + | sprintf( painCave.errMsg, |
533 | + | "DumpWriter detected a numerical error writing the electric" |
534 | + | " field for object %d", index); |
535 | + | painCave.isFatal = 1; |
536 | + | simError(); |
537 | + | } |
538 | + | sprintf(tempBuffer, " %13e %13e %13e", |
539 | + | eField[0], eField[1], eField[2]); |
540 | + | line += tempBuffer; |
541 | + | } |
542 | + | |
543 | sprintf(tempBuffer, "%10d %7s %s\n", index, type.c_str(), line.c_str()); | |
544 | return std::string(tempBuffer); | |
545 | } |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |