--- trunk/src/brains/ForceManager.cpp 2007/04/06 21:53:43 1126 +++ trunk/src/brains/ForceManager.cpp 2008/09/12 20:51:22 1292 @@ -50,11 +50,13 @@ #include "brains/ForceManager.hpp" #include "primitives/Molecule.hpp" #include "UseTheForce/doForces_interface.h" -#define __C +#define __OOPSE_C #include "UseTheForce/DarkSide/fInteractionMap.h" #include "utils/simError.h" +#include "primitives/Bond.hpp" #include "primitives/Bend.hpp" -#include "primitives/Bend.hpp" +#include "primitives/Torsion.hpp" +#include "primitives/Inversion.hpp" namespace oopse { void ForceManager::calcForces(bool needPotential, bool needStress) { @@ -83,18 +85,19 @@ namespace oopse { // forces are zeroed here, before any are accumulated. // NOTE: do not rezero the forces in Fortran. - + for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) { for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { atom->zeroForcesAndTorques(); } - + //change the positions of atoms which belong to the rigidbodies for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { rb->zeroForcesAndTorques(); } + } // Zero out the stress tensor @@ -108,14 +111,17 @@ namespace oopse { Bond* bond; Bend* bend; Torsion* torsion; + Inversion* inversion; SimInfo::MoleculeIterator mi; Molecule::RigidBodyIterator rbIter; Molecule::BondIterator bondIter;; Molecule::BendIterator bendIter; Molecule::TorsionIterator torsionIter; + Molecule::InversionIterator inversionIter; RealType bondPotential = 0.0; RealType bendPotential = 0.0; RealType torsionPotential = 0.0; + RealType inversionPotential = 0.0; //calculate short range interactions for (mol = info_->beginMolecule(mi); mol != NULL; @@ -175,6 +181,30 @@ namespace oopse { i->second.prev.potential = i->second.curr.potential; i->second.curr.angle = angle; i->second.curr.potential = currTorsionPot; + i->second.deltaV = fabs(i->second.curr.potential - + i->second.prev.potential); + } + } + + for (inversion = mol->beginInversion(inversionIter); + inversion != NULL; + inversion = mol->nextInversion(inversionIter)) { + RealType angle; + inversion->calcForce(angle); + RealType currInversionPot = inversion->getPotential(); + inversionPotential += inversion->getPotential(); + std::map::iterator i = inversionDataSets.find(inversion); + if (i == inversionDataSets.end()) { + InversionDataSet dataSet; + dataSet.prev.angle = dataSet.curr.angle = angle; + dataSet.prev.potential = dataSet.curr.potential = currInversionPot; + dataSet.deltaV = 0.0; + inversionDataSets.insert(std::map::value_type(inversion, dataSet)); + }else { + i->second.prev.angle = i->second.curr.angle; + i->second.prev.potential = i->second.curr.potential; + i->second.curr.angle = angle; + i->second.curr.potential = currInversionPot; i->second.deltaV = fabs(i->second.curr.potential - i->second.prev.potential); } @@ -182,12 +212,13 @@ namespace oopse { } RealType shortRangePotential = bondPotential + bendPotential + - torsionPotential; + torsionPotential + inversionPotential; Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); curSnapshot->statData[Stats::SHORT_RANGE_POTENTIAL] = shortRangePotential; curSnapshot->statData[Stats::BOND_POTENTIAL] = bondPotential; curSnapshot->statData[Stats::BEND_POTENTIAL] = bendPotential; curSnapshot->statData[Stats::DIHEDRAL_POTENTIAL] = torsionPotential; + curSnapshot->statData[Stats::INVERSION_POTENTIAL] = inversionPotential; } @@ -201,6 +232,7 @@ namespace oopse { RealType* A; RealType* electroFrame; RealType* rc; + RealType* particlePot; //get current snapshot from SimInfo curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); @@ -212,6 +244,7 @@ namespace oopse { trq = config->getArrayPointer(DataStorage::dslTorque); A = config->getArrayPointer(DataStorage::dslAmat); electroFrame = config->getArrayPointer(DataStorage::dslElectroFrame); + particlePot = config->getArrayPointer(DataStorage::dslParticlePot); //calculate the center of mass of cutoff group SimInfo::MoleculeIterator mi; @@ -251,18 +284,19 @@ namespace oopse { longRangePotential[i]=0.0; //Initialize array } - doForceLoop( pos, - rc, - A, - electroFrame, - frc, - trq, - tau.getArrayPointer(), - longRangePotential, - &passedCalcPot, - &passedCalcStress, - &isError ); - + doForceLoop(pos, + rc, + A, + electroFrame, + frc, + trq, + tau.getArrayPointer(), + longRangePotential, + particlePot, + &passedCalcPot, + &passedCalcStress, + &isError ); + if( isError ){ sprintf( painCave.errMsg, "Error returned from the fortran force calculation.\n" );