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/fCutoffPolicy.h" |
56 |
< |
#include "UseTheForce/DarkSide/fElectrostaticSummationMethod.h" |
57 |
< |
#include "UseTheForce/DarkSide/fElectrostaticScreeningMethod.h" |
58 |
< |
#include "UseTheForce/DarkSide/fSwitchingFunctionType.h" |
59 |
< |
#include "UseTheForce/doForces_interface.h" |
60 |
< |
#include "UseTheForce/DarkSide/electrostatic_interface.h" |
61 |
< |
#include "UseTheForce/notifyCutoffs_interface.h" |
62 |
< |
#include "UseTheForce/DarkSide/switcheroo_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 { |
73 |
< |
|
74 |
< |
SimInfo::SimInfo(MakeStamps* stamps, std::vector<std::pair<MoleculeStamp*, int> >& molStampPairs, |
75 |
< |
ForceField* ff, Globals* simParams) : |
76 |
< |
stamps_(stamps), forceField_(ff), simParams_(simParams), |
77 |
< |
ndf_(0), ndfRaw_(0), ndfTrans_(0), nZconstraint_(0), |
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), nRigidBodies_(0), |
73 |
< |
nIntegrableObjects_(0), nCutoffGroups_(0), nConstraints_(0), |
74 |
< |
sman_(NULL), fortranInitialized_(false) { |
75 |
< |
|
84 |
< |
|
85 |
< |
std::vector<std::pair<MoleculeStamp*, int> >::iterator i; |
86 |
< |
MoleculeStamp* molStamp; |
87 |
< |
int nMolWithSameStamp; |
88 |
< |
int nCutoffAtoms = 0; // number of atoms belong to cutoff groups |
89 |
< |
int nGroups = 0; //total cutoff groups defined in meta-data file |
90 |
< |
CutoffGroupStamp* cgStamp; |
91 |
< |
RigidBodyStamp* rbStamp; |
92 |
< |
int nRigidAtoms = 0; |
72 |
> |
nAtoms_(0), nBonds_(0), nBends_(0), nTorsions_(0), nInversions_(0), |
73 |
> |
nRigidBodies_(0), nIntegrableObjects_(0), nCutoffGroups_(0), |
74 |
> |
nConstraints_(0), sman_(NULL), topologyDone_(false), |
75 |
> |
calcBoxDipole_(false), useAtomicVirial_(true) { |
76 |
|
|
77 |
< |
for (i = molStampPairs.begin(); i !=molStampPairs.end(); ++i) { |
78 |
< |
molStamp = i->first; |
79 |
< |
nMolWithSameStamp = i->second; |
80 |
< |
|
81 |
< |
addMoleculeStamp(molStamp, nMolWithSameStamp); |
82 |
< |
|
83 |
< |
//calculate atoms in molecules |
84 |
< |
nGlobalAtoms_ += molStamp->getNAtoms() *nMolWithSameStamp; |
85 |
< |
|
86 |
< |
|
87 |
< |
//calculate atoms in cutoff groups |
88 |
< |
int nAtomsInGroups = 0; |
89 |
< |
int nCutoffGroupsInStamp = molStamp->getNCutoffGroups(); |
90 |
< |
|
91 |
< |
for (int j=0; j < nCutoffGroupsInStamp; j++) { |
92 |
< |
cgStamp = molStamp->getCutoffGroup(j); |
93 |
< |
nAtomsInGroups += cgStamp->getNMembers(); |
94 |
< |
} |
95 |
< |
|
96 |
< |
nGroups += nCutoffGroupsInStamp * nMolWithSameStamp; |
97 |
< |
|
98 |
< |
nCutoffAtoms += nAtomsInGroups * nMolWithSameStamp; |
99 |
< |
|
100 |
< |
//calculate atoms in rigid bodies |
101 |
< |
int nAtomsInRigidBodies = 0; |
102 |
< |
int nRigidBodiesInStamp = molStamp->getNRigidBodies(); |
120 |
< |
|
121 |
< |
for (int j=0; j < nRigidBodiesInStamp; j++) { |
122 |
< |
rbStamp = molStamp->getRigidBody(j); |
123 |
< |
nAtomsInRigidBodies += rbStamp->getNMembers(); |
124 |
< |
} |
125 |
< |
|
126 |
< |
nGlobalRigidBodies_ += nRigidBodiesInStamp * nMolWithSameStamp; |
127 |
< |
nRigidAtoms += nAtomsInRigidBodies * nMolWithSameStamp; |
128 |
< |
|
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 |
81 |
> |
CutoffGroupStamp* cgStamp; |
82 |
> |
RigidBodyStamp* rbStamp; |
83 |
> |
int nRigidAtoms = 0; |
84 |
> |
|
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 |
< |
//every free atom (atom does not belong to cutoff groups) is a cutoff |
106 |
< |
//group therefore the total number of cutoff groups in the system is |
107 |
< |
//equal to the total number of atoms minus number of atoms belong to |
108 |
< |
//cutoff group defined in meta-data file plus the number of cutoff |
109 |
< |
//groups defined in meta-data file |
110 |
< |
nGlobalCutoffGroups_ = nGlobalAtoms_ - nCutoffAtoms + nGroups; |
111 |
< |
|
112 |
< |
//every free atom (atom does not belong to rigid bodies) is an |
113 |
< |
//integrable object therefore the total number of integrable objects |
114 |
< |
//in the system is equal to the total number of atoms minus number of |
115 |
< |
//atoms belong to rigid body defined in meta-data file plus the number |
116 |
< |
//of rigid bodies defined in meta-data file |
117 |
< |
nGlobalIntegrableObjects_ = nGlobalAtoms_ - nRigidAtoms |
118 |
< |
+ nGlobalRigidBodies_; |
119 |
< |
|
120 |
< |
nGlobalMols_ = molStampIds_.size(); |
147 |
< |
|
148 |
< |
#ifdef IS_MPI |
149 |
< |
molToProcMap_.resize(nGlobalMols_); |
150 |
< |
#endif |
151 |
< |
|
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 |
|
|
132 |
+ |
nGlobalCutoffGroups_ = nGlobalAtoms_ - nCutoffAtoms + nGroups; |
133 |
+ |
|
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(); |
145 |
+ |
molToProcMap_.resize(nGlobalMols_); |
146 |
+ |
} |
147 |
+ |
|
148 |
|
SimInfo::~SimInfo() { |
149 |
< |
std::map<int, Molecule*>::iterator i; |
149 |
> |
map<int, Molecule*>::iterator i; |
150 |
|
for (i = molecules_.begin(); i != molecules_.end(); ++i) { |
151 |
|
delete i->second; |
152 |
|
} |
153 |
|
molecules_.clear(); |
154 |
|
|
161 |
– |
delete stamps_; |
155 |
|
delete sman_; |
156 |
|
delete simParams_; |
157 |
|
delete forceField_; |
158 |
|
} |
159 |
|
|
167 |
– |
int SimInfo::getNGlobalConstraints() { |
168 |
– |
int nGlobalConstraints; |
169 |
– |
#ifdef IS_MPI |
170 |
– |
MPI_Allreduce(&nConstraints_, &nGlobalConstraints, 1, MPI_INT, MPI_SUM, |
171 |
– |
MPI_COMM_WORLD); |
172 |
– |
#else |
173 |
– |
nGlobalConstraints = nConstraints_; |
174 |
– |
#endif |
175 |
– |
return nGlobalConstraints; |
176 |
– |
} |
160 |
|
|
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 |
< |
|
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 |
< |
addExcludePairs(mol); |
180 |
< |
|
178 |
> |
|
179 |
> |
addInteractionPairs(mol); |
180 |
> |
|
181 |
|
return true; |
182 |
|
} else { |
183 |
|
return false; |
184 |
|
} |
185 |
|
} |
186 |
< |
|
186 |
> |
|
187 |
|
bool SimInfo::removeMolecule(Molecule* mol) { |
188 |
|
MoleculeIterator i; |
189 |
|
i = molecules_.find(mol->getGlobalIndex()); |
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); |
205 |
> |
removeInteractionPairs(mol); |
206 |
|
molecules_.erase(mol->getGlobalIndex()); |
207 |
|
|
208 |
|
delete mol; |
211 |
|
} else { |
212 |
|
return false; |
213 |
|
} |
229 |
– |
|
230 |
– |
|
214 |
|
} |
215 |
|
|
216 |
|
|
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 |
|
|
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_; |
266 |
|
|
267 |
|
} |
268 |
|
|
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 |
|
|
326 |
|
|
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)) { |
392 |
> |
for (bend= mol->beginBend(bendIter); bend != NULL; |
393 |
> |
bend = mol->nextBend(bendIter)) { |
394 |
> |
|
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 |
< |
exclude_.addPair(a, b); |
408 |
< |
exclude_.addPair(a, c); |
409 |
< |
exclude_.addPair(b, c); |
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)) { |
414 |
> |
for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; |
415 |
> |
torsion = mol->nextTorsion(torsionIter)) { |
416 |
> |
|
417 |
|
a = torsion->getAtomA()->getGlobalIndex(); |
418 |
|
b = torsion->getAtomB()->getGlobalIndex(); |
419 |
|
c = torsion->getAtomC()->getGlobalIndex(); |
420 |
< |
d = torsion->getAtomD()->getGlobalIndex(); |
420 |
> |
d = torsion->getAtomD()->getGlobalIndex(); |
421 |
|
|
422 |
< |
exclude_.addPair(a, b); |
423 |
< |
exclude_.addPair(a, c); |
424 |
< |
exclude_.addPair(a, d); |
425 |
< |
exclude_.addPair(b, c); |
426 |
< |
exclude_.addPair(b, d); |
427 |
< |
exclude_.addPair(c, d); |
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; |
449 |
< |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
450 |
< |
std::vector<Atom*> atoms = rb->getAtoms(); |
451 |
< |
for (int i = 0; i < atoms.size() -1 ; ++i) { |
452 |
< |
for (int j = i + 1; j < atoms.size(); ++j) { |
447 |
> |
for (inversion= mol->beginInversion(inversionIter); inversion != NULL; |
448 |
> |
inversion = mol->nextInversion(inversionIter)) { |
449 |
> |
|
450 |
> |
a = inversion->getAtomA()->getGlobalIndex(); |
451 |
> |
b = inversion->getAtomB()->getGlobalIndex(); |
452 |
> |
c = inversion->getAtomC()->getGlobalIndex(); |
453 |
> |
d = inversion->getAtomD()->getGlobalIndex(); |
454 |
> |
|
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 |
> |
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 |
< |
exclude_.addPair(a, b); |
483 |
> |
excludedInteractions_.addPair(a, b); |
484 |
|
} |
485 |
|
} |
486 |
|
} |
487 |
|
|
488 |
|
} |
489 |
|
|
490 |
< |
void SimInfo::removeExcludePairs(Molecule* mol) { |
491 |
< |
std::vector<Bond*>::iterator bondIter; |
492 |
< |
std::vector<Bend*>::iterator bendIter; |
493 |
< |
std::vector<Torsion*>::iterator torsionIter; |
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)) { |
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 |
< |
exclude_.removePair(a, b); |
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)) { |
545 |
> |
for (bend= mol->beginBend(bendIter); bend != NULL; |
546 |
> |
bend = mol->nextBend(bendIter)) { |
547 |
> |
|
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 |
< |
exclude_.removePair(a, b); |
561 |
< |
exclude_.removePair(a, c); |
562 |
< |
exclude_.removePair(b, c); |
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)) { |
567 |
> |
for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; |
568 |
> |
torsion = mol->nextTorsion(torsionIter)) { |
569 |
> |
|
570 |
|
a = torsion->getAtomA()->getGlobalIndex(); |
571 |
|
b = torsion->getAtomB()->getGlobalIndex(); |
572 |
|
c = torsion->getAtomC()->getGlobalIndex(); |
573 |
< |
d = torsion->getAtomD()->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 |
< |
exclude_.removePair(a, b); |
586 |
< |
exclude_.removePair(a, c); |
587 |
< |
exclude_.removePair(a, d); |
588 |
< |
exclude_.removePair(b, c); |
589 |
< |
exclude_.removePair(b, d); |
590 |
< |
exclude_.removePair(c, d); |
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; |
602 |
< |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
603 |
< |
std::vector<Atom*> atoms = rb->getAtoms(); |
604 |
< |
for (int i = 0; i < atoms.size() -1 ; ++i) { |
605 |
< |
for (int j = i + 1; j < atoms.size(); ++j) { |
600 |
> |
for (inversion= mol->beginInversion(inversionIter); inversion != NULL; |
601 |
> |
inversion = mol->nextInversion(inversionIter)) { |
602 |
> |
|
603 |
> |
a = inversion->getAtomA()->getGlobalIndex(); |
604 |
> |
b = inversion->getAtomB()->getGlobalIndex(); |
605 |
> |
c = inversion->getAtomC()->getGlobalIndex(); |
606 |
> |
d = inversion->getAtomD()->getGlobalIndex(); |
607 |
> |
|
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 |
> |
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 |
< |
exclude_.removePair(a, b); |
636 |
> |
excludedInteractions_.removePair(a, b); |
637 |
|
} |
638 |
|
} |
639 |
|
} |
640 |
< |
|
640 |
> |
|
641 |
|
} |
642 |
< |
|
643 |
< |
|
642 |
> |
|
643 |
> |
|
644 |
|
void SimInfo::addMoleculeStamp(MoleculeStamp* molStamp, int nmol) { |
645 |
|
int curStampId; |
646 |
< |
|
646 |
> |
|
647 |
|
//index from 0 |
648 |
|
curStampId = moleculeStamps_.size(); |
649 |
|
|
651 |
|
molStampIds_.insert(molStampIds_.end(), nmol, curStampId); |
652 |
|
} |
653 |
|
|
462 |
– |
void SimInfo::update() { |
654 |
|
|
655 |
< |
setupSimType(); |
656 |
< |
|
657 |
< |
#ifdef IS_MPI |
658 |
< |
setupFortranParallel(); |
659 |
< |
#endif |
660 |
< |
|
661 |
< |
setupFortranSim(); |
662 |
< |
|
663 |
< |
//setup fortran force field |
473 |
< |
/** @deprecate */ |
474 |
< |
int isError = 0; |
475 |
< |
|
476 |
< |
setupElectrostaticSummationMethod( isError ); |
477 |
< |
setupSwitchingFunction(); |
478 |
< |
|
479 |
< |
if(isError){ |
480 |
< |
sprintf( painCave.errMsg, |
481 |
< |
"ForceField error: There was an error initializing the forceField in fortran.\n" ); |
482 |
< |
painCave.isFatal = 1; |
483 |
< |
simError(); |
484 |
< |
} |
485 |
< |
|
486 |
< |
|
487 |
< |
setupCutoff(); |
488 |
< |
|
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(); |
492 |
– |
|
493 |
– |
fortranInitialized_ = true; |
667 |
|
} |
668 |
< |
|
669 |
< |
std::set<AtomType*> SimInfo::getUniqueAtomTypes() { |
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; |
682 |
< |
|
683 |
< |
for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
504 |
< |
|
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 |
< |
|
509 |
< |
} |
686 |
> |
} |
687 |
> |
} |
688 |
|
|
689 |
< |
return atomTypes; |
512 |
< |
} |
689 |
> |
#ifdef IS_MPI |
690 |
|
|
691 |
< |
void SimInfo::setupSimType() { |
692 |
< |
std::set<AtomType*>::iterator i; |
516 |
< |
std::set<AtomType*> atomTypes; |
517 |
< |
atomTypes = getUniqueAtomTypes(); |
518 |
< |
|
519 |
< |
int useLennardJones = 0; |
520 |
< |
int useElectrostatic = 0; |
521 |
< |
int useEAM = 0; |
522 |
< |
int useSC = 0; |
523 |
< |
int useCharge = 0; |
524 |
< |
int useDirectional = 0; |
525 |
< |
int useDipole = 0; |
526 |
< |
int useGayBerne = 0; |
527 |
< |
int useSticky = 0; |
528 |
< |
int useStickyPower = 0; |
529 |
< |
int useShape = 0; |
530 |
< |
int useFLARB = 0; //it is not in AtomType yet |
531 |
< |
int useDirectionalAtom = 0; |
532 |
< |
int useElectrostatics = 0; |
533 |
< |
//usePBC and useRF are from simParams |
534 |
< |
int usePBC = simParams_->getUsePeriodicBoundaryConditions(); |
535 |
< |
int useRF; |
536 |
< |
int useSF; |
537 |
< |
std::string myMethod; |
691 |
> |
// loop over the found atom types on this processor, and add their |
692 |
> |
// numerical idents to a vector: |
693 |
|
|
694 |
< |
// set the useRF logical |
695 |
< |
useRF = 0; |
696 |
< |
useSF = 0; |
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 |
+ |
// count_local holds the number of found types on this processor |
700 |
+ |
int count_local = foundTypes.size(); |
701 |
|
|
702 |
< |
if (simParams_->haveElectrostaticSummationMethod()) { |
703 |
< |
std::string myMethod = simParams_->getElectrostaticSummationMethod(); |
704 |
< |
toUpper(myMethod); |
705 |
< |
if (myMethod == "REACTION_FIELD") { |
548 |
< |
useRF=1; |
549 |
< |
} else { |
550 |
< |
if (myMethod == "SHIFTED_FORCE") { |
551 |
< |
useSF = 1; |
552 |
< |
} |
553 |
< |
} |
554 |
< |
} |
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(); |
561 |
< |
useSC |= (*i)->isSC(); |
562 |
< |
useCharge |= (*i)->isCharge(); |
563 |
< |
useDirectional |= (*i)->isDirectional(); |
564 |
< |
useDipole |= (*i)->isDipole(); |
565 |
< |
useGayBerne |= (*i)->isGayBerne(); |
566 |
< |
useSticky |= (*i)->isSticky(); |
567 |
< |
useStickyPower |= (*i)->isStickyPower(); |
568 |
< |
useShape |= (*i)->isShape(); |
757 |
> |
usesElectrostatic |= (*i)->isElectrostatic(); |
758 |
> |
usesMetallic |= (*i)->isMetal(); |
759 |
> |
usesDirectional |= (*i)->isDirectional(); |
760 |
|
} |
761 |
|
|
571 |
– |
if (useSticky || useStickyPower || useDipole || useGayBerne || useShape) { |
572 |
– |
useDirectionalAtom = 1; |
573 |
– |
} |
574 |
– |
|
575 |
– |
if (useCharge || useDipole) { |
576 |
– |
useElectrostatics = 1; |
577 |
– |
} |
578 |
– |
|
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 |
|
|
588 |
– |
temp = useLennardJones; |
589 |
– |
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; |
595 |
< |
MPI_Allreduce(&temp, &useCharge, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
596 |
< |
|
597 |
< |
temp = useDipole; |
598 |
< |
MPI_Allreduce(&temp, &useDipole, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
599 |
< |
|
600 |
< |
temp = useSticky; |
601 |
< |
MPI_Allreduce(&temp, &useSticky, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
602 |
< |
|
603 |
< |
temp = useStickyPower; |
604 |
< |
MPI_Allreduce(&temp, &useStickyPower, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
782 |
> |
vector<int> GlobalAtomIndices(getNAtoms(), 0); |
783 |
|
|
784 |
< |
temp = useGayBerne; |
785 |
< |
MPI_Allreduce(&temp, &useGayBerne, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
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 |
|
|
609 |
– |
temp = useEAM; |
610 |
– |
MPI_Allreduce(&temp, &useEAM, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
793 |
|
|
794 |
< |
temp = useSC; |
795 |
< |
MPI_Allreduce(&temp, &useSC, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
796 |
< |
|
797 |
< |
temp = useShape; |
798 |
< |
MPI_Allreduce(&temp, &useShape, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
794 |
> |
vector<int> SimInfo::getGlobalGroupIndices() { |
795 |
> |
SimInfo::MoleculeIterator mi; |
796 |
> |
Molecule* mol; |
797 |
> |
Molecule::CutoffGroupIterator ci; |
798 |
> |
CutoffGroup* cg; |
799 |
|
|
800 |
< |
temp = useFLARB; |
801 |
< |
MPI_Allreduce(&temp, &useFLARB, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
802 |
< |
|
621 |
< |
temp = useRF; |
622 |
< |
MPI_Allreduce(&temp, &useRF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
623 |
< |
|
624 |
< |
temp = useSF; |
625 |
< |
MPI_Allreduce(&temp, &useSF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
626 |
< |
|
627 |
< |
#endif |
628 |
< |
|
629 |
< |
fInfo_.SIM_uses_PBC = usePBC; |
630 |
< |
fInfo_.SIM_uses_DirectionalAtoms = useDirectionalAtom; |
631 |
< |
fInfo_.SIM_uses_LennardJones = useLennardJones; |
632 |
< |
fInfo_.SIM_uses_Electrostatics = useElectrostatics; |
633 |
< |
fInfo_.SIM_uses_Charges = useCharge; |
634 |
< |
fInfo_.SIM_uses_Dipoles = useDipole; |
635 |
< |
fInfo_.SIM_uses_Sticky = useSticky; |
636 |
< |
fInfo_.SIM_uses_StickyPower = useStickyPower; |
637 |
< |
fInfo_.SIM_uses_GayBerne = useGayBerne; |
638 |
< |
fInfo_.SIM_uses_EAM = useEAM; |
639 |
< |
fInfo_.SIM_uses_SC = useSC; |
640 |
< |
fInfo_.SIM_uses_Shapes = useShape; |
641 |
< |
fInfo_.SIM_uses_FLARB = useFLARB; |
642 |
< |
fInfo_.SIM_uses_RF = useRF; |
643 |
< |
fInfo_.SIM_uses_SF = useSF; |
644 |
< |
|
645 |
< |
if( myMethod == "REACTION_FIELD") { |
800 |
> |
vector<int> GlobalGroupIndices; |
801 |
> |
|
802 |
> |
for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
803 |
|
|
804 |
< |
if (simParams_->haveDielectric()) { |
805 |
< |
fInfo_.dielect = simParams_->getDielectric(); |
806 |
< |
} else { |
807 |
< |
sprintf(painCave.errMsg, |
808 |
< |
"SimSetup Error: No Dielectric constant was set.\n" |
809 |
< |
"\tYou are trying to use Reaction Field without" |
653 |
< |
"\tsetting a dielectric constant!\n"); |
654 |
< |
painCave.isFatal = 1; |
655 |
< |
simError(); |
656 |
< |
} |
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 |
< |
|
811 |
> |
return GlobalGroupIndices; |
812 |
|
} |
813 |
|
|
661 |
– |
void SimInfo::setupFortranSim() { |
662 |
– |
int isError; |
663 |
– |
int nExclude; |
664 |
– |
std::vector<int> fortranGlobalGroupMembership; |
665 |
– |
|
666 |
– |
nExclude = exclude_.getSize(); |
667 |
– |
isError = 0; |
814 |
|
|
815 |
< |
//globalGroupMembership_ is filled by SimCreator |
816 |
< |
for (int i = 0; i < nGlobalAtoms_; i++) { |
671 |
< |
fortranGlobalGroupMembership.push_back(globalGroupMembership_[i] + 1); |
672 |
< |
} |
815 |
> |
void SimInfo::prepareTopology() { |
816 |
> |
int nExclude, nOneTwo, nOneThree, nOneFour; |
817 |
|
|
818 |
|
//calculate mass ratio of cutoff group |
675 |
– |
std::vector<double> mfact; |
819 |
|
SimInfo::MoleculeIterator mi; |
820 |
|
Molecule* mol; |
821 |
|
Molecule::CutoffGroupIterator ci; |
822 |
|
CutoffGroup* cg; |
823 |
|
Molecule::AtomIterator ai; |
824 |
|
Atom* atom; |
825 |
< |
double totalMass; |
825 |
> |
RealType totalMass; |
826 |
|
|
827 |
< |
//to avoid memory reallocation, reserve enough space for mfact |
828 |
< |
mfact.reserve(getNCutoffGroups()); |
827 |
> |
//to avoid memory reallocation, reserve enough space for massFactors_ |
828 |
> |
massFactors_.clear(); |
829 |
> |
massFactors_.reserve(getNCutoffGroups()); |
830 |
|
|
831 |
|
for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
832 |
< |
for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { |
832 |
> |
for (cg = mol->beginCutoffGroup(ci); cg != NULL; |
833 |
> |
cg = mol->nextCutoffGroup(ci)) { |
834 |
|
|
835 |
|
totalMass = cg->getMass(); |
836 |
|
for(atom = cg->beginAtom(ai); atom != NULL; atom = cg->nextAtom(ai)) { |
837 |
|
// Check for massless groups - set mfact to 1 if true |
838 |
|
if (totalMass != 0) |
839 |
< |
mfact.push_back(atom->getMass()/totalMass); |
839 |
> |
massFactors_.push_back(atom->getMass()/totalMass); |
840 |
|
else |
841 |
< |
mfact.push_back( 1.0 ); |
841 |
> |
massFactors_.push_back( 1.0 ); |
842 |
|
} |
698 |
– |
|
843 |
|
} |
844 |
|
} |
845 |
|
|
846 |
< |
//fill ident array of local atoms (it is actually ident of AtomType, it is so confusing !!!) |
703 |
< |
std::vector<int> identArray; |
846 |
> |
// Build the identArray_ |
847 |
|
|
848 |
< |
//to avoid memory reallocation, reserve enough space identArray |
849 |
< |
identArray.reserve(getNAtoms()); |
707 |
< |
|
848 |
> |
identArray_.clear(); |
849 |
> |
identArray_.reserve(getNAtoms()); |
850 |
|
for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
851 |
|
for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
852 |
< |
identArray.push_back(atom->getIdent()); |
852 |
> |
identArray_.push_back(atom->getIdent()); |
853 |
|
} |
854 |
|
} |
713 |
– |
|
714 |
– |
//fill molMembershipArray |
715 |
– |
//molMembershipArray is filled by SimCreator |
716 |
– |
std::vector<int> molMembershipArray(nGlobalAtoms_); |
717 |
– |
for (int i = 0; i < nGlobalAtoms_; i++) { |
718 |
– |
molMembershipArray[i] = globalMolMembership_[i] + 1; |
719 |
– |
} |
855 |
|
|
856 |
< |
//setup fortran simulation |
722 |
< |
int nGlobalExcludes = 0; |
723 |
< |
int* globalExcludes = NULL; |
724 |
< |
int* excludeList = exclude_.getExcludeList(); |
725 |
< |
setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray[0], &nExclude, excludeList , |
726 |
< |
&nGlobalExcludes, globalExcludes, &molMembershipArray[0], |
727 |
< |
&mfact[0], &nCutoffGroups_, &fortranGlobalGroupMembership[0], &isError); |
856 |
> |
//scan topology |
857 |
|
|
858 |
< |
if( isError ){ |
858 |
> |
nExclude = excludedInteractions_.getSize(); |
859 |
> |
nOneTwo = oneTwoInteractions_.getSize(); |
860 |
> |
nOneThree = oneThreeInteractions_.getSize(); |
861 |
> |
nOneFour = oneFourInteractions_.getSize(); |
862 |
|
|
863 |
< |
sprintf( painCave.errMsg, |
864 |
< |
"There was an error setting the simulation information in fortran.\n" ); |
865 |
< |
painCave.isFatal = 1; |
866 |
< |
painCave.severity = OOPSE_ERROR; |
735 |
< |
simError(); |
736 |
< |
} |
863 |
> |
int* excludeList = excludedInteractions_.getPairList(); |
864 |
> |
int* oneTwoList = oneTwoInteractions_.getPairList(); |
865 |
> |
int* oneThreeList = oneThreeInteractions_.getPairList(); |
866 |
> |
int* oneFourList = oneFourInteractions_.getPairList(); |
867 |
|
|
868 |
< |
#ifdef IS_MPI |
869 |
< |
sprintf( checkPointMsg, |
870 |
< |
"succesfully sent the simulation information to fortran.\n"); |
871 |
< |
MPIcheckPoint(); |
872 |
< |
#endif // is_mpi |
873 |
< |
} |
874 |
< |
|
745 |
< |
|
746 |
< |
#ifdef IS_MPI |
747 |
< |
void SimInfo::setupFortranParallel() { |
868 |
> |
//setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray_[0], |
869 |
> |
// &nExclude, excludeList, |
870 |
> |
// &nOneTwo, oneTwoList, |
871 |
> |
// &nOneThree, oneThreeList, |
872 |
> |
// &nOneFour, oneFourList, |
873 |
> |
// &molMembershipArray[0], &mfact[0], &nCutoffGroups_, |
874 |
> |
// &fortranGlobalGroupMembership[0], &isError); |
875 |
|
|
876 |
< |
//SimInfo is responsible for creating localToGlobalAtomIndex and localToGlobalGroupIndex |
750 |
< |
std::vector<int> localToGlobalAtomIndex(getNAtoms(), 0); |
751 |
< |
std::vector<int> localToGlobalCutoffGroupIndex; |
752 |
< |
SimInfo::MoleculeIterator mi; |
753 |
< |
Molecule::AtomIterator ai; |
754 |
< |
Molecule::CutoffGroupIterator ci; |
755 |
< |
Molecule* mol; |
756 |
< |
Atom* atom; |
757 |
< |
CutoffGroup* cg; |
758 |
< |
mpiSimData parallelData; |
759 |
< |
int isError; |
760 |
< |
|
761 |
< |
for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
762 |
< |
|
763 |
< |
//local index(index in DataStorge) of atom is important |
764 |
< |
for (atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
765 |
< |
localToGlobalAtomIndex[atom->getLocalIndex()] = atom->getGlobalIndex() + 1; |
766 |
< |
} |
767 |
< |
|
768 |
< |
//local index of cutoff group is trivial, it only depends on the order of travesing |
769 |
< |
for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { |
770 |
< |
localToGlobalCutoffGroupIndex.push_back(cg->getGlobalIndex() + 1); |
771 |
< |
} |
772 |
< |
|
773 |
< |
} |
774 |
< |
|
775 |
< |
//fill up mpiSimData struct |
776 |
< |
parallelData.nMolGlobal = getNGlobalMolecules(); |
777 |
< |
parallelData.nMolLocal = getNMolecules(); |
778 |
< |
parallelData.nAtomsGlobal = getNGlobalAtoms(); |
779 |
< |
parallelData.nAtomsLocal = getNAtoms(); |
780 |
< |
parallelData.nGroupsGlobal = getNGlobalCutoffGroups(); |
781 |
< |
parallelData.nGroupsLocal = getNCutoffGroups(); |
782 |
< |
parallelData.myNode = worldRank; |
783 |
< |
MPI_Comm_size(MPI_COMM_WORLD, &(parallelData.nProcessors)); |
784 |
< |
|
785 |
< |
//pass mpiSimData struct and index arrays to fortran |
786 |
< |
setFsimParallel(¶llelData, &(parallelData.nAtomsLocal), |
787 |
< |
&localToGlobalAtomIndex[0], &(parallelData.nGroupsLocal), |
788 |
< |
&localToGlobalCutoffGroupIndex[0], &isError); |
789 |
< |
|
790 |
< |
if (isError) { |
791 |
< |
sprintf(painCave.errMsg, |
792 |
< |
"mpiRefresh errror: fortran didn't like something we gave it.\n"); |
793 |
< |
painCave.isFatal = 1; |
794 |
< |
simError(); |
795 |
< |
} |
796 |
< |
|
797 |
< |
sprintf(checkPointMsg, " mpiRefresh successful.\n"); |
798 |
< |
MPIcheckPoint(); |
799 |
< |
|
800 |
< |
|
801 |
< |
} |
802 |
< |
|
803 |
< |
#endif |
804 |
< |
|
805 |
< |
double SimInfo::calcMaxCutoffRadius() { |
806 |
< |
|
807 |
< |
|
808 |
< |
std::set<AtomType*> atomTypes; |
809 |
< |
std::set<AtomType*>::iterator i; |
810 |
< |
std::vector<double> cutoffRadius; |
811 |
< |
|
812 |
< |
//get the unique atom types |
813 |
< |
atomTypes = getUniqueAtomTypes(); |
814 |
< |
|
815 |
< |
//query the max cutoff radius among these atom types |
816 |
< |
for (i = atomTypes.begin(); i != atomTypes.end(); ++i) { |
817 |
< |
cutoffRadius.push_back(forceField_->getRcutFromAtomType(*i)); |
818 |
< |
} |
819 |
< |
|
820 |
< |
double maxCutoffRadius = *(std::max_element(cutoffRadius.begin(), cutoffRadius.end())); |
821 |
< |
#ifdef IS_MPI |
822 |
< |
//pick the max cutoff radius among the processors |
823 |
< |
#endif |
824 |
< |
|
825 |
< |
return maxCutoffRadius; |
826 |
< |
} |
827 |
< |
|
828 |
< |
void SimInfo::getCutoff(double& rcut, double& rsw) { |
829 |
< |
|
830 |
< |
if (fInfo_.SIM_uses_Charges | fInfo_.SIM_uses_Dipoles | fInfo_.SIM_uses_RF) { |
831 |
< |
|
832 |
< |
if (!simParams_->haveCutoffRadius()){ |
833 |
< |
sprintf(painCave.errMsg, |
834 |
< |
"SimCreator Warning: No value was set for the cutoffRadius.\n" |
835 |
< |
"\tOOPSE will use a default value of 15.0 angstroms" |
836 |
< |
"\tfor the cutoffRadius.\n"); |
837 |
< |
painCave.isFatal = 0; |
838 |
< |
simError(); |
839 |
< |
rcut = 15.0; |
840 |
< |
} else{ |
841 |
< |
rcut = simParams_->getCutoffRadius(); |
842 |
< |
} |
843 |
< |
|
844 |
< |
if (!simParams_->haveSwitchingRadius()){ |
845 |
< |
sprintf(painCave.errMsg, |
846 |
< |
"SimCreator Warning: No value was set for switchingRadius.\n" |
847 |
< |
"\tOOPSE will use a default value of\n" |
848 |
< |
"\t0.85 * cutoffRadius for the switchingRadius\n"); |
849 |
< |
painCave.isFatal = 0; |
850 |
< |
simError(); |
851 |
< |
rsw = 0.85 * rcut; |
852 |
< |
} else{ |
853 |
< |
rsw = simParams_->getSwitchingRadius(); |
854 |
< |
} |
855 |
< |
|
856 |
< |
} else { |
857 |
< |
// if charge, dipole or reaction field is not used and the cutofff radius is not specified in |
858 |
< |
//meta-data file, the maximum cutoff radius calculated from forcefiled will be used |
859 |
< |
|
860 |
< |
if (simParams_->haveCutoffRadius()) { |
861 |
< |
rcut = simParams_->getCutoffRadius(); |
862 |
< |
} else { |
863 |
< |
//set cutoff radius to the maximum cutoff radius based on atom types in the whole system |
864 |
< |
rcut = calcMaxCutoffRadius(); |
865 |
< |
} |
866 |
< |
|
867 |
< |
if (simParams_->haveSwitchingRadius()) { |
868 |
< |
rsw = simParams_->getSwitchingRadius(); |
869 |
< |
} else { |
870 |
< |
rsw = rcut; |
871 |
< |
} |
872 |
< |
|
873 |
< |
} |
874 |
< |
} |
875 |
< |
|
876 |
< |
void SimInfo::setupCutoff() { |
877 |
< |
getCutoff(rcut_, rsw_); |
878 |
< |
double rnblist = rcut_ + 1; // skin of neighbor list |
879 |
< |
|
880 |
< |
//Pass these cutoff radius etc. to fortran. This function should be called once and only once |
881 |
< |
|
882 |
< |
int cp = TRADITIONAL_CUTOFF_POLICY; |
883 |
< |
if (simParams_->haveCutoffPolicy()) { |
884 |
< |
std::string myPolicy = simParams_->getCutoffPolicy(); |
885 |
< |
toUpper(myPolicy); |
886 |
< |
if (myPolicy == "MIX") { |
887 |
< |
cp = MIX_CUTOFF_POLICY; |
888 |
< |
} else { |
889 |
< |
if (myPolicy == "MAX") { |
890 |
< |
cp = MAX_CUTOFF_POLICY; |
891 |
< |
} else { |
892 |
< |
if (myPolicy == "TRADITIONAL") { |
893 |
< |
cp = TRADITIONAL_CUTOFF_POLICY; |
894 |
< |
} else { |
895 |
< |
// throw error |
896 |
< |
sprintf( painCave.errMsg, |
897 |
< |
"SimInfo error: Unknown cutoffPolicy. (Input file specified %s .)\n\tcutoffPolicy must be one of: \"Mix\", \"Max\", or \"Traditional\".", myPolicy.c_str() ); |
898 |
< |
painCave.isFatal = 1; |
899 |
< |
simError(); |
900 |
< |
} |
901 |
< |
} |
902 |
< |
} |
903 |
< |
} |
904 |
< |
|
905 |
< |
|
906 |
< |
if (simParams_->haveSkinThickness()) { |
907 |
< |
double skinThickness = simParams_->getSkinThickness(); |
908 |
< |
} |
909 |
< |
|
910 |
< |
notifyFortranCutoffs(&rcut_, &rsw_, &rnblist, &cp); |
911 |
< |
// also send cutoff notification to electrostatics |
912 |
< |
setElectrostaticCutoffRadius(&rcut_, &rsw_); |
913 |
< |
} |
914 |
< |
|
915 |
< |
void SimInfo::setupElectrostaticSummationMethod( int isError ) { |
916 |
< |
|
917 |
< |
int errorOut; |
918 |
< |
int esm = NONE; |
919 |
< |
int sm = UNDAMPED; |
920 |
< |
double alphaVal; |
921 |
< |
double dielectric; |
922 |
< |
|
923 |
< |
errorOut = isError; |
924 |
< |
alphaVal = simParams_->getDampingAlpha(); |
925 |
< |
dielectric = simParams_->getDielectric(); |
926 |
< |
|
927 |
< |
if (simParams_->haveElectrostaticSummationMethod()) { |
928 |
< |
std::string myMethod = simParams_->getElectrostaticSummationMethod(); |
929 |
< |
toUpper(myMethod); |
930 |
< |
if (myMethod == "NONE") { |
931 |
< |
esm = NONE; |
932 |
< |
} else { |
933 |
< |
if (myMethod == "SWITCHING_FUNCTION") { |
934 |
< |
esm = SWITCHING_FUNCTION; |
935 |
< |
} else { |
936 |
< |
if (myMethod == "SHIFTED_POTENTIAL") { |
937 |
< |
esm = SHIFTED_POTENTIAL; |
938 |
< |
} else { |
939 |
< |
if (myMethod == "SHIFTED_FORCE") { |
940 |
< |
esm = SHIFTED_FORCE; |
941 |
< |
} else { |
942 |
< |
if (myMethod == "REACTION_FIELD") { |
943 |
< |
esm = REACTION_FIELD; |
944 |
< |
} else { |
945 |
< |
// throw error |
946 |
< |
sprintf( painCave.errMsg, |
947 |
< |
"SimInfo error: Unknown electrostaticSummationMethod. (Input file specified %s .)\n\telectrostaticSummationMethod must be one of: \"none\", \"shifted_potential\", \"shifted_force\", or \"reaction_field\".", myMethod.c_str() ); |
948 |
< |
painCave.isFatal = 1; |
949 |
< |
simError(); |
950 |
< |
} |
951 |
< |
} |
952 |
< |
} |
953 |
< |
} |
954 |
< |
} |
955 |
< |
} |
956 |
< |
|
957 |
< |
if (simParams_->haveElectrostaticScreeningMethod()) { |
958 |
< |
std::string myScreen = simParams_->getElectrostaticScreeningMethod(); |
959 |
< |
toUpper(myScreen); |
960 |
< |
if (myScreen == "UNDAMPED") { |
961 |
< |
sm = UNDAMPED; |
962 |
< |
} else { |
963 |
< |
if (myScreen == "DAMPED") { |
964 |
< |
sm = DAMPED; |
965 |
< |
if (!simParams_->haveDampingAlpha()) { |
966 |
< |
//throw error |
967 |
< |
sprintf( painCave.errMsg, |
968 |
< |
"SimInfo warning: dampingAlpha was not specified in the input file. A default value of %f (1/ang) will be used.", alphaVal); |
969 |
< |
painCave.isFatal = 0; |
970 |
< |
simError(); |
971 |
< |
} |
972 |
< |
} else { |
973 |
< |
// throw error |
974 |
< |
sprintf( painCave.errMsg, |
975 |
< |
"SimInfo error: Unknown electrostaticScreeningMethod. (Input file specified %s .)\n\telectrostaticScreeningMethod must be one of: \"undamped\" or \"damped\".", myScreen.c_str() ); |
976 |
< |
painCave.isFatal = 1; |
977 |
< |
simError(); |
978 |
< |
} |
979 |
< |
} |
980 |
< |
} |
981 |
< |
|
982 |
< |
// let's pass some summation method variables to fortran |
983 |
< |
setElectrostaticSummationMethod( &esm ); |
984 |
< |
setScreeningMethod( &sm ); |
985 |
< |
setDampingAlpha( &alphaVal ); |
986 |
< |
setReactionFieldDielectric( &dielectric ); |
987 |
< |
initFortranFF( &esm, &errorOut ); |
988 |
< |
} |
989 |
< |
|
990 |
< |
void SimInfo::setupSwitchingFunction() { |
991 |
< |
int ft = CUBIC; |
992 |
< |
|
993 |
< |
if (simParams_->haveSwitchingFunctionType()) { |
994 |
< |
std::string funcType = simParams_->getSwitchingFunctionType(); |
995 |
< |
toUpper(funcType); |
996 |
< |
if (funcType == "CUBIC") { |
997 |
< |
ft = CUBIC; |
998 |
< |
} else { |
999 |
< |
if (funcType == "FIFTH_ORDER_POLYNOMIAL") { |
1000 |
< |
ft = FIFTH_ORDER_POLY; |
1001 |
< |
} else { |
1002 |
< |
// throw error |
1003 |
< |
sprintf( painCave.errMsg, |
1004 |
< |
"SimInfo error: Unknown switchingFunctionType. (Input file specified %s .)\n\tswitchingFunctionType must be one of: \"cubic\" or \"fifth_order_polynomial\".", funcType.c_str() ); |
1005 |
< |
painCave.isFatal = 1; |
1006 |
< |
simError(); |
1007 |
< |
} |
1008 |
< |
} |
1009 |
< |
} |
1010 |
< |
|
1011 |
< |
// send switching function notification to switcheroo |
1012 |
< |
setFunctionType(&ft); |
1013 |
< |
|
876 |
> |
topologyDone_ = true; |
877 |
|
} |
878 |
|
|
879 |
|
void SimInfo::addProperty(GenericData* genData) { |
880 |
|
properties_.addProperty(genData); |
881 |
|
} |
882 |
|
|
883 |
< |
void SimInfo::removeProperty(const std::string& propName) { |
883 |
> |
void SimInfo::removeProperty(const string& propName) { |
884 |
|
properties_.removeProperty(propName); |
885 |
|
} |
886 |
|
|
888 |
|
properties_.clearProperties(); |
889 |
|
} |
890 |
|
|
891 |
< |
std::vector<std::string> SimInfo::getPropertyNames() { |
891 |
> |
vector<string> SimInfo::getPropertyNames() { |
892 |
|
return properties_.getPropertyNames(); |
893 |
|
} |
894 |
|
|
895 |
< |
std::vector<GenericData*> SimInfo::getProperties() { |
895 |
> |
vector<GenericData*> SimInfo::getProperties() { |
896 |
|
return properties_.getProperties(); |
897 |
|
} |
898 |
|
|
899 |
< |
GenericData* SimInfo::getPropertyByName(const std::string& propName) { |
899 |
> |
GenericData* SimInfo::getPropertyByName(const string& propName) { |
900 |
|
return properties_.getPropertyByName(propName); |
901 |
|
} |
902 |
|
|
910 |
|
Molecule* mol; |
911 |
|
RigidBody* rb; |
912 |
|
Atom* atom; |
913 |
+ |
CutoffGroup* cg; |
914 |
|
SimInfo::MoleculeIterator mi; |
915 |
|
Molecule::RigidBodyIterator rbIter; |
916 |
< |
Molecule::AtomIterator atomIter;; |
916 |
> |
Molecule::AtomIterator atomIter; |
917 |
> |
Molecule::CutoffGroupIterator cgIter; |
918 |
|
|
919 |
|
for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
920 |
|
|
925 |
|
for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
926 |
|
rb->setSnapshotManager(sman_); |
927 |
|
} |
928 |
+ |
|
929 |
+ |
for (cg = mol->beginCutoffGroup(cgIter); cg != NULL; cg = mol->nextCutoffGroup(cgIter)) { |
930 |
+ |
cg->setSnapshotManager(sman_); |
931 |
+ |
} |
932 |
|
} |
933 |
|
|
934 |
|
} |
938 |
|
Molecule* mol; |
939 |
|
|
940 |
|
Vector3d comVel(0.0); |
941 |
< |
double totalMass = 0.0; |
941 |
> |
RealType totalMass = 0.0; |
942 |
|
|
943 |
|
|
944 |
|
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
945 |
< |
double mass = mol->getMass(); |
945 |
> |
RealType mass = mol->getMass(); |
946 |
|
totalMass += mass; |
947 |
|
comVel += mass * mol->getComVel(); |
948 |
|
} |
949 |
|
|
950 |
|
#ifdef IS_MPI |
951 |
< |
double tmpMass = totalMass; |
951 |
> |
RealType tmpMass = totalMass; |
952 |
|
Vector3d tmpComVel(comVel); |
953 |
< |
MPI_Allreduce(&tmpMass,&totalMass,1,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
954 |
< |
MPI_Allreduce(tmpComVel.getArrayPointer(), comVel.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
953 |
> |
MPI_Allreduce(&tmpMass,&totalMass,1,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); |
954 |
> |
MPI_Allreduce(tmpComVel.getArrayPointer(), comVel.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); |
955 |
|
#endif |
956 |
|
|
957 |
|
comVel /= totalMass; |
964 |
|
Molecule* mol; |
965 |
|
|
966 |
|
Vector3d com(0.0); |
967 |
< |
double totalMass = 0.0; |
967 |
> |
RealType totalMass = 0.0; |
968 |
|
|
969 |
|
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
970 |
< |
double mass = mol->getMass(); |
970 |
> |
RealType mass = mol->getMass(); |
971 |
|
totalMass += mass; |
972 |
|
com += mass * mol->getCom(); |
973 |
|
} |
974 |
|
|
975 |
|
#ifdef IS_MPI |
976 |
< |
double tmpMass = totalMass; |
976 |
> |
RealType tmpMass = totalMass; |
977 |
|
Vector3d tmpCom(com); |
978 |
< |
MPI_Allreduce(&tmpMass,&totalMass,1,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
979 |
< |
MPI_Allreduce(tmpCom.getArrayPointer(), com.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
978 |
> |
MPI_Allreduce(&tmpMass,&totalMass,1,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); |
979 |
> |
MPI_Allreduce(tmpCom.getArrayPointer(), com.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); |
980 |
|
#endif |
981 |
|
|
982 |
|
com /= totalMass; |
985 |
|
|
986 |
|
} |
987 |
|
|
988 |
< |
std::ostream& operator <<(std::ostream& o, SimInfo& info) { |
988 |
> |
ostream& operator <<(ostream& o, SimInfo& info) { |
989 |
|
|
990 |
|
return o; |
991 |
|
} |
1000 |
|
Molecule* mol; |
1001 |
|
|
1002 |
|
|
1003 |
< |
double totalMass = 0.0; |
1003 |
> |
RealType totalMass = 0.0; |
1004 |
|
|
1005 |
|
|
1006 |
|
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
1007 |
< |
double mass = mol->getMass(); |
1007 |
> |
RealType mass = mol->getMass(); |
1008 |
|
totalMass += mass; |
1009 |
|
com += mass * mol->getCom(); |
1010 |
|
comVel += mass * mol->getComVel(); |
1011 |
|
} |
1012 |
|
|
1013 |
|
#ifdef IS_MPI |
1014 |
< |
double tmpMass = totalMass; |
1014 |
> |
RealType tmpMass = totalMass; |
1015 |
|
Vector3d tmpCom(com); |
1016 |
|
Vector3d tmpComVel(comVel); |
1017 |
< |
MPI_Allreduce(&tmpMass,&totalMass,1,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1018 |
< |
MPI_Allreduce(tmpCom.getArrayPointer(), com.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1019 |
< |
MPI_Allreduce(tmpComVel.getArrayPointer(), comVel.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1017 |
> |
MPI_Allreduce(&tmpMass,&totalMass,1,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); |
1018 |
> |
MPI_Allreduce(tmpCom.getArrayPointer(), com.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); |
1019 |
> |
MPI_Allreduce(tmpComVel.getArrayPointer(), comVel.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); |
1020 |
|
#endif |
1021 |
|
|
1022 |
|
com /= totalMass; |
1028 |
|
|
1029 |
|
|
1030 |
|
[ Ixx -Ixy -Ixz ] |
1031 |
< |
J =| -Iyx Iyy -Iyz | |
1031 |
> |
J =| -Iyx Iyy -Iyz | |
1032 |
|
[ -Izx -Iyz Izz ] |
1033 |
|
*/ |
1034 |
|
|
1035 |
|
void SimInfo::getInertiaTensor(Mat3x3d &inertiaTensor, Vector3d &angularMomentum){ |
1036 |
|
|
1037 |
|
|
1038 |
< |
double xx = 0.0; |
1039 |
< |
double yy = 0.0; |
1040 |
< |
double zz = 0.0; |
1041 |
< |
double xy = 0.0; |
1042 |
< |
double xz = 0.0; |
1043 |
< |
double yz = 0.0; |
1038 |
> |
RealType xx = 0.0; |
1039 |
> |
RealType yy = 0.0; |
1040 |
> |
RealType zz = 0.0; |
1041 |
> |
RealType xy = 0.0; |
1042 |
> |
RealType xz = 0.0; |
1043 |
> |
RealType yz = 0.0; |
1044 |
|
Vector3d com(0.0); |
1045 |
|
Vector3d comVel(0.0); |
1046 |
|
|
1052 |
|
Vector3d thisq(0.0); |
1053 |
|
Vector3d thisv(0.0); |
1054 |
|
|
1055 |
< |
double thisMass = 0.0; |
1055 |
> |
RealType thisMass = 0.0; |
1056 |
|
|
1057 |
|
|
1058 |
|
|
1090 |
|
#ifdef IS_MPI |
1091 |
|
Mat3x3d tmpI(inertiaTensor); |
1092 |
|
Vector3d tmpAngMom; |
1093 |
< |
MPI_Allreduce(tmpI.getArrayPointer(), inertiaTensor.getArrayPointer(),9,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1094 |
< |
MPI_Allreduce(tmpAngMom.getArrayPointer(), angularMomentum.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1093 |
> |
MPI_Allreduce(tmpI.getArrayPointer(), inertiaTensor.getArrayPointer(),9,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); |
1094 |
> |
MPI_Allreduce(tmpAngMom.getArrayPointer(), angularMomentum.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); |
1095 |
|
#endif |
1096 |
|
|
1097 |
|
return; |
1112 |
|
Vector3d thisr(0.0); |
1113 |
|
Vector3d thisp(0.0); |
1114 |
|
|
1115 |
< |
double thisMass; |
1115 |
> |
RealType thisMass; |
1116 |
|
|
1117 |
|
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
1118 |
|
thisMass = mol->getMass(); |
1125 |
|
|
1126 |
|
#ifdef IS_MPI |
1127 |
|
Vector3d tmpAngMom; |
1128 |
< |
MPI_Allreduce(tmpAngMom.getArrayPointer(), angularMomentum.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); |
1128 |
> |
MPI_Allreduce(tmpAngMom.getArrayPointer(), angularMomentum.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); |
1129 |
|
#endif |
1130 |
|
|
1131 |
|
return angularMomentum; |
1132 |
|
} |
1133 |
|
|
1134 |
< |
|
1135 |
< |
}//end namespace oopse |
1134 |
> |
StuntDouble* SimInfo::getIOIndexToIntegrableObject(int index) { |
1135 |
> |
return IOIndexToIntegrableObject.at(index); |
1136 |
> |
} |
1137 |
> |
|
1138 |
> |
void SimInfo::setIOIndexToIntegrableObject(const vector<StuntDouble*>& v) { |
1139 |
> |
IOIndexToIntegrableObject= v; |
1140 |
> |
} |
1141 |
|
|
1142 |
+ |
/* Returns the Volume of the simulation based on a ellipsoid with semi-axes |
1143 |
+ |
based on the radius of gyration V=4/3*Pi*R_1*R_2*R_3 |
1144 |
+ |
where R_i are related to the principle inertia moments R_i = sqrt(C*I_i/N), this reduces to |
1145 |
+ |
V = 4/3*Pi*(C/N)^3/2*sqrt(det(I)). See S.E. Baltazar et. al. Comp. Mat. Sci. 37 (2006) 526-536. |
1146 |
+ |
*/ |
1147 |
+ |
void SimInfo::getGyrationalVolume(RealType &volume){ |
1148 |
+ |
Mat3x3d intTensor; |
1149 |
+ |
RealType det; |
1150 |
+ |
Vector3d dummyAngMom; |
1151 |
+ |
RealType sysconstants; |
1152 |
+ |
RealType geomCnst; |
1153 |
+ |
|
1154 |
+ |
geomCnst = 3.0/2.0; |
1155 |
+ |
/* Get the inertial tensor and angular momentum for free*/ |
1156 |
+ |
getInertiaTensor(intTensor,dummyAngMom); |
1157 |
+ |
|
1158 |
+ |
det = intTensor.determinant(); |
1159 |
+ |
sysconstants = geomCnst/(RealType)nGlobalIntegrableObjects_; |
1160 |
+ |
volume = 4.0/3.0*NumericConstant::PI*pow(sysconstants,3.0/2.0)*sqrt(det); |
1161 |
+ |
return; |
1162 |
+ |
} |
1163 |
+ |
|
1164 |
+ |
void SimInfo::getGyrationalVolume(RealType &volume, RealType &detI){ |
1165 |
+ |
Mat3x3d intTensor; |
1166 |
+ |
Vector3d dummyAngMom; |
1167 |
+ |
RealType sysconstants; |
1168 |
+ |
RealType geomCnst; |
1169 |
+ |
|
1170 |
+ |
geomCnst = 3.0/2.0; |
1171 |
+ |
/* Get the inertial tensor and angular momentum for free*/ |
1172 |
+ |
getInertiaTensor(intTensor,dummyAngMom); |
1173 |
+ |
|
1174 |
+ |
detI = intTensor.determinant(); |
1175 |
+ |
sysconstants = geomCnst/(RealType)nGlobalIntegrableObjects_; |
1176 |
+ |
volume = 4.0/3.0*NumericConstant::PI*pow(sysconstants,3.0/2.0)*sqrt(detI); |
1177 |
+ |
return; |
1178 |
+ |
} |
1179 |
+ |
/* |
1180 |
+ |
void SimInfo::setStuntDoubleFromGlobalIndex(vector<StuntDouble*> v) { |
1181 |
+ |
assert( v.size() == nAtoms_ + nRigidBodies_); |
1182 |
+ |
sdByGlobalIndex_ = v; |
1183 |
+ |
} |
1184 |
+ |
|
1185 |
+ |
StuntDouble* SimInfo::getStuntDoubleFromGlobalIndex(int index) { |
1186 |
+ |
//assert(index < nAtoms_ + nRigidBodies_); |
1187 |
+ |
return sdByGlobalIndex_.at(index); |
1188 |
+ |
} |
1189 |
+ |
*/ |
1190 |
+ |
int SimInfo::getNGlobalConstraints() { |
1191 |
+ |
int nGlobalConstraints; |
1192 |
+ |
#ifdef IS_MPI |
1193 |
+ |
MPI_Allreduce(&nConstraints_, &nGlobalConstraints, 1, MPI_INT, MPI_SUM, |
1194 |
+ |
MPI_COMM_WORLD); |
1195 |
+ |
#else |
1196 |
+ |
nGlobalConstraints = nConstraints_; |
1197 |
+ |
#endif |
1198 |
+ |
return nGlobalConstraints; |
1199 |
+ |
} |
1200 |
+ |
|
1201 |
+ |
}//end namespace OpenMD |
1202 |
+ |
|