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 |
|
#include <cmath> |
45 |
|
#include "restraints/ObjectRestraint.hpp" |
46 |
|
#include "io/RestReader.hpp" |
47 |
|
#include "utils/simError.h" |
48 |
< |
#include "utils/OOPSEConstant.hpp" |
48 |
> |
#include "utils/PhysicalConstants.hpp" |
49 |
|
#include "utils/StringUtils.hpp" |
50 |
|
#include "selection/SelectionEvaluator.hpp" |
51 |
|
#include "selection/SelectionManager.hpp" |
54 |
|
#endif |
55 |
|
|
56 |
|
|
57 |
< |
namespace oopse { |
57 |
> |
namespace OpenMD { |
58 |
|
|
59 |
|
RestraintForceManager::RestraintForceManager(SimInfo* info): ForceManager(info) { |
60 |
|
|
89 |
|
int nRestraintStamps = simParam->getNRestraintStamps(); |
90 |
|
std::vector<RestraintStamp*> stamp = simParam->getRestraintStamps(); |
91 |
|
|
92 |
+ |
std::vector<int> stuntDoubleIndex; |
93 |
+ |
|
94 |
|
for (int i = 0; i < nRestraintStamps; i++){ |
95 |
|
|
96 |
|
std::string myType = toUpperCopy(stamp[i]->getType()); |
111 |
|
molIndex = stamp[i]->getMolIndex(); |
112 |
|
} |
113 |
|
|
114 |
< |
Molecule* mol = info_->getMoleculeByGlobalIndex(molIndex); |
113 |
< |
|
114 |
< |
if (mol == NULL) { |
114 |
> |
if (molIndex < 0) { |
115 |
|
sprintf(painCave.errMsg, |
116 |
< |
"Restraint Error: A molecular restraint was specified, but\n" |
117 |
< |
"\tno molecule was found with global index %d.\n", |
118 |
< |
molIndex); |
116 |
> |
"Restraint Error: A molecular restraint was specified\n" |
117 |
> |
"\twith a molIndex that was less than 0\n"); |
118 |
|
painCave.isFatal = 1; |
119 |
|
simError(); |
120 |
+ |
} |
121 |
+ |
if (molIndex >= info_->getNGlobalMolecules()) { |
122 |
+ |
sprintf(painCave.errMsg, |
123 |
+ |
"Restraint Error: A molecular restraint was specified with\n" |
124 |
+ |
"\ta molIndex that was greater than the total number of molecules\n"); |
125 |
+ |
painCave.isFatal = 1; |
126 |
+ |
simError(); |
127 |
+ |
} |
128 |
+ |
|
129 |
+ |
Molecule* mol = info_->getMoleculeByGlobalIndex(molIndex); |
130 |
+ |
|
131 |
+ |
if (mol == NULL) { |
132 |
+ |
#ifdef IS_MPI |
133 |
+ |
// getMoleculeByGlobalIndex returns a NULL in parallel if |
134 |
+ |
// this proc doesn't have the molecule. Do a quick check to |
135 |
+ |
// make sure another processor is supposed to have it. |
136 |
+ |
|
137 |
+ |
int myrank = MPI::COMM_WORLD.Get_rank(); |
138 |
+ |
if (info_->getMolToProc(molIndex) == myrank) { |
139 |
+ |
|
140 |
+ |
// If we were supposed to have it but got a null, then freak out. |
141 |
+ |
#endif |
142 |
+ |
|
143 |
+ |
sprintf(painCave.errMsg, |
144 |
+ |
"Restraint Error: A molecular restraint was specified, but\n" |
145 |
+ |
"\tno molecule was found with global index %d.\n", |
146 |
+ |
molIndex); |
147 |
+ |
painCave.isFatal = 1; |
148 |
+ |
simError(); |
149 |
+ |
|
150 |
+ |
#ifdef IS_MPI |
151 |
+ |
} |
152 |
+ |
#endif |
153 |
|
} |
154 |
|
|
155 |
+ |
|
156 |
+ |
#ifdef IS_MPI |
157 |
+ |
// only handle this molecular restraint if this processor owns the |
158 |
+ |
// molecule |
159 |
+ |
int myrank = MPI::COMM_WORLD.Get_rank(); |
160 |
+ |
if (info_->getMolToProc(molIndex) == myrank) { |
161 |
+ |
|
162 |
+ |
#endif |
163 |
+ |
|
164 |
|
MolecularRestraint* rest = new MolecularRestraint(); |
165 |
|
|
166 |
|
std::string restPre("mol_"); |
196 |
|
restraints_.push_back(rest); |
197 |
|
mol->addProperty(new RestraintData("Restraint", rest)); |
198 |
|
restrainedMols_.push_back(mol); |
199 |
< |
|
199 |
> |
#ifdef IS_MPI |
200 |
> |
} |
201 |
> |
#endif |
202 |
|
} else if (myType.compare("OBJECT") == 0) { |
203 |
|
|
204 |
|
std::string objectSelection; |
234 |
|
|
235 |
|
for (sd = seleMan.beginSelected(selei); sd != NULL; |
236 |
|
sd = seleMan.nextSelected(selei)) { |
237 |
< |
|
237 |
> |
stuntDoubleIndex.push_back(sd->getGlobalIntegrableObjectIndex()); |
238 |
> |
|
239 |
|
ObjectRestraint* rest = new ObjectRestraint(); |
240 |
|
|
241 |
|
if (stamp[i]->haveDisplacementSpringConstant()) { |
275 |
|
// are times when it won't use restraints at all, so only open the |
276 |
|
// restraint file if we are actually using restraints: |
277 |
|
|
278 |
< |
if (simParam->getUseRestraints()) { |
278 |
> |
if (simParam->getUseRestraints()) { |
279 |
|
std::string refFile = simParam->getRestraint_file(); |
280 |
< |
RestReader* rr = new RestReader(info, refFile); |
237 |
< |
|
280 |
> |
RestReader* rr = new RestReader(info, refFile, stuntDoubleIndex); |
281 |
|
rr->readReferenceStructure(); |
282 |
|
} |
283 |
|
|
284 |
|
restOutput_ = getPrefix(info_->getFinalConfigFileName()) + ".rest"; |
285 |
|
restOut = new RestWriter(info_, restOutput_.c_str(), restraints_); |
243 |
– |
|
286 |
|
if(!restOut){ |
287 |
|
sprintf(painCave.errMsg, "Restraint error: Failed to create RestWriter\n"); |
288 |
|
painCave.isFatal = 1; |
305 |
|
currRestTime_ = currSnapshot_->getTime(); |
306 |
|
} |
307 |
|
|
308 |
< |
void RestraintForceManager::calcForces(bool needPotential, bool needStress){ |
308 |
> |
void RestraintForceManager::calcForces(){ |
309 |
|
|
310 |
< |
ForceManager::calcForces(needPotential, needStress); |
310 |
> |
ForceManager::calcForces(); |
311 |
|
RealType restPot_local, restPot; |
312 |
|
|
313 |
|
restPot_local = doRestraints(1.0); |
360 |
|
if (mRest == NULL) { |
361 |
|
sprintf( painCave.errMsg, |
362 |
|
"Can not cast RestraintData to MolecularRestraint\n"); |
363 |
< |
painCave.severity = OOPSE_ERROR; |
363 |
> |
painCave.severity = OPENMD_ERROR; |
364 |
|
painCave.isFatal = 1; |
365 |
|
simError(); |
366 |
|
} |
367 |
|
} else { |
368 |
|
sprintf( painCave.errMsg, |
369 |
|
"Can not cast GenericData to RestraintData\n"); |
370 |
< |
painCave.severity = OOPSE_ERROR; |
370 |
> |
painCave.severity = OPENMD_ERROR; |
371 |
|
painCave.isFatal = 1; |
372 |
|
simError(); |
373 |
|
} |
374 |
|
} else { |
375 |
|
sprintf( painCave.errMsg, "Can not find Restraint for RestrainedObject\n"); |
376 |
< |
painCave.severity = OOPSE_ERROR; |
376 |
> |
painCave.severity = OPENMD_ERROR; |
377 |
|
painCave.isFatal = 1; |
378 |
|
simError(); |
379 |
|
} |
387 |
|
std::vector<Vector3d> forces; |
388 |
|
|
389 |
|
for(sd = (*rm)->beginIntegrableObject(ioi); sd != NULL; |
390 |
< |
sd = (*rm)->nextIntegrableObject(ioi)) { |
390 |
> |
sd = (*rm)->nextIntegrableObject(ioi)) { |
391 |
|
struc.push_back(sd->getPos()); |
392 |
|
} |
393 |
|
|
425 |
|
if (oRest == NULL) { |
426 |
|
sprintf( painCave.errMsg, |
427 |
|
"Can not cast RestraintData to ObjectRestraint\n"); |
428 |
< |
painCave.severity = OOPSE_ERROR; |
428 |
> |
painCave.severity = OPENMD_ERROR; |
429 |
|
painCave.isFatal = 1; |
430 |
|
simError(); |
431 |
|
} |
432 |
|
} else { |
433 |
|
sprintf( painCave.errMsg, |
434 |
|
"Can not cast GenericData to RestraintData\n"); |
435 |
< |
painCave.severity = OOPSE_ERROR; |
435 |
> |
painCave.severity = OPENMD_ERROR; |
436 |
|
painCave.isFatal = 1; |
437 |
|
simError(); |
438 |
|
} |
439 |
|
} else { |
440 |
|
sprintf( painCave.errMsg, "Can not find Restraint for RestrainedObject\n"); |
441 |
< |
painCave.severity = OOPSE_ERROR; |
441 |
> |
painCave.severity = OPENMD_ERROR; |
442 |
|
painCave.isFatal = 1; |
443 |
|
simError(); |
444 |
|
} |