--- trunk/src/flucq/FluctuatingChargeConstraints.cpp 2013/07/29 17:55:17 1915 +++ trunk/src/flucq/FluctuatingChargeConstraints.cpp 2015/03/07 16:59:57 2070 @@ -40,18 +40,18 @@ * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). */ -#include "FluctuatingChargeConstraints.hpp" -#include "primitives/Molecule.hpp" - #ifdef IS_MPI #include #endif +#include "FluctuatingChargeConstraints.hpp" +#include "primitives/Molecule.hpp" + namespace OpenMD { FluctuatingChargeConstraints::FluctuatingChargeConstraints(SimInfo* info) : - info_(info), constrainRegions_(false), hasFlucQ_(false), initialized_(false) { - + info_(info), initialized_(false), hasFlucQ_(false), + constrainRegions_(false) { } void FluctuatingChargeConstraints::initialize(){ @@ -100,6 +100,7 @@ namespace OpenMD { void FluctuatingChargeConstraints::applyConstraints() { if (!initialized_) initialize(); if (!hasFlucQ_) return; + SimInfo::MoleculeIterator i; Molecule::FluctuatingChargeIterator j; Molecule* mol; @@ -135,14 +136,14 @@ namespace OpenMD { #ifdef IS_MPI // in parallel, we need to add up the contributions from all // processors: - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &totalFrc, 1, MPI::REALTYPE, - MPI::SUM); + MPI_Allreduce(MPI_IN_PLACE, &totalFrc, 1, MPI_REALTYPE, + MPI_SUM, MPI_COMM_WORLD); if (constrainRegions_) { - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, ®ionForce_[0], - regionForce_.size(), MPI::REALTYPE, MPI::SUM); - MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, ®ionCharges_[0], - regionCharges_.size(), MPI::INT, MPI::SUM); + MPI_Allreduce(MPI_IN_PLACE, ®ionForce_[0], + regionForce_.size(), MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, ®ionCharges_[0], + regionCharges_.size(), MPI_INT, MPI_SUM, MPI_COMM_WORLD); } #endif @@ -152,7 +153,7 @@ namespace OpenMD { // do the same in the regions: if (constrainRegions_) { - for (int i = 0; i < regionForce_.size(); ++i) { + for (unsigned int i = 0; i < regionForce_.size(); ++i) { regionForce_[ i ] /= regionCharges_[ i ]; } } @@ -183,9 +184,9 @@ namespace OpenMD { for (atom = mol->beginFluctuatingCharge(j); atom != NULL; atom = mol->nextFluctuatingCharge(j)) { - //constrainedFrc = atom->getFlucQFrc() - totalFrc - totalMolFrc; + constrainedFrc = atom->getFlucQFrc() - totalFrc - totalMolFrc; - constrainedFrc = atom->getFlucQFrc() - totalMolFrc; + //constrainedFrc = atom->getFlucQFrc() - totalMolFrc; if (constrainRegions_) constrainedFrc -= regionFrc;