| 6 |
|
* redistribute this software in source and binary code form, provided |
| 7 |
|
* that the following conditions are met: |
| 8 |
|
* |
| 9 |
< |
* 1. Acknowledgement of the program authors must be made in any |
| 10 |
< |
* publication of scientific results based in part on use of the |
| 11 |
< |
* program. An acceptable form of acknowledgement is citation of |
| 12 |
< |
* the article in which the program was described (Matthew |
| 13 |
< |
* A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher |
| 14 |
< |
* J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented |
| 15 |
< |
* Parallel Simulation Engine for Molecular Dynamics," |
| 16 |
< |
* J. Comput. Chem. 26, pp. 252-271 (2005)) |
| 17 |
< |
* |
| 18 |
< |
* 2. Redistributions of source code must retain the above copyright |
| 9 |
> |
* 1. Redistributions of source code must retain the above copyright |
| 10 |
|
* notice, this list of conditions and the following disclaimer. |
| 11 |
|
* |
| 12 |
< |
* 3. Redistributions in binary form must reproduce the above copyright |
| 12 |
> |
* 2. Redistributions in binary form must reproduce the above copyright |
| 13 |
|
* notice, this list of conditions and the following disclaimer in the |
| 14 |
|
* documentation and/or other materials provided with the |
| 15 |
|
* distribution. |
| 28 |
|
* arising out of the use of or inability to use software, even if the |
| 29 |
|
* University of Notre Dame has been advised of the possibility of |
| 30 |
|
* such damages. |
| 31 |
+ |
* |
| 32 |
+ |
* SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your |
| 33 |
+ |
* research, please cite the appropriate papers when you publish your |
| 34 |
+ |
* work. Good starting points are: |
| 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). |
| 39 |
+ |
* [4] Vardeman & Gezelter, in progress (2009). |
| 40 |
|
*/ |
| 41 |
|
|
| 42 |
|
/** |
| 50 |
|
#include "brains/ForceManager.hpp" |
| 51 |
|
#include "primitives/Molecule.hpp" |
| 52 |
|
#include "UseTheForce/doForces_interface.h" |
| 53 |
< |
#define __C |
| 53 |
> |
#define __OPENMD_C |
| 54 |
|
#include "UseTheForce/DarkSide/fInteractionMap.h" |
| 55 |
|
#include "utils/simError.h" |
| 56 |
|
#include "primitives/Bond.hpp" |
| 57 |
|
#include "primitives/Bend.hpp" |
| 58 |
< |
namespace oopse { |
| 58 |
> |
#include "primitives/Torsion.hpp" |
| 59 |
> |
#include "primitives/Inversion.hpp" |
| 60 |
|
|
| 61 |
< |
void ForceManager::calcForces(bool needPotential, bool needStress) { |
| 61 |
> |
namespace OpenMD { |
| 62 |
> |
|
| 63 |
> |
ForceManager::ForceManager(SimInfo * info) : info_(info), |
| 64 |
> |
NBforcesInitialized_(false) { |
| 65 |
> |
} |
| 66 |
> |
|
| 67 |
> |
void ForceManager::calcForces() { |
| 68 |
|
|
| 69 |
+ |
|
| 70 |
|
if (!info_->isFortranInitialized()) { |
| 71 |
|
info_->update(); |
| 72 |
+ |
nbiMan_->setSimInfo(info_); |
| 73 |
+ |
nbiMan_->initialize(); |
| 74 |
+ |
info_->setupFortran(); |
| 75 |
|
} |
| 76 |
|
|
| 77 |
|
preCalculation(); |
| 78 |
|
|
| 79 |
|
calcShortRangeInteraction(); |
| 80 |
|
|
| 81 |
< |
calcLongRangeInteraction(needPotential, needStress); |
| 81 |
> |
calcLongRangeInteraction(); |
| 82 |
|
|
| 83 |
< |
postCalculation(needStress); |
| 83 |
> |
postCalculation(); |
| 84 |
|
|
| 85 |
|
} |
| 86 |
|
|
| 120 |
|
Bond* bond; |
| 121 |
|
Bend* bend; |
| 122 |
|
Torsion* torsion; |
| 123 |
+ |
Inversion* inversion; |
| 124 |
|
SimInfo::MoleculeIterator mi; |
| 125 |
|
Molecule::RigidBodyIterator rbIter; |
| 126 |
|
Molecule::BondIterator bondIter;; |
| 127 |
|
Molecule::BendIterator bendIter; |
| 128 |
|
Molecule::TorsionIterator torsionIter; |
| 129 |
+ |
Molecule::InversionIterator inversionIter; |
| 130 |
|
RealType bondPotential = 0.0; |
| 131 |
|
RealType bendPotential = 0.0; |
| 132 |
|
RealType torsionPotential = 0.0; |
| 133 |
+ |
RealType inversionPotential = 0.0; |
| 134 |
|
|
| 135 |
|
//calculate short range interactions |
| 136 |
|
for (mol = info_->beginMolecule(mi); mol != NULL; |
| 154 |
|
RealType angle; |
| 155 |
|
bend->calcForce(angle); |
| 156 |
|
RealType currBendPot = bend->getPotential(); |
| 157 |
+ |
|
| 158 |
|
bendPotential += bend->getPotential(); |
| 159 |
|
std::map<Bend*, BendDataSet>::iterator i = bendDataSets.find(bend); |
| 160 |
|
if (i == bendDataSets.end()) { |
| 195 |
|
i->second.prev.potential); |
| 196 |
|
} |
| 197 |
|
} |
| 198 |
+ |
|
| 199 |
+ |
for (inversion = mol->beginInversion(inversionIter); |
| 200 |
+ |
inversion != NULL; |
| 201 |
+ |
inversion = mol->nextInversion(inversionIter)) { |
| 202 |
+ |
RealType angle; |
| 203 |
+ |
inversion->calcForce(angle); |
| 204 |
+ |
RealType currInversionPot = inversion->getPotential(); |
| 205 |
+ |
inversionPotential += inversion->getPotential(); |
| 206 |
+ |
std::map<Inversion*, InversionDataSet>::iterator i = inversionDataSets.find(inversion); |
| 207 |
+ |
if (i == inversionDataSets.end()) { |
| 208 |
+ |
InversionDataSet dataSet; |
| 209 |
+ |
dataSet.prev.angle = dataSet.curr.angle = angle; |
| 210 |
+ |
dataSet.prev.potential = dataSet.curr.potential = currInversionPot; |
| 211 |
+ |
dataSet.deltaV = 0.0; |
| 212 |
+ |
inversionDataSets.insert(std::map<Inversion*, InversionDataSet>::value_type(inversion, dataSet)); |
| 213 |
+ |
}else { |
| 214 |
+ |
i->second.prev.angle = i->second.curr.angle; |
| 215 |
+ |
i->second.prev.potential = i->second.curr.potential; |
| 216 |
+ |
i->second.curr.angle = angle; |
| 217 |
+ |
i->second.curr.potential = currInversionPot; |
| 218 |
+ |
i->second.deltaV = fabs(i->second.curr.potential - |
| 219 |
+ |
i->second.prev.potential); |
| 220 |
+ |
} |
| 221 |
+ |
} |
| 222 |
|
} |
| 223 |
|
|
| 224 |
|
RealType shortRangePotential = bondPotential + bendPotential + |
| 225 |
< |
torsionPotential; |
| 225 |
> |
torsionPotential + inversionPotential; |
| 226 |
|
Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); |
| 227 |
|
curSnapshot->statData[Stats::SHORT_RANGE_POTENTIAL] = shortRangePotential; |
| 228 |
|
curSnapshot->statData[Stats::BOND_POTENTIAL] = bondPotential; |
| 229 |
|
curSnapshot->statData[Stats::BEND_POTENTIAL] = bendPotential; |
| 230 |
|
curSnapshot->statData[Stats::DIHEDRAL_POTENTIAL] = torsionPotential; |
| 231 |
+ |
curSnapshot->statData[Stats::INVERSION_POTENTIAL] = inversionPotential; |
| 232 |
|
|
| 233 |
|
} |
| 234 |
|
|
| 235 |
< |
void ForceManager::calcLongRangeInteraction(bool needPotential, |
| 196 |
< |
bool needStress) { |
| 235 |
> |
void ForceManager::calcLongRangeInteraction() { |
| 236 |
|
Snapshot* curSnapshot; |
| 237 |
|
DataStorage* config; |
| 238 |
|
RealType* frc; |
| 284 |
|
//initialize data before passing to fortran |
| 285 |
|
RealType longRangePotential[LR_POT_TYPES]; |
| 286 |
|
RealType lrPot = 0.0; |
| 248 |
– |
Vector3d totalDipole; |
| 249 |
– |
short int passedCalcPot = needPotential; |
| 250 |
– |
short int passedCalcStress = needStress; |
| 287 |
|
int isError = 0; |
| 288 |
|
|
| 289 |
|
for (int i=0; i<LR_POT_TYPES;i++){ |
| 299 |
|
tau.getArrayPointer(), |
| 300 |
|
longRangePotential, |
| 301 |
|
particlePot, |
| 266 |
– |
&passedCalcPot, |
| 267 |
– |
&passedCalcStress, |
| 302 |
|
&isError ); |
| 303 |
|
|
| 304 |
|
if( isError ){ |
| 310 |
|
for (int i=0; i<LR_POT_TYPES;i++){ |
| 311 |
|
lrPot += longRangePotential[i]; //Quick hack |
| 312 |
|
} |
| 313 |
< |
|
| 280 |
< |
// grab the simulation box dipole moment if specified |
| 281 |
< |
if (info_->getCalcBoxDipole()){ |
| 282 |
< |
getAccumulatedBoxDipole(totalDipole.getArrayPointer()); |
| 283 |
< |
|
| 284 |
< |
curSnapshot->statData[Stats::BOX_DIPOLE_X] = totalDipole(0); |
| 285 |
< |
curSnapshot->statData[Stats::BOX_DIPOLE_Y] = totalDipole(1); |
| 286 |
< |
curSnapshot->statData[Stats::BOX_DIPOLE_Z] = totalDipole(2); |
| 287 |
< |
} |
| 288 |
< |
|
| 313 |
> |
|
| 314 |
|
//store the tau and long range potential |
| 315 |
|
curSnapshot->statData[Stats::LONG_RANGE_POTENTIAL] = lrPot; |
| 316 |
|
curSnapshot->statData[Stats::VANDERWAALS_POTENTIAL] = longRangePotential[VDW_POT]; |
| 318 |
|
} |
| 319 |
|
|
| 320 |
|
|
| 321 |
< |
void ForceManager::postCalculation(bool needStress) { |
| 321 |
> |
void ForceManager::postCalculation() { |
| 322 |
|
SimInfo::MoleculeIterator mi; |
| 323 |
|
Molecule* mol; |
| 324 |
|
Molecule::RigidBodyIterator rbIter; |
| 331 |
|
mol = info_->nextMolecule(mi)) { |
| 332 |
|
for (rb = mol->beginRigidBody(rbIter); rb != NULL; |
| 333 |
|
rb = mol->nextRigidBody(rbIter)) { |
| 334 |
< |
if (needStress) { |
| 335 |
< |
Mat3x3d rbTau = rb->calcForcesAndTorquesAndVirial(); |
| 311 |
< |
tau += rbTau; |
| 312 |
< |
} else{ |
| 313 |
< |
rb->calcForcesAndTorques(); |
| 314 |
< |
} |
| 334 |
> |
Mat3x3d rbTau = rb->calcForcesAndTorquesAndVirial(); |
| 335 |
> |
tau += rbTau; |
| 336 |
|
} |
| 337 |
|
} |
| 338 |
< |
|
| 318 |
< |
if (needStress) { |
| 338 |
> |
|
| 339 |
|
#ifdef IS_MPI |
| 340 |
< |
Mat3x3d tmpTau(tau); |
| 341 |
< |
MPI_Allreduce(tmpTau.getArrayPointer(), tau.getArrayPointer(), |
| 342 |
< |
9, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); |
| 340 |
> |
Mat3x3d tmpTau(tau); |
| 341 |
> |
MPI_Allreduce(tmpTau.getArrayPointer(), tau.getArrayPointer(), |
| 342 |
> |
9, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); |
| 343 |
|
#endif |
| 344 |
< |
curSnapshot->statData.setTau(tau); |
| 325 |
< |
} |
| 344 |
> |
curSnapshot->statData.setTau(tau); |
| 345 |
|
} |
| 346 |
|
|
| 347 |
< |
} //end namespace oopse |
| 347 |
> |
} //end namespace OpenMD |