ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/nonbonded/Electrostatic.cpp
(Generate patch)

Comparing trunk/src/nonbonded/Electrostatic.cpp (file contents):
Revision 1932 by gezelter, Wed Aug 21 16:52:56 2013 UTC vs.
Revision 1969 by gezelter, Wed Feb 26 14:14:50 2014 UTC

# Line 40 | Line 40
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 +
47   #include <stdio.h>
48   #include <string.h>
49  
# Line 57 | Line 61
61   #include "math/erfc.hpp"
62   #include "math/SquareMatrix.hpp"
63   #include "primitives/Molecule.hpp"
64 < #ifdef IS_MPI
61 < #include <mpi.h>
62 < #endif
64 > #include "flucq/FluctuatingChargeForces.hpp"
65  
66   namespace OpenMD {
67    
# Line 69 | Line 71 | namespace OpenMD {
71                                    haveDampingAlpha_(false),
72                                    haveDielectric_(false),
73                                    haveElectroSplines_(false)
74 <  {}
74 >  {
75 >    flucQ_ = new FluctuatingChargeForces(info_);
76 >  }
77    
78 +  void Electrostatic::setForceField(ForceField *ff) {
79 +    forceField_ = ff;
80 +    flucQ_->setForceField(forceField_);
81 +  }
82 +
83 +  void Electrostatic::setSimulatedAtomTypes(set<AtomType*> &simtypes) {
84 +    simTypes_ = simtypes;
85 +    flucQ_->setSimulatedAtomTypes(simTypes_);
86 +  }
87 +
88    void Electrostatic::initialize() {
89      
90      Globals* simParams_ = info_->getSimParams();
# Line 987 | Line 1001 | namespace OpenMD {
1001          F  -= pref * (rdDa * rdDb) * (dv22 - 2.0*v22or) * rhat;
1002          Ta += pref * ( v21 * DaxDb - v22 * rdDb * rxDa);
1003          Tb += pref * (-v21 * DaxDb - v22 * rdDa * rxDb);
990
1004          // Even if we excluded this pair from direct interactions, we
1005          // still have the reaction-field-mediated dipole-dipole
1006          // interaction:
# Line 1047 | Line 1060 | namespace OpenMD {
1060          trQaQb = QaQb.trace();
1061          rQaQb = rhat * QaQb;
1062          QaQbr = QaQb * rhat;
1063 <        QaxQb = cross(Q_a, Q_b);
1063 >        QaxQb = mCross(Q_a, Q_b);
1064          rQaQbr = dot(rQa, Qbr);
1065          rQaxQbr = cross(rQa, Qbr);
1066          
# Line 1078 | Line 1091 | namespace OpenMD {
1091          //             + 4.0 * cross(rhat, QbQar)
1092  
1093          Tb += pref * 2.0 * cross(rhat,Qbr) * rdQar * v43;
1081
1094        }
1095      }
1096  
# Line 1141 | Line 1153 | namespace OpenMD {
1153          
1154      if (i_is_Fluctuating) {
1155        C_a += *(sdat.flucQ);
1156 <      *(sdat.flucQfrc) -=  *(sdat.flucQ) * data.hardness + data.electronegativity;
1157 <      (*(sdat.excludedPot))[ELECTROSTATIC_FAMILY] += (*sdat.flucQ) *
1158 <        (*(sdat.flucQ) * data.hardness * 0.5 + data.electronegativity);
1156 >
1157 >      flucQ_->getSelfInteraction(sdat.atid, *(sdat.flucQ),  
1158 >                                 (*(sdat.excludedPot))[ELECTROSTATIC_FAMILY],
1159 >                                 *(sdat.flucQfrc) );
1160 >
1161      }
1162  
1163      switch (summationMethod_) {
# Line 1441 | Line 1455 | namespace OpenMD {
1455                  if (data.is_Quadrupole) {
1456                    Q = atom->getQuadrupole() * mPoleConverter;
1457                    Qk = Q * kVec;                  
1458 <                  qk = dot(Qk, kVec);
1459 <                  qxk[i] = cross(Qk, kVec);
1458 >                  qk = dot(kVec, Qk);
1459 >                  qxk[i] = -cross(kVec, Qk);
1460                    qkc[i] = qk * ckr[i];
1461                    qks[i] = qk * skr[i];
1462                  }              
# Line 1459 | Line 1473 | namespace OpenMD {
1473              qkss = std::accumulate(qks.begin(),qks.end(),0.0);
1474              
1475   #ifdef IS_MPI
1476 <            MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &ckcs, 1, MPI::REALTYPE,
1477 <                                      MPI::SUM);
1478 <            MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &ckss, 1, MPI::REALTYPE,
1479 <                                      MPI::SUM);
1480 <            MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &dkcs, 1, MPI::REALTYPE,
1481 <                                      MPI::SUM);
1482 <            MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &dkss, 1, MPI::REALTYPE,
1483 <                                      MPI::SUM);
1484 <            MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &qkcs, 1, MPI::REALTYPE,
1485 <                                      MPI::SUM);
1486 <            MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &qkss, 1, MPI::REALTYPE,
1487 <                                      MPI::SUM);
1476 >            MPI_Allreduce(MPI_IN_PLACE, &ckcs, 1, MPI_REALTYPE,
1477 >                          MPI_SUM, MPI_COMM_WORLD);
1478 >            MPI_Allreduce(MPI_IN_PLACE, &ckss, 1, MPI_REALTYPE,
1479 >                          MPI_SUM, MPI_COMM_WORLD);
1480 >            MPI_Allreduce(MPI_IN_PLACE, &dkcs, 1, MPI_REALTYPE,
1481 >                          MPI_SUM, MPI_COMM_WORLD);
1482 >            MPI_Allreduce(MPI_IN_PLACE, &dkss, 1, MPI_REALTYPE,
1483 >                          MPI_SUM, MPI_COMM_WORLD);
1484 >            MPI_Allreduce(MPI_IN_PLACE, &qkcs, 1, MPI_REALTYPE,
1485 >                          MPI_SUM, MPI_COMM_WORLD);
1486 >            MPI_Allreduce(MPI_IN_PLACE, &qkss, 1, MPI_REALTYPE,
1487 >                          MPI_SUM, MPI_COMM_WORLD);
1488   #endif        
1489              
1490              // Accumulate potential energy and virial contribution:
# Line 1501 | Line 1515 | namespace OpenMD {
1515                  RealType qtrq1 = AK[kk]*(skr[i]*(ckcs-dkss-qkcs)
1516                                           -ckr[i]*(ckss+dkcs-qkss));
1517                  RealType qtrq2 = 2.0*AK[kk]*(ckr[i]*(ckcs-dkss-qkcs)
1518 <                                             +skr[i]*(ckss+dkcs-qkss));
1518 >                                            +skr[i]*(ckss+dkcs-qkss));
1519                
1520                  atom->addFrc( 4.0 * rvol * qfrc * kVec );
1521                  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines