1 |
< |
/* |
1 |
> |
/* |
2 |
|
* Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. |
3 |
|
* |
4 |
|
* The University of Notre Dame grants you ("Licensee") a |
52 |
|
#include "brains/SimInfo.hpp" |
53 |
|
#include "math/Vector3.hpp" |
54 |
|
#include "primitives/Molecule.hpp" |
55 |
+ |
#include "UseTheForce/fCutoffPolicy.h" |
56 |
+ |
#include "UseTheForce/DarkSide/fElectrostaticSummationMethod.h" |
57 |
|
#include "UseTheForce/doForces_interface.h" |
58 |
+ |
#include "UseTheForce/DarkSide/electrostatic_interface.h" |
59 |
|
#include "UseTheForce/notifyCutoffs_interface.h" |
60 |
|
#include "utils/MemoryUtils.hpp" |
61 |
|
#include "utils/simError.h" |
68 |
|
|
69 |
|
namespace oopse { |
70 |
|
|
71 |
< |
SimInfo::SimInfo(std::vector<std::pair<MoleculeStamp*, int> >& molStampPairs, |
72 |
< |
ForceField* ff, Globals* simParams) : |
73 |
< |
forceField_(ff), simParams_(simParams), |
74 |
< |
ndf_(0), ndfRaw_(0), ndfTrans_(0), nZconstraint_(0), |
75 |
< |
nGlobalMols_(0), nGlobalAtoms_(0), nGlobalCutoffGroups_(0), |
76 |
< |
nGlobalIntegrableObjects_(0), nGlobalRigidBodies_(0), |
77 |
< |
nAtoms_(0), nBonds_(0), nBends_(0), nTorsions_(0), nRigidBodies_(0), |
78 |
< |
nIntegrableObjects_(0), nCutoffGroups_(0), nConstraints_(0), |
79 |
< |
sman_(NULL), fortranInitialized_(false), selectMan_(NULL) { |
71 |
> |
SimInfo::SimInfo(MakeStamps* stamps, std::vector<std::pair<MoleculeStamp*, int> >& molStampPairs, |
72 |
> |
ForceField* ff, Globals* simParams) : |
73 |
> |
stamps_(stamps), forceField_(ff), simParams_(simParams), |
74 |
> |
ndf_(0), ndfRaw_(0), ndfTrans_(0), nZconstraint_(0), |
75 |
> |
nGlobalMols_(0), nGlobalAtoms_(0), nGlobalCutoffGroups_(0), |
76 |
> |
nGlobalIntegrableObjects_(0), nGlobalRigidBodies_(0), |
77 |
> |
nAtoms_(0), nBonds_(0), nBends_(0), nTorsions_(0), nRigidBodies_(0), |
78 |
> |
nIntegrableObjects_(0), nCutoffGroups_(0), nConstraints_(0), |
79 |
> |
sman_(NULL), fortranInitialized_(false) { |
80 |
|
|
81 |
|
|
82 |
< |
std::vector<std::pair<MoleculeStamp*, int> >::iterator i; |
83 |
< |
MoleculeStamp* molStamp; |
84 |
< |
int nMolWithSameStamp; |
85 |
< |
int nCutoffAtoms = 0; // number of atoms belong to cutoff groups |
86 |
< |
int nGroups = 0; //total cutoff groups defined in meta-data file |
87 |
< |
CutoffGroupStamp* cgStamp; |
88 |
< |
RigidBodyStamp* rbStamp; |
89 |
< |
int nRigidAtoms = 0; |
82 |
> |
std::vector<std::pair<MoleculeStamp*, int> >::iterator i; |
83 |
> |
MoleculeStamp* molStamp; |
84 |
> |
int nMolWithSameStamp; |
85 |
> |
int nCutoffAtoms = 0; // number of atoms belong to cutoff groups |
86 |
> |
int nGroups = 0; //total cutoff groups defined in meta-data file |
87 |
> |
CutoffGroupStamp* cgStamp; |
88 |
> |
RigidBodyStamp* rbStamp; |
89 |
> |
int nRigidAtoms = 0; |
90 |
|
|
91 |
< |
for (i = molStampPairs.begin(); i !=molStampPairs.end(); ++i) { |
91 |
> |
for (i = molStampPairs.begin(); i !=molStampPairs.end(); ++i) { |
92 |
|
molStamp = i->first; |
93 |
|
nMolWithSameStamp = i->second; |
94 |
|
|
103 |
|
int nCutoffGroupsInStamp = molStamp->getNCutoffGroups(); |
104 |
|
|
105 |
|
for (int j=0; j < nCutoffGroupsInStamp; j++) { |
106 |
< |
cgStamp = molStamp->getCutoffGroup(j); |
107 |
< |
nAtomsInGroups += cgStamp->getNMembers(); |
106 |
> |
cgStamp = molStamp->getCutoffGroup(j); |
107 |
> |
nAtomsInGroups += cgStamp->getNMembers(); |
108 |
|
} |
109 |
|
|
110 |
|
nGroups += nCutoffGroupsInStamp * nMolWithSameStamp; |
115 |
|
int nRigidBodiesInStamp = molStamp->getNRigidBodies(); |
116 |
|
|
117 |
|
for (int j=0; j < nRigidBodiesInStamp; j++) { |
118 |
< |
rbStamp = molStamp->getRigidBody(j); |
119 |
< |
nAtomsInRigidBodies += rbStamp->getNMembers(); |
118 |
> |
rbStamp = molStamp->getRigidBody(j); |
119 |
> |
nAtomsInRigidBodies += rbStamp->getNMembers(); |
120 |
|
} |
121 |
|
|
122 |
|
nGlobalRigidBodies_ += nRigidBodiesInStamp * nMolWithSameStamp; |
123 |
|
nRigidAtoms += nAtomsInRigidBodies * nMolWithSameStamp; |
124 |
|
|
125 |
< |
} |
125 |
> |
} |
126 |
|
|
127 |
< |
//every free atom (atom does not belong to cutoff groups) is a cutoff group |
128 |
< |
//therefore the total number of cutoff groups in the system is equal to |
129 |
< |
//the total number of atoms minus number of atoms belong to cutoff group defined in meta-data |
130 |
< |
//file plus the number of cutoff groups defined in meta-data file |
131 |
< |
nGlobalCutoffGroups_ = nGlobalAtoms_ - nCutoffAtoms + nGroups; |
127 |
> |
//every free atom (atom does not belong to cutoff groups) is a cutoff group |
128 |
> |
//therefore the total number of cutoff groups in the system is equal to |
129 |
> |
//the total number of atoms minus number of atoms belong to cutoff group defined in meta-data |
130 |
> |
//file plus the number of cutoff groups defined in meta-data file |
131 |
> |
nGlobalCutoffGroups_ = nGlobalAtoms_ - nCutoffAtoms + nGroups; |
132 |
|
|
133 |
< |
//every free atom (atom does not belong to rigid bodies) is an integrable object |
134 |
< |
//therefore the total number of integrable objects in the system is equal to |
135 |
< |
//the total number of atoms minus number of atoms belong to rigid body defined in meta-data |
136 |
< |
//file plus the number of rigid bodies defined in meta-data file |
137 |
< |
nGlobalIntegrableObjects_ = nGlobalAtoms_ - nRigidAtoms + nGlobalRigidBodies_; |
133 |
> |
//every free atom (atom does not belong to rigid bodies) is an integrable object |
134 |
> |
//therefore the total number of integrable objects in the system is equal to |
135 |
> |
//the total number of atoms minus number of atoms belong to rigid body defined in meta-data |
136 |
> |
//file plus the number of rigid bodies defined in meta-data file |
137 |
> |
nGlobalIntegrableObjects_ = nGlobalAtoms_ - nRigidAtoms + nGlobalRigidBodies_; |
138 |
|
|
139 |
< |
nGlobalMols_ = molStampIds_.size(); |
139 |
> |
nGlobalMols_ = molStampIds_.size(); |
140 |
|
|
141 |
|
#ifdef IS_MPI |
142 |
< |
molToProcMap_.resize(nGlobalMols_); |
142 |
> |
molToProcMap_.resize(nGlobalMols_); |
143 |
|
#endif |
144 |
|
|
145 |
< |
selectMan_ = new SelectionManager(this); |
143 |
< |
selectMan_->selectAll(); |
144 |
< |
} |
145 |
> |
} |
146 |
|
|
147 |
< |
SimInfo::~SimInfo() { |
147 |
> |
SimInfo::~SimInfo() { |
148 |
|
std::map<int, Molecule*>::iterator i; |
149 |
|
for (i = molecules_.begin(); i != molecules_.end(); ++i) { |
150 |
< |
delete i->second; |
150 |
> |
delete i->second; |
151 |
|
} |
152 |
|
molecules_.clear(); |
153 |
< |
|
154 |
< |
MemoryUtils::deletePointers(moleculeStamps_); |
154 |
< |
|
153 |
> |
|
154 |
> |
delete stamps_; |
155 |
|
delete sman_; |
156 |
|
delete simParams_; |
157 |
|
delete forceField_; |
158 |
< |
delete selectMan_; |
159 |
< |
} |
158 |
> |
} |
159 |
|
|
160 |
< |
int SimInfo::getNGlobalConstraints() { |
160 |
> |
int SimInfo::getNGlobalConstraints() { |
161 |
|
int nGlobalConstraints; |
162 |
|
#ifdef IS_MPI |
163 |
|
MPI_Allreduce(&nConstraints_, &nGlobalConstraints, 1, MPI_INT, MPI_SUM, |
166 |
|
nGlobalConstraints = nConstraints_; |
167 |
|
#endif |
168 |
|
return nGlobalConstraints; |
169 |
< |
} |
169 |
> |
} |
170 |
|
|
171 |
< |
bool SimInfo::addMolecule(Molecule* mol) { |
171 |
> |
bool SimInfo::addMolecule(Molecule* mol) { |
172 |
|
MoleculeIterator i; |
173 |
|
|
174 |
|
i = molecules_.find(mol->getGlobalIndex()); |
175 |
|
if (i == molecules_.end() ) { |
176 |
|
|
177 |
< |
molecules_.insert(std::make_pair(mol->getGlobalIndex(), mol)); |
177 |
> |
molecules_.insert(std::make_pair(mol->getGlobalIndex(), mol)); |
178 |
|
|
179 |
< |
nAtoms_ += mol->getNAtoms(); |
180 |
< |
nBonds_ += mol->getNBonds(); |
181 |
< |
nBends_ += mol->getNBends(); |
182 |
< |
nTorsions_ += mol->getNTorsions(); |
183 |
< |
nRigidBodies_ += mol->getNRigidBodies(); |
184 |
< |
nIntegrableObjects_ += mol->getNIntegrableObjects(); |
185 |
< |
nCutoffGroups_ += mol->getNCutoffGroups(); |
186 |
< |
nConstraints_ += mol->getNConstraintPairs(); |
179 |
> |
nAtoms_ += mol->getNAtoms(); |
180 |
> |
nBonds_ += mol->getNBonds(); |
181 |
> |
nBends_ += mol->getNBends(); |
182 |
> |
nTorsions_ += mol->getNTorsions(); |
183 |
> |
nRigidBodies_ += mol->getNRigidBodies(); |
184 |
> |
nIntegrableObjects_ += mol->getNIntegrableObjects(); |
185 |
> |
nCutoffGroups_ += mol->getNCutoffGroups(); |
186 |
> |
nConstraints_ += mol->getNConstraintPairs(); |
187 |
|
|
188 |
< |
addExcludePairs(mol); |
188 |
> |
addExcludePairs(mol); |
189 |
|
|
190 |
< |
return true; |
190 |
> |
return true; |
191 |
|
} else { |
192 |
< |
return false; |
192 |
> |
return false; |
193 |
|
} |
194 |
< |
} |
194 |
> |
} |
195 |
|
|
196 |
< |
bool SimInfo::removeMolecule(Molecule* mol) { |
196 |
> |
bool SimInfo::removeMolecule(Molecule* mol) { |
197 |
|
MoleculeIterator i; |
198 |
|
i = molecules_.find(mol->getGlobalIndex()); |
199 |
|
|
200 |
|
if (i != molecules_.end() ) { |
201 |
|
|
202 |
< |
assert(mol == i->second); |
202 |
> |
assert(mol == i->second); |
203 |
|
|
204 |
< |
nAtoms_ -= mol->getNAtoms(); |
205 |
< |
nBonds_ -= mol->getNBonds(); |
206 |
< |
nBends_ -= mol->getNBends(); |
207 |
< |
nTorsions_ -= mol->getNTorsions(); |
208 |
< |
nRigidBodies_ -= mol->getNRigidBodies(); |
209 |
< |
nIntegrableObjects_ -= mol->getNIntegrableObjects(); |
210 |
< |
nCutoffGroups_ -= mol->getNCutoffGroups(); |
211 |
< |
nConstraints_ -= mol->getNConstraintPairs(); |
213 |
< |
|
214 |
< |
removeExcludePairs(mol); |
215 |
< |
molecules_.erase(mol->getGlobalIndex()); |
204 |
> |
nAtoms_ -= mol->getNAtoms(); |
205 |
> |
nBonds_ -= mol->getNBonds(); |
206 |
> |
nBends_ -= mol->getNBends(); |
207 |
> |
nTorsions_ -= mol->getNTorsions(); |
208 |
> |
nRigidBodies_ -= mol->getNRigidBodies(); |
209 |
> |
nIntegrableObjects_ -= mol->getNIntegrableObjects(); |
210 |
> |
nCutoffGroups_ -= mol->getNCutoffGroups(); |
211 |
> |
nConstraints_ -= mol->getNConstraintPairs(); |
212 |
|
|
213 |
< |
delete mol; |
213 |
> |
removeExcludePairs(mol); |
214 |
> |
molecules_.erase(mol->getGlobalIndex()); |
215 |
> |
|
216 |
> |
delete mol; |
217 |
|
|
218 |
< |
return true; |
218 |
> |
return true; |
219 |
|
} else { |
220 |
< |
return false; |
220 |
> |
return false; |
221 |
|
} |
222 |
|
|
223 |
|
|
224 |
< |
} |
224 |
> |
} |
225 |
|
|
226 |
|
|
227 |
< |
Molecule* SimInfo::beginMolecule(MoleculeIterator& i) { |
227 |
> |
Molecule* SimInfo::beginMolecule(MoleculeIterator& i) { |
228 |
|
i = molecules_.begin(); |
229 |
|
return i == molecules_.end() ? NULL : i->second; |
230 |
< |
} |
230 |
> |
} |
231 |
|
|
232 |
< |
Molecule* SimInfo::nextMolecule(MoleculeIterator& i) { |
232 |
> |
Molecule* SimInfo::nextMolecule(MoleculeIterator& i) { |
233 |
|
++i; |
234 |
|
return i == molecules_.end() ? NULL : i->second; |
235 |
< |
} |
235 |
> |
} |
236 |
|
|
237 |
|
|
238 |
< |
void SimInfo::calcNdf() { |
238 |
> |
void SimInfo::calcNdf() { |
239 |
|
int ndf_local; |
240 |
|
MoleculeIterator i; |
241 |
|
std::vector<StuntDouble*>::iterator j; |
245 |
|
ndf_local = 0; |
246 |
|
|
247 |
|
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
248 |
< |
for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL; |
249 |
< |
integrableObject = mol->nextIntegrableObject(j)) { |
248 |
> |
for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL; |
249 |
> |
integrableObject = mol->nextIntegrableObject(j)) { |
250 |
|
|
251 |
< |
ndf_local += 3; |
251 |
> |
ndf_local += 3; |
252 |
|
|
253 |
< |
if (integrableObject->isDirectional()) { |
254 |
< |
if (integrableObject->isLinear()) { |
255 |
< |
ndf_local += 2; |
256 |
< |
} else { |
257 |
< |
ndf_local += 3; |
258 |
< |
} |
259 |
< |
} |
253 |
> |
if (integrableObject->isDirectional()) { |
254 |
> |
if (integrableObject->isLinear()) { |
255 |
> |
ndf_local += 2; |
256 |
> |
} else { |
257 |
> |
ndf_local += 3; |
258 |
> |
} |
259 |
> |
} |
260 |
|
|
261 |
< |
}//end for (integrableObject) |
261 |
> |
}//end for (integrableObject) |
262 |
|
}// end for (mol) |
263 |
|
|
264 |
|
// n_constraints is local, so subtract them on each processor |
274 |
|
// entire system: |
275 |
|
ndf_ = ndf_ - 3 - nZconstraint_; |
276 |
|
|
277 |
< |
} |
277 |
> |
} |
278 |
|
|
279 |
< |
void SimInfo::calcNdfRaw() { |
279 |
> |
void SimInfo::calcNdfRaw() { |
280 |
|
int ndfRaw_local; |
281 |
|
|
282 |
|
MoleculeIterator i; |
288 |
|
ndfRaw_local = 0; |
289 |
|
|
290 |
|
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
291 |
< |
for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL; |
292 |
< |
integrableObject = mol->nextIntegrableObject(j)) { |
291 |
> |
for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL; |
292 |
> |
integrableObject = mol->nextIntegrableObject(j)) { |
293 |
|
|
294 |
< |
ndfRaw_local += 3; |
294 |
> |
ndfRaw_local += 3; |
295 |
|
|
296 |
< |
if (integrableObject->isDirectional()) { |
297 |
< |
if (integrableObject->isLinear()) { |
298 |
< |
ndfRaw_local += 2; |
299 |
< |
} else { |
300 |
< |
ndfRaw_local += 3; |
301 |
< |
} |
302 |
< |
} |
296 |
> |
if (integrableObject->isDirectional()) { |
297 |
> |
if (integrableObject->isLinear()) { |
298 |
> |
ndfRaw_local += 2; |
299 |
> |
} else { |
300 |
> |
ndfRaw_local += 3; |
301 |
> |
} |
302 |
> |
} |
303 |
|
|
304 |
< |
} |
304 |
> |
} |
305 |
|
} |
306 |
|
|
307 |
|
#ifdef IS_MPI |
309 |
|
#else |
310 |
|
ndfRaw_ = ndfRaw_local; |
311 |
|
#endif |
312 |
< |
} |
312 |
> |
} |
313 |
|
|
314 |
< |
void SimInfo::calcNdfTrans() { |
314 |
> |
void SimInfo::calcNdfTrans() { |
315 |
|
int ndfTrans_local; |
316 |
|
|
317 |
|
ndfTrans_local = 3 * nIntegrableObjects_ - nConstraints_; |
325 |
|
|
326 |
|
ndfTrans_ = ndfTrans_ - 3 - nZconstraint_; |
327 |
|
|
328 |
< |
} |
328 |
> |
} |
329 |
|
|
330 |
< |
void SimInfo::addExcludePairs(Molecule* mol) { |
330 |
> |
void SimInfo::addExcludePairs(Molecule* mol) { |
331 |
|
std::vector<Bond*>::iterator bondIter; |
332 |
|
std::vector<Bend*>::iterator bendIter; |
333 |
|
std::vector<Torsion*>::iterator torsionIter; |
340 |
|
int d; |
341 |
|
|
342 |
|
for (bond= mol->beginBond(bondIter); bond != NULL; bond = mol->nextBond(bondIter)) { |
343 |
< |
a = bond->getAtomA()->getGlobalIndex(); |
344 |
< |
b = bond->getAtomB()->getGlobalIndex(); |
345 |
< |
exclude_.addPair(a, b); |
343 |
> |
a = bond->getAtomA()->getGlobalIndex(); |
344 |
> |
b = bond->getAtomB()->getGlobalIndex(); |
345 |
> |
exclude_.addPair(a, b); |
346 |
|
} |
347 |
|
|
348 |
|
for (bend= mol->beginBend(bendIter); bend != NULL; bend = mol->nextBend(bendIter)) { |
349 |
< |
a = bend->getAtomA()->getGlobalIndex(); |
350 |
< |
b = bend->getAtomB()->getGlobalIndex(); |
351 |
< |
c = bend->getAtomC()->getGlobalIndex(); |
349 |
> |
a = bend->getAtomA()->getGlobalIndex(); |
350 |
> |
b = bend->getAtomB()->getGlobalIndex(); |
351 |
> |
c = bend->getAtomC()->getGlobalIndex(); |
352 |
|
|
353 |
< |
exclude_.addPair(a, b); |
354 |
< |
exclude_.addPair(a, c); |
355 |
< |
exclude_.addPair(b, c); |
353 |
> |
exclude_.addPair(a, b); |
354 |
> |
exclude_.addPair(a, c); |
355 |
> |
exclude_.addPair(b, c); |
356 |
|
} |
357 |
|
|
358 |
|
for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; torsion = mol->nextTorsion(torsionIter)) { |
359 |
< |
a = torsion->getAtomA()->getGlobalIndex(); |
360 |
< |
b = torsion->getAtomB()->getGlobalIndex(); |
361 |
< |
c = torsion->getAtomC()->getGlobalIndex(); |
362 |
< |
d = torsion->getAtomD()->getGlobalIndex(); |
359 |
> |
a = torsion->getAtomA()->getGlobalIndex(); |
360 |
> |
b = torsion->getAtomB()->getGlobalIndex(); |
361 |
> |
c = torsion->getAtomC()->getGlobalIndex(); |
362 |
> |
d = torsion->getAtomD()->getGlobalIndex(); |
363 |
|
|
364 |
< |
exclude_.addPair(a, b); |
365 |
< |
exclude_.addPair(a, c); |
366 |
< |
exclude_.addPair(a, d); |
367 |
< |
exclude_.addPair(b, c); |
368 |
< |
exclude_.addPair(b, d); |
369 |
< |
exclude_.addPair(c, d); |
364 |
> |
exclude_.addPair(a, b); |
365 |
> |
exclude_.addPair(a, c); |
366 |
> |
exclude_.addPair(a, d); |
367 |
> |
exclude_.addPair(b, c); |
368 |
> |
exclude_.addPair(b, d); |
369 |
> |
exclude_.addPair(c, d); |
370 |
|
} |
371 |
|
|
372 |
< |
|
373 |
< |
} |
372 |
> |
Molecule::RigidBodyIterator rbIter; |
373 |
> |
RigidBody* rb; |
374 |
> |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
375 |
> |
std::vector<Atom*> atoms = rb->getAtoms(); |
376 |
> |
for (int i = 0; i < atoms.size() -1 ; ++i) { |
377 |
> |
for (int j = i + 1; j < atoms.size(); ++j) { |
378 |
> |
a = atoms[i]->getGlobalIndex(); |
379 |
> |
b = atoms[j]->getGlobalIndex(); |
380 |
> |
exclude_.addPair(a, b); |
381 |
> |
} |
382 |
> |
} |
383 |
> |
} |
384 |
|
|
385 |
< |
void SimInfo::removeExcludePairs(Molecule* mol) { |
385 |
> |
} |
386 |
> |
|
387 |
> |
void SimInfo::removeExcludePairs(Molecule* mol) { |
388 |
|
std::vector<Bond*>::iterator bondIter; |
389 |
|
std::vector<Bend*>::iterator bendIter; |
390 |
|
std::vector<Torsion*>::iterator torsionIter; |
397 |
|
int d; |
398 |
|
|
399 |
|
for (bond= mol->beginBond(bondIter); bond != NULL; bond = mol->nextBond(bondIter)) { |
400 |
< |
a = bond->getAtomA()->getGlobalIndex(); |
401 |
< |
b = bond->getAtomB()->getGlobalIndex(); |
402 |
< |
exclude_.removePair(a, b); |
400 |
> |
a = bond->getAtomA()->getGlobalIndex(); |
401 |
> |
b = bond->getAtomB()->getGlobalIndex(); |
402 |
> |
exclude_.removePair(a, b); |
403 |
|
} |
404 |
|
|
405 |
|
for (bend= mol->beginBend(bendIter); bend != NULL; bend = mol->nextBend(bendIter)) { |
406 |
< |
a = bend->getAtomA()->getGlobalIndex(); |
407 |
< |
b = bend->getAtomB()->getGlobalIndex(); |
408 |
< |
c = bend->getAtomC()->getGlobalIndex(); |
406 |
> |
a = bend->getAtomA()->getGlobalIndex(); |
407 |
> |
b = bend->getAtomB()->getGlobalIndex(); |
408 |
> |
c = bend->getAtomC()->getGlobalIndex(); |
409 |
|
|
410 |
< |
exclude_.removePair(a, b); |
411 |
< |
exclude_.removePair(a, c); |
412 |
< |
exclude_.removePair(b, c); |
410 |
> |
exclude_.removePair(a, b); |
411 |
> |
exclude_.removePair(a, c); |
412 |
> |
exclude_.removePair(b, c); |
413 |
|
} |
414 |
|
|
415 |
|
for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; torsion = mol->nextTorsion(torsionIter)) { |
416 |
< |
a = torsion->getAtomA()->getGlobalIndex(); |
417 |
< |
b = torsion->getAtomB()->getGlobalIndex(); |
418 |
< |
c = torsion->getAtomC()->getGlobalIndex(); |
419 |
< |
d = torsion->getAtomD()->getGlobalIndex(); |
416 |
> |
a = torsion->getAtomA()->getGlobalIndex(); |
417 |
> |
b = torsion->getAtomB()->getGlobalIndex(); |
418 |
> |
c = torsion->getAtomC()->getGlobalIndex(); |
419 |
> |
d = torsion->getAtomD()->getGlobalIndex(); |
420 |
|
|
421 |
< |
exclude_.removePair(a, b); |
422 |
< |
exclude_.removePair(a, c); |
423 |
< |
exclude_.removePair(a, d); |
424 |
< |
exclude_.removePair(b, c); |
425 |
< |
exclude_.removePair(b, d); |
426 |
< |
exclude_.removePair(c, d); |
421 |
> |
exclude_.removePair(a, b); |
422 |
> |
exclude_.removePair(a, c); |
423 |
> |
exclude_.removePair(a, d); |
424 |
> |
exclude_.removePair(b, c); |
425 |
> |
exclude_.removePair(b, d); |
426 |
> |
exclude_.removePair(c, d); |
427 |
|
} |
428 |
|
|
429 |
< |
} |
429 |
> |
Molecule::RigidBodyIterator rbIter; |
430 |
> |
RigidBody* rb; |
431 |
> |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
432 |
> |
std::vector<Atom*> atoms = rb->getAtoms(); |
433 |
> |
for (int i = 0; i < atoms.size() -1 ; ++i) { |
434 |
> |
for (int j = i + 1; j < atoms.size(); ++j) { |
435 |
> |
a = atoms[i]->getGlobalIndex(); |
436 |
> |
b = atoms[j]->getGlobalIndex(); |
437 |
> |
exclude_.removePair(a, b); |
438 |
> |
} |
439 |
> |
} |
440 |
> |
} |
441 |
|
|
442 |
+ |
} |
443 |
|
|
444 |
< |
void SimInfo::addMoleculeStamp(MoleculeStamp* molStamp, int nmol) { |
444 |
> |
|
445 |
> |
void SimInfo::addMoleculeStamp(MoleculeStamp* molStamp, int nmol) { |
446 |
|
int curStampId; |
447 |
|
|
448 |
|
//index from 0 |
450 |
|
|
451 |
|
moleculeStamps_.push_back(molStamp); |
452 |
|
molStampIds_.insert(molStampIds_.end(), nmol, curStampId); |
453 |
< |
} |
453 |
> |
} |
454 |
|
|
455 |
< |
void SimInfo::update() { |
455 |
> |
void SimInfo::update() { |
456 |
|
|
457 |
|
setupSimType(); |
458 |
|
|
465 |
|
//setup fortran force field |
466 |
|
/** @deprecate */ |
467 |
|
int isError = 0; |
468 |
< |
initFortranFF( &fInfo_.SIM_uses_RF , &isError ); |
468 |
> |
|
469 |
> |
setupElectrostaticSummationMethod( isError ); |
470 |
> |
|
471 |
|
if(isError){ |
472 |
< |
sprintf( painCave.errMsg, |
473 |
< |
"ForceField error: There was an error initializing the forceField in fortran.\n" ); |
474 |
< |
painCave.isFatal = 1; |
475 |
< |
simError(); |
472 |
> |
sprintf( painCave.errMsg, |
473 |
> |
"ForceField error: There was an error initializing the forceField in fortran.\n" ); |
474 |
> |
painCave.isFatal = 1; |
475 |
> |
simError(); |
476 |
|
} |
477 |
|
|
478 |
|
|
483 |
|
calcNdfTrans(); |
484 |
|
|
485 |
|
fortranInitialized_ = true; |
486 |
< |
} |
486 |
> |
} |
487 |
|
|
488 |
< |
std::set<AtomType*> SimInfo::getUniqueAtomTypes() { |
488 |
> |
std::set<AtomType*> SimInfo::getUniqueAtomTypes() { |
489 |
|
SimInfo::MoleculeIterator mi; |
490 |
|
Molecule* mol; |
491 |
|
Molecule::AtomIterator ai; |
494 |
|
|
495 |
|
for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
496 |
|
|
497 |
< |
for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
498 |
< |
atomTypes.insert(atom->getAtomType()); |
499 |
< |
} |
497 |
> |
for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
498 |
> |
atomTypes.insert(atom->getAtomType()); |
499 |
> |
} |
500 |
|
|
501 |
|
} |
502 |
|
|
503 |
|
return atomTypes; |
504 |
< |
} |
504 |
> |
} |
505 |
|
|
506 |
< |
void SimInfo::setupSimType() { |
506 |
> |
void SimInfo::setupSimType() { |
507 |
|
std::set<AtomType*>::iterator i; |
508 |
|
std::set<AtomType*> atomTypes; |
509 |
|
atomTypes = getUniqueAtomTypes(); |
516 |
|
int useDipole = 0; |
517 |
|
int useGayBerne = 0; |
518 |
|
int useSticky = 0; |
519 |
+ |
int useStickyPower = 0; |
520 |
|
int useShape = 0; |
521 |
|
int useFLARB = 0; //it is not in AtomType yet |
522 |
|
int useDirectionalAtom = 0; |
523 |
|
int useElectrostatics = 0; |
524 |
|
//usePBC and useRF are from simParams |
525 |
|
int usePBC = simParams_->getPBC(); |
526 |
< |
int useRF = simParams_->getUseRF(); |
526 |
> |
int useRF; |
527 |
|
|
528 |
+ |
// set the useRF logical |
529 |
+ |
std::string myMethod = simParams_->getElectrostaticSummationMethod(); |
530 |
+ |
if (myMethod == "REACTION_FIELD") |
531 |
+ |
useRF = 1; |
532 |
+ |
else |
533 |
+ |
useRF = 0; |
534 |
+ |
|
535 |
|
//loop over all of the atom types |
536 |
|
for (i = atomTypes.begin(); i != atomTypes.end(); ++i) { |
537 |
< |
useLennardJones |= (*i)->isLennardJones(); |
538 |
< |
useElectrostatic |= (*i)->isElectrostatic(); |
539 |
< |
useEAM |= (*i)->isEAM(); |
540 |
< |
useCharge |= (*i)->isCharge(); |
541 |
< |
useDirectional |= (*i)->isDirectional(); |
542 |
< |
useDipole |= (*i)->isDipole(); |
543 |
< |
useGayBerne |= (*i)->isGayBerne(); |
544 |
< |
useSticky |= (*i)->isSticky(); |
545 |
< |
useShape |= (*i)->isShape(); |
537 |
> |
useLennardJones |= (*i)->isLennardJones(); |
538 |
> |
useElectrostatic |= (*i)->isElectrostatic(); |
539 |
> |
useEAM |= (*i)->isEAM(); |
540 |
> |
useCharge |= (*i)->isCharge(); |
541 |
> |
useDirectional |= (*i)->isDirectional(); |
542 |
> |
useDipole |= (*i)->isDipole(); |
543 |
> |
useGayBerne |= (*i)->isGayBerne(); |
544 |
> |
useSticky |= (*i)->isSticky(); |
545 |
> |
useStickyPower |= (*i)->isStickyPower(); |
546 |
> |
useShape |= (*i)->isShape(); |
547 |
|
} |
548 |
|
|
549 |
< |
if (useSticky || useDipole || useGayBerne || useShape) { |
550 |
< |
useDirectionalAtom = 1; |
549 |
> |
if (useSticky || useStickyPower || useDipole || useGayBerne || useShape) { |
550 |
> |
useDirectionalAtom = 1; |
551 |
|
} |
552 |
|
|
553 |
|
if (useCharge || useDipole) { |
554 |
< |
useElectrostatics = 1; |
554 |
> |
useElectrostatics = 1; |
555 |
|
} |
556 |
|
|
557 |
|
#ifdef IS_MPI |
578 |
|
temp = useSticky; |
579 |
|
MPI_Allreduce(&temp, &useSticky, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
580 |
|
|
581 |
+ |
temp = useStickyPower; |
582 |
+ |
MPI_Allreduce(&temp, &useStickyPower, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
583 |
+ |
|
584 |
|
temp = useGayBerne; |
585 |
|
MPI_Allreduce(&temp, &useGayBerne, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
586 |
|
|
595 |
|
|
596 |
|
temp = useRF; |
597 |
|
MPI_Allreduce(&temp, &useRF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
598 |
< |
|
598 |
> |
|
599 |
|
#endif |
600 |
|
|
601 |
|
fInfo_.SIM_uses_PBC = usePBC; |
605 |
|
fInfo_.SIM_uses_Charges = useCharge; |
606 |
|
fInfo_.SIM_uses_Dipoles = useDipole; |
607 |
|
fInfo_.SIM_uses_Sticky = useSticky; |
608 |
+ |
fInfo_.SIM_uses_StickyPower = useStickyPower; |
609 |
|
fInfo_.SIM_uses_GayBerne = useGayBerne; |
610 |
|
fInfo_.SIM_uses_EAM = useEAM; |
611 |
|
fInfo_.SIM_uses_Shapes = useShape; |
612 |
|
fInfo_.SIM_uses_FLARB = useFLARB; |
613 |
|
fInfo_.SIM_uses_RF = useRF; |
614 |
|
|
615 |
< |
if( fInfo_.SIM_uses_Dipoles && fInfo_.SIM_uses_RF) { |
615 |
> |
if( fInfo_.SIM_uses_Dipoles && myMethod == "REACTION_FIELD") { |
616 |
|
|
617 |
< |
if (simParams_->haveDielectric()) { |
618 |
< |
fInfo_.dielect = simParams_->getDielectric(); |
619 |
< |
} else { |
620 |
< |
sprintf(painCave.errMsg, |
621 |
< |
"SimSetup Error: No Dielectric constant was set.\n" |
622 |
< |
"\tYou are trying to use Reaction Field without" |
623 |
< |
"\tsetting a dielectric constant!\n"); |
624 |
< |
painCave.isFatal = 1; |
625 |
< |
simError(); |
626 |
< |
} |
617 |
> |
if (simParams_->haveDielectric()) { |
618 |
> |
fInfo_.dielect = simParams_->getDielectric(); |
619 |
> |
} else { |
620 |
> |
sprintf(painCave.errMsg, |
621 |
> |
"SimSetup Error: No Dielectric constant was set.\n" |
622 |
> |
"\tYou are trying to use Reaction Field without" |
623 |
> |
"\tsetting a dielectric constant!\n"); |
624 |
> |
painCave.isFatal = 1; |
625 |
> |
simError(); |
626 |
> |
} |
627 |
|
|
628 |
|
} else { |
629 |
< |
fInfo_.dielect = 0.0; |
629 |
> |
fInfo_.dielect = 0.0; |
630 |
|
} |
631 |
|
|
632 |
< |
} |
632 |
> |
} |
633 |
|
|
634 |
< |
void SimInfo::setupFortranSim() { |
634 |
> |
void SimInfo::setupFortranSim() { |
635 |
|
int isError; |
636 |
|
int nExclude; |
637 |
|
std::vector<int> fortranGlobalGroupMembership; |
641 |
|
|
642 |
|
//globalGroupMembership_ is filled by SimCreator |
643 |
|
for (int i = 0; i < nGlobalAtoms_; i++) { |
644 |
< |
fortranGlobalGroupMembership.push_back(globalGroupMembership_[i] + 1); |
644 |
> |
fortranGlobalGroupMembership.push_back(globalGroupMembership_[i] + 1); |
645 |
|
} |
646 |
|
|
647 |
|
//calculate mass ratio of cutoff group |
658 |
|
mfact.reserve(getNCutoffGroups()); |
659 |
|
|
660 |
|
for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
661 |
< |
for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { |
661 |
> |
for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { |
662 |
|
|
663 |
< |
totalMass = cg->getMass(); |
664 |
< |
for(atom = cg->beginAtom(ai); atom != NULL; atom = cg->nextAtom(ai)) { |
665 |
< |
mfact.push_back(atom->getMass()/totalMass); |
666 |
< |
} |
663 |
> |
totalMass = cg->getMass(); |
664 |
> |
for(atom = cg->beginAtom(ai); atom != NULL; atom = cg->nextAtom(ai)) { |
665 |
> |
mfact.push_back(atom->getMass()/totalMass); |
666 |
> |
} |
667 |
|
|
668 |
< |
} |
668 |
> |
} |
669 |
|
} |
670 |
|
|
671 |
|
//fill ident array of local atoms (it is actually ident of AtomType, it is so confusing !!!) |
675 |
|
identArray.reserve(getNAtoms()); |
676 |
|
|
677 |
|
for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
678 |
< |
for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
679 |
< |
identArray.push_back(atom->getIdent()); |
680 |
< |
} |
678 |
> |
for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
679 |
> |
identArray.push_back(atom->getIdent()); |
680 |
> |
} |
681 |
|
} |
682 |
|
|
683 |
|
//fill molMembershipArray |
684 |
|
//molMembershipArray is filled by SimCreator |
685 |
|
std::vector<int> molMembershipArray(nGlobalAtoms_); |
686 |
|
for (int i = 0; i < nGlobalAtoms_; i++) { |
687 |
< |
molMembershipArray[i] = globalMolMembership_[i] + 1; |
687 |
> |
molMembershipArray[i] = globalMolMembership_[i] + 1; |
688 |
|
} |
689 |
|
|
690 |
|
//setup fortran simulation |
652 |
– |
//gloalExcludes and molMembershipArray should go away (They are never used) |
653 |
– |
//why the hell fortran need to know molecule? |
654 |
– |
//OOPSE = Object-Obfuscated Parallel Simulation Engine |
691 |
|
int nGlobalExcludes = 0; |
692 |
|
int* globalExcludes = NULL; |
693 |
|
int* excludeList = exclude_.getExcludeList(); |
694 |
|
setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray[0], &nExclude, excludeList , |
695 |
< |
&nGlobalExcludes, globalExcludes, &molMembershipArray[0], |
696 |
< |
&mfact[0], &nCutoffGroups_, &fortranGlobalGroupMembership[0], &isError); |
695 |
> |
&nGlobalExcludes, globalExcludes, &molMembershipArray[0], |
696 |
> |
&mfact[0], &nCutoffGroups_, &fortranGlobalGroupMembership[0], &isError); |
697 |
|
|
698 |
|
if( isError ){ |
699 |
|
|
700 |
< |
sprintf( painCave.errMsg, |
701 |
< |
"There was an error setting the simulation information in fortran.\n" ); |
702 |
< |
painCave.isFatal = 1; |
703 |
< |
painCave.severity = OOPSE_ERROR; |
704 |
< |
simError(); |
700 |
> |
sprintf( painCave.errMsg, |
701 |
> |
"There was an error setting the simulation information in fortran.\n" ); |
702 |
> |
painCave.isFatal = 1; |
703 |
> |
painCave.severity = OOPSE_ERROR; |
704 |
> |
simError(); |
705 |
|
} |
706 |
|
|
707 |
|
#ifdef IS_MPI |
708 |
|
sprintf( checkPointMsg, |
709 |
< |
"succesfully sent the simulation information to fortran.\n"); |
709 |
> |
"succesfully sent the simulation information to fortran.\n"); |
710 |
|
MPIcheckPoint(); |
711 |
|
#endif // is_mpi |
712 |
< |
} |
712 |
> |
} |
713 |
|
|
714 |
|
|
715 |
|
#ifdef IS_MPI |
716 |
< |
void SimInfo::setupFortranParallel() { |
716 |
> |
void SimInfo::setupFortranParallel() { |
717 |
|
|
718 |
|
//SimInfo is responsible for creating localToGlobalAtomIndex and localToGlobalGroupIndex |
719 |
|
std::vector<int> localToGlobalAtomIndex(getNAtoms(), 0); |
729 |
|
|
730 |
|
for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
731 |
|
|
732 |
< |
//local index(index in DataStorge) of atom is important |
733 |
< |
for (atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
734 |
< |
localToGlobalAtomIndex[atom->getLocalIndex()] = atom->getGlobalIndex() + 1; |
735 |
< |
} |
732 |
> |
//local index(index in DataStorge) of atom is important |
733 |
> |
for (atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
734 |
> |
localToGlobalAtomIndex[atom->getLocalIndex()] = atom->getGlobalIndex() + 1; |
735 |
> |
} |
736 |
|
|
737 |
< |
//local index of cutoff group is trivial, it only depends on the order of travesing |
738 |
< |
for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { |
739 |
< |
localToGlobalCutoffGroupIndex.push_back(cg->getGlobalIndex() + 1); |
740 |
< |
} |
737 |
> |
//local index of cutoff group is trivial, it only depends on the order of travesing |
738 |
> |
for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { |
739 |
> |
localToGlobalCutoffGroupIndex.push_back(cg->getGlobalIndex() + 1); |
740 |
> |
} |
741 |
|
|
742 |
|
} |
743 |
|
|
757 |
|
&localToGlobalCutoffGroupIndex[0], &isError); |
758 |
|
|
759 |
|
if (isError) { |
760 |
< |
sprintf(painCave.errMsg, |
761 |
< |
"mpiRefresh errror: fortran didn't like something we gave it.\n"); |
762 |
< |
painCave.isFatal = 1; |
763 |
< |
simError(); |
760 |
> |
sprintf(painCave.errMsg, |
761 |
> |
"mpiRefresh errror: fortran didn't like something we gave it.\n"); |
762 |
> |
painCave.isFatal = 1; |
763 |
> |
simError(); |
764 |
|
} |
765 |
|
|
766 |
|
sprintf(checkPointMsg, " mpiRefresh successful.\n"); |
767 |
|
MPIcheckPoint(); |
768 |
|
|
769 |
|
|
770 |
< |
} |
770 |
> |
} |
771 |
|
|
772 |
|
#endif |
773 |
|
|
774 |
< |
double SimInfo::calcMaxCutoffRadius() { |
774 |
> |
double SimInfo::calcMaxCutoffRadius() { |
775 |
|
|
776 |
|
|
777 |
|
std::set<AtomType*> atomTypes; |
783 |
|
|
784 |
|
//query the max cutoff radius among these atom types |
785 |
|
for (i = atomTypes.begin(); i != atomTypes.end(); ++i) { |
786 |
< |
cutoffRadius.push_back(forceField_->getRcutFromAtomType(*i)); |
786 |
> |
cutoffRadius.push_back(forceField_->getRcutFromAtomType(*i)); |
787 |
|
} |
788 |
|
|
789 |
|
double maxCutoffRadius = *(std::max_element(cutoffRadius.begin(), cutoffRadius.end())); |
792 |
|
#endif |
793 |
|
|
794 |
|
return maxCutoffRadius; |
795 |
< |
} |
795 |
> |
} |
796 |
|
|
797 |
< |
void SimInfo::getCutoff(double& rcut, double& rsw) { |
797 |
> |
void SimInfo::getCutoff(double& rcut, double& rsw) { |
798 |
|
|
799 |
|
if (fInfo_.SIM_uses_Charges | fInfo_.SIM_uses_Dipoles | fInfo_.SIM_uses_RF) { |
800 |
|
|
801 |
< |
if (!simParams_->haveRcut()){ |
802 |
< |
sprintf(painCave.errMsg, |
801 |
> |
if (!simParams_->haveRcut()){ |
802 |
> |
sprintf(painCave.errMsg, |
803 |
|
"SimCreator Warning: No value was set for the cutoffRadius.\n" |
804 |
|
"\tOOPSE will use a default value of 15.0 angstroms" |
805 |
|
"\tfor the cutoffRadius.\n"); |
806 |
< |
painCave.isFatal = 0; |
807 |
< |
simError(); |
808 |
< |
rcut = 15.0; |
809 |
< |
} else{ |
810 |
< |
rcut = simParams_->getRcut(); |
811 |
< |
} |
806 |
> |
painCave.isFatal = 0; |
807 |
> |
simError(); |
808 |
> |
rcut = 15.0; |
809 |
> |
} else{ |
810 |
> |
rcut = simParams_->getRcut(); |
811 |
> |
} |
812 |
|
|
813 |
< |
if (!simParams_->haveRsw()){ |
814 |
< |
sprintf(painCave.errMsg, |
813 |
> |
if (!simParams_->haveRsw()){ |
814 |
> |
sprintf(painCave.errMsg, |
815 |
|
"SimCreator Warning: No value was set for switchingRadius.\n" |
816 |
|
"\tOOPSE will use a default value of\n" |
817 |
|
"\t0.95 * cutoffRadius for the switchingRadius\n"); |
818 |
< |
painCave.isFatal = 0; |
819 |
< |
simError(); |
820 |
< |
rsw = 0.95 * rcut; |
821 |
< |
} else{ |
822 |
< |
rsw = simParams_->getRsw(); |
823 |
< |
} |
818 |
> |
painCave.isFatal = 0; |
819 |
> |
simError(); |
820 |
> |
rsw = 0.95 * rcut; |
821 |
> |
} else{ |
822 |
> |
rsw = simParams_->getRsw(); |
823 |
> |
} |
824 |
|
|
825 |
|
} else { |
826 |
< |
// if charge, dipole or reaction field is not used and the cutofff radius is not specified in |
827 |
< |
//meta-data file, the maximum cutoff radius calculated from forcefiled will be used |
826 |
> |
// if charge, dipole or reaction field is not used and the cutofff radius is not specified in |
827 |
> |
//meta-data file, the maximum cutoff radius calculated from forcefiled will be used |
828 |
|
|
829 |
< |
if (simParams_->haveRcut()) { |
830 |
< |
rcut = simParams_->getRcut(); |
831 |
< |
} else { |
832 |
< |
//set cutoff radius to the maximum cutoff radius based on atom types in the whole system |
833 |
< |
rcut = calcMaxCutoffRadius(); |
834 |
< |
} |
829 |
> |
if (simParams_->haveRcut()) { |
830 |
> |
rcut = simParams_->getRcut(); |
831 |
> |
} else { |
832 |
> |
//set cutoff radius to the maximum cutoff radius based on atom types in the whole system |
833 |
> |
rcut = calcMaxCutoffRadius(); |
834 |
> |
} |
835 |
|
|
836 |
< |
if (simParams_->haveRsw()) { |
837 |
< |
rsw = simParams_->getRsw(); |
838 |
< |
} else { |
839 |
< |
rsw = rcut; |
840 |
< |
} |
836 |
> |
if (simParams_->haveRsw()) { |
837 |
> |
rsw = simParams_->getRsw(); |
838 |
> |
} else { |
839 |
> |
rsw = rcut; |
840 |
> |
} |
841 |
|
|
842 |
|
} |
843 |
< |
} |
843 |
> |
} |
844 |
|
|
845 |
< |
void SimInfo::setupCutoff() { |
845 |
> |
void SimInfo::setupCutoff() { |
846 |
|
getCutoff(rcut_, rsw_); |
847 |
|
double rnblist = rcut_ + 1; // skin of neighbor list |
848 |
|
|
849 |
|
//Pass these cutoff radius etc. to fortran. This function should be called once and only once |
850 |
< |
notifyFortranCutoffs(&rcut_, &rsw_, &rnblist); |
851 |
< |
} |
850 |
> |
|
851 |
> |
int cp = TRADITIONAL_CUTOFF_POLICY; |
852 |
> |
if (simParams_->haveCutoffPolicy()) { |
853 |
> |
std::string myPolicy = simParams_->getCutoffPolicy(); |
854 |
> |
if (myPolicy == "MIX") { |
855 |
> |
cp = MIX_CUTOFF_POLICY; |
856 |
> |
} else { |
857 |
> |
if (myPolicy == "MAX") { |
858 |
> |
cp = MAX_CUTOFF_POLICY; |
859 |
> |
} else { |
860 |
> |
if (myPolicy == "TRADITIONAL") { |
861 |
> |
cp = TRADITIONAL_CUTOFF_POLICY; |
862 |
> |
} else { |
863 |
> |
// throw error |
864 |
> |
sprintf( painCave.errMsg, |
865 |
> |
"SimInfo error: Unknown cutoffPolicy. (Input file specified %s .)\n\tcutoffPolicy must be one of: \"Mix\", \"Max\", or \"Traditional\".", myPolicy.c_str() ); |
866 |
> |
painCave.isFatal = 1; |
867 |
> |
simError(); |
868 |
> |
} |
869 |
> |
} |
870 |
> |
} |
871 |
> |
} |
872 |
> |
notifyFortranCutoffs(&rcut_, &rsw_, &rnblist, &cp); |
873 |
> |
// also send cutoff notification to electrostatics |
874 |
> |
setElectrostaticCutoffRadius(&rcut_); |
875 |
> |
} |
876 |
|
|
877 |
< |
void SimInfo::addProperty(GenericData* genData) { |
877 |
> |
void SimInfo::setupElectrostaticSummationMethod( int isError ) { |
878 |
> |
|
879 |
> |
int errorOut; |
880 |
> |
int esm = NONE; |
881 |
> |
double alphaVal; |
882 |
> |
double dielectric; |
883 |
> |
|
884 |
> |
errorOut = isError; |
885 |
> |
alphaVal = simParams_->getDampingAlpha(); |
886 |
> |
dielectric = simParams_->getDielectric(); |
887 |
> |
|
888 |
> |
if (simParams_->haveElectrostaticSummationMethod()) { |
889 |
> |
std::string myMethod = simParams_->getElectrostaticSummationMethod(); |
890 |
> |
if (myMethod == "NONE") { |
891 |
> |
esm = NONE; |
892 |
> |
} else { |
893 |
> |
if (myMethod == "UNDAMPED_WOLF") { |
894 |
> |
esm = UNDAMPED_WOLF; |
895 |
> |
} else { |
896 |
> |
if (myMethod == "DAMPED_WOLF") { |
897 |
> |
esm = DAMPED_WOLF; |
898 |
> |
if (!simParams_->haveDampingAlpha()) { |
899 |
> |
//throw error |
900 |
> |
sprintf( painCave.errMsg, |
901 |
> |
"SimInfo warning: dampingAlpha was not specified in the input file. A default value of %f (1/ang) will be used for the Damped Wolf Method.", alphaVal); |
902 |
> |
painCave.isFatal = 0; |
903 |
> |
simError(); |
904 |
> |
} |
905 |
> |
} else { |
906 |
> |
if (myMethod == "REACTION_FIELD") { |
907 |
> |
esm = REACTION_FIELD; |
908 |
> |
} else { |
909 |
> |
// throw error |
910 |
> |
sprintf( painCave.errMsg, |
911 |
> |
"SimInfo error: Unknown electrostaticSummationMethod. (Input file specified %s .)\n\telectrostaticSummationMethod must be one of: \"none\", \"undamped_wolf\", \"damped_wolf\", or \"reaction_field\".", myMethod.c_str() ); |
912 |
> |
painCave.isFatal = 1; |
913 |
> |
simError(); |
914 |
> |
} |
915 |
> |
} |
916 |
> |
} |
917 |
> |
} |
918 |
> |
} |
919 |
> |
// let's pass some summation method variables to fortran |
920 |
> |
setElectrostaticSummationMethod( &esm ); |
921 |
> |
setDampedWolfAlpha( &alphaVal ); |
922 |
> |
setReactionFieldDielectric( &dielectric ); |
923 |
> |
initFortranFF( &esm, &errorOut ); |
924 |
> |
} |
925 |
> |
|
926 |
> |
void SimInfo::addProperty(GenericData* genData) { |
927 |
|
properties_.addProperty(genData); |
928 |
< |
} |
928 |
> |
} |
929 |
|
|
930 |
< |
void SimInfo::removeProperty(const std::string& propName) { |
930 |
> |
void SimInfo::removeProperty(const std::string& propName) { |
931 |
|
properties_.removeProperty(propName); |
932 |
< |
} |
932 |
> |
} |
933 |
|
|
934 |
< |
void SimInfo::clearProperties() { |
934 |
> |
void SimInfo::clearProperties() { |
935 |
|
properties_.clearProperties(); |
936 |
< |
} |
936 |
> |
} |
937 |
|
|
938 |
< |
std::vector<std::string> SimInfo::getPropertyNames() { |
938 |
> |
std::vector<std::string> SimInfo::getPropertyNames() { |
939 |
|
return properties_.getPropertyNames(); |
940 |
< |
} |
940 |
> |
} |
941 |
|
|
942 |
< |
std::vector<GenericData*> SimInfo::getProperties() { |
942 |
> |
std::vector<GenericData*> SimInfo::getProperties() { |
943 |
|
return properties_.getProperties(); |
944 |
< |
} |
944 |
> |
} |
945 |
|
|
946 |
< |
GenericData* SimInfo::getPropertyByName(const std::string& propName) { |
947 |
< |
return properties_.getPropertyByName(propName); |
948 |
< |
} |
946 |
> |
GenericData* SimInfo::getPropertyByName(const std::string& propName) { |
947 |
> |
return properties_.getPropertyByName(propName); |
948 |
> |
} |
949 |
|
|
950 |
< |
void SimInfo::setSnapshotManager(SnapshotManager* sman) { |
951 |
< |
//if (sman_ == sman_) { |
952 |
< |
// return; |
953 |
< |
//} |
954 |
< |
|
846 |
< |
//delete sman_; |
950 |
> |
void SimInfo::setSnapshotManager(SnapshotManager* sman) { |
951 |
> |
if (sman_ == sman) { |
952 |
> |
return; |
953 |
> |
} |
954 |
> |
delete sman_; |
955 |
|
sman_ = sman; |
956 |
|
|
957 |
|
Molecule* mol; |
963 |
|
|
964 |
|
for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
965 |
|
|
966 |
< |
for (atom = mol->beginAtom(atomIter); atom != NULL; atom = mol->nextAtom(atomIter)) { |
967 |
< |
atom->setSnapshotManager(sman_); |
968 |
< |
} |
966 |
> |
for (atom = mol->beginAtom(atomIter); atom != NULL; atom = mol->nextAtom(atomIter)) { |
967 |
> |
atom->setSnapshotManager(sman_); |
968 |
> |
} |
969 |
|
|
970 |
< |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
971 |
< |
rb->setSnapshotManager(sman_); |
972 |
< |
} |
970 |
> |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
971 |
> |
rb->setSnapshotManager(sman_); |
972 |
> |
} |
973 |
|
} |
974 |
|
|
975 |
< |
} |
975 |
> |
} |
976 |
|
|
977 |
< |
Vector3d SimInfo::getComVel(){ |
977 |
> |
Vector3d SimInfo::getComVel(){ |
978 |
|
SimInfo::MoleculeIterator i; |
979 |
|
Molecule* mol; |
980 |
|
|
983 |
|
|
984 |
|
|
985 |
|
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
986 |
< |
double mass = mol->getMass(); |
987 |
< |
totalMass += mass; |
988 |
< |
comVel += mass * mol->getComVel(); |
986 |
> |
double mass = mol->getMass(); |
987 |
> |
totalMass += mass; |
988 |
> |
comVel += mass * mol->getComVel(); |
989 |
|
} |
990 |
|
|
991 |
|
#ifdef IS_MPI |
998 |
|
comVel /= totalMass; |
999 |
|
|
1000 |
|
return comVel; |
1001 |
< |
} |
1001 |
> |
} |
1002 |
|
|
1003 |
< |
Vector3d SimInfo::getCom(){ |
1003 |
> |
Vector3d SimInfo::getCom(){ |
1004 |
|
SimInfo::MoleculeIterator i; |
1005 |
|
Molecule* mol; |
1006 |
|
|
1008 |
|
double totalMass = 0.0; |
1009 |
|
|
1010 |
|
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
1011 |
< |
double mass = mol->getMass(); |
1012 |
< |
totalMass += mass; |
1013 |
< |
com += mass * mol->getCom(); |
1011 |
> |
double mass = mol->getMass(); |
1012 |
> |
totalMass += mass; |
1013 |
> |
com += mass * mol->getCom(); |
1014 |
|
} |
1015 |
|
|
1016 |
|
#ifdef IS_MPI |
1024 |
|
|
1025 |
|
return com; |
1026 |
|
|
1027 |
< |
} |
1027 |
> |
} |
1028 |
|
|
1029 |
< |
std::ostream& operator <<(std::ostream& o, SimInfo& info) { |
1029 |
> |
std::ostream& operator <<(std::ostream& o, SimInfo& info) { |
1030 |
|
|
1031 |
|
return o; |
1032 |
< |
} |
1032 |
> |
} |
1033 |
> |
|
1034 |
> |
|
1035 |
> |
/* |
1036 |
> |
Returns center of mass and center of mass velocity in one function call. |
1037 |
> |
*/ |
1038 |
> |
|
1039 |
> |
void SimInfo::getComAll(Vector3d &com, Vector3d &comVel){ |
1040 |
> |
SimInfo::MoleculeIterator i; |
1041 |
> |
Molecule* mol; |
1042 |
> |
|
1043 |
> |
|
1044 |
> |
double totalMass = 0.0; |
1045 |
> |
|
1046 |
|
|
1047 |
+ |
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
1048 |
+ |
double mass = mol->getMass(); |
1049 |
+ |
totalMass += mass; |
1050 |
+ |
com += mass * mol->getCom(); |
1051 |
+ |
comVel += mass * mol->getComVel(); |
1052 |
+ |
} |
1053 |
+ |
|
1054 |
+ |
#ifdef IS_MPI |
1055 |
+ |
double tmpMass = totalMass; |
1056 |
+ |
Vector3d tmpCom(com); |
1057 |
+ |
Vector3d tmpComVel(comVel); |
1058 |
+ |
MPI_Allreduce(&tmpMass,&totalMass,1,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1059 |
+ |
MPI_Allreduce(tmpCom.getArrayPointer(), com.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1060 |
+ |
MPI_Allreduce(tmpComVel.getArrayPointer(), comVel.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1061 |
+ |
#endif |
1062 |
+ |
|
1063 |
+ |
com /= totalMass; |
1064 |
+ |
comVel /= totalMass; |
1065 |
+ |
} |
1066 |
+ |
|
1067 |
+ |
/* |
1068 |
+ |
Return intertia tensor for entire system and angular momentum Vector. |
1069 |
+ |
|
1070 |
+ |
|
1071 |
+ |
[ Ixx -Ixy -Ixz ] |
1072 |
+ |
J =| -Iyx Iyy -Iyz | |
1073 |
+ |
[ -Izx -Iyz Izz ] |
1074 |
+ |
*/ |
1075 |
+ |
|
1076 |
+ |
void SimInfo::getInertiaTensor(Mat3x3d &inertiaTensor, Vector3d &angularMomentum){ |
1077 |
+ |
|
1078 |
+ |
|
1079 |
+ |
double xx = 0.0; |
1080 |
+ |
double yy = 0.0; |
1081 |
+ |
double zz = 0.0; |
1082 |
+ |
double xy = 0.0; |
1083 |
+ |
double xz = 0.0; |
1084 |
+ |
double yz = 0.0; |
1085 |
+ |
Vector3d com(0.0); |
1086 |
+ |
Vector3d comVel(0.0); |
1087 |
+ |
|
1088 |
+ |
getComAll(com, comVel); |
1089 |
+ |
|
1090 |
+ |
SimInfo::MoleculeIterator i; |
1091 |
+ |
Molecule* mol; |
1092 |
+ |
|
1093 |
+ |
Vector3d thisq(0.0); |
1094 |
+ |
Vector3d thisv(0.0); |
1095 |
+ |
|
1096 |
+ |
double thisMass = 0.0; |
1097 |
+ |
|
1098 |
+ |
|
1099 |
+ |
|
1100 |
+ |
|
1101 |
+ |
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
1102 |
+ |
|
1103 |
+ |
thisq = mol->getCom()-com; |
1104 |
+ |
thisv = mol->getComVel()-comVel; |
1105 |
+ |
thisMass = mol->getMass(); |
1106 |
+ |
// Compute moment of intertia coefficients. |
1107 |
+ |
xx += thisq[0]*thisq[0]*thisMass; |
1108 |
+ |
yy += thisq[1]*thisq[1]*thisMass; |
1109 |
+ |
zz += thisq[2]*thisq[2]*thisMass; |
1110 |
+ |
|
1111 |
+ |
// compute products of intertia |
1112 |
+ |
xy += thisq[0]*thisq[1]*thisMass; |
1113 |
+ |
xz += thisq[0]*thisq[2]*thisMass; |
1114 |
+ |
yz += thisq[1]*thisq[2]*thisMass; |
1115 |
+ |
|
1116 |
+ |
angularMomentum += cross( thisq, thisv ) * thisMass; |
1117 |
+ |
|
1118 |
+ |
} |
1119 |
+ |
|
1120 |
+ |
|
1121 |
+ |
inertiaTensor(0,0) = yy + zz; |
1122 |
+ |
inertiaTensor(0,1) = -xy; |
1123 |
+ |
inertiaTensor(0,2) = -xz; |
1124 |
+ |
inertiaTensor(1,0) = -xy; |
1125 |
+ |
inertiaTensor(1,1) = xx + zz; |
1126 |
+ |
inertiaTensor(1,2) = -yz; |
1127 |
+ |
inertiaTensor(2,0) = -xz; |
1128 |
+ |
inertiaTensor(2,1) = -yz; |
1129 |
+ |
inertiaTensor(2,2) = xx + yy; |
1130 |
+ |
|
1131 |
+ |
#ifdef IS_MPI |
1132 |
+ |
Mat3x3d tmpI(inertiaTensor); |
1133 |
+ |
Vector3d tmpAngMom; |
1134 |
+ |
MPI_Allreduce(tmpI.getArrayPointer(), inertiaTensor.getArrayPointer(),9,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1135 |
+ |
MPI_Allreduce(tmpAngMom.getArrayPointer(), angularMomentum.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1136 |
+ |
#endif |
1137 |
+ |
|
1138 |
+ |
return; |
1139 |
+ |
} |
1140 |
+ |
|
1141 |
+ |
//Returns the angular momentum of the system |
1142 |
+ |
Vector3d SimInfo::getAngularMomentum(){ |
1143 |
+ |
|
1144 |
+ |
Vector3d com(0.0); |
1145 |
+ |
Vector3d comVel(0.0); |
1146 |
+ |
Vector3d angularMomentum(0.0); |
1147 |
+ |
|
1148 |
+ |
getComAll(com,comVel); |
1149 |
+ |
|
1150 |
+ |
SimInfo::MoleculeIterator i; |
1151 |
+ |
Molecule* mol; |
1152 |
+ |
|
1153 |
+ |
Vector3d thisr(0.0); |
1154 |
+ |
Vector3d thisp(0.0); |
1155 |
+ |
|
1156 |
+ |
double thisMass; |
1157 |
+ |
|
1158 |
+ |
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
1159 |
+ |
thisMass = mol->getMass(); |
1160 |
+ |
thisr = mol->getCom()-com; |
1161 |
+ |
thisp = (mol->getComVel()-comVel)*thisMass; |
1162 |
+ |
|
1163 |
+ |
angularMomentum += cross( thisr, thisp ); |
1164 |
+ |
|
1165 |
+ |
} |
1166 |
+ |
|
1167 |
+ |
#ifdef IS_MPI |
1168 |
+ |
Vector3d tmpAngMom; |
1169 |
+ |
MPI_Allreduce(tmpAngMom.getArrayPointer(), angularMomentum.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1170 |
+ |
#endif |
1171 |
+ |
|
1172 |
+ |
return angularMomentum; |
1173 |
+ |
} |
1174 |
+ |
|
1175 |
+ |
|
1176 |
|
}//end namespace oopse |
1177 |
|
|