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 |
|
/** |
47 |
|
* @version 1.0 |
48 |
|
*/ |
49 |
|
|
50 |
+ |
|
51 |
|
#include "brains/ForceManager.hpp" |
52 |
|
#include "primitives/Molecule.hpp" |
53 |
< |
#include "UseTheForce/doForces_interface.h" |
53 |
< |
#define __C |
54 |
< |
#include "UseTheForce/DarkSide/fInteractionMap.h" |
53 |
> |
#define __OPENMD_C |
54 |
|
#include "utils/simError.h" |
55 |
+ |
#include "primitives/Bond.hpp" |
56 |
|
#include "primitives/Bend.hpp" |
57 |
< |
#include "primitives/Bend.hpp" |
58 |
< |
namespace oopse { |
57 |
> |
#include "primitives/Torsion.hpp" |
58 |
> |
#include "primitives/Inversion.hpp" |
59 |
> |
#include "nonbonded/NonBondedInteraction.hpp" |
60 |
> |
#include "parallel/ForceMatrixDecomposition.hpp" |
61 |
|
|
62 |
< |
/* |
63 |
< |
struct BendOrderStruct { |
64 |
< |
Bend* bend; |
65 |
< |
BendDataSet dataSet; |
66 |
< |
}; |
67 |
< |
struct TorsionOrderStruct { |
68 |
< |
Torsion* torsion; |
67 |
< |
TorsionDataSet dataSet; |
68 |
< |
}; |
69 |
< |
|
70 |
< |
bool BendSortFunctor(const BendOrderStruct& b1, const BendOrderStruct& b2) { |
71 |
< |
return b1.dataSet.deltaV < b2.dataSet.deltaV; |
62 |
> |
using namespace std; |
63 |
> |
namespace OpenMD { |
64 |
> |
|
65 |
> |
ForceManager::ForceManager(SimInfo * info) : info_(info) { |
66 |
> |
forceField_ = info_->getForceField(); |
67 |
> |
interactionMan_ = new InteractionManager(); |
68 |
> |
fDecomp_ = new ForceMatrixDecomposition(info_, interactionMan_); |
69 |
|
} |
70 |
|
|
71 |
< |
bool TorsionSortFunctor(const TorsionOrderStruct& t1, const TorsionOrderStruct& t2) { |
72 |
< |
return t1.dataSet.deltaV < t2.dataSet.deltaV; |
73 |
< |
} |
74 |
< |
*/ |
75 |
< |
void ForceManager::calcForces(bool needPotential, bool needStress) { |
71 |
> |
/** |
72 |
> |
* setupCutoffs |
73 |
> |
* |
74 |
> |
* Sets the values of cutoffRadius, cutoffMethod, and cutoffPolicy |
75 |
> |
* |
76 |
> |
* cutoffRadius : realType |
77 |
> |
* If the cutoffRadius was explicitly set, use that value. |
78 |
> |
* If the cutoffRadius was not explicitly set: |
79 |
> |
* Are there electrostatic atoms? Use 12.0 Angstroms. |
80 |
> |
* No electrostatic atoms? Poll the atom types present in the |
81 |
> |
* simulation for suggested cutoff values (e.g. 2.5 * sigma). |
82 |
> |
* Use the maximum suggested value that was found. |
83 |
> |
* |
84 |
> |
* cutoffMethod : (one of HARD, SWITCHED, SHIFTED_FORCE, SHIFTED_POTENTIAL) |
85 |
> |
* If cutoffMethod was explicitly set, use that choice. |
86 |
> |
* If cutoffMethod was not explicitly set, use SHIFTED_FORCE |
87 |
> |
* |
88 |
> |
* cutoffPolicy : (one of MIX, MAX, TRADITIONAL) |
89 |
> |
* If cutoffPolicy was explicitly set, use that choice. |
90 |
> |
* If cutoffPolicy was not explicitly set, use TRADITIONAL |
91 |
> |
*/ |
92 |
> |
void ForceManager::setupCutoffs() { |
93 |
> |
|
94 |
> |
Globals* simParams_ = info_->getSimParams(); |
95 |
> |
ForceFieldOptions& forceFieldOptions_ = forceField_->getForceFieldOptions(); |
96 |
> |
|
97 |
> |
if (simParams_->haveCutoffRadius()) { |
98 |
> |
rCut_ = simParams_->getCutoffRadius(); |
99 |
> |
} else { |
100 |
> |
if (info_->usesElectrostaticAtoms()) { |
101 |
> |
sprintf(painCave.errMsg, |
102 |
> |
"ForceManager::setupCutoffs: No value was set for the cutoffRadius.\n" |
103 |
> |
"\tOpenMD will use a default value of 12.0 angstroms" |
104 |
> |
"\tfor the cutoffRadius.\n"); |
105 |
> |
painCave.isFatal = 0; |
106 |
> |
painCave.severity = OPENMD_INFO; |
107 |
> |
simError(); |
108 |
> |
rCut_ = 12.0; |
109 |
> |
} else { |
110 |
> |
RealType thisCut; |
111 |
> |
set<AtomType*>::iterator i; |
112 |
> |
set<AtomType*> atomTypes; |
113 |
> |
atomTypes = info_->getSimulatedAtomTypes(); |
114 |
> |
for (i = atomTypes.begin(); i != atomTypes.end(); ++i) { |
115 |
> |
thisCut = interactionMan_->getSuggestedCutoffRadius((*i)); |
116 |
> |
rCut_ = max(thisCut, rCut_); |
117 |
> |
} |
118 |
> |
sprintf(painCave.errMsg, |
119 |
> |
"ForceManager::setupCutoffs: No value was set for the cutoffRadius.\n" |
120 |
> |
"\tOpenMD will use %lf angstroms.\n", |
121 |
> |
rCut_); |
122 |
> |
painCave.isFatal = 0; |
123 |
> |
painCave.severity = OPENMD_INFO; |
124 |
> |
simError(); |
125 |
> |
} |
126 |
> |
fDecomp_->setUserCutoff(rCut_); |
127 |
> |
} |
128 |
|
|
129 |
< |
if (!info_->isFortranInitialized()) { |
130 |
< |
info_->update(); |
129 |
> |
map<string, CutoffMethod> stringToCutoffMethod; |
130 |
> |
stringToCutoffMethod["HARD"] = HARD; |
131 |
> |
stringToCutoffMethod["SWITCHED"] = SWITCHED; |
132 |
> |
stringToCutoffMethod["SHIFTED_POTENTIAL"] = SHIFTED_POTENTIAL; |
133 |
> |
stringToCutoffMethod["SHIFTED_FORCE"] = SHIFTED_FORCE; |
134 |
> |
|
135 |
> |
if (simParams_->haveCutoffMethod()) { |
136 |
> |
string cutMeth = toUpperCopy(simParams_->getCutoffMethod()); |
137 |
> |
map<string, CutoffMethod>::iterator i; |
138 |
> |
i = stringToCutoffMethod.find(cutMeth); |
139 |
> |
if (i == stringToCutoffMethod.end()) { |
140 |
> |
sprintf(painCave.errMsg, |
141 |
> |
"ForceManager::setupCutoffs: Could not find chosen cutoffMethod %s\n" |
142 |
> |
"\tShould be one of: " |
143 |
> |
"HARD, SWITCHED, SHIFTED_POTENTIAL, or SHIFTED_FORCE\n", |
144 |
> |
cutMeth.c_str()); |
145 |
> |
painCave.isFatal = 1; |
146 |
> |
painCave.severity = OPENMD_ERROR; |
147 |
> |
simError(); |
148 |
> |
} else { |
149 |
> |
cutoffMethod_ = i->second; |
150 |
> |
} |
151 |
> |
} else { |
152 |
> |
sprintf(painCave.errMsg, |
153 |
> |
"ForceManager::setupCutoffs: No value was set for the cutoffMethod.\n" |
154 |
> |
"\tOpenMD will use SHIFTED_FORCE.\n"); |
155 |
> |
painCave.isFatal = 0; |
156 |
> |
painCave.severity = OPENMD_INFO; |
157 |
> |
simError(); |
158 |
> |
cutoffMethod_ = SHIFTED_FORCE; |
159 |
|
} |
160 |
|
|
161 |
< |
preCalculation(); |
162 |
< |
|
163 |
< |
calcShortRangeInteraction(); |
161 |
> |
map<string, CutoffPolicy> stringToCutoffPolicy; |
162 |
> |
stringToCutoffPolicy["MIX"] = MIX; |
163 |
> |
stringToCutoffPolicy["MAX"] = MAX; |
164 |
> |
stringToCutoffPolicy["TRADITIONAL"] = TRADITIONAL; |
165 |
|
|
166 |
< |
calcLongRangeInteraction(needPotential, needStress); |
166 |
> |
std::string cutPolicy; |
167 |
> |
if (forceFieldOptions_.haveCutoffPolicy()){ |
168 |
> |
cutPolicy = forceFieldOptions_.getCutoffPolicy(); |
169 |
> |
}else if (simParams_->haveCutoffPolicy()) { |
170 |
> |
cutPolicy = simParams_->getCutoffPolicy(); |
171 |
> |
} |
172 |
|
|
173 |
< |
postCalculation(); |
173 |
> |
if (!cutPolicy.empty()){ |
174 |
> |
toUpper(cutPolicy); |
175 |
> |
map<string, CutoffPolicy>::iterator i; |
176 |
> |
i = stringToCutoffPolicy.find(cutPolicy); |
177 |
|
|
178 |
< |
/* |
179 |
< |
std::vector<BendOrderStruct> bendOrderStruct; |
180 |
< |
for(std::map<Bend*, BendDataSet>::iterator i = bendDataSets.begin(); i != bendDataSets.end(); ++i) { |
181 |
< |
BendOrderStruct tmp; |
182 |
< |
tmp.bend= const_cast<Bend*>(i->first); |
183 |
< |
tmp.dataSet = i->second; |
184 |
< |
bendOrderStruct.push_back(tmp); |
178 |
> |
if (i == stringToCutoffPolicy.end()) { |
179 |
> |
sprintf(painCave.errMsg, |
180 |
> |
"ForceManager::setupCutoffs: Could not find chosen cutoffPolicy %s\n" |
181 |
> |
"\tShould be one of: " |
182 |
> |
"MIX, MAX, or TRADITIONAL\n", |
183 |
> |
cutPolicy.c_str()); |
184 |
> |
painCave.isFatal = 1; |
185 |
> |
painCave.severity = OPENMD_ERROR; |
186 |
> |
simError(); |
187 |
> |
} else { |
188 |
> |
cutoffPolicy_ = i->second; |
189 |
> |
} |
190 |
> |
} else { |
191 |
> |
sprintf(painCave.errMsg, |
192 |
> |
"ForceManager::setupCutoffs: No value was set for the cutoffPolicy.\n" |
193 |
> |
"\tOpenMD will use TRADITIONAL.\n"); |
194 |
> |
painCave.isFatal = 0; |
195 |
> |
painCave.severity = OPENMD_INFO; |
196 |
> |
simError(); |
197 |
> |
cutoffPolicy_ = TRADITIONAL; |
198 |
|
} |
199 |
+ |
fDecomp_->setCutoffPolicy(cutoffPolicy_); |
200 |
+ |
} |
201 |
|
|
202 |
< |
std::vector<TorsionOrderStruct> torsionOrderStruct; |
203 |
< |
for(std::map<Torsion*, TorsionDataSet>::iterator j = torsionDataSets.begin(); j != torsionDataSets.end(); ++j) { |
204 |
< |
TorsionOrderStruct tmp; |
205 |
< |
tmp.torsion = const_cast<Torsion*>(j->first); |
206 |
< |
tmp.dataSet = j->second; |
207 |
< |
torsionOrderStruct.push_back(tmp); |
208 |
< |
} |
202 |
> |
/** |
203 |
> |
* setupSwitching |
204 |
> |
* |
205 |
> |
* Sets the values of switchingRadius and |
206 |
> |
* If the switchingRadius was explicitly set, use that value (but check it) |
207 |
> |
* If the switchingRadius was not explicitly set: use 0.85 * cutoffRadius_ |
208 |
> |
*/ |
209 |
> |
void ForceManager::setupSwitching() { |
210 |
> |
Globals* simParams_ = info_->getSimParams(); |
211 |
> |
|
212 |
> |
// create the switching function object: |
213 |
> |
switcher_ = new SwitchingFunction(); |
214 |
|
|
215 |
< |
std::sort(bendOrderStruct.begin(), bendOrderStruct.end(), std::ptr_fun(BendSortFunctor)); |
216 |
< |
std::sort(torsionOrderStruct.begin(), torsionOrderStruct.end(), std::ptr_fun(TorsionSortFunctor)); |
217 |
< |
for (std::vector<BendOrderStruct>::iterator k = bendOrderStruct.begin(); k != bendOrderStruct.end(); ++k) { |
218 |
< |
Bend* bend = k->bend; |
219 |
< |
std::cout << "Bend: atom1=" <<bend->getAtomA()->getGlobalIndex() << ",atom2 = "<< bend->getAtomB()->getGlobalIndex() << ",atom3="<<bend->getAtomC()->getGlobalIndex() << " "; |
220 |
< |
std::cout << "deltaV=" << k->dataSet.deltaV << ",p_theta=" << k->dataSet.prev.angle <<",p_pot=" << k->dataSet.prev.potential<< ",c_theta=" << k->dataSet.curr.angle << ", c_pot = " << k->dataSet.curr.potential <<std::endl; |
215 |
> |
if (simParams_->haveSwitchingRadius()) { |
216 |
> |
rSwitch_ = simParams_->getSwitchingRadius(); |
217 |
> |
if (rSwitch_ > rCut_) { |
218 |
> |
sprintf(painCave.errMsg, |
219 |
> |
"ForceManager::setupSwitching: switchingRadius (%f) is larger " |
220 |
> |
"than the cutoffRadius(%f)\n", rSwitch_, rCut_); |
221 |
> |
painCave.isFatal = 1; |
222 |
> |
painCave.severity = OPENMD_ERROR; |
223 |
> |
simError(); |
224 |
> |
} |
225 |
> |
} else { |
226 |
> |
rSwitch_ = 0.85 * rCut_; |
227 |
> |
sprintf(painCave.errMsg, |
228 |
> |
"ForceManager::setupSwitching: No value was set for the switchingRadius.\n" |
229 |
> |
"\tOpenMD will use a default value of 85 percent of the cutoffRadius.\n" |
230 |
> |
"\tswitchingRadius = %f. for this simulation\n", rSwitch_); |
231 |
> |
painCave.isFatal = 0; |
232 |
> |
painCave.severity = OPENMD_WARNING; |
233 |
> |
simError(); |
234 |
> |
} |
235 |
> |
|
236 |
> |
// Default to cubic switching function. |
237 |
> |
sft_ = cubic; |
238 |
> |
if (simParams_->haveSwitchingFunctionType()) { |
239 |
> |
string funcType = simParams_->getSwitchingFunctionType(); |
240 |
> |
toUpper(funcType); |
241 |
> |
if (funcType == "CUBIC") { |
242 |
> |
sft_ = cubic; |
243 |
> |
} else { |
244 |
> |
if (funcType == "FIFTH_ORDER_POLYNOMIAL") { |
245 |
> |
sft_ = fifth_order_poly; |
246 |
> |
} else { |
247 |
> |
// throw error |
248 |
> |
sprintf( painCave.errMsg, |
249 |
> |
"ForceManager::setupSwitching : Unknown switchingFunctionType. (Input file specified %s .)\n" |
250 |
> |
"\tswitchingFunctionType must be one of: " |
251 |
> |
"\"cubic\" or \"fifth_order_polynomial\".", |
252 |
> |
funcType.c_str() ); |
253 |
> |
painCave.isFatal = 1; |
254 |
> |
painCave.severity = OPENMD_ERROR; |
255 |
> |
simError(); |
256 |
> |
} |
257 |
> |
} |
258 |
|
} |
259 |
< |
for (std::vector<TorsionOrderStruct>::iterator l = torsionOrderStruct.begin(); l != torsionOrderStruct.end(); ++l) { |
260 |
< |
Torsion* torsion = l->torsion; |
261 |
< |
std::cout << "Torsion: atom1=" <<torsion->getAtomA()->getGlobalIndex() << ",atom2 = "<< torsion->getAtomB()->getGlobalIndex() << ",atom3="<<torsion->getAtomC()->getGlobalIndex() << ",atom4="<<torsion->getAtomD()->getGlobalIndex()<< " "; |
262 |
< |
std::cout << "deltaV=" << l->dataSet.deltaV << ",p_theta=" << l->dataSet.prev.angle <<",p_pot=" << l->dataSet.prev.potential<< ",c_theta=" << l->dataSet.curr.angle << ", c_pot = " << l->dataSet.curr.potential <<std::endl; |
259 |
> |
switcher_->setSwitchType(sft_); |
260 |
> |
switcher_->setSwitch(rSwitch_, rCut_); |
261 |
> |
} |
262 |
> |
|
263 |
> |
void ForceManager::initialize() { |
264 |
> |
|
265 |
> |
if (!info_->isTopologyDone()) { |
266 |
> |
info_->update(); |
267 |
> |
interactionMan_->setSimInfo(info_); |
268 |
> |
interactionMan_->initialize(); |
269 |
> |
|
270 |
> |
// We want to delay the cutoffs until after the interaction |
271 |
> |
// manager has set up the atom-atom interactions so that we can |
272 |
> |
// query them for suggested cutoff values |
273 |
> |
|
274 |
> |
setupCutoffs(); |
275 |
> |
setupSwitching(); |
276 |
> |
|
277 |
> |
info_->prepareTopology(); |
278 |
|
} |
279 |
< |
*/ |
279 |
> |
|
280 |
> |
ForceFieldOptions& fopts = forceField_->getForceFieldOptions(); |
281 |
> |
|
282 |
> |
// Force fields can set options on how to scale van der Waals and electrostatic |
283 |
> |
// interactions for atoms connected via bonds, bends and torsions |
284 |
> |
// in this case the topological distance between atoms is: |
285 |
> |
// 0 = topologically unconnected |
286 |
> |
// 1 = bonded together |
287 |
> |
// 2 = connected via a bend |
288 |
> |
// 3 = connected via a torsion |
289 |
> |
|
290 |
> |
vdwScale_.reserve(4); |
291 |
> |
fill(vdwScale_.begin(), vdwScale_.end(), 0.0); |
292 |
> |
|
293 |
> |
electrostaticScale_.reserve(4); |
294 |
> |
fill(electrostaticScale_.begin(), electrostaticScale_.end(), 0.0); |
295 |
> |
|
296 |
> |
vdwScale_[0] = 1.0; |
297 |
> |
vdwScale_[1] = fopts.getvdw12scale(); |
298 |
> |
vdwScale_[2] = fopts.getvdw13scale(); |
299 |
> |
vdwScale_[3] = fopts.getvdw14scale(); |
300 |
> |
|
301 |
> |
electrostaticScale_[0] = 1.0; |
302 |
> |
electrostaticScale_[1] = fopts.getelectrostatic12scale(); |
303 |
> |
electrostaticScale_[2] = fopts.getelectrostatic13scale(); |
304 |
> |
electrostaticScale_[3] = fopts.getelectrostatic14scale(); |
305 |
> |
|
306 |
> |
fDecomp_->distributeInitialData(); |
307 |
> |
|
308 |
> |
initialized_ = true; |
309 |
> |
|
310 |
|
} |
311 |
|
|
312 |
+ |
void ForceManager::calcForces() { |
313 |
+ |
|
314 |
+ |
if (!initialized_) initialize(); |
315 |
+ |
|
316 |
+ |
preCalculation(); |
317 |
+ |
shortRangeInteractions(); |
318 |
+ |
longRangeInteractions(); |
319 |
+ |
postCalculation(); |
320 |
+ |
} |
321 |
+ |
|
322 |
|
void ForceManager::preCalculation() { |
323 |
|
SimInfo::MoleculeIterator mi; |
324 |
|
Molecule* mol; |
326 |
|
Atom* atom; |
327 |
|
Molecule::RigidBodyIterator rbIter; |
328 |
|
RigidBody* rb; |
329 |
+ |
Molecule::CutoffGroupIterator ci; |
330 |
+ |
CutoffGroup* cg; |
331 |
|
|
332 |
|
// forces are zeroed here, before any are accumulated. |
333 |
< |
// NOTE: do not rezero the forces in Fortran. |
334 |
< |
for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) { |
333 |
> |
|
334 |
> |
for (mol = info_->beginMolecule(mi); mol != NULL; |
335 |
> |
mol = info_->nextMolecule(mi)) { |
336 |
|
for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
337 |
|
atom->zeroForcesAndTorques(); |
338 |
|
} |
339 |
< |
|
339 |
> |
|
340 |
|
//change the positions of atoms which belong to the rigidbodies |
341 |
< |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
341 |
> |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; |
342 |
> |
rb = mol->nextRigidBody(rbIter)) { |
343 |
|
rb->zeroForcesAndTorques(); |
344 |
|
} |
345 |
+ |
|
346 |
+ |
if(info_->getNGlobalCutoffGroups() != info_->getNGlobalAtoms()){ |
347 |
+ |
for(cg = mol->beginCutoffGroup(ci); cg != NULL; |
348 |
+ |
cg = mol->nextCutoffGroup(ci)) { |
349 |
+ |
//calculate the center of mass of cutoff group |
350 |
+ |
cg->updateCOM(); |
351 |
+ |
} |
352 |
+ |
} |
353 |
|
} |
354 |
+ |
|
355 |
+ |
// Zero out the stress tensor |
356 |
+ |
tau *= 0.0; |
357 |
|
|
358 |
|
} |
359 |
< |
|
360 |
< |
void ForceManager::calcShortRangeInteraction() { |
359 |
> |
|
360 |
> |
void ForceManager::shortRangeInteractions() { |
361 |
|
Molecule* mol; |
362 |
|
RigidBody* rb; |
363 |
|
Bond* bond; |
364 |
|
Bend* bend; |
365 |
|
Torsion* torsion; |
366 |
+ |
Inversion* inversion; |
367 |
|
SimInfo::MoleculeIterator mi; |
368 |
|
Molecule::RigidBodyIterator rbIter; |
369 |
|
Molecule::BondIterator bondIter;; |
370 |
|
Molecule::BendIterator bendIter; |
371 |
|
Molecule::TorsionIterator torsionIter; |
372 |
+ |
Molecule::InversionIterator inversionIter; |
373 |
|
RealType bondPotential = 0.0; |
374 |
|
RealType bendPotential = 0.0; |
375 |
|
RealType torsionPotential = 0.0; |
376 |
+ |
RealType inversionPotential = 0.0; |
377 |
|
|
378 |
|
//calculate short range interactions |
379 |
< |
for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) { |
379 |
> |
for (mol = info_->beginMolecule(mi); mol != NULL; |
380 |
> |
mol = info_->nextMolecule(mi)) { |
381 |
|
|
382 |
|
//change the positions of atoms which belong to the rigidbodies |
383 |
< |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
384 |
< |
rb->updateAtoms(); |
383 |
> |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; |
384 |
> |
rb = mol->nextRigidBody(rbIter)) { |
385 |
> |
rb->updateAtoms(); |
386 |
|
} |
387 |
|
|
388 |
< |
for (bond = mol->beginBond(bondIter); bond != NULL; bond = mol->nextBond(bondIter)) { |
388 |
> |
for (bond = mol->beginBond(bondIter); bond != NULL; |
389 |
> |
bond = mol->nextBond(bondIter)) { |
390 |
|
bond->calcForce(); |
391 |
|
bondPotential += bond->getPotential(); |
392 |
|
} |
393 |
|
|
394 |
< |
|
395 |
< |
for (bend = mol->beginBend(bendIter); bend != NULL; bend = mol->nextBend(bendIter)) { |
396 |
< |
|
178 |
< |
RealType angle; |
179 |
< |
bend->calcForce(angle); |
180 |
< |
RealType currBendPot = bend->getPotential(); |
181 |
< |
bendPotential += bend->getPotential(); |
182 |
< |
std::map<Bend*, BendDataSet>::iterator i = bendDataSets.find(bend); |
183 |
< |
if (i == bendDataSets.end()) { |
184 |
< |
BendDataSet dataSet; |
185 |
< |
dataSet.prev.angle = dataSet.curr.angle = angle; |
186 |
< |
dataSet.prev.potential = dataSet.curr.potential = currBendPot; |
187 |
< |
dataSet.deltaV = 0.0; |
188 |
< |
bendDataSets.insert(std::map<Bend*, BendDataSet>::value_type(bend, dataSet)); |
189 |
< |
}else { |
190 |
< |
i->second.prev.angle = i->second.curr.angle; |
191 |
< |
i->second.prev.potential = i->second.curr.potential; |
192 |
< |
i->second.curr.angle = angle; |
193 |
< |
i->second.curr.potential = currBendPot; |
194 |
< |
i->second.deltaV = fabs(i->second.curr.potential - i->second.prev.potential); |
195 |
< |
} |
196 |
< |
} |
197 |
< |
|
198 |
< |
for (torsion = mol->beginTorsion(torsionIter); torsion != NULL; torsion = mol->nextTorsion(torsionIter)) { |
394 |
> |
for (bend = mol->beginBend(bendIter); bend != NULL; |
395 |
> |
bend = mol->nextBend(bendIter)) { |
396 |
> |
|
397 |
|
RealType angle; |
398 |
< |
torsion->calcForce(angle); |
399 |
< |
RealType currTorsionPot = torsion->getPotential(); |
400 |
< |
torsionPotential += torsion->getPotential(); |
401 |
< |
std::map<Torsion*, TorsionDataSet>::iterator i = torsionDataSets.find(torsion); |
402 |
< |
if (i == torsionDataSets.end()) { |
403 |
< |
TorsionDataSet dataSet; |
404 |
< |
dataSet.prev.angle = dataSet.curr.angle = angle; |
405 |
< |
dataSet.prev.potential = dataSet.curr.potential = currTorsionPot; |
406 |
< |
dataSet.deltaV = 0.0; |
407 |
< |
torsionDataSets.insert(std::map<Torsion*, TorsionDataSet>::value_type(torsion, dataSet)); |
408 |
< |
}else { |
409 |
< |
i->second.prev.angle = i->second.curr.angle; |
410 |
< |
i->second.prev.potential = i->second.curr.potential; |
411 |
< |
i->second.curr.angle = angle; |
412 |
< |
i->second.curr.potential = currTorsionPot; |
413 |
< |
i->second.deltaV = fabs(i->second.curr.potential - i->second.prev.potential); |
414 |
< |
} |
398 |
> |
bend->calcForce(angle); |
399 |
> |
RealType currBendPot = bend->getPotential(); |
400 |
> |
|
401 |
> |
bendPotential += bend->getPotential(); |
402 |
> |
map<Bend*, BendDataSet>::iterator i = bendDataSets.find(bend); |
403 |
> |
if (i == bendDataSets.end()) { |
404 |
> |
BendDataSet dataSet; |
405 |
> |
dataSet.prev.angle = dataSet.curr.angle = angle; |
406 |
> |
dataSet.prev.potential = dataSet.curr.potential = currBendPot; |
407 |
> |
dataSet.deltaV = 0.0; |
408 |
> |
bendDataSets.insert(map<Bend*, BendDataSet>::value_type(bend, dataSet)); |
409 |
> |
}else { |
410 |
> |
i->second.prev.angle = i->second.curr.angle; |
411 |
> |
i->second.prev.potential = i->second.curr.potential; |
412 |
> |
i->second.curr.angle = angle; |
413 |
> |
i->second.curr.potential = currBendPot; |
414 |
> |
i->second.deltaV = fabs(i->second.curr.potential - |
415 |
> |
i->second.prev.potential); |
416 |
> |
} |
417 |
|
} |
418 |
< |
|
418 |
> |
|
419 |
> |
for (torsion = mol->beginTorsion(torsionIter); torsion != NULL; |
420 |
> |
torsion = mol->nextTorsion(torsionIter)) { |
421 |
> |
RealType angle; |
422 |
> |
torsion->calcForce(angle); |
423 |
> |
RealType currTorsionPot = torsion->getPotential(); |
424 |
> |
torsionPotential += torsion->getPotential(); |
425 |
> |
map<Torsion*, TorsionDataSet>::iterator i = torsionDataSets.find(torsion); |
426 |
> |
if (i == torsionDataSets.end()) { |
427 |
> |
TorsionDataSet dataSet; |
428 |
> |
dataSet.prev.angle = dataSet.curr.angle = angle; |
429 |
> |
dataSet.prev.potential = dataSet.curr.potential = currTorsionPot; |
430 |
> |
dataSet.deltaV = 0.0; |
431 |
> |
torsionDataSets.insert(map<Torsion*, TorsionDataSet>::value_type(torsion, dataSet)); |
432 |
> |
}else { |
433 |
> |
i->second.prev.angle = i->second.curr.angle; |
434 |
> |
i->second.prev.potential = i->second.curr.potential; |
435 |
> |
i->second.curr.angle = angle; |
436 |
> |
i->second.curr.potential = currTorsionPot; |
437 |
> |
i->second.deltaV = fabs(i->second.curr.potential - |
438 |
> |
i->second.prev.potential); |
439 |
> |
} |
440 |
> |
} |
441 |
> |
|
442 |
> |
for (inversion = mol->beginInversion(inversionIter); |
443 |
> |
inversion != NULL; |
444 |
> |
inversion = mol->nextInversion(inversionIter)) { |
445 |
> |
RealType angle; |
446 |
> |
inversion->calcForce(angle); |
447 |
> |
RealType currInversionPot = inversion->getPotential(); |
448 |
> |
inversionPotential += inversion->getPotential(); |
449 |
> |
map<Inversion*, InversionDataSet>::iterator i = inversionDataSets.find(inversion); |
450 |
> |
if (i == inversionDataSets.end()) { |
451 |
> |
InversionDataSet dataSet; |
452 |
> |
dataSet.prev.angle = dataSet.curr.angle = angle; |
453 |
> |
dataSet.prev.potential = dataSet.curr.potential = currInversionPot; |
454 |
> |
dataSet.deltaV = 0.0; |
455 |
> |
inversionDataSets.insert(map<Inversion*, InversionDataSet>::value_type(inversion, dataSet)); |
456 |
> |
}else { |
457 |
> |
i->second.prev.angle = i->second.curr.angle; |
458 |
> |
i->second.prev.potential = i->second.curr.potential; |
459 |
> |
i->second.curr.angle = angle; |
460 |
> |
i->second.curr.potential = currInversionPot; |
461 |
> |
i->second.deltaV = fabs(i->second.curr.potential - |
462 |
> |
i->second.prev.potential); |
463 |
> |
} |
464 |
> |
} |
465 |
|
} |
466 |
|
|
467 |
< |
RealType shortRangePotential = bondPotential + bendPotential + torsionPotential; |
467 |
> |
RealType shortRangePotential = bondPotential + bendPotential + |
468 |
> |
torsionPotential + inversionPotential; |
469 |
|
Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); |
470 |
|
curSnapshot->statData[Stats::SHORT_RANGE_POTENTIAL] = shortRangePotential; |
471 |
|
curSnapshot->statData[Stats::BOND_POTENTIAL] = bondPotential; |
472 |
|
curSnapshot->statData[Stats::BEND_POTENTIAL] = bendPotential; |
473 |
|
curSnapshot->statData[Stats::DIHEDRAL_POTENTIAL] = torsionPotential; |
474 |
< |
|
474 |
> |
curSnapshot->statData[Stats::INVERSION_POTENTIAL] = inversionPotential; |
475 |
|
} |
476 |
+ |
|
477 |
+ |
void ForceManager::longRangeInteractions() { |
478 |
+ |
// some of this initial stuff will go away: |
479 |
+ |
Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); |
480 |
+ |
DataStorage* config = &(curSnapshot->atomData); |
481 |
+ |
DataStorage* cgConfig = &(curSnapshot->cgData); |
482 |
+ |
RealType* frc = config->getArrayPointer(DataStorage::dslForce); |
483 |
+ |
RealType* pos = config->getArrayPointer(DataStorage::dslPosition); |
484 |
+ |
RealType* trq = config->getArrayPointer(DataStorage::dslTorque); |
485 |
+ |
RealType* A = config->getArrayPointer(DataStorage::dslAmat); |
486 |
+ |
RealType* electroFrame = config->getArrayPointer(DataStorage::dslElectroFrame); |
487 |
+ |
RealType* particlePot = config->getArrayPointer(DataStorage::dslParticlePot); |
488 |
|
|
489 |
< |
void ForceManager::calcLongRangeInteraction(bool needPotential, bool needStress) { |
231 |
< |
Snapshot* curSnapshot; |
232 |
< |
DataStorage* config; |
233 |
< |
RealType* frc; |
234 |
< |
RealType* pos; |
235 |
< |
RealType* trq; |
236 |
< |
RealType* A; |
237 |
< |
RealType* electroFrame; |
238 |
< |
RealType* rc; |
489 |
> |
// new stuff starts here: |
490 |
|
|
491 |
< |
//get current snapshot from SimInfo |
492 |
< |
curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); |
491 |
> |
fDecomp_->zeroWorkArrays(); |
492 |
> |
fDecomp_->distributeData(); |
493 |
> |
|
494 |
> |
int cg1, cg2, atom1, atom2, topoDist; |
495 |
> |
Vector3d d_grp, dag, d; |
496 |
> |
RealType rgrpsq, rgrp, r2, r; |
497 |
> |
RealType electroMult, vdwMult; |
498 |
> |
RealType vij; |
499 |
> |
Vector3d fij, fg; |
500 |
> |
tuple3<RealType, RealType, RealType> cuts; |
501 |
> |
RealType rCutSq; |
502 |
> |
bool in_switching_region; |
503 |
> |
RealType sw, dswdr, swderiv; |
504 |
> |
vector<int> atomListColumn, atomListRow, atomListLocal; |
505 |
> |
InteractionData idat; |
506 |
> |
SelfData sdat; |
507 |
> |
RealType mf; |
508 |
> |
potVec pot(0.0); |
509 |
> |
potVec longRangePotential(0.0); |
510 |
> |
RealType lrPot; |
511 |
> |
RealType vpair; |
512 |
|
|
513 |
< |
//get array pointers |
244 |
< |
config = &(curSnapshot->atomData); |
245 |
< |
frc = config->getArrayPointer(DataStorage::dslForce); |
246 |
< |
pos = config->getArrayPointer(DataStorage::dslPosition); |
247 |
< |
trq = config->getArrayPointer(DataStorage::dslTorque); |
248 |
< |
A = config->getArrayPointer(DataStorage::dslAmat); |
249 |
< |
electroFrame = config->getArrayPointer(DataStorage::dslElectroFrame); |
513 |
> |
int loopStart, loopEnd; |
514 |
|
|
515 |
< |
//calculate the center of mass of cutoff group |
516 |
< |
SimInfo::MoleculeIterator mi; |
517 |
< |
Molecule* mol; |
518 |
< |
Molecule::CutoffGroupIterator ci; |
519 |
< |
CutoffGroup* cg; |
520 |
< |
Vector3d com; |
521 |
< |
std::vector<Vector3d> rcGroup; |
515 |
> |
loopEnd = PAIR_LOOP; |
516 |
> |
if (info_->requiresPrepair() ) { |
517 |
> |
loopStart = PREPAIR_LOOP; |
518 |
> |
} else { |
519 |
> |
loopStart = PAIR_LOOP; |
520 |
> |
} |
521 |
> |
|
522 |
|
|
523 |
< |
if(info_->getNCutoffGroups() > 0){ |
524 |
< |
|
525 |
< |
for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) { |
526 |
< |
for(cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { |
527 |
< |
cg->getCOM(com); |
528 |
< |
rcGroup.push_back(com); |
523 |
> |
for (int iLoop = loopStart; iLoop <= loopEnd; iLoop++) { |
524 |
> |
|
525 |
> |
if (iLoop == loopStart) { |
526 |
> |
bool update_nlist = fDecomp_->checkNeighborList(); |
527 |
> |
if (update_nlist) |
528 |
> |
neighborList = fDecomp_->buildNeighborList(); |
529 |
> |
} |
530 |
> |
|
531 |
> |
for (vector<pair<int, int> >::iterator it = neighborList.begin(); |
532 |
> |
it != neighborList.end(); ++it) { |
533 |
> |
|
534 |
> |
cg1 = (*it).first; |
535 |
> |
cg2 = (*it).second; |
536 |
> |
|
537 |
> |
cuts = fDecomp_->getGroupCutoffs(cg1, cg2); |
538 |
> |
|
539 |
> |
d_grp = fDecomp_->getIntergroupVector(cg1, cg2); |
540 |
> |
curSnapshot->wrapVector(d_grp); |
541 |
> |
rgrpsq = d_grp.lengthSquare(); |
542 |
> |
|
543 |
> |
rCutSq = cuts.second; |
544 |
> |
|
545 |
> |
if (rgrpsq < rCutSq) { |
546 |
> |
idat.rcut = &cuts.first; |
547 |
> |
if (iLoop == PAIR_LOOP) { |
548 |
> |
vij *= 0.0; |
549 |
> |
fij = V3Zero; |
550 |
> |
} |
551 |
> |
|
552 |
> |
in_switching_region = switcher_->getSwitch(rgrpsq, sw, dswdr, |
553 |
> |
rgrp); |
554 |
> |
|
555 |
> |
idat.sw = &sw; |
556 |
> |
|
557 |
> |
atomListRow = fDecomp_->getAtomsInGroupRow(cg1); |
558 |
> |
atomListColumn = fDecomp_->getAtomsInGroupColumn(cg2); |
559 |
> |
|
560 |
> |
for (vector<int>::iterator ia = atomListRow.begin(); |
561 |
> |
ia != atomListRow.end(); ++ia) { |
562 |
> |
atom1 = (*ia); |
563 |
> |
|
564 |
> |
for (vector<int>::iterator jb = atomListColumn.begin(); |
565 |
> |
jb != atomListColumn.end(); ++jb) { |
566 |
> |
atom2 = (*jb); |
567 |
> |
|
568 |
> |
cerr << "doing atoms " << atom1 << " " << atom2 << "\n"; |
569 |
> |
if (!fDecomp_->skipAtomPair(atom1, atom2)) { |
570 |
> |
|
571 |
> |
vpair = 0.0; |
572 |
> |
|
573 |
> |
cerr << "filling idat atoms " << atom1 << " " << atom2 << "\n"; |
574 |
> |
idat = fDecomp_->fillInteractionData(atom1, atom2); |
575 |
> |
cerr << "done with idat\n"; |
576 |
> |
|
577 |
> |
topoDist = fDecomp_->getTopologicalDistance(atom1, atom2); |
578 |
> |
vdwMult = vdwScale_[topoDist]; |
579 |
> |
electroMult = electrostaticScale_[topoDist]; |
580 |
> |
|
581 |
> |
idat.vdwMult = &vdwMult; |
582 |
> |
idat.electroMult = &electroMult; |
583 |
> |
idat.pot = &pot; |
584 |
> |
idat.vpair = &vpair; |
585 |
> |
|
586 |
> |
if (atomListRow.size() == 1 && atomListColumn.size() == 1) { |
587 |
> |
idat.d = &d_grp; |
588 |
> |
idat.r2 = &rgrpsq; |
589 |
> |
} else { |
590 |
> |
d = fDecomp_->getInteratomicVector(atom1, atom2); |
591 |
> |
curSnapshot->wrapVector( d ); |
592 |
> |
r2 = d.lengthSquare(); |
593 |
> |
idat.d = &d; |
594 |
> |
idat.r2 = &r2; |
595 |
> |
} |
596 |
> |
|
597 |
> |
cerr << "d = " << d << "\n"; |
598 |
> |
cerr << "r2 = " << r2 << "\n"; |
599 |
> |
r = sqrt( r2 ); |
600 |
> |
idat.rij = &r; |
601 |
> |
|
602 |
> |
if (iLoop == PREPAIR_LOOP) { |
603 |
> |
interactionMan_->doPrePair(idat); |
604 |
> |
} else { |
605 |
> |
cerr << "doing doPair " << atom1 << " " << atom2 << " " << r << "\n"; |
606 |
> |
interactionMan_->doPair(idat); |
607 |
> |
fDecomp_->unpackInteractionData(idat, atom1, atom2); |
608 |
> |
vij += *(idat.vpair); |
609 |
> |
fij += *(idat.f1); |
610 |
> |
tau -= outProduct( *(idat.d), *(idat.f1)); |
611 |
> |
} |
612 |
> |
} |
613 |
> |
} |
614 |
> |
} |
615 |
> |
|
616 |
> |
if (iLoop == PAIR_LOOP) { |
617 |
> |
if (in_switching_region) { |
618 |
> |
swderiv = vij * dswdr / rgrp; |
619 |
> |
fg = swderiv * d_grp; |
620 |
> |
|
621 |
> |
fij += fg; |
622 |
> |
|
623 |
> |
if (atomListRow.size() == 1 && atomListColumn.size() == 1) { |
624 |
> |
tau -= outProduct( *(idat.d), fg); |
625 |
> |
} |
626 |
> |
|
627 |
> |
for (vector<int>::iterator ia = atomListRow.begin(); |
628 |
> |
ia != atomListRow.end(); ++ia) { |
629 |
> |
atom1 = (*ia); |
630 |
> |
mf = fDecomp_->getMassFactorRow(atom1); |
631 |
> |
// fg is the force on atom ia due to cutoff group's |
632 |
> |
// presence in switching region |
633 |
> |
fg = swderiv * d_grp * mf; |
634 |
> |
fDecomp_->addForceToAtomRow(atom1, fg); |
635 |
> |
|
636 |
> |
if (atomListRow.size() > 1) { |
637 |
> |
if (info_->usesAtomicVirial()) { |
638 |
> |
// find the distance between the atom |
639 |
> |
// and the center of the cutoff group: |
640 |
> |
dag = fDecomp_->getAtomToGroupVectorRow(atom1, cg1); |
641 |
> |
tau -= outProduct(dag, fg); |
642 |
> |
} |
643 |
> |
} |
644 |
> |
} |
645 |
> |
for (vector<int>::iterator jb = atomListColumn.begin(); |
646 |
> |
jb != atomListColumn.end(); ++jb) { |
647 |
> |
atom2 = (*jb); |
648 |
> |
mf = fDecomp_->getMassFactorColumn(atom2); |
649 |
> |
// fg is the force on atom jb due to cutoff group's |
650 |
> |
// presence in switching region |
651 |
> |
fg = -swderiv * d_grp * mf; |
652 |
> |
fDecomp_->addForceToAtomColumn(atom2, fg); |
653 |
> |
|
654 |
> |
if (atomListColumn.size() > 1) { |
655 |
> |
if (info_->usesAtomicVirial()) { |
656 |
> |
// find the distance between the atom |
657 |
> |
// and the center of the cutoff group: |
658 |
> |
dag = fDecomp_->getAtomToGroupVectorColumn(atom2, cg2); |
659 |
> |
tau -= outProduct(dag, fg); |
660 |
> |
} |
661 |
> |
} |
662 |
> |
} |
663 |
> |
} |
664 |
> |
//if (!SIM_uses_AtomicVirial) { |
665 |
> |
// tau -= outProduct(d_grp, fij); |
666 |
> |
//} |
667 |
> |
} |
668 |
|
} |
669 |
< |
}// end for (mol) |
670 |
< |
|
671 |
< |
rc = rcGroup[0].getArrayPointer(); |
672 |
< |
} else { |
673 |
< |
// center of mass of the group is the same as position of the atom if cutoff group does not exist |
674 |
< |
rc = pos; |
669 |
> |
} |
670 |
> |
|
671 |
> |
if (iLoop == PREPAIR_LOOP) { |
672 |
> |
if (info_->requiresPrepair()) { |
673 |
> |
fDecomp_->collectIntermediateData(); |
674 |
> |
|
675 |
> |
for (int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) { |
676 |
> |
sdat = fDecomp_->fillSelfData(atom1); |
677 |
> |
interactionMan_->doPreForce(sdat); |
678 |
> |
} |
679 |
> |
|
680 |
> |
fDecomp_->distributeIntermediateData(); |
681 |
> |
} |
682 |
> |
} |
683 |
> |
|
684 |
|
} |
273 |
– |
|
274 |
– |
//initialize data before passing to fortran |
275 |
– |
RealType longRangePotential[LR_POT_TYPES]; |
276 |
– |
RealType lrPot = 0.0; |
685 |
|
|
686 |
< |
Mat3x3d tau; |
687 |
< |
short int passedCalcPot = needPotential; |
688 |
< |
short int passedCalcStress = needStress; |
689 |
< |
int isError = 0; |
686 |
> |
fDecomp_->collectData(); |
687 |
> |
|
688 |
> |
if ( info_->requiresSkipCorrection() ) { |
689 |
> |
|
690 |
> |
for (int atom1 = 0; atom1 < fDecomp_->getNAtomsInRow(); atom1++) { |
691 |
|
|
692 |
< |
for (int i=0; i<LR_POT_TYPES;i++){ |
693 |
< |
longRangePotential[i]=0.0; //Initialize array |
692 |
> |
vector<int> skipList = fDecomp_->getSkipsForAtom( atom1 ); |
693 |
> |
|
694 |
> |
for (vector<int>::iterator jb = skipList.begin(); |
695 |
> |
jb != skipList.end(); ++jb) { |
696 |
> |
|
697 |
> |
atom2 = (*jb); |
698 |
> |
idat = fDecomp_->fillSkipData(atom1, atom2); |
699 |
> |
interactionMan_->doSkipCorrection(idat); |
700 |
> |
|
701 |
> |
} |
702 |
> |
} |
703 |
|
} |
704 |
+ |
|
705 |
+ |
if (info_->requiresSelfCorrection()) { |
706 |
|
|
707 |
< |
doForceLoop( pos, |
708 |
< |
rc, |
709 |
< |
A, |
710 |
< |
electroFrame, |
291 |
< |
frc, |
292 |
< |
trq, |
293 |
< |
tau.getArrayPointer(), |
294 |
< |
longRangePotential, |
295 |
< |
&passedCalcPot, |
296 |
< |
&passedCalcStress, |
297 |
< |
&isError ); |
707 |
> |
for (int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) { |
708 |
> |
sdat = fDecomp_->fillSelfData(atom1); |
709 |
> |
interactionMan_->doSelfCorrection(sdat); |
710 |
> |
} |
711 |
|
|
299 |
– |
if( isError ){ |
300 |
– |
sprintf( painCave.errMsg, |
301 |
– |
"Error returned from the fortran force calculation.\n" ); |
302 |
– |
painCave.isFatal = 1; |
303 |
– |
simError(); |
712 |
|
} |
305 |
– |
for (int i=0; i<LR_POT_TYPES;i++){ |
306 |
– |
lrPot += longRangePotential[i]; //Quick hack |
307 |
– |
} |
713 |
|
|
714 |
+ |
longRangePotential = fDecomp_->getLongRangePotential(); |
715 |
+ |
lrPot = longRangePotential.sum(); |
716 |
+ |
|
717 |
|
//store the tau and long range potential |
718 |
|
curSnapshot->statData[Stats::LONG_RANGE_POTENTIAL] = lrPot; |
719 |
< |
curSnapshot->statData[Stats::VANDERWAALS_POTENTIAL] = longRangePotential[VDW_POT]; |
720 |
< |
curSnapshot->statData[Stats::ELECTROSTATIC_POTENTIAL] = longRangePotential[ELECTROSTATIC_POT]; |
313 |
< |
|
314 |
< |
curSnapshot->statData.setTau(tau); |
719 |
> |
curSnapshot->statData[Stats::VANDERWAALS_POTENTIAL] = longRangePotential[VANDERWAALS_FAMILY]; |
720 |
> |
curSnapshot->statData[Stats::ELECTROSTATIC_POTENTIAL] = longRangePotential[ELECTROSTATIC_FAMILY]; |
721 |
|
} |
722 |
|
|
723 |
< |
|
723 |
> |
|
724 |
|
void ForceManager::postCalculation() { |
725 |
|
SimInfo::MoleculeIterator mi; |
726 |
|
Molecule* mol; |
727 |
|
Molecule::RigidBodyIterator rbIter; |
728 |
|
RigidBody* rb; |
729 |
+ |
Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); |
730 |
|
|
731 |
|
// collect the atomic forces onto rigid bodies |
732 |
< |
for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) { |
733 |
< |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
734 |
< |
rb->calcForcesAndTorques(); |
732 |
> |
|
733 |
> |
for (mol = info_->beginMolecule(mi); mol != NULL; |
734 |
> |
mol = info_->nextMolecule(mi)) { |
735 |
> |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; |
736 |
> |
rb = mol->nextRigidBody(rbIter)) { |
737 |
> |
Mat3x3d rbTau = rb->calcForcesAndTorquesAndVirial(); |
738 |
> |
tau += rbTau; |
739 |
|
} |
740 |
|
} |
741 |
< |
|
741 |
> |
|
742 |
> |
#ifdef IS_MPI |
743 |
> |
Mat3x3d tmpTau(tau); |
744 |
> |
MPI_Allreduce(tmpTau.getArrayPointer(), tau.getArrayPointer(), |
745 |
> |
9, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); |
746 |
> |
#endif |
747 |
> |
curSnapshot->statData.setTau(tau); |
748 |
|
} |
749 |
|
|
750 |
< |
} //end namespace oopse |
750 |
> |
} //end namespace OpenMD |