ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/restraints/RestraintForceManager.cpp
(Generate patch)

Comparing trunk/src/restraints/RestraintForceManager.cpp (file contents):
Revision 1390 by gezelter, Wed Nov 25 20:02:06 2009 UTC vs.
Revision 1879 by gezelter, Sun Jun 16 15:15:42 2013 UTC

# Line 35 | Line 35
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).                        
38 > * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).          
39 > * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40 > * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   */
42  
43 + #include "config.h"
44   #include <cmath>
45 +
46   #include "restraints/RestraintForceManager.hpp"
47   #include "restraints/MolecularRestraint.hpp"
48   #include "restraints/ObjectRestraint.hpp"
# Line 89 | Line 92 | namespace OpenMD {
92      int nRestraintStamps = simParam->getNRestraintStamps();
93      std::vector<RestraintStamp*> stamp = simParam->getRestraintStamps();
94  
95 +    std::vector<int> stuntDoubleIndex;
96 +
97      for (int i = 0; i < nRestraintStamps; i++){
98  
99        std::string myType = toUpperCopy(stamp[i]->getType());
# Line 96 | Line 101 | namespace OpenMD {
101        if (myType.compare("MOLECULAR")==0){
102  
103          int molIndex;
99        std::vector<Vector3d> ref;
104          Vector3d refCom;
105  
106          if (!stamp[i]->haveMolIndex()) {
# Line 134 | Line 138 | namespace OpenMD {
138          
139            int myrank = MPI::COMM_WORLD.Get_rank();
140            if (info_->getMolToProc(molIndex) == myrank) {
141 +        
142              // If we were supposed to have it but got a null, then freak out.
143   #endif
144  
# Line 149 | Line 154 | namespace OpenMD {
154   #endif
155          }
156          
157 +
158 + #ifdef IS_MPI
159 +        // only handle this molecular restraint if this processor owns the
160 +        // molecule
161 +        int myrank = MPI::COMM_WORLD.Get_rank();
162 +        if (info_->getMolToProc(molIndex) == myrank) {
163 +
164 + #endif
165 +
166          MolecularRestraint* rest = new MolecularRestraint();
167  
168          std::string restPre("mol_");
# Line 184 | Line 198 | namespace OpenMD {
198          restraints_.push_back(rest);
199          mol->addProperty(new RestraintData("Restraint", rest));
200          restrainedMols_.push_back(mol);
201 <        
201 > #ifdef IS_MPI
202 >        }
203 > #endif        
204        } else if (myType.compare("OBJECT") == 0) {
205          
206          std::string objectSelection;
# Line 220 | Line 236 | namespace OpenMD {
236  
237          for (sd = seleMan.beginSelected(selei); sd != NULL;
238               sd = seleMan.nextSelected(selei)) {
239 <          
239 >          stuntDoubleIndex.push_back(sd->getGlobalIntegrableObjectIndex());
240 >
241            ObjectRestraint* rest = new ObjectRestraint();
242            
243            if (stamp[i]->haveDisplacementSpringConstant()) {
# Line 260 | Line 277 | namespace OpenMD {
277      // are times when it won't use restraints at all, so only open the
278      // restraint file if we are actually using restraints:
279  
280 <    if (simParam->getUseRestraints()) {
280 >    if (simParam->getUseRestraints()) {
281        std::string refFile = simParam->getRestraint_file();
282 <      RestReader* rr = new RestReader(info, refFile);
266 <
282 >      RestReader* rr = new RestReader(info, refFile, stuntDoubleIndex);
283        rr->readReferenceStructure();
284      }
285  
286      restOutput_ = getPrefix(info_->getFinalConfigFileName()) + ".rest";
287      restOut = new RestWriter(info_, restOutput_.c_str(), restraints_);
272    
288      if(!restOut){
289        sprintf(painCave.errMsg, "Restraint error: Failed to create RestWriter\n");
290        painCave.isFatal = 1;
# Line 292 | Line 307 | namespace OpenMD {
307      currRestTime_ = currSnapshot_->getTime();
308    }
309  
310 <  void RestraintForceManager::calcForces(bool needPotential, bool needStress){
310 >  void RestraintForceManager::calcForces(){
311  
312 <    ForceManager::calcForces(needPotential, needStress);    
312 >    ForceManager::calcForces();    
313      RealType restPot_local, restPot;
314  
315      restPot_local = doRestraints(1.0);
# Line 306 | Line 321 | namespace OpenMD {
321      restPot = restPot_local;
322   #endif
323      currSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot();
324 <    currSnapshot_->statData[Stats::LONG_RANGE_POTENTIAL] += restPot;
325 <    currSnapshot_->statData[Stats::VHARM] = restPot;
324 >    RealType pot = currSnapshot_->getLongRangePotential();
325 >    pot += restPot;
326 >    currSnapshot_->setLongRangePotential(pot);
327 >    currSnapshot_->setRestraintPotential(restPot);
328  
329      //write out forces and current positions of restrained molecules    
330      if (currSnapshot_->getTime() >= currRestTime_){
# Line 322 | Line 339 | namespace OpenMD {
339      Molecule::IntegrableObjectIterator ioi;
340      MolecularRestraint* mRest;
341      StuntDouble* sd;
325    RealType pTot;
342  
343      std::vector<StuntDouble*>::const_iterator ro;
344      ObjectRestraint* oRest;
# Line 374 | Line 390 | namespace OpenMD {
390        std::vector<Vector3d> forces;
391        
392        for(sd = (*rm)->beginIntegrableObject(ioi); sd != NULL;
393 <          sd = (*rm)->nextIntegrableObject(ioi)) {        
393 >          sd = (*rm)->nextIntegrableObject(ioi)) {
394          struc.push_back(sd->getPos());
395        }
396  

Comparing trunk/src/restraints/RestraintForceManager.cpp (property svn:keywords):
Revision 1390 by gezelter, Wed Nov 25 20:02:06 2009 UTC vs.
Revision 1879 by gezelter, Sun Jun 16 15:15:42 2013 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines