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