# | Line 1 | Line 1 | |
---|---|---|
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 | |
# | Line 65 | Line 65 | namespace oopse { | |
65 | ||
66 | namespace oopse { | |
67 | ||
68 | < | SimInfo::SimInfo(std::vector<std::pair<MoleculeStamp*, int> >& molStampPairs, |
69 | < | ForceField* ff, Globals* simParams) : |
70 | < | forceField_(ff), simParams_(simParams), |
71 | < | ndf_(0), ndfRaw_(0), ndfTrans_(0), nZconstraint_(0), |
72 | < | nGlobalMols_(0), nGlobalAtoms_(0), nGlobalCutoffGroups_(0), |
73 | < | nGlobalIntegrableObjects_(0), nGlobalRigidBodies_(0), |
74 | < | nAtoms_(0), nBonds_(0), nBends_(0), nTorsions_(0), nRigidBodies_(0), |
75 | < | nIntegrableObjects_(0), nCutoffGroups_(0), nConstraints_(0), |
76 | < | sman_(NULL), fortranInitialized_(false) { |
68 | > | SimInfo::SimInfo(MakeStamps* stamps, std::vector<std::pair<MoleculeStamp*, int> >& molStampPairs, |
69 | > | ForceField* ff, Globals* simParams) : |
70 | > | stamps_(stamps), forceField_(ff), simParams_(simParams), |
71 | > | ndf_(0), ndfRaw_(0), ndfTrans_(0), nZconstraint_(0), |
72 | > | nGlobalMols_(0), nGlobalAtoms_(0), nGlobalCutoffGroups_(0), |
73 | > | nGlobalIntegrableObjects_(0), nGlobalRigidBodies_(0), |
74 | > | nAtoms_(0), nBonds_(0), nBends_(0), nTorsions_(0), nRigidBodies_(0), |
75 | > | nIntegrableObjects_(0), nCutoffGroups_(0), nConstraints_(0), |
76 | > | sman_(NULL), fortranInitialized_(false) { |
77 | ||
78 | ||
79 | < | std::vector<std::pair<MoleculeStamp*, int> >::iterator i; |
80 | < | MoleculeStamp* molStamp; |
81 | < | int nMolWithSameStamp; |
82 | < | int nCutoffAtoms = 0; // number of atoms belong to cutoff groups |
83 | < | int nGroups = 0; //total cutoff groups defined in meta-data file |
84 | < | CutoffGroupStamp* cgStamp; |
85 | < | RigidBodyStamp* rbStamp; |
86 | < | int nRigidAtoms = 0; |
79 | > | std::vector<std::pair<MoleculeStamp*, int> >::iterator i; |
80 | > | MoleculeStamp* molStamp; |
81 | > | int nMolWithSameStamp; |
82 | > | int nCutoffAtoms = 0; // number of atoms belong to cutoff groups |
83 | > | int nGroups = 0; //total cutoff groups defined in meta-data file |
84 | > | CutoffGroupStamp* cgStamp; |
85 | > | RigidBodyStamp* rbStamp; |
86 | > | int nRigidAtoms = 0; |
87 | ||
88 | < | for (i = molStampPairs.begin(); i !=molStampPairs.end(); ++i) { |
88 | > | for (i = molStampPairs.begin(); i !=molStampPairs.end(); ++i) { |
89 | molStamp = i->first; | |
90 | nMolWithSameStamp = i->second; | |
91 | ||
# | Line 100 | Line 100 | SimInfo::SimInfo(std::vector<std::pair<MoleculeStamp*, | |
100 | int nCutoffGroupsInStamp = molStamp->getNCutoffGroups(); | |
101 | ||
102 | for (int j=0; j < nCutoffGroupsInStamp; j++) { | |
103 | < | cgStamp = molStamp->getCutoffGroup(j); |
104 | < | nAtomsInGroups += cgStamp->getNMembers(); |
103 | > | cgStamp = molStamp->getCutoffGroup(j); |
104 | > | nAtomsInGroups += cgStamp->getNMembers(); |
105 | } | |
106 | ||
107 | nGroups += nCutoffGroupsInStamp * nMolWithSameStamp; | |
# | Line 112 | Line 112 | SimInfo::SimInfo(std::vector<std::pair<MoleculeStamp*, | |
112 | int nRigidBodiesInStamp = molStamp->getNRigidBodies(); | |
113 | ||
114 | for (int j=0; j < nRigidBodiesInStamp; j++) { | |
115 | < | rbStamp = molStamp->getRigidBody(j); |
116 | < | nAtomsInRigidBodies += rbStamp->getNMembers(); |
115 | > | rbStamp = molStamp->getRigidBody(j); |
116 | > | nAtomsInRigidBodies += rbStamp->getNMembers(); |
117 | } | |
118 | ||
119 | nGlobalRigidBodies_ += nRigidBodiesInStamp * nMolWithSameStamp; | |
120 | nRigidAtoms += nAtomsInRigidBodies * nMolWithSameStamp; | |
121 | ||
122 | < | } |
122 | > | } |
123 | ||
124 | < | //every free atom (atom does not belong to cutoff groups) is a cutoff group |
125 | < | //therefore the total number of cutoff groups in the system is equal to |
126 | < | //the total number of atoms minus number of atoms belong to cutoff group defined in meta-data |
127 | < | //file plus the number of cutoff groups defined in meta-data file |
128 | < | nGlobalCutoffGroups_ = nGlobalAtoms_ - nCutoffAtoms + nGroups; |
124 | > | //every free atom (atom does not belong to cutoff groups) is a cutoff group |
125 | > | //therefore the total number of cutoff groups in the system is equal to |
126 | > | //the total number of atoms minus number of atoms belong to cutoff group defined in meta-data |
127 | > | //file plus the number of cutoff groups defined in meta-data file |
128 | > | nGlobalCutoffGroups_ = nGlobalAtoms_ - nCutoffAtoms + nGroups; |
129 | ||
130 | < | //every free atom (atom does not belong to rigid bodies) is an integrable object |
131 | < | //therefore the total number of integrable objects in the system is equal to |
132 | < | //the total number of atoms minus number of atoms belong to rigid body defined in meta-data |
133 | < | //file plus the number of rigid bodies defined in meta-data file |
134 | < | nGlobalIntegrableObjects_ = nGlobalAtoms_ - nRigidAtoms + nGlobalRigidBodies_; |
130 | > | //every free atom (atom does not belong to rigid bodies) is an integrable object |
131 | > | //therefore the total number of integrable objects in the system is equal to |
132 | > | //the total number of atoms minus number of atoms belong to rigid body defined in meta-data |
133 | > | //file plus the number of rigid bodies defined in meta-data file |
134 | > | nGlobalIntegrableObjects_ = nGlobalAtoms_ - nRigidAtoms + nGlobalRigidBodies_; |
135 | ||
136 | < | nGlobalMols_ = molStampIds_.size(); |
136 | > | nGlobalMols_ = molStampIds_.size(); |
137 | ||
138 | #ifdef IS_MPI | |
139 | < | molToProcMap_.resize(nGlobalMols_); |
139 | > | molToProcMap_.resize(nGlobalMols_); |
140 | #endif | |
141 | ||
142 | < | } |
142 | > | } |
143 | ||
144 | < | SimInfo::~SimInfo() { |
144 | > | SimInfo::~SimInfo() { |
145 | std::map<int, Molecule*>::iterator i; | |
146 | for (i = molecules_.begin(); i != molecules_.end(); ++i) { | |
147 | < | delete i->second; |
147 | > | delete i->second; |
148 | } | |
149 | molecules_.clear(); | |
150 | < | |
151 | < | MemoryUtils::deletePointers(moleculeStamps_); |
152 | < | |
150 | > | |
151 | > | delete stamps_; |
152 | delete sman_; | |
153 | delete simParams_; | |
154 | delete forceField_; | |
155 | < | } |
155 | > | } |
156 | ||
157 | < | int SimInfo::getNGlobalConstraints() { |
157 | > | int SimInfo::getNGlobalConstraints() { |
158 | int nGlobalConstraints; | |
159 | #ifdef IS_MPI | |
160 | MPI_Allreduce(&nConstraints_, &nGlobalConstraints, 1, MPI_INT, MPI_SUM, | |
# | Line 164 | Line 163 | int SimInfo::getNGlobalConstraints() { | |
163 | nGlobalConstraints = nConstraints_; | |
164 | #endif | |
165 | return nGlobalConstraints; | |
166 | < | } |
166 | > | } |
167 | ||
168 | < | bool SimInfo::addMolecule(Molecule* mol) { |
168 | > | bool SimInfo::addMolecule(Molecule* mol) { |
169 | MoleculeIterator i; | |
170 | ||
171 | i = molecules_.find(mol->getGlobalIndex()); | |
172 | if (i == molecules_.end() ) { | |
173 | ||
174 | < | molecules_.insert(std::make_pair(mol->getGlobalIndex(), mol)); |
174 | > | molecules_.insert(std::make_pair(mol->getGlobalIndex(), mol)); |
175 | ||
176 | < | nAtoms_ += mol->getNAtoms(); |
177 | < | nBonds_ += mol->getNBonds(); |
178 | < | nBends_ += mol->getNBends(); |
179 | < | nTorsions_ += mol->getNTorsions(); |
180 | < | nRigidBodies_ += mol->getNRigidBodies(); |
181 | < | nIntegrableObjects_ += mol->getNIntegrableObjects(); |
182 | < | nCutoffGroups_ += mol->getNCutoffGroups(); |
183 | < | nConstraints_ += mol->getNConstraintPairs(); |
176 | > | nAtoms_ += mol->getNAtoms(); |
177 | > | nBonds_ += mol->getNBonds(); |
178 | > | nBends_ += mol->getNBends(); |
179 | > | nTorsions_ += mol->getNTorsions(); |
180 | > | nRigidBodies_ += mol->getNRigidBodies(); |
181 | > | nIntegrableObjects_ += mol->getNIntegrableObjects(); |
182 | > | nCutoffGroups_ += mol->getNCutoffGroups(); |
183 | > | nConstraints_ += mol->getNConstraintPairs(); |
184 | ||
185 | < | addExcludePairs(mol); |
185 | > | addExcludePairs(mol); |
186 | ||
187 | < | return true; |
187 | > | return true; |
188 | } else { | |
189 | < | return false; |
189 | > | return false; |
190 | } | |
191 | < | } |
191 | > | } |
192 | ||
193 | < | bool SimInfo::removeMolecule(Molecule* mol) { |
193 | > | bool SimInfo::removeMolecule(Molecule* mol) { |
194 | MoleculeIterator i; | |
195 | i = molecules_.find(mol->getGlobalIndex()); | |
196 | ||
197 | if (i != molecules_.end() ) { | |
198 | ||
199 | < | assert(mol == i->second); |
199 | > | assert(mol == i->second); |
200 | ||
201 | < | nAtoms_ -= mol->getNAtoms(); |
202 | < | nBonds_ -= mol->getNBonds(); |
203 | < | nBends_ -= mol->getNBends(); |
204 | < | nTorsions_ -= mol->getNTorsions(); |
205 | < | nRigidBodies_ -= mol->getNRigidBodies(); |
206 | < | nIntegrableObjects_ -= mol->getNIntegrableObjects(); |
207 | < | nCutoffGroups_ -= mol->getNCutoffGroups(); |
208 | < | nConstraints_ -= mol->getNConstraintPairs(); |
201 | > | nAtoms_ -= mol->getNAtoms(); |
202 | > | nBonds_ -= mol->getNBonds(); |
203 | > | nBends_ -= mol->getNBends(); |
204 | > | nTorsions_ -= mol->getNTorsions(); |
205 | > | nRigidBodies_ -= mol->getNRigidBodies(); |
206 | > | nIntegrableObjects_ -= mol->getNIntegrableObjects(); |
207 | > | nCutoffGroups_ -= mol->getNCutoffGroups(); |
208 | > | nConstraints_ -= mol->getNConstraintPairs(); |
209 | ||
210 | < | removeExcludePairs(mol); |
211 | < | molecules_.erase(mol->getGlobalIndex()); |
210 | > | removeExcludePairs(mol); |
211 | > | molecules_.erase(mol->getGlobalIndex()); |
212 | ||
213 | < | delete mol; |
213 | > | delete mol; |
214 | ||
215 | < | return true; |
215 | > | return true; |
216 | } else { | |
217 | < | return false; |
217 | > | return false; |
218 | } | |
219 | ||
220 | ||
221 | < | } |
221 | > | } |
222 | ||
223 | ||
224 | < | Molecule* SimInfo::beginMolecule(MoleculeIterator& i) { |
224 | > | Molecule* SimInfo::beginMolecule(MoleculeIterator& i) { |
225 | i = molecules_.begin(); | |
226 | return i == molecules_.end() ? NULL : i->second; | |
227 | < | } |
227 | > | } |
228 | ||
229 | < | Molecule* SimInfo::nextMolecule(MoleculeIterator& i) { |
229 | > | Molecule* SimInfo::nextMolecule(MoleculeIterator& i) { |
230 | ++i; | |
231 | return i == molecules_.end() ? NULL : i->second; | |
232 | < | } |
232 | > | } |
233 | ||
234 | ||
235 | < | void SimInfo::calcNdf() { |
235 | > | void SimInfo::calcNdf() { |
236 | int ndf_local; | |
237 | MoleculeIterator i; | |
238 | std::vector<StuntDouble*>::iterator j; | |
# | Line 243 | Line 242 | void SimInfo::calcNdf() { | |
242 | ndf_local = 0; | |
243 | ||
244 | for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { | |
245 | < | for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL; |
246 | < | integrableObject = mol->nextIntegrableObject(j)) { |
245 | > | for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL; |
246 | > | integrableObject = mol->nextIntegrableObject(j)) { |
247 | ||
248 | < | ndf_local += 3; |
248 | > | ndf_local += 3; |
249 | ||
250 | < | if (integrableObject->isDirectional()) { |
251 | < | if (integrableObject->isLinear()) { |
252 | < | ndf_local += 2; |
253 | < | } else { |
254 | < | ndf_local += 3; |
255 | < | } |
256 | < | } |
250 | > | if (integrableObject->isDirectional()) { |
251 | > | if (integrableObject->isLinear()) { |
252 | > | ndf_local += 2; |
253 | > | } else { |
254 | > | ndf_local += 3; |
255 | > | } |
256 | > | } |
257 | ||
258 | < | }//end for (integrableObject) |
258 | > | }//end for (integrableObject) |
259 | }// end for (mol) | |
260 | ||
261 | // n_constraints is local, so subtract them on each processor | |
# | Line 272 | Line 271 | void SimInfo::calcNdf() { | |
271 | // entire system: | |
272 | ndf_ = ndf_ - 3 - nZconstraint_; | |
273 | ||
274 | < | } |
274 | > | } |
275 | ||
276 | < | void SimInfo::calcNdfRaw() { |
276 | > | void SimInfo::calcNdfRaw() { |
277 | int ndfRaw_local; | |
278 | ||
279 | MoleculeIterator i; | |
# | Line 286 | Line 285 | void SimInfo::calcNdfRaw() { | |
285 | ndfRaw_local = 0; | |
286 | ||
287 | for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { | |
288 | < | for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL; |
289 | < | integrableObject = mol->nextIntegrableObject(j)) { |
288 | > | for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL; |
289 | > | integrableObject = mol->nextIntegrableObject(j)) { |
290 | ||
291 | < | ndfRaw_local += 3; |
291 | > | ndfRaw_local += 3; |
292 | ||
293 | < | if (integrableObject->isDirectional()) { |
294 | < | if (integrableObject->isLinear()) { |
295 | < | ndfRaw_local += 2; |
296 | < | } else { |
297 | < | ndfRaw_local += 3; |
298 | < | } |
299 | < | } |
293 | > | if (integrableObject->isDirectional()) { |
294 | > | if (integrableObject->isLinear()) { |
295 | > | ndfRaw_local += 2; |
296 | > | } else { |
297 | > | ndfRaw_local += 3; |
298 | > | } |
299 | > | } |
300 | ||
301 | < | } |
301 | > | } |
302 | } | |
303 | ||
304 | #ifdef IS_MPI | |
# | Line 307 | Line 306 | void SimInfo::calcNdfRaw() { | |
306 | #else | |
307 | ndfRaw_ = ndfRaw_local; | |
308 | #endif | |
309 | < | } |
309 | > | } |
310 | ||
311 | < | void SimInfo::calcNdfTrans() { |
311 | > | void SimInfo::calcNdfTrans() { |
312 | int ndfTrans_local; | |
313 | ||
314 | ndfTrans_local = 3 * nIntegrableObjects_ - nConstraints_; | |
# | Line 323 | Line 322 | void SimInfo::calcNdfTrans() { | |
322 | ||
323 | ndfTrans_ = ndfTrans_ - 3 - nZconstraint_; | |
324 | ||
325 | < | } |
325 | > | } |
326 | ||
327 | < | void SimInfo::addExcludePairs(Molecule* mol) { |
327 | > | void SimInfo::addExcludePairs(Molecule* mol) { |
328 | std::vector<Bond*>::iterator bondIter; | |
329 | std::vector<Bend*>::iterator bendIter; | |
330 | std::vector<Torsion*>::iterator torsionIter; | |
# | Line 338 | Line 337 | void SimInfo::addExcludePairs(Molecule* mol) { | |
337 | int d; | |
338 | ||
339 | for (bond= mol->beginBond(bondIter); bond != NULL; bond = mol->nextBond(bondIter)) { | |
340 | < | a = bond->getAtomA()->getGlobalIndex(); |
341 | < | b = bond->getAtomB()->getGlobalIndex(); |
342 | < | exclude_.addPair(a, b); |
340 | > | a = bond->getAtomA()->getGlobalIndex(); |
341 | > | b = bond->getAtomB()->getGlobalIndex(); |
342 | > | exclude_.addPair(a, b); |
343 | } | |
344 | ||
345 | for (bend= mol->beginBend(bendIter); bend != NULL; bend = mol->nextBend(bendIter)) { | |
346 | < | a = bend->getAtomA()->getGlobalIndex(); |
347 | < | b = bend->getAtomB()->getGlobalIndex(); |
348 | < | c = bend->getAtomC()->getGlobalIndex(); |
346 | > | a = bend->getAtomA()->getGlobalIndex(); |
347 | > | b = bend->getAtomB()->getGlobalIndex(); |
348 | > | c = bend->getAtomC()->getGlobalIndex(); |
349 | ||
350 | < | exclude_.addPair(a, b); |
351 | < | exclude_.addPair(a, c); |
352 | < | exclude_.addPair(b, c); |
350 | > | exclude_.addPair(a, b); |
351 | > | exclude_.addPair(a, c); |
352 | > | exclude_.addPair(b, c); |
353 | } | |
354 | ||
355 | for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; torsion = mol->nextTorsion(torsionIter)) { | |
356 | < | a = torsion->getAtomA()->getGlobalIndex(); |
357 | < | b = torsion->getAtomB()->getGlobalIndex(); |
358 | < | c = torsion->getAtomC()->getGlobalIndex(); |
359 | < | d = torsion->getAtomD()->getGlobalIndex(); |
356 | > | a = torsion->getAtomA()->getGlobalIndex(); |
357 | > | b = torsion->getAtomB()->getGlobalIndex(); |
358 | > | c = torsion->getAtomC()->getGlobalIndex(); |
359 | > | d = torsion->getAtomD()->getGlobalIndex(); |
360 | ||
361 | < | exclude_.addPair(a, b); |
362 | < | exclude_.addPair(a, c); |
363 | < | exclude_.addPair(a, d); |
364 | < | exclude_.addPair(b, c); |
365 | < | exclude_.addPair(b, d); |
366 | < | exclude_.addPair(c, d); |
361 | > | exclude_.addPair(a, b); |
362 | > | exclude_.addPair(a, c); |
363 | > | exclude_.addPair(a, d); |
364 | > | exclude_.addPair(b, c); |
365 | > | exclude_.addPair(b, d); |
366 | > | exclude_.addPair(c, d); |
367 | } | |
368 | ||
369 | Molecule::RigidBodyIterator rbIter; | |
370 | RigidBody* rb; | |
371 | for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { | |
372 | < | std::vector<Atom*> atoms = rb->getAtoms(); |
373 | < | for (int i = 0; i < atoms.size() -1 ; ++i) { |
374 | < | for (int j = i + 1; j < atoms.size(); ++j) { |
375 | < | a = atoms[i]->getGlobalIndex(); |
376 | < | b = atoms[j]->getGlobalIndex(); |
377 | < | exclude_.addPair(a, b); |
378 | < | } |
379 | < | } |
372 | > | std::vector<Atom*> atoms = rb->getAtoms(); |
373 | > | for (int i = 0; i < atoms.size() -1 ; ++i) { |
374 | > | for (int j = i + 1; j < atoms.size(); ++j) { |
375 | > | a = atoms[i]->getGlobalIndex(); |
376 | > | b = atoms[j]->getGlobalIndex(); |
377 | > | exclude_.addPair(a, b); |
378 | > | } |
379 | > | } |
380 | } | |
381 | ||
382 | < | } |
382 | > | } |
383 | ||
384 | < | void SimInfo::removeExcludePairs(Molecule* mol) { |
384 | > | void SimInfo::removeExcludePairs(Molecule* mol) { |
385 | std::vector<Bond*>::iterator bondIter; | |
386 | std::vector<Bend*>::iterator bendIter; | |
387 | std::vector<Torsion*>::iterator torsionIter; | |
# | Line 395 | Line 394 | void SimInfo::removeExcludePairs(Molecule* mol) { | |
394 | int d; | |
395 | ||
396 | for (bond= mol->beginBond(bondIter); bond != NULL; bond = mol->nextBond(bondIter)) { | |
397 | < | a = bond->getAtomA()->getGlobalIndex(); |
398 | < | b = bond->getAtomB()->getGlobalIndex(); |
399 | < | exclude_.removePair(a, b); |
397 | > | a = bond->getAtomA()->getGlobalIndex(); |
398 | > | b = bond->getAtomB()->getGlobalIndex(); |
399 | > | exclude_.removePair(a, b); |
400 | } | |
401 | ||
402 | for (bend= mol->beginBend(bendIter); bend != NULL; bend = mol->nextBend(bendIter)) { | |
403 | < | a = bend->getAtomA()->getGlobalIndex(); |
404 | < | b = bend->getAtomB()->getGlobalIndex(); |
405 | < | c = bend->getAtomC()->getGlobalIndex(); |
403 | > | a = bend->getAtomA()->getGlobalIndex(); |
404 | > | b = bend->getAtomB()->getGlobalIndex(); |
405 | > | c = bend->getAtomC()->getGlobalIndex(); |
406 | ||
407 | < | exclude_.removePair(a, b); |
408 | < | exclude_.removePair(a, c); |
409 | < | exclude_.removePair(b, c); |
407 | > | exclude_.removePair(a, b); |
408 | > | exclude_.removePair(a, c); |
409 | > | exclude_.removePair(b, c); |
410 | } | |
411 | ||
412 | for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; torsion = mol->nextTorsion(torsionIter)) { | |
413 | < | a = torsion->getAtomA()->getGlobalIndex(); |
414 | < | b = torsion->getAtomB()->getGlobalIndex(); |
415 | < | c = torsion->getAtomC()->getGlobalIndex(); |
416 | < | d = torsion->getAtomD()->getGlobalIndex(); |
413 | > | a = torsion->getAtomA()->getGlobalIndex(); |
414 | > | b = torsion->getAtomB()->getGlobalIndex(); |
415 | > | c = torsion->getAtomC()->getGlobalIndex(); |
416 | > | d = torsion->getAtomD()->getGlobalIndex(); |
417 | ||
418 | < | exclude_.removePair(a, b); |
419 | < | exclude_.removePair(a, c); |
420 | < | exclude_.removePair(a, d); |
421 | < | exclude_.removePair(b, c); |
422 | < | exclude_.removePair(b, d); |
423 | < | exclude_.removePair(c, d); |
418 | > | exclude_.removePair(a, b); |
419 | > | exclude_.removePair(a, c); |
420 | > | exclude_.removePair(a, d); |
421 | > | exclude_.removePair(b, c); |
422 | > | exclude_.removePair(b, d); |
423 | > | exclude_.removePair(c, d); |
424 | } | |
425 | ||
426 | Molecule::RigidBodyIterator rbIter; | |
427 | RigidBody* rb; | |
428 | for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { | |
429 | < | std::vector<Atom*> atoms = rb->getAtoms(); |
430 | < | for (int i = 0; i < atoms.size() -1 ; ++i) { |
431 | < | for (int j = i + 1; j < atoms.size(); ++j) { |
432 | < | a = atoms[i]->getGlobalIndex(); |
433 | < | b = atoms[j]->getGlobalIndex(); |
434 | < | exclude_.removePair(a, b); |
435 | < | } |
436 | < | } |
429 | > | std::vector<Atom*> atoms = rb->getAtoms(); |
430 | > | for (int i = 0; i < atoms.size() -1 ; ++i) { |
431 | > | for (int j = i + 1; j < atoms.size(); ++j) { |
432 | > | a = atoms[i]->getGlobalIndex(); |
433 | > | b = atoms[j]->getGlobalIndex(); |
434 | > | exclude_.removePair(a, b); |
435 | > | } |
436 | > | } |
437 | } | |
438 | ||
439 | < | } |
439 | > | } |
440 | ||
441 | ||
442 | < | void SimInfo::addMoleculeStamp(MoleculeStamp* molStamp, int nmol) { |
442 | > | void SimInfo::addMoleculeStamp(MoleculeStamp* molStamp, int nmol) { |
443 | int curStampId; | |
444 | ||
445 | //index from 0 | |
# | Line 448 | Line 447 | void SimInfo::addMoleculeStamp(MoleculeStamp* molStamp | |
447 | ||
448 | moleculeStamps_.push_back(molStamp); | |
449 | molStampIds_.insert(molStampIds_.end(), nmol, curStampId); | |
450 | < | } |
450 | > | } |
451 | ||
452 | < | void SimInfo::update() { |
452 | > | void SimInfo::update() { |
453 | ||
454 | setupSimType(); | |
455 | ||
# | Line 463 | Line 462 | void SimInfo::update() { | |
462 | //setup fortran force field | |
463 | /** @deprecate */ | |
464 | int isError = 0; | |
465 | < | initFortranFF( &fInfo_.SIM_uses_RF , &isError ); |
465 | > | initFortranFF( &fInfo_.SIM_uses_RF, &fInfo_.SIM_uses_UW, |
466 | > | &fInfo_.SIM_uses_DW, &isError ); |
467 | if(isError){ | |
468 | < | sprintf( painCave.errMsg, |
469 | < | "ForceField error: There was an error initializing the forceField in fortran.\n" ); |
470 | < | painCave.isFatal = 1; |
471 | < | simError(); |
468 | > | sprintf( painCave.errMsg, |
469 | > | "ForceField error: There was an error initializing the forceField in fortran.\n" ); |
470 | > | painCave.isFatal = 1; |
471 | > | simError(); |
472 | } | |
473 | ||
474 | ||
# | Line 479 | Line 479 | void SimInfo::update() { | |
479 | calcNdfTrans(); | |
480 | ||
481 | fortranInitialized_ = true; | |
482 | < | } |
482 | > | } |
483 | ||
484 | < | std::set<AtomType*> SimInfo::getUniqueAtomTypes() { |
484 | > | std::set<AtomType*> SimInfo::getUniqueAtomTypes() { |
485 | SimInfo::MoleculeIterator mi; | |
486 | Molecule* mol; | |
487 | Molecule::AtomIterator ai; | |
# | Line 490 | Line 490 | std::set<AtomType*> SimInfo::getUniqueAtomTypes() { | |
490 | ||
491 | for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { | |
492 | ||
493 | < | for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
494 | < | atomTypes.insert(atom->getAtomType()); |
495 | < | } |
493 | > | for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
494 | > | atomTypes.insert(atom->getAtomType()); |
495 | > | } |
496 | ||
497 | } | |
498 | ||
499 | return atomTypes; | |
500 | < | } |
500 | > | } |
501 | ||
502 | < | void SimInfo::setupSimType() { |
502 | > | void SimInfo::setupSimType() { |
503 | std::set<AtomType*>::iterator i; | |
504 | std::set<AtomType*> atomTypes; | |
505 | atomTypes = getUniqueAtomTypes(); | |
# | Line 512 | Line 512 | void SimInfo::setupSimType() { | |
512 | int useDipole = 0; | |
513 | int useGayBerne = 0; | |
514 | int useSticky = 0; | |
515 | + | int useStickyPower = 0; |
516 | int useShape = 0; | |
517 | int useFLARB = 0; //it is not in AtomType yet | |
518 | int useDirectionalAtom = 0; | |
# | Line 519 | Line 520 | void SimInfo::setupSimType() { | |
520 | //usePBC and useRF are from simParams | |
521 | int usePBC = simParams_->getPBC(); | |
522 | int useRF = simParams_->getUseRF(); | |
523 | + | int useUW = simParams_->getUseUndampedWolf(); |
524 | + | int useDW = simParams_->getUseDampedWolf(); |
525 | ||
526 | //loop over all of the atom types | |
527 | for (i = atomTypes.begin(); i != atomTypes.end(); ++i) { | |
528 | < | useLennardJones |= (*i)->isLennardJones(); |
529 | < | useElectrostatic |= (*i)->isElectrostatic(); |
530 | < | useEAM |= (*i)->isEAM(); |
531 | < | useCharge |= (*i)->isCharge(); |
532 | < | useDirectional |= (*i)->isDirectional(); |
533 | < | useDipole |= (*i)->isDipole(); |
534 | < | useGayBerne |= (*i)->isGayBerne(); |
535 | < | useSticky |= (*i)->isSticky(); |
536 | < | useShape |= (*i)->isShape(); |
528 | > | useLennardJones |= (*i)->isLennardJones(); |
529 | > | useElectrostatic |= (*i)->isElectrostatic(); |
530 | > | useEAM |= (*i)->isEAM(); |
531 | > | useCharge |= (*i)->isCharge(); |
532 | > | useDirectional |= (*i)->isDirectional(); |
533 | > | useDipole |= (*i)->isDipole(); |
534 | > | useGayBerne |= (*i)->isGayBerne(); |
535 | > | useSticky |= (*i)->isSticky(); |
536 | > | useStickyPower |= (*i)->isStickyPower(); |
537 | > | useShape |= (*i)->isShape(); |
538 | } | |
539 | ||
540 | < | if (useSticky || useDipole || useGayBerne || useShape) { |
541 | < | useDirectionalAtom = 1; |
540 | > | if (useSticky || useStickyPower || useDipole || useGayBerne || useShape) { |
541 | > | useDirectionalAtom = 1; |
542 | } | |
543 | ||
544 | if (useCharge || useDipole) { | |
545 | < | useElectrostatics = 1; |
545 | > | useElectrostatics = 1; |
546 | } | |
547 | ||
548 | #ifdef IS_MPI | |
# | Line 565 | Line 569 | void SimInfo::setupSimType() { | |
569 | temp = useSticky; | |
570 | MPI_Allreduce(&temp, &useSticky, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); | |
571 | ||
572 | + | temp = useStickyPower; |
573 | + | MPI_Allreduce(&temp, &useStickyPower, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
574 | + | |
575 | temp = useGayBerne; | |
576 | MPI_Allreduce(&temp, &useGayBerne, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); | |
577 | ||
# | Line 579 | Line 586 | void SimInfo::setupSimType() { | |
586 | ||
587 | temp = useRF; | |
588 | MPI_Allreduce(&temp, &useRF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); | |
589 | + | |
590 | + | temp = useUW; |
591 | + | MPI_Allreduce(&temp, &useUW, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
592 | + | |
593 | + | temp = useDW; |
594 | + | MPI_Allreduce(&temp, &useDW, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
595 | ||
596 | #endif | |
597 | ||
# | Line 589 | Line 602 | void SimInfo::setupSimType() { | |
602 | fInfo_.SIM_uses_Charges = useCharge; | |
603 | fInfo_.SIM_uses_Dipoles = useDipole; | |
604 | fInfo_.SIM_uses_Sticky = useSticky; | |
605 | + | fInfo_.SIM_uses_StickyPower = useStickyPower; |
606 | fInfo_.SIM_uses_GayBerne = useGayBerne; | |
607 | fInfo_.SIM_uses_EAM = useEAM; | |
608 | fInfo_.SIM_uses_Shapes = useShape; | |
609 | fInfo_.SIM_uses_FLARB = useFLARB; | |
610 | fInfo_.SIM_uses_RF = useRF; | |
611 | + | fInfo_.SIM_uses_UW = useUW; |
612 | + | fInfo_.SIM_uses_DW = useDW; |
613 | ||
614 | if( fInfo_.SIM_uses_Dipoles && fInfo_.SIM_uses_RF) { | |
615 | ||
616 | < | if (simParams_->haveDielectric()) { |
617 | < | fInfo_.dielect = simParams_->getDielectric(); |
618 | < | } else { |
619 | < | sprintf(painCave.errMsg, |
620 | < | "SimSetup Error: No Dielectric constant was set.\n" |
621 | < | "\tYou are trying to use Reaction Field without" |
622 | < | "\tsetting a dielectric constant!\n"); |
623 | < | painCave.isFatal = 1; |
624 | < | simError(); |
625 | < | } |
616 | > | if (simParams_->haveDielectric()) { |
617 | > | fInfo_.dielect = simParams_->getDielectric(); |
618 | > | } else { |
619 | > | sprintf(painCave.errMsg, |
620 | > | "SimSetup Error: No Dielectric constant was set.\n" |
621 | > | "\tYou are trying to use Reaction Field without" |
622 | > | "\tsetting a dielectric constant!\n"); |
623 | > | painCave.isFatal = 1; |
624 | > | simError(); |
625 | > | } |
626 | ||
627 | } else { | |
628 | < | fInfo_.dielect = 0.0; |
628 | > | fInfo_.dielect = 0.0; |
629 | } | |
630 | ||
631 | < | } |
631 | > | } |
632 | ||
633 | < | void SimInfo::setupFortranSim() { |
633 | > | void SimInfo::setupFortranSim() { |
634 | int isError; | |
635 | int nExclude; | |
636 | std::vector<int> fortranGlobalGroupMembership; | |
# | Line 624 | Line 640 | void SimInfo::setupFortranSim() { | |
640 | ||
641 | //globalGroupMembership_ is filled by SimCreator | |
642 | for (int i = 0; i < nGlobalAtoms_; i++) { | |
643 | < | fortranGlobalGroupMembership.push_back(globalGroupMembership_[i] + 1); |
643 | > | fortranGlobalGroupMembership.push_back(globalGroupMembership_[i] + 1); |
644 | } | |
645 | ||
646 | //calculate mass ratio of cutoff group | |
# | Line 641 | Line 657 | void SimInfo::setupFortranSim() { | |
657 | mfact.reserve(getNCutoffGroups()); | |
658 | ||
659 | for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { | |
660 | < | for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { |
660 | > | for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { |
661 | ||
662 | < | totalMass = cg->getMass(); |
663 | < | for(atom = cg->beginAtom(ai); atom != NULL; atom = cg->nextAtom(ai)) { |
664 | < | mfact.push_back(atom->getMass()/totalMass); |
665 | < | } |
662 | > | totalMass = cg->getMass(); |
663 | > | for(atom = cg->beginAtom(ai); atom != NULL; atom = cg->nextAtom(ai)) { |
664 | > | mfact.push_back(atom->getMass()/totalMass); |
665 | > | } |
666 | ||
667 | < | } |
667 | > | } |
668 | } | |
669 | ||
670 | //fill ident array of local atoms (it is actually ident of AtomType, it is so confusing !!!) | |
# | Line 658 | Line 674 | void SimInfo::setupFortranSim() { | |
674 | identArray.reserve(getNAtoms()); | |
675 | ||
676 | for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { | |
677 | < | for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
678 | < | identArray.push_back(atom->getIdent()); |
679 | < | } |
677 | > | for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
678 | > | identArray.push_back(atom->getIdent()); |
679 | > | } |
680 | } | |
681 | ||
682 | //fill molMembershipArray | |
683 | //molMembershipArray is filled by SimCreator | |
684 | std::vector<int> molMembershipArray(nGlobalAtoms_); | |
685 | for (int i = 0; i < nGlobalAtoms_; i++) { | |
686 | < | molMembershipArray[i] = globalMolMembership_[i] + 1; |
686 | > | molMembershipArray[i] = globalMolMembership_[i] + 1; |
687 | } | |
688 | ||
689 | //setup fortran simulation | |
# | Line 675 | Line 691 | void SimInfo::setupFortranSim() { | |
691 | int* globalExcludes = NULL; | |
692 | int* excludeList = exclude_.getExcludeList(); | |
693 | setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray[0], &nExclude, excludeList , | |
694 | < | &nGlobalExcludes, globalExcludes, &molMembershipArray[0], |
695 | < | &mfact[0], &nCutoffGroups_, &fortranGlobalGroupMembership[0], &isError); |
694 | > | &nGlobalExcludes, globalExcludes, &molMembershipArray[0], |
695 | > | &mfact[0], &nCutoffGroups_, &fortranGlobalGroupMembership[0], &isError); |
696 | ||
697 | if( isError ){ | |
698 | ||
699 | < | sprintf( painCave.errMsg, |
700 | < | "There was an error setting the simulation information in fortran.\n" ); |
701 | < | painCave.isFatal = 1; |
702 | < | painCave.severity = OOPSE_ERROR; |
703 | < | simError(); |
699 | > | sprintf( painCave.errMsg, |
700 | > | "There was an error setting the simulation information in fortran.\n" ); |
701 | > | painCave.isFatal = 1; |
702 | > | painCave.severity = OOPSE_ERROR; |
703 | > | simError(); |
704 | } | |
705 | ||
706 | #ifdef IS_MPI | |
707 | sprintf( checkPointMsg, | |
708 | < | "succesfully sent the simulation information to fortran.\n"); |
708 | > | "succesfully sent the simulation information to fortran.\n"); |
709 | MPIcheckPoint(); | |
710 | #endif // is_mpi | |
711 | < | } |
711 | > | } |
712 | ||
713 | ||
714 | #ifdef IS_MPI | |
715 | < | void SimInfo::setupFortranParallel() { |
715 | > | void SimInfo::setupFortranParallel() { |
716 | ||
717 | //SimInfo is responsible for creating localToGlobalAtomIndex and localToGlobalGroupIndex | |
718 | std::vector<int> localToGlobalAtomIndex(getNAtoms(), 0); | |
# | Line 712 | Line 728 | void SimInfo::setupFortranParallel() { | |
728 | ||
729 | for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { | |
730 | ||
731 | < | //local index(index in DataStorge) of atom is important |
732 | < | for (atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
733 | < | localToGlobalAtomIndex[atom->getLocalIndex()] = atom->getGlobalIndex() + 1; |
734 | < | } |
731 | > | //local index(index in DataStorge) of atom is important |
732 | > | for (atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
733 | > | localToGlobalAtomIndex[atom->getLocalIndex()] = atom->getGlobalIndex() + 1; |
734 | > | } |
735 | ||
736 | < | //local index of cutoff group is trivial, it only depends on the order of travesing |
737 | < | for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { |
738 | < | localToGlobalCutoffGroupIndex.push_back(cg->getGlobalIndex() + 1); |
739 | < | } |
736 | > | //local index of cutoff group is trivial, it only depends on the order of travesing |
737 | > | for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { |
738 | > | localToGlobalCutoffGroupIndex.push_back(cg->getGlobalIndex() + 1); |
739 | > | } |
740 | ||
741 | } | |
742 | ||
# | Line 740 | Line 756 | void SimInfo::setupFortranParallel() { | |
756 | &localToGlobalCutoffGroupIndex[0], &isError); | |
757 | ||
758 | if (isError) { | |
759 | < | sprintf(painCave.errMsg, |
760 | < | "mpiRefresh errror: fortran didn't like something we gave it.\n"); |
761 | < | painCave.isFatal = 1; |
762 | < | simError(); |
759 | > | sprintf(painCave.errMsg, |
760 | > | "mpiRefresh errror: fortran didn't like something we gave it.\n"); |
761 | > | painCave.isFatal = 1; |
762 | > | simError(); |
763 | } | |
764 | ||
765 | sprintf(checkPointMsg, " mpiRefresh successful.\n"); | |
766 | MPIcheckPoint(); | |
767 | ||
768 | ||
769 | < | } |
769 | > | } |
770 | ||
771 | #endif | |
772 | ||
773 | < | double SimInfo::calcMaxCutoffRadius() { |
773 | > | double SimInfo::calcMaxCutoffRadius() { |
774 | ||
775 | ||
776 | std::set<AtomType*> atomTypes; | |
# | Line 766 | Line 782 | double SimInfo::calcMaxCutoffRadius() { | |
782 | ||
783 | //query the max cutoff radius among these atom types | |
784 | for (i = atomTypes.begin(); i != atomTypes.end(); ++i) { | |
785 | < | cutoffRadius.push_back(forceField_->getRcutFromAtomType(*i)); |
785 | > | cutoffRadius.push_back(forceField_->getRcutFromAtomType(*i)); |
786 | } | |
787 | ||
788 | double maxCutoffRadius = *(std::max_element(cutoffRadius.begin(), cutoffRadius.end())); | |
# | Line 775 | Line 791 | double SimInfo::calcMaxCutoffRadius() { | |
791 | #endif | |
792 | ||
793 | return maxCutoffRadius; | |
794 | < | } |
794 | > | } |
795 | ||
796 | < | void SimInfo::getCutoff(double& rcut, double& rsw) { |
796 | > | void SimInfo::getCutoff(double& rcut, double& rsw) { |
797 | ||
798 | if (fInfo_.SIM_uses_Charges | fInfo_.SIM_uses_Dipoles | fInfo_.SIM_uses_RF) { | |
799 | ||
800 | < | if (!simParams_->haveRcut()){ |
801 | < | sprintf(painCave.errMsg, |
800 | > | if (!simParams_->haveRcut()){ |
801 | > | sprintf(painCave.errMsg, |
802 | "SimCreator Warning: No value was set for the cutoffRadius.\n" | |
803 | "\tOOPSE will use a default value of 15.0 angstroms" | |
804 | "\tfor the cutoffRadius.\n"); | |
805 | < | painCave.isFatal = 0; |
806 | < | simError(); |
807 | < | rcut = 15.0; |
808 | < | } else{ |
809 | < | rcut = simParams_->getRcut(); |
810 | < | } |
805 | > | painCave.isFatal = 0; |
806 | > | simError(); |
807 | > | rcut = 15.0; |
808 | > | } else{ |
809 | > | rcut = simParams_->getRcut(); |
810 | > | } |
811 | ||
812 | < | if (!simParams_->haveRsw()){ |
813 | < | sprintf(painCave.errMsg, |
812 | > | if (!simParams_->haveRsw()){ |
813 | > | sprintf(painCave.errMsg, |
814 | "SimCreator Warning: No value was set for switchingRadius.\n" | |
815 | "\tOOPSE will use a default value of\n" | |
816 | "\t0.95 * cutoffRadius for the switchingRadius\n"); | |
817 | < | painCave.isFatal = 0; |
818 | < | simError(); |
819 | < | rsw = 0.95 * rcut; |
820 | < | } else{ |
821 | < | rsw = simParams_->getRsw(); |
822 | < | } |
817 | > | painCave.isFatal = 0; |
818 | > | simError(); |
819 | > | rsw = 0.95 * rcut; |
820 | > | } else{ |
821 | > | rsw = simParams_->getRsw(); |
822 | > | } |
823 | ||
824 | } else { | |
825 | < | // if charge, dipole or reaction field is not used and the cutofff radius is not specified in |
826 | < | //meta-data file, the maximum cutoff radius calculated from forcefiled will be used |
825 | > | // if charge, dipole or reaction field is not used and the cutofff radius is not specified in |
826 | > | //meta-data file, the maximum cutoff radius calculated from forcefiled will be used |
827 | ||
828 | < | if (simParams_->haveRcut()) { |
829 | < | rcut = simParams_->getRcut(); |
830 | < | } else { |
831 | < | //set cutoff radius to the maximum cutoff radius based on atom types in the whole system |
832 | < | rcut = calcMaxCutoffRadius(); |
833 | < | } |
828 | > | if (simParams_->haveRcut()) { |
829 | > | rcut = simParams_->getRcut(); |
830 | > | } else { |
831 | > | //set cutoff radius to the maximum cutoff radius based on atom types in the whole system |
832 | > | rcut = calcMaxCutoffRadius(); |
833 | > | } |
834 | ||
835 | < | if (simParams_->haveRsw()) { |
836 | < | rsw = simParams_->getRsw(); |
837 | < | } else { |
838 | < | rsw = rcut; |
839 | < | } |
835 | > | if (simParams_->haveRsw()) { |
836 | > | rsw = simParams_->getRsw(); |
837 | > | } else { |
838 | > | rsw = rcut; |
839 | > | } |
840 | ||
841 | } | |
842 | < | } |
842 | > | } |
843 | ||
844 | < | void SimInfo::setupCutoff() { |
844 | > | void SimInfo::setupCutoff() { |
845 | getCutoff(rcut_, rsw_); | |
846 | double rnblist = rcut_ + 1; // skin of neighbor list | |
847 | ||
848 | //Pass these cutoff radius etc. to fortran. This function should be called once and only once | |
849 | notifyFortranCutoffs(&rcut_, &rsw_, &rnblist); | |
850 | < | } |
850 | > | } |
851 | ||
852 | < | void SimInfo::addProperty(GenericData* genData) { |
852 | > | void SimInfo::addProperty(GenericData* genData) { |
853 | properties_.addProperty(genData); | |
854 | < | } |
854 | > | } |
855 | ||
856 | < | void SimInfo::removeProperty(const std::string& propName) { |
856 | > | void SimInfo::removeProperty(const std::string& propName) { |
857 | properties_.removeProperty(propName); | |
858 | < | } |
858 | > | } |
859 | ||
860 | < | void SimInfo::clearProperties() { |
860 | > | void SimInfo::clearProperties() { |
861 | properties_.clearProperties(); | |
862 | < | } |
862 | > | } |
863 | ||
864 | < | std::vector<std::string> SimInfo::getPropertyNames() { |
864 | > | std::vector<std::string> SimInfo::getPropertyNames() { |
865 | return properties_.getPropertyNames(); | |
866 | < | } |
866 | > | } |
867 | ||
868 | < | std::vector<GenericData*> SimInfo::getProperties() { |
868 | > | std::vector<GenericData*> SimInfo::getProperties() { |
869 | return properties_.getProperties(); | |
870 | < | } |
870 | > | } |
871 | ||
872 | < | GenericData* SimInfo::getPropertyByName(const std::string& propName) { |
872 | > | GenericData* SimInfo::getPropertyByName(const std::string& propName) { |
873 | return properties_.getPropertyByName(propName); | |
874 | < | } |
874 | > | } |
875 | ||
876 | < | void SimInfo::setSnapshotManager(SnapshotManager* sman) { |
876 | > | void SimInfo::setSnapshotManager(SnapshotManager* sman) { |
877 | if (sman_ == sman) { | |
878 | < | return; |
878 | > | return; |
879 | } | |
880 | delete sman_; | |
881 | sman_ = sman; | |
# | Line 873 | Line 889 | void SimInfo::setSnapshotManager(SnapshotManager* sman | |
889 | ||
890 | for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { | |
891 | ||
892 | < | for (atom = mol->beginAtom(atomIter); atom != NULL; atom = mol->nextAtom(atomIter)) { |
893 | < | atom->setSnapshotManager(sman_); |
894 | < | } |
892 | > | for (atom = mol->beginAtom(atomIter); atom != NULL; atom = mol->nextAtom(atomIter)) { |
893 | > | atom->setSnapshotManager(sman_); |
894 | > | } |
895 | ||
896 | < | for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
897 | < | rb->setSnapshotManager(sman_); |
898 | < | } |
896 | > | for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
897 | > | rb->setSnapshotManager(sman_); |
898 | > | } |
899 | } | |
900 | ||
901 | < | } |
901 | > | } |
902 | ||
903 | < | Vector3d SimInfo::getComVel(){ |
903 | > | Vector3d SimInfo::getComVel(){ |
904 | SimInfo::MoleculeIterator i; | |
905 | Molecule* mol; | |
906 | ||
# | Line 893 | Line 909 | Vector3d SimInfo::getComVel(){ | |
909 | ||
910 | ||
911 | for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { | |
912 | < | double mass = mol->getMass(); |
913 | < | totalMass += mass; |
914 | < | comVel += mass * mol->getComVel(); |
912 | > | double mass = mol->getMass(); |
913 | > | totalMass += mass; |
914 | > | comVel += mass * mol->getComVel(); |
915 | } | |
916 | ||
917 | #ifdef IS_MPI | |
# | Line 908 | Line 924 | Vector3d SimInfo::getComVel(){ | |
924 | comVel /= totalMass; | |
925 | ||
926 | return comVel; | |
927 | < | } |
927 | > | } |
928 | ||
929 | < | Vector3d SimInfo::getCom(){ |
929 | > | Vector3d SimInfo::getCom(){ |
930 | SimInfo::MoleculeIterator i; | |
931 | Molecule* mol; | |
932 | ||
# | Line 918 | Line 934 | Vector3d SimInfo::getCom(){ | |
934 | double totalMass = 0.0; | |
935 | ||
936 | for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { | |
937 | < | double mass = mol->getMass(); |
938 | < | totalMass += mass; |
939 | < | com += mass * mol->getCom(); |
937 | > | double mass = mol->getMass(); |
938 | > | totalMass += mass; |
939 | > | com += mass * mol->getCom(); |
940 | } | |
941 | ||
942 | #ifdef IS_MPI | |
# | Line 934 | Line 950 | Vector3d SimInfo::getCom(){ | |
950 | ||
951 | return com; | |
952 | ||
953 | < | } |
953 | > | } |
954 | ||
955 | < | std::ostream& operator <<(std::ostream& o, SimInfo& info) { |
955 | > | std::ostream& operator <<(std::ostream& o, SimInfo& info) { |
956 | ||
957 | return o; | |
958 | < | } |
958 | > | } |
959 | > | |
960 | > | |
961 | > | /* |
962 | > | Returns center of mass and center of mass velocity in one function call. |
963 | > | */ |
964 | > | |
965 | > | void SimInfo::getComAll(Vector3d &com, Vector3d &comVel){ |
966 | > | SimInfo::MoleculeIterator i; |
967 | > | Molecule* mol; |
968 | > | |
969 | > | |
970 | > | double totalMass = 0.0; |
971 | > | |
972 | ||
973 | + | for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
974 | + | double mass = mol->getMass(); |
975 | + | totalMass += mass; |
976 | + | com += mass * mol->getCom(); |
977 | + | comVel += mass * mol->getComVel(); |
978 | + | } |
979 | + | |
980 | + | #ifdef IS_MPI |
981 | + | double tmpMass = totalMass; |
982 | + | Vector3d tmpCom(com); |
983 | + | Vector3d tmpComVel(comVel); |
984 | + | MPI_Allreduce(&tmpMass,&totalMass,1,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
985 | + | MPI_Allreduce(tmpCom.getArrayPointer(), com.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
986 | + | MPI_Allreduce(tmpComVel.getArrayPointer(), comVel.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
987 | + | #endif |
988 | + | |
989 | + | com /= totalMass; |
990 | + | comVel /= totalMass; |
991 | + | } |
992 | + | |
993 | + | /* |
994 | + | Return intertia tensor for entire system and angular momentum Vector. |
995 | + | |
996 | + | |
997 | + | [ Ixx -Ixy -Ixz ] |
998 | + | J =| -Iyx Iyy -Iyz | |
999 | + | [ -Izx -Iyz Izz ] |
1000 | + | */ |
1001 | + | |
1002 | + | void SimInfo::getInertiaTensor(Mat3x3d &inertiaTensor, Vector3d &angularMomentum){ |
1003 | + | |
1004 | + | |
1005 | + | double xx = 0.0; |
1006 | + | double yy = 0.0; |
1007 | + | double zz = 0.0; |
1008 | + | double xy = 0.0; |
1009 | + | double xz = 0.0; |
1010 | + | double yz = 0.0; |
1011 | + | Vector3d com(0.0); |
1012 | + | Vector3d comVel(0.0); |
1013 | + | |
1014 | + | getComAll(com, comVel); |
1015 | + | |
1016 | + | SimInfo::MoleculeIterator i; |
1017 | + | Molecule* mol; |
1018 | + | |
1019 | + | Vector3d thisq(0.0); |
1020 | + | Vector3d thisv(0.0); |
1021 | + | |
1022 | + | double thisMass = 0.0; |
1023 | + | |
1024 | + | |
1025 | + | |
1026 | + | |
1027 | + | for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
1028 | + | |
1029 | + | thisq = mol->getCom()-com; |
1030 | + | thisv = mol->getComVel()-comVel; |
1031 | + | thisMass = mol->getMass(); |
1032 | + | // Compute moment of intertia coefficients. |
1033 | + | xx += thisq[0]*thisq[0]*thisMass; |
1034 | + | yy += thisq[1]*thisq[1]*thisMass; |
1035 | + | zz += thisq[2]*thisq[2]*thisMass; |
1036 | + | |
1037 | + | // compute products of intertia |
1038 | + | xy += thisq[0]*thisq[1]*thisMass; |
1039 | + | xz += thisq[0]*thisq[2]*thisMass; |
1040 | + | yz += thisq[1]*thisq[2]*thisMass; |
1041 | + | |
1042 | + | angularMomentum += cross( thisq, thisv ) * thisMass; |
1043 | + | |
1044 | + | } |
1045 | + | |
1046 | + | |
1047 | + | inertiaTensor(0,0) = yy + zz; |
1048 | + | inertiaTensor(0,1) = -xy; |
1049 | + | inertiaTensor(0,2) = -xz; |
1050 | + | inertiaTensor(1,0) = -xy; |
1051 | + | inertiaTensor(1,1) = xx + zz; |
1052 | + | inertiaTensor(1,2) = -yz; |
1053 | + | inertiaTensor(2,0) = -xz; |
1054 | + | inertiaTensor(2,1) = -yz; |
1055 | + | inertiaTensor(2,2) = xx + yy; |
1056 | + | |
1057 | + | #ifdef IS_MPI |
1058 | + | Mat3x3d tmpI(inertiaTensor); |
1059 | + | Vector3d tmpAngMom; |
1060 | + | MPI_Allreduce(tmpI.getArrayPointer(), inertiaTensor.getArrayPointer(),9,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1061 | + | MPI_Allreduce(tmpAngMom.getArrayPointer(), angularMomentum.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1062 | + | #endif |
1063 | + | |
1064 | + | return; |
1065 | + | } |
1066 | + | |
1067 | + | //Returns the angular momentum of the system |
1068 | + | Vector3d SimInfo::getAngularMomentum(){ |
1069 | + | |
1070 | + | Vector3d com(0.0); |
1071 | + | Vector3d comVel(0.0); |
1072 | + | Vector3d angularMomentum(0.0); |
1073 | + | |
1074 | + | getComAll(com,comVel); |
1075 | + | |
1076 | + | SimInfo::MoleculeIterator i; |
1077 | + | Molecule* mol; |
1078 | + | |
1079 | + | Vector3d thisr(0.0); |
1080 | + | Vector3d thisp(0.0); |
1081 | + | |
1082 | + | double thisMass; |
1083 | + | |
1084 | + | for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
1085 | + | thisMass = mol->getMass(); |
1086 | + | thisr = mol->getCom()-com; |
1087 | + | thisp = (mol->getComVel()-comVel)*thisMass; |
1088 | + | |
1089 | + | angularMomentum += cross( thisr, thisp ); |
1090 | + | |
1091 | + | } |
1092 | + | |
1093 | + | #ifdef IS_MPI |
1094 | + | Vector3d tmpAngMom; |
1095 | + | MPI_Allreduce(tmpAngMom.getArrayPointer(), angularMomentum.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1096 | + | #endif |
1097 | + | |
1098 | + | return angularMomentum; |
1099 | + | } |
1100 | + | |
1101 | + | |
1102 | }//end namespace oopse | |
1103 |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |