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 |
|
/** |
54 |
|
#include "math/Vector3.hpp" |
55 |
|
#include "primitives/Molecule.hpp" |
56 |
|
#include "primitives/StuntDouble.hpp" |
57 |
– |
#include "UseTheForce/fCutoffPolicy.h" |
58 |
– |
#include "UseTheForce/DarkSide/fElectrostaticSummationMethod.h" |
59 |
– |
#include "UseTheForce/DarkSide/fElectrostaticScreeningMethod.h" |
60 |
– |
#include "UseTheForce/DarkSide/fSwitchingFunctionType.h" |
61 |
– |
#include "UseTheForce/doForces_interface.h" |
57 |
|
#include "UseTheForce/DarkSide/neighborLists_interface.h" |
63 |
– |
#include "UseTheForce/DarkSide/electrostatic_interface.h" |
64 |
– |
#include "UseTheForce/DarkSide/switcheroo_interface.h" |
58 |
|
#include "utils/MemoryUtils.hpp" |
59 |
|
#include "utils/simError.h" |
60 |
|
#include "selection/SelectionManager.hpp" |
61 |
|
#include "io/ForceFieldOptions.hpp" |
62 |
|
#include "UseTheForce/ForceField.hpp" |
63 |
+ |
#include "nonbonded/SwitchingFunction.hpp" |
64 |
|
|
71 |
– |
|
65 |
|
#ifdef IS_MPI |
66 |
|
#include "UseTheForce/mpiComponentPlan.h" |
67 |
|
#include "UseTheForce/DarkSide/simParallel_interface.h" |
68 |
|
#endif |
69 |
|
|
70 |
< |
namespace oopse { |
71 |
< |
std::set<int> getRigidSet(int index, std::map<int, std::set<int> >& container) { |
79 |
< |
std::map<int, std::set<int> >::iterator i = container.find(index); |
80 |
< |
std::set<int> result; |
81 |
< |
if (i != container.end()) { |
82 |
< |
result = i->second; |
83 |
< |
} |
84 |
< |
|
85 |
< |
return result; |
86 |
< |
} |
70 |
> |
using namespace std; |
71 |
> |
namespace OpenMD { |
72 |
|
|
73 |
|
SimInfo::SimInfo(ForceField* ff, Globals* simParams) : |
74 |
|
forceField_(ff), simParams_(simParams), |
78 |
|
nAtoms_(0), nBonds_(0), nBends_(0), nTorsions_(0), nInversions_(0), |
79 |
|
nRigidBodies_(0), nIntegrableObjects_(0), nCutoffGroups_(0), |
80 |
|
nConstraints_(0), sman_(NULL), fortranInitialized_(false), |
81 |
< |
calcBoxDipole_(false), useAtomicVirial_(true) { |
82 |
< |
|
83 |
< |
|
84 |
< |
MoleculeStamp* molStamp; |
85 |
< |
int nMolWithSameStamp; |
86 |
< |
int nCutoffAtoms = 0; // number of atoms belong to cutoff groups |
87 |
< |
int nGroups = 0; //total cutoff groups defined in meta-data file |
88 |
< |
CutoffGroupStamp* cgStamp; |
89 |
< |
RigidBodyStamp* rbStamp; |
90 |
< |
int nRigidAtoms = 0; |
91 |
< |
|
92 |
< |
std::vector<Component*> components = simParams->getComponents(); |
81 |
> |
calcBoxDipole_(false), useAtomicVirial_(true) { |
82 |
> |
|
83 |
> |
MoleculeStamp* molStamp; |
84 |
> |
int nMolWithSameStamp; |
85 |
> |
int nCutoffAtoms = 0; // number of atoms belong to cutoff groups |
86 |
> |
int nGroups = 0; //total cutoff groups defined in meta-data file |
87 |
> |
CutoffGroupStamp* cgStamp; |
88 |
> |
RigidBodyStamp* rbStamp; |
89 |
> |
int nRigidAtoms = 0; |
90 |
> |
|
91 |
> |
vector<Component*> components = simParams->getComponents(); |
92 |
> |
|
93 |
> |
for (vector<Component*>::iterator i = components.begin(); i !=components.end(); ++i) { |
94 |
> |
molStamp = (*i)->getMoleculeStamp(); |
95 |
> |
nMolWithSameStamp = (*i)->getNMol(); |
96 |
|
|
97 |
< |
for (std::vector<Component*>::iterator i = components.begin(); i !=components.end(); ++i) { |
98 |
< |
molStamp = (*i)->getMoleculeStamp(); |
99 |
< |
nMolWithSameStamp = (*i)->getNMol(); |
100 |
< |
|
101 |
< |
addMoleculeStamp(molStamp, nMolWithSameStamp); |
102 |
< |
|
103 |
< |
//calculate atoms in molecules |
104 |
< |
nGlobalAtoms_ += molStamp->getNAtoms() *nMolWithSameStamp; |
105 |
< |
|
106 |
< |
//calculate atoms in cutoff groups |
107 |
< |
int nAtomsInGroups = 0; |
108 |
< |
int nCutoffGroupsInStamp = molStamp->getNCutoffGroups(); |
121 |
< |
|
122 |
< |
for (int j=0; j < nCutoffGroupsInStamp; j++) { |
123 |
< |
cgStamp = molStamp->getCutoffGroupStamp(j); |
124 |
< |
nAtomsInGroups += cgStamp->getNMembers(); |
125 |
< |
} |
126 |
< |
|
127 |
< |
nGroups += nCutoffGroupsInStamp * nMolWithSameStamp; |
128 |
< |
|
129 |
< |
nCutoffAtoms += nAtomsInGroups * nMolWithSameStamp; |
130 |
< |
|
131 |
< |
//calculate atoms in rigid bodies |
132 |
< |
int nAtomsInRigidBodies = 0; |
133 |
< |
int nRigidBodiesInStamp = molStamp->getNRigidBodies(); |
134 |
< |
|
135 |
< |
for (int j=0; j < nRigidBodiesInStamp; j++) { |
136 |
< |
rbStamp = molStamp->getRigidBodyStamp(j); |
137 |
< |
nAtomsInRigidBodies += rbStamp->getNMembers(); |
138 |
< |
} |
139 |
< |
|
140 |
< |
nGlobalRigidBodies_ += nRigidBodiesInStamp * nMolWithSameStamp; |
141 |
< |
nRigidAtoms += nAtomsInRigidBodies * nMolWithSameStamp; |
142 |
< |
|
97 |
> |
addMoleculeStamp(molStamp, nMolWithSameStamp); |
98 |
> |
|
99 |
> |
//calculate atoms in molecules |
100 |
> |
nGlobalAtoms_ += molStamp->getNAtoms() *nMolWithSameStamp; |
101 |
> |
|
102 |
> |
//calculate atoms in cutoff groups |
103 |
> |
int nAtomsInGroups = 0; |
104 |
> |
int nCutoffGroupsInStamp = molStamp->getNCutoffGroups(); |
105 |
> |
|
106 |
> |
for (int j=0; j < nCutoffGroupsInStamp; j++) { |
107 |
> |
cgStamp = molStamp->getCutoffGroupStamp(j); |
108 |
> |
nAtomsInGroups += cgStamp->getNMembers(); |
109 |
|
} |
110 |
< |
|
111 |
< |
//every free atom (atom does not belong to cutoff groups) is a cutoff |
112 |
< |
//group therefore the total number of cutoff groups in the system is |
113 |
< |
//equal to the total number of atoms minus number of atoms belong to |
114 |
< |
//cutoff group defined in meta-data file plus the number of cutoff |
115 |
< |
//groups defined in meta-data file |
116 |
< |
nGlobalCutoffGroups_ = nGlobalAtoms_ - nCutoffAtoms + nGroups; |
117 |
< |
|
118 |
< |
//every free atom (atom does not belong to rigid bodies) is an |
119 |
< |
//integrable object therefore the total number of integrable objects |
120 |
< |
//in the system is equal to the total number of atoms minus number of |
121 |
< |
//atoms belong to rigid body defined in meta-data file plus the number |
122 |
< |
//of rigid bodies defined in meta-data file |
123 |
< |
nGlobalIntegrableObjects_ = nGlobalAtoms_ - nRigidAtoms |
124 |
< |
+ nGlobalRigidBodies_; |
125 |
< |
|
126 |
< |
nGlobalMols_ = molStampIds_.size(); |
161 |
< |
molToProcMap_.resize(nGlobalMols_); |
110 |
> |
|
111 |
> |
nGroups += nCutoffGroupsInStamp * nMolWithSameStamp; |
112 |
> |
|
113 |
> |
nCutoffAtoms += nAtomsInGroups * nMolWithSameStamp; |
114 |
> |
|
115 |
> |
//calculate atoms in rigid bodies |
116 |
> |
int nAtomsInRigidBodies = 0; |
117 |
> |
int nRigidBodiesInStamp = molStamp->getNRigidBodies(); |
118 |
> |
|
119 |
> |
for (int j=0; j < nRigidBodiesInStamp; j++) { |
120 |
> |
rbStamp = molStamp->getRigidBodyStamp(j); |
121 |
> |
nAtomsInRigidBodies += rbStamp->getNMembers(); |
122 |
> |
} |
123 |
> |
|
124 |
> |
nGlobalRigidBodies_ += nRigidBodiesInStamp * nMolWithSameStamp; |
125 |
> |
nRigidAtoms += nAtomsInRigidBodies * nMolWithSameStamp; |
126 |
> |
|
127 |
|
} |
128 |
< |
|
128 |
> |
|
129 |
> |
//every free atom (atom does not belong to cutoff groups) is a cutoff |
130 |
> |
//group therefore the total number of cutoff groups in the system is |
131 |
> |
//equal to the total number of atoms minus number of atoms belong to |
132 |
> |
//cutoff group defined in meta-data file plus the number of cutoff |
133 |
> |
//groups defined in meta-data file |
134 |
> |
nGlobalCutoffGroups_ = nGlobalAtoms_ - nCutoffAtoms + nGroups; |
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 |
|
} |
157 |
|
delete forceField_; |
158 |
|
} |
159 |
|
|
176 |
– |
int SimInfo::getNGlobalConstraints() { |
177 |
– |
int nGlobalConstraints; |
178 |
– |
#ifdef IS_MPI |
179 |
– |
MPI_Allreduce(&nConstraints_, &nGlobalConstraints, 1, MPI_INT, MPI_SUM, |
180 |
– |
MPI_COMM_WORLD); |
181 |
– |
#else |
182 |
– |
nGlobalConstraints = nConstraints_; |
183 |
– |
#endif |
184 |
– |
return nGlobalConstraints; |
185 |
– |
} |
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(); |
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()); |
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 |
|
} |
240 |
– |
|
241 |
– |
|
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 |
|
|
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; |
333 |
< |
std::vector<Inversion*>::iterator inversionIter; |
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; |
341 |
|
int c; |
342 |
|
int d; |
343 |
|
|
344 |
< |
std::map<int, std::set<int> > atomGroups; |
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 (integrableObject = mol->beginIntegrableObject(ii); integrableObject != NULL; |
359 |
< |
integrableObject = mol->nextIntegrableObject(ii)) { |
360 |
< |
|
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 |
< |
std::vector<Atom*> atoms = rb->getAtoms(); |
365 |
< |
std::set<int> rigidAtoms; |
366 |
< |
for (int i = 0; i < atoms.size(); ++i) { |
367 |
< |
rigidAtoms.insert(atoms[i]->getGlobalIndex()); |
368 |
< |
} |
369 |
< |
for (int i = 0; i < atoms.size(); ++i) { |
370 |
< |
atomGroups.insert(std::map<int, std::set<int> >::value_type(atoms[i]->getGlobalIndex(), rigidAtoms)); |
371 |
< |
} |
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 |
< |
std::set<int> oneAtomSet; |
373 |
> |
set<int> oneAtomSet; |
374 |
|
oneAtomSet.insert(integrableObject->getGlobalIndex()); |
375 |
< |
atomGroups.insert(std::map<int, std::set<int> >::value_type(integrableObject->getGlobalIndex(), oneAtomSet)); |
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 |
|
|
398 |
– |
|
399 |
– |
|
400 |
– |
for (bond= mol->beginBond(bondIter); bond != NULL; bond = mol->nextBond(bondIter)) { |
382 |
|
a = bond->getAtomA()->getGlobalIndex(); |
383 |
< |
b = bond->getAtomB()->getGlobalIndex(); |
384 |
< |
exclude_.addPair(a, b); |
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(); |
410 |
– |
std::set<int> rigidSetA = getRigidSet(a, atomGroups); |
411 |
– |
std::set<int> rigidSetB = getRigidSet(b, atomGroups); |
412 |
– |
std::set<int> rigidSetC = getRigidSet(c, atomGroups); |
413 |
– |
|
414 |
– |
exclude_.addPairs(rigidSetA, rigidSetB); |
415 |
– |
exclude_.addPairs(rigidSetA, rigidSetC); |
416 |
– |
exclude_.addPairs(rigidSetB, rigidSetC); |
398 |
|
|
399 |
< |
//exclude_.addPair(a, b); |
400 |
< |
//exclude_.addPair(a, c); |
401 |
< |
//exclude_.addPair(b, c); |
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)) { |
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(); |
428 |
< |
std::set<int> rigidSetA = getRigidSet(a, atomGroups); |
429 |
< |
std::set<int> rigidSetB = getRigidSet(b, atomGroups); |
430 |
< |
std::set<int> rigidSetC = getRigidSet(c, atomGroups); |
431 |
< |
std::set<int> rigidSetD = getRigidSet(d, atomGroups); |
420 |
> |
d = torsion->getAtomD()->getGlobalIndex(); |
421 |
|
|
422 |
< |
exclude_.addPairs(rigidSetA, rigidSetB); |
423 |
< |
exclude_.addPairs(rigidSetA, rigidSetC); |
424 |
< |
exclude_.addPairs(rigidSetA, rigidSetD); |
425 |
< |
exclude_.addPairs(rigidSetB, rigidSetC); |
426 |
< |
exclude_.addPairs(rigidSetB, rigidSetD); |
427 |
< |
exclude_.addPairs(rigidSetC, rigidSetD); |
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 |
< |
/* |
433 |
< |
exclude_.addPairs(rigidSetA.begin(), rigidSetA.end(), rigidSetB.begin(), rigidSetB.end()); |
434 |
< |
exclude_.addPairs(rigidSetA.begin(), rigidSetA.end(), rigidSetC.begin(), rigidSetC.end()); |
435 |
< |
exclude_.addPairs(rigidSetA.begin(), rigidSetA.end(), rigidSetD.begin(), rigidSetD.end()); |
436 |
< |
exclude_.addPairs(rigidSetB.begin(), rigidSetB.end(), rigidSetC.begin(), rigidSetC.end()); |
437 |
< |
exclude_.addPairs(rigidSetB.begin(), rigidSetB.end(), rigidSetD.begin(), rigidSetD.end()); |
438 |
< |
exclude_.addPairs(rigidSetC.begin(), rigidSetC.end(), rigidSetD.begin(), rigidSetD.end()); |
439 |
< |
|
440 |
< |
|
441 |
< |
exclude_.addPair(a, b); |
442 |
< |
exclude_.addPair(a, c); |
443 |
< |
exclude_.addPair(a, d); |
444 |
< |
exclude_.addPair(b, c); |
453 |
< |
exclude_.addPair(b, d); |
454 |
< |
exclude_.addPair(c, d); |
455 |
< |
*/ |
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 |
|
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(); |
464 |
– |
std::set<int> rigidSetA = getRigidSet(a, atomGroups); |
465 |
– |
std::set<int> rigidSetB = getRigidSet(b, atomGroups); |
466 |
– |
std::set<int> rigidSetC = getRigidSet(c, atomGroups); |
467 |
– |
std::set<int> rigidSetD = getRigidSet(d, atomGroups); |
454 |
|
|
455 |
< |
exclude_.addPairs(rigidSetA, rigidSetB); |
456 |
< |
exclude_.addPairs(rigidSetA, rigidSetC); |
457 |
< |
exclude_.addPairs(rigidSetA, rigidSetD); |
458 |
< |
exclude_.addPairs(rigidSetB, rigidSetC); |
459 |
< |
exclude_.addPairs(rigidSetB, rigidSetD); |
460 |
< |
exclude_.addPairs(rigidSetC, rigidSetD); |
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 |
< |
/* |
466 |
< |
exclude_.addPairs(rigidSetA.begin(), rigidSetA.end(), rigidSetB.begin(), rigidSetB.end()); |
467 |
< |
exclude_.addPairs(rigidSetA.begin(), rigidSetA.end(), rigidSetC.begin(), rigidSetC.end()); |
468 |
< |
exclude_.addPairs(rigidSetA.begin(), rigidSetA.end(), rigidSetD.begin(), rigidSetD.end()); |
469 |
< |
exclude_.addPairs(rigidSetB.begin(), rigidSetB.end(), rigidSetC.begin(), rigidSetC.end()); |
470 |
< |
exclude_.addPairs(rigidSetB.begin(), rigidSetB.end(), rigidSetD.begin(), rigidSetD.end()); |
471 |
< |
exclude_.addPairs(rigidSetC.begin(), rigidSetC.end(), rigidSetD.begin(), rigidSetD.end()); |
472 |
< |
|
473 |
< |
|
485 |
< |
exclude_.addPair(a, b); |
486 |
< |
exclude_.addPair(a, c); |
487 |
< |
exclude_.addPair(a, d); |
488 |
< |
exclude_.addPair(b, c); |
489 |
< |
exclude_.addPair(b, d); |
490 |
< |
exclude_.addPair(c, d); |
491 |
< |
*/ |
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; rb = mol->nextRigidBody(rbIter)) { |
477 |
< |
std::vector<Atom*> atoms = rb->getAtoms(); |
478 |
< |
for (int i = 0; i < atoms.size() -1 ; ++i) { |
479 |
< |
for (int j = i + 1; j < atoms.size(); ++j) { |
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; |
494 |
< |
std::vector<Inversion*>::iterator inversionIter; |
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; |
502 |
|
int c; |
503 |
|
int d; |
504 |
|
|
505 |
< |
std::map<int, std::set<int> > atomGroups; |
522 |
< |
|
505 |
> |
map<int, set<int> > atomGroups; |
506 |
|
Molecule::RigidBodyIterator rbIter; |
507 |
|
RigidBody* rb; |
508 |
|
Molecule::IntegrableObjectIterator ii; |
509 |
|
StuntDouble* integrableObject; |
510 |
|
|
511 |
< |
for (integrableObject = mol->beginIntegrableObject(ii); integrableObject != NULL; |
512 |
< |
integrableObject = mol->nextIntegrableObject(ii)) { |
513 |
< |
|
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 |
< |
std::vector<Atom*> atoms = rb->getAtoms(); |
518 |
< |
std::set<int> rigidAtoms; |
519 |
< |
for (int i = 0; i < atoms.size(); ++i) { |
520 |
< |
rigidAtoms.insert(atoms[i]->getGlobalIndex()); |
521 |
< |
} |
522 |
< |
for (int i = 0; i < atoms.size(); ++i) { |
523 |
< |
atomGroups.insert(std::map<int, std::set<int> >::value_type(atoms[i]->getGlobalIndex(), rigidAtoms)); |
524 |
< |
} |
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 |
< |
std::set<int> oneAtomSet; |
526 |
> |
set<int> oneAtomSet; |
527 |
|
oneAtomSet.insert(integrableObject->getGlobalIndex()); |
528 |
< |
atomGroups.insert(std::map<int, std::set<int> >::value_type(integrableObject->getGlobalIndex(), oneAtomSet)); |
528 |
> |
atomGroups.insert(map<int, set<int> >::value_type(integrableObject->getGlobalIndex(), oneAtomSet)); |
529 |
|
} |
530 |
|
} |
531 |
|
|
532 |
< |
|
533 |
< |
for (bond= mol->beginBond(bondIter); bond != NULL; bond = mol->nextBond(bondIter)) { |
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(); |
559 |
– |
|
560 |
– |
std::set<int> rigidSetA = getRigidSet(a, atomGroups); |
561 |
– |
std::set<int> rigidSetB = getRigidSet(b, atomGroups); |
562 |
– |
std::set<int> rigidSetC = getRigidSet(c, atomGroups); |
563 |
– |
|
564 |
– |
exclude_.removePairs(rigidSetA, rigidSetB); |
565 |
– |
exclude_.removePairs(rigidSetA, rigidSetC); |
566 |
– |
exclude_.removePairs(rigidSetB, rigidSetC); |
551 |
|
|
552 |
< |
//exclude_.removePair(a, b); |
553 |
< |
//exclude_.removePair(a, c); |
554 |
< |
//exclude_.removePair(b, c); |
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)) { |
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 |
< |
std::set<int> rigidSetA = getRigidSet(a, atomGroups); |
586 |
< |
std::set<int> rigidSetB = getRigidSet(b, atomGroups); |
587 |
< |
std::set<int> rigidSetC = getRigidSet(c, atomGroups); |
588 |
< |
std::set<int> rigidSetD = getRigidSet(d, atomGroups); |
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 |
< |
exclude_.removePairs(rigidSetA, rigidSetB); |
594 |
< |
exclude_.removePairs(rigidSetA, rigidSetC); |
595 |
< |
exclude_.removePairs(rigidSetA, rigidSetD); |
596 |
< |
exclude_.removePairs(rigidSetB, rigidSetC); |
597 |
< |
exclude_.removePairs(rigidSetB, rigidSetD); |
589 |
< |
exclude_.removePairs(rigidSetC, rigidSetD); |
590 |
< |
|
591 |
< |
/* |
592 |
< |
exclude_.removePairs(rigidSetA.begin(), rigidSetA.end(), rigidSetB.begin(), rigidSetB.end()); |
593 |
< |
exclude_.removePairs(rigidSetA.begin(), rigidSetA.end(), rigidSetC.begin(), rigidSetC.end()); |
594 |
< |
exclude_.removePairs(rigidSetA.begin(), rigidSetA.end(), rigidSetD.begin(), rigidSetD.end()); |
595 |
< |
exclude_.removePairs(rigidSetB.begin(), rigidSetB.end(), rigidSetC.begin(), rigidSetC.end()); |
596 |
< |
exclude_.removePairs(rigidSetB.begin(), rigidSetB.end(), rigidSetD.begin(), rigidSetD.end()); |
597 |
< |
exclude_.removePairs(rigidSetC.begin(), rigidSetC.end(), rigidSetD.begin(), rigidSetD.end()); |
598 |
< |
|
599 |
< |
|
600 |
< |
exclude_.removePair(a, b); |
601 |
< |
exclude_.removePair(a, c); |
602 |
< |
exclude_.removePair(a, d); |
603 |
< |
exclude_.removePair(b, c); |
604 |
< |
exclude_.removePair(b, d); |
605 |
< |
exclude_.removePair(c, d); |
606 |
< |
*/ |
593 |
> |
if (options_.havevdw14scale() || options_.haveelectrostatic14scale()) { |
594 |
> |
oneFourInteractions_.removePair(a, d); |
595 |
> |
} else { |
596 |
> |
excludedInteractions_.removePair(a, d); |
597 |
> |
} |
598 |
|
} |
599 |
|
|
600 |
< |
for (inversion= mol->beginInversion(inversionIter); inversion != NULL; inversion = mol->nextInversion(inversionIter)) { |
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 |
< |
std::set<int> rigidSetA = getRigidSet(a, atomGroups); |
609 |
< |
std::set<int> rigidSetB = getRigidSet(b, atomGroups); |
610 |
< |
std::set<int> rigidSetC = getRigidSet(c, atomGroups); |
611 |
< |
std::set<int> rigidSetD = getRigidSet(d, atomGroups); |
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 |
< |
exclude_.removePairs(rigidSetA, rigidSetB); |
619 |
< |
exclude_.removePairs(rigidSetA, rigidSetC); |
620 |
< |
exclude_.removePairs(rigidSetA, rigidSetD); |
621 |
< |
exclude_.removePairs(rigidSetB, rigidSetC); |
622 |
< |
exclude_.removePairs(rigidSetB, rigidSetD); |
623 |
< |
exclude_.removePairs(rigidSetC, rigidSetD); |
624 |
< |
|
625 |
< |
/* |
626 |
< |
exclude_.removePairs(rigidSetA.begin(), rigidSetA.end(), rigidSetB.begin(), rigidSetB.end()); |
629 |
< |
exclude_.removePairs(rigidSetA.begin(), rigidSetA.end(), rigidSetC.begin(), rigidSetC.end()); |
630 |
< |
exclude_.removePairs(rigidSetA.begin(), rigidSetA.end(), rigidSetD.begin(), rigidSetD.end()); |
631 |
< |
exclude_.removePairs(rigidSetB.begin(), rigidSetB.end(), rigidSetC.begin(), rigidSetC.end()); |
632 |
< |
exclude_.removePairs(rigidSetB.begin(), rigidSetB.end(), rigidSetD.begin(), rigidSetD.end()); |
633 |
< |
exclude_.removePairs(rigidSetC.begin(), rigidSetC.end(), rigidSetD.begin(), rigidSetD.end()); |
634 |
< |
|
635 |
< |
|
636 |
< |
exclude_.removePair(a, b); |
637 |
< |
exclude_.removePair(a, c); |
638 |
< |
exclude_.removePair(a, d); |
639 |
< |
exclude_.removePair(b, c); |
640 |
< |
exclude_.removePair(b, d); |
641 |
< |
exclude_.removePair(c, d); |
642 |
< |
*/ |
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; rb = mol->nextRigidBody(rbIter)) { |
630 |
< |
std::vector<Atom*> atoms = rb->getAtoms(); |
631 |
< |
for (int i = 0; i < atoms.size() -1 ; ++i) { |
632 |
< |
for (int j = i + 1; j < atoms.size(); ++j) { |
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 |
|
|
669 |
– |
void SimInfo::update() { |
654 |
|
|
655 |
< |
setupSimType(); |
656 |
< |
|
657 |
< |
#ifdef IS_MPI |
658 |
< |
setupFortranParallel(); |
659 |
< |
#endif |
660 |
< |
|
661 |
< |
setupFortranSim(); |
662 |
< |
|
663 |
< |
//setup fortran force field |
680 |
< |
/** @deprecate */ |
681 |
< |
int isError = 0; |
682 |
< |
|
683 |
< |
setupCutoff(); |
684 |
< |
|
685 |
< |
setupElectrostaticSummationMethod( isError ); |
686 |
< |
setupSwitchingFunction(); |
687 |
< |
setupAccumulateBoxDipole(); |
688 |
< |
|
689 |
< |
if(isError){ |
690 |
< |
sprintf( painCave.errMsg, |
691 |
< |
"ForceField error: There was an error initializing the forceField in fortran.\n" ); |
692 |
< |
painCave.isFatal = 1; |
693 |
< |
simError(); |
694 |
< |
} |
695 |
< |
|
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(); |
699 |
– |
|
700 |
– |
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)) { |
711 |
< |
|
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 |
< |
|
716 |
< |
} |
686 |
> |
} |
687 |
> |
} |
688 |
|
|
689 |
< |
return atomTypes; |
719 |
< |
} |
689 |
> |
#ifdef IS_MPI |
690 |
|
|
691 |
< |
void SimInfo::setupSimType() { |
692 |
< |
std::set<AtomType*>::iterator i; |
723 |
< |
std::set<AtomType*> atomTypes; |
724 |
< |
atomTypes = getUniqueAtomTypes(); |
725 |
< |
|
726 |
< |
int useLennardJones = 0; |
727 |
< |
int useElectrostatic = 0; |
728 |
< |
int useEAM = 0; |
729 |
< |
int useSC = 0; |
730 |
< |
int useCharge = 0; |
731 |
< |
int useDirectional = 0; |
732 |
< |
int useDipole = 0; |
733 |
< |
int useGayBerne = 0; |
734 |
< |
int useSticky = 0; |
735 |
< |
int useStickyPower = 0; |
736 |
< |
int useShape = 0; |
737 |
< |
int useFLARB = 0; //it is not in AtomType yet |
738 |
< |
int useDirectionalAtom = 0; |
739 |
< |
int useElectrostatics = 0; |
740 |
< |
//usePBC and useRF are from simParams |
741 |
< |
int usePBC = simParams_->getUsePeriodicBoundaryConditions(); |
742 |
< |
int useRF; |
743 |
< |
int useSF; |
744 |
< |
int useSP; |
745 |
< |
int useBoxDipole; |
691 |
> |
// loop over the found atom types on this processor, and add their |
692 |
> |
// numerical idents to a vector: |
693 |
|
|
694 |
< |
std::string myMethod; |
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 |
< |
// set the useRF logical |
700 |
< |
useRF = 0; |
751 |
< |
useSF = 0; |
752 |
< |
useSP = 0; |
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 |
< |
if (simParams_->haveElectrostaticSummationMethod()) { |
708 |
< |
std::string myMethod = simParams_->getElectrostaticSummationMethod(); |
709 |
< |
toUpper(myMethod); |
710 |
< |
if (myMethod == "REACTION_FIELD"){ |
711 |
< |
useRF = 1; |
712 |
< |
} else if (myMethod == "SHIFTED_FORCE"){ |
713 |
< |
useSF = 1; |
714 |
< |
} else if (myMethod == "SHIFTED_POTENTIAL"){ |
715 |
< |
useSP = 1; |
716 |
< |
} |
717 |
< |
} |
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 |
< |
if (simParams_->haveAccumulateBoxDipole()) |
720 |
< |
if (simParams_->getAccumulateBoxDipole()) |
769 |
< |
useBoxDipole = 1; |
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(); |
778 |
< |
useSC |= (*i)->isSC(); |
779 |
< |
useCharge |= (*i)->isCharge(); |
780 |
< |
useDirectional |= (*i)->isDirectional(); |
781 |
< |
useDipole |= (*i)->isDipole(); |
782 |
< |
useGayBerne |= (*i)->isGayBerne(); |
783 |
< |
useSticky |= (*i)->isSticky(); |
784 |
< |
useStickyPower |= (*i)->isStickyPower(); |
785 |
< |
useShape |= (*i)->isShape(); |
786 |
< |
} |
787 |
< |
|
788 |
< |
if (useSticky || useStickyPower || useDipole || useGayBerne || useShape) { |
789 |
< |
useDirectionalAtom = 1; |
790 |
< |
} |
791 |
< |
|
792 |
< |
if (useCharge || useDipole) { |
793 |
< |
useElectrostatics = 1; |
757 |
> |
usesElectrostatic |= (*i)->isElectrostatic(); |
758 |
> |
usesMetallic |= (*i)->isMetal(); |
759 |
> |
usesDirectional |= (*i)->isDirectional(); |
760 |
|
} |
761 |
|
|
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); |
804 |
< |
|
805 |
< |
temp = useLennardJones; |
806 |
< |
MPI_Allreduce(&temp, &useLennardJones, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
807 |
< |
|
808 |
< |
temp = useElectrostatics; |
809 |
< |
MPI_Allreduce(&temp, &useElectrostatics, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
810 |
< |
|
811 |
< |
temp = useCharge; |
812 |
< |
MPI_Allreduce(&temp, &useCharge, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
813 |
< |
|
814 |
< |
temp = useDipole; |
815 |
< |
MPI_Allreduce(&temp, &useDipole, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
816 |
< |
|
817 |
< |
temp = useSticky; |
818 |
< |
MPI_Allreduce(&temp, &useSticky, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
819 |
< |
|
820 |
< |
temp = useStickyPower; |
821 |
< |
MPI_Allreduce(&temp, &useStickyPower, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
822 |
< |
|
823 |
< |
temp = useGayBerne; |
824 |
< |
MPI_Allreduce(&temp, &useGayBerne, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
825 |
< |
|
826 |
< |
temp = useEAM; |
827 |
< |
MPI_Allreduce(&temp, &useEAM, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
828 |
< |
|
829 |
< |
temp = useSC; |
830 |
< |
MPI_Allreduce(&temp, &useSC, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
831 |
< |
|
832 |
< |
temp = useShape; |
833 |
< |
MPI_Allreduce(&temp, &useShape, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
834 |
< |
|
835 |
< |
temp = useFLARB; |
836 |
< |
MPI_Allreduce(&temp, &useFLARB, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
837 |
< |
|
838 |
< |
temp = useRF; |
839 |
< |
MPI_Allreduce(&temp, &useRF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
840 |
< |
|
841 |
< |
temp = useSF; |
842 |
< |
MPI_Allreduce(&temp, &useSF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
843 |
< |
|
844 |
< |
temp = useSP; |
845 |
< |
MPI_Allreduce(&temp, &useSP, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
846 |
< |
|
847 |
< |
temp = useBoxDipole; |
848 |
< |
MPI_Allreduce(&temp, &useBoxDipole, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
849 |
< |
|
850 |
< |
temp = useAtomicVirial_; |
851 |
< |
MPI_Allreduce(&temp, &useAtomicVirial_, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
852 |
< |
|
770 |
> |
temp = usesElectrostatic; |
771 |
> |
MPI_Allreduce(&temp, &usesElectrostaticAtoms_, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
772 |
|
#endif |
773 |
< |
|
774 |
< |
fInfo_.SIM_uses_PBC = usePBC; |
775 |
< |
fInfo_.SIM_uses_DirectionalAtoms = useDirectionalAtom; |
776 |
< |
fInfo_.SIM_uses_LennardJones = useLennardJones; |
777 |
< |
fInfo_.SIM_uses_Electrostatics = useElectrostatics; |
778 |
< |
fInfo_.SIM_uses_Charges = useCharge; |
860 |
< |
fInfo_.SIM_uses_Dipoles = useDipole; |
861 |
< |
fInfo_.SIM_uses_Sticky = useSticky; |
862 |
< |
fInfo_.SIM_uses_StickyPower = useStickyPower; |
863 |
< |
fInfo_.SIM_uses_GayBerne = useGayBerne; |
864 |
< |
fInfo_.SIM_uses_EAM = useEAM; |
865 |
< |
fInfo_.SIM_uses_SC = useSC; |
866 |
< |
fInfo_.SIM_uses_Shapes = useShape; |
867 |
< |
fInfo_.SIM_uses_FLARB = useFLARB; |
868 |
< |
fInfo_.SIM_uses_RF = useRF; |
869 |
< |
fInfo_.SIM_uses_SF = useSF; |
870 |
< |
fInfo_.SIM_uses_SP = useSP; |
871 |
< |
fInfo_.SIM_uses_BoxDipole = useBoxDipole; |
872 |
< |
fInfo_.SIM_uses_AtomicVirial = useAtomicVirial_; |
773 |
> |
fInfo_.SIM_uses_PBC = usesPeriodicBoundaries_; |
774 |
> |
fInfo_.SIM_uses_DirectionalAtoms = usesDirectionalAtoms_; |
775 |
> |
fInfo_.SIM_uses_MetallicAtoms = usesMetallicAtoms_; |
776 |
> |
fInfo_.SIM_requires_SkipCorrection = usesElectrostaticAtoms_; |
777 |
> |
fInfo_.SIM_requires_SelfCorrection = usesElectrostaticAtoms_; |
778 |
> |
fInfo_.SIM_uses_AtomicVirial = usesAtomicVirial_; |
779 |
|
} |
780 |
|
|
781 |
< |
void SimInfo::setupFortranSim() { |
781 |
> |
void SimInfo::setupFortran() { |
782 |
|
int isError; |
783 |
< |
int nExclude; |
784 |
< |
std::vector<int> fortranGlobalGroupMembership; |
783 |
> |
int nExclude, nOneTwo, nOneThree, nOneFour; |
784 |
> |
vector<int> fortranGlobalGroupMembership; |
785 |
|
|
880 |
– |
nExclude = exclude_.getSize(); |
786 |
|
isError = 0; |
787 |
|
|
788 |
|
//globalGroupMembership_ is filled by SimCreator |
791 |
|
} |
792 |
|
|
793 |
|
//calculate mass ratio of cutoff group |
794 |
< |
std::vector<RealType> mfact; |
794 |
> |
vector<RealType> mfact; |
795 |
|
SimInfo::MoleculeIterator mi; |
796 |
|
Molecule* mol; |
797 |
|
Molecule::CutoffGroupIterator ci; |
814 |
|
else |
815 |
|
mfact.push_back( 1.0 ); |
816 |
|
} |
912 |
– |
|
817 |
|
} |
818 |
|
} |
819 |
|
|
820 |
< |
//fill ident array of local atoms (it is actually ident of AtomType, it is so confusing !!!) |
821 |
< |
std::vector<int> identArray; |
820 |
> |
//fill ident array of local atoms (it is actually ident of |
821 |
> |
//AtomType, it is so confusing !!!) |
822 |
> |
vector<int> identArray; |
823 |
|
|
824 |
|
//to avoid memory reallocation, reserve enough space identArray |
825 |
|
identArray.reserve(getNAtoms()); |
832 |
|
|
833 |
|
//fill molMembershipArray |
834 |
|
//molMembershipArray is filled by SimCreator |
835 |
< |
std::vector<int> molMembershipArray(nGlobalAtoms_); |
835 |
> |
vector<int> molMembershipArray(nGlobalAtoms_); |
836 |
|
for (int i = 0; i < nGlobalAtoms_; i++) { |
837 |
|
molMembershipArray[i] = globalMolMembership_[i] + 1; |
838 |
|
} |
839 |
|
|
840 |
|
//setup fortran simulation |
841 |
< |
int nGlobalExcludes = 0; |
842 |
< |
int* globalExcludes = NULL; |
843 |
< |
int* excludeList = exclude_.getExcludeList(); |
841 |
> |
|
842 |
> |
nExclude = excludedInteractions_.getSize(); |
843 |
> |
nOneTwo = oneTwoInteractions_.getSize(); |
844 |
> |
nOneThree = oneThreeInteractions_.getSize(); |
845 |
> |
nOneFour = oneFourInteractions_.getSize(); |
846 |
> |
|
847 |
> |
int* excludeList = excludedInteractions_.getPairList(); |
848 |
> |
int* oneTwoList = oneTwoInteractions_.getPairList(); |
849 |
> |
int* oneThreeList = oneThreeInteractions_.getPairList(); |
850 |
> |
int* oneFourList = oneFourInteractions_.getPairList(); |
851 |
> |
|
852 |
|
setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray[0], |
853 |
< |
&nExclude, excludeList , &nGlobalExcludes, globalExcludes, |
853 |
> |
&nExclude, excludeList, |
854 |
> |
&nOneTwo, oneTwoList, |
855 |
> |
&nOneThree, oneThreeList, |
856 |
> |
&nOneFour, oneFourList, |
857 |
|
&molMembershipArray[0], &mfact[0], &nCutoffGroups_, |
858 |
|
&fortranGlobalGroupMembership[0], &isError); |
859 |
|
|
862 |
|
sprintf( painCave.errMsg, |
863 |
|
"There was an error setting the simulation information in fortran.\n" ); |
864 |
|
painCave.isFatal = 1; |
865 |
< |
painCave.severity = OOPSE_ERROR; |
865 |
> |
painCave.severity = OPENMD_ERROR; |
866 |
|
simError(); |
867 |
|
} |
868 |
|
|
878 |
|
setNeighbors(&nlistNeighbors); |
879 |
|
} |
880 |
|
|
965 |
– |
|
966 |
– |
} |
967 |
– |
|
968 |
– |
|
969 |
– |
void SimInfo::setupFortranParallel() { |
881 |
|
#ifdef IS_MPI |
882 |
< |
//SimInfo is responsible for creating localToGlobalAtomIndex and localToGlobalGroupIndex |
883 |
< |
std::vector<int> localToGlobalAtomIndex(getNAtoms(), 0); |
884 |
< |
std::vector<int> localToGlobalCutoffGroupIndex; |
885 |
< |
SimInfo::MoleculeIterator mi; |
975 |
< |
Molecule::AtomIterator ai; |
976 |
< |
Molecule::CutoffGroupIterator ci; |
977 |
< |
Molecule* mol; |
978 |
< |
Atom* atom; |
979 |
< |
CutoffGroup* cg; |
882 |
> |
//SimInfo is responsible for creating localToGlobalAtomIndex and |
883 |
> |
//localToGlobalGroupIndex |
884 |
> |
vector<int> localToGlobalAtomIndex(getNAtoms(), 0); |
885 |
> |
vector<int> localToGlobalCutoffGroupIndex; |
886 |
|
mpiSimData parallelData; |
981 |
– |
int isError; |
887 |
|
|
888 |
|
for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
889 |
|
|
923 |
|
|
924 |
|
sprintf(checkPointMsg, " mpiRefresh successful.\n"); |
925 |
|
errorCheckPoint(); |
1021 |
– |
|
926 |
|
#endif |
927 |
< |
} |
1024 |
< |
|
1025 |
< |
void SimInfo::setupCutoff() { |
1026 |
< |
|
1027 |
< |
ForceFieldOptions& forceFieldOptions_ = forceField_->getForceFieldOptions(); |
1028 |
< |
|
1029 |
< |
// Check the cutoff policy |
1030 |
< |
int cp = TRADITIONAL_CUTOFF_POLICY; // Set to traditional by default |
1031 |
< |
|
1032 |
< |
// Set LJ shifting bools to false |
1033 |
< |
ljsp_ = false; |
1034 |
< |
ljsf_ = false; |
1035 |
< |
|
1036 |
< |
std::string myPolicy; |
1037 |
< |
if (forceFieldOptions_.haveCutoffPolicy()){ |
1038 |
< |
myPolicy = forceFieldOptions_.getCutoffPolicy(); |
1039 |
< |
}else if (simParams_->haveCutoffPolicy()) { |
1040 |
< |
myPolicy = simParams_->getCutoffPolicy(); |
1041 |
< |
} |
1042 |
< |
|
1043 |
< |
if (!myPolicy.empty()){ |
1044 |
< |
toUpper(myPolicy); |
1045 |
< |
if (myPolicy == "MIX") { |
1046 |
< |
cp = MIX_CUTOFF_POLICY; |
1047 |
< |
} else { |
1048 |
< |
if (myPolicy == "MAX") { |
1049 |
< |
cp = MAX_CUTOFF_POLICY; |
1050 |
< |
} else { |
1051 |
< |
if (myPolicy == "TRADITIONAL") { |
1052 |
< |
cp = TRADITIONAL_CUTOFF_POLICY; |
1053 |
< |
} else { |
1054 |
< |
// throw error |
1055 |
< |
sprintf( painCave.errMsg, |
1056 |
< |
"SimInfo error: Unknown cutoffPolicy. (Input file specified %s .)\n\tcutoffPolicy must be one of: \"Mix\", \"Max\", or \"Traditional\".", myPolicy.c_str() ); |
1057 |
< |
painCave.isFatal = 1; |
1058 |
< |
simError(); |
1059 |
< |
} |
1060 |
< |
} |
1061 |
< |
} |
1062 |
< |
} |
1063 |
< |
notifyFortranCutoffPolicy(&cp); |
1064 |
< |
|
1065 |
< |
// Check the Skin Thickness for neighborlists |
1066 |
< |
RealType skin; |
1067 |
< |
if (simParams_->haveSkinThickness()) { |
1068 |
< |
skin = simParams_->getSkinThickness(); |
1069 |
< |
notifyFortranSkinThickness(&skin); |
1070 |
< |
} |
1071 |
< |
|
1072 |
< |
// Check if the cutoff was set explicitly: |
1073 |
< |
if (simParams_->haveCutoffRadius()) { |
1074 |
< |
rcut_ = simParams_->getCutoffRadius(); |
1075 |
< |
if (simParams_->haveSwitchingRadius()) { |
1076 |
< |
rsw_ = simParams_->getSwitchingRadius(); |
1077 |
< |
} else { |
1078 |
< |
if (fInfo_.SIM_uses_Charges | |
1079 |
< |
fInfo_.SIM_uses_Dipoles | |
1080 |
< |
fInfo_.SIM_uses_RF) { |
1081 |
< |
|
1082 |
< |
rsw_ = 0.85 * rcut_; |
1083 |
< |
sprintf(painCave.errMsg, |
1084 |
< |
"SimCreator Warning: No value was set for the switchingRadius.\n" |
1085 |
< |
"\tOOPSE will use a default value of 85 percent of the cutoffRadius.\n" |
1086 |
< |
"\tswitchingRadius = %f. for this simulation\n", rsw_); |
1087 |
< |
painCave.isFatal = 0; |
1088 |
< |
simError(); |
1089 |
< |
} else { |
1090 |
< |
rsw_ = rcut_; |
1091 |
< |
sprintf(painCave.errMsg, |
1092 |
< |
"SimCreator Warning: No value was set for the switchingRadius.\n" |
1093 |
< |
"\tOOPSE will use the same value as the cutoffRadius.\n" |
1094 |
< |
"\tswitchingRadius = %f. for this simulation\n", rsw_); |
1095 |
< |
painCave.isFatal = 0; |
1096 |
< |
simError(); |
1097 |
< |
} |
1098 |
< |
} |
1099 |
< |
|
1100 |
< |
if (simParams_->haveElectrostaticSummationMethod()) { |
1101 |
< |
std::string myMethod = simParams_->getElectrostaticSummationMethod(); |
1102 |
< |
toUpper(myMethod); |
1103 |
< |
|
1104 |
< |
if (myMethod == "SHIFTED_POTENTIAL") { |
1105 |
< |
ljsp_ = true; |
1106 |
< |
} else if (myMethod == "SHIFTED_FORCE") { |
1107 |
< |
ljsf_ = true; |
1108 |
< |
} |
1109 |
< |
} |
1110 |
< |
notifyFortranCutoffs(&rcut_, &rsw_, &ljsp_, &ljsf_); |
1111 |
< |
|
1112 |
< |
} else { |
1113 |
< |
|
1114 |
< |
// For electrostatic atoms, we'll assume a large safe value: |
1115 |
< |
if (fInfo_.SIM_uses_Charges | fInfo_.SIM_uses_Dipoles | fInfo_.SIM_uses_RF) { |
1116 |
< |
sprintf(painCave.errMsg, |
1117 |
< |
"SimCreator Warning: No value was set for the cutoffRadius.\n" |
1118 |
< |
"\tOOPSE will use a default value of 15.0 angstroms" |
1119 |
< |
"\tfor the cutoffRadius.\n"); |
1120 |
< |
painCave.isFatal = 0; |
1121 |
< |
simError(); |
1122 |
< |
rcut_ = 15.0; |
1123 |
< |
|
1124 |
< |
if (simParams_->haveElectrostaticSummationMethod()) { |
1125 |
< |
std::string myMethod = simParams_->getElectrostaticSummationMethod(); |
1126 |
< |
toUpper(myMethod); |
1127 |
< |
|
1128 |
< |
// For the time being, we're tethering the LJ shifted behavior to the |
1129 |
< |
// electrostaticSummationMethod keyword options |
1130 |
< |
if (myMethod == "SHIFTED_POTENTIAL") { |
1131 |
< |
ljsp_ = true; |
1132 |
< |
} else if (myMethod == "SHIFTED_FORCE") { |
1133 |
< |
ljsf_ = true; |
1134 |
< |
} |
1135 |
< |
if (myMethod == "SHIFTED_POTENTIAL" || myMethod == "SHIFTED_FORCE") { |
1136 |
< |
if (simParams_->haveSwitchingRadius()){ |
1137 |
< |
sprintf(painCave.errMsg, |
1138 |
< |
"SimInfo Warning: A value was set for the switchingRadius\n" |
1139 |
< |
"\teven though the electrostaticSummationMethod was\n" |
1140 |
< |
"\tset to %s\n", myMethod.c_str()); |
1141 |
< |
painCave.isFatal = 1; |
1142 |
< |
simError(); |
1143 |
< |
} |
1144 |
< |
} |
1145 |
< |
} |
1146 |
< |
|
1147 |
< |
if (simParams_->haveSwitchingRadius()){ |
1148 |
< |
rsw_ = simParams_->getSwitchingRadius(); |
1149 |
< |
} else { |
1150 |
< |
sprintf(painCave.errMsg, |
1151 |
< |
"SimCreator Warning: No value was set for switchingRadius.\n" |
1152 |
< |
"\tOOPSE will use a default value of\n" |
1153 |
< |
"\t0.85 * cutoffRadius for the switchingRadius\n"); |
1154 |
< |
painCave.isFatal = 0; |
1155 |
< |
simError(); |
1156 |
< |
rsw_ = 0.85 * rcut_; |
1157 |
< |
} |
1158 |
< |
|
1159 |
< |
notifyFortranCutoffs(&rcut_, &rsw_, &ljsp_, &ljsf_); |
1160 |
< |
|
1161 |
< |
} else { |
1162 |
< |
// We didn't set rcut explicitly, and we don't have electrostatic atoms, so |
1163 |
< |
// We'll punt and let fortran figure out the cutoffs later. |
1164 |
< |
|
1165 |
< |
notifyFortranYouAreOnYourOwn(); |
1166 |
< |
|
1167 |
< |
} |
1168 |
< |
} |
1169 |
< |
} |
1170 |
< |
|
1171 |
< |
void SimInfo::setupElectrostaticSummationMethod( int isError ) { |
1172 |
< |
|
1173 |
< |
int errorOut; |
1174 |
< |
int esm = NONE; |
1175 |
< |
int sm = UNDAMPED; |
1176 |
< |
RealType alphaVal; |
1177 |
< |
RealType dielectric; |
1178 |
< |
|
1179 |
< |
errorOut = isError; |
1180 |
< |
|
1181 |
< |
if (simParams_->haveElectrostaticSummationMethod()) { |
1182 |
< |
std::string myMethod = simParams_->getElectrostaticSummationMethod(); |
1183 |
< |
toUpper(myMethod); |
1184 |
< |
if (myMethod == "NONE") { |
1185 |
< |
esm = NONE; |
1186 |
< |
} else { |
1187 |
< |
if (myMethod == "SWITCHING_FUNCTION") { |
1188 |
< |
esm = SWITCHING_FUNCTION; |
1189 |
< |
} else { |
1190 |
< |
if (myMethod == "SHIFTED_POTENTIAL") { |
1191 |
< |
esm = SHIFTED_POTENTIAL; |
1192 |
< |
} else { |
1193 |
< |
if (myMethod == "SHIFTED_FORCE") { |
1194 |
< |
esm = SHIFTED_FORCE; |
1195 |
< |
} else { |
1196 |
< |
if (myMethod == "REACTION_FIELD") { |
1197 |
< |
esm = REACTION_FIELD; |
1198 |
< |
dielectric = simParams_->getDielectric(); |
1199 |
< |
if (!simParams_->haveDielectric()) { |
1200 |
< |
// throw warning |
1201 |
< |
sprintf( painCave.errMsg, |
1202 |
< |
"SimInfo warning: dielectric was not specified in the input file\n\tfor the reaction field correction method.\n" |
1203 |
< |
"\tA default value of %f will be used for the dielectric.\n", dielectric); |
1204 |
< |
painCave.isFatal = 0; |
1205 |
< |
simError(); |
1206 |
< |
} |
1207 |
< |
} else { |
1208 |
< |
// throw error |
1209 |
< |
sprintf( painCave.errMsg, |
1210 |
< |
"SimInfo error: Unknown electrostaticSummationMethod.\n" |
1211 |
< |
"\t(Input file specified %s .)\n" |
1212 |
< |
"\telectrostaticSummationMethod must be one of: \"none\",\n" |
1213 |
< |
"\t\"shifted_potential\", \"shifted_force\", or \n" |
1214 |
< |
"\t\"reaction_field\".\n", myMethod.c_str() ); |
1215 |
< |
painCave.isFatal = 1; |
1216 |
< |
simError(); |
1217 |
< |
} |
1218 |
< |
} |
1219 |
< |
} |
1220 |
< |
} |
1221 |
< |
} |
1222 |
< |
} |
1223 |
< |
|
1224 |
< |
if (simParams_->haveElectrostaticScreeningMethod()) { |
1225 |
< |
std::string myScreen = simParams_->getElectrostaticScreeningMethod(); |
1226 |
< |
toUpper(myScreen); |
1227 |
< |
if (myScreen == "UNDAMPED") { |
1228 |
< |
sm = UNDAMPED; |
1229 |
< |
} else { |
1230 |
< |
if (myScreen == "DAMPED") { |
1231 |
< |
sm = DAMPED; |
1232 |
< |
if (!simParams_->haveDampingAlpha()) { |
1233 |
< |
// first set a cutoff dependent alpha value |
1234 |
< |
// we assume alpha depends linearly with rcut from 0 to 20.5 ang |
1235 |
< |
alphaVal = 0.5125 - rcut_* 0.025; |
1236 |
< |
// for values rcut > 20.5, alpha is zero |
1237 |
< |
if (alphaVal < 0) alphaVal = 0; |
1238 |
< |
|
1239 |
< |
// throw warning |
1240 |
< |
sprintf( painCave.errMsg, |
1241 |
< |
"SimInfo warning: dampingAlpha was not specified in the input file.\n" |
1242 |
< |
"\tA default value of %f (1/ang) will be used for the cutoff of\n\t%f (ang).\n", alphaVal, rcut_); |
1243 |
< |
painCave.isFatal = 0; |
1244 |
< |
simError(); |
1245 |
< |
} else { |
1246 |
< |
alphaVal = simParams_->getDampingAlpha(); |
1247 |
< |
} |
1248 |
< |
|
1249 |
< |
} else { |
1250 |
< |
// throw error |
1251 |
< |
sprintf( painCave.errMsg, |
1252 |
< |
"SimInfo error: Unknown electrostaticScreeningMethod.\n" |
1253 |
< |
"\t(Input file specified %s .)\n" |
1254 |
< |
"\telectrostaticScreeningMethod must be one of: \"undamped\"\n" |
1255 |
< |
"or \"damped\".\n", myScreen.c_str() ); |
1256 |
< |
painCave.isFatal = 1; |
1257 |
< |
simError(); |
1258 |
< |
} |
1259 |
< |
} |
1260 |
< |
} |
1261 |
< |
|
1262 |
< |
// let's pass some summation method variables to fortran |
1263 |
< |
setElectrostaticSummationMethod( &esm ); |
1264 |
< |
setFortranElectrostaticMethod( &esm ); |
1265 |
< |
setScreeningMethod( &sm ); |
1266 |
< |
setDampingAlpha( &alphaVal ); |
1267 |
< |
setReactionFieldDielectric( &dielectric ); |
1268 |
< |
initFortranFF( &errorOut ); |
927 |
> |
fortranInitialized_ = true; |
928 |
|
} |
929 |
|
|
1271 |
– |
void SimInfo::setupSwitchingFunction() { |
1272 |
– |
int ft = CUBIC; |
1273 |
– |
|
1274 |
– |
if (simParams_->haveSwitchingFunctionType()) { |
1275 |
– |
std::string funcType = simParams_->getSwitchingFunctionType(); |
1276 |
– |
toUpper(funcType); |
1277 |
– |
if (funcType == "CUBIC") { |
1278 |
– |
ft = CUBIC; |
1279 |
– |
} else { |
1280 |
– |
if (funcType == "FIFTH_ORDER_POLYNOMIAL") { |
1281 |
– |
ft = FIFTH_ORDER_POLY; |
1282 |
– |
} else { |
1283 |
– |
// throw error |
1284 |
– |
sprintf( painCave.errMsg, |
1285 |
– |
"SimInfo error: Unknown switchingFunctionType. (Input file specified %s .)\n\tswitchingFunctionType must be one of: \"cubic\" or \"fifth_order_polynomial\".", funcType.c_str() ); |
1286 |
– |
painCave.isFatal = 1; |
1287 |
– |
simError(); |
1288 |
– |
} |
1289 |
– |
} |
1290 |
– |
} |
1291 |
– |
|
1292 |
– |
// send switching function notification to switcheroo |
1293 |
– |
setFunctionType(&ft); |
1294 |
– |
|
1295 |
– |
} |
1296 |
– |
|
1297 |
– |
void SimInfo::setupAccumulateBoxDipole() { |
1298 |
– |
|
1299 |
– |
// we only call setAccumulateBoxDipole if the accumulateBoxDipole parameter is true |
1300 |
– |
if ( simParams_->haveAccumulateBoxDipole() ) |
1301 |
– |
if ( simParams_->getAccumulateBoxDipole() ) { |
1302 |
– |
setAccumulateBoxDipole(); |
1303 |
– |
calcBoxDipole_ = true; |
1304 |
– |
} |
1305 |
– |
|
1306 |
– |
} |
1307 |
– |
|
930 |
|
void SimInfo::addProperty(GenericData* genData) { |
931 |
|
properties_.addProperty(genData); |
932 |
|
} |
933 |
|
|
934 |
< |
void SimInfo::removeProperty(const std::string& propName) { |
934 |
> |
void SimInfo::removeProperty(const string& propName) { |
935 |
|
properties_.removeProperty(propName); |
936 |
|
} |
937 |
|
|
939 |
|
properties_.clearProperties(); |
940 |
|
} |
941 |
|
|
942 |
< |
std::vector<std::string> SimInfo::getPropertyNames() { |
942 |
> |
vector<string> SimInfo::getPropertyNames() { |
943 |
|
return properties_.getPropertyNames(); |
944 |
|
} |
945 |
|
|
946 |
< |
std::vector<GenericData*> SimInfo::getProperties() { |
946 |
> |
vector<GenericData*> SimInfo::getProperties() { |
947 |
|
return properties_.getProperties(); |
948 |
|
} |
949 |
|
|
950 |
< |
GenericData* SimInfo::getPropertyByName(const std::string& propName) { |
950 |
> |
GenericData* SimInfo::getPropertyByName(const string& propName) { |
951 |
|
return properties_.getPropertyByName(propName); |
952 |
|
} |
953 |
|
|
1030 |
|
|
1031 |
|
} |
1032 |
|
|
1033 |
< |
std::ostream& operator <<(std::ostream& o, SimInfo& info) { |
1033 |
> |
ostream& operator <<(ostream& o, SimInfo& info) { |
1034 |
|
|
1035 |
|
return o; |
1036 |
|
} |
1073 |
|
|
1074 |
|
|
1075 |
|
[ Ixx -Ixy -Ixz ] |
1076 |
< |
J =| -Iyx Iyy -Iyz | |
1076 |
> |
J =| -Iyx Iyy -Iyz | |
1077 |
|
[ -Izx -Iyz Izz ] |
1078 |
|
*/ |
1079 |
|
|
1180 |
|
return IOIndexToIntegrableObject.at(index); |
1181 |
|
} |
1182 |
|
|
1183 |
< |
void SimInfo::setIOIndexToIntegrableObject(const std::vector<StuntDouble*>& v) { |
1183 |
> |
void SimInfo::setIOIndexToIntegrableObject(const vector<StuntDouble*>& v) { |
1184 |
|
IOIndexToIntegrableObject= v; |
1185 |
|
} |
1186 |
|
|
1222 |
|
return; |
1223 |
|
} |
1224 |
|
/* |
1225 |
< |
void SimInfo::setStuntDoubleFromGlobalIndex(std::vector<StuntDouble*> v) { |
1225 |
> |
void SimInfo::setStuntDoubleFromGlobalIndex(vector<StuntDouble*> v) { |
1226 |
|
assert( v.size() == nAtoms_ + nRigidBodies_); |
1227 |
|
sdByGlobalIndex_ = v; |
1228 |
|
} |
1232 |
|
return sdByGlobalIndex_.at(index); |
1233 |
|
} |
1234 |
|
*/ |
1235 |
< |
}//end namespace oopse |
1235 |
> |
int SimInfo::getNGlobalConstraints() { |
1236 |
> |
int nGlobalConstraints; |
1237 |
> |
#ifdef IS_MPI |
1238 |
> |
MPI_Allreduce(&nConstraints_, &nGlobalConstraints, 1, MPI_INT, MPI_SUM, |
1239 |
> |
MPI_COMM_WORLD); |
1240 |
> |
#else |
1241 |
> |
nGlobalConstraints = nConstraints_; |
1242 |
> |
#endif |
1243 |
> |
return nGlobalConstraints; |
1244 |
> |
} |
1245 |
|
|
1246 |
+ |
}//end namespace OpenMD |
1247 |
+ |
|