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 |
+ |
#ifdef IS_MPI |
44 |
+ |
#include <mpi.h> |
45 |
+ |
#endif |
46 |
+ |
|
47 |
+ |
#include "config.h" |
48 |
|
#include <cmath> |
49 |
+ |
|
50 |
|
#include "restraints/RestraintForceManager.hpp" |
51 |
|
#include "restraints/MolecularRestraint.hpp" |
52 |
|
#include "restraints/ObjectRestraint.hpp" |
56 |
|
#include "utils/StringUtils.hpp" |
57 |
|
#include "selection/SelectionEvaluator.hpp" |
58 |
|
#include "selection/SelectionManager.hpp" |
52 |
– |
#ifdef IS_MPI |
53 |
– |
#include <mpi.h> |
54 |
– |
#endif |
59 |
|
|
56 |
– |
|
60 |
|
namespace OpenMD { |
61 |
|
|
62 |
|
RestraintForceManager::RestraintForceManager(SimInfo* info): ForceManager(info) { |
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()); |
101 |
|
if (myType.compare("MOLECULAR")==0){ |
102 |
|
|
103 |
|
int molIndex; |
99 |
– |
std::vector<Vector3d> ref; |
104 |
|
Vector3d refCom; |
105 |
|
|
106 |
|
if (!stamp[i]->haveMolIndex()) { |
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 |
|
|
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_"); |
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; |
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()) { |
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; |
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); |
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_){ |
339 |
|
Molecule::IntegrableObjectIterator ioi; |
340 |
|
MolecularRestraint* mRest; |
341 |
|
StuntDouble* sd; |
325 |
– |
RealType pTot; |
342 |
|
|
343 |
|
std::vector<StuntDouble*>::const_iterator ro; |
344 |
|
ObjectRestraint* oRest; |
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 |
|
|