1 |
gezelter |
507 |
/* |
2 |
gezelter |
246 |
* Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. |
3 |
|
|
* |
4 |
|
|
* The University of Notre Dame grants you ("Licensee") a |
5 |
|
|
* non-exclusive, royalty free, license to use, modify and |
6 |
|
|
* redistribute this software in source and binary code form, provided |
7 |
|
|
* that the following conditions are met: |
8 |
|
|
* |
9 |
|
|
* 1. Acknowledgement of the program authors must be made in any |
10 |
|
|
* publication of scientific results based in part on use of the |
11 |
|
|
* program. An acceptable form of acknowledgement is citation of |
12 |
|
|
* the article in which the program was described (Matthew |
13 |
|
|
* A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher |
14 |
|
|
* J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented |
15 |
|
|
* Parallel Simulation Engine for Molecular Dynamics," |
16 |
|
|
* J. Comput. Chem. 26, pp. 252-271 (2005)) |
17 |
|
|
* |
18 |
|
|
* 2. Redistributions of source code must retain the above copyright |
19 |
|
|
* notice, this list of conditions and the following disclaimer. |
20 |
|
|
* |
21 |
|
|
* 3. Redistributions in binary form must reproduce the above copyright |
22 |
|
|
* notice, this list of conditions and the following disclaimer in the |
23 |
|
|
* documentation and/or other materials provided with the |
24 |
|
|
* distribution. |
25 |
|
|
* |
26 |
|
|
* This software is provided "AS IS," without a warranty of any |
27 |
|
|
* kind. All express or implied conditions, representations and |
28 |
|
|
* warranties, including any implied warranty of merchantability, |
29 |
|
|
* fitness for a particular purpose or non-infringement, are hereby |
30 |
|
|
* excluded. The University of Notre Dame and its licensors shall not |
31 |
|
|
* be liable for any damages suffered by licensee as a result of |
32 |
|
|
* using, modifying or distributing the software or its |
33 |
|
|
* derivatives. In no event will the University of Notre Dame or its |
34 |
|
|
* licensors be liable for any lost revenue, profit or data, or for |
35 |
|
|
* direct, indirect, special, consequential, incidental or punitive |
36 |
|
|
* damages, however caused and regardless of the theory of liability, |
37 |
|
|
* arising out of the use of or inability to use software, even if the |
38 |
|
|
* University of Notre Dame has been advised of the possibility of |
39 |
|
|
* such damages. |
40 |
|
|
*/ |
41 |
|
|
|
42 |
|
|
/** |
43 |
|
|
* @file SimInfo.cpp |
44 |
|
|
* @author tlin |
45 |
|
|
* @date 11/02/2004 |
46 |
|
|
* @version 1.0 |
47 |
|
|
*/ |
48 |
gezelter |
2 |
|
49 |
gezelter |
246 |
#include <algorithm> |
50 |
|
|
#include <set> |
51 |
tim |
749 |
#include <map> |
52 |
gezelter |
2 |
|
53 |
tim |
3 |
#include "brains/SimInfo.hpp" |
54 |
gezelter |
246 |
#include "math/Vector3.hpp" |
55 |
|
|
#include "primitives/Molecule.hpp" |
56 |
gezelter |
586 |
#include "UseTheForce/fCutoffPolicy.h" |
57 |
chrisfen |
606 |
#include "UseTheForce/DarkSide/fElectrostaticSummationMethod.h" |
58 |
chrisfen |
716 |
#include "UseTheForce/DarkSide/fElectrostaticScreeningMethod.h" |
59 |
chrisfen |
726 |
#include "UseTheForce/DarkSide/fSwitchingFunctionType.h" |
60 |
gezelter |
246 |
#include "UseTheForce/doForces_interface.h" |
61 |
chrisfen |
610 |
#include "UseTheForce/DarkSide/electrostatic_interface.h" |
62 |
chrisfen |
726 |
#include "UseTheForce/DarkSide/switcheroo_interface.h" |
63 |
gezelter |
246 |
#include "utils/MemoryUtils.hpp" |
64 |
tim |
3 |
#include "utils/simError.h" |
65 |
tim |
316 |
#include "selection/SelectionManager.hpp" |
66 |
chuckv |
834 |
#include "io/ForceFieldOptions.hpp" |
67 |
|
|
#include "UseTheForce/ForceField.hpp" |
68 |
gezelter |
2 |
|
69 |
gezelter |
246 |
#ifdef IS_MPI |
70 |
|
|
#include "UseTheForce/mpiComponentPlan.h" |
71 |
|
|
#include "UseTheForce/DarkSide/simParallel_interface.h" |
72 |
|
|
#endif |
73 |
gezelter |
2 |
|
74 |
gezelter |
246 |
namespace oopse { |
75 |
tim |
749 |
std::set<int> getRigidSet(int index, std::map<int, std::set<int> >& container) { |
76 |
|
|
std::map<int, std::set<int> >::iterator i = container.find(index); |
77 |
|
|
std::set<int> result; |
78 |
|
|
if (i != container.end()) { |
79 |
|
|
result = i->second; |
80 |
|
|
} |
81 |
gezelter |
2 |
|
82 |
tim |
749 |
return result; |
83 |
|
|
} |
84 |
|
|
|
85 |
tim |
770 |
SimInfo::SimInfo(ForceField* ff, Globals* simParams) : |
86 |
|
|
forceField_(ff), simParams_(simParams), |
87 |
gezelter |
507 |
ndf_(0), ndfRaw_(0), ndfTrans_(0), nZconstraint_(0), |
88 |
|
|
nGlobalMols_(0), nGlobalAtoms_(0), nGlobalCutoffGroups_(0), |
89 |
|
|
nGlobalIntegrableObjects_(0), nGlobalRigidBodies_(0), |
90 |
|
|
nAtoms_(0), nBonds_(0), nBends_(0), nTorsions_(0), nRigidBodies_(0), |
91 |
|
|
nIntegrableObjects_(0), nCutoffGroups_(0), nConstraints_(0), |
92 |
|
|
sman_(NULL), fortranInitialized_(false) { |
93 |
gezelter |
2 |
|
94 |
gezelter |
507 |
MoleculeStamp* molStamp; |
95 |
|
|
int nMolWithSameStamp; |
96 |
|
|
int nCutoffAtoms = 0; // number of atoms belong to cutoff groups |
97 |
chrisfen |
645 |
int nGroups = 0; //total cutoff groups defined in meta-data file |
98 |
gezelter |
507 |
CutoffGroupStamp* cgStamp; |
99 |
|
|
RigidBodyStamp* rbStamp; |
100 |
|
|
int nRigidAtoms = 0; |
101 |
tim |
770 |
std::vector<Component*> components = simParams->getComponents(); |
102 |
|
|
|
103 |
|
|
for (std::vector<Component*>::iterator i = components.begin(); i !=components.end(); ++i) { |
104 |
|
|
molStamp = (*i)->getMoleculeStamp(); |
105 |
|
|
nMolWithSameStamp = (*i)->getNMol(); |
106 |
gezelter |
246 |
|
107 |
|
|
addMoleculeStamp(molStamp, nMolWithSameStamp); |
108 |
gezelter |
2 |
|
109 |
gezelter |
246 |
//calculate atoms in molecules |
110 |
|
|
nGlobalAtoms_ += molStamp->getNAtoms() *nMolWithSameStamp; |
111 |
gezelter |
2 |
|
112 |
gezelter |
246 |
//calculate atoms in cutoff groups |
113 |
|
|
int nAtomsInGroups = 0; |
114 |
|
|
int nCutoffGroupsInStamp = molStamp->getNCutoffGroups(); |
115 |
|
|
|
116 |
|
|
for (int j=0; j < nCutoffGroupsInStamp; j++) { |
117 |
tim |
770 |
cgStamp = molStamp->getCutoffGroupStamp(j); |
118 |
gezelter |
507 |
nAtomsInGroups += cgStamp->getNMembers(); |
119 |
gezelter |
246 |
} |
120 |
gezelter |
2 |
|
121 |
gezelter |
246 |
nGroups += nCutoffGroupsInStamp * nMolWithSameStamp; |
122 |
chrisfen |
645 |
|
123 |
gezelter |
246 |
nCutoffAtoms += nAtomsInGroups * nMolWithSameStamp; |
124 |
gezelter |
2 |
|
125 |
gezelter |
246 |
//calculate atoms in rigid bodies |
126 |
|
|
int nAtomsInRigidBodies = 0; |
127 |
tim |
274 |
int nRigidBodiesInStamp = molStamp->getNRigidBodies(); |
128 |
gezelter |
246 |
|
129 |
|
|
for (int j=0; j < nRigidBodiesInStamp; j++) { |
130 |
tim |
770 |
rbStamp = molStamp->getRigidBodyStamp(j); |
131 |
gezelter |
507 |
nAtomsInRigidBodies += rbStamp->getNMembers(); |
132 |
gezelter |
246 |
} |
133 |
gezelter |
2 |
|
134 |
gezelter |
246 |
nGlobalRigidBodies_ += nRigidBodiesInStamp * nMolWithSameStamp; |
135 |
|
|
nRigidAtoms += nAtomsInRigidBodies * nMolWithSameStamp; |
136 |
|
|
|
137 |
gezelter |
507 |
} |
138 |
chrisfen |
143 |
|
139 |
chrisfen |
645 |
//every free atom (atom does not belong to cutoff groups) is a cutoff |
140 |
|
|
//group therefore the total number of cutoff groups in the system is |
141 |
|
|
//equal to the total number of atoms minus number of atoms belong to |
142 |
|
|
//cutoff group defined in meta-data file plus the number of cutoff |
143 |
|
|
//groups defined in meta-data file |
144 |
gezelter |
507 |
nGlobalCutoffGroups_ = nGlobalAtoms_ - nCutoffAtoms + nGroups; |
145 |
gezelter |
2 |
|
146 |
chrisfen |
645 |
//every free atom (atom does not belong to rigid bodies) is an |
147 |
|
|
//integrable object therefore the total number of integrable objects |
148 |
|
|
//in the system is equal to the total number of atoms minus number of |
149 |
|
|
//atoms belong to rigid body defined in meta-data file plus the number |
150 |
|
|
//of rigid bodies defined in meta-data file |
151 |
|
|
nGlobalIntegrableObjects_ = nGlobalAtoms_ - nRigidAtoms |
152 |
|
|
+ nGlobalRigidBodies_; |
153 |
|
|
|
154 |
gezelter |
507 |
nGlobalMols_ = molStampIds_.size(); |
155 |
gezelter |
2 |
|
156 |
gezelter |
246 |
#ifdef IS_MPI |
157 |
gezelter |
507 |
molToProcMap_.resize(nGlobalMols_); |
158 |
gezelter |
246 |
#endif |
159 |
tim |
292 |
|
160 |
gezelter |
507 |
} |
161 |
gezelter |
2 |
|
162 |
gezelter |
507 |
SimInfo::~SimInfo() { |
163 |
tim |
398 |
std::map<int, Molecule*>::iterator i; |
164 |
|
|
for (i = molecules_.begin(); i != molecules_.end(); ++i) { |
165 |
gezelter |
507 |
delete i->second; |
166 |
tim |
398 |
} |
167 |
|
|
molecules_.clear(); |
168 |
tim |
490 |
|
169 |
gezelter |
246 |
delete sman_; |
170 |
|
|
delete simParams_; |
171 |
|
|
delete forceField_; |
172 |
gezelter |
507 |
} |
173 |
gezelter |
2 |
|
174 |
gezelter |
507 |
int SimInfo::getNGlobalConstraints() { |
175 |
gezelter |
246 |
int nGlobalConstraints; |
176 |
|
|
#ifdef IS_MPI |
177 |
|
|
MPI_Allreduce(&nConstraints_, &nGlobalConstraints, 1, MPI_INT, MPI_SUM, |
178 |
|
|
MPI_COMM_WORLD); |
179 |
|
|
#else |
180 |
|
|
nGlobalConstraints = nConstraints_; |
181 |
|
|
#endif |
182 |
|
|
return nGlobalConstraints; |
183 |
gezelter |
507 |
} |
184 |
gezelter |
2 |
|
185 |
gezelter |
507 |
bool SimInfo::addMolecule(Molecule* mol) { |
186 |
gezelter |
246 |
MoleculeIterator i; |
187 |
gezelter |
2 |
|
188 |
gezelter |
246 |
i = molecules_.find(mol->getGlobalIndex()); |
189 |
|
|
if (i == molecules_.end() ) { |
190 |
gezelter |
2 |
|
191 |
gezelter |
507 |
molecules_.insert(std::make_pair(mol->getGlobalIndex(), mol)); |
192 |
gezelter |
246 |
|
193 |
gezelter |
507 |
nAtoms_ += mol->getNAtoms(); |
194 |
|
|
nBonds_ += mol->getNBonds(); |
195 |
|
|
nBends_ += mol->getNBends(); |
196 |
|
|
nTorsions_ += mol->getNTorsions(); |
197 |
|
|
nRigidBodies_ += mol->getNRigidBodies(); |
198 |
|
|
nIntegrableObjects_ += mol->getNIntegrableObjects(); |
199 |
|
|
nCutoffGroups_ += mol->getNCutoffGroups(); |
200 |
|
|
nConstraints_ += mol->getNConstraintPairs(); |
201 |
gezelter |
2 |
|
202 |
gezelter |
507 |
addExcludePairs(mol); |
203 |
gezelter |
246 |
|
204 |
gezelter |
507 |
return true; |
205 |
gezelter |
246 |
} else { |
206 |
gezelter |
507 |
return false; |
207 |
gezelter |
246 |
} |
208 |
gezelter |
507 |
} |
209 |
gezelter |
2 |
|
210 |
gezelter |
507 |
bool SimInfo::removeMolecule(Molecule* mol) { |
211 |
gezelter |
246 |
MoleculeIterator i; |
212 |
|
|
i = molecules_.find(mol->getGlobalIndex()); |
213 |
gezelter |
2 |
|
214 |
gezelter |
246 |
if (i != molecules_.end() ) { |
215 |
gezelter |
2 |
|
216 |
gezelter |
507 |
assert(mol == i->second); |
217 |
gezelter |
246 |
|
218 |
gezelter |
507 |
nAtoms_ -= mol->getNAtoms(); |
219 |
|
|
nBonds_ -= mol->getNBonds(); |
220 |
|
|
nBends_ -= mol->getNBends(); |
221 |
|
|
nTorsions_ -= mol->getNTorsions(); |
222 |
|
|
nRigidBodies_ -= mol->getNRigidBodies(); |
223 |
|
|
nIntegrableObjects_ -= mol->getNIntegrableObjects(); |
224 |
|
|
nCutoffGroups_ -= mol->getNCutoffGroups(); |
225 |
|
|
nConstraints_ -= mol->getNConstraintPairs(); |
226 |
gezelter |
2 |
|
227 |
gezelter |
507 |
removeExcludePairs(mol); |
228 |
|
|
molecules_.erase(mol->getGlobalIndex()); |
229 |
gezelter |
2 |
|
230 |
gezelter |
507 |
delete mol; |
231 |
gezelter |
246 |
|
232 |
gezelter |
507 |
return true; |
233 |
gezelter |
246 |
} else { |
234 |
gezelter |
507 |
return false; |
235 |
gezelter |
246 |
} |
236 |
|
|
|
237 |
|
|
|
238 |
gezelter |
507 |
} |
239 |
gezelter |
246 |
|
240 |
|
|
|
241 |
gezelter |
507 |
Molecule* SimInfo::beginMolecule(MoleculeIterator& i) { |
242 |
gezelter |
246 |
i = molecules_.begin(); |
243 |
|
|
return i == molecules_.end() ? NULL : i->second; |
244 |
gezelter |
507 |
} |
245 |
gezelter |
246 |
|
246 |
gezelter |
507 |
Molecule* SimInfo::nextMolecule(MoleculeIterator& i) { |
247 |
gezelter |
246 |
++i; |
248 |
|
|
return i == molecules_.end() ? NULL : i->second; |
249 |
gezelter |
507 |
} |
250 |
gezelter |
2 |
|
251 |
|
|
|
252 |
gezelter |
507 |
void SimInfo::calcNdf() { |
253 |
gezelter |
246 |
int ndf_local; |
254 |
|
|
MoleculeIterator i; |
255 |
|
|
std::vector<StuntDouble*>::iterator j; |
256 |
|
|
Molecule* mol; |
257 |
|
|
StuntDouble* integrableObject; |
258 |
gezelter |
2 |
|
259 |
gezelter |
246 |
ndf_local = 0; |
260 |
|
|
|
261 |
|
|
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
262 |
gezelter |
507 |
for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL; |
263 |
|
|
integrableObject = mol->nextIntegrableObject(j)) { |
264 |
gezelter |
2 |
|
265 |
gezelter |
507 |
ndf_local += 3; |
266 |
gezelter |
2 |
|
267 |
gezelter |
507 |
if (integrableObject->isDirectional()) { |
268 |
|
|
if (integrableObject->isLinear()) { |
269 |
|
|
ndf_local += 2; |
270 |
|
|
} else { |
271 |
|
|
ndf_local += 3; |
272 |
|
|
} |
273 |
|
|
} |
274 |
gezelter |
246 |
|
275 |
tim |
770 |
} |
276 |
|
|
} |
277 |
gezelter |
246 |
|
278 |
|
|
// n_constraints is local, so subtract them on each processor |
279 |
|
|
ndf_local -= nConstraints_; |
280 |
|
|
|
281 |
|
|
#ifdef IS_MPI |
282 |
|
|
MPI_Allreduce(&ndf_local,&ndf_,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD); |
283 |
|
|
#else |
284 |
|
|
ndf_ = ndf_local; |
285 |
|
|
#endif |
286 |
|
|
|
287 |
|
|
// nZconstraints_ is global, as are the 3 COM translations for the |
288 |
|
|
// entire system: |
289 |
|
|
ndf_ = ndf_ - 3 - nZconstraint_; |
290 |
|
|
|
291 |
gezelter |
507 |
} |
292 |
gezelter |
2 |
|
293 |
gezelter |
507 |
void SimInfo::calcNdfRaw() { |
294 |
gezelter |
246 |
int ndfRaw_local; |
295 |
gezelter |
2 |
|
296 |
gezelter |
246 |
MoleculeIterator i; |
297 |
|
|
std::vector<StuntDouble*>::iterator j; |
298 |
|
|
Molecule* mol; |
299 |
|
|
StuntDouble* integrableObject; |
300 |
|
|
|
301 |
|
|
// Raw degrees of freedom that we have to set |
302 |
|
|
ndfRaw_local = 0; |
303 |
|
|
|
304 |
|
|
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
305 |
gezelter |
507 |
for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL; |
306 |
|
|
integrableObject = mol->nextIntegrableObject(j)) { |
307 |
gezelter |
246 |
|
308 |
gezelter |
507 |
ndfRaw_local += 3; |
309 |
gezelter |
246 |
|
310 |
gezelter |
507 |
if (integrableObject->isDirectional()) { |
311 |
|
|
if (integrableObject->isLinear()) { |
312 |
|
|
ndfRaw_local += 2; |
313 |
|
|
} else { |
314 |
|
|
ndfRaw_local += 3; |
315 |
|
|
} |
316 |
|
|
} |
317 |
gezelter |
246 |
|
318 |
gezelter |
507 |
} |
319 |
gezelter |
246 |
} |
320 |
|
|
|
321 |
|
|
#ifdef IS_MPI |
322 |
|
|
MPI_Allreduce(&ndfRaw_local,&ndfRaw_,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD); |
323 |
|
|
#else |
324 |
|
|
ndfRaw_ = ndfRaw_local; |
325 |
|
|
#endif |
326 |
gezelter |
507 |
} |
327 |
gezelter |
2 |
|
328 |
gezelter |
507 |
void SimInfo::calcNdfTrans() { |
329 |
gezelter |
246 |
int ndfTrans_local; |
330 |
gezelter |
2 |
|
331 |
gezelter |
246 |
ndfTrans_local = 3 * nIntegrableObjects_ - nConstraints_; |
332 |
gezelter |
2 |
|
333 |
|
|
|
334 |
gezelter |
246 |
#ifdef IS_MPI |
335 |
|
|
MPI_Allreduce(&ndfTrans_local,&ndfTrans_,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD); |
336 |
|
|
#else |
337 |
|
|
ndfTrans_ = ndfTrans_local; |
338 |
|
|
#endif |
339 |
gezelter |
2 |
|
340 |
gezelter |
246 |
ndfTrans_ = ndfTrans_ - 3 - nZconstraint_; |
341 |
|
|
|
342 |
gezelter |
507 |
} |
343 |
gezelter |
2 |
|
344 |
gezelter |
507 |
void SimInfo::addExcludePairs(Molecule* mol) { |
345 |
gezelter |
246 |
std::vector<Bond*>::iterator bondIter; |
346 |
|
|
std::vector<Bend*>::iterator bendIter; |
347 |
|
|
std::vector<Torsion*>::iterator torsionIter; |
348 |
|
|
Bond* bond; |
349 |
|
|
Bend* bend; |
350 |
|
|
Torsion* torsion; |
351 |
|
|
int a; |
352 |
|
|
int b; |
353 |
|
|
int c; |
354 |
|
|
int d; |
355 |
tim |
749 |
|
356 |
|
|
std::map<int, std::set<int> > atomGroups; |
357 |
|
|
|
358 |
|
|
Molecule::RigidBodyIterator rbIter; |
359 |
|
|
RigidBody* rb; |
360 |
|
|
Molecule::IntegrableObjectIterator ii; |
361 |
|
|
StuntDouble* integrableObject; |
362 |
gezelter |
246 |
|
363 |
tim |
749 |
for (integrableObject = mol->beginIntegrableObject(ii); integrableObject != NULL; |
364 |
|
|
integrableObject = mol->nextIntegrableObject(ii)) { |
365 |
|
|
|
366 |
|
|
if (integrableObject->isRigidBody()) { |
367 |
|
|
rb = static_cast<RigidBody*>(integrableObject); |
368 |
|
|
std::vector<Atom*> atoms = rb->getAtoms(); |
369 |
|
|
std::set<int> rigidAtoms; |
370 |
|
|
for (int i = 0; i < atoms.size(); ++i) { |
371 |
|
|
rigidAtoms.insert(atoms[i]->getGlobalIndex()); |
372 |
|
|
} |
373 |
|
|
for (int i = 0; i < atoms.size(); ++i) { |
374 |
|
|
atomGroups.insert(std::map<int, std::set<int> >::value_type(atoms[i]->getGlobalIndex(), rigidAtoms)); |
375 |
|
|
} |
376 |
|
|
} else { |
377 |
|
|
std::set<int> oneAtomSet; |
378 |
|
|
oneAtomSet.insert(integrableObject->getGlobalIndex()); |
379 |
|
|
atomGroups.insert(std::map<int, std::set<int> >::value_type(integrableObject->getGlobalIndex(), oneAtomSet)); |
380 |
|
|
} |
381 |
|
|
} |
382 |
|
|
|
383 |
|
|
|
384 |
|
|
|
385 |
gezelter |
246 |
for (bond= mol->beginBond(bondIter); bond != NULL; bond = mol->nextBond(bondIter)) { |
386 |
gezelter |
507 |
a = bond->getAtomA()->getGlobalIndex(); |
387 |
|
|
b = bond->getAtomB()->getGlobalIndex(); |
388 |
|
|
exclude_.addPair(a, b); |
389 |
gezelter |
246 |
} |
390 |
gezelter |
2 |
|
391 |
gezelter |
246 |
for (bend= mol->beginBend(bendIter); bend != NULL; bend = mol->nextBend(bendIter)) { |
392 |
gezelter |
507 |
a = bend->getAtomA()->getGlobalIndex(); |
393 |
|
|
b = bend->getAtomB()->getGlobalIndex(); |
394 |
|
|
c = bend->getAtomC()->getGlobalIndex(); |
395 |
tim |
749 |
std::set<int> rigidSetA = getRigidSet(a, atomGroups); |
396 |
|
|
std::set<int> rigidSetB = getRigidSet(b, atomGroups); |
397 |
|
|
std::set<int> rigidSetC = getRigidSet(c, atomGroups); |
398 |
gezelter |
2 |
|
399 |
tim |
749 |
exclude_.addPairs(rigidSetA, rigidSetB); |
400 |
|
|
exclude_.addPairs(rigidSetA, rigidSetC); |
401 |
|
|
exclude_.addPairs(rigidSetB, rigidSetC); |
402 |
|
|
|
403 |
|
|
//exclude_.addPair(a, b); |
404 |
|
|
//exclude_.addPair(a, c); |
405 |
|
|
//exclude_.addPair(b, c); |
406 |
gezelter |
246 |
} |
407 |
gezelter |
2 |
|
408 |
gezelter |
246 |
for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; torsion = mol->nextTorsion(torsionIter)) { |
409 |
gezelter |
507 |
a = torsion->getAtomA()->getGlobalIndex(); |
410 |
|
|
b = torsion->getAtomB()->getGlobalIndex(); |
411 |
|
|
c = torsion->getAtomC()->getGlobalIndex(); |
412 |
|
|
d = torsion->getAtomD()->getGlobalIndex(); |
413 |
tim |
749 |
std::set<int> rigidSetA = getRigidSet(a, atomGroups); |
414 |
|
|
std::set<int> rigidSetB = getRigidSet(b, atomGroups); |
415 |
|
|
std::set<int> rigidSetC = getRigidSet(c, atomGroups); |
416 |
|
|
std::set<int> rigidSetD = getRigidSet(d, atomGroups); |
417 |
gezelter |
2 |
|
418 |
tim |
749 |
exclude_.addPairs(rigidSetA, rigidSetB); |
419 |
|
|
exclude_.addPairs(rigidSetA, rigidSetC); |
420 |
|
|
exclude_.addPairs(rigidSetA, rigidSetD); |
421 |
|
|
exclude_.addPairs(rigidSetB, rigidSetC); |
422 |
|
|
exclude_.addPairs(rigidSetB, rigidSetD); |
423 |
|
|
exclude_.addPairs(rigidSetC, rigidSetD); |
424 |
|
|
|
425 |
|
|
/* |
426 |
|
|
exclude_.addPairs(rigidSetA.begin(), rigidSetA.end(), rigidSetB.begin(), rigidSetB.end()); |
427 |
|
|
exclude_.addPairs(rigidSetA.begin(), rigidSetA.end(), rigidSetC.begin(), rigidSetC.end()); |
428 |
|
|
exclude_.addPairs(rigidSetA.begin(), rigidSetA.end(), rigidSetD.begin(), rigidSetD.end()); |
429 |
|
|
exclude_.addPairs(rigidSetB.begin(), rigidSetB.end(), rigidSetC.begin(), rigidSetC.end()); |
430 |
|
|
exclude_.addPairs(rigidSetB.begin(), rigidSetB.end(), rigidSetD.begin(), rigidSetD.end()); |
431 |
|
|
exclude_.addPairs(rigidSetC.begin(), rigidSetC.end(), rigidSetD.begin(), rigidSetD.end()); |
432 |
|
|
|
433 |
|
|
|
434 |
gezelter |
507 |
exclude_.addPair(a, b); |
435 |
|
|
exclude_.addPair(a, c); |
436 |
|
|
exclude_.addPair(a, d); |
437 |
|
|
exclude_.addPair(b, c); |
438 |
|
|
exclude_.addPair(b, d); |
439 |
|
|
exclude_.addPair(c, d); |
440 |
tim |
749 |
*/ |
441 |
gezelter |
2 |
} |
442 |
|
|
|
443 |
tim |
430 |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
444 |
gezelter |
507 |
std::vector<Atom*> atoms = rb->getAtoms(); |
445 |
|
|
for (int i = 0; i < atoms.size() -1 ; ++i) { |
446 |
|
|
for (int j = i + 1; j < atoms.size(); ++j) { |
447 |
|
|
a = atoms[i]->getGlobalIndex(); |
448 |
|
|
b = atoms[j]->getGlobalIndex(); |
449 |
|
|
exclude_.addPair(a, b); |
450 |
|
|
} |
451 |
|
|
} |
452 |
tim |
430 |
} |
453 |
|
|
|
454 |
gezelter |
507 |
} |
455 |
gezelter |
246 |
|
456 |
gezelter |
507 |
void SimInfo::removeExcludePairs(Molecule* mol) { |
457 |
gezelter |
246 |
std::vector<Bond*>::iterator bondIter; |
458 |
|
|
std::vector<Bend*>::iterator bendIter; |
459 |
|
|
std::vector<Torsion*>::iterator torsionIter; |
460 |
|
|
Bond* bond; |
461 |
|
|
Bend* bend; |
462 |
|
|
Torsion* torsion; |
463 |
|
|
int a; |
464 |
|
|
int b; |
465 |
|
|
int c; |
466 |
|
|
int d; |
467 |
tim |
749 |
|
468 |
|
|
std::map<int, std::set<int> > atomGroups; |
469 |
|
|
|
470 |
|
|
Molecule::RigidBodyIterator rbIter; |
471 |
|
|
RigidBody* rb; |
472 |
|
|
Molecule::IntegrableObjectIterator ii; |
473 |
|
|
StuntDouble* integrableObject; |
474 |
gezelter |
246 |
|
475 |
tim |
749 |
for (integrableObject = mol->beginIntegrableObject(ii); integrableObject != NULL; |
476 |
|
|
integrableObject = mol->nextIntegrableObject(ii)) { |
477 |
|
|
|
478 |
|
|
if (integrableObject->isRigidBody()) { |
479 |
|
|
rb = static_cast<RigidBody*>(integrableObject); |
480 |
|
|
std::vector<Atom*> atoms = rb->getAtoms(); |
481 |
|
|
std::set<int> rigidAtoms; |
482 |
|
|
for (int i = 0; i < atoms.size(); ++i) { |
483 |
|
|
rigidAtoms.insert(atoms[i]->getGlobalIndex()); |
484 |
|
|
} |
485 |
|
|
for (int i = 0; i < atoms.size(); ++i) { |
486 |
|
|
atomGroups.insert(std::map<int, std::set<int> >::value_type(atoms[i]->getGlobalIndex(), rigidAtoms)); |
487 |
|
|
} |
488 |
|
|
} else { |
489 |
|
|
std::set<int> oneAtomSet; |
490 |
|
|
oneAtomSet.insert(integrableObject->getGlobalIndex()); |
491 |
|
|
atomGroups.insert(std::map<int, std::set<int> >::value_type(integrableObject->getGlobalIndex(), oneAtomSet)); |
492 |
|
|
} |
493 |
|
|
} |
494 |
|
|
|
495 |
|
|
|
496 |
gezelter |
246 |
for (bond= mol->beginBond(bondIter); bond != NULL; bond = mol->nextBond(bondIter)) { |
497 |
gezelter |
507 |
a = bond->getAtomA()->getGlobalIndex(); |
498 |
|
|
b = bond->getAtomB()->getGlobalIndex(); |
499 |
|
|
exclude_.removePair(a, b); |
500 |
gezelter |
2 |
} |
501 |
gezelter |
246 |
|
502 |
|
|
for (bend= mol->beginBend(bendIter); bend != NULL; bend = mol->nextBend(bendIter)) { |
503 |
gezelter |
507 |
a = bend->getAtomA()->getGlobalIndex(); |
504 |
|
|
b = bend->getAtomB()->getGlobalIndex(); |
505 |
|
|
c = bend->getAtomC()->getGlobalIndex(); |
506 |
gezelter |
246 |
|
507 |
tim |
749 |
std::set<int> rigidSetA = getRigidSet(a, atomGroups); |
508 |
|
|
std::set<int> rigidSetB = getRigidSet(b, atomGroups); |
509 |
|
|
std::set<int> rigidSetC = getRigidSet(c, atomGroups); |
510 |
|
|
|
511 |
|
|
exclude_.removePairs(rigidSetA, rigidSetB); |
512 |
|
|
exclude_.removePairs(rigidSetA, rigidSetC); |
513 |
|
|
exclude_.removePairs(rigidSetB, rigidSetC); |
514 |
|
|
|
515 |
|
|
//exclude_.removePair(a, b); |
516 |
|
|
//exclude_.removePair(a, c); |
517 |
|
|
//exclude_.removePair(b, c); |
518 |
gezelter |
2 |
} |
519 |
gezelter |
246 |
|
520 |
|
|
for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; torsion = mol->nextTorsion(torsionIter)) { |
521 |
gezelter |
507 |
a = torsion->getAtomA()->getGlobalIndex(); |
522 |
|
|
b = torsion->getAtomB()->getGlobalIndex(); |
523 |
|
|
c = torsion->getAtomC()->getGlobalIndex(); |
524 |
|
|
d = torsion->getAtomD()->getGlobalIndex(); |
525 |
gezelter |
246 |
|
526 |
tim |
749 |
std::set<int> rigidSetA = getRigidSet(a, atomGroups); |
527 |
|
|
std::set<int> rigidSetB = getRigidSet(b, atomGroups); |
528 |
|
|
std::set<int> rigidSetC = getRigidSet(c, atomGroups); |
529 |
|
|
std::set<int> rigidSetD = getRigidSet(d, atomGroups); |
530 |
|
|
|
531 |
|
|
exclude_.removePairs(rigidSetA, rigidSetB); |
532 |
|
|
exclude_.removePairs(rigidSetA, rigidSetC); |
533 |
|
|
exclude_.removePairs(rigidSetA, rigidSetD); |
534 |
|
|
exclude_.removePairs(rigidSetB, rigidSetC); |
535 |
|
|
exclude_.removePairs(rigidSetB, rigidSetD); |
536 |
|
|
exclude_.removePairs(rigidSetC, rigidSetD); |
537 |
|
|
|
538 |
|
|
/* |
539 |
|
|
exclude_.removePairs(rigidSetA.begin(), rigidSetA.end(), rigidSetB.begin(), rigidSetB.end()); |
540 |
|
|
exclude_.removePairs(rigidSetA.begin(), rigidSetA.end(), rigidSetC.begin(), rigidSetC.end()); |
541 |
|
|
exclude_.removePairs(rigidSetA.begin(), rigidSetA.end(), rigidSetD.begin(), rigidSetD.end()); |
542 |
|
|
exclude_.removePairs(rigidSetB.begin(), rigidSetB.end(), rigidSetC.begin(), rigidSetC.end()); |
543 |
|
|
exclude_.removePairs(rigidSetB.begin(), rigidSetB.end(), rigidSetD.begin(), rigidSetD.end()); |
544 |
|
|
exclude_.removePairs(rigidSetC.begin(), rigidSetC.end(), rigidSetD.begin(), rigidSetD.end()); |
545 |
|
|
|
546 |
|
|
|
547 |
gezelter |
507 |
exclude_.removePair(a, b); |
548 |
|
|
exclude_.removePair(a, c); |
549 |
|
|
exclude_.removePair(a, d); |
550 |
|
|
exclude_.removePair(b, c); |
551 |
|
|
exclude_.removePair(b, d); |
552 |
|
|
exclude_.removePair(c, d); |
553 |
tim |
749 |
*/ |
554 |
gezelter |
246 |
} |
555 |
|
|
|
556 |
tim |
430 |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
557 |
gezelter |
507 |
std::vector<Atom*> atoms = rb->getAtoms(); |
558 |
|
|
for (int i = 0; i < atoms.size() -1 ; ++i) { |
559 |
|
|
for (int j = i + 1; j < atoms.size(); ++j) { |
560 |
|
|
a = atoms[i]->getGlobalIndex(); |
561 |
|
|
b = atoms[j]->getGlobalIndex(); |
562 |
|
|
exclude_.removePair(a, b); |
563 |
|
|
} |
564 |
|
|
} |
565 |
tim |
430 |
} |
566 |
|
|
|
567 |
gezelter |
507 |
} |
568 |
gezelter |
2 |
|
569 |
|
|
|
570 |
gezelter |
507 |
void SimInfo::addMoleculeStamp(MoleculeStamp* molStamp, int nmol) { |
571 |
gezelter |
246 |
int curStampId; |
572 |
gezelter |
2 |
|
573 |
gezelter |
246 |
//index from 0 |
574 |
|
|
curStampId = moleculeStamps_.size(); |
575 |
gezelter |
2 |
|
576 |
gezelter |
246 |
moleculeStamps_.push_back(molStamp); |
577 |
|
|
molStampIds_.insert(molStampIds_.end(), nmol, curStampId); |
578 |
gezelter |
507 |
} |
579 |
gezelter |
2 |
|
580 |
gezelter |
507 |
void SimInfo::update() { |
581 |
gezelter |
2 |
|
582 |
gezelter |
246 |
setupSimType(); |
583 |
gezelter |
2 |
|
584 |
gezelter |
246 |
#ifdef IS_MPI |
585 |
|
|
setupFortranParallel(); |
586 |
|
|
#endif |
587 |
gezelter |
2 |
|
588 |
gezelter |
246 |
setupFortranSim(); |
589 |
gezelter |
2 |
|
590 |
gezelter |
246 |
//setup fortran force field |
591 |
|
|
/** @deprecate */ |
592 |
|
|
int isError = 0; |
593 |
chrisfen |
598 |
|
594 |
chrisfen |
603 |
setupElectrostaticSummationMethod( isError ); |
595 |
chrisfen |
726 |
setupSwitchingFunction(); |
596 |
chrisfen |
598 |
|
597 |
gezelter |
246 |
if(isError){ |
598 |
gezelter |
507 |
sprintf( painCave.errMsg, |
599 |
|
|
"ForceField error: There was an error initializing the forceField in fortran.\n" ); |
600 |
|
|
painCave.isFatal = 1; |
601 |
|
|
simError(); |
602 |
gezelter |
246 |
} |
603 |
gezelter |
2 |
|
604 |
gezelter |
246 |
|
605 |
|
|
setupCutoff(); |
606 |
gezelter |
2 |
|
607 |
gezelter |
246 |
calcNdf(); |
608 |
|
|
calcNdfRaw(); |
609 |
|
|
calcNdfTrans(); |
610 |
|
|
|
611 |
|
|
fortranInitialized_ = true; |
612 |
gezelter |
507 |
} |
613 |
gezelter |
2 |
|
614 |
gezelter |
507 |
std::set<AtomType*> SimInfo::getUniqueAtomTypes() { |
615 |
gezelter |
246 |
SimInfo::MoleculeIterator mi; |
616 |
|
|
Molecule* mol; |
617 |
|
|
Molecule::AtomIterator ai; |
618 |
|
|
Atom* atom; |
619 |
|
|
std::set<AtomType*> atomTypes; |
620 |
gezelter |
2 |
|
621 |
gezelter |
246 |
for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
622 |
gezelter |
2 |
|
623 |
gezelter |
507 |
for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
624 |
|
|
atomTypes.insert(atom->getAtomType()); |
625 |
|
|
} |
626 |
gezelter |
246 |
|
627 |
|
|
} |
628 |
gezelter |
2 |
|
629 |
gezelter |
246 |
return atomTypes; |
630 |
gezelter |
507 |
} |
631 |
gezelter |
2 |
|
632 |
gezelter |
507 |
void SimInfo::setupSimType() { |
633 |
gezelter |
246 |
std::set<AtomType*>::iterator i; |
634 |
|
|
std::set<AtomType*> atomTypes; |
635 |
|
|
atomTypes = getUniqueAtomTypes(); |
636 |
gezelter |
2 |
|
637 |
gezelter |
246 |
int useLennardJones = 0; |
638 |
|
|
int useElectrostatic = 0; |
639 |
|
|
int useEAM = 0; |
640 |
chuckv |
734 |
int useSC = 0; |
641 |
gezelter |
246 |
int useCharge = 0; |
642 |
|
|
int useDirectional = 0; |
643 |
|
|
int useDipole = 0; |
644 |
|
|
int useGayBerne = 0; |
645 |
|
|
int useSticky = 0; |
646 |
chrisfen |
523 |
int useStickyPower = 0; |
647 |
gezelter |
246 |
int useShape = 0; |
648 |
|
|
int useFLARB = 0; //it is not in AtomType yet |
649 |
|
|
int useDirectionalAtom = 0; |
650 |
|
|
int useElectrostatics = 0; |
651 |
|
|
//usePBC and useRF are from simParams |
652 |
tim |
665 |
int usePBC = simParams_->getUsePeriodicBoundaryConditions(); |
653 |
chrisfen |
611 |
int useRF; |
654 |
chrisfen |
720 |
int useSF; |
655 |
tim |
665 |
std::string myMethod; |
656 |
gezelter |
2 |
|
657 |
chrisfen |
611 |
// set the useRF logical |
658 |
tim |
665 |
useRF = 0; |
659 |
chrisfen |
720 |
useSF = 0; |
660 |
chrisfen |
691 |
|
661 |
|
|
|
662 |
tim |
665 |
if (simParams_->haveElectrostaticSummationMethod()) { |
663 |
chrisfen |
691 |
std::string myMethod = simParams_->getElectrostaticSummationMethod(); |
664 |
|
|
toUpper(myMethod); |
665 |
|
|
if (myMethod == "REACTION_FIELD") { |
666 |
|
|
useRF=1; |
667 |
chrisfen |
705 |
} else { |
668 |
chrisfen |
720 |
if (myMethod == "SHIFTED_FORCE") { |
669 |
|
|
useSF = 1; |
670 |
chrisfen |
705 |
} |
671 |
chrisfen |
691 |
} |
672 |
tim |
665 |
} |
673 |
chrisfen |
611 |
|
674 |
gezelter |
246 |
//loop over all of the atom types |
675 |
|
|
for (i = atomTypes.begin(); i != atomTypes.end(); ++i) { |
676 |
gezelter |
507 |
useLennardJones |= (*i)->isLennardJones(); |
677 |
|
|
useElectrostatic |= (*i)->isElectrostatic(); |
678 |
|
|
useEAM |= (*i)->isEAM(); |
679 |
chuckv |
734 |
useSC |= (*i)->isSC(); |
680 |
gezelter |
507 |
useCharge |= (*i)->isCharge(); |
681 |
|
|
useDirectional |= (*i)->isDirectional(); |
682 |
|
|
useDipole |= (*i)->isDipole(); |
683 |
|
|
useGayBerne |= (*i)->isGayBerne(); |
684 |
|
|
useSticky |= (*i)->isSticky(); |
685 |
chrisfen |
523 |
useStickyPower |= (*i)->isStickyPower(); |
686 |
gezelter |
507 |
useShape |= (*i)->isShape(); |
687 |
gezelter |
246 |
} |
688 |
gezelter |
2 |
|
689 |
chrisfen |
523 |
if (useSticky || useStickyPower || useDipole || useGayBerne || useShape) { |
690 |
gezelter |
507 |
useDirectionalAtom = 1; |
691 |
gezelter |
246 |
} |
692 |
gezelter |
2 |
|
693 |
gezelter |
246 |
if (useCharge || useDipole) { |
694 |
gezelter |
507 |
useElectrostatics = 1; |
695 |
gezelter |
246 |
} |
696 |
gezelter |
2 |
|
697 |
gezelter |
246 |
#ifdef IS_MPI |
698 |
|
|
int temp; |
699 |
gezelter |
2 |
|
700 |
gezelter |
246 |
temp = usePBC; |
701 |
|
|
MPI_Allreduce(&temp, &usePBC, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
702 |
gezelter |
2 |
|
703 |
gezelter |
246 |
temp = useDirectionalAtom; |
704 |
|
|
MPI_Allreduce(&temp, &useDirectionalAtom, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
705 |
gezelter |
2 |
|
706 |
gezelter |
246 |
temp = useLennardJones; |
707 |
|
|
MPI_Allreduce(&temp, &useLennardJones, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
708 |
gezelter |
2 |
|
709 |
gezelter |
246 |
temp = useElectrostatics; |
710 |
|
|
MPI_Allreduce(&temp, &useElectrostatics, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
711 |
gezelter |
2 |
|
712 |
gezelter |
246 |
temp = useCharge; |
713 |
|
|
MPI_Allreduce(&temp, &useCharge, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
714 |
gezelter |
2 |
|
715 |
gezelter |
246 |
temp = useDipole; |
716 |
|
|
MPI_Allreduce(&temp, &useDipole, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
717 |
gezelter |
2 |
|
718 |
gezelter |
246 |
temp = useSticky; |
719 |
|
|
MPI_Allreduce(&temp, &useSticky, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
720 |
gezelter |
2 |
|
721 |
chrisfen |
523 |
temp = useStickyPower; |
722 |
|
|
MPI_Allreduce(&temp, &useStickyPower, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
723 |
|
|
|
724 |
gezelter |
246 |
temp = useGayBerne; |
725 |
|
|
MPI_Allreduce(&temp, &useGayBerne, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
726 |
gezelter |
2 |
|
727 |
gezelter |
246 |
temp = useEAM; |
728 |
|
|
MPI_Allreduce(&temp, &useEAM, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
729 |
gezelter |
2 |
|
730 |
chuckv |
734 |
temp = useSC; |
731 |
|
|
MPI_Allreduce(&temp, &useSC, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
732 |
|
|
|
733 |
gezelter |
246 |
temp = useShape; |
734 |
|
|
MPI_Allreduce(&temp, &useShape, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
735 |
|
|
|
736 |
|
|
temp = useFLARB; |
737 |
|
|
MPI_Allreduce(&temp, &useFLARB, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
738 |
|
|
|
739 |
chrisfen |
611 |
temp = useRF; |
740 |
|
|
MPI_Allreduce(&temp, &useRF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
741 |
|
|
|
742 |
chrisfen |
720 |
temp = useSF; |
743 |
|
|
MPI_Allreduce(&temp, &useSF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
744 |
chrisfen |
705 |
|
745 |
gezelter |
2 |
#endif |
746 |
|
|
|
747 |
gezelter |
246 |
fInfo_.SIM_uses_PBC = usePBC; |
748 |
|
|
fInfo_.SIM_uses_DirectionalAtoms = useDirectionalAtom; |
749 |
|
|
fInfo_.SIM_uses_LennardJones = useLennardJones; |
750 |
|
|
fInfo_.SIM_uses_Electrostatics = useElectrostatics; |
751 |
|
|
fInfo_.SIM_uses_Charges = useCharge; |
752 |
|
|
fInfo_.SIM_uses_Dipoles = useDipole; |
753 |
|
|
fInfo_.SIM_uses_Sticky = useSticky; |
754 |
chrisfen |
523 |
fInfo_.SIM_uses_StickyPower = useStickyPower; |
755 |
gezelter |
246 |
fInfo_.SIM_uses_GayBerne = useGayBerne; |
756 |
|
|
fInfo_.SIM_uses_EAM = useEAM; |
757 |
chuckv |
734 |
fInfo_.SIM_uses_SC = useSC; |
758 |
gezelter |
246 |
fInfo_.SIM_uses_Shapes = useShape; |
759 |
|
|
fInfo_.SIM_uses_FLARB = useFLARB; |
760 |
chrisfen |
611 |
fInfo_.SIM_uses_RF = useRF; |
761 |
chrisfen |
720 |
fInfo_.SIM_uses_SF = useSF; |
762 |
gezelter |
2 |
|
763 |
chrisfen |
691 |
if( myMethod == "REACTION_FIELD") { |
764 |
|
|
|
765 |
gezelter |
507 |
if (simParams_->haveDielectric()) { |
766 |
|
|
fInfo_.dielect = simParams_->getDielectric(); |
767 |
|
|
} else { |
768 |
|
|
sprintf(painCave.errMsg, |
769 |
|
|
"SimSetup Error: No Dielectric constant was set.\n" |
770 |
|
|
"\tYou are trying to use Reaction Field without" |
771 |
|
|
"\tsetting a dielectric constant!\n"); |
772 |
|
|
painCave.isFatal = 1; |
773 |
|
|
simError(); |
774 |
chrisfen |
691 |
} |
775 |
gezelter |
246 |
} |
776 |
chrisfen |
705 |
|
777 |
gezelter |
507 |
} |
778 |
gezelter |
2 |
|
779 |
gezelter |
507 |
void SimInfo::setupFortranSim() { |
780 |
gezelter |
246 |
int isError; |
781 |
|
|
int nExclude; |
782 |
|
|
std::vector<int> fortranGlobalGroupMembership; |
783 |
|
|
|
784 |
|
|
nExclude = exclude_.getSize(); |
785 |
|
|
isError = 0; |
786 |
gezelter |
2 |
|
787 |
gezelter |
246 |
//globalGroupMembership_ is filled by SimCreator |
788 |
|
|
for (int i = 0; i < nGlobalAtoms_; i++) { |
789 |
gezelter |
507 |
fortranGlobalGroupMembership.push_back(globalGroupMembership_[i] + 1); |
790 |
gezelter |
246 |
} |
791 |
gezelter |
2 |
|
792 |
gezelter |
246 |
//calculate mass ratio of cutoff group |
793 |
|
|
std::vector<double> mfact; |
794 |
|
|
SimInfo::MoleculeIterator mi; |
795 |
|
|
Molecule* mol; |
796 |
|
|
Molecule::CutoffGroupIterator ci; |
797 |
|
|
CutoffGroup* cg; |
798 |
|
|
Molecule::AtomIterator ai; |
799 |
|
|
Atom* atom; |
800 |
|
|
double totalMass; |
801 |
|
|
|
802 |
|
|
//to avoid memory reallocation, reserve enough space for mfact |
803 |
|
|
mfact.reserve(getNCutoffGroups()); |
804 |
gezelter |
2 |
|
805 |
gezelter |
246 |
for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
806 |
gezelter |
507 |
for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { |
807 |
gezelter |
2 |
|
808 |
gezelter |
507 |
totalMass = cg->getMass(); |
809 |
|
|
for(atom = cg->beginAtom(ai); atom != NULL; atom = cg->nextAtom(ai)) { |
810 |
chrisfen |
645 |
// Check for massless groups - set mfact to 1 if true |
811 |
|
|
if (totalMass != 0) |
812 |
|
|
mfact.push_back(atom->getMass()/totalMass); |
813 |
|
|
else |
814 |
|
|
mfact.push_back( 1.0 ); |
815 |
gezelter |
507 |
} |
816 |
gezelter |
2 |
|
817 |
gezelter |
507 |
} |
818 |
gezelter |
246 |
} |
819 |
gezelter |
2 |
|
820 |
gezelter |
246 |
//fill ident array of local atoms (it is actually ident of AtomType, it is so confusing !!!) |
821 |
|
|
std::vector<int> identArray; |
822 |
gezelter |
2 |
|
823 |
gezelter |
246 |
//to avoid memory reallocation, reserve enough space identArray |
824 |
|
|
identArray.reserve(getNAtoms()); |
825 |
|
|
|
826 |
|
|
for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
827 |
gezelter |
507 |
for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
828 |
|
|
identArray.push_back(atom->getIdent()); |
829 |
|
|
} |
830 |
gezelter |
246 |
} |
831 |
gezelter |
2 |
|
832 |
gezelter |
246 |
//fill molMembershipArray |
833 |
|
|
//molMembershipArray is filled by SimCreator |
834 |
|
|
std::vector<int> molMembershipArray(nGlobalAtoms_); |
835 |
|
|
for (int i = 0; i < nGlobalAtoms_; i++) { |
836 |
gezelter |
507 |
molMembershipArray[i] = globalMolMembership_[i] + 1; |
837 |
gezelter |
246 |
} |
838 |
|
|
|
839 |
|
|
//setup fortran simulation |
840 |
|
|
int nGlobalExcludes = 0; |
841 |
|
|
int* globalExcludes = NULL; |
842 |
|
|
int* excludeList = exclude_.getExcludeList(); |
843 |
|
|
setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray[0], &nExclude, excludeList , |
844 |
gezelter |
507 |
&nGlobalExcludes, globalExcludes, &molMembershipArray[0], |
845 |
|
|
&mfact[0], &nCutoffGroups_, &fortranGlobalGroupMembership[0], &isError); |
846 |
gezelter |
2 |
|
847 |
gezelter |
246 |
if( isError ){ |
848 |
gezelter |
2 |
|
849 |
gezelter |
507 |
sprintf( painCave.errMsg, |
850 |
|
|
"There was an error setting the simulation information in fortran.\n" ); |
851 |
|
|
painCave.isFatal = 1; |
852 |
|
|
painCave.severity = OOPSE_ERROR; |
853 |
|
|
simError(); |
854 |
gezelter |
246 |
} |
855 |
|
|
|
856 |
|
|
#ifdef IS_MPI |
857 |
|
|
sprintf( checkPointMsg, |
858 |
gezelter |
507 |
"succesfully sent the simulation information to fortran.\n"); |
859 |
gezelter |
246 |
MPIcheckPoint(); |
860 |
|
|
#endif // is_mpi |
861 |
gezelter |
507 |
} |
862 |
gezelter |
2 |
|
863 |
|
|
|
864 |
gezelter |
246 |
#ifdef IS_MPI |
865 |
gezelter |
507 |
void SimInfo::setupFortranParallel() { |
866 |
gezelter |
246 |
|
867 |
|
|
//SimInfo is responsible for creating localToGlobalAtomIndex and localToGlobalGroupIndex |
868 |
|
|
std::vector<int> localToGlobalAtomIndex(getNAtoms(), 0); |
869 |
|
|
std::vector<int> localToGlobalCutoffGroupIndex; |
870 |
|
|
SimInfo::MoleculeIterator mi; |
871 |
|
|
Molecule::AtomIterator ai; |
872 |
|
|
Molecule::CutoffGroupIterator ci; |
873 |
|
|
Molecule* mol; |
874 |
|
|
Atom* atom; |
875 |
|
|
CutoffGroup* cg; |
876 |
|
|
mpiSimData parallelData; |
877 |
|
|
int isError; |
878 |
gezelter |
2 |
|
879 |
gezelter |
246 |
for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
880 |
gezelter |
2 |
|
881 |
gezelter |
507 |
//local index(index in DataStorge) of atom is important |
882 |
|
|
for (atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
883 |
|
|
localToGlobalAtomIndex[atom->getLocalIndex()] = atom->getGlobalIndex() + 1; |
884 |
|
|
} |
885 |
gezelter |
2 |
|
886 |
gezelter |
507 |
//local index of cutoff group is trivial, it only depends on the order of travesing |
887 |
|
|
for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { |
888 |
|
|
localToGlobalCutoffGroupIndex.push_back(cg->getGlobalIndex() + 1); |
889 |
|
|
} |
890 |
gezelter |
246 |
|
891 |
|
|
} |
892 |
gezelter |
2 |
|
893 |
gezelter |
246 |
//fill up mpiSimData struct |
894 |
|
|
parallelData.nMolGlobal = getNGlobalMolecules(); |
895 |
|
|
parallelData.nMolLocal = getNMolecules(); |
896 |
|
|
parallelData.nAtomsGlobal = getNGlobalAtoms(); |
897 |
|
|
parallelData.nAtomsLocal = getNAtoms(); |
898 |
|
|
parallelData.nGroupsGlobal = getNGlobalCutoffGroups(); |
899 |
|
|
parallelData.nGroupsLocal = getNCutoffGroups(); |
900 |
|
|
parallelData.myNode = worldRank; |
901 |
|
|
MPI_Comm_size(MPI_COMM_WORLD, &(parallelData.nProcessors)); |
902 |
gezelter |
2 |
|
903 |
gezelter |
246 |
//pass mpiSimData struct and index arrays to fortran |
904 |
|
|
setFsimParallel(¶llelData, &(parallelData.nAtomsLocal), |
905 |
|
|
&localToGlobalAtomIndex[0], &(parallelData.nGroupsLocal), |
906 |
|
|
&localToGlobalCutoffGroupIndex[0], &isError); |
907 |
gezelter |
2 |
|
908 |
gezelter |
246 |
if (isError) { |
909 |
gezelter |
507 |
sprintf(painCave.errMsg, |
910 |
|
|
"mpiRefresh errror: fortran didn't like something we gave it.\n"); |
911 |
|
|
painCave.isFatal = 1; |
912 |
|
|
simError(); |
913 |
gezelter |
246 |
} |
914 |
gezelter |
2 |
|
915 |
gezelter |
246 |
sprintf(checkPointMsg, " mpiRefresh successful.\n"); |
916 |
|
|
MPIcheckPoint(); |
917 |
gezelter |
2 |
|
918 |
|
|
|
919 |
gezelter |
507 |
} |
920 |
chrisfen |
143 |
|
921 |
gezelter |
246 |
#endif |
922 |
chrisfen |
143 |
|
923 |
gezelter |
764 |
void SimInfo::setupCutoff() { |
924 |
gezelter |
2 |
|
925 |
chuckv |
834 |
ForceFieldOptions& forceFieldOptions_ = forceField_->getForceFieldOptions(); |
926 |
|
|
|
927 |
gezelter |
764 |
// Check the cutoff policy |
928 |
chuckv |
834 |
int cp = TRADITIONAL_CUTOFF_POLICY; // Set to traditional by default |
929 |
|
|
|
930 |
|
|
std::string myPolicy; |
931 |
|
|
if (forceFieldOptions_.haveCutoffPolicy()){ |
932 |
|
|
myPolicy = forceFieldOptions_.getCutoffPolicy(); |
933 |
|
|
}else if (simParams_->haveCutoffPolicy()) { |
934 |
|
|
myPolicy = simParams_->getCutoffPolicy(); |
935 |
|
|
} |
936 |
|
|
|
937 |
|
|
if (!myPolicy.empty()){ |
938 |
tim |
665 |
toUpper(myPolicy); |
939 |
gezelter |
586 |
if (myPolicy == "MIX") { |
940 |
|
|
cp = MIX_CUTOFF_POLICY; |
941 |
|
|
} else { |
942 |
|
|
if (myPolicy == "MAX") { |
943 |
|
|
cp = MAX_CUTOFF_POLICY; |
944 |
|
|
} else { |
945 |
|
|
if (myPolicy == "TRADITIONAL") { |
946 |
|
|
cp = TRADITIONAL_CUTOFF_POLICY; |
947 |
|
|
} else { |
948 |
|
|
// throw error |
949 |
|
|
sprintf( painCave.errMsg, |
950 |
|
|
"SimInfo error: Unknown cutoffPolicy. (Input file specified %s .)\n\tcutoffPolicy must be one of: \"Mix\", \"Max\", or \"Traditional\".", myPolicy.c_str() ); |
951 |
|
|
painCave.isFatal = 1; |
952 |
|
|
simError(); |
953 |
|
|
} |
954 |
|
|
} |
955 |
|
|
} |
956 |
gezelter |
764 |
} |
957 |
|
|
notifyFortranCutoffPolicy(&cp); |
958 |
chuckv |
629 |
|
959 |
gezelter |
764 |
// Check the Skin Thickness for neighborlists |
960 |
|
|
double skin; |
961 |
|
|
if (simParams_->haveSkinThickness()) { |
962 |
|
|
skin = simParams_->getSkinThickness(); |
963 |
|
|
notifyFortranSkinThickness(&skin); |
964 |
|
|
} |
965 |
|
|
|
966 |
|
|
// Check if the cutoff was set explicitly: |
967 |
|
|
if (simParams_->haveCutoffRadius()) { |
968 |
|
|
rcut_ = simParams_->getCutoffRadius(); |
969 |
|
|
if (simParams_->haveSwitchingRadius()) { |
970 |
|
|
rsw_ = simParams_->getSwitchingRadius(); |
971 |
|
|
} else { |
972 |
chrisfen |
878 |
if (fInfo_.SIM_uses_Charges | |
973 |
|
|
fInfo_.SIM_uses_Dipoles | |
974 |
|
|
fInfo_.SIM_uses_RF) { |
975 |
|
|
|
976 |
|
|
rsw_ = 0.85 * rcut_; |
977 |
|
|
sprintf(painCave.errMsg, |
978 |
|
|
"SimCreator Warning: No value was set for the switchingRadius.\n" |
979 |
|
|
"\tOOPSE will use a default value of 85\% of the cutoffRadius" |
980 |
|
|
"\tswitchingRadius = %f. for this simulation\n", rsw_); |
981 |
|
|
painCave.isFatal = 0; |
982 |
|
|
simError(); |
983 |
|
|
} else { |
984 |
|
|
rsw_ = rcut_; |
985 |
|
|
sprintf(painCave.errMsg, |
986 |
|
|
"SimCreator Warning: No value was set for the switchingRadius.\n" |
987 |
|
|
"\tOOPSE will use the same value as the cutoffRadius.\n" |
988 |
|
|
"\tswitchingRadius = %f. for this simulation\n", rsw_); |
989 |
|
|
painCave.isFatal = 0; |
990 |
|
|
simError(); |
991 |
|
|
} |
992 |
|
|
|
993 |
gezelter |
764 |
notifyFortranCutoffs(&rcut_, &rsw_); |
994 |
|
|
|
995 |
|
|
} else { |
996 |
|
|
|
997 |
|
|
// For electrostatic atoms, we'll assume a large safe value: |
998 |
|
|
if (fInfo_.SIM_uses_Charges | fInfo_.SIM_uses_Dipoles | fInfo_.SIM_uses_RF) { |
999 |
|
|
sprintf(painCave.errMsg, |
1000 |
|
|
"SimCreator Warning: No value was set for the cutoffRadius.\n" |
1001 |
|
|
"\tOOPSE will use a default value of 15.0 angstroms" |
1002 |
|
|
"\tfor the cutoffRadius.\n"); |
1003 |
|
|
painCave.isFatal = 0; |
1004 |
|
|
simError(); |
1005 |
|
|
rcut_ = 15.0; |
1006 |
|
|
|
1007 |
|
|
if (simParams_->haveElectrostaticSummationMethod()) { |
1008 |
|
|
std::string myMethod = simParams_->getElectrostaticSummationMethod(); |
1009 |
|
|
toUpper(myMethod); |
1010 |
|
|
if (myMethod == "SHIFTED_POTENTIAL" || myMethod == "SHIFTED_FORCE") { |
1011 |
|
|
if (simParams_->haveSwitchingRadius()){ |
1012 |
|
|
sprintf(painCave.errMsg, |
1013 |
|
|
"SimInfo Warning: A value was set for the switchingRadius\n" |
1014 |
|
|
"\teven though the electrostaticSummationMethod was\n" |
1015 |
|
|
"\tset to %s\n", myMethod.c_str()); |
1016 |
|
|
painCave.isFatal = 1; |
1017 |
|
|
simError(); |
1018 |
|
|
} |
1019 |
|
|
} |
1020 |
|
|
} |
1021 |
|
|
|
1022 |
|
|
if (simParams_->haveSwitchingRadius()){ |
1023 |
|
|
rsw_ = simParams_->getSwitchingRadius(); |
1024 |
|
|
} else { |
1025 |
|
|
sprintf(painCave.errMsg, |
1026 |
|
|
"SimCreator Warning: No value was set for switchingRadius.\n" |
1027 |
|
|
"\tOOPSE will use a default value of\n" |
1028 |
|
|
"\t0.85 * cutoffRadius for the switchingRadius\n"); |
1029 |
|
|
painCave.isFatal = 0; |
1030 |
|
|
simError(); |
1031 |
|
|
rsw_ = 0.85 * rcut_; |
1032 |
|
|
} |
1033 |
|
|
notifyFortranCutoffs(&rcut_, &rsw_); |
1034 |
|
|
} else { |
1035 |
|
|
// We didn't set rcut explicitly, and we don't have electrostatic atoms, so |
1036 |
|
|
// We'll punt and let fortran figure out the cutoffs later. |
1037 |
|
|
|
1038 |
|
|
notifyFortranYouAreOnYourOwn(); |
1039 |
chuckv |
629 |
|
1040 |
gezelter |
764 |
} |
1041 |
chuckv |
629 |
} |
1042 |
gezelter |
507 |
} |
1043 |
gezelter |
2 |
|
1044 |
chrisfen |
603 |
void SimInfo::setupElectrostaticSummationMethod( int isError ) { |
1045 |
chrisfen |
598 |
|
1046 |
|
|
int errorOut; |
1047 |
chrisfen |
603 |
int esm = NONE; |
1048 |
chrisfen |
709 |
int sm = UNDAMPED; |
1049 |
chrisfen |
598 |
double alphaVal; |
1050 |
chrisfen |
610 |
double dielectric; |
1051 |
chrisfen |
598 |
|
1052 |
|
|
errorOut = isError; |
1053 |
chrisfen |
610 |
alphaVal = simParams_->getDampingAlpha(); |
1054 |
|
|
dielectric = simParams_->getDielectric(); |
1055 |
chrisfen |
598 |
|
1056 |
chrisfen |
603 |
if (simParams_->haveElectrostaticSummationMethod()) { |
1057 |
chrisfen |
604 |
std::string myMethod = simParams_->getElectrostaticSummationMethod(); |
1058 |
tim |
665 |
toUpper(myMethod); |
1059 |
chrisfen |
603 |
if (myMethod == "NONE") { |
1060 |
|
|
esm = NONE; |
1061 |
chrisfen |
598 |
} else { |
1062 |
chrisfen |
709 |
if (myMethod == "SWITCHING_FUNCTION") { |
1063 |
|
|
esm = SWITCHING_FUNCTION; |
1064 |
chrisfen |
598 |
} else { |
1065 |
chrisfen |
709 |
if (myMethod == "SHIFTED_POTENTIAL") { |
1066 |
|
|
esm = SHIFTED_POTENTIAL; |
1067 |
|
|
} else { |
1068 |
|
|
if (myMethod == "SHIFTED_FORCE") { |
1069 |
|
|
esm = SHIFTED_FORCE; |
1070 |
chrisfen |
598 |
} else { |
1071 |
chrisfen |
709 |
if (myMethod == "REACTION_FIELD") { |
1072 |
|
|
esm = REACTION_FIELD; |
1073 |
|
|
} else { |
1074 |
|
|
// throw error |
1075 |
|
|
sprintf( painCave.errMsg, |
1076 |
gezelter |
764 |
"SimInfo error: Unknown electrostaticSummationMethod.\n" |
1077 |
|
|
"\t(Input file specified %s .)\n" |
1078 |
|
|
"\telectrostaticSummationMethod must be one of: \"none\",\n" |
1079 |
|
|
"\t\"shifted_potential\", \"shifted_force\", or \n" |
1080 |
|
|
"\t\"reaction_field\".\n", myMethod.c_str() ); |
1081 |
chrisfen |
709 |
painCave.isFatal = 1; |
1082 |
|
|
simError(); |
1083 |
|
|
} |
1084 |
|
|
} |
1085 |
|
|
} |
1086 |
chrisfen |
598 |
} |
1087 |
|
|
} |
1088 |
|
|
} |
1089 |
chrisfen |
709 |
|
1090 |
chrisfen |
716 |
if (simParams_->haveElectrostaticScreeningMethod()) { |
1091 |
|
|
std::string myScreen = simParams_->getElectrostaticScreeningMethod(); |
1092 |
chrisfen |
709 |
toUpper(myScreen); |
1093 |
|
|
if (myScreen == "UNDAMPED") { |
1094 |
|
|
sm = UNDAMPED; |
1095 |
|
|
} else { |
1096 |
|
|
if (myScreen == "DAMPED") { |
1097 |
|
|
sm = DAMPED; |
1098 |
|
|
if (!simParams_->haveDampingAlpha()) { |
1099 |
|
|
//throw error |
1100 |
|
|
sprintf( painCave.errMsg, |
1101 |
gezelter |
764 |
"SimInfo warning: dampingAlpha was not specified in the input file.\n" |
1102 |
|
|
"\tA default value of %f (1/ang) will be used.\n", alphaVal); |
1103 |
chrisfen |
709 |
painCave.isFatal = 0; |
1104 |
|
|
simError(); |
1105 |
|
|
} |
1106 |
chrisfen |
716 |
} else { |
1107 |
|
|
// throw error |
1108 |
|
|
sprintf( painCave.errMsg, |
1109 |
gezelter |
764 |
"SimInfo error: Unknown electrostaticScreeningMethod.\n" |
1110 |
|
|
"\t(Input file specified %s .)\n" |
1111 |
|
|
"\telectrostaticScreeningMethod must be one of: \"undamped\"\n" |
1112 |
|
|
"or \"damped\".\n", myScreen.c_str() ); |
1113 |
chrisfen |
716 |
painCave.isFatal = 1; |
1114 |
|
|
simError(); |
1115 |
chrisfen |
709 |
} |
1116 |
|
|
} |
1117 |
|
|
} |
1118 |
chrisfen |
716 |
|
1119 |
chrisfen |
610 |
// let's pass some summation method variables to fortran |
1120 |
chrisfen |
853 |
setElectrostaticSummationMethod( &esm ); |
1121 |
gezelter |
809 |
setFortranElectrostaticMethod( &esm ); |
1122 |
chrisfen |
709 |
setScreeningMethod( &sm ); |
1123 |
|
|
setDampingAlpha( &alphaVal ); |
1124 |
chrisfen |
610 |
setReactionFieldDielectric( &dielectric ); |
1125 |
gezelter |
764 |
initFortranFF( &errorOut ); |
1126 |
chrisfen |
598 |
} |
1127 |
|
|
|
1128 |
chrisfen |
726 |
void SimInfo::setupSwitchingFunction() { |
1129 |
|
|
int ft = CUBIC; |
1130 |
|
|
|
1131 |
|
|
if (simParams_->haveSwitchingFunctionType()) { |
1132 |
|
|
std::string funcType = simParams_->getSwitchingFunctionType(); |
1133 |
|
|
toUpper(funcType); |
1134 |
|
|
if (funcType == "CUBIC") { |
1135 |
|
|
ft = CUBIC; |
1136 |
|
|
} else { |
1137 |
|
|
if (funcType == "FIFTH_ORDER_POLYNOMIAL") { |
1138 |
|
|
ft = FIFTH_ORDER_POLY; |
1139 |
|
|
} else { |
1140 |
|
|
// throw error |
1141 |
|
|
sprintf( painCave.errMsg, |
1142 |
|
|
"SimInfo error: Unknown switchingFunctionType. (Input file specified %s .)\n\tswitchingFunctionType must be one of: \"cubic\" or \"fifth_order_polynomial\".", funcType.c_str() ); |
1143 |
|
|
painCave.isFatal = 1; |
1144 |
|
|
simError(); |
1145 |
|
|
} |
1146 |
|
|
} |
1147 |
|
|
} |
1148 |
|
|
|
1149 |
|
|
// send switching function notification to switcheroo |
1150 |
|
|
setFunctionType(&ft); |
1151 |
|
|
|
1152 |
|
|
} |
1153 |
|
|
|
1154 |
gezelter |
507 |
void SimInfo::addProperty(GenericData* genData) { |
1155 |
gezelter |
246 |
properties_.addProperty(genData); |
1156 |
gezelter |
507 |
} |
1157 |
gezelter |
2 |
|
1158 |
gezelter |
507 |
void SimInfo::removeProperty(const std::string& propName) { |
1159 |
gezelter |
246 |
properties_.removeProperty(propName); |
1160 |
gezelter |
507 |
} |
1161 |
gezelter |
2 |
|
1162 |
gezelter |
507 |
void SimInfo::clearProperties() { |
1163 |
gezelter |
246 |
properties_.clearProperties(); |
1164 |
gezelter |
507 |
} |
1165 |
gezelter |
2 |
|
1166 |
gezelter |
507 |
std::vector<std::string> SimInfo::getPropertyNames() { |
1167 |
gezelter |
246 |
return properties_.getPropertyNames(); |
1168 |
gezelter |
507 |
} |
1169 |
gezelter |
246 |
|
1170 |
gezelter |
507 |
std::vector<GenericData*> SimInfo::getProperties() { |
1171 |
gezelter |
246 |
return properties_.getProperties(); |
1172 |
gezelter |
507 |
} |
1173 |
gezelter |
2 |
|
1174 |
gezelter |
507 |
GenericData* SimInfo::getPropertyByName(const std::string& propName) { |
1175 |
gezelter |
246 |
return properties_.getPropertyByName(propName); |
1176 |
gezelter |
507 |
} |
1177 |
gezelter |
2 |
|
1178 |
gezelter |
507 |
void SimInfo::setSnapshotManager(SnapshotManager* sman) { |
1179 |
tim |
432 |
if (sman_ == sman) { |
1180 |
gezelter |
507 |
return; |
1181 |
tim |
432 |
} |
1182 |
|
|
delete sman_; |
1183 |
gezelter |
246 |
sman_ = sman; |
1184 |
gezelter |
2 |
|
1185 |
gezelter |
246 |
Molecule* mol; |
1186 |
|
|
RigidBody* rb; |
1187 |
|
|
Atom* atom; |
1188 |
|
|
SimInfo::MoleculeIterator mi; |
1189 |
|
|
Molecule::RigidBodyIterator rbIter; |
1190 |
|
|
Molecule::AtomIterator atomIter;; |
1191 |
|
|
|
1192 |
|
|
for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
1193 |
|
|
|
1194 |
gezelter |
507 |
for (atom = mol->beginAtom(atomIter); atom != NULL; atom = mol->nextAtom(atomIter)) { |
1195 |
|
|
atom->setSnapshotManager(sman_); |
1196 |
|
|
} |
1197 |
gezelter |
246 |
|
1198 |
gezelter |
507 |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
1199 |
|
|
rb->setSnapshotManager(sman_); |
1200 |
|
|
} |
1201 |
gezelter |
246 |
} |
1202 |
gezelter |
2 |
|
1203 |
gezelter |
507 |
} |
1204 |
gezelter |
2 |
|
1205 |
gezelter |
507 |
Vector3d SimInfo::getComVel(){ |
1206 |
gezelter |
246 |
SimInfo::MoleculeIterator i; |
1207 |
|
|
Molecule* mol; |
1208 |
gezelter |
2 |
|
1209 |
gezelter |
246 |
Vector3d comVel(0.0); |
1210 |
|
|
double totalMass = 0.0; |
1211 |
gezelter |
2 |
|
1212 |
gezelter |
246 |
|
1213 |
|
|
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
1214 |
gezelter |
507 |
double mass = mol->getMass(); |
1215 |
|
|
totalMass += mass; |
1216 |
|
|
comVel += mass * mol->getComVel(); |
1217 |
gezelter |
246 |
} |
1218 |
gezelter |
2 |
|
1219 |
gezelter |
246 |
#ifdef IS_MPI |
1220 |
|
|
double tmpMass = totalMass; |
1221 |
|
|
Vector3d tmpComVel(comVel); |
1222 |
|
|
MPI_Allreduce(&tmpMass,&totalMass,1,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1223 |
|
|
MPI_Allreduce(tmpComVel.getArrayPointer(), comVel.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1224 |
|
|
#endif |
1225 |
|
|
|
1226 |
|
|
comVel /= totalMass; |
1227 |
|
|
|
1228 |
|
|
return comVel; |
1229 |
gezelter |
507 |
} |
1230 |
gezelter |
2 |
|
1231 |
gezelter |
507 |
Vector3d SimInfo::getCom(){ |
1232 |
gezelter |
246 |
SimInfo::MoleculeIterator i; |
1233 |
|
|
Molecule* mol; |
1234 |
gezelter |
2 |
|
1235 |
gezelter |
246 |
Vector3d com(0.0); |
1236 |
|
|
double totalMass = 0.0; |
1237 |
|
|
|
1238 |
|
|
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
1239 |
gezelter |
507 |
double mass = mol->getMass(); |
1240 |
|
|
totalMass += mass; |
1241 |
|
|
com += mass * mol->getCom(); |
1242 |
gezelter |
246 |
} |
1243 |
gezelter |
2 |
|
1244 |
|
|
#ifdef IS_MPI |
1245 |
gezelter |
246 |
double tmpMass = totalMass; |
1246 |
|
|
Vector3d tmpCom(com); |
1247 |
|
|
MPI_Allreduce(&tmpMass,&totalMass,1,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1248 |
|
|
MPI_Allreduce(tmpCom.getArrayPointer(), com.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1249 |
gezelter |
2 |
#endif |
1250 |
|
|
|
1251 |
gezelter |
246 |
com /= totalMass; |
1252 |
gezelter |
2 |
|
1253 |
gezelter |
246 |
return com; |
1254 |
gezelter |
2 |
|
1255 |
gezelter |
507 |
} |
1256 |
gezelter |
246 |
|
1257 |
gezelter |
507 |
std::ostream& operator <<(std::ostream& o, SimInfo& info) { |
1258 |
gezelter |
246 |
|
1259 |
|
|
return o; |
1260 |
gezelter |
507 |
} |
1261 |
chuckv |
555 |
|
1262 |
|
|
|
1263 |
|
|
/* |
1264 |
|
|
Returns center of mass and center of mass velocity in one function call. |
1265 |
|
|
*/ |
1266 |
|
|
|
1267 |
|
|
void SimInfo::getComAll(Vector3d &com, Vector3d &comVel){ |
1268 |
|
|
SimInfo::MoleculeIterator i; |
1269 |
|
|
Molecule* mol; |
1270 |
|
|
|
1271 |
|
|
|
1272 |
|
|
double totalMass = 0.0; |
1273 |
|
|
|
1274 |
gezelter |
246 |
|
1275 |
chuckv |
555 |
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
1276 |
|
|
double mass = mol->getMass(); |
1277 |
|
|
totalMass += mass; |
1278 |
|
|
com += mass * mol->getCom(); |
1279 |
|
|
comVel += mass * mol->getComVel(); |
1280 |
|
|
} |
1281 |
|
|
|
1282 |
|
|
#ifdef IS_MPI |
1283 |
|
|
double tmpMass = totalMass; |
1284 |
|
|
Vector3d tmpCom(com); |
1285 |
|
|
Vector3d tmpComVel(comVel); |
1286 |
|
|
MPI_Allreduce(&tmpMass,&totalMass,1,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1287 |
|
|
MPI_Allreduce(tmpCom.getArrayPointer(), com.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1288 |
|
|
MPI_Allreduce(tmpComVel.getArrayPointer(), comVel.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1289 |
|
|
#endif |
1290 |
|
|
|
1291 |
|
|
com /= totalMass; |
1292 |
|
|
comVel /= totalMass; |
1293 |
|
|
} |
1294 |
|
|
|
1295 |
|
|
/* |
1296 |
|
|
Return intertia tensor for entire system and angular momentum Vector. |
1297 |
chuckv |
557 |
|
1298 |
|
|
|
1299 |
|
|
[ Ixx -Ixy -Ixz ] |
1300 |
|
|
J =| -Iyx Iyy -Iyz | |
1301 |
|
|
[ -Izx -Iyz Izz ] |
1302 |
chuckv |
555 |
*/ |
1303 |
|
|
|
1304 |
|
|
void SimInfo::getInertiaTensor(Mat3x3d &inertiaTensor, Vector3d &angularMomentum){ |
1305 |
|
|
|
1306 |
|
|
|
1307 |
|
|
double xx = 0.0; |
1308 |
|
|
double yy = 0.0; |
1309 |
|
|
double zz = 0.0; |
1310 |
|
|
double xy = 0.0; |
1311 |
|
|
double xz = 0.0; |
1312 |
|
|
double yz = 0.0; |
1313 |
|
|
Vector3d com(0.0); |
1314 |
|
|
Vector3d comVel(0.0); |
1315 |
|
|
|
1316 |
|
|
getComAll(com, comVel); |
1317 |
|
|
|
1318 |
|
|
SimInfo::MoleculeIterator i; |
1319 |
|
|
Molecule* mol; |
1320 |
|
|
|
1321 |
|
|
Vector3d thisq(0.0); |
1322 |
|
|
Vector3d thisv(0.0); |
1323 |
|
|
|
1324 |
|
|
double thisMass = 0.0; |
1325 |
|
|
|
1326 |
|
|
|
1327 |
|
|
|
1328 |
|
|
|
1329 |
|
|
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
1330 |
|
|
|
1331 |
|
|
thisq = mol->getCom()-com; |
1332 |
|
|
thisv = mol->getComVel()-comVel; |
1333 |
|
|
thisMass = mol->getMass(); |
1334 |
|
|
// Compute moment of intertia coefficients. |
1335 |
|
|
xx += thisq[0]*thisq[0]*thisMass; |
1336 |
|
|
yy += thisq[1]*thisq[1]*thisMass; |
1337 |
|
|
zz += thisq[2]*thisq[2]*thisMass; |
1338 |
|
|
|
1339 |
|
|
// compute products of intertia |
1340 |
|
|
xy += thisq[0]*thisq[1]*thisMass; |
1341 |
|
|
xz += thisq[0]*thisq[2]*thisMass; |
1342 |
|
|
yz += thisq[1]*thisq[2]*thisMass; |
1343 |
|
|
|
1344 |
|
|
angularMomentum += cross( thisq, thisv ) * thisMass; |
1345 |
|
|
|
1346 |
|
|
} |
1347 |
|
|
|
1348 |
|
|
|
1349 |
|
|
inertiaTensor(0,0) = yy + zz; |
1350 |
|
|
inertiaTensor(0,1) = -xy; |
1351 |
|
|
inertiaTensor(0,2) = -xz; |
1352 |
|
|
inertiaTensor(1,0) = -xy; |
1353 |
chuckv |
557 |
inertiaTensor(1,1) = xx + zz; |
1354 |
chuckv |
555 |
inertiaTensor(1,2) = -yz; |
1355 |
|
|
inertiaTensor(2,0) = -xz; |
1356 |
|
|
inertiaTensor(2,1) = -yz; |
1357 |
|
|
inertiaTensor(2,2) = xx + yy; |
1358 |
|
|
|
1359 |
|
|
#ifdef IS_MPI |
1360 |
|
|
Mat3x3d tmpI(inertiaTensor); |
1361 |
|
|
Vector3d tmpAngMom; |
1362 |
|
|
MPI_Allreduce(tmpI.getArrayPointer(), inertiaTensor.getArrayPointer(),9,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1363 |
|
|
MPI_Allreduce(tmpAngMom.getArrayPointer(), angularMomentum.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1364 |
|
|
#endif |
1365 |
|
|
|
1366 |
|
|
return; |
1367 |
|
|
} |
1368 |
|
|
|
1369 |
|
|
//Returns the angular momentum of the system |
1370 |
|
|
Vector3d SimInfo::getAngularMomentum(){ |
1371 |
|
|
|
1372 |
|
|
Vector3d com(0.0); |
1373 |
|
|
Vector3d comVel(0.0); |
1374 |
|
|
Vector3d angularMomentum(0.0); |
1375 |
|
|
|
1376 |
|
|
getComAll(com,comVel); |
1377 |
|
|
|
1378 |
|
|
SimInfo::MoleculeIterator i; |
1379 |
|
|
Molecule* mol; |
1380 |
|
|
|
1381 |
chuckv |
557 |
Vector3d thisr(0.0); |
1382 |
|
|
Vector3d thisp(0.0); |
1383 |
chuckv |
555 |
|
1384 |
chuckv |
557 |
double thisMass; |
1385 |
chuckv |
555 |
|
1386 |
|
|
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
1387 |
chuckv |
557 |
thisMass = mol->getMass(); |
1388 |
|
|
thisr = mol->getCom()-com; |
1389 |
|
|
thisp = (mol->getComVel()-comVel)*thisMass; |
1390 |
chuckv |
555 |
|
1391 |
chuckv |
557 |
angularMomentum += cross( thisr, thisp ); |
1392 |
|
|
|
1393 |
chuckv |
555 |
} |
1394 |
|
|
|
1395 |
|
|
#ifdef IS_MPI |
1396 |
|
|
Vector3d tmpAngMom; |
1397 |
|
|
MPI_Allreduce(tmpAngMom.getArrayPointer(), angularMomentum.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1398 |
|
|
#endif |
1399 |
|
|
|
1400 |
|
|
return angularMomentum; |
1401 |
|
|
} |
1402 |
|
|
|
1403 |
|
|
|
1404 |
gezelter |
246 |
}//end namespace oopse |
1405 |
|
|
|