35 |
|
* |
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). |
38 |
> |
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). |
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 |
+ |
#ifdef IS_MPI |
44 |
+ |
#include <mpi.h> |
45 |
+ |
#endif |
46 |
|
#include <cmath> |
47 |
|
#include "constraints/ZconstraintForceManager.hpp" |
48 |
|
#include "integrators/Integrator.hpp" |
49 |
|
#include "utils/simError.h" |
50 |
|
#include "utils/PhysicalConstants.hpp" |
51 |
|
#include "utils/StringUtils.hpp" |
49 |
– |
#ifdef IS_MPI |
50 |
– |
#include <mpi.h> |
51 |
– |
#endif |
52 |
|
|
53 |
|
namespace OpenMD { |
54 |
|
ZconstraintForceManager::ZconstraintForceManager(SimInfo* info): ForceManager(info), infiniteTime(1e31) { |
161 |
|
#ifndef IS_MPI |
162 |
|
totMassUnconsMols_ = totMassUnconsMols_local; |
163 |
|
#else |
164 |
< |
MPI_Allreduce(&totMassUnconsMols_local, &totMassUnconsMols_, 1, MPI_REALTYPE, |
165 |
< |
MPI_SUM, MPI_COMM_WORLD); |
164 |
> |
MPI_Allreduce(&totMassUnconsMols_local, &totMassUnconsMols_, 1, |
165 |
> |
MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); |
166 |
|
#endif |
167 |
|
|
168 |
|
// creat zconsWriter |
326 |
|
#ifndef IS_MPI |
327 |
|
pzMovingMols = pzMovingMols_local; |
328 |
|
#else |
329 |
< |
MPI_Allreduce(&pzMovingMols_local, &pzMovingMols, 1, MPI_REALTYPE, |
330 |
< |
MPI_SUM, MPI_COMM_WORLD); |
329 |
> |
MPI_Allreduce(&pzMovingMols_local, &pzMovingMols, 1, |
330 |
> |
MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); |
331 |
|
#endif |
332 |
|
|
333 |
|
RealType vzMovingMols = pzMovingMols / (totMassMovingZMols_ + totMassUnconsMols_); |
397 |
|
|
398 |
|
//calculate total z-constraint force |
399 |
|
#ifdef IS_MPI |
400 |
< |
MPI_Allreduce(&totalFZ_local, &totalFZ, 1, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); |
400 |
> |
MPI_Allreduce(&totalFZ_local, &totalFZ, 1, |
401 |
> |
MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); |
402 |
|
#else |
403 |
|
totalFZ = totalFZ_local; |
404 |
|
#endif |
481 |
|
#ifndef IS_MPI |
482 |
|
totalFZ = totalFZ_local; |
483 |
|
#else |
484 |
< |
MPI_Allreduce(&totalFZ_local, &totalFZ, 1, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); |
484 |
> |
MPI_Allreduce(&totalFZ_local, &totalFZ, 1, MPI_REALTYPE, |
485 |
> |
MPI_SUM, MPI_COMM_WORLD); |
486 |
|
#endif |
487 |
|
|
488 |
|
//modify the forces of unconstrained molecules |
567 |
|
#ifndef IS_MPI |
568 |
|
havingFixed = havingFixed_local; |
569 |
|
#else |
570 |
< |
MPI_Allreduce(&havingFixed_local, &havingFixed, 1, MPI_INT, MPI_SUM, |
571 |
< |
MPI_COMM_WORLD); |
570 |
> |
MPI_Allreduce(&havingFixed_local, &havingFixed, 1, |
571 |
> |
MPI_INT, MPI_SUM, MPI_COMM_WORLD); |
572 |
|
#endif |
573 |
|
|
574 |
|
return havingFixed > 0; |
584 |
|
#ifndef IS_MPI |
585 |
|
havingMoving = havingMoving_local; |
586 |
|
#else |
587 |
< |
MPI_Allreduce(&havingMoving_local, &havingMoving, 1, MPI_INT, MPI_SUM, |
588 |
< |
MPI_COMM_WORLD); |
587 |
> |
MPI_Allreduce(&havingMoving_local, &havingMoving, 1, |
588 |
> |
MPI_INT, MPI_SUM, MPI_COMM_WORLD); |
589 |
|
#endif |
590 |
|
|
591 |
|
return havingMoving > 0; |
600 |
|
} |
601 |
|
|
602 |
|
#ifdef IS_MPI |
603 |
< |
MPI_Allreduce(&totMassMovingZMols_local, &totMassMovingZMols_, 1, MPI_REALTYPE, |
604 |
< |
MPI_SUM, MPI_COMM_WORLD); |
603 |
> |
MPI_Allreduce(&totMassMovingZMols_local, &totMassMovingZMols_, |
604 |
> |
1, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); |
605 |
|
#else |
606 |
|
totMassMovingZMols_ = totMassMovingZMols_local; |
607 |
|
#endif |