40 |
|
* [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). |
41 |
|
*/ |
42 |
|
|
43 |
– |
#include "FluctuatingChargeConstraints.hpp" |
44 |
– |
#include "primitives/Molecule.hpp" |
45 |
– |
|
43 |
|
#ifdef IS_MPI |
44 |
|
#include <mpi.h> |
45 |
|
#endif |
46 |
|
|
47 |
+ |
#include "FluctuatingChargeConstraints.hpp" |
48 |
+ |
#include "primitives/Molecule.hpp" |
49 |
+ |
|
50 |
|
namespace OpenMD { |
51 |
|
|
52 |
|
FluctuatingChargeConstraints::FluctuatingChargeConstraints(SimInfo* info) : |
53 |
< |
info_(info), constrainRegions_(false), hasFlucQ_(false), initialized_(false) { |
54 |
< |
|
53 |
> |
info_(info), initialized_(false), hasFlucQ_(false), |
54 |
> |
constrainRegions_(false) { |
55 |
|
} |
56 |
|
|
57 |
|
void FluctuatingChargeConstraints::initialize(){ |
100 |
|
void FluctuatingChargeConstraints::applyConstraints() { |
101 |
|
if (!initialized_) initialize(); |
102 |
|
if (!hasFlucQ_) return; |
103 |
+ |
|
104 |
|
SimInfo::MoleculeIterator i; |
105 |
|
Molecule::FluctuatingChargeIterator j; |
106 |
|
Molecule* mol; |
136 |
|
#ifdef IS_MPI |
137 |
|
// in parallel, we need to add up the contributions from all |
138 |
|
// processors: |
139 |
< |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &totalFrc, 1, MPI::REALTYPE, |
140 |
< |
MPI::SUM); |
139 |
> |
MPI_Allreduce(MPI_IN_PLACE, &totalFrc, 1, MPI_REALTYPE, |
140 |
> |
MPI_SUM, MPI_COMM_WORLD); |
141 |
|
|
142 |
|
if (constrainRegions_) { |
143 |
< |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, ®ionForce_[0], |
144 |
< |
regionForce_.size(), MPI::REALTYPE, MPI::SUM); |
145 |
< |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, ®ionCharges_[0], |
146 |
< |
regionCharges_.size(), MPI::INT, MPI::SUM); |
143 |
> |
MPI_Allreduce(MPI_IN_PLACE, ®ionForce_[0], |
144 |
> |
regionForce_.size(), MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); |
145 |
> |
MPI_Allreduce(MPI_IN_PLACE, ®ionCharges_[0], |
146 |
> |
regionCharges_.size(), MPI_INT, MPI_SUM, MPI_COMM_WORLD); |
147 |
|
} |
148 |
|
|
149 |
|
#endif |
153 |
|
|
154 |
|
// do the same in the regions: |
155 |
|
if (constrainRegions_) { |
156 |
< |
for (int i = 0; i < regionForce_.size(); ++i) { |
156 |
> |
for (unsigned int i = 0; i < regionForce_.size(); ++i) { |
157 |
|
regionForce_[ i ] /= regionCharges_[ i ]; |
158 |
|
} |
159 |
|
} |
184 |
|
|
185 |
|
for (atom = mol->beginFluctuatingCharge(j); atom != NULL; |
186 |
|
atom = mol->nextFluctuatingCharge(j)) { |
187 |
< |
//constrainedFrc = atom->getFlucQFrc() - totalFrc - totalMolFrc; |
187 |
> |
constrainedFrc = atom->getFlucQFrc() - totalFrc - totalMolFrc; |
188 |
|
|
189 |
< |
constrainedFrc = atom->getFlucQFrc() - totalMolFrc; |
189 |
> |
//constrainedFrc = atom->getFlucQFrc() - totalMolFrc; |
190 |
|
|
191 |
|
if (constrainRegions_) |
192 |
|
constrainedFrc -= regionFrc; |