1 |
|
#include <algorithm> |
2 |
< |
#include <cstdlib> |
2 |
> |
#include <stdlib.h> |
3 |
|
#include <iostream> |
4 |
< |
#include <cmath> |
4 |
> |
#include <math.h> |
5 |
|
#include <string> |
6 |
|
#include <sprng.h> |
7 |
|
#include "SimSetup.hpp" |
9 |
|
#include "parse_me.h" |
10 |
|
#include "Integrator.hpp" |
11 |
|
#include "simError.h" |
12 |
+ |
#include "RigidBody.hpp" |
13 |
+ |
//#include "ConjugateMinimizer.hpp" |
14 |
+ |
#include "OOPSEMinimizer.hpp" |
15 |
|
|
16 |
|
#ifdef IS_MPI |
17 |
|
#include "mpiBASS.h" |
27 |
|
#define NPTxyz_ENS 4 |
28 |
|
|
29 |
|
|
30 |
< |
#define FF_DUFF 0 |
31 |
< |
#define FF_LJ 1 |
32 |
< |
#define FF_EAM 2 |
30 |
> |
#define FF_DUFF 0 |
31 |
> |
#define FF_LJ 1 |
32 |
> |
#define FF_EAM 2 |
33 |
> |
#define FF_H2O 3 |
34 |
|
|
35 |
|
using namespace std; |
36 |
|
|
37 |
+ |
/** |
38 |
+ |
* Check whether dividend is divisble by divisor or not |
39 |
+ |
*/ |
40 |
+ |
bool isDivisible(double dividend, double divisor){ |
41 |
+ |
double tolerance = 0.000001; |
42 |
+ |
double quotient; |
43 |
+ |
double diff; |
44 |
+ |
int intQuotient; |
45 |
+ |
|
46 |
+ |
quotient = dividend / divisor; |
47 |
+ |
|
48 |
+ |
if (quotient < 0) |
49 |
+ |
quotient = -quotient; |
50 |
+ |
|
51 |
+ |
intQuotient = int (quotient + tolerance); |
52 |
+ |
|
53 |
+ |
diff = fabs(fabs(dividend) - intQuotient * fabs(divisor)); |
54 |
+ |
|
55 |
+ |
if (diff <= tolerance) |
56 |
+ |
return true; |
57 |
+ |
else |
58 |
+ |
return false; |
59 |
+ |
} |
60 |
+ |
|
61 |
|
SimSetup::SimSetup(){ |
62 |
|
|
63 |
|
initSuspend = false; |
147 |
|
// make the output filenames |
148 |
|
|
149 |
|
makeOutNames(); |
150 |
< |
|
123 |
< |
// make the integrator |
124 |
< |
|
125 |
< |
makeIntegrator(); |
126 |
< |
|
150 |
> |
|
151 |
|
#ifdef IS_MPI |
152 |
|
mpiSim->mpiRefresh(); |
153 |
|
#endif |
155 |
|
// initialize the Fortran |
156 |
|
|
157 |
|
initFortran(); |
158 |
+ |
|
159 |
+ |
if (globals->haveMinimizer()) |
160 |
+ |
// make minimizer |
161 |
+ |
makeMinimizer(); |
162 |
+ |
else |
163 |
+ |
// make the integrator |
164 |
+ |
makeIntegrator(); |
165 |
+ |
|
166 |
|
} |
167 |
|
|
168 |
|
|
169 |
|
void SimSetup::makeMolecules(void){ |
170 |
< |
int k; |
171 |
< |
int i, j, exI, exJ, tempEx, stampID, atomOffset, excludeOffset; |
170 |
> |
int i, j, k; |
171 |
> |
int exI, exJ, exK, exL, slI, slJ; |
172 |
> |
int tempI, tempJ, tempK, tempL; |
173 |
> |
int molI; |
174 |
> |
int stampID, atomOffset, rbOffset; |
175 |
|
molInit molInfo; |
176 |
|
DirectionalAtom* dAtom; |
177 |
+ |
RigidBody* myRB; |
178 |
+ |
StuntDouble* mySD; |
179 |
|
LinkedAssign* extras; |
180 |
|
LinkedAssign* current_extra; |
181 |
|
AtomStamp* currentAtom; |
182 |
|
BondStamp* currentBond; |
183 |
|
BendStamp* currentBend; |
184 |
|
TorsionStamp* currentTorsion; |
185 |
< |
|
185 |
> |
RigidBodyStamp* currentRigidBody; |
186 |
> |
CutoffGroupStamp* currentCutoffGroup; |
187 |
> |
CutoffGroup* myCutoffGroup; |
188 |
> |
|
189 |
|
bond_pair* theBonds; |
190 |
|
bend_set* theBends; |
191 |
|
torsion_set* theTorsions; |
192 |
|
|
193 |
+ |
set<int> skipList; |
194 |
|
|
195 |
+ |
double phi, theta, psi; |
196 |
+ |
char* molName; |
197 |
+ |
char rbName[100]; |
198 |
+ |
|
199 |
|
//init the forceField paramters |
200 |
|
|
201 |
|
the_ff->readParams(); |
202 |
|
|
158 |
– |
|
203 |
|
// init the atoms |
204 |
|
|
205 |
< |
double ux, uy, uz, u, uSqr; |
205 |
> |
int nMembers, nNew, rb1, rb2; |
206 |
|
|
207 |
|
for (k = 0; k < nInfo; k++){ |
208 |
|
the_ff->setSimInfo(&(info[k])); |
209 |
|
|
210 |
|
atomOffset = 0; |
211 |
< |
excludeOffset = 0; |
211 |
> |
|
212 |
|
for (i = 0; i < info[k].n_mol; i++){ |
213 |
|
stampID = info[k].molecules[i].getStampID(); |
214 |
+ |
molName = comp_stamps[stampID]->getID(); |
215 |
|
|
216 |
|
molInfo.nAtoms = comp_stamps[stampID]->getNAtoms(); |
217 |
|
molInfo.nBonds = comp_stamps[stampID]->getNBonds(); |
218 |
|
molInfo.nBends = comp_stamps[stampID]->getNBends(); |
219 |
|
molInfo.nTorsions = comp_stamps[stampID]->getNTorsions(); |
220 |
< |
molInfo.nExcludes = molInfo.nBonds + molInfo.nBends + molInfo.nTorsions; |
221 |
< |
|
220 |
> |
molInfo.nRigidBodies = comp_stamps[stampID]->getNRigidBodies(); |
221 |
> |
molInfo.nCutoffGroups = comp_stamps[stampID]->getNCutoffGroups(); |
222 |
> |
|
223 |
|
molInfo.myAtoms = &(info[k].atoms[atomOffset]); |
178 |
– |
molInfo.myExcludes = &(info[k].excludes[excludeOffset]); |
179 |
– |
molInfo.myBonds = new Bond * [molInfo.nBonds]; |
180 |
– |
molInfo.myBends = new Bend * [molInfo.nBends]; |
181 |
– |
molInfo.myTorsions = new Torsion * [molInfo.nTorsions]; |
224 |
|
|
225 |
+ |
if (molInfo.nBonds > 0) |
226 |
+ |
molInfo.myBonds = new (Bond *) [molInfo.nBonds]; |
227 |
+ |
else |
228 |
+ |
molInfo.myBonds = NULL; |
229 |
+ |
|
230 |
+ |
if (molInfo.nBends > 0) |
231 |
+ |
molInfo.myBends = new (Bend *) [molInfo.nBends]; |
232 |
+ |
else |
233 |
+ |
molInfo.myBends = NULL; |
234 |
+ |
|
235 |
+ |
if (molInfo.nTorsions > 0) |
236 |
+ |
molInfo.myTorsions = new (Torsion *) [molInfo.nTorsions]; |
237 |
+ |
else |
238 |
+ |
molInfo.myTorsions = NULL; |
239 |
+ |
|
240 |
|
theBonds = new bond_pair[molInfo.nBonds]; |
241 |
|
theBends = new bend_set[molInfo.nBends]; |
242 |
|
theTorsions = new torsion_set[molInfo.nTorsions]; |
243 |
< |
|
243 |
> |
|
244 |
|
// make the Atoms |
245 |
|
|
246 |
|
for (j = 0; j < molInfo.nAtoms; j++){ |
247 |
|
currentAtom = comp_stamps[stampID]->getAtom(j); |
248 |
+ |
|
249 |
|
if (currentAtom->haveOrientation()){ |
250 |
|
dAtom = new DirectionalAtom((j + atomOffset), |
251 |
|
info[k].getConfiguration()); |
252 |
|
info[k].n_oriented++; |
253 |
|
molInfo.myAtoms[j] = dAtom; |
254 |
|
|
255 |
< |
ux = currentAtom->getOrntX(); |
256 |
< |
uy = currentAtom->getOrntY(); |
257 |
< |
uz = currentAtom->getOrntZ(); |
255 |
> |
// Directional Atoms have standard unit vectors which are oriented |
256 |
> |
// in space using the three Euler angles. We assume the standard |
257 |
> |
// unit vector was originally along the z axis below. |
258 |
|
|
259 |
< |
uSqr = (ux * ux) + (uy * uy) + (uz * uz); |
259 |
> |
phi = currentAtom->getEulerPhi() * M_PI / 180.0; |
260 |
> |
theta = currentAtom->getEulerTheta() * M_PI / 180.0; |
261 |
> |
psi = currentAtom->getEulerPsi()* M_PI / 180.0; |
262 |
|
|
263 |
< |
u = sqrt(uSqr); |
264 |
< |
ux = ux / u; |
205 |
< |
uy = uy / u; |
206 |
< |
uz = uz / u; |
207 |
< |
|
208 |
< |
dAtom->setSUx(ux); |
209 |
< |
dAtom->setSUy(uy); |
210 |
< |
dAtom->setSUz(uz); |
263 |
> |
dAtom->setUnitFrameFromEuler(phi, theta, psi); |
264 |
> |
|
265 |
|
} |
266 |
|
else{ |
267 |
< |
molInfo.myAtoms[j] = new GeneralAtom((j + atomOffset), |
268 |
< |
info[k].getConfiguration()); |
267 |
> |
|
268 |
> |
molInfo.myAtoms[j] = new Atom((j + atomOffset), info[k].getConfiguration()); |
269 |
> |
|
270 |
|
} |
216 |
– |
molInfo.myAtoms[j]->setType(currentAtom->getType()); |
271 |
|
|
272 |
+ |
molInfo.myAtoms[j]->setType(currentAtom->getType()); |
273 |
|
#ifdef IS_MPI |
274 |
|
|
275 |
< |
molInfo.myAtoms[j]->setGlobalIndex(globalIndex[j + atomOffset]); |
275 |
> |
molInfo.myAtoms[j]->setGlobalIndex(globalAtomIndex[j + atomOffset]); |
276 |
|
|
277 |
|
#endif // is_mpi |
278 |
|
} |
283 |
|
theBonds[j].a = currentBond->getA() + atomOffset; |
284 |
|
theBonds[j].b = currentBond->getB() + atomOffset; |
285 |
|
|
286 |
< |
exI = theBonds[j].a; |
287 |
< |
exJ = theBonds[j].b; |
286 |
> |
tempI = theBonds[j].a; |
287 |
> |
tempJ = theBonds[j].b; |
288 |
|
|
234 |
– |
// exclude_I must always be the smaller of the pair |
235 |
– |
if (exI > exJ){ |
236 |
– |
tempEx = exI; |
237 |
– |
exI = exJ; |
238 |
– |
exJ = tempEx; |
239 |
– |
} |
289 |
|
#ifdef IS_MPI |
290 |
< |
tempEx = exI; |
291 |
< |
exI = info[k].atoms[tempEx]->getGlobalIndex() + 1; |
292 |
< |
tempEx = exJ; |
293 |
< |
exJ = info[k].atoms[tempEx]->getGlobalIndex() + 1; |
290 |
> |
exI = info[k].atoms[tempI]->getGlobalIndex() + 1; |
291 |
> |
exJ = info[k].atoms[tempJ]->getGlobalIndex() + 1; |
292 |
> |
#else |
293 |
> |
exI = tempI + 1; |
294 |
> |
exJ = tempJ + 1; |
295 |
> |
#endif |
296 |
|
|
297 |
< |
info[k].excludes[j + excludeOffset]->setPair(exI, exJ); |
247 |
< |
#else // isn't MPI |
248 |
< |
|
249 |
< |
info[k].excludes[j + excludeOffset]->setPair((exI + 1), (exJ + 1)); |
250 |
< |
#endif //is_mpi |
297 |
> |
info[k].excludes->addPair(exI, exJ); |
298 |
|
} |
252 |
– |
excludeOffset += molInfo.nBonds; |
299 |
|
|
300 |
|
//make the bends |
301 |
|
for (j = 0; j < molInfo.nBends; j++){ |
345 |
|
} |
346 |
|
} |
347 |
|
|
348 |
< |
if (!theBends[j].isGhost){ |
349 |
< |
exI = theBends[j].a; |
350 |
< |
exJ = theBends[j].c; |
351 |
< |
} |
352 |
< |
else{ |
307 |
< |
exI = theBends[j].a; |
308 |
< |
exJ = theBends[j].b; |
309 |
< |
} |
310 |
< |
|
311 |
< |
// exclude_I must always be the smaller of the pair |
312 |
< |
if (exI > exJ){ |
313 |
< |
tempEx = exI; |
314 |
< |
exI = exJ; |
315 |
< |
exJ = tempEx; |
316 |
< |
} |
348 |
> |
if (theBends[j].isGhost) { |
349 |
> |
|
350 |
> |
tempI = theBends[j].a; |
351 |
> |
tempJ = theBends[j].b; |
352 |
> |
|
353 |
|
#ifdef IS_MPI |
354 |
< |
tempEx = exI; |
355 |
< |
exI = info[k].atoms[tempEx]->getGlobalIndex() + 1; |
356 |
< |
tempEx = exJ; |
357 |
< |
exJ = info[k].atoms[tempEx]->getGlobalIndex() + 1; |
354 |
> |
exI = info[k].atoms[tempI]->getGlobalIndex() + 1; |
355 |
> |
exJ = info[k].atoms[tempJ]->getGlobalIndex() + 1; |
356 |
> |
#else |
357 |
> |
exI = tempI + 1; |
358 |
> |
exJ = tempJ + 1; |
359 |
> |
#endif |
360 |
> |
info[k].excludes->addPair(exI, exJ); |
361 |
|
|
362 |
< |
info[k].excludes[j + excludeOffset]->setPair(exI, exJ); |
363 |
< |
#else // isn't MPI |
364 |
< |
info[k].excludes[j + excludeOffset]->setPair((exI + 1), (exJ + 1)); |
365 |
< |
#endif //is_mpi |
362 |
> |
} else { |
363 |
> |
|
364 |
> |
tempI = theBends[j].a; |
365 |
> |
tempJ = theBends[j].b; |
366 |
> |
tempK = theBends[j].c; |
367 |
> |
|
368 |
> |
#ifdef IS_MPI |
369 |
> |
exI = info[k].atoms[tempI]->getGlobalIndex() + 1; |
370 |
> |
exJ = info[k].atoms[tempJ]->getGlobalIndex() + 1; |
371 |
> |
exK = info[k].atoms[tempK]->getGlobalIndex() + 1; |
372 |
> |
#else |
373 |
> |
exI = tempI + 1; |
374 |
> |
exJ = tempJ + 1; |
375 |
> |
exK = tempK + 1; |
376 |
> |
#endif |
377 |
> |
|
378 |
> |
info[k].excludes->addPair(exI, exK); |
379 |
> |
info[k].excludes->addPair(exI, exJ); |
380 |
> |
info[k].excludes->addPair(exJ, exK); |
381 |
> |
} |
382 |
|
} |
328 |
– |
excludeOffset += molInfo.nBends; |
383 |
|
|
384 |
|
for (j = 0; j < molInfo.nTorsions; j++){ |
385 |
|
currentTorsion = comp_stamps[stampID]->getTorsion(j); |
388 |
|
theTorsions[j].c = currentTorsion->getC() + atomOffset; |
389 |
|
theTorsions[j].d = currentTorsion->getD() + atomOffset; |
390 |
|
|
391 |
< |
exI = theTorsions[j].a; |
392 |
< |
exJ = theTorsions[j].d; |
391 |
> |
tempI = theTorsions[j].a; |
392 |
> |
tempJ = theTorsions[j].b; |
393 |
> |
tempK = theTorsions[j].c; |
394 |
> |
tempL = theTorsions[j].d; |
395 |
|
|
396 |
< |
// exclude_I must always be the smaller of the pair |
397 |
< |
if (exI > exJ){ |
398 |
< |
tempEx = exI; |
399 |
< |
exI = exJ; |
400 |
< |
exJ = tempEx; |
396 |
> |
#ifdef IS_MPI |
397 |
> |
exI = info[k].atoms[tempI]->getGlobalIndex() + 1; |
398 |
> |
exJ = info[k].atoms[tempJ]->getGlobalIndex() + 1; |
399 |
> |
exK = info[k].atoms[tempK]->getGlobalIndex() + 1; |
400 |
> |
exL = info[k].atoms[tempL]->getGlobalIndex() + 1; |
401 |
> |
#else |
402 |
> |
exI = tempI + 1; |
403 |
> |
exJ = tempJ + 1; |
404 |
> |
exK = tempK + 1; |
405 |
> |
exL = tempL + 1; |
406 |
> |
#endif |
407 |
> |
|
408 |
> |
info[k].excludes->addPair(exI, exJ); |
409 |
> |
info[k].excludes->addPair(exI, exK); |
410 |
> |
info[k].excludes->addPair(exI, exL); |
411 |
> |
info[k].excludes->addPair(exJ, exK); |
412 |
> |
info[k].excludes->addPair(exJ, exL); |
413 |
> |
info[k].excludes->addPair(exK, exL); |
414 |
> |
} |
415 |
> |
|
416 |
> |
|
417 |
> |
molInfo.myRigidBodies.clear(); |
418 |
> |
|
419 |
> |
for (j = 0; j < molInfo.nRigidBodies; j++){ |
420 |
> |
|
421 |
> |
currentRigidBody = comp_stamps[stampID]->getRigidBody(j); |
422 |
> |
nMembers = currentRigidBody->getNMembers(); |
423 |
> |
|
424 |
> |
// Create the Rigid Body: |
425 |
> |
|
426 |
> |
myRB = new RigidBody(); |
427 |
> |
|
428 |
> |
sprintf(rbName,"%s_RB_%d", molName, j); |
429 |
> |
myRB->setType(rbName); |
430 |
> |
|
431 |
> |
for (rb1 = 0; rb1 < nMembers; rb1++) { |
432 |
> |
|
433 |
> |
// molI is atom numbering inside this molecule |
434 |
> |
molI = currentRigidBody->getMember(rb1); |
435 |
> |
|
436 |
> |
// tempI is atom numbering on local processor |
437 |
> |
tempI = molI + atomOffset; |
438 |
> |
|
439 |
> |
// currentAtom is the AtomStamp (which we need for |
440 |
> |
// rigid body reference positions) |
441 |
> |
currentAtom = comp_stamps[stampID]->getAtom(molI); |
442 |
> |
|
443 |
> |
// When we add to the rigid body, add the atom itself and |
444 |
> |
// the stamp info: |
445 |
> |
|
446 |
> |
myRB->addAtom(info[k].atoms[tempI], currentAtom); |
447 |
> |
|
448 |
> |
// Add this atom to the Skip List for the integrators |
449 |
> |
#ifdef IS_MPI |
450 |
> |
slI = info[k].atoms[tempI]->getGlobalIndex(); |
451 |
> |
#else |
452 |
> |
slI = tempI; |
453 |
> |
#endif |
454 |
> |
skipList.insert(slI); |
455 |
> |
|
456 |
|
} |
457 |
+ |
|
458 |
+ |
for(rb1 = 0; rb1 < nMembers - 1; rb1++) { |
459 |
+ |
for(rb2 = rb1+1; rb2 < nMembers; rb2++) { |
460 |
+ |
|
461 |
+ |
tempI = currentRigidBody->getMember(rb1); |
462 |
+ |
tempJ = currentRigidBody->getMember(rb2); |
463 |
+ |
|
464 |
+ |
// Some explanation is required here. |
465 |
+ |
// Fortran indexing starts at 1, while c indexing starts at 0 |
466 |
+ |
// Also, in parallel computations, the GlobalIndex is |
467 |
+ |
// used for the exclude list: |
468 |
+ |
|
469 |
|
#ifdef IS_MPI |
470 |
< |
tempEx = exI; |
471 |
< |
exI = info[k].atoms[tempEx]->getGlobalIndex() + 1; |
472 |
< |
tempEx = exJ; |
473 |
< |
exJ = info[k].atoms[tempEx]->getGlobalIndex() + 1; |
470 |
> |
exI = molInfo.myAtoms[tempI]->getGlobalIndex() + 1; |
471 |
> |
exJ = molInfo.myAtoms[tempJ]->getGlobalIndex() + 1; |
472 |
> |
#else |
473 |
> |
exI = molInfo.myAtoms[tempI]->getIndex() + 1; |
474 |
> |
exJ = molInfo.myAtoms[tempJ]->getIndex() + 1; |
475 |
> |
#endif |
476 |
> |
|
477 |
> |
info[k].excludes->addPair(exI, exJ); |
478 |
> |
|
479 |
> |
} |
480 |
> |
} |
481 |
|
|
482 |
< |
info[k].excludes[j + excludeOffset]->setPair(exI, exJ); |
483 |
< |
#else // isn't MPI |
354 |
< |
info[k].excludes[j + excludeOffset]->setPair((exI + 1), (exJ + 1)); |
355 |
< |
#endif //is_mpi |
482 |
> |
molInfo.myRigidBodies.push_back(myRB); |
483 |
> |
info[k].rigidBodies.push_back(myRB); |
484 |
|
} |
485 |
< |
excludeOffset += molInfo.nTorsions; |
485 |
> |
|
486 |
|
|
487 |
+ |
//creat cutoff group for molecule |
488 |
+ |
molInfo.myCutoffGroups.clear(); |
489 |
+ |
for (j = 0; j < molInfo.nCutoffGroups; j++){ |
490 |
|
|
491 |
< |
// send the arrays off to the forceField for init. |
491 |
> |
currentCutoffGroup = comp_stamps[stampID]->getCutoffGroup(j); |
492 |
> |
nMembers = currentCutoffGroup->getNMembers(); |
493 |
|
|
494 |
+ |
myCutoffGroup = new CutoffGroup(); |
495 |
+ |
|
496 |
+ |
for (int cg = 0; cg < nMembers; cg++) { |
497 |
+ |
|
498 |
+ |
// molI is atom numbering inside this molecule |
499 |
+ |
molI = currentCutoffGroup->getMember(cg); |
500 |
+ |
|
501 |
+ |
// tempI is atom numbering on local processor |
502 |
+ |
tempI = molI + atomOffset; |
503 |
+ |
|
504 |
+ |
myCutoffGroup->addAtom(info[k].atoms[tempI]); |
505 |
+ |
} |
506 |
+ |
|
507 |
+ |
molInfo.myCutoffGroups.push_back(myCutoffGroup); |
508 |
+ |
}//end for (j = 0; j < molInfo.nCutoffGroups; j++) |
509 |
+ |
|
510 |
+ |
|
511 |
+ |
|
512 |
+ |
// After this is all set up, scan through the atoms to |
513 |
+ |
// see if they can be added to the integrableObjects: |
514 |
+ |
|
515 |
+ |
molInfo.myIntegrableObjects.clear(); |
516 |
+ |
|
517 |
+ |
|
518 |
+ |
for (j = 0; j < molInfo.nAtoms; j++){ |
519 |
+ |
|
520 |
+ |
#ifdef IS_MPI |
521 |
+ |
slJ = molInfo.myAtoms[j]->getGlobalIndex(); |
522 |
+ |
#else |
523 |
+ |
slJ = j+atomOffset; |
524 |
+ |
#endif |
525 |
+ |
|
526 |
+ |
// if they aren't on the skip list, then they can be integrated |
527 |
+ |
|
528 |
+ |
if (skipList.find(slJ) == skipList.end()) { |
529 |
+ |
mySD = (StuntDouble *) molInfo.myAtoms[j]; |
530 |
+ |
info[k].integrableObjects.push_back(mySD); |
531 |
+ |
molInfo.myIntegrableObjects.push_back(mySD); |
532 |
+ |
} |
533 |
+ |
} |
534 |
+ |
|
535 |
+ |
// all rigid bodies are integrated: |
536 |
+ |
|
537 |
+ |
for (j = 0; j < molInfo.nRigidBodies; j++) { |
538 |
+ |
mySD = (StuntDouble *) molInfo.myRigidBodies[j]; |
539 |
+ |
info[k].integrableObjects.push_back(mySD); |
540 |
+ |
molInfo.myIntegrableObjects.push_back(mySD); |
541 |
+ |
} |
542 |
+ |
|
543 |
+ |
|
544 |
+ |
// send the arrays off to the forceField for init. |
545 |
+ |
|
546 |
|
the_ff->initializeAtoms(molInfo.nAtoms, molInfo.myAtoms); |
547 |
|
the_ff->initializeBonds(molInfo.nBonds, molInfo.myBonds, theBonds); |
548 |
|
the_ff->initializeBends(molInfo.nBends, molInfo.myBends, theBends); |
549 |
|
the_ff->initializeTorsions(molInfo.nTorsions, molInfo.myTorsions, |
550 |
|
theTorsions); |
551 |
|
|
368 |
– |
|
552 |
|
info[k].molecules[i].initialize(molInfo); |
553 |
|
|
554 |
|
|
556 |
|
delete[] theBonds; |
557 |
|
delete[] theBends; |
558 |
|
delete[] theTorsions; |
559 |
< |
} |
559 |
> |
} |
560 |
|
} |
561 |
|
|
562 |
|
#ifdef IS_MPI |
566 |
|
|
567 |
|
// clean up the forcefield |
568 |
|
|
569 |
< |
the_ff->calcRcut(); |
569 |
> |
if (!globals->haveRcut()){ |
570 |
> |
|
571 |
> |
the_ff->calcRcut(); |
572 |
> |
|
573 |
> |
} else { |
574 |
> |
|
575 |
> |
the_ff->setRcut( globals->getRcut() ); |
576 |
> |
} |
577 |
> |
|
578 |
|
the_ff->cleanMe(); |
579 |
|
} |
580 |
|
|
775 |
|
} |
776 |
|
else if (!strcasecmp(force_field, "EAM")){ |
777 |
|
ffCase = FF_EAM; |
778 |
+ |
} |
779 |
+ |
else if (!strcasecmp(force_field, "WATER")){ |
780 |
+ |
ffCase = FF_H2O; |
781 |
|
} |
782 |
|
else{ |
783 |
|
sprintf(painCave.errMsg, "SimSetup Error. Unrecognized force field -> %s\n", |
807 |
|
} |
808 |
|
else{ |
809 |
|
sprintf(painCave.errMsg, |
810 |
< |
"SimSetup Warning. Unrecognized Ensemble -> %s, " |
811 |
< |
"reverting to NVE for this simulation.\n", |
810 |
> |
"SimSetup Warning. Unrecognized Ensemble -> %s \n" |
811 |
> |
"\treverting to NVE for this simulation.\n", |
812 |
|
ensemble); |
813 |
|
painCave.isFatal = 0; |
814 |
|
simError(); |
840 |
|
if (!the_components[i]->haveNMol()){ |
841 |
|
// we have a problem |
842 |
|
sprintf(painCave.errMsg, |
843 |
< |
"SimSetup Error. No global NMol or component NMol" |
844 |
< |
" given. Cannot calculate the number of atoms.\n"); |
843 |
> |
"SimSetup Error. No global NMol or component NMol given.\n" |
844 |
> |
"\tCannot calculate the number of atoms.\n"); |
845 |
|
painCave.isFatal = 1; |
846 |
|
simError(); |
847 |
|
} |
861 |
|
simError(); |
862 |
|
} |
863 |
|
|
864 |
+ |
//check whether sample time, status time, thermal time and reset time are divisble by dt |
865 |
+ |
if (globals->haveSampleTime() && !isDivisible(globals->getSampleTime(), globals->getDt())){ |
866 |
+ |
sprintf(painCave.errMsg, |
867 |
+ |
"Sample time is not divisible by dt.\n" |
868 |
+ |
"\tThis will result in samples that are not uniformly\n" |
869 |
+ |
"\tdistributed in time. If this is a problem, change\n" |
870 |
+ |
"\tyour sampleTime variable.\n"); |
871 |
+ |
painCave.isFatal = 0; |
872 |
+ |
simError(); |
873 |
+ |
} |
874 |
+ |
|
875 |
+ |
if (globals->haveStatusTime() && !isDivisible(globals->getStatusTime(), globals->getDt())){ |
876 |
+ |
sprintf(painCave.errMsg, |
877 |
+ |
"Status time is not divisible by dt.\n" |
878 |
+ |
"\tThis will result in status reports that are not uniformly\n" |
879 |
+ |
"\tdistributed in time. If this is a problem, change \n" |
880 |
+ |
"\tyour statusTime variable.\n"); |
881 |
+ |
painCave.isFatal = 0; |
882 |
+ |
simError(); |
883 |
+ |
} |
884 |
+ |
|
885 |
+ |
if (globals->haveThermalTime() && !isDivisible(globals->getThermalTime(), globals->getDt())){ |
886 |
+ |
sprintf(painCave.errMsg, |
887 |
+ |
"Thermal time is not divisible by dt.\n" |
888 |
+ |
"\tThis will result in thermalizations that are not uniformly\n" |
889 |
+ |
"\tdistributed in time. If this is a problem, change \n" |
890 |
+ |
"\tyour thermalTime variable.\n"); |
891 |
+ |
painCave.isFatal = 0; |
892 |
+ |
simError(); |
893 |
+ |
} |
894 |
+ |
|
895 |
+ |
if (globals->haveResetTime() && !isDivisible(globals->getResetTime(), globals->getDt())){ |
896 |
+ |
sprintf(painCave.errMsg, |
897 |
+ |
"Reset time is not divisible by dt.\n" |
898 |
+ |
"\tThis will result in integrator resets that are not uniformly\n" |
899 |
+ |
"\tdistributed in time. If this is a problem, change\n" |
900 |
+ |
"\tyour resetTime variable.\n"); |
901 |
+ |
painCave.isFatal = 0; |
902 |
+ |
simError(); |
903 |
+ |
} |
904 |
+ |
|
905 |
|
// set the status, sample, and thermal kick times |
906 |
|
|
907 |
|
for (i = 0; i < nInfo; i++){ |
908 |
|
if (globals->haveSampleTime()){ |
909 |
|
info[i].sampleTime = globals->getSampleTime(); |
910 |
|
info[i].statusTime = info[i].sampleTime; |
676 |
– |
info[i].thermalTime = info[i].sampleTime; |
911 |
|
} |
912 |
|
else{ |
913 |
|
info[i].sampleTime = globals->getRunTime(); |
914 |
|
info[i].statusTime = info[i].sampleTime; |
681 |
– |
info[i].thermalTime = info[i].sampleTime; |
915 |
|
} |
916 |
|
|
917 |
|
if (globals->haveStatusTime()){ |
920 |
|
|
921 |
|
if (globals->haveThermalTime()){ |
922 |
|
info[i].thermalTime = globals->getThermalTime(); |
923 |
+ |
} else { |
924 |
+ |
info[i].thermalTime = globals->getRunTime(); |
925 |
|
} |
926 |
|
|
927 |
|
info[i].resetIntegrator = 0; |
931 |
|
} |
932 |
|
|
933 |
|
// check for the temperature set flag |
934 |
< |
|
934 |
> |
|
935 |
|
if (globals->haveTempSet()) |
936 |
|
info[i].setTemp = globals->getTempSet(); |
937 |
|
|
938 |
< |
// get some of the tricky things that may still be in the globals |
938 |
> |
// check for the extended State init |
939 |
|
|
940 |
< |
double boxVector[3]; |
941 |
< |
if (globals->haveBox()){ |
942 |
< |
boxVector[0] = globals->getBox(); |
708 |
< |
boxVector[1] = globals->getBox(); |
709 |
< |
boxVector[2] = globals->getBox(); |
710 |
< |
|
711 |
< |
info[i].setBox(boxVector); |
712 |
< |
} |
713 |
< |
else if (globals->haveDensity()){ |
714 |
< |
double vol; |
715 |
< |
vol = (double) tot_nmol / globals->getDensity(); |
716 |
< |
boxVector[0] = pow(vol, (1.0 / 3.0)); |
717 |
< |
boxVector[1] = boxVector[0]; |
718 |
< |
boxVector[2] = boxVector[0]; |
719 |
< |
|
720 |
< |
info[i].setBox(boxVector); |
721 |
< |
} |
722 |
< |
else{ |
723 |
< |
if (!globals->haveBoxX()){ |
724 |
< |
sprintf(painCave.errMsg, |
725 |
< |
"SimSetup error, no periodic BoxX size given.\n"); |
726 |
< |
painCave.isFatal = 1; |
727 |
< |
simError(); |
728 |
< |
} |
729 |
< |
boxVector[0] = globals->getBoxX(); |
730 |
< |
|
731 |
< |
if (!globals->haveBoxY()){ |
732 |
< |
sprintf(painCave.errMsg, |
733 |
< |
"SimSetup error, no periodic BoxY size given.\n"); |
734 |
< |
painCave.isFatal = 1; |
735 |
< |
simError(); |
736 |
< |
} |
737 |
< |
boxVector[1] = globals->getBoxY(); |
738 |
< |
|
739 |
< |
if (!globals->haveBoxZ()){ |
740 |
< |
sprintf(painCave.errMsg, |
741 |
< |
"SimSetup error, no periodic BoxZ size given.\n"); |
742 |
< |
painCave.isFatal = 1; |
743 |
< |
simError(); |
744 |
< |
} |
745 |
< |
boxVector[2] = globals->getBoxZ(); |
746 |
< |
|
747 |
< |
info[i].setBox(boxVector); |
748 |
< |
} |
940 |
> |
info[i].useInitXSstate = globals->getUseInitXSstate(); |
941 |
> |
info[i].orthoTolerance = globals->getOrthoBoxTolerance(); |
942 |
> |
|
943 |
|
} |
944 |
< |
|
944 |
> |
|
945 |
|
//setup seed for random number generator |
946 |
|
int seedValue; |
947 |
|
|
981 |
|
for (int i = 0; i < nInfo; i++){ |
982 |
|
info[i].setSeed(seedValue); |
983 |
|
} |
984 |
< |
|
984 |
> |
|
985 |
|
#ifdef IS_MPI |
986 |
< |
strcpy(checkPointMsg, "Succesfully gathered all information from Bass\n"); |
986 |
> |
strcpy(checkPointMsg, "Successfully gathered all information from Bass\n"); |
987 |
|
MPIcheckPoint(); |
988 |
|
#endif // is_mpi |
989 |
|
} |
992 |
|
void SimSetup::finalInfoCheck(void){ |
993 |
|
int index; |
994 |
|
int usesDipoles; |
995 |
+ |
int usesCharges; |
996 |
|
int i; |
997 |
|
|
998 |
|
for (i = 0; i < nInfo; i++){ |
1004 |
|
usesDipoles = (info[i].atoms[index])->hasDipole(); |
1005 |
|
index++; |
1006 |
|
} |
1007 |
< |
|
1007 |
> |
index = 0; |
1008 |
> |
usesCharges = 0; |
1009 |
> |
while ((index < info[i].n_atoms) && !usesCharges){ |
1010 |
> |
usesCharges= (info[i].atoms[index])->hasCharge(); |
1011 |
> |
index++; |
1012 |
> |
} |
1013 |
|
#ifdef IS_MPI |
1014 |
|
int myUse = usesDipoles; |
1015 |
|
MPI_Allreduce(&myUse, &usesDipoles, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
1016 |
|
#endif //is_mpi |
1017 |
|
|
1018 |
< |
double theEcr, theEst; |
1018 |
> |
double theRcut, theRsw; |
1019 |
|
|
1020 |
|
if (globals->getUseRF()){ |
1021 |
|
info[i].useReactionField = 1; |
1022 |
|
|
1023 |
< |
if (!globals->haveECR()){ |
1023 |
> |
if (!globals->haveRcut()){ |
1024 |
|
sprintf(painCave.errMsg, |
1025 |
< |
"SimSetup Warning: using default value of 1/2 the smallest " |
1026 |
< |
"box length for the electrostaticCutoffRadius.\n" |
1027 |
< |
"I hope you have a very fast processor!\n"); |
1025 |
> |
"SimSetup Warning: No value was set for the cutoffRadius.\n" |
1026 |
> |
"\tOOPSE will use a default value of 15.0 angstroms" |
1027 |
> |
"\tfor the cutoffRadius.\n"); |
1028 |
|
painCave.isFatal = 0; |
1029 |
|
simError(); |
1030 |
< |
double smallest; |
831 |
< |
smallest = info[i].boxL[0]; |
832 |
< |
if (info[i].boxL[1] <= smallest) |
833 |
< |
smallest = info[i].boxL[1]; |
834 |
< |
if (info[i].boxL[2] <= smallest) |
835 |
< |
smallest = info[i].boxL[2]; |
836 |
< |
theEcr = 0.5 * smallest; |
1030 |
> |
theRcut = 15.0; |
1031 |
|
} |
1032 |
|
else{ |
1033 |
< |
theEcr = globals->getECR(); |
1033 |
> |
theRcut = globals->getRcut(); |
1034 |
|
} |
1035 |
|
|
1036 |
< |
if (!globals->haveEST()){ |
1036 |
> |
if (!globals->haveRsw()){ |
1037 |
|
sprintf(painCave.errMsg, |
1038 |
< |
"SimSetup Warning: using default value of 0.05 * the " |
1039 |
< |
"electrostaticCutoffRadius for the electrostaticSkinThickness\n"); |
1038 |
> |
"SimSetup Warning: No value was set for switchingRadius.\n" |
1039 |
> |
"\tOOPSE will use a default value of\n" |
1040 |
> |
"\t0.95 * cutoffRadius for the switchingRadius\n"); |
1041 |
|
painCave.isFatal = 0; |
1042 |
|
simError(); |
1043 |
< |
theEst = 0.05 * theEcr; |
1043 |
> |
theRsw = 0.95 * theRcut; |
1044 |
|
} |
1045 |
|
else{ |
1046 |
< |
theEst = globals->getEST(); |
1046 |
> |
theRsw = globals->getRsw(); |
1047 |
|
} |
1048 |
|
|
1049 |
< |
info[i].setEcr(theEcr, theEst); |
1049 |
> |
info[i].setDefaultRcut(theRcut, theRsw); |
1050 |
|
|
1051 |
|
if (!globals->haveDielectric()){ |
1052 |
|
sprintf(painCave.errMsg, |
1053 |
< |
"SimSetup Error: You are trying to use Reaction Field without" |
1054 |
< |
"setting a dielectric constant!\n"); |
1053 |
> |
"SimSetup Error: No Dielectric constant was set.\n" |
1054 |
> |
"\tYou are trying to use Reaction Field without" |
1055 |
> |
"\tsetting a dielectric constant!\n"); |
1056 |
|
painCave.isFatal = 1; |
1057 |
|
simError(); |
1058 |
|
} |
1059 |
|
info[i].dielectric = globals->getDielectric(); |
1060 |
|
} |
1061 |
|
else{ |
1062 |
< |
if (usesDipoles){ |
1063 |
< |
if (!globals->haveECR()){ |
1062 |
> |
if (usesDipoles || usesCharges){ |
1063 |
> |
|
1064 |
> |
if (!globals->haveRcut()){ |
1065 |
|
sprintf(painCave.errMsg, |
1066 |
< |
"SimSetup Warning: using default value of 1/2 the smallest " |
1067 |
< |
"box length for the electrostaticCutoffRadius.\n" |
1068 |
< |
"I hope you have a very fast processor!\n"); |
1066 |
> |
"SimSetup Warning: No value was set for the cutoffRadius.\n" |
1067 |
> |
"\tOOPSE will use a default value of 15.0 angstroms" |
1068 |
> |
"\tfor the cutoffRadius.\n"); |
1069 |
|
painCave.isFatal = 0; |
1070 |
|
simError(); |
1071 |
< |
double smallest; |
1072 |
< |
smallest = info[i].boxL[0]; |
876 |
< |
if (info[i].boxL[1] <= smallest) |
877 |
< |
smallest = info[i].boxL[1]; |
878 |
< |
if (info[i].boxL[2] <= smallest) |
879 |
< |
smallest = info[i].boxL[2]; |
880 |
< |
theEcr = 0.5 * smallest; |
881 |
< |
} |
1071 |
> |
theRcut = 15.0; |
1072 |
> |
} |
1073 |
|
else{ |
1074 |
< |
theEcr = globals->getECR(); |
1074 |
> |
theRcut = globals->getRcut(); |
1075 |
|
} |
1076 |
< |
|
1077 |
< |
if (!globals->haveEST()){ |
1076 |
> |
|
1077 |
> |
if (!globals->haveRsw()){ |
1078 |
|
sprintf(painCave.errMsg, |
1079 |
< |
"SimSetup Warning: using default value of 0.05 * the " |
1080 |
< |
"electrostaticCutoffRadius for the " |
1081 |
< |
"electrostaticSkinThickness\n"); |
1082 |
< |
painCave.isFatal = 0; |
1083 |
< |
simError(); |
1084 |
< |
theEst = 0.05 * theEcr; |
1079 |
> |
"SimSetup Warning: No value was set for switchingRadius.\n" |
1080 |
> |
"\tOOPSE will use a default value of\n" |
1081 |
> |
"\t0.95 * cutoffRadius for the switchingRadius\n"); |
1082 |
> |
painCave.isFatal = 0; |
1083 |
> |
simError(); |
1084 |
> |
theRsw = 0.95 * theRcut; |
1085 |
|
} |
1086 |
|
else{ |
1087 |
< |
theEst = globals->getEST(); |
1087 |
> |
theRsw = globals->getRsw(); |
1088 |
|
} |
1089 |
< |
|
1090 |
< |
info[i].setEcr(theEcr, theEst); |
1089 |
> |
|
1090 |
> |
info[i].setDefaultRcut(theRcut, theRsw); |
1091 |
> |
|
1092 |
|
} |
1093 |
|
} |
1094 |
|
} |
903 |
– |
|
1095 |
|
#ifdef IS_MPI |
1096 |
|
strcpy(checkPointMsg, "post processing checks out"); |
1097 |
|
MPIcheckPoint(); |
1098 |
|
#endif // is_mpi |
1099 |
|
} |
1100 |
< |
|
1100 |
> |
|
1101 |
|
void SimSetup::initSystemCoords(void){ |
1102 |
|
int i; |
1103 |
|
|
1125 |
|
delete fileInit; |
1126 |
|
} |
1127 |
|
else{ |
1128 |
< |
#ifdef IS_MPI |
938 |
< |
|
1128 |
> |
|
1129 |
|
// no init from bass |
1130 |
< |
|
1130 |
> |
|
1131 |
|
sprintf(painCave.errMsg, |
1132 |
< |
"Cannot intialize a parallel simulation without an initial configuration file.\n"); |
1132 |
> |
"Cannot intialize a simulation without an initial configuration file.\n"); |
1133 |
|
painCave.isFatal = 1;; |
1134 |
|
simError(); |
1135 |
< |
|
946 |
< |
#else |
947 |
< |
|
948 |
< |
initFromBass(); |
949 |
< |
|
950 |
< |
|
951 |
< |
#endif |
1135 |
> |
|
1136 |
|
} |
1137 |
|
|
1138 |
|
#ifdef IS_MPI |
1286 |
|
the_ff = new EAM_FF(); |
1287 |
|
break; |
1288 |
|
|
1289 |
+ |
case FF_H2O: |
1290 |
+ |
the_ff = new WATER(); |
1291 |
+ |
break; |
1292 |
+ |
|
1293 |
|
default: |
1294 |
|
sprintf(painCave.errMsg, |
1295 |
|
"SimSetup Error. Unrecognized force field in case statement.\n"); |
1310 |
|
LinkedMolStamp* headStamp = new LinkedMolStamp(); |
1311 |
|
LinkedMolStamp* currentStamp = NULL; |
1312 |
|
comp_stamps = new MoleculeStamp * [n_components]; |
1313 |
+ |
bool haveCutoffGroups; |
1314 |
|
|
1315 |
+ |
haveCutoffGroups = false; |
1316 |
+ |
|
1317 |
|
// make an array of molecule stamps that match the components used. |
1318 |
|
// also extract the used stamps out into a separate linked list |
1319 |
|
|
1348 |
|
headStamp->add(currentStamp); |
1349 |
|
comp_stamps[i] = headStamp->match(id); |
1350 |
|
} |
1351 |
+ |
|
1352 |
+ |
if(comp_stamps[i]->getNCutoffGroups() > 0) |
1353 |
+ |
haveCutoffGroups = true; |
1354 |
|
} |
1355 |
+ |
|
1356 |
+ |
for (i = 0; i < nInfo; i++) |
1357 |
+ |
info[i].haveCutoffGroups = haveCutoffGroups; |
1358 |
|
|
1359 |
|
#ifdef IS_MPI |
1360 |
|
strcpy(checkPointMsg, "Component stamps successfully extracted\n"); |
1371 |
|
tot_bonds = 0; |
1372 |
|
tot_bends = 0; |
1373 |
|
tot_torsions = 0; |
1374 |
+ |
tot_rigid = 0; |
1375 |
|
for (i = 0; i < n_components; i++){ |
1376 |
|
tot_atoms += components_nmol[i] * comp_stamps[i]->getNAtoms(); |
1377 |
|
tot_bonds += components_nmol[i] * comp_stamps[i]->getNBonds(); |
1378 |
|
tot_bends += components_nmol[i] * comp_stamps[i]->getNBends(); |
1379 |
|
tot_torsions += components_nmol[i] * comp_stamps[i]->getNTorsions(); |
1380 |
+ |
tot_rigid += components_nmol[i] * comp_stamps[i]->getNRigidBodies(); |
1381 |
|
} |
1382 |
< |
|
1382 |
> |
|
1383 |
|
tot_SRI = tot_bonds + tot_bends + tot_torsions; |
1384 |
|
molMembershipArray = new int[tot_atoms]; |
1385 |
|
|
1401 |
|
int i, j, k; |
1402 |
|
int localMol, allMol; |
1403 |
|
int local_atoms, local_bonds, local_bends, local_torsions, local_SRI; |
1404 |
+ |
int local_rigid; |
1405 |
+ |
vector<int> globalMolIndex; |
1406 |
|
|
1407 |
|
mpiSim = new mpiSimulation(info); |
1408 |
|
|
1409 |
< |
globalIndex = mpiSim->divideLabor(); |
1409 |
> |
mpiSim->divideLabor(); |
1410 |
> |
globalAtomIndex = mpiSim->getGlobalAtomIndex(); |
1411 |
> |
//globalMolIndex = mpiSim->getGlobalMolIndex(); |
1412 |
|
|
1413 |
|
// set up the local variables |
1414 |
|
|
1421 |
|
local_bonds = 0; |
1422 |
|
local_bends = 0; |
1423 |
|
local_torsions = 0; |
1424 |
< |
globalAtomIndex = 0; |
1424 |
> |
local_rigid = 0; |
1425 |
> |
globalAtomCounter = 0; |
1426 |
|
|
1223 |
– |
|
1427 |
|
for (i = 0; i < n_components; i++){ |
1428 |
|
for (j = 0; j < components_nmol[i]; j++){ |
1429 |
|
if (mol2proc[allMol] == worldRank){ |
1431 |
|
local_bonds += comp_stamps[i]->getNBonds(); |
1432 |
|
local_bends += comp_stamps[i]->getNBends(); |
1433 |
|
local_torsions += comp_stamps[i]->getNTorsions(); |
1434 |
+ |
local_rigid += comp_stamps[i]->getNRigidBodies(); |
1435 |
|
localMol++; |
1436 |
|
} |
1437 |
|
for (k = 0; k < comp_stamps[i]->getNAtoms(); k++){ |
1438 |
< |
info[0].molMembershipArray[globalAtomIndex] = allMol; |
1439 |
< |
globalAtomIndex++; |
1438 |
> |
info[0].molMembershipArray[globalAtomCounter] = allMol; |
1439 |
> |
globalAtomCounter++; |
1440 |
|
} |
1441 |
|
|
1442 |
|
allMol++; |
1445 |
|
local_SRI = local_bonds + local_bends + local_torsions; |
1446 |
|
|
1447 |
|
info[0].n_atoms = mpiSim->getMyNlocal(); |
1448 |
+ |
|
1449 |
|
|
1450 |
|
if (local_atoms != info[0].n_atoms){ |
1451 |
|
sprintf(painCave.errMsg, |
1452 |
< |
"SimSetup error: mpiSim's localAtom (%d) and SimSetup's" |
1453 |
< |
" localAtom (%d) are not equal.\n", |
1452 |
> |
"SimSetup error: mpiSim's localAtom (%d) and SimSetup's\n" |
1453 |
> |
"\tlocalAtom (%d) are not equal.\n", |
1454 |
|
info[0].n_atoms, local_atoms); |
1455 |
|
painCave.isFatal = 1; |
1456 |
|
simError(); |
1478 |
|
|
1479 |
|
Atom** the_atoms; |
1480 |
|
Molecule* the_molecules; |
1276 |
– |
Exclude** the_excludes; |
1481 |
|
|
1278 |
– |
|
1482 |
|
for (l = 0; l < nInfo; l++){ |
1483 |
|
// create the atom and short range interaction arrays |
1484 |
|
|
1504 |
|
#else // is_mpi |
1505 |
|
|
1506 |
|
molIndex = 0; |
1507 |
< |
globalAtomIndex = 0; |
1507 |
> |
globalAtomCounter = 0; |
1508 |
|
for (i = 0; i < n_components; i++){ |
1509 |
|
for (j = 0; j < components_nmol[i]; j++){ |
1510 |
|
the_molecules[molIndex].setStampID(i); |
1511 |
|
the_molecules[molIndex].setMyIndex(molIndex); |
1512 |
|
the_molecules[molIndex].setGlobalIndex(molIndex); |
1513 |
|
for (k = 0; k < comp_stamps[i]->getNAtoms(); k++){ |
1514 |
< |
info[l].molMembershipArray[globalAtomIndex] = molIndex; |
1515 |
< |
globalAtomIndex++; |
1514 |
> |
info[l].molMembershipArray[globalAtomCounter] = molIndex; |
1515 |
> |
globalAtomCounter++; |
1516 |
|
} |
1517 |
|
molIndex++; |
1518 |
|
} |
1521 |
|
|
1522 |
|
#endif // is_mpi |
1523 |
|
|
1524 |
< |
|
1525 |
< |
if (info[l].n_SRI){ |
1526 |
< |
Exclude::createArray(info[l].n_SRI); |
1324 |
< |
the_excludes = new Exclude * [info[l].n_SRI]; |
1325 |
< |
for (int ex = 0; ex < info[l].n_SRI; ex++){ |
1326 |
< |
the_excludes[ex] = new Exclude(ex); |
1327 |
< |
} |
1328 |
< |
info[l].globalExcludes = new int; |
1329 |
< |
info[l].n_exclude = info[l].n_SRI; |
1330 |
< |
} |
1331 |
< |
else{ |
1332 |
< |
Exclude::createArray(1); |
1333 |
< |
the_excludes = new Exclude * ; |
1334 |
< |
the_excludes[0] = new Exclude(0); |
1335 |
< |
the_excludes[0]->setPair(0, 0); |
1336 |
< |
info[l].globalExcludes = new int; |
1337 |
< |
info[l].globalExcludes[0] = 0; |
1338 |
< |
info[l].n_exclude = 0; |
1339 |
< |
} |
1340 |
< |
|
1524 |
> |
info[l].globalExcludes = new int; |
1525 |
> |
info[l].globalExcludes[0] = 0; |
1526 |
> |
|
1527 |
|
// set the arrays into the SimInfo object |
1528 |
|
|
1529 |
|
info[l].atoms = the_atoms; |
1530 |
|
info[l].molecules = the_molecules; |
1531 |
|
info[l].nGlobalExcludes = 0; |
1532 |
< |
info[l].excludes = the_excludes; |
1347 |
< |
|
1532 |
> |
|
1533 |
|
the_ff->setSimInfo(info); |
1534 |
|
} |
1535 |
|
} |
1572 |
|
else{ |
1573 |
|
sprintf(painCave.errMsg, |
1574 |
|
"SimSetup error: If you use the NVT\n" |
1575 |
< |
" ensemble, you must set tauThermostat.\n"); |
1575 |
> |
"\tensemble, you must set tauThermostat.\n"); |
1576 |
|
painCave.isFatal = 1; |
1577 |
|
simError(); |
1578 |
|
} |
1595 |
|
else{ |
1596 |
|
sprintf(painCave.errMsg, |
1597 |
|
"SimSetup error: If you use a constant pressure\n" |
1598 |
< |
" ensemble, you must set targetPressure in the BASS file.\n"); |
1598 |
> |
"\tensemble, you must set targetPressure in the BASS file.\n"); |
1599 |
|
painCave.isFatal = 1; |
1600 |
|
simError(); |
1601 |
|
} |
1605 |
|
else{ |
1606 |
|
sprintf(painCave.errMsg, |
1607 |
|
"SimSetup error: If you use an NPT\n" |
1608 |
< |
" ensemble, you must set tauThermostat.\n"); |
1608 |
> |
"\tensemble, you must set tauThermostat.\n"); |
1609 |
|
painCave.isFatal = 1; |
1610 |
|
simError(); |
1611 |
|
} |
1615 |
|
else{ |
1616 |
|
sprintf(painCave.errMsg, |
1617 |
|
"SimSetup error: If you use an NPT\n" |
1618 |
< |
" ensemble, you must set tauBarostat.\n"); |
1618 |
> |
"\tensemble, you must set tauBarostat.\n"); |
1619 |
|
painCave.isFatal = 1; |
1620 |
|
simError(); |
1621 |
|
} |
1638 |
|
else{ |
1639 |
|
sprintf(painCave.errMsg, |
1640 |
|
"SimSetup error: If you use a constant pressure\n" |
1641 |
< |
" ensemble, you must set targetPressure in the BASS file.\n"); |
1641 |
> |
"\tensemble, you must set targetPressure in the BASS file.\n"); |
1642 |
|
painCave.isFatal = 1; |
1643 |
|
simError(); |
1644 |
|
} |
1645 |
|
|
1646 |
|
if (globals->haveTauThermostat()) |
1647 |
|
myNPTf->setTauThermostat(globals->getTauThermostat()); |
1648 |
+ |
|
1649 |
|
else{ |
1650 |
|
sprintf(painCave.errMsg, |
1651 |
|
"SimSetup error: If you use an NPT\n" |
1652 |
< |
" ensemble, you must set tauThermostat.\n"); |
1652 |
> |
"\tensemble, you must set tauThermostat.\n"); |
1653 |
|
painCave.isFatal = 1; |
1654 |
|
simError(); |
1655 |
|
} |
1656 |
|
|
1657 |
|
if (globals->haveTauBarostat()) |
1658 |
|
myNPTf->setTauBarostat(globals->getTauBarostat()); |
1659 |
+ |
|
1660 |
|
else{ |
1661 |
|
sprintf(painCave.errMsg, |
1662 |
|
"SimSetup error: If you use an NPT\n" |
1663 |
< |
" ensemble, you must set tauBarostat.\n"); |
1663 |
> |
"\tensemble, you must set tauBarostat.\n"); |
1664 |
|
painCave.isFatal = 1; |
1665 |
|
simError(); |
1666 |
|
} |
1683 |
|
else{ |
1684 |
|
sprintf(painCave.errMsg, |
1685 |
|
"SimSetup error: If you use a constant pressure\n" |
1686 |
< |
" ensemble, you must set targetPressure in the BASS file.\n"); |
1686 |
> |
"\tensemble, you must set targetPressure in the BASS file.\n"); |
1687 |
|
painCave.isFatal = 1; |
1688 |
|
simError(); |
1689 |
|
} |
1693 |
|
else{ |
1694 |
|
sprintf(painCave.errMsg, |
1695 |
|
"SimSetup error: If you use an NPT\n" |
1696 |
< |
" ensemble, you must set tauThermostat.\n"); |
1696 |
> |
"\tensemble, you must set tauThermostat.\n"); |
1697 |
|
painCave.isFatal = 1; |
1698 |
|
simError(); |
1699 |
|
} |
1703 |
|
else{ |
1704 |
|
sprintf(painCave.errMsg, |
1705 |
|
"SimSetup error: If you use an NPT\n" |
1706 |
< |
" ensemble, you must set tauBarostat.\n"); |
1706 |
> |
"\tensemble, you must set tauBarostat.\n"); |
1707 |
|
painCave.isFatal = 1; |
1708 |
|
simError(); |
1709 |
|
} |
1756 |
|
} |
1757 |
|
else{ |
1758 |
|
sprintf(painCave.errMsg, |
1759 |
< |
"ZConstraint error: If you use an ZConstraint\n" |
1760 |
< |
" , you must set sample time.\n"); |
1759 |
> |
"ZConstraint error: If you use a ZConstraint,\n" |
1760 |
> |
"\tyou must set zconsTime.\n"); |
1761 |
|
painCave.isFatal = 1; |
1762 |
|
simError(); |
1763 |
|
} |
1772 |
|
else{ |
1773 |
|
double defaultZConsTol = 0.01; |
1774 |
|
sprintf(painCave.errMsg, |
1775 |
< |
"ZConstraint Waring: Tolerance for z-constraint methodl is not specified\n" |
1776 |
< |
" , default value %f is used.\n", |
1775 |
> |
"ZConstraint Warning: Tolerance for z-constraint method is not specified.\n" |
1776 |
> |
"\tOOPSE will use a default value of %f.\n" |
1777 |
> |
"\tTo set the tolerance, use the zconsTol variable.\n", |
1778 |
|
defaultZConsTol); |
1779 |
|
painCave.isFatal = 0; |
1780 |
|
simError(); |
1792 |
|
} |
1793 |
|
else{ |
1794 |
|
sprintf(painCave.errMsg, |
1795 |
< |
"ZConstraint Warning: User does not set force Subtraction policy, " |
1796 |
< |
"PolicyByMass is used\n"); |
1795 |
> |
"ZConstraint Warning: No force subtraction policy was set.\n" |
1796 |
> |
"\tOOPSE will use PolicyByMass.\n" |
1797 |
> |
"\tTo set the policy, use the zconsForcePolicy variable.\n"); |
1798 |
|
painCave.isFatal = 0; |
1799 |
|
simError(); |
1800 |
|
zconsForcePolicy->setData("BYMASS"); |
1801 |
|
} |
1802 |
|
|
1803 |
|
theInfo.addProperty(zconsForcePolicy); |
1804 |
+ |
|
1805 |
+ |
//set zcons gap |
1806 |
+ |
DoubleData* zconsGap = new DoubleData(); |
1807 |
+ |
zconsGap->setID(ZCONSGAP_ID); |
1808 |
+ |
|
1809 |
+ |
if (globals->haveZConsGap()){ |
1810 |
+ |
zconsGap->setData(globals->getZconsGap()); |
1811 |
+ |
theInfo.addProperty(zconsGap); |
1812 |
+ |
} |
1813 |
|
|
1814 |
+ |
//set zcons fixtime |
1815 |
+ |
DoubleData* zconsFixtime = new DoubleData(); |
1816 |
+ |
zconsFixtime->setID(ZCONSFIXTIME_ID); |
1817 |
+ |
|
1818 |
+ |
if (globals->haveZConsFixTime()){ |
1819 |
+ |
zconsFixtime->setData(globals->getZconsFixtime()); |
1820 |
+ |
theInfo.addProperty(zconsFixtime); |
1821 |
+ |
} |
1822 |
+ |
|
1823 |
+ |
//set zconsUsingSMD |
1824 |
+ |
IntData* zconsUsingSMD = new IntData(); |
1825 |
+ |
zconsUsingSMD->setID(ZCONSUSINGSMD_ID); |
1826 |
+ |
|
1827 |
+ |
if (globals->haveZConsUsingSMD()){ |
1828 |
+ |
zconsUsingSMD->setData(globals->getZconsUsingSMD()); |
1829 |
+ |
theInfo.addProperty(zconsUsingSMD); |
1830 |
+ |
} |
1831 |
+ |
|
1832 |
|
//Determine the name of ouput file and add it into SimInfo's property list |
1833 |
|
//Be careful, do not use inFileName, since it is a pointer which |
1834 |
|
//point to a string at master node, and slave nodes do not contain that string |
1858 |
|
tempParaItem.zPos = zconStamp[i]->getZpos(); |
1859 |
|
tempParaItem.zconsIndex = zconStamp[i]->getMolIndex(); |
1860 |
|
tempParaItem.kRatio = zconStamp[i]->getKratio(); |
1861 |
< |
|
1861 |
> |
tempParaItem.havingCantVel = zconStamp[i]->haveCantVel(); |
1862 |
> |
tempParaItem.cantVel = zconStamp[i]->getCantVel(); |
1863 |
|
zconsParaData->addItem(tempParaItem); |
1864 |
|
} |
1865 |
|
|
1866 |
|
//check the uniqueness of index |
1867 |
|
if(!zconsParaData->isIndexUnique()){ |
1868 |
|
sprintf(painCave.errMsg, |
1869 |
< |
"ZConstraint Error: molIndex is not unique\n"); |
1869 |
> |
"ZConstraint Error: molIndex is not unique!\n"); |
1870 |
|
painCave.isFatal = 1; |
1871 |
|
simError(); |
1872 |
|
} |
1877 |
|
//push data into siminfo, therefore, we can retrieve later |
1878 |
|
theInfo.addProperty(zconsParaData); |
1879 |
|
} |
1880 |
+ |
|
1881 |
+ |
void SimSetup::makeMinimizer(){ |
1882 |
+ |
|
1883 |
+ |
OOPSEMinimizer* myOOPSEMinimizer; |
1884 |
+ |
MinimizerParameterSet* param; |
1885 |
+ |
char minimizerName[100]; |
1886 |
+ |
|
1887 |
+ |
for (int i = 0; i < nInfo; i++){ |
1888 |
+ |
|
1889 |
+ |
//prepare parameter set for minimizer |
1890 |
+ |
param = new MinimizerParameterSet(); |
1891 |
+ |
param->setDefaultParameter(); |
1892 |
+ |
|
1893 |
+ |
if (globals->haveMinimizer()){ |
1894 |
+ |
param->setFTol(globals->getMinFTol()); |
1895 |
+ |
} |
1896 |
+ |
|
1897 |
+ |
if (globals->haveMinGTol()){ |
1898 |
+ |
param->setGTol(globals->getMinGTol()); |
1899 |
+ |
} |
1900 |
+ |
|
1901 |
+ |
if (globals->haveMinMaxIter()){ |
1902 |
+ |
param->setMaxIteration(globals->getMinMaxIter()); |
1903 |
+ |
} |
1904 |
+ |
|
1905 |
+ |
if (globals->haveMinWriteFrq()){ |
1906 |
+ |
param->setMaxIteration(globals->getMinMaxIter()); |
1907 |
+ |
} |
1908 |
+ |
|
1909 |
+ |
if (globals->haveMinWriteFrq()){ |
1910 |
+ |
param->setWriteFrq(globals->getMinWriteFrq()); |
1911 |
+ |
} |
1912 |
+ |
|
1913 |
+ |
if (globals->haveMinStepSize()){ |
1914 |
+ |
param->setStepSize(globals->getMinStepSize()); |
1915 |
+ |
} |
1916 |
+ |
|
1917 |
+ |
if (globals->haveMinLSMaxIter()){ |
1918 |
+ |
param->setLineSearchMaxIteration(globals->getMinLSMaxIter()); |
1919 |
+ |
} |
1920 |
+ |
|
1921 |
+ |
if (globals->haveMinLSTol()){ |
1922 |
+ |
param->setLineSearchTol(globals->getMinLSTol()); |
1923 |
+ |
} |
1924 |
+ |
|
1925 |
+ |
strcpy(minimizerName, globals->getMinimizer()); |
1926 |
+ |
|
1927 |
+ |
if (!strcasecmp(minimizerName, "CG")){ |
1928 |
+ |
myOOPSEMinimizer = new PRCGMinimizer(&(info[i]), the_ff, param); |
1929 |
+ |
} |
1930 |
+ |
else if (!strcasecmp(minimizerName, "SD")){ |
1931 |
+ |
//myOOPSEMinimizer = MinimizerFactory.creatMinimizer("", &(info[i]), the_ff, param); |
1932 |
+ |
myOOPSEMinimizer = new SDMinimizer(&(info[i]), the_ff, param); |
1933 |
+ |
} |
1934 |
+ |
else{ |
1935 |
+ |
sprintf(painCave.errMsg, |
1936 |
+ |
"SimSetup error: Unrecognized Minimizer, use Conjugate Gradient \n"); |
1937 |
+ |
painCave.isFatal = 0; |
1938 |
+ |
simError(); |
1939 |
+ |
|
1940 |
+ |
myOOPSEMinimizer = new PRCGMinimizer(&(info[i]), the_ff, param); |
1941 |
+ |
} |
1942 |
+ |
info[i].the_integrator = myOOPSEMinimizer; |
1943 |
+ |
|
1944 |
+ |
//store the minimizer into simInfo |
1945 |
+ |
info[i].the_minimizer = myOOPSEMinimizer; |
1946 |
+ |
info[i].has_minimizer = true; |
1947 |
+ |
} |
1948 |
+ |
|
1949 |
+ |
} |