--- trunk/src/brains/ForceManager.cpp 2013/07/29 17:55:17 1915 +++ trunk/src/brains/ForceManager.cpp 2014/04/29 17:32:31 1993 @@ -417,6 +417,7 @@ namespace OpenMD { if (doHeatFlux_) doParticlePot_ = true; doElectricField_ = info_->getSimParams()->getOutputElectricField(); + doSitePotential_ = info_->getSimParams()->getOutputSitePotential(); } @@ -637,14 +638,15 @@ namespace OpenMD { // Collect from all nodes. This should eventually be moved into a // SystemDecomposition, but this is a better place than in // Thermo to do the collection. - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &bondPotential, 1, MPI::REALTYPE, - MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &bendPotential, 1, MPI::REALTYPE, - MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &torsionPotential, 1, - MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &inversionPotential, 1, - MPI::REALTYPE, MPI::SUM); + + MPI_Allreduce(MPI_IN_PLACE, &bondPotential, 1, MPI_REALTYPE, + MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &bendPotential, 1, MPI_REALTYPE, + MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &torsionPotential, 1, + MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &inversionPotential, 1, + MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); #endif Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); @@ -666,6 +668,7 @@ namespace OpenMD { DataStorage* config = &(curSnapshot->atomData); DataStorage* cgConfig = &(curSnapshot->cgData); + //calculate the center of mass of cutoff group SimInfo::MoleculeIterator mi; @@ -709,10 +712,14 @@ namespace OpenMD { RealType dVdFQ1(0.0); RealType dVdFQ2(0.0); potVec longRangePotential(0.0); + RealType reciprocalPotential(0.0); potVec workPot(0.0); potVec exPot(0.0); Vector3d eField1(0.0); Vector3d eField2(0.0); + RealType sPot1(0.0); + RealType sPot2(0.0); + vector::iterator ia, jb; int loopStart, loopEnd; @@ -728,13 +735,16 @@ namespace OpenMD { idat.dVdFQ1 = &dVdFQ1; idat.dVdFQ2 = &dVdFQ2; idat.eField1 = &eField1; - idat.eField2 = &eField2; + idat.eField2 = &eField2; + idat.sPot1 = &sPot1; + idat.sPot2 = &sPot2; idat.f1 = &f1; idat.sw = &sw; idat.shiftedPot = (cutoffMethod_ == SHIFTED_POTENTIAL) ? true : false; idat.shiftedForce = (cutoffMethod_ == SHIFTED_FORCE || cutoffMethod_ == TAYLOR_SHIFTED) ? true : false; idat.doParticlePot = doParticlePot_; idat.doElectricField = doElectricField_; + idat.doSitePotential = doSitePotential_; sdat.doParticlePot = doParticlePot_; loopEnd = PAIR_LOOP; @@ -769,12 +779,13 @@ namespace OpenMD { rgrpsq = d_grp.lengthSquare(); if (rgrpsq < rCutSq) { - if (iLoop == PAIR_LOOP) { vij = 0.0; fij.zero(); eField1.zero(); eField2.zero(); + sPot1 = 0.0; + sPot2 = 0.0; } in_switching_region = switcher_->getSwitch(rgrpsq, sw, dswdr, @@ -826,7 +837,7 @@ namespace OpenMD { r = sqrt( *(idat.r2) ); idat.rij = &r; - + if (iLoop == PREPAIR_LOOP) { interactionMan_->doPrePair(idat); } else { @@ -926,7 +937,9 @@ namespace OpenMD { // collects pairwise information fDecomp_->collectData(); if (cutoffMethod_ == EWALD_FULL) { - interactionMan_->doReciprocalSpaceSum(); + interactionMan_->doReciprocalSpaceSum(reciprocalPotential); + + curSnapshot->setReciprocalPotential(reciprocalPotential); } if (info_->requiresSelfCorrection()) { @@ -949,7 +962,6 @@ namespace OpenMD { } - void ForceManager::postCalculation() { vector::iterator pi; @@ -975,8 +987,8 @@ namespace OpenMD { } #ifdef IS_MPI - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, stressTensor.getArrayPointer(), 9, - MPI::REALTYPE, MPI::SUM); + MPI_Allreduce(MPI_IN_PLACE, stressTensor.getArrayPointer(), 9, + MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); #endif curSnapshot->setStressTensor(stressTensor);