57 |
|
#include "primitives/Bend.hpp" |
58 |
|
#include "primitives/Torsion.hpp" |
59 |
|
#include "primitives/Inversion.hpp" |
60 |
+ |
|
61 |
|
namespace OpenMD { |
62 |
+ |
|
63 |
+ |
ForceManager::ForceManager(SimInfo * info) : info_(info), |
64 |
+ |
NBforcesInitialized_(false) { |
65 |
+ |
lj_ = LJ::Instance(); |
66 |
+ |
lj_->setForceField(info_->getForceField()); |
67 |
|
|
68 |
< |
void ForceManager::calcForces(bool needPotential, bool needStress) { |
68 |
> |
gb_ = GB::Instance(); |
69 |
> |
gb_->setForceField(info_->getForceField()); |
70 |
> |
|
71 |
> |
eam_ = EAM::Instance(); |
72 |
> |
eam_->setForceField(info_->getForceField()); |
73 |
> |
} |
74 |
> |
|
75 |
> |
void ForceManager::calcForces() { |
76 |
|
|
77 |
|
if (!info_->isFortranInitialized()) { |
78 |
|
info_->update(); |
82 |
|
|
83 |
|
calcShortRangeInteraction(); |
84 |
|
|
85 |
< |
calcLongRangeInteraction(needPotential, needStress); |
85 |
> |
calcLongRangeInteraction(); |
86 |
|
|
87 |
< |
postCalculation(needStress); |
87 |
> |
postCalculation(); |
88 |
|
|
89 |
|
} |
90 |
|
|
158 |
|
RealType angle; |
159 |
|
bend->calcForce(angle); |
160 |
|
RealType currBendPot = bend->getPotential(); |
161 |
+ |
|
162 |
|
bendPotential += bend->getPotential(); |
163 |
|
std::map<Bend*, BendDataSet>::iterator i = bendDataSets.find(bend); |
164 |
|
if (i == bendDataSets.end()) { |
236 |
|
|
237 |
|
} |
238 |
|
|
239 |
< |
void ForceManager::calcLongRangeInteraction(bool needPotential, |
226 |
< |
bool needStress) { |
239 |
> |
void ForceManager::calcLongRangeInteraction() { |
240 |
|
Snapshot* curSnapshot; |
241 |
|
DataStorage* config; |
242 |
|
RealType* frc; |
289 |
|
RealType longRangePotential[LR_POT_TYPES]; |
290 |
|
RealType lrPot = 0.0; |
291 |
|
Vector3d totalDipole; |
279 |
– |
short int passedCalcPot = needPotential; |
280 |
– |
short int passedCalcStress = needStress; |
292 |
|
int isError = 0; |
293 |
|
|
294 |
|
for (int i=0; i<LR_POT_TYPES;i++){ |
304 |
|
tau.getArrayPointer(), |
305 |
|
longRangePotential, |
306 |
|
particlePot, |
296 |
– |
&passedCalcPot, |
297 |
– |
&passedCalcStress, |
307 |
|
&isError ); |
308 |
|
|
309 |
|
if( isError ){ |
332 |
|
} |
333 |
|
|
334 |
|
|
335 |
< |
void ForceManager::postCalculation(bool needStress) { |
335 |
> |
void ForceManager::postCalculation() { |
336 |
|
SimInfo::MoleculeIterator mi; |
337 |
|
Molecule* mol; |
338 |
|
Molecule::RigidBodyIterator rbIter; |
345 |
|
mol = info_->nextMolecule(mi)) { |
346 |
|
for (rb = mol->beginRigidBody(rbIter); rb != NULL; |
347 |
|
rb = mol->nextRigidBody(rbIter)) { |
348 |
< |
if (needStress) { |
349 |
< |
Mat3x3d rbTau = rb->calcForcesAndTorquesAndVirial(); |
341 |
< |
tau += rbTau; |
342 |
< |
} else{ |
343 |
< |
rb->calcForcesAndTorques(); |
344 |
< |
} |
348 |
> |
Mat3x3d rbTau = rb->calcForcesAndTorquesAndVirial(); |
349 |
> |
tau += rbTau; |
350 |
|
} |
351 |
|
} |
352 |
< |
|
348 |
< |
if (needStress) { |
352 |
> |
|
353 |
|
#ifdef IS_MPI |
354 |
< |
Mat3x3d tmpTau(tau); |
355 |
< |
MPI_Allreduce(tmpTau.getArrayPointer(), tau.getArrayPointer(), |
356 |
< |
9, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); |
354 |
> |
Mat3x3d tmpTau(tau); |
355 |
> |
MPI_Allreduce(tmpTau.getArrayPointer(), tau.getArrayPointer(), |
356 |
> |
9, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); |
357 |
|
#endif |
358 |
< |
curSnapshot->statData.setTau(tau); |
355 |
< |
} |
358 |
> |
curSnapshot->statData.setTau(tau); |
359 |
|
} |
360 |
|
|
361 |
|
} //end namespace OpenMD |