| 58 |
|
#include "primitives/Torsion.hpp" |
| 59 |
|
#include "primitives/Inversion.hpp" |
| 60 |
|
#include "nonbonded/NonBondedInteraction.hpp" |
| 61 |
+ |
#include "perturbations/ElectricField.hpp" |
| 62 |
|
#include "parallel/ForceMatrixDecomposition.hpp" |
| 63 |
|
|
| 64 |
|
#include <cstdio> |
| 424 |
|
electrostaticScale_[2] = fopts.getelectrostatic13scale(); |
| 425 |
|
electrostaticScale_[3] = fopts.getelectrostatic14scale(); |
| 426 |
|
|
| 427 |
+ |
if (info_->getSimParams()->haveElectricField()) { |
| 428 |
+ |
ElectricField* eField = new ElectricField(info_); |
| 429 |
+ |
perturbations_.push_back(eField); |
| 430 |
+ |
} |
| 431 |
+ |
|
| 432 |
|
fDecomp_->distributeInitialData(); |
| 433 |
|
|
| 434 |
|
initialized_ = true; |
| 455 |
|
Molecule::CutoffGroupIterator ci; |
| 456 |
|
CutoffGroup* cg; |
| 457 |
|
|
| 458 |
< |
// forces are zeroed here, before any are accumulated. |
| 458 |
> |
// forces and potentials are zeroed here, before any are |
| 459 |
> |
// accumulated. |
| 460 |
|
|
| 461 |
+ |
Snapshot* snap = info_->getSnapshotManager()->getCurrentSnapshot(); |
| 462 |
+ |
|
| 463 |
+ |
snap->setBondPotential(0.0); |
| 464 |
+ |
snap->setBendPotential(0.0); |
| 465 |
+ |
snap->setTorsionPotential(0.0); |
| 466 |
+ |
snap->setInversionPotential(0.0); |
| 467 |
+ |
|
| 468 |
+ |
potVec zeroPot(0.0); |
| 469 |
+ |
snap->setLongRangePotential(zeroPot); |
| 470 |
+ |
snap->setExcludedPotentials(zeroPot); |
| 471 |
+ |
|
| 472 |
+ |
snap->setRestraintPotential(0.0); |
| 473 |
+ |
snap->setRawPotential(0.0); |
| 474 |
+ |
|
| 475 |
|
for (mol = info_->beginMolecule(mi); mol != NULL; |
| 476 |
|
mol = info_->nextMolecule(mi)) { |
| 477 |
|
for(atom = mol->beginAtom(ai); atom != NULL; |
| 629 |
|
curSnapshot->setTorsionPotential(torsionPotential); |
| 630 |
|
curSnapshot->setInversionPotential(inversionPotential); |
| 631 |
|
|
| 632 |
< |
RealType shortRangePotential = bondPotential + bendPotential + |
| 633 |
< |
torsionPotential + inversionPotential; |
| 632 |
> |
// RealType shortRangePotential = bondPotential + bendPotential + |
| 633 |
> |
// torsionPotential + inversionPotential; |
| 634 |
|
|
| 635 |
< |
curSnapshot->setShortRangePotential(shortRangePotential); |
| 635 |
> |
// curSnapshot->setShortRangePotential(shortRangePotential); |
| 636 |
|
} |
| 637 |
|
|
| 638 |
|
void ForceManager::longRangeInteractions() { |
| 681 |
|
InteractionData idat; |
| 682 |
|
SelfData sdat; |
| 683 |
|
RealType mf; |
| 663 |
– |
RealType lrPot; |
| 684 |
|
RealType vpair; |
| 685 |
|
RealType dVdFQ1(0.0); |
| 686 |
|
RealType dVdFQ2(0.0); |
| 696 |
|
idat.pot = &workPot; |
| 697 |
|
idat.excludedPot = &exPot; |
| 698 |
|
sdat.pot = fDecomp_->getEmbeddingPotential(); |
| 699 |
+ |
sdat.excludedPot = fDecomp_->getExcludedSelfPotential(); |
| 700 |
|
idat.vpair = &vpair; |
| 701 |
|
idat.dVdFQ1 = &dVdFQ1; |
| 702 |
|
idat.dVdFQ2 = &dVdFQ2; |
| 874 |
|
|
| 875 |
|
fDecomp_->collectIntermediateData(); |
| 876 |
|
|
| 877 |
< |
for (int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) { |
| 877 |
> |
for (unsigned int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) { |
| 878 |
|
fDecomp_->fillSelfData(sdat, atom1); |
| 879 |
|
interactionMan_->doPreForce(sdat); |
| 880 |
|
} |
| 889 |
|
fDecomp_->collectData(); |
| 890 |
|
|
| 891 |
|
if (info_->requiresSelfCorrection()) { |
| 892 |
< |
for (int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) { |
| 892 |
> |
for (unsigned int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) { |
| 893 |
|
fDecomp_->fillSelfData(sdat, atom1); |
| 894 |
|
interactionMan_->doSelfCorrection(sdat); |
| 895 |
|
} |
| 901 |
|
longRangePotential = *(fDecomp_->getEmbeddingPotential()) + |
| 902 |
|
*(fDecomp_->getPairwisePotential()); |
| 903 |
|
|
| 904 |
< |
curSnapshot->setLongRangePotentialFamilies(longRangePotential); |
| 905 |
< |
|
| 906 |
< |
lrPot = longRangePotential.sum(); |
| 907 |
< |
|
| 887 |
< |
//store the long range potential |
| 888 |
< |
curSnapshot->setLongRangePotential(lrPot); |
| 889 |
< |
|
| 890 |
< |
curSnapshot->setExcludedPotentials(*(fDecomp_->getExcludedPotential())); |
| 904 |
> |
curSnapshot->setLongRangePotential(longRangePotential); |
| 905 |
> |
|
| 906 |
> |
curSnapshot->setExcludedPotentials(*(fDecomp_->getExcludedSelfPotential()) + |
| 907 |
> |
*(fDecomp_->getExcludedPotential())); |
| 908 |
|
|
| 909 |
|
} |
| 910 |
|
|
| 911 |
|
|
| 912 |
|
void ForceManager::postCalculation() { |
| 913 |
+ |
|
| 914 |
+ |
vector<Perturbation*>::iterator pi; |
| 915 |
+ |
for (pi = perturbations_.begin(); pi != perturbations_.end(); ++pi) { |
| 916 |
+ |
(*pi)->applyPerturbation(); |
| 917 |
+ |
} |
| 918 |
+ |
|
| 919 |
|
SimInfo::MoleculeIterator mi; |
| 920 |
|
Molecule* mol; |
| 921 |
|
Molecule::RigidBodyIterator rbIter; |
| 922 |
|
RigidBody* rb; |
| 923 |
|
Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); |
| 924 |
< |
|
| 924 |
> |
|
| 925 |
|
// collect the atomic forces onto rigid bodies |
| 926 |
|
|
| 927 |
|
for (mol = info_->beginMolecule(mi); mol != NULL; |
| 940 |
|
curSnapshot->setStressTensor(stressTensor); |
| 941 |
|
|
| 942 |
|
} |
| 920 |
– |
|
| 943 |
|
} //end namespace OpenMD |