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 |
6 |
|
* redistribute this software in source and binary code form, provided |
7 |
|
* that the following conditions are met: |
8 |
|
* |
9 |
< |
* 1. Acknowledgement of the program authors must be made in any |
10 |
< |
* publication of scientific results based in part on use of the |
11 |
< |
* program. An acceptable form of acknowledgement is citation of |
12 |
< |
* the article in which the program was described (Matthew |
13 |
< |
* A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher |
14 |
< |
* J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented |
15 |
< |
* Parallel Simulation Engine for Molecular Dynamics," |
16 |
< |
* J. Comput. Chem. 26, pp. 252-271 (2005)) |
17 |
< |
* |
18 |
< |
* 2. Redistributions of source code must retain the above copyright |
9 |
> |
* 1. Redistributions of source code must retain the above copyright |
10 |
|
* notice, this list of conditions and the following disclaimer. |
11 |
|
* |
12 |
< |
* 3. Redistributions in binary form must reproduce the above copyright |
12 |
> |
* 2. Redistributions in binary form must reproduce the above copyright |
13 |
|
* notice, this list of conditions and the following disclaimer in the |
14 |
|
* documentation and/or other materials provided with the |
15 |
|
* distribution. |
28 |
|
* arising out of the use of or inability to use software, even if the |
29 |
|
* University of Notre Dame has been advised of the possibility of |
30 |
|
* such damages. |
31 |
+ |
* |
32 |
+ |
* SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your |
33 |
+ |
* research, please cite the appropriate papers when you publish your |
34 |
+ |
* work. Good starting points are: |
35 |
+ |
* |
36 |
+ |
* [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |
37 |
+ |
* [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). |
38 |
+ |
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). |
39 |
+ |
* [4] Vardeman & Gezelter, in progress (2009). |
40 |
|
*/ |
41 |
|
|
42 |
|
/** |
48 |
|
|
49 |
|
#include <algorithm> |
50 |
|
#include <set> |
51 |
+ |
#include <map> |
52 |
|
|
53 |
|
#include "brains/SimInfo.hpp" |
54 |
|
#include "math/Vector3.hpp" |
55 |
|
#include "primitives/Molecule.hpp" |
56 |
< |
#include "UseTheForce/doForces_interface.h" |
56 |
< |
#include "UseTheForce/notifyCutoffs_interface.h" |
56 |
> |
#include "primitives/StuntDouble.hpp" |
57 |
|
#include "utils/MemoryUtils.hpp" |
58 |
|
#include "utils/simError.h" |
59 |
|
#include "selection/SelectionManager.hpp" |
60 |
+ |
#include "io/ForceFieldOptions.hpp" |
61 |
+ |
#include "UseTheForce/ForceField.hpp" |
62 |
+ |
#include "nonbonded/SwitchingFunction.hpp" |
63 |
|
|
64 |
< |
#ifdef IS_MPI |
65 |
< |
#include "UseTheForce/mpiComponentPlan.h" |
66 |
< |
#include "UseTheForce/DarkSide/simParallel_interface.h" |
67 |
< |
#endif |
68 |
< |
|
69 |
< |
namespace oopse { |
70 |
< |
|
71 |
< |
SimInfo::SimInfo(std::vector<std::pair<MoleculeStamp*, int> >& molStampPairs, |
72 |
< |
ForceField* ff, Globals* simParams) : |
73 |
< |
forceField_(ff), simParams_(simParams), |
74 |
< |
ndf_(0), ndfRaw_(0), ndfTrans_(0), nZconstraint_(0), |
75 |
< |
nGlobalMols_(0), nGlobalAtoms_(0), nGlobalCutoffGroups_(0), |
76 |
< |
nGlobalIntegrableObjects_(0), nGlobalRigidBodies_(0), |
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; |
64 |
> |
using namespace std; |
65 |
> |
namespace OpenMD { |
66 |
> |
|
67 |
> |
SimInfo::SimInfo(ForceField* ff, Globals* simParams) : |
68 |
> |
forceField_(ff), simParams_(simParams), |
69 |
> |
ndf_(0), fdf_local(0), ndfRaw_(0), ndfTrans_(0), nZconstraint_(0), |
70 |
> |
nGlobalMols_(0), nGlobalAtoms_(0), nGlobalCutoffGroups_(0), |
71 |
> |
nGlobalIntegrableObjects_(0), nGlobalRigidBodies_(0), |
72 |
> |
nAtoms_(0), nBonds_(0), nBends_(0), nTorsions_(0), nInversions_(0), |
73 |
> |
nRigidBodies_(0), nIntegrableObjects_(0), nCutoffGroups_(0), |
74 |
> |
nConstraints_(0), sman_(NULL), fortranInitialized_(false), |
75 |
> |
calcBoxDipole_(false), useAtomicVirial_(true) { |
76 |
> |
|
77 |
|
MoleculeStamp* molStamp; |
78 |
|
int nMolWithSameStamp; |
79 |
|
int nCutoffAtoms = 0; // number of atoms belong to cutoff groups |
80 |
< |
int nGroups = 0; //total cutoff groups defined in meta-data file |
80 |
> |
int nGroups = 0; //total cutoff groups defined in meta-data file |
81 |
|
CutoffGroupStamp* cgStamp; |
82 |
|
RigidBodyStamp* rbStamp; |
83 |
|
int nRigidAtoms = 0; |
84 |
|
|
85 |
< |
for (i = molStampPairs.begin(); i !=molStampPairs.end(); ++i) { |
86 |
< |
molStamp = i->first; |
87 |
< |
nMolWithSameStamp = i->second; |
88 |
< |
|
89 |
< |
addMoleculeStamp(molStamp, nMolWithSameStamp); |
90 |
< |
|
91 |
< |
//calculate atoms in molecules |
92 |
< |
nGlobalAtoms_ += molStamp->getNAtoms() *nMolWithSameStamp; |
93 |
< |
|
94 |
< |
|
95 |
< |
//calculate atoms in cutoff groups |
96 |
< |
int nAtomsInGroups = 0; |
97 |
< |
int nCutoffGroupsInStamp = molStamp->getNCutoffGroups(); |
98 |
< |
|
99 |
< |
for (int j=0; j < nCutoffGroupsInStamp; j++) { |
100 |
< |
cgStamp = molStamp->getCutoffGroup(j); |
101 |
< |
nAtomsInGroups += cgStamp->getNMembers(); |
102 |
< |
} |
103 |
< |
|
104 |
< |
nGroups += nCutoffGroupsInStamp * nMolWithSameStamp; |
105 |
< |
nCutoffAtoms += nAtomsInGroups * nMolWithSameStamp; |
106 |
< |
|
107 |
< |
//calculate atoms in rigid bodies |
108 |
< |
int nAtomsInRigidBodies = 0; |
109 |
< |
int nRigidBodiesInStamp = molStamp->getNRigidBodies(); |
110 |
< |
|
111 |
< |
for (int j=0; j < nRigidBodiesInStamp; j++) { |
112 |
< |
rbStamp = molStamp->getRigidBody(j); |
113 |
< |
nAtomsInRigidBodies += rbStamp->getNMembers(); |
114 |
< |
} |
115 |
< |
|
116 |
< |
nGlobalRigidBodies_ += nRigidBodiesInStamp * nMolWithSameStamp; |
117 |
< |
nRigidAtoms += nAtomsInRigidBodies * nMolWithSameStamp; |
118 |
< |
|
85 |
> |
vector<Component*> components = simParams->getComponents(); |
86 |
> |
|
87 |
> |
for (vector<Component*>::iterator i = components.begin(); i !=components.end(); ++i) { |
88 |
> |
molStamp = (*i)->getMoleculeStamp(); |
89 |
> |
nMolWithSameStamp = (*i)->getNMol(); |
90 |
> |
|
91 |
> |
addMoleculeStamp(molStamp, nMolWithSameStamp); |
92 |
> |
|
93 |
> |
//calculate atoms in molecules |
94 |
> |
nGlobalAtoms_ += molStamp->getNAtoms() *nMolWithSameStamp; |
95 |
> |
|
96 |
> |
//calculate atoms in cutoff groups |
97 |
> |
int nAtomsInGroups = 0; |
98 |
> |
int nCutoffGroupsInStamp = molStamp->getNCutoffGroups(); |
99 |
> |
|
100 |
> |
for (int j=0; j < nCutoffGroupsInStamp; j++) { |
101 |
> |
cgStamp = molStamp->getCutoffGroupStamp(j); |
102 |
> |
nAtomsInGroups += cgStamp->getNMembers(); |
103 |
> |
} |
104 |
> |
|
105 |
> |
nGroups += nCutoffGroupsInStamp * nMolWithSameStamp; |
106 |
> |
|
107 |
> |
nCutoffAtoms += nAtomsInGroups * nMolWithSameStamp; |
108 |
> |
|
109 |
> |
//calculate atoms in rigid bodies |
110 |
> |
int nAtomsInRigidBodies = 0; |
111 |
> |
int nRigidBodiesInStamp = molStamp->getNRigidBodies(); |
112 |
> |
|
113 |
> |
for (int j=0; j < nRigidBodiesInStamp; j++) { |
114 |
> |
rbStamp = molStamp->getRigidBodyStamp(j); |
115 |
> |
nAtomsInRigidBodies += rbStamp->getNMembers(); |
116 |
> |
} |
117 |
> |
|
118 |
> |
nGlobalRigidBodies_ += nRigidBodiesInStamp * nMolWithSameStamp; |
119 |
> |
nRigidAtoms += nAtomsInRigidBodies * nMolWithSameStamp; |
120 |
> |
|
121 |
|
} |
122 |
+ |
|
123 |
+ |
//every free atom (atom does not belong to cutoff groups) is a cutoff |
124 |
+ |
//group therefore the total number of cutoff groups in the system is |
125 |
+ |
//equal to the total number of atoms minus number of atoms belong to |
126 |
+ |
//cutoff group defined in meta-data file plus the number of cutoff |
127 |
+ |
//groups defined in meta-data file |
128 |
+ |
std::cerr << "nGA = " << nGlobalAtoms_ << "\n"; |
129 |
+ |
std::cerr << "nCA = " << nCutoffAtoms << "\n"; |
130 |
+ |
std::cerr << "nG = " << nGroups << "\n"; |
131 |
|
|
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 |
132 |
|
nGlobalCutoffGroups_ = nGlobalAtoms_ - nCutoffAtoms + nGroups; |
133 |
|
|
134 |
< |
//every free atom (atom does not belong to rigid bodies) is an integrable object |
135 |
< |
//therefore the total number of integrable objects in the system is equal to |
136 |
< |
//the total number of atoms minus number of atoms belong to rigid body defined in meta-data |
137 |
< |
//file plus the number of rigid bodies defined in meta-data file |
138 |
< |
nGlobalIntegrableObjects_ = nGlobalAtoms_ - nRigidAtoms + nGlobalRigidBodies_; |
139 |
< |
|
134 |
> |
std::cerr << "nGCG = " << nGlobalCutoffGroups_ << "\n"; |
135 |
> |
|
136 |
> |
//every free atom (atom does not belong to rigid bodies) is an |
137 |
> |
//integrable object therefore the total number of integrable objects |
138 |
> |
//in the system is equal to the total number of atoms minus number of |
139 |
> |
//atoms belong to rigid body defined in meta-data file plus the number |
140 |
> |
//of rigid bodies defined in meta-data file |
141 |
> |
nGlobalIntegrableObjects_ = nGlobalAtoms_ - nRigidAtoms |
142 |
> |
+ nGlobalRigidBodies_; |
143 |
> |
|
144 |
|
nGlobalMols_ = molStampIds_.size(); |
137 |
– |
|
138 |
– |
#ifdef IS_MPI |
145 |
|
molToProcMap_.resize(nGlobalMols_); |
146 |
< |
#endif |
147 |
< |
|
148 |
< |
} |
149 |
< |
|
144 |
< |
SimInfo::~SimInfo() { |
145 |
< |
std::map<int, Molecule*>::iterator i; |
146 |
> |
} |
147 |
> |
|
148 |
> |
SimInfo::~SimInfo() { |
149 |
> |
map<int, Molecule*>::iterator i; |
150 |
|
for (i = molecules_.begin(); i != molecules_.end(); ++i) { |
151 |
< |
delete i->second; |
151 |
> |
delete i->second; |
152 |
|
} |
153 |
|
molecules_.clear(); |
154 |
< |
|
151 |
< |
MemoryUtils::deletePointers(moleculeStamps_); |
152 |
< |
|
154 |
> |
|
155 |
|
delete sman_; |
156 |
|
delete simParams_; |
157 |
|
delete forceField_; |
158 |
< |
} |
158 |
> |
} |
159 |
|
|
158 |
– |
int SimInfo::getNGlobalConstraints() { |
159 |
– |
int nGlobalConstraints; |
160 |
– |
#ifdef IS_MPI |
161 |
– |
MPI_Allreduce(&nConstraints_, &nGlobalConstraints, 1, MPI_INT, MPI_SUM, |
162 |
– |
MPI_COMM_WORLD); |
163 |
– |
#else |
164 |
– |
nGlobalConstraints = nConstraints_; |
165 |
– |
#endif |
166 |
– |
return nGlobalConstraints; |
167 |
– |
} |
160 |
|
|
161 |
< |
bool SimInfo::addMolecule(Molecule* mol) { |
161 |
> |
bool SimInfo::addMolecule(Molecule* mol) { |
162 |
|
MoleculeIterator i; |
163 |
< |
|
163 |
> |
|
164 |
|
i = molecules_.find(mol->getGlobalIndex()); |
165 |
|
if (i == molecules_.end() ) { |
166 |
< |
|
167 |
< |
molecules_.insert(std::make_pair(mol->getGlobalIndex(), mol)); |
168 |
< |
|
169 |
< |
nAtoms_ += mol->getNAtoms(); |
170 |
< |
nBonds_ += mol->getNBonds(); |
171 |
< |
nBends_ += mol->getNBends(); |
172 |
< |
nTorsions_ += mol->getNTorsions(); |
173 |
< |
nRigidBodies_ += mol->getNRigidBodies(); |
174 |
< |
nIntegrableObjects_ += mol->getNIntegrableObjects(); |
175 |
< |
nCutoffGroups_ += mol->getNCutoffGroups(); |
176 |
< |
nConstraints_ += mol->getNConstraintPairs(); |
177 |
< |
|
178 |
< |
addExcludePairs(mol); |
179 |
< |
|
180 |
< |
return true; |
166 |
> |
|
167 |
> |
molecules_.insert(make_pair(mol->getGlobalIndex(), mol)); |
168 |
> |
|
169 |
> |
nAtoms_ += mol->getNAtoms(); |
170 |
> |
nBonds_ += mol->getNBonds(); |
171 |
> |
nBends_ += mol->getNBends(); |
172 |
> |
nTorsions_ += mol->getNTorsions(); |
173 |
> |
nInversions_ += mol->getNInversions(); |
174 |
> |
nRigidBodies_ += mol->getNRigidBodies(); |
175 |
> |
nIntegrableObjects_ += mol->getNIntegrableObjects(); |
176 |
> |
nCutoffGroups_ += mol->getNCutoffGroups(); |
177 |
> |
nConstraints_ += mol->getNConstraintPairs(); |
178 |
> |
|
179 |
> |
addInteractionPairs(mol); |
180 |
> |
|
181 |
> |
return true; |
182 |
|
} else { |
183 |
< |
return false; |
183 |
> |
return false; |
184 |
|
} |
185 |
< |
} |
186 |
< |
|
187 |
< |
bool SimInfo::removeMolecule(Molecule* mol) { |
185 |
> |
} |
186 |
> |
|
187 |
> |
bool SimInfo::removeMolecule(Molecule* mol) { |
188 |
|
MoleculeIterator i; |
189 |
|
i = molecules_.find(mol->getGlobalIndex()); |
190 |
|
|
191 |
|
if (i != molecules_.end() ) { |
192 |
|
|
193 |
< |
assert(mol == i->second); |
193 |
> |
assert(mol == i->second); |
194 |
|
|
195 |
< |
nAtoms_ -= mol->getNAtoms(); |
196 |
< |
nBonds_ -= mol->getNBonds(); |
197 |
< |
nBends_ -= mol->getNBends(); |
198 |
< |
nTorsions_ -= mol->getNTorsions(); |
199 |
< |
nRigidBodies_ -= mol->getNRigidBodies(); |
200 |
< |
nIntegrableObjects_ -= mol->getNIntegrableObjects(); |
201 |
< |
nCutoffGroups_ -= mol->getNCutoffGroups(); |
202 |
< |
nConstraints_ -= mol->getNConstraintPairs(); |
195 |
> |
nAtoms_ -= mol->getNAtoms(); |
196 |
> |
nBonds_ -= mol->getNBonds(); |
197 |
> |
nBends_ -= mol->getNBends(); |
198 |
> |
nTorsions_ -= mol->getNTorsions(); |
199 |
> |
nInversions_ -= mol->getNInversions(); |
200 |
> |
nRigidBodies_ -= mol->getNRigidBodies(); |
201 |
> |
nIntegrableObjects_ -= mol->getNIntegrableObjects(); |
202 |
> |
nCutoffGroups_ -= mol->getNCutoffGroups(); |
203 |
> |
nConstraints_ -= mol->getNConstraintPairs(); |
204 |
|
|
205 |
< |
removeExcludePairs(mol); |
206 |
< |
molecules_.erase(mol->getGlobalIndex()); |
205 |
> |
removeInteractionPairs(mol); |
206 |
> |
molecules_.erase(mol->getGlobalIndex()); |
207 |
|
|
208 |
< |
delete mol; |
208 |
> |
delete mol; |
209 |
|
|
210 |
< |
return true; |
210 |
> |
return true; |
211 |
|
} else { |
212 |
< |
return false; |
212 |
> |
return false; |
213 |
|
} |
214 |
+ |
} |
215 |
|
|
221 |
– |
|
222 |
– |
} |
223 |
– |
|
216 |
|
|
217 |
< |
Molecule* SimInfo::beginMolecule(MoleculeIterator& i) { |
217 |
> |
Molecule* SimInfo::beginMolecule(MoleculeIterator& i) { |
218 |
|
i = molecules_.begin(); |
219 |
|
return i == molecules_.end() ? NULL : i->second; |
220 |
< |
} |
220 |
> |
} |
221 |
|
|
222 |
< |
Molecule* SimInfo::nextMolecule(MoleculeIterator& i) { |
222 |
> |
Molecule* SimInfo::nextMolecule(MoleculeIterator& i) { |
223 |
|
++i; |
224 |
|
return i == molecules_.end() ? NULL : i->second; |
225 |
< |
} |
225 |
> |
} |
226 |
|
|
227 |
|
|
228 |
< |
void SimInfo::calcNdf() { |
228 |
> |
void SimInfo::calcNdf() { |
229 |
|
int ndf_local; |
230 |
|
MoleculeIterator i; |
231 |
< |
std::vector<StuntDouble*>::iterator j; |
231 |
> |
vector<StuntDouble*>::iterator j; |
232 |
|
Molecule* mol; |
233 |
|
StuntDouble* integrableObject; |
234 |
|
|
235 |
|
ndf_local = 0; |
236 |
|
|
237 |
|
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
238 |
< |
for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL; |
239 |
< |
integrableObject = mol->nextIntegrableObject(j)) { |
238 |
> |
for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL; |
239 |
> |
integrableObject = mol->nextIntegrableObject(j)) { |
240 |
|
|
241 |
< |
ndf_local += 3; |
241 |
> |
ndf_local += 3; |
242 |
|
|
243 |
< |
if (integrableObject->isDirectional()) { |
244 |
< |
if (integrableObject->isLinear()) { |
245 |
< |
ndf_local += 2; |
246 |
< |
} else { |
247 |
< |
ndf_local += 3; |
248 |
< |
} |
249 |
< |
} |
243 |
> |
if (integrableObject->isDirectional()) { |
244 |
> |
if (integrableObject->isLinear()) { |
245 |
> |
ndf_local += 2; |
246 |
> |
} else { |
247 |
> |
ndf_local += 3; |
248 |
> |
} |
249 |
> |
} |
250 |
|
|
251 |
< |
}//end for (integrableObject) |
252 |
< |
}// end for (mol) |
251 |
> |
} |
252 |
> |
} |
253 |
|
|
254 |
|
// n_constraints is local, so subtract them on each processor |
255 |
|
ndf_local -= nConstraints_; |
264 |
|
// entire system: |
265 |
|
ndf_ = ndf_ - 3 - nZconstraint_; |
266 |
|
|
267 |
< |
} |
267 |
> |
} |
268 |
|
|
269 |
< |
void SimInfo::calcNdfRaw() { |
269 |
> |
int SimInfo::getFdf() { |
270 |
> |
#ifdef IS_MPI |
271 |
> |
MPI_Allreduce(&fdf_local,&fdf_,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD); |
272 |
> |
#else |
273 |
> |
fdf_ = fdf_local; |
274 |
> |
#endif |
275 |
> |
return fdf_; |
276 |
> |
} |
277 |
> |
|
278 |
> |
void SimInfo::calcNdfRaw() { |
279 |
|
int ndfRaw_local; |
280 |
|
|
281 |
|
MoleculeIterator i; |
282 |
< |
std::vector<StuntDouble*>::iterator j; |
282 |
> |
vector<StuntDouble*>::iterator j; |
283 |
|
Molecule* mol; |
284 |
|
StuntDouble* integrableObject; |
285 |
|
|
287 |
|
ndfRaw_local = 0; |
288 |
|
|
289 |
|
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
290 |
< |
for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL; |
291 |
< |
integrableObject = mol->nextIntegrableObject(j)) { |
290 |
> |
for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL; |
291 |
> |
integrableObject = mol->nextIntegrableObject(j)) { |
292 |
|
|
293 |
< |
ndfRaw_local += 3; |
293 |
> |
ndfRaw_local += 3; |
294 |
|
|
295 |
< |
if (integrableObject->isDirectional()) { |
296 |
< |
if (integrableObject->isLinear()) { |
297 |
< |
ndfRaw_local += 2; |
298 |
< |
} else { |
299 |
< |
ndfRaw_local += 3; |
300 |
< |
} |
301 |
< |
} |
295 |
> |
if (integrableObject->isDirectional()) { |
296 |
> |
if (integrableObject->isLinear()) { |
297 |
> |
ndfRaw_local += 2; |
298 |
> |
} else { |
299 |
> |
ndfRaw_local += 3; |
300 |
> |
} |
301 |
> |
} |
302 |
|
|
303 |
< |
} |
303 |
> |
} |
304 |
|
} |
305 |
|
|
306 |
|
#ifdef IS_MPI |
308 |
|
#else |
309 |
|
ndfRaw_ = ndfRaw_local; |
310 |
|
#endif |
311 |
< |
} |
311 |
> |
} |
312 |
|
|
313 |
< |
void SimInfo::calcNdfTrans() { |
313 |
> |
void SimInfo::calcNdfTrans() { |
314 |
|
int ndfTrans_local; |
315 |
|
|
316 |
|
ndfTrans_local = 3 * nIntegrableObjects_ - nConstraints_; |
324 |
|
|
325 |
|
ndfTrans_ = ndfTrans_ - 3 - nZconstraint_; |
326 |
|
|
327 |
< |
} |
327 |
> |
} |
328 |
|
|
329 |
< |
void SimInfo::addExcludePairs(Molecule* mol) { |
330 |
< |
std::vector<Bond*>::iterator bondIter; |
331 |
< |
std::vector<Bend*>::iterator bendIter; |
332 |
< |
std::vector<Torsion*>::iterator torsionIter; |
329 |
> |
void SimInfo::addInteractionPairs(Molecule* mol) { |
330 |
> |
ForceFieldOptions& options_ = forceField_->getForceFieldOptions(); |
331 |
> |
vector<Bond*>::iterator bondIter; |
332 |
> |
vector<Bend*>::iterator bendIter; |
333 |
> |
vector<Torsion*>::iterator torsionIter; |
334 |
> |
vector<Inversion*>::iterator inversionIter; |
335 |
|
Bond* bond; |
336 |
|
Bend* bend; |
337 |
|
Torsion* torsion; |
338 |
+ |
Inversion* inversion; |
339 |
|
int a; |
340 |
|
int b; |
341 |
|
int c; |
342 |
|
int d; |
343 |
+ |
|
344 |
+ |
// atomGroups can be used to add special interaction maps between |
345 |
+ |
// groups of atoms that are in two separate rigid bodies. |
346 |
+ |
// However, most site-site interactions between two rigid bodies |
347 |
+ |
// are probably not special, just the ones between the physically |
348 |
+ |
// bonded atoms. Interactions *within* a single rigid body should |
349 |
+ |
// always be excluded. These are done at the bottom of this |
350 |
+ |
// function. |
351 |
+ |
|
352 |
+ |
map<int, set<int> > atomGroups; |
353 |
+ |
Molecule::RigidBodyIterator rbIter; |
354 |
+ |
RigidBody* rb; |
355 |
+ |
Molecule::IntegrableObjectIterator ii; |
356 |
+ |
StuntDouble* integrableObject; |
357 |
|
|
358 |
< |
for (bond= mol->beginBond(bondIter); bond != NULL; bond = mol->nextBond(bondIter)) { |
359 |
< |
a = bond->getAtomA()->getGlobalIndex(); |
360 |
< |
b = bond->getAtomB()->getGlobalIndex(); |
361 |
< |
exclude_.addPair(a, b); |
358 |
> |
for (integrableObject = mol->beginIntegrableObject(ii); |
359 |
> |
integrableObject != NULL; |
360 |
> |
integrableObject = mol->nextIntegrableObject(ii)) { |
361 |
> |
|
362 |
> |
if (integrableObject->isRigidBody()) { |
363 |
> |
rb = static_cast<RigidBody*>(integrableObject); |
364 |
> |
vector<Atom*> atoms = rb->getAtoms(); |
365 |
> |
set<int> rigidAtoms; |
366 |
> |
for (int i = 0; i < static_cast<int>(atoms.size()); ++i) { |
367 |
> |
rigidAtoms.insert(atoms[i]->getGlobalIndex()); |
368 |
> |
} |
369 |
> |
for (int i = 0; i < static_cast<int>(atoms.size()); ++i) { |
370 |
> |
atomGroups.insert(map<int, set<int> >::value_type(atoms[i]->getGlobalIndex(), rigidAtoms)); |
371 |
> |
} |
372 |
> |
} else { |
373 |
> |
set<int> oneAtomSet; |
374 |
> |
oneAtomSet.insert(integrableObject->getGlobalIndex()); |
375 |
> |
atomGroups.insert(map<int, set<int> >::value_type(integrableObject->getGlobalIndex(), oneAtomSet)); |
376 |
> |
} |
377 |
> |
} |
378 |
> |
|
379 |
> |
for (bond= mol->beginBond(bondIter); bond != NULL; |
380 |
> |
bond = mol->nextBond(bondIter)) { |
381 |
> |
|
382 |
> |
a = bond->getAtomA()->getGlobalIndex(); |
383 |
> |
b = bond->getAtomB()->getGlobalIndex(); |
384 |
> |
|
385 |
> |
if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) { |
386 |
> |
oneTwoInteractions_.addPair(a, b); |
387 |
> |
} else { |
388 |
> |
excludedInteractions_.addPair(a, b); |
389 |
> |
} |
390 |
|
} |
391 |
|
|
392 |
< |
for (bend= mol->beginBend(bendIter); bend != NULL; bend = mol->nextBend(bendIter)) { |
393 |
< |
a = bend->getAtomA()->getGlobalIndex(); |
348 |
< |
b = bend->getAtomB()->getGlobalIndex(); |
349 |
< |
c = bend->getAtomC()->getGlobalIndex(); |
392 |
> |
for (bend= mol->beginBend(bendIter); bend != NULL; |
393 |
> |
bend = mol->nextBend(bendIter)) { |
394 |
|
|
395 |
< |
exclude_.addPair(a, b); |
396 |
< |
exclude_.addPair(a, c); |
397 |
< |
exclude_.addPair(b, c); |
395 |
> |
a = bend->getAtomA()->getGlobalIndex(); |
396 |
> |
b = bend->getAtomB()->getGlobalIndex(); |
397 |
> |
c = bend->getAtomC()->getGlobalIndex(); |
398 |
> |
|
399 |
> |
if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) { |
400 |
> |
oneTwoInteractions_.addPair(a, b); |
401 |
> |
oneTwoInteractions_.addPair(b, c); |
402 |
> |
} else { |
403 |
> |
excludedInteractions_.addPair(a, b); |
404 |
> |
excludedInteractions_.addPair(b, c); |
405 |
> |
} |
406 |
> |
|
407 |
> |
if (options_.havevdw13scale() || options_.haveelectrostatic13scale()) { |
408 |
> |
oneThreeInteractions_.addPair(a, c); |
409 |
> |
} else { |
410 |
> |
excludedInteractions_.addPair(a, c); |
411 |
> |
} |
412 |
|
} |
413 |
|
|
414 |
< |
for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; torsion = mol->nextTorsion(torsionIter)) { |
415 |
< |
a = torsion->getAtomA()->getGlobalIndex(); |
358 |
< |
b = torsion->getAtomB()->getGlobalIndex(); |
359 |
< |
c = torsion->getAtomC()->getGlobalIndex(); |
360 |
< |
d = torsion->getAtomD()->getGlobalIndex(); |
414 |
> |
for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; |
415 |
> |
torsion = mol->nextTorsion(torsionIter)) { |
416 |
|
|
417 |
< |
exclude_.addPair(a, b); |
418 |
< |
exclude_.addPair(a, c); |
419 |
< |
exclude_.addPair(a, d); |
420 |
< |
exclude_.addPair(b, c); |
421 |
< |
exclude_.addPair(b, d); |
422 |
< |
exclude_.addPair(c, d); |
417 |
> |
a = torsion->getAtomA()->getGlobalIndex(); |
418 |
> |
b = torsion->getAtomB()->getGlobalIndex(); |
419 |
> |
c = torsion->getAtomC()->getGlobalIndex(); |
420 |
> |
d = torsion->getAtomD()->getGlobalIndex(); |
421 |
> |
|
422 |
> |
if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) { |
423 |
> |
oneTwoInteractions_.addPair(a, b); |
424 |
> |
oneTwoInteractions_.addPair(b, c); |
425 |
> |
oneTwoInteractions_.addPair(c, d); |
426 |
> |
} else { |
427 |
> |
excludedInteractions_.addPair(a, b); |
428 |
> |
excludedInteractions_.addPair(b, c); |
429 |
> |
excludedInteractions_.addPair(c, d); |
430 |
> |
} |
431 |
> |
|
432 |
> |
if (options_.havevdw13scale() || options_.haveelectrostatic13scale()) { |
433 |
> |
oneThreeInteractions_.addPair(a, c); |
434 |
> |
oneThreeInteractions_.addPair(b, d); |
435 |
> |
} else { |
436 |
> |
excludedInteractions_.addPair(a, c); |
437 |
> |
excludedInteractions_.addPair(b, d); |
438 |
> |
} |
439 |
> |
|
440 |
> |
if (options_.havevdw14scale() || options_.haveelectrostatic14scale()) { |
441 |
> |
oneFourInteractions_.addPair(a, d); |
442 |
> |
} else { |
443 |
> |
excludedInteractions_.addPair(a, d); |
444 |
> |
} |
445 |
|
} |
446 |
|
|
447 |
< |
Molecule::RigidBodyIterator rbIter; |
448 |
< |
RigidBody* rb; |
372 |
< |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
373 |
< |
std::vector<Atom*> atoms = rb->getAtoms(); |
374 |
< |
for (int i = 0; i < atoms.size() -1 ; ++i) { |
375 |
< |
for (int j = i + 1; j < atoms.size(); ++j) { |
376 |
< |
a = atoms[i]->getGlobalIndex(); |
377 |
< |
b = atoms[j]->getGlobalIndex(); |
378 |
< |
exclude_.addPair(a, b); |
379 |
< |
} |
380 |
< |
} |
381 |
< |
} |
447 |
> |
for (inversion= mol->beginInversion(inversionIter); inversion != NULL; |
448 |
> |
inversion = mol->nextInversion(inversionIter)) { |
449 |
|
|
450 |
< |
Molecule::CutoffGroupIterator cgIter; |
451 |
< |
CutoffGroup* cg; |
452 |
< |
for (cg = mol->beginCutoffGroup(cgIter); cg != NULL; cg = mol->nextCutoffGroup(cgIter)) { |
453 |
< |
std::vector<Atom*> atoms = cg->getAtoms(); |
387 |
< |
for (int i = 0; i < atoms.size() -1 ; ++i) { |
388 |
< |
for (int j = i + 1; j < atoms.size(); ++j) { |
389 |
< |
a = atoms[i]->getGlobalIndex(); |
390 |
< |
b = atoms[j]->getGlobalIndex(); |
391 |
< |
exclude_.addPair(a, b); |
392 |
< |
} |
393 |
< |
} |
394 |
< |
} |
450 |
> |
a = inversion->getAtomA()->getGlobalIndex(); |
451 |
> |
b = inversion->getAtomB()->getGlobalIndex(); |
452 |
> |
c = inversion->getAtomC()->getGlobalIndex(); |
453 |
> |
d = inversion->getAtomD()->getGlobalIndex(); |
454 |
|
|
455 |
< |
} |
455 |
> |
if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) { |
456 |
> |
oneTwoInteractions_.addPair(a, b); |
457 |
> |
oneTwoInteractions_.addPair(a, c); |
458 |
> |
oneTwoInteractions_.addPair(a, d); |
459 |
> |
} else { |
460 |
> |
excludedInteractions_.addPair(a, b); |
461 |
> |
excludedInteractions_.addPair(a, c); |
462 |
> |
excludedInteractions_.addPair(a, d); |
463 |
> |
} |
464 |
|
|
465 |
< |
void SimInfo::removeExcludePairs(Molecule* mol) { |
466 |
< |
std::vector<Bond*>::iterator bondIter; |
467 |
< |
std::vector<Bend*>::iterator bendIter; |
468 |
< |
std::vector<Torsion*>::iterator torsionIter; |
465 |
> |
if (options_.havevdw13scale() || options_.haveelectrostatic13scale()) { |
466 |
> |
oneThreeInteractions_.addPair(b, c); |
467 |
> |
oneThreeInteractions_.addPair(b, d); |
468 |
> |
oneThreeInteractions_.addPair(c, d); |
469 |
> |
} else { |
470 |
> |
excludedInteractions_.addPair(b, c); |
471 |
> |
excludedInteractions_.addPair(b, d); |
472 |
> |
excludedInteractions_.addPair(c, d); |
473 |
> |
} |
474 |
> |
} |
475 |
> |
|
476 |
> |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; |
477 |
> |
rb = mol->nextRigidBody(rbIter)) { |
478 |
> |
vector<Atom*> atoms = rb->getAtoms(); |
479 |
> |
for (int i = 0; i < static_cast<int>(atoms.size()) -1 ; ++i) { |
480 |
> |
for (int j = i + 1; j < static_cast<int>(atoms.size()); ++j) { |
481 |
> |
a = atoms[i]->getGlobalIndex(); |
482 |
> |
b = atoms[j]->getGlobalIndex(); |
483 |
> |
excludedInteractions_.addPair(a, b); |
484 |
> |
} |
485 |
> |
} |
486 |
> |
} |
487 |
> |
|
488 |
> |
} |
489 |
> |
|
490 |
> |
void SimInfo::removeInteractionPairs(Molecule* mol) { |
491 |
> |
ForceFieldOptions& options_ = forceField_->getForceFieldOptions(); |
492 |
> |
vector<Bond*>::iterator bondIter; |
493 |
> |
vector<Bend*>::iterator bendIter; |
494 |
> |
vector<Torsion*>::iterator torsionIter; |
495 |
> |
vector<Inversion*>::iterator inversionIter; |
496 |
|
Bond* bond; |
497 |
|
Bend* bend; |
498 |
|
Torsion* torsion; |
499 |
+ |
Inversion* inversion; |
500 |
|
int a; |
501 |
|
int b; |
502 |
|
int c; |
503 |
|
int d; |
504 |
+ |
|
505 |
+ |
map<int, set<int> > atomGroups; |
506 |
+ |
Molecule::RigidBodyIterator rbIter; |
507 |
+ |
RigidBody* rb; |
508 |
+ |
Molecule::IntegrableObjectIterator ii; |
509 |
+ |
StuntDouble* integrableObject; |
510 |
|
|
511 |
< |
for (bond= mol->beginBond(bondIter); bond != NULL; bond = mol->nextBond(bondIter)) { |
512 |
< |
a = bond->getAtomA()->getGlobalIndex(); |
513 |
< |
b = bond->getAtomB()->getGlobalIndex(); |
514 |
< |
exclude_.removePair(a, b); |
511 |
> |
for (integrableObject = mol->beginIntegrableObject(ii); |
512 |
> |
integrableObject != NULL; |
513 |
> |
integrableObject = mol->nextIntegrableObject(ii)) { |
514 |
> |
|
515 |
> |
if (integrableObject->isRigidBody()) { |
516 |
> |
rb = static_cast<RigidBody*>(integrableObject); |
517 |
> |
vector<Atom*> atoms = rb->getAtoms(); |
518 |
> |
set<int> rigidAtoms; |
519 |
> |
for (int i = 0; i < static_cast<int>(atoms.size()); ++i) { |
520 |
> |
rigidAtoms.insert(atoms[i]->getGlobalIndex()); |
521 |
> |
} |
522 |
> |
for (int i = 0; i < static_cast<int>(atoms.size()); ++i) { |
523 |
> |
atomGroups.insert(map<int, set<int> >::value_type(atoms[i]->getGlobalIndex(), rigidAtoms)); |
524 |
> |
} |
525 |
> |
} else { |
526 |
> |
set<int> oneAtomSet; |
527 |
> |
oneAtomSet.insert(integrableObject->getGlobalIndex()); |
528 |
> |
atomGroups.insert(map<int, set<int> >::value_type(integrableObject->getGlobalIndex(), oneAtomSet)); |
529 |
> |
} |
530 |
> |
} |
531 |
> |
|
532 |
> |
for (bond= mol->beginBond(bondIter); bond != NULL; |
533 |
> |
bond = mol->nextBond(bondIter)) { |
534 |
> |
|
535 |
> |
a = bond->getAtomA()->getGlobalIndex(); |
536 |
> |
b = bond->getAtomB()->getGlobalIndex(); |
537 |
> |
|
538 |
> |
if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) { |
539 |
> |
oneTwoInteractions_.removePair(a, b); |
540 |
> |
} else { |
541 |
> |
excludedInteractions_.removePair(a, b); |
542 |
> |
} |
543 |
|
} |
544 |
|
|
545 |
< |
for (bend= mol->beginBend(bendIter); bend != NULL; bend = mol->nextBend(bendIter)) { |
546 |
< |
a = bend->getAtomA()->getGlobalIndex(); |
418 |
< |
b = bend->getAtomB()->getGlobalIndex(); |
419 |
< |
c = bend->getAtomC()->getGlobalIndex(); |
545 |
> |
for (bend= mol->beginBend(bendIter); bend != NULL; |
546 |
> |
bend = mol->nextBend(bendIter)) { |
547 |
|
|
548 |
< |
exclude_.removePair(a, b); |
549 |
< |
exclude_.removePair(a, c); |
550 |
< |
exclude_.removePair(b, c); |
548 |
> |
a = bend->getAtomA()->getGlobalIndex(); |
549 |
> |
b = bend->getAtomB()->getGlobalIndex(); |
550 |
> |
c = bend->getAtomC()->getGlobalIndex(); |
551 |
> |
|
552 |
> |
if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) { |
553 |
> |
oneTwoInteractions_.removePair(a, b); |
554 |
> |
oneTwoInteractions_.removePair(b, c); |
555 |
> |
} else { |
556 |
> |
excludedInteractions_.removePair(a, b); |
557 |
> |
excludedInteractions_.removePair(b, c); |
558 |
> |
} |
559 |
> |
|
560 |
> |
if (options_.havevdw13scale() || options_.haveelectrostatic13scale()) { |
561 |
> |
oneThreeInteractions_.removePair(a, c); |
562 |
> |
} else { |
563 |
> |
excludedInteractions_.removePair(a, c); |
564 |
> |
} |
565 |
|
} |
566 |
|
|
567 |
< |
for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; torsion = mol->nextTorsion(torsionIter)) { |
568 |
< |
a = torsion->getAtomA()->getGlobalIndex(); |
428 |
< |
b = torsion->getAtomB()->getGlobalIndex(); |
429 |
< |
c = torsion->getAtomC()->getGlobalIndex(); |
430 |
< |
d = torsion->getAtomD()->getGlobalIndex(); |
567 |
> |
for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; |
568 |
> |
torsion = mol->nextTorsion(torsionIter)) { |
569 |
|
|
570 |
< |
exclude_.removePair(a, b); |
571 |
< |
exclude_.removePair(a, c); |
572 |
< |
exclude_.removePair(a, d); |
573 |
< |
exclude_.removePair(b, c); |
574 |
< |
exclude_.removePair(b, d); |
575 |
< |
exclude_.removePair(c, d); |
570 |
> |
a = torsion->getAtomA()->getGlobalIndex(); |
571 |
> |
b = torsion->getAtomB()->getGlobalIndex(); |
572 |
> |
c = torsion->getAtomC()->getGlobalIndex(); |
573 |
> |
d = torsion->getAtomD()->getGlobalIndex(); |
574 |
> |
|
575 |
> |
if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) { |
576 |
> |
oneTwoInteractions_.removePair(a, b); |
577 |
> |
oneTwoInteractions_.removePair(b, c); |
578 |
> |
oneTwoInteractions_.removePair(c, d); |
579 |
> |
} else { |
580 |
> |
excludedInteractions_.removePair(a, b); |
581 |
> |
excludedInteractions_.removePair(b, c); |
582 |
> |
excludedInteractions_.removePair(c, d); |
583 |
> |
} |
584 |
> |
|
585 |
> |
if (options_.havevdw13scale() || options_.haveelectrostatic13scale()) { |
586 |
> |
oneThreeInteractions_.removePair(a, c); |
587 |
> |
oneThreeInteractions_.removePair(b, d); |
588 |
> |
} else { |
589 |
> |
excludedInteractions_.removePair(a, c); |
590 |
> |
excludedInteractions_.removePair(b, d); |
591 |
> |
} |
592 |
> |
|
593 |
> |
if (options_.havevdw14scale() || options_.haveelectrostatic14scale()) { |
594 |
> |
oneFourInteractions_.removePair(a, d); |
595 |
> |
} else { |
596 |
> |
excludedInteractions_.removePair(a, d); |
597 |
> |
} |
598 |
|
} |
599 |
|
|
600 |
< |
Molecule::RigidBodyIterator rbIter; |
601 |
< |
RigidBody* rb; |
442 |
< |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
443 |
< |
std::vector<Atom*> atoms = rb->getAtoms(); |
444 |
< |
for (int i = 0; i < atoms.size() -1 ; ++i) { |
445 |
< |
for (int j = i + 1; j < atoms.size(); ++j) { |
446 |
< |
a = atoms[i]->getGlobalIndex(); |
447 |
< |
b = atoms[j]->getGlobalIndex(); |
448 |
< |
exclude_.removePair(a, b); |
449 |
< |
} |
450 |
< |
} |
451 |
< |
} |
600 |
> |
for (inversion= mol->beginInversion(inversionIter); inversion != NULL; |
601 |
> |
inversion = mol->nextInversion(inversionIter)) { |
602 |
|
|
603 |
< |
Molecule::CutoffGroupIterator cgIter; |
604 |
< |
CutoffGroup* cg; |
605 |
< |
for (cg = mol->beginCutoffGroup(cgIter); cg != NULL; cg = mol->nextCutoffGroup(cgIter)) { |
606 |
< |
std::vector<Atom*> atoms = cg->getAtoms(); |
457 |
< |
for (int i = 0; i < atoms.size() -1 ; ++i) { |
458 |
< |
for (int j = i + 1; j < atoms.size(); ++j) { |
459 |
< |
a = atoms[i]->getGlobalIndex(); |
460 |
< |
b = atoms[j]->getGlobalIndex(); |
461 |
< |
exclude_.removePair(a, b); |
462 |
< |
} |
463 |
< |
} |
464 |
< |
} |
603 |
> |
a = inversion->getAtomA()->getGlobalIndex(); |
604 |
> |
b = inversion->getAtomB()->getGlobalIndex(); |
605 |
> |
c = inversion->getAtomC()->getGlobalIndex(); |
606 |
> |
d = inversion->getAtomD()->getGlobalIndex(); |
607 |
|
|
608 |
< |
} |
608 |
> |
if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) { |
609 |
> |
oneTwoInteractions_.removePair(a, b); |
610 |
> |
oneTwoInteractions_.removePair(a, c); |
611 |
> |
oneTwoInteractions_.removePair(a, d); |
612 |
> |
} else { |
613 |
> |
excludedInteractions_.removePair(a, b); |
614 |
> |
excludedInteractions_.removePair(a, c); |
615 |
> |
excludedInteractions_.removePair(a, d); |
616 |
> |
} |
617 |
|
|
618 |
+ |
if (options_.havevdw13scale() || options_.haveelectrostatic13scale()) { |
619 |
+ |
oneThreeInteractions_.removePair(b, c); |
620 |
+ |
oneThreeInteractions_.removePair(b, d); |
621 |
+ |
oneThreeInteractions_.removePair(c, d); |
622 |
+ |
} else { |
623 |
+ |
excludedInteractions_.removePair(b, c); |
624 |
+ |
excludedInteractions_.removePair(b, d); |
625 |
+ |
excludedInteractions_.removePair(c, d); |
626 |
+ |
} |
627 |
+ |
} |
628 |
|
|
629 |
< |
void SimInfo::addMoleculeStamp(MoleculeStamp* molStamp, int nmol) { |
629 |
> |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; |
630 |
> |
rb = mol->nextRigidBody(rbIter)) { |
631 |
> |
vector<Atom*> atoms = rb->getAtoms(); |
632 |
> |
for (int i = 0; i < static_cast<int>(atoms.size()) -1 ; ++i) { |
633 |
> |
for (int j = i + 1; j < static_cast<int>(atoms.size()); ++j) { |
634 |
> |
a = atoms[i]->getGlobalIndex(); |
635 |
> |
b = atoms[j]->getGlobalIndex(); |
636 |
> |
excludedInteractions_.removePair(a, b); |
637 |
> |
} |
638 |
> |
} |
639 |
> |
} |
640 |
> |
|
641 |
> |
} |
642 |
> |
|
643 |
> |
|
644 |
> |
void SimInfo::addMoleculeStamp(MoleculeStamp* molStamp, int nmol) { |
645 |
|
int curStampId; |
646 |
< |
|
646 |
> |
|
647 |
|
//index from 0 |
648 |
|
curStampId = moleculeStamps_.size(); |
649 |
|
|
650 |
|
moleculeStamps_.push_back(molStamp); |
651 |
|
molStampIds_.insert(molStampIds_.end(), nmol, curStampId); |
652 |
< |
} |
652 |
> |
} |
653 |
|
|
479 |
– |
void SimInfo::update() { |
654 |
|
|
655 |
< |
setupSimType(); |
656 |
< |
|
657 |
< |
#ifdef IS_MPI |
658 |
< |
setupFortranParallel(); |
659 |
< |
#endif |
660 |
< |
|
661 |
< |
setupFortranSim(); |
662 |
< |
|
663 |
< |
//setup fortran force field |
490 |
< |
/** @deprecate */ |
491 |
< |
int isError = 0; |
492 |
< |
initFortranFF( &fInfo_.SIM_uses_RF , &isError ); |
493 |
< |
if(isError){ |
494 |
< |
sprintf( painCave.errMsg, |
495 |
< |
"ForceField error: There was an error initializing the forceField in fortran.\n" ); |
496 |
< |
painCave.isFatal = 1; |
497 |
< |
simError(); |
498 |
< |
} |
499 |
< |
|
500 |
< |
|
501 |
< |
setupCutoff(); |
502 |
< |
|
655 |
> |
/** |
656 |
> |
* update |
657 |
> |
* |
658 |
> |
* Performs the global checks and variable settings after the |
659 |
> |
* objects have been created. |
660 |
> |
* |
661 |
> |
*/ |
662 |
> |
void SimInfo::update() { |
663 |
> |
setupSimVariables(); |
664 |
|
calcNdf(); |
665 |
|
calcNdfRaw(); |
666 |
|
calcNdfTrans(); |
667 |
< |
|
668 |
< |
fortranInitialized_ = true; |
669 |
< |
} |
670 |
< |
|
671 |
< |
std::set<AtomType*> SimInfo::getUniqueAtomTypes() { |
667 |
> |
} |
668 |
> |
|
669 |
> |
/** |
670 |
> |
* getSimulatedAtomTypes |
671 |
> |
* |
672 |
> |
* Returns an STL set of AtomType* that are actually present in this |
673 |
> |
* simulation. Must query all processors to assemble this information. |
674 |
> |
* |
675 |
> |
*/ |
676 |
> |
set<AtomType*> SimInfo::getSimulatedAtomTypes() { |
677 |
|
SimInfo::MoleculeIterator mi; |
678 |
|
Molecule* mol; |
679 |
|
Molecule::AtomIterator ai; |
680 |
|
Atom* atom; |
681 |
< |
std::set<AtomType*> atomTypes; |
681 |
> |
set<AtomType*> atomTypes; |
682 |
> |
|
683 |
> |
for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
684 |
> |
for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
685 |
> |
atomTypes.insert(atom->getAtomType()); |
686 |
> |
} |
687 |
> |
} |
688 |
|
|
689 |
< |
for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
689 |
> |
#ifdef IS_MPI |
690 |
|
|
691 |
< |
for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
692 |
< |
atomTypes.insert(atom->getAtomType()); |
521 |
< |
} |
522 |
< |
|
523 |
< |
} |
691 |
> |
// loop over the found atom types on this processor, and add their |
692 |
> |
// numerical idents to a vector: |
693 |
|
|
694 |
< |
return atomTypes; |
695 |
< |
} |
694 |
> |
vector<int> foundTypes; |
695 |
> |
set<AtomType*>::iterator i; |
696 |
> |
for (i = atomTypes.begin(); i != atomTypes.end(); ++i) |
697 |
> |
foundTypes.push_back( (*i)->getIdent() ); |
698 |
|
|
699 |
< |
void SimInfo::setupSimType() { |
700 |
< |
std::set<AtomType*>::iterator i; |
530 |
< |
std::set<AtomType*> atomTypes; |
531 |
< |
atomTypes = getUniqueAtomTypes(); |
532 |
< |
|
533 |
< |
int useLennardJones = 0; |
534 |
< |
int useElectrostatic = 0; |
535 |
< |
int useEAM = 0; |
536 |
< |
int useCharge = 0; |
537 |
< |
int useDirectional = 0; |
538 |
< |
int useDipole = 0; |
539 |
< |
int useGayBerne = 0; |
540 |
< |
int useSticky = 0; |
541 |
< |
int useShape = 0; |
542 |
< |
int useFLARB = 0; //it is not in AtomType yet |
543 |
< |
int useDirectionalAtom = 0; |
544 |
< |
int useElectrostatics = 0; |
545 |
< |
//usePBC and useRF are from simParams |
546 |
< |
int usePBC = simParams_->getPBC(); |
547 |
< |
int useRF = simParams_->getUseRF(); |
699 |
> |
// count_local holds the number of found types on this processor |
700 |
> |
int count_local = foundTypes.size(); |
701 |
|
|
702 |
+ |
// count holds the total number of found types on all processors |
703 |
+ |
// (some will be redundant with the ones found locally): |
704 |
+ |
int count; |
705 |
+ |
MPI::COMM_WORLD.Allreduce(&count_local, &count, 1, MPI::INT, MPI::SUM); |
706 |
+ |
|
707 |
+ |
// create a vector to hold the globally found types, and resize it: |
708 |
+ |
vector<int> ftGlobal; |
709 |
+ |
ftGlobal.resize(count); |
710 |
+ |
vector<int> counts; |
711 |
+ |
|
712 |
+ |
int nproc = MPI::COMM_WORLD.Get_size(); |
713 |
+ |
counts.resize(nproc); |
714 |
+ |
vector<int> disps; |
715 |
+ |
disps.resize(nproc); |
716 |
+ |
|
717 |
+ |
// now spray out the foundTypes to all the other processors: |
718 |
+ |
|
719 |
+ |
MPI::COMM_WORLD.Allgatherv(&foundTypes[0], count_local, MPI::INT, |
720 |
+ |
&ftGlobal[0], &counts[0], &disps[0], MPI::INT); |
721 |
+ |
|
722 |
+ |
// foundIdents is a stl set, so inserting an already found ident |
723 |
+ |
// will have no effect. |
724 |
+ |
set<int> foundIdents; |
725 |
+ |
vector<int>::iterator j; |
726 |
+ |
for (j = ftGlobal.begin(); j != ftGlobal.end(); ++j) |
727 |
+ |
foundIdents.insert((*j)); |
728 |
+ |
|
729 |
+ |
// now iterate over the foundIdents and get the actual atom types |
730 |
+ |
// that correspond to these: |
731 |
+ |
set<int>::iterator it; |
732 |
+ |
for (it = foundIdents.begin(); it != foundIdents.end(); ++it) |
733 |
+ |
atomTypes.insert( forceField_->getAtomType((*it)) ); |
734 |
+ |
|
735 |
+ |
#endif |
736 |
+ |
|
737 |
+ |
return atomTypes; |
738 |
+ |
} |
739 |
+ |
|
740 |
+ |
void SimInfo::setupSimVariables() { |
741 |
+ |
useAtomicVirial_ = simParams_->getUseAtomicVirial(); |
742 |
+ |
// we only call setAccumulateBoxDipole if the accumulateBoxDipole parameter is true |
743 |
+ |
calcBoxDipole_ = false; |
744 |
+ |
if ( simParams_->haveAccumulateBoxDipole() ) |
745 |
+ |
if ( simParams_->getAccumulateBoxDipole() ) { |
746 |
+ |
calcBoxDipole_ = true; |
747 |
+ |
} |
748 |
+ |
|
749 |
+ |
set<AtomType*>::iterator i; |
750 |
+ |
set<AtomType*> atomTypes; |
751 |
+ |
atomTypes = getSimulatedAtomTypes(); |
752 |
+ |
int usesElectrostatic = 0; |
753 |
+ |
int usesMetallic = 0; |
754 |
+ |
int usesDirectional = 0; |
755 |
|
//loop over all of the atom types |
756 |
|
for (i = atomTypes.begin(); i != atomTypes.end(); ++i) { |
757 |
< |
useLennardJones |= (*i)->isLennardJones(); |
758 |
< |
useElectrostatic |= (*i)->isElectrostatic(); |
759 |
< |
useEAM |= (*i)->isEAM(); |
554 |
< |
useCharge |= (*i)->isCharge(); |
555 |
< |
useDirectional |= (*i)->isDirectional(); |
556 |
< |
useDipole |= (*i)->isDipole(); |
557 |
< |
useGayBerne |= (*i)->isGayBerne(); |
558 |
< |
useSticky |= (*i)->isSticky(); |
559 |
< |
useShape |= (*i)->isShape(); |
757 |
> |
usesElectrostatic |= (*i)->isElectrostatic(); |
758 |
> |
usesMetallic |= (*i)->isMetal(); |
759 |
> |
usesDirectional |= (*i)->isDirectional(); |
760 |
|
} |
761 |
|
|
562 |
– |
if (useSticky || useDipole || useGayBerne || useShape) { |
563 |
– |
useDirectionalAtom = 1; |
564 |
– |
} |
565 |
– |
|
566 |
– |
if (useCharge || useDipole) { |
567 |
– |
useElectrostatics = 1; |
568 |
– |
} |
569 |
– |
|
762 |
|
#ifdef IS_MPI |
763 |
|
int temp; |
764 |
+ |
temp = usesDirectional; |
765 |
+ |
MPI_Allreduce(&temp, &usesDirectionalAtoms_, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
766 |
|
|
767 |
< |
temp = usePBC; |
768 |
< |
MPI_Allreduce(&temp, &usePBC, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
767 |
> |
temp = usesMetallic; |
768 |
> |
MPI_Allreduce(&temp, &usesMetallicAtoms_, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
769 |
|
|
770 |
< |
temp = useDirectionalAtom; |
771 |
< |
MPI_Allreduce(&temp, &useDirectionalAtom, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
770 |
> |
temp = usesElectrostatic; |
771 |
> |
MPI_Allreduce(&temp, &usesElectrostaticAtoms_, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
772 |
> |
#endif |
773 |
> |
} |
774 |
|
|
579 |
– |
temp = useLennardJones; |
580 |
– |
MPI_Allreduce(&temp, &useLennardJones, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
775 |
|
|
776 |
< |
temp = useElectrostatics; |
777 |
< |
MPI_Allreduce(&temp, &useElectrostatics, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
776 |
> |
vector<int> SimInfo::getGlobalAtomIndices() { |
777 |
> |
SimInfo::MoleculeIterator mi; |
778 |
> |
Molecule* mol; |
779 |
> |
Molecule::AtomIterator ai; |
780 |
> |
Atom* atom; |
781 |
|
|
782 |
< |
temp = useCharge; |
586 |
< |
MPI_Allreduce(&temp, &useCharge, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
587 |
< |
|
588 |
< |
temp = useDipole; |
589 |
< |
MPI_Allreduce(&temp, &useDipole, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
590 |
< |
|
591 |
< |
temp = useSticky; |
592 |
< |
MPI_Allreduce(&temp, &useSticky, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
593 |
< |
|
594 |
< |
temp = useGayBerne; |
595 |
< |
MPI_Allreduce(&temp, &useGayBerne, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
596 |
< |
|
597 |
< |
temp = useEAM; |
598 |
< |
MPI_Allreduce(&temp, &useEAM, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
599 |
< |
|
600 |
< |
temp = useShape; |
601 |
< |
MPI_Allreduce(&temp, &useShape, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
602 |
< |
|
603 |
< |
temp = useFLARB; |
604 |
< |
MPI_Allreduce(&temp, &useFLARB, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
605 |
< |
|
606 |
< |
temp = useRF; |
607 |
< |
MPI_Allreduce(&temp, &useRF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
782 |
> |
vector<int> GlobalAtomIndices(getNAtoms(), 0); |
783 |
|
|
784 |
< |
#endif |
784 |
> |
for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
785 |
> |
|
786 |
> |
for (atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
787 |
> |
GlobalAtomIndices[atom->getLocalIndex()] = atom->getGlobalIndex(); |
788 |
> |
} |
789 |
> |
} |
790 |
> |
return GlobalAtomIndices; |
791 |
> |
} |
792 |
|
|
611 |
– |
fInfo_.SIM_uses_PBC = usePBC; |
612 |
– |
fInfo_.SIM_uses_DirectionalAtoms = useDirectionalAtom; |
613 |
– |
fInfo_.SIM_uses_LennardJones = useLennardJones; |
614 |
– |
fInfo_.SIM_uses_Electrostatics = useElectrostatics; |
615 |
– |
fInfo_.SIM_uses_Charges = useCharge; |
616 |
– |
fInfo_.SIM_uses_Dipoles = useDipole; |
617 |
– |
fInfo_.SIM_uses_Sticky = useSticky; |
618 |
– |
fInfo_.SIM_uses_GayBerne = useGayBerne; |
619 |
– |
fInfo_.SIM_uses_EAM = useEAM; |
620 |
– |
fInfo_.SIM_uses_Shapes = useShape; |
621 |
– |
fInfo_.SIM_uses_FLARB = useFLARB; |
622 |
– |
fInfo_.SIM_uses_RF = useRF; |
793 |
|
|
794 |
< |
if( fInfo_.SIM_uses_Dipoles && fInfo_.SIM_uses_RF) { |
794 |
> |
vector<int> SimInfo::getGlobalGroupIndices() { |
795 |
> |
SimInfo::MoleculeIterator mi; |
796 |
> |
Molecule* mol; |
797 |
> |
Molecule::CutoffGroupIterator ci; |
798 |
> |
CutoffGroup* cg; |
799 |
|
|
800 |
< |
if (simParams_->haveDielectric()) { |
801 |
< |
fInfo_.dielect = simParams_->getDielectric(); |
802 |
< |
} else { |
803 |
< |
sprintf(painCave.errMsg, |
804 |
< |
"SimSetup Error: No Dielectric constant was set.\n" |
805 |
< |
"\tYou are trying to use Reaction Field without" |
806 |
< |
"\tsetting a dielectric constant!\n"); |
807 |
< |
painCave.isFatal = 1; |
808 |
< |
simError(); |
809 |
< |
} |
636 |
< |
|
637 |
< |
} else { |
638 |
< |
fInfo_.dielect = 0.0; |
800 |
> |
vector<int> GlobalGroupIndices; |
801 |
> |
|
802 |
> |
for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
803 |
> |
|
804 |
> |
//local index of cutoff group is trivial, it only depends on the |
805 |
> |
//order of travesing |
806 |
> |
for (cg = mol->beginCutoffGroup(ci); cg != NULL; |
807 |
> |
cg = mol->nextCutoffGroup(ci)) { |
808 |
> |
GlobalGroupIndices.push_back(cg->getGlobalIndex()); |
809 |
> |
} |
810 |
|
} |
811 |
+ |
return GlobalGroupIndices; |
812 |
+ |
} |
813 |
|
|
641 |
– |
} |
814 |
|
|
815 |
< |
void SimInfo::setupFortranSim() { |
815 |
> |
void SimInfo::setupFortran() { |
816 |
|
int isError; |
817 |
< |
int nExclude; |
818 |
< |
std::vector<int> fortranGlobalGroupMembership; |
817 |
> |
int nExclude, nOneTwo, nOneThree, nOneFour; |
818 |
> |
vector<int> fortranGlobalGroupMembership; |
819 |
|
|
648 |
– |
nExclude = exclude_.getSize(); |
820 |
|
isError = 0; |
821 |
|
|
822 |
|
//globalGroupMembership_ is filled by SimCreator |
823 |
|
for (int i = 0; i < nGlobalAtoms_; i++) { |
824 |
< |
fortranGlobalGroupMembership.push_back(globalGroupMembership_[i] + 1); |
824 |
> |
fortranGlobalGroupMembership.push_back(globalGroupMembership_[i] + 1); |
825 |
|
} |
826 |
|
|
827 |
|
//calculate mass ratio of cutoff group |
828 |
< |
std::vector<double> mfact; |
828 |
> |
vector<RealType> mfact; |
829 |
|
SimInfo::MoleculeIterator mi; |
830 |
|
Molecule* mol; |
831 |
|
Molecule::CutoffGroupIterator ci; |
832 |
|
CutoffGroup* cg; |
833 |
|
Molecule::AtomIterator ai; |
834 |
|
Atom* atom; |
835 |
< |
double totalMass; |
835 |
> |
RealType totalMass; |
836 |
|
|
837 |
|
//to avoid memory reallocation, reserve enough space for mfact |
838 |
|
mfact.reserve(getNCutoffGroups()); |
839 |
|
|
840 |
|
for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
841 |
< |
for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { |
841 |
> |
for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { |
842 |
|
|
843 |
< |
totalMass = cg->getMass(); |
844 |
< |
for(atom = cg->beginAtom(ai); atom != NULL; atom = cg->nextAtom(ai)) { |
845 |
< |
mfact.push_back(atom->getMass()/totalMass); |
846 |
< |
} |
847 |
< |
|
848 |
< |
} |
843 |
> |
totalMass = cg->getMass(); |
844 |
> |
for(atom = cg->beginAtom(ai); atom != NULL; atom = cg->nextAtom(ai)) { |
845 |
> |
// Check for massless groups - set mfact to 1 if true |
846 |
> |
if (totalMass != 0) |
847 |
> |
mfact.push_back(atom->getMass()/totalMass); |
848 |
> |
else |
849 |
> |
mfact.push_back( 1.0 ); |
850 |
> |
} |
851 |
> |
} |
852 |
|
} |
853 |
|
|
854 |
< |
//fill ident array of local atoms (it is actually ident of AtomType, it is so confusing !!!) |
681 |
< |
std::vector<int> identArray; |
854 |
> |
// Build the identArray_ |
855 |
|
|
856 |
< |
//to avoid memory reallocation, reserve enough space identArray |
857 |
< |
identArray.reserve(getNAtoms()); |
685 |
< |
|
856 |
> |
identArray_.clear(); |
857 |
> |
identArray_.reserve(getNAtoms()); |
858 |
|
for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
859 |
< |
for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
860 |
< |
identArray.push_back(atom->getIdent()); |
861 |
< |
} |
859 |
> |
for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
860 |
> |
identArray_.push_back(atom->getIdent()); |
861 |
> |
} |
862 |
|
} |
863 |
|
|
864 |
|
//fill molMembershipArray |
865 |
|
//molMembershipArray is filled by SimCreator |
866 |
< |
std::vector<int> molMembershipArray(nGlobalAtoms_); |
866 |
> |
vector<int> molMembershipArray(nGlobalAtoms_); |
867 |
|
for (int i = 0; i < nGlobalAtoms_; i++) { |
868 |
< |
molMembershipArray[i] = globalMolMembership_[i] + 1; |
868 |
> |
molMembershipArray[i] = globalMolMembership_[i] + 1; |
869 |
|
} |
870 |
|
|
871 |
|
//setup fortran simulation |
700 |
– |
//gloalExcludes and molMembershipArray should go away (They are never used) |
701 |
– |
//why the hell fortran need to know molecule? |
702 |
– |
//OOPSE = Object-Obfuscated Parallel Simulation Engine |
703 |
– |
int nGlobalExcludes = 0; |
704 |
– |
int* globalExcludes = NULL; |
705 |
– |
int* excludeList = exclude_.getExcludeList(); |
706 |
– |
setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray[0], &nExclude, excludeList , |
707 |
– |
&nGlobalExcludes, globalExcludes, &molMembershipArray[0], |
708 |
– |
&mfact[0], &nCutoffGroups_, &fortranGlobalGroupMembership[0], &isError); |
872 |
|
|
873 |
< |
if( isError ){ |
873 |
> |
nExclude = excludedInteractions_.getSize(); |
874 |
> |
nOneTwo = oneTwoInteractions_.getSize(); |
875 |
> |
nOneThree = oneThreeInteractions_.getSize(); |
876 |
> |
nOneFour = oneFourInteractions_.getSize(); |
877 |
|
|
878 |
< |
sprintf( painCave.errMsg, |
879 |
< |
"There was an error setting the simulation information in fortran.\n" ); |
880 |
< |
painCave.isFatal = 1; |
881 |
< |
painCave.severity = OOPSE_ERROR; |
716 |
< |
simError(); |
717 |
< |
} |
878 |
> |
int* excludeList = excludedInteractions_.getPairList(); |
879 |
> |
int* oneTwoList = oneTwoInteractions_.getPairList(); |
880 |
> |
int* oneThreeList = oneThreeInteractions_.getPairList(); |
881 |
> |
int* oneFourList = oneFourInteractions_.getPairList(); |
882 |
|
|
883 |
< |
#ifdef IS_MPI |
884 |
< |
sprintf( checkPointMsg, |
885 |
< |
"succesfully sent the simulation information to fortran.\n"); |
886 |
< |
MPIcheckPoint(); |
887 |
< |
#endif // is_mpi |
888 |
< |
} |
889 |
< |
|
726 |
< |
|
727 |
< |
#ifdef IS_MPI |
728 |
< |
void SimInfo::setupFortranParallel() { |
883 |
> |
//setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray_[0], |
884 |
> |
// &nExclude, excludeList, |
885 |
> |
// &nOneTwo, oneTwoList, |
886 |
> |
// &nOneThree, oneThreeList, |
887 |
> |
// &nOneFour, oneFourList, |
888 |
> |
// &molMembershipArray[0], &mfact[0], &nCutoffGroups_, |
889 |
> |
// &fortranGlobalGroupMembership[0], &isError); |
890 |
|
|
891 |
< |
//SimInfo is responsible for creating localToGlobalAtomIndex and localToGlobalGroupIndex |
892 |
< |
std::vector<int> localToGlobalAtomIndex(getNAtoms(), 0); |
893 |
< |
std::vector<int> localToGlobalCutoffGroupIndex; |
894 |
< |
SimInfo::MoleculeIterator mi; |
895 |
< |
Molecule::AtomIterator ai; |
896 |
< |
Molecule::CutoffGroupIterator ci; |
897 |
< |
Molecule* mol; |
898 |
< |
Atom* atom; |
899 |
< |
CutoffGroup* cg; |
900 |
< |
mpiSimData parallelData; |
901 |
< |
int isError; |
891 |
> |
// if( isError ){ |
892 |
> |
// |
893 |
> |
// sprintf( painCave.errMsg, |
894 |
> |
// "There was an error setting the simulation information in fortran.\n" ); |
895 |
> |
// painCave.isFatal = 1; |
896 |
> |
// painCave.severity = OPENMD_ERROR; |
897 |
> |
// simError(); |
898 |
> |
//} |
899 |
> |
|
900 |
> |
|
901 |
> |
// sprintf( checkPointMsg, |
902 |
> |
// "succesfully sent the simulation information to fortran.\n"); |
903 |
> |
|
904 |
> |
// errorCheckPoint(); |
905 |
> |
|
906 |
> |
// Setup number of neighbors in neighbor list if present |
907 |
> |
//if (simParams_->haveNeighborListNeighbors()) { |
908 |
> |
// int nlistNeighbors = simParams_->getNeighborListNeighbors(); |
909 |
> |
// setNeighbors(&nlistNeighbors); |
910 |
> |
//} |
911 |
> |
|
912 |
> |
#ifdef IS_MPI |
913 |
> |
// mpiSimData parallelData; |
914 |
|
|
742 |
– |
for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
743 |
– |
|
744 |
– |
//local index(index in DataStorge) of atom is important |
745 |
– |
for (atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
746 |
– |
localToGlobalAtomIndex[atom->getLocalIndex()] = atom->getGlobalIndex() + 1; |
747 |
– |
} |
748 |
– |
|
749 |
– |
//local index of cutoff group is trivial, it only depends on the order of travesing |
750 |
– |
for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { |
751 |
– |
localToGlobalCutoffGroupIndex.push_back(cg->getGlobalIndex() + 1); |
752 |
– |
} |
753 |
– |
|
754 |
– |
} |
755 |
– |
|
915 |
|
//fill up mpiSimData struct |
916 |
< |
parallelData.nMolGlobal = getNGlobalMolecules(); |
917 |
< |
parallelData.nMolLocal = getNMolecules(); |
918 |
< |
parallelData.nAtomsGlobal = getNGlobalAtoms(); |
919 |
< |
parallelData.nAtomsLocal = getNAtoms(); |
920 |
< |
parallelData.nGroupsGlobal = getNGlobalCutoffGroups(); |
921 |
< |
parallelData.nGroupsLocal = getNCutoffGroups(); |
922 |
< |
parallelData.myNode = worldRank; |
923 |
< |
MPI_Comm_size(MPI_COMM_WORLD, &(parallelData.nProcessors)); |
916 |
> |
// parallelData.nMolGlobal = getNGlobalMolecules(); |
917 |
> |
// parallelData.nMolLocal = getNMolecules(); |
918 |
> |
// parallelData.nAtomsGlobal = getNGlobalAtoms(); |
919 |
> |
// parallelData.nAtomsLocal = getNAtoms(); |
920 |
> |
// parallelData.nGroupsGlobal = getNGlobalCutoffGroups(); |
921 |
> |
// parallelData.nGroupsLocal = getNCutoffGroups(); |
922 |
> |
// parallelData.myNode = worldRank; |
923 |
> |
// MPI_Comm_size(MPI_COMM_WORLD, &(parallelData.nProcessors)); |
924 |
|
|
925 |
|
//pass mpiSimData struct and index arrays to fortran |
926 |
< |
setFsimParallel(¶llelData, &(parallelData.nAtomsLocal), |
927 |
< |
&localToGlobalAtomIndex[0], &(parallelData.nGroupsLocal), |
928 |
< |
&localToGlobalCutoffGroupIndex[0], &isError); |
926 |
> |
//setFsimParallel(¶llelData, &(parallelData.nAtomsLocal), |
927 |
> |
// &localToGlobalAtomIndex[0], &(parallelData.nGroupsLocal), |
928 |
> |
// &localToGlobalCutoffGroupIndex[0], &isError); |
929 |
|
|
930 |
< |
if (isError) { |
931 |
< |
sprintf(painCave.errMsg, |
932 |
< |
"mpiRefresh errror: fortran didn't like something we gave it.\n"); |
933 |
< |
painCave.isFatal = 1; |
934 |
< |
simError(); |
935 |
< |
} |
930 |
> |
// if (isError) { |
931 |
> |
// sprintf(painCave.errMsg, |
932 |
> |
// "mpiRefresh errror: fortran didn't like something we gave it.\n"); |
933 |
> |
// painCave.isFatal = 1; |
934 |
> |
// simError(); |
935 |
> |
// } |
936 |
|
|
937 |
< |
sprintf(checkPointMsg, " mpiRefresh successful.\n"); |
938 |
< |
MPIcheckPoint(); |
780 |
< |
|
781 |
< |
|
782 |
< |
} |
783 |
< |
|
937 |
> |
// sprintf(checkPointMsg, " mpiRefresh successful.\n"); |
938 |
> |
// errorCheckPoint(); |
939 |
|
#endif |
940 |
|
|
941 |
< |
double SimInfo::calcMaxCutoffRadius() { |
941 |
> |
// initFortranFF(&isError); |
942 |
> |
// if (isError) { |
943 |
> |
// sprintf(painCave.errMsg, |
944 |
> |
// "initFortranFF errror: fortran didn't like something we gave it.\n"); |
945 |
> |
// painCave.isFatal = 1; |
946 |
> |
// simError(); |
947 |
> |
// } |
948 |
> |
// fortranInitialized_ = true; |
949 |
> |
} |
950 |
|
|
951 |
+ |
void SimInfo::addProperty(GenericData* genData) { |
952 |
+ |
properties_.addProperty(genData); |
953 |
+ |
} |
954 |
|
|
955 |
< |
std::set<AtomType*> atomTypes; |
956 |
< |
std::set<AtomType*>::iterator i; |
957 |
< |
std::vector<double> cutoffRadius; |
955 |
> |
void SimInfo::removeProperty(const string& propName) { |
956 |
> |
properties_.removeProperty(propName); |
957 |
> |
} |
958 |
|
|
959 |
< |
//get the unique atom types |
960 |
< |
atomTypes = getUniqueAtomTypes(); |
959 |
> |
void SimInfo::clearProperties() { |
960 |
> |
properties_.clearProperties(); |
961 |
> |
} |
962 |
|
|
963 |
< |
//query the max cutoff radius among these atom types |
964 |
< |
for (i = atomTypes.begin(); i != atomTypes.end(); ++i) { |
965 |
< |
cutoffRadius.push_back(forceField_->getRcutFromAtomType(*i)); |
966 |
< |
} |
963 |
> |
vector<string> SimInfo::getPropertyNames() { |
964 |
> |
return properties_.getPropertyNames(); |
965 |
> |
} |
966 |
> |
|
967 |
> |
vector<GenericData*> SimInfo::getProperties() { |
968 |
> |
return properties_.getProperties(); |
969 |
> |
} |
970 |
|
|
971 |
< |
double maxCutoffRadius = *(std::max_element(cutoffRadius.begin(), cutoffRadius.end())); |
972 |
< |
#ifdef IS_MPI |
973 |
< |
//pick the max cutoff radius among the processors |
804 |
< |
#endif |
805 |
< |
|
806 |
< |
return maxCutoffRadius; |
807 |
< |
} |
971 |
> |
GenericData* SimInfo::getPropertyByName(const string& propName) { |
972 |
> |
return properties_.getPropertyByName(propName); |
973 |
> |
} |
974 |
|
|
975 |
< |
void SimInfo::getCutoff(double& rcut, double& rsw) { |
976 |
< |
|
977 |
< |
if (fInfo_.SIM_uses_Charges | fInfo_.SIM_uses_Dipoles | fInfo_.SIM_uses_RF) { |
978 |
< |
|
979 |
< |
if (!simParams_->haveRcut()){ |
814 |
< |
sprintf(painCave.errMsg, |
815 |
< |
"SimCreator Warning: No value was set for the cutoffRadius.\n" |
816 |
< |
"\tOOPSE will use a default value of 15.0 angstroms" |
817 |
< |
"\tfor the cutoffRadius.\n"); |
818 |
< |
painCave.isFatal = 0; |
819 |
< |
simError(); |
820 |
< |
rcut = 15.0; |
821 |
< |
} else{ |
822 |
< |
rcut = simParams_->getRcut(); |
823 |
< |
} |
824 |
< |
|
825 |
< |
if (!simParams_->haveRsw()){ |
826 |
< |
sprintf(painCave.errMsg, |
827 |
< |
"SimCreator Warning: No value was set for switchingRadius.\n" |
828 |
< |
"\tOOPSE will use a default value of\n" |
829 |
< |
"\t0.95 * cutoffRadius for the switchingRadius\n"); |
830 |
< |
painCave.isFatal = 0; |
831 |
< |
simError(); |
832 |
< |
rsw = 0.95 * rcut; |
833 |
< |
} else{ |
834 |
< |
rsw = simParams_->getRsw(); |
835 |
< |
} |
836 |
< |
|
837 |
< |
} else { |
838 |
< |
// if charge, dipole or reaction field is not used and the cutofff radius is not specified in |
839 |
< |
//meta-data file, the maximum cutoff radius calculated from forcefiled will be used |
840 |
< |
|
841 |
< |
if (simParams_->haveRcut()) { |
842 |
< |
rcut = simParams_->getRcut(); |
843 |
< |
} else { |
844 |
< |
//set cutoff radius to the maximum cutoff radius based on atom types in the whole system |
845 |
< |
rcut = calcMaxCutoffRadius(); |
846 |
< |
} |
847 |
< |
|
848 |
< |
if (simParams_->haveRsw()) { |
849 |
< |
rsw = simParams_->getRsw(); |
850 |
< |
} else { |
851 |
< |
rsw = rcut; |
852 |
< |
} |
853 |
< |
|
854 |
< |
} |
855 |
< |
} |
856 |
< |
|
857 |
< |
void SimInfo::setupCutoff() { |
858 |
< |
getCutoff(rcut_, rsw_); |
859 |
< |
double rnblist = rcut_ + 1; // skin of neighbor list |
860 |
< |
|
861 |
< |
//Pass these cutoff radius etc. to fortran. This function should be called once and only once |
862 |
< |
notifyFortranCutoffs(&rcut_, &rsw_, &rnblist); |
863 |
< |
} |
864 |
< |
|
865 |
< |
void SimInfo::addProperty(GenericData* genData) { |
866 |
< |
properties_.addProperty(genData); |
867 |
< |
} |
868 |
< |
|
869 |
< |
void SimInfo::removeProperty(const std::string& propName) { |
870 |
< |
properties_.removeProperty(propName); |
871 |
< |
} |
872 |
< |
|
873 |
< |
void SimInfo::clearProperties() { |
874 |
< |
properties_.clearProperties(); |
875 |
< |
} |
876 |
< |
|
877 |
< |
std::vector<std::string> SimInfo::getPropertyNames() { |
878 |
< |
return properties_.getPropertyNames(); |
879 |
< |
} |
880 |
< |
|
881 |
< |
std::vector<GenericData*> SimInfo::getProperties() { |
882 |
< |
return properties_.getProperties(); |
883 |
< |
} |
884 |
< |
|
885 |
< |
GenericData* SimInfo::getPropertyByName(const std::string& propName) { |
886 |
< |
return properties_.getPropertyByName(propName); |
887 |
< |
} |
888 |
< |
|
889 |
< |
void SimInfo::setSnapshotManager(SnapshotManager* sman) { |
890 |
< |
//if (sman_ == sman_) { |
891 |
< |
// return; |
892 |
< |
//} |
893 |
< |
|
894 |
< |
//delete sman_; |
975 |
> |
void SimInfo::setSnapshotManager(SnapshotManager* sman) { |
976 |
> |
if (sman_ == sman) { |
977 |
> |
return; |
978 |
> |
} |
979 |
> |
delete sman_; |
980 |
|
sman_ = sman; |
981 |
|
|
982 |
|
Molecule* mol; |
983 |
|
RigidBody* rb; |
984 |
|
Atom* atom; |
985 |
+ |
CutoffGroup* cg; |
986 |
|
SimInfo::MoleculeIterator mi; |
987 |
|
Molecule::RigidBodyIterator rbIter; |
988 |
< |
Molecule::AtomIterator atomIter;; |
988 |
> |
Molecule::AtomIterator atomIter; |
989 |
> |
Molecule::CutoffGroupIterator cgIter; |
990 |
|
|
991 |
|
for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
992 |
|
|
993 |
< |
for (atom = mol->beginAtom(atomIter); atom != NULL; atom = mol->nextAtom(atomIter)) { |
994 |
< |
atom->setSnapshotManager(sman_); |
995 |
< |
} |
993 |
> |
for (atom = mol->beginAtom(atomIter); atom != NULL; atom = mol->nextAtom(atomIter)) { |
994 |
> |
atom->setSnapshotManager(sman_); |
995 |
> |
} |
996 |
|
|
997 |
< |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
998 |
< |
rb->setSnapshotManager(sman_); |
999 |
< |
} |
997 |
> |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
998 |
> |
rb->setSnapshotManager(sman_); |
999 |
> |
} |
1000 |
> |
|
1001 |
> |
for (cg = mol->beginCutoffGroup(cgIter); cg != NULL; cg = mol->nextCutoffGroup(cgIter)) { |
1002 |
> |
cg->setSnapshotManager(sman_); |
1003 |
> |
} |
1004 |
|
} |
1005 |
|
|
1006 |
< |
} |
1006 |
> |
} |
1007 |
|
|
1008 |
< |
Vector3d SimInfo::getComVel(){ |
1008 |
> |
Vector3d SimInfo::getComVel(){ |
1009 |
|
SimInfo::MoleculeIterator i; |
1010 |
|
Molecule* mol; |
1011 |
|
|
1012 |
|
Vector3d comVel(0.0); |
1013 |
< |
double totalMass = 0.0; |
1013 |
> |
RealType totalMass = 0.0; |
1014 |
|
|
1015 |
|
|
1016 |
|
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
1017 |
< |
double mass = mol->getMass(); |
1018 |
< |
totalMass += mass; |
1019 |
< |
comVel += mass * mol->getComVel(); |
1017 |
> |
RealType mass = mol->getMass(); |
1018 |
> |
totalMass += mass; |
1019 |
> |
comVel += mass * mol->getComVel(); |
1020 |
|
} |
1021 |
|
|
1022 |
|
#ifdef IS_MPI |
1023 |
< |
double tmpMass = totalMass; |
1023 |
> |
RealType tmpMass = totalMass; |
1024 |
|
Vector3d tmpComVel(comVel); |
1025 |
< |
MPI_Allreduce(&tmpMass,&totalMass,1,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1026 |
< |
MPI_Allreduce(tmpComVel.getArrayPointer(), comVel.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1025 |
> |
MPI_Allreduce(&tmpMass,&totalMass,1,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); |
1026 |
> |
MPI_Allreduce(tmpComVel.getArrayPointer(), comVel.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); |
1027 |
|
#endif |
1028 |
|
|
1029 |
|
comVel /= totalMass; |
1030 |
|
|
1031 |
|
return comVel; |
1032 |
< |
} |
1032 |
> |
} |
1033 |
|
|
1034 |
< |
Vector3d SimInfo::getCom(){ |
1034 |
> |
Vector3d SimInfo::getCom(){ |
1035 |
|
SimInfo::MoleculeIterator i; |
1036 |
|
Molecule* mol; |
1037 |
|
|
1038 |
|
Vector3d com(0.0); |
1039 |
< |
double totalMass = 0.0; |
1039 |
> |
RealType totalMass = 0.0; |
1040 |
|
|
1041 |
|
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
1042 |
< |
double mass = mol->getMass(); |
1043 |
< |
totalMass += mass; |
1044 |
< |
com += mass * mol->getCom(); |
1042 |
> |
RealType mass = mol->getMass(); |
1043 |
> |
totalMass += mass; |
1044 |
> |
com += mass * mol->getCom(); |
1045 |
|
} |
1046 |
|
|
1047 |
|
#ifdef IS_MPI |
1048 |
< |
double tmpMass = totalMass; |
1048 |
> |
RealType tmpMass = totalMass; |
1049 |
|
Vector3d tmpCom(com); |
1050 |
< |
MPI_Allreduce(&tmpMass,&totalMass,1,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1051 |
< |
MPI_Allreduce(tmpCom.getArrayPointer(), com.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1050 |
> |
MPI_Allreduce(&tmpMass,&totalMass,1,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); |
1051 |
> |
MPI_Allreduce(tmpCom.getArrayPointer(), com.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); |
1052 |
|
#endif |
1053 |
|
|
1054 |
|
com /= totalMass; |
1055 |
|
|
1056 |
|
return com; |
1057 |
|
|
1058 |
< |
} |
1058 |
> |
} |
1059 |
|
|
1060 |
< |
std::ostream& operator <<(std::ostream& o, SimInfo& info) { |
1060 |
> |
ostream& operator <<(ostream& o, SimInfo& info) { |
1061 |
|
|
1062 |
|
return o; |
1063 |
< |
} |
1063 |
> |
} |
1064 |
> |
|
1065 |
> |
|
1066 |
> |
/* |
1067 |
> |
Returns center of mass and center of mass velocity in one function call. |
1068 |
> |
*/ |
1069 |
> |
|
1070 |
> |
void SimInfo::getComAll(Vector3d &com, Vector3d &comVel){ |
1071 |
> |
SimInfo::MoleculeIterator i; |
1072 |
> |
Molecule* mol; |
1073 |
> |
|
1074 |
> |
|
1075 |
> |
RealType totalMass = 0.0; |
1076 |
> |
|
1077 |
|
|
1078 |
< |
}//end namespace oopse |
1078 |
> |
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
1079 |
> |
RealType mass = mol->getMass(); |
1080 |
> |
totalMass += mass; |
1081 |
> |
com += mass * mol->getCom(); |
1082 |
> |
comVel += mass * mol->getComVel(); |
1083 |
> |
} |
1084 |
> |
|
1085 |
> |
#ifdef IS_MPI |
1086 |
> |
RealType tmpMass = totalMass; |
1087 |
> |
Vector3d tmpCom(com); |
1088 |
> |
Vector3d tmpComVel(comVel); |
1089 |
> |
MPI_Allreduce(&tmpMass,&totalMass,1,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); |
1090 |
> |
MPI_Allreduce(tmpCom.getArrayPointer(), com.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); |
1091 |
> |
MPI_Allreduce(tmpComVel.getArrayPointer(), comVel.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); |
1092 |
> |
#endif |
1093 |
> |
|
1094 |
> |
com /= totalMass; |
1095 |
> |
comVel /= totalMass; |
1096 |
> |
} |
1097 |
> |
|
1098 |
> |
/* |
1099 |
> |
Return intertia tensor for entire system and angular momentum Vector. |
1100 |
|
|
1101 |
+ |
|
1102 |
+ |
[ Ixx -Ixy -Ixz ] |
1103 |
+ |
J =| -Iyx Iyy -Iyz | |
1104 |
+ |
[ -Izx -Iyz Izz ] |
1105 |
+ |
*/ |
1106 |
+ |
|
1107 |
+ |
void SimInfo::getInertiaTensor(Mat3x3d &inertiaTensor, Vector3d &angularMomentum){ |
1108 |
+ |
|
1109 |
+ |
|
1110 |
+ |
RealType xx = 0.0; |
1111 |
+ |
RealType yy = 0.0; |
1112 |
+ |
RealType zz = 0.0; |
1113 |
+ |
RealType xy = 0.0; |
1114 |
+ |
RealType xz = 0.0; |
1115 |
+ |
RealType yz = 0.0; |
1116 |
+ |
Vector3d com(0.0); |
1117 |
+ |
Vector3d comVel(0.0); |
1118 |
+ |
|
1119 |
+ |
getComAll(com, comVel); |
1120 |
+ |
|
1121 |
+ |
SimInfo::MoleculeIterator i; |
1122 |
+ |
Molecule* mol; |
1123 |
+ |
|
1124 |
+ |
Vector3d thisq(0.0); |
1125 |
+ |
Vector3d thisv(0.0); |
1126 |
+ |
|
1127 |
+ |
RealType thisMass = 0.0; |
1128 |
+ |
|
1129 |
+ |
|
1130 |
+ |
|
1131 |
+ |
|
1132 |
+ |
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
1133 |
+ |
|
1134 |
+ |
thisq = mol->getCom()-com; |
1135 |
+ |
thisv = mol->getComVel()-comVel; |
1136 |
+ |
thisMass = mol->getMass(); |
1137 |
+ |
// Compute moment of intertia coefficients. |
1138 |
+ |
xx += thisq[0]*thisq[0]*thisMass; |
1139 |
+ |
yy += thisq[1]*thisq[1]*thisMass; |
1140 |
+ |
zz += thisq[2]*thisq[2]*thisMass; |
1141 |
+ |
|
1142 |
+ |
// compute products of intertia |
1143 |
+ |
xy += thisq[0]*thisq[1]*thisMass; |
1144 |
+ |
xz += thisq[0]*thisq[2]*thisMass; |
1145 |
+ |
yz += thisq[1]*thisq[2]*thisMass; |
1146 |
+ |
|
1147 |
+ |
angularMomentum += cross( thisq, thisv ) * thisMass; |
1148 |
+ |
|
1149 |
+ |
} |
1150 |
+ |
|
1151 |
+ |
|
1152 |
+ |
inertiaTensor(0,0) = yy + zz; |
1153 |
+ |
inertiaTensor(0,1) = -xy; |
1154 |
+ |
inertiaTensor(0,2) = -xz; |
1155 |
+ |
inertiaTensor(1,0) = -xy; |
1156 |
+ |
inertiaTensor(1,1) = xx + zz; |
1157 |
+ |
inertiaTensor(1,2) = -yz; |
1158 |
+ |
inertiaTensor(2,0) = -xz; |
1159 |
+ |
inertiaTensor(2,1) = -yz; |
1160 |
+ |
inertiaTensor(2,2) = xx + yy; |
1161 |
+ |
|
1162 |
+ |
#ifdef IS_MPI |
1163 |
+ |
Mat3x3d tmpI(inertiaTensor); |
1164 |
+ |
Vector3d tmpAngMom; |
1165 |
+ |
MPI_Allreduce(tmpI.getArrayPointer(), inertiaTensor.getArrayPointer(),9,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); |
1166 |
+ |
MPI_Allreduce(tmpAngMom.getArrayPointer(), angularMomentum.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); |
1167 |
+ |
#endif |
1168 |
+ |
|
1169 |
+ |
return; |
1170 |
+ |
} |
1171 |
+ |
|
1172 |
+ |
//Returns the angular momentum of the system |
1173 |
+ |
Vector3d SimInfo::getAngularMomentum(){ |
1174 |
+ |
|
1175 |
+ |
Vector3d com(0.0); |
1176 |
+ |
Vector3d comVel(0.0); |
1177 |
+ |
Vector3d angularMomentum(0.0); |
1178 |
+ |
|
1179 |
+ |
getComAll(com,comVel); |
1180 |
+ |
|
1181 |
+ |
SimInfo::MoleculeIterator i; |
1182 |
+ |
Molecule* mol; |
1183 |
+ |
|
1184 |
+ |
Vector3d thisr(0.0); |
1185 |
+ |
Vector3d thisp(0.0); |
1186 |
+ |
|
1187 |
+ |
RealType thisMass; |
1188 |
+ |
|
1189 |
+ |
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
1190 |
+ |
thisMass = mol->getMass(); |
1191 |
+ |
thisr = mol->getCom()-com; |
1192 |
+ |
thisp = (mol->getComVel()-comVel)*thisMass; |
1193 |
+ |
|
1194 |
+ |
angularMomentum += cross( thisr, thisp ); |
1195 |
+ |
|
1196 |
+ |
} |
1197 |
+ |
|
1198 |
+ |
#ifdef IS_MPI |
1199 |
+ |
Vector3d tmpAngMom; |
1200 |
+ |
MPI_Allreduce(tmpAngMom.getArrayPointer(), angularMomentum.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); |
1201 |
+ |
#endif |
1202 |
+ |
|
1203 |
+ |
return angularMomentum; |
1204 |
+ |
} |
1205 |
+ |
|
1206 |
+ |
StuntDouble* SimInfo::getIOIndexToIntegrableObject(int index) { |
1207 |
+ |
return IOIndexToIntegrableObject.at(index); |
1208 |
+ |
} |
1209 |
+ |
|
1210 |
+ |
void SimInfo::setIOIndexToIntegrableObject(const vector<StuntDouble*>& v) { |
1211 |
+ |
IOIndexToIntegrableObject= v; |
1212 |
+ |
} |
1213 |
+ |
|
1214 |
+ |
/* Returns the Volume of the simulation based on a ellipsoid with semi-axes |
1215 |
+ |
based on the radius of gyration V=4/3*Pi*R_1*R_2*R_3 |
1216 |
+ |
where R_i are related to the principle inertia moments R_i = sqrt(C*I_i/N), this reduces to |
1217 |
+ |
V = 4/3*Pi*(C/N)^3/2*sqrt(det(I)). See S.E. Baltazar et. al. Comp. Mat. Sci. 37 (2006) 526-536. |
1218 |
+ |
*/ |
1219 |
+ |
void SimInfo::getGyrationalVolume(RealType &volume){ |
1220 |
+ |
Mat3x3d intTensor; |
1221 |
+ |
RealType det; |
1222 |
+ |
Vector3d dummyAngMom; |
1223 |
+ |
RealType sysconstants; |
1224 |
+ |
RealType geomCnst; |
1225 |
+ |
|
1226 |
+ |
geomCnst = 3.0/2.0; |
1227 |
+ |
/* Get the inertial tensor and angular momentum for free*/ |
1228 |
+ |
getInertiaTensor(intTensor,dummyAngMom); |
1229 |
+ |
|
1230 |
+ |
det = intTensor.determinant(); |
1231 |
+ |
sysconstants = geomCnst/(RealType)nGlobalIntegrableObjects_; |
1232 |
+ |
volume = 4.0/3.0*NumericConstant::PI*pow(sysconstants,3.0/2.0)*sqrt(det); |
1233 |
+ |
return; |
1234 |
+ |
} |
1235 |
+ |
|
1236 |
+ |
void SimInfo::getGyrationalVolume(RealType &volume, RealType &detI){ |
1237 |
+ |
Mat3x3d intTensor; |
1238 |
+ |
Vector3d dummyAngMom; |
1239 |
+ |
RealType sysconstants; |
1240 |
+ |
RealType geomCnst; |
1241 |
+ |
|
1242 |
+ |
geomCnst = 3.0/2.0; |
1243 |
+ |
/* Get the inertial tensor and angular momentum for free*/ |
1244 |
+ |
getInertiaTensor(intTensor,dummyAngMom); |
1245 |
+ |
|
1246 |
+ |
detI = intTensor.determinant(); |
1247 |
+ |
sysconstants = geomCnst/(RealType)nGlobalIntegrableObjects_; |
1248 |
+ |
volume = 4.0/3.0*NumericConstant::PI*pow(sysconstants,3.0/2.0)*sqrt(detI); |
1249 |
+ |
return; |
1250 |
+ |
} |
1251 |
+ |
/* |
1252 |
+ |
void SimInfo::setStuntDoubleFromGlobalIndex(vector<StuntDouble*> v) { |
1253 |
+ |
assert( v.size() == nAtoms_ + nRigidBodies_); |
1254 |
+ |
sdByGlobalIndex_ = v; |
1255 |
+ |
} |
1256 |
+ |
|
1257 |
+ |
StuntDouble* SimInfo::getStuntDoubleFromGlobalIndex(int index) { |
1258 |
+ |
//assert(index < nAtoms_ + nRigidBodies_); |
1259 |
+ |
return sdByGlobalIndex_.at(index); |
1260 |
+ |
} |
1261 |
+ |
*/ |
1262 |
+ |
int SimInfo::getNGlobalConstraints() { |
1263 |
+ |
int nGlobalConstraints; |
1264 |
+ |
#ifdef IS_MPI |
1265 |
+ |
MPI_Allreduce(&nConstraints_, &nGlobalConstraints, 1, MPI_INT, MPI_SUM, |
1266 |
+ |
MPI_COMM_WORLD); |
1267 |
+ |
#else |
1268 |
+ |
nGlobalConstraints = nConstraints_; |
1269 |
+ |
#endif |
1270 |
+ |
return nGlobalConstraints; |
1271 |
+ |
} |
1272 |
+ |
|
1273 |
+ |
}//end namespace OpenMD |
1274 |
+ |
|