| 61 |
|
#include "math/erfc.hpp" |
| 62 |
|
#include "math/SquareMatrix.hpp" |
| 63 |
|
#include "primitives/Molecule.hpp" |
| 64 |
+ |
#include "flucq/FluctuatingChargeForces.hpp" |
| 65 |
|
|
| 66 |
|
namespace OpenMD { |
| 67 |
|
|
| 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(); |
| 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_) { |
| 1260 |
|
vector<vector<RealType> > els; |
| 1261 |
|
vector<vector<RealType> > ems; |
| 1262 |
|
vector<vector<RealType> > ens; |
| 1248 |
– |
|
| 1263 |
|
|
| 1264 |
|
int nMax = info_->getNAtoms(); |
| 1265 |
|
|
| 1282 |
|
Vector3d t( 2.0 * M_PI ); |
| 1283 |
|
t.Vdiv(t, box); |
| 1284 |
|
|
| 1271 |
– |
|
| 1285 |
|
SimInfo::MoleculeIterator mi; |
| 1286 |
|
Molecule::AtomIterator ai; |
| 1287 |
|
int i; |
| 1471 |
|
qkss = std::accumulate(qks.begin(),qks.end(),0.0); |
| 1472 |
|
|
| 1473 |
|
#ifdef IS_MPI |
| 1474 |
< |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &ckcs, 1, MPI::REALTYPE, |
| 1475 |
< |
MPI::SUM); |
| 1476 |
< |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &ckss, 1, MPI::REALTYPE, |
| 1477 |
< |
MPI::SUM); |
| 1478 |
< |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &dkcs, 1, MPI::REALTYPE, |
| 1479 |
< |
MPI::SUM); |
| 1480 |
< |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &dkss, 1, MPI::REALTYPE, |
| 1481 |
< |
MPI::SUM); |
| 1482 |
< |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &qkcs, 1, MPI::REALTYPE, |
| 1483 |
< |
MPI::SUM); |
| 1484 |
< |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &qkss, 1, MPI::REALTYPE, |
| 1485 |
< |
MPI::SUM); |
| 1474 |
> |
MPI_Allreduce(MPI_IN_PLACE, &ckcs, 1, MPI_REALTYPE, |
| 1475 |
> |
MPI_SUM, MPI_COMM_WORLD); |
| 1476 |
> |
MPI_Allreduce(MPI_IN_PLACE, &ckss, 1, MPI_REALTYPE, |
| 1477 |
> |
MPI_SUM, MPI_COMM_WORLD); |
| 1478 |
> |
MPI_Allreduce(MPI_IN_PLACE, &dkcs, 1, MPI_REALTYPE, |
| 1479 |
> |
MPI_SUM, MPI_COMM_WORLD); |
| 1480 |
> |
MPI_Allreduce(MPI_IN_PLACE, &dkss, 1, MPI_REALTYPE, |
| 1481 |
> |
MPI_SUM, MPI_COMM_WORLD); |
| 1482 |
> |
MPI_Allreduce(MPI_IN_PLACE, &qkcs, 1, MPI_REALTYPE, |
| 1483 |
> |
MPI_SUM, MPI_COMM_WORLD); |
| 1484 |
> |
MPI_Allreduce(MPI_IN_PLACE, &qkss, 1, MPI_REALTYPE, |
| 1485 |
> |
MPI_SUM, MPI_COMM_WORLD); |
| 1486 |
|
#endif |
| 1487 |
|
|
| 1488 |
|
// Accumulate potential energy and virial contribution: |
| 1516 |
|
+skr[i]*(ckss+dkcs-qkss)); |
| 1517 |
|
|
| 1518 |
|
atom->addFrc( 4.0 * rvol * qfrc * kVec ); |
| 1519 |
< |
|
| 1519 |
> |
|
| 1520 |
> |
if (atom->isFluctuatingCharge()) { |
| 1521 |
> |
atom->addFlucQFrc( - 2.0 * rvol * qtrq2 ); |
| 1522 |
> |
} |
| 1523 |
> |
|
| 1524 |
|
if (data.is_Dipole) { |
| 1525 |
|
atom->addTrq( 4.0 * rvol * qtrq1 * dxk[i] ); |
| 1526 |
|
} |