--- trunk/src/perturbations/ElectricField.cpp 2013/06/16 15:15:42 1879 +++ trunk/src/perturbations/ElectricField.cpp 2014/04/17 19:07:31 1987 @@ -94,6 +94,10 @@ namespace OpenMD { RealType chrg = 0.0; AtomType* atype = atom->getAtomType(); + + // ad-hoc choice of the origin for potential calculation and + // fluctuating charge force: + pos = atom->getPos(); if (atype->isElectrostatic()) { atom->addElectricField(EF * chrgToKcal); @@ -109,14 +113,13 @@ namespace OpenMD { if ( fqa.isFluctuatingCharge() ) { isCharge = true; chrg += atom->getFlucQPos(); + atom->addFlucQFrc( dot(pos,EF) * chrgToKcal ); } if (isCharge) { EFfrc = EF*chrg; EFfrc *= chrgToKcal; atom->addFrc(EFfrc); - // ad-hoc choice of the origin for potential calculation - pos = atom->getPos(); pot = -dot(pos, EFfrc); if (doParticlePot) { atom->addParticlePot(pot); @@ -141,8 +144,8 @@ namespace OpenMD { } } #ifdef IS_MPI - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &fieldPot, 1, MPI::REALTYPE, - MPI::SUM); + MPI_Allreduce(MPI_IN_PLACE, &fieldPot, 1, MPI_REALTYPE, + MPI_SUM, MPI_COMM_WORLD); #endif Snapshot* snap = info_->getSnapshotManager()->getCurrentSnapshot(); longRangePotential = snap->getLongRangePotentials();