# | Line 9 | Line 9 | |
---|---|---|
9 | #include "parse_me.h" | |
10 | #include "Integrator.hpp" | |
11 | #include "simError.h" | |
12 | < | //#include "ConjugateMinimizer.hpp" |
12 | > | #include "RigidBody.hpp" |
13 | #include "OOPSEMinimizer.hpp" | |
14 | + | //#include "ConstraintElement.hpp" |
15 | + | //#include "ConstraintPair.hpp" |
16 | ||
17 | #ifdef IS_MPI | |
18 | #include "mpiBASS.h" | |
# | Line 146 | Line 148 | void SimSetup::createSim(void){ | |
148 | // make the output filenames | |
149 | ||
150 | makeOutNames(); | |
149 | – | |
150 | – | if (globals->haveMinimizer()) |
151 | – | // make minimizer |
152 | – | makeMinimizer(); |
153 | – | else |
154 | – | // make the integrator |
155 | – | makeIntegrator(); |
151 | ||
152 | #ifdef IS_MPI | |
153 | mpiSim->mpiRefresh(); | |
# | Line 161 | Line 156 | void SimSetup::createSim(void){ | |
156 | // initialize the Fortran | |
157 | ||
158 | initFortran(); | |
159 | + | |
160 | + | if (globals->haveMinimizer()) |
161 | + | // make minimizer |
162 | + | makeMinimizer(); |
163 | + | else |
164 | + | // make the integrator |
165 | + | makeIntegrator(); |
166 | + | |
167 | } | |
168 | ||
169 | ||
170 | void SimSetup::makeMolecules(void){ | |
171 | < | int k; |
172 | < | int i, j, exI, exJ, tempEx, stampID, atomOffset, excludeOffset; |
171 | > | int i, j, k; |
172 | > | int exI, exJ, exK, exL, slI, slJ; |
173 | > | int tempI, tempJ, tempK, tempL; |
174 | > | int molI, globalID; |
175 | > | int stampID, atomOffset, rbOffset, groupOffset; |
176 | molInit molInfo; | |
177 | DirectionalAtom* dAtom; | |
178 | + | RigidBody* myRB; |
179 | + | StuntDouble* mySD; |
180 | LinkedAssign* extras; | |
181 | LinkedAssign* current_extra; | |
182 | AtomStamp* currentAtom; | |
183 | BondStamp* currentBond; | |
184 | BendStamp* currentBend; | |
185 | TorsionStamp* currentTorsion; | |
186 | + | RigidBodyStamp* currentRigidBody; |
187 | + | CutoffGroupStamp* currentCutoffGroup; |
188 | + | CutoffGroup* myCutoffGroup; |
189 | + | int nCutoffGroups;// number of cutoff group of a molecule defined in mdl file |
190 | + | set<int> cutoffAtomSet; //atoms belong to cutoffgroup defined at mdl file |
191 | ||
192 | bond_pair* theBonds; | |
193 | bend_set* theBends; | |
194 | torsion_set* theTorsions; | |
195 | ||
196 | + | set<int> skipList; |
197 | + | |
198 | + | double phi, theta, psi; |
199 | + | char* molName; |
200 | + | char rbName[100]; |
201 | + | |
202 | + | //ConstraintPair* consPair; //constraint pair |
203 | + | //ConstraintElement* consElement1; //first element of constraint pair |
204 | + | //ConstraintElement* consElement2; //second element of constraint pair |
205 | + | //int whichRigidBody; |
206 | + | //int consAtomIndex; //index of constraint atom in rigid body's atom array |
207 | + | //vector<pair<int, int> > jointAtoms; |
208 | //init the forceField paramters | |
209 | ||
210 | the_ff->readParams(); | |
211 | ||
187 | – | |
212 | // init the atoms | |
213 | ||
214 | < | double phi, theta, psi; |
191 | < | double sux, suy, suz; |
192 | < | double Axx, Axy, Axz, Ayx, Ayy, Ayz, Azx, Azy, Azz; |
193 | < | double ux, uy, uz, u, uSqr; |
214 | > | int nMembers, nNew, rb1, rb2; |
215 | ||
216 | for (k = 0; k < nInfo; k++){ | |
217 | the_ff->setSimInfo(&(info[k])); | |
218 | + | |
219 | + | #ifdef IS_MPI |
220 | + | info[k].globalGroupMembership = new int[mpiSim->getNAtomsGlobal()]; |
221 | + | for (i = 0; i < mpiSim->getNAtomsGlobal(); i++) |
222 | + | info[k].globalGroupMembership[i] = 0; |
223 | + | #else |
224 | + | info[k].globalGroupMembership = new int[info[k].n_atoms]; |
225 | + | for (i = 0; i < info[k].n_atoms; i++) |
226 | + | info[k].globalGroupMembership[i] = 0; |
227 | + | #endif |
228 | ||
229 | atomOffset = 0; | |
230 | < | excludeOffset = 0; |
230 | > | groupOffset = 0; |
231 | > | |
232 | for (i = 0; i < info[k].n_mol; i++){ | |
233 | stampID = info[k].molecules[i].getStampID(); | |
234 | + | molName = comp_stamps[stampID]->getID(); |
235 | ||
236 | molInfo.nAtoms = comp_stamps[stampID]->getNAtoms(); | |
237 | molInfo.nBonds = comp_stamps[stampID]->getNBonds(); | |
238 | molInfo.nBends = comp_stamps[stampID]->getNBends(); | |
239 | molInfo.nTorsions = comp_stamps[stampID]->getNTorsions(); | |
240 | < | molInfo.nExcludes = molInfo.nBonds + molInfo.nBends + molInfo.nTorsions; |
240 | > | molInfo.nRigidBodies = comp_stamps[stampID]->getNRigidBodies(); |
241 | ||
242 | + | nCutoffGroups = comp_stamps[stampID]->getNCutoffGroups(); |
243 | + | |
244 | molInfo.myAtoms = &(info[k].atoms[atomOffset]); | |
210 | – | molInfo.myExcludes = &(info[k].excludes[excludeOffset]); |
211 | – | molInfo.myBonds = new Bond * [molInfo.nBonds]; |
212 | – | molInfo.myBends = new Bend * [molInfo.nBends]; |
213 | – | molInfo.myTorsions = new Torsion * [molInfo.nTorsions]; |
245 | ||
246 | + | if (molInfo.nBonds > 0) |
247 | + | molInfo.myBonds = new Bond*[molInfo.nBonds]; |
248 | + | else |
249 | + | molInfo.myBonds = NULL; |
250 | + | |
251 | + | if (molInfo.nBends > 0) |
252 | + | molInfo.myBends = new Bend*[molInfo.nBends]; |
253 | + | else |
254 | + | molInfo.myBends = NULL; |
255 | + | |
256 | + | if (molInfo.nTorsions > 0) |
257 | + | molInfo.myTorsions = new Torsion *[molInfo.nTorsions]; |
258 | + | else |
259 | + | molInfo.myTorsions = NULL; |
260 | + | |
261 | theBonds = new bond_pair[molInfo.nBonds]; | |
262 | theBends = new bend_set[molInfo.nBends]; | |
263 | theTorsions = new torsion_set[molInfo.nTorsions]; | |
264 | < | |
264 | > | |
265 | // make the Atoms | |
266 | ||
267 | for (j = 0; j < molInfo.nAtoms; j++){ | |
268 | currentAtom = comp_stamps[stampID]->getAtom(j); | |
269 | + | |
270 | if (currentAtom->haveOrientation()){ | |
271 | dAtom = new DirectionalAtom((j + atomOffset), | |
272 | info[k].getConfiguration()); | |
# | Line 233 | Line 280 | void SimSetup::makeMolecules(void){ | |
280 | phi = currentAtom->getEulerPhi() * M_PI / 180.0; | |
281 | theta = currentAtom->getEulerTheta() * M_PI / 180.0; | |
282 | psi = currentAtom->getEulerPsi()* M_PI / 180.0; | |
236 | – | |
237 | – | Axx = (cos(phi) * cos(psi)) - (sin(phi) * cos(theta) * sin(psi)); |
238 | – | Axy = (sin(phi) * cos(psi)) + (cos(phi) * cos(theta) * sin(psi)); |
239 | – | Axz = sin(theta) * sin(psi); |
240 | – | |
241 | – | Ayx = -(cos(phi) * sin(psi)) - (sin(phi) * cos(theta) * cos(psi)); |
242 | – | Ayy = -(sin(phi) * sin(psi)) + (cos(phi) * cos(theta) * cos(psi)); |
243 | – | Ayz = sin(theta) * cos(psi); |
244 | – | |
245 | – | Azx = sin(phi) * sin(theta); |
246 | – | Azy = -cos(phi) * sin(theta); |
247 | – | Azz = cos(theta); |
283 | ||
284 | < | sux = 0.0; |
285 | < | suy = 0.0; |
251 | < | suz = 1.0; |
252 | < | |
253 | < | ux = (Axx * sux) + (Ayx * suy) + (Azx * suz); |
254 | < | uy = (Axy * sux) + (Ayy * suy) + (Azy * suz); |
255 | < | uz = (Axz * sux) + (Ayz * suy) + (Azz * suz); |
256 | < | |
257 | < | uSqr = (ux * ux) + (uy * uy) + (uz * uz); |
258 | < | |
259 | < | u = sqrt(uSqr); |
260 | < | ux = ux / u; |
261 | < | uy = uy / u; |
262 | < | uz = uz / u; |
263 | < | |
264 | < | dAtom->setSUx(ux); |
265 | < | dAtom->setSUy(uy); |
266 | < | dAtom->setSUz(uz); |
284 | > | dAtom->setUnitFrameFromEuler(phi, theta, psi); |
285 | > | |
286 | } | |
287 | else{ | |
269 | – | molInfo.myAtoms[j] = new GeneralAtom((j + atomOffset), |
270 | – | info[k].getConfiguration()); |
271 | – | } |
272 | – | molInfo.myAtoms[j]->setType(currentAtom->getType()); |
288 | ||
289 | < | #ifdef IS_MPI |
289 | > | molInfo.myAtoms[j] = new Atom((j + atomOffset), info[k].getConfiguration()); |
290 | ||
291 | < | molInfo.myAtoms[j]->setGlobalIndex(globalIndex[j + atomOffset]); |
291 | > | } |
292 | ||
293 | + | molInfo.myAtoms[j]->setType(currentAtom->getType()); |
294 | + | #ifdef IS_MPI |
295 | + | molInfo.myAtoms[j]->setGlobalIndex(globalAtomIndex[j + atomOffset]); |
296 | #endif // is_mpi | |
297 | } | |
298 | ||
# | Line 284 | Line 302 | void SimSetup::makeMolecules(void){ | |
302 | theBonds[j].a = currentBond->getA() + atomOffset; | |
303 | theBonds[j].b = currentBond->getB() + atomOffset; | |
304 | ||
305 | < | exI = theBonds[j].a; |
306 | < | exJ = theBonds[j].b; |
305 | > | tempI = theBonds[j].a; |
306 | > | tempJ = theBonds[j].b; |
307 | ||
290 | – | // exclude_I must always be the smaller of the pair |
291 | – | if (exI > exJ){ |
292 | – | tempEx = exI; |
293 | – | exI = exJ; |
294 | – | exJ = tempEx; |
295 | – | } |
308 | #ifdef IS_MPI | |
309 | < | tempEx = exI; |
310 | < | exI = info[k].atoms[tempEx]->getGlobalIndex() + 1; |
311 | < | tempEx = exJ; |
312 | < | exJ = info[k].atoms[tempEx]->getGlobalIndex() + 1; |
309 | > | exI = info[k].atoms[tempI]->getGlobalIndex() + 1; |
310 | > | exJ = info[k].atoms[tempJ]->getGlobalIndex() + 1; |
311 | > | #else |
312 | > | exI = tempI + 1; |
313 | > | exJ = tempJ + 1; |
314 | > | #endif |
315 | ||
316 | < | info[k].excludes[j + excludeOffset]->setPair(exI, exJ); |
303 | < | #else // isn't MPI |
304 | < | |
305 | < | info[k].excludes[j + excludeOffset]->setPair((exI + 1), (exJ + 1)); |
306 | < | #endif //is_mpi |
316 | > | info[k].excludes->addPair(exI, exJ); |
317 | } | |
308 | – | excludeOffset += molInfo.nBonds; |
318 | ||
319 | //make the bends | |
320 | for (j = 0; j < molInfo.nBends; j++){ | |
# | Line 355 | Line 364 | void SimSetup::makeMolecules(void){ | |
364 | } | |
365 | } | |
366 | ||
367 | < | if (!theBends[j].isGhost){ |
368 | < | exI = theBends[j].a; |
369 | < | exJ = theBends[j].c; |
370 | < | } |
371 | < | else{ |
363 | < | exI = theBends[j].a; |
364 | < | exJ = theBends[j].b; |
365 | < | } |
366 | < | |
367 | < | // exclude_I must always be the smaller of the pair |
368 | < | if (exI > exJ){ |
369 | < | tempEx = exI; |
370 | < | exI = exJ; |
371 | < | exJ = tempEx; |
372 | < | } |
367 | > | if (theBends[j].isGhost) { |
368 | > | |
369 | > | tempI = theBends[j].a; |
370 | > | tempJ = theBends[j].b; |
371 | > | |
372 | #ifdef IS_MPI | |
373 | < | tempEx = exI; |
374 | < | exI = info[k].atoms[tempEx]->getGlobalIndex() + 1; |
375 | < | tempEx = exJ; |
376 | < | exJ = info[k].atoms[tempEx]->getGlobalIndex() + 1; |
373 | > | exI = info[k].atoms[tempI]->getGlobalIndex() + 1; |
374 | > | exJ = info[k].atoms[tempJ]->getGlobalIndex() + 1; |
375 | > | #else |
376 | > | exI = tempI + 1; |
377 | > | exJ = tempJ + 1; |
378 | > | #endif |
379 | > | info[k].excludes->addPair(exI, exJ); |
380 | ||
381 | < | info[k].excludes[j + excludeOffset]->setPair(exI, exJ); |
382 | < | #else // isn't MPI |
383 | < | info[k].excludes[j + excludeOffset]->setPair((exI + 1), (exJ + 1)); |
384 | < | #endif //is_mpi |
381 | > | } else { |
382 | > | |
383 | > | tempI = theBends[j].a; |
384 | > | tempJ = theBends[j].b; |
385 | > | tempK = theBends[j].c; |
386 | > | |
387 | > | #ifdef IS_MPI |
388 | > | exI = info[k].atoms[tempI]->getGlobalIndex() + 1; |
389 | > | exJ = info[k].atoms[tempJ]->getGlobalIndex() + 1; |
390 | > | exK = info[k].atoms[tempK]->getGlobalIndex() + 1; |
391 | > | #else |
392 | > | exI = tempI + 1; |
393 | > | exJ = tempJ + 1; |
394 | > | exK = tempK + 1; |
395 | > | #endif |
396 | > | |
397 | > | info[k].excludes->addPair(exI, exK); |
398 | > | info[k].excludes->addPair(exI, exJ); |
399 | > | info[k].excludes->addPair(exJ, exK); |
400 | > | } |
401 | } | |
384 | – | excludeOffset += molInfo.nBends; |
402 | ||
403 | for (j = 0; j < molInfo.nTorsions; j++){ | |
404 | currentTorsion = comp_stamps[stampID]->getTorsion(j); | |
# | Line 390 | Line 407 | void SimSetup::makeMolecules(void){ | |
407 | theTorsions[j].c = currentTorsion->getC() + atomOffset; | |
408 | theTorsions[j].d = currentTorsion->getD() + atomOffset; | |
409 | ||
410 | < | exI = theTorsions[j].a; |
411 | < | exJ = theTorsions[j].d; |
410 | > | tempI = theTorsions[j].a; |
411 | > | tempJ = theTorsions[j].b; |
412 | > | tempK = theTorsions[j].c; |
413 | > | tempL = theTorsions[j].d; |
414 | ||
415 | < | // exclude_I must always be the smaller of the pair |
416 | < | if (exI > exJ){ |
417 | < | tempEx = exI; |
418 | < | exI = exJ; |
419 | < | exJ = tempEx; |
415 | > | #ifdef IS_MPI |
416 | > | exI = info[k].atoms[tempI]->getGlobalIndex() + 1; |
417 | > | exJ = info[k].atoms[tempJ]->getGlobalIndex() + 1; |
418 | > | exK = info[k].atoms[tempK]->getGlobalIndex() + 1; |
419 | > | exL = info[k].atoms[tempL]->getGlobalIndex() + 1; |
420 | > | #else |
421 | > | exI = tempI + 1; |
422 | > | exJ = tempJ + 1; |
423 | > | exK = tempK + 1; |
424 | > | exL = tempL + 1; |
425 | > | #endif |
426 | > | |
427 | > | info[k].excludes->addPair(exI, exJ); |
428 | > | info[k].excludes->addPair(exI, exK); |
429 | > | info[k].excludes->addPair(exI, exL); |
430 | > | info[k].excludes->addPair(exJ, exK); |
431 | > | info[k].excludes->addPair(exJ, exL); |
432 | > | info[k].excludes->addPair(exK, exL); |
433 | > | } |
434 | > | |
435 | > | |
436 | > | molInfo.myRigidBodies.clear(); |
437 | > | |
438 | > | for (j = 0; j < molInfo.nRigidBodies; j++){ |
439 | > | |
440 | > | currentRigidBody = comp_stamps[stampID]->getRigidBody(j); |
441 | > | nMembers = currentRigidBody->getNMembers(); |
442 | > | |
443 | > | // Create the Rigid Body: |
444 | > | |
445 | > | myRB = new RigidBody(); |
446 | > | |
447 | > | sprintf(rbName,"%s_RB_%d", molName, j); |
448 | > | myRB->setType(rbName); |
449 | > | |
450 | > | for (rb1 = 0; rb1 < nMembers; rb1++) { |
451 | > | |
452 | > | // molI is atom numbering inside this molecule |
453 | > | molI = currentRigidBody->getMember(rb1); |
454 | > | |
455 | > | // tempI is atom numbering on local processor |
456 | > | tempI = molI + atomOffset; |
457 | > | |
458 | > | // currentAtom is the AtomStamp (which we need for |
459 | > | // rigid body reference positions) |
460 | > | currentAtom = comp_stamps[stampID]->getAtom(molI); |
461 | > | |
462 | > | // When we add to the rigid body, add the atom itself and |
463 | > | // the stamp info: |
464 | > | |
465 | > | myRB->addAtom(info[k].atoms[tempI], currentAtom); |
466 | > | |
467 | > | // Add this atom to the Skip List for the integrators |
468 | > | #ifdef IS_MPI |
469 | > | slI = info[k].atoms[tempI]->getGlobalIndex(); |
470 | > | #else |
471 | > | slI = tempI; |
472 | > | #endif |
473 | > | skipList.insert(slI); |
474 | > | |
475 | } | |
476 | + | |
477 | + | for(rb1 = 0; rb1 < nMembers - 1; rb1++) { |
478 | + | for(rb2 = rb1+1; rb2 < nMembers; rb2++) { |
479 | + | |
480 | + | tempI = currentRigidBody->getMember(rb1); |
481 | + | tempJ = currentRigidBody->getMember(rb2); |
482 | + | |
483 | + | // Some explanation is required here. |
484 | + | // Fortran indexing starts at 1, while c indexing starts at 0 |
485 | + | // Also, in parallel computations, the GlobalIndex is |
486 | + | // used for the exclude list: |
487 | + | |
488 | #ifdef IS_MPI | |
489 | < | tempEx = exI; |
490 | < | exI = info[k].atoms[tempEx]->getGlobalIndex() + 1; |
491 | < | tempEx = exJ; |
492 | < | exJ = info[k].atoms[tempEx]->getGlobalIndex() + 1; |
489 | > | exI = molInfo.myAtoms[tempI]->getGlobalIndex() + 1; |
490 | > | exJ = molInfo.myAtoms[tempJ]->getGlobalIndex() + 1; |
491 | > | #else |
492 | > | exI = molInfo.myAtoms[tempI]->getIndex() + 1; |
493 | > | exJ = molInfo.myAtoms[tempJ]->getIndex() + 1; |
494 | > | #endif |
495 | > | |
496 | > | info[k].excludes->addPair(exI, exJ); |
497 | > | |
498 | > | } |
499 | > | } |
500 | ||
501 | < | info[k].excludes[j + excludeOffset]->setPair(exI, exJ); |
502 | < | #else // isn't MPI |
410 | < | info[k].excludes[j + excludeOffset]->setPair((exI + 1), (exJ + 1)); |
411 | < | #endif //is_mpi |
501 | > | molInfo.myRigidBodies.push_back(myRB); |
502 | > | info[k].rigidBodies.push_back(myRB); |
503 | } | |
504 | < | excludeOffset += molInfo.nTorsions; |
504 | > | |
505 | ||
506 | + | //create cutoff group for molecule |
507 | ||
508 | < | // send the arrays off to the forceField for init. |
508 | > | cutoffAtomSet.clear(); |
509 | > | molInfo.myCutoffGroups.clear(); |
510 | > | |
511 | > | for (j = 0; j < nCutoffGroups; j++){ |
512 | > | |
513 | > | currentCutoffGroup = comp_stamps[stampID]->getCutoffGroup(j); |
514 | > | nMembers = currentCutoffGroup->getNMembers(); |
515 | > | |
516 | > | myCutoffGroup = new CutoffGroup(); |
517 | > | |
518 | > | #ifdef IS_MPI |
519 | > | myCutoffGroup->setGlobalIndex(globalGroupIndex[j + groupOffset]); |
520 | > | #else |
521 | > | myCutoffGroup->setGlobalIndex(j + groupOffset); |
522 | > | #endif |
523 | > | |
524 | > | for (int cg = 0; cg < nMembers; cg++) { |
525 | > | |
526 | > | // molI is atom numbering inside this molecule |
527 | > | molI = currentCutoffGroup->getMember(cg); |
528 | > | |
529 | > | // tempI is atom numbering on local processor |
530 | > | tempI = molI + atomOffset; |
531 | > | |
532 | > | #ifdef IS_MPI |
533 | > | globalID = info[k].atoms[tempI]->getGlobalIndex(); |
534 | > | info[k].globalGroupMembership[globalID] = globalGroupIndex[j+groupOffset]; |
535 | > | #else |
536 | > | globalID = info[k].atoms[tempI]->getIndex(); |
537 | > | info[k].globalGroupMembership[globalID] = j + groupOffset; |
538 | > | #endif |
539 | > | |
540 | > | |
541 | > | |
542 | > | myCutoffGroup->addAtom(info[k].atoms[tempI]); |
543 | > | |
544 | > | cutoffAtomSet.insert(tempI); |
545 | > | } |
546 | > | |
547 | > | molInfo.myCutoffGroups.push_back(myCutoffGroup); |
548 | > | groupOffset++; |
549 | > | |
550 | > | }//end for (j = 0; j < molInfo.nCutoffGroups; j++) |
551 | > | |
552 | > | //creat a cutoff group for every atom in current molecule which does not belong to cutoffgroup defined at mdl file |
553 | > | |
554 | > | for(j = 0; j < molInfo.nAtoms; j++){ |
555 | > | |
556 | > | if(cutoffAtomSet.find(molInfo.myAtoms[j]->getIndex()) == cutoffAtomSet.end()){ |
557 | > | myCutoffGroup = new CutoffGroup(); |
558 | > | myCutoffGroup->addAtom(molInfo.myAtoms[j]); |
559 | > | |
560 | > | #ifdef IS_MPI |
561 | > | myCutoffGroup->setGlobalIndex(globalGroupIndex[j + groupOffset]); |
562 | > | globalID = info[k].atoms[atomOffset + j]->getGlobalIndex(); |
563 | > | info[k].globalGroupMembership[globalID] = globalGroupIndex[j+groupOffset]; |
564 | > | #else |
565 | > | myCutoffGroup->setGlobalIndex(j + groupOffset); |
566 | > | globalID = info[k].atoms[atomOffset + j]->getIndex(); |
567 | > | info[k].globalGroupMembership[globalID] = j+groupOffset; |
568 | > | #endif |
569 | > | molInfo.myCutoffGroups.push_back(myCutoffGroup); |
570 | > | groupOffset++; |
571 | > | } |
572 | > | |
573 | > | } |
574 | > | |
575 | > | // After this is all set up, scan through the atoms to |
576 | > | // see if they can be added to the integrableObjects: |
577 | > | |
578 | > | molInfo.myIntegrableObjects.clear(); |
579 | > | |
580 | > | |
581 | > | for (j = 0; j < molInfo.nAtoms; j++){ |
582 | > | |
583 | > | #ifdef IS_MPI |
584 | > | slJ = molInfo.myAtoms[j]->getGlobalIndex(); |
585 | > | #else |
586 | > | slJ = j+atomOffset; |
587 | > | #endif |
588 | > | |
589 | > | // if they aren't on the skip list, then they can be integrated |
590 | > | |
591 | > | if (skipList.find(slJ) == skipList.end()) { |
592 | > | mySD = (StuntDouble *) molInfo.myAtoms[j]; |
593 | > | info[k].integrableObjects.push_back(mySD); |
594 | > | molInfo.myIntegrableObjects.push_back(mySD); |
595 | > | } |
596 | > | } |
597 | > | |
598 | > | // all rigid bodies are integrated: |
599 | > | |
600 | > | for (j = 0; j < molInfo.nRigidBodies; j++) { |
601 | > | mySD = (StuntDouble *) molInfo.myRigidBodies[j]; |
602 | > | info[k].integrableObjects.push_back(mySD); |
603 | > | molInfo.myIntegrableObjects.push_back(mySD); |
604 | > | } |
605 | > | |
606 | ||
607 | + | /* |
608 | + | |
609 | + | //creat ConstraintPair. |
610 | + | molInfo.myConstraintPair.clear(); |
611 | + | |
612 | + | for (j = 0; j < molInfo.nBonds; j++){ |
613 | + | |
614 | + | //if both atoms are in the same rigid body, just skip it |
615 | + | currentBond = comp_stamps[stampID]->getBond(j); |
616 | + | if(!comp_stamps[stampID]->isBondInSameRigidBody(currentBond)){ |
617 | + | |
618 | + | tempI = currentBond->getA() + atomOffset; |
619 | + | if( comp_stamps[stampID]->isAtomInRigidBody(currentBond->getA(), whichRigidBody, consAtomIndex)) |
620 | + | consElement1 = new ConstraintRigidBody(molInfo.myRigidBodies[whichRigidBody], consAtomIndex); |
621 | + | else |
622 | + | consElement1 = new ConstraintAtom(info[k].atoms[tempI]); |
623 | + | |
624 | + | tempJ = currentBond->getB() + atomOffset; |
625 | + | if(comp_stamps[stampID]->isAtomInRigidBody(currentBond->getB(), whichRigidBody, consAtomIndex)) |
626 | + | consElement2 = new ConstraintRigidBody(molInfo.myRigidBodies[whichRigidBody], consAtomIndex); |
627 | + | else |
628 | + | consElement2 = new ConstraintAtom(info[k].atoms[tempJ]); |
629 | + | |
630 | + | consPair = new DistanceConstraintPair(consElement1, consElement2); |
631 | + | molInfo.myConstraintPairs.push_back(consPair); |
632 | + | } |
633 | + | } |
634 | + | |
635 | + | //loop over rigid bodies, if two rigid bodies share same joint, creat a HingeConstraintPair |
636 | + | for (int rb1 = 0; rb1 < molInfo.nRigidBodies -1 ; rb1++){ |
637 | + | for (int rb2 = rb1 + 1; rb2 < molInfo.nRigidBodies ; rb2++){ |
638 | + | |
639 | + | jointAtoms = comp_stamps[stampID]->getJointAtoms(rb1, rb2); |
640 | + | |
641 | + | for(size_t m = 0; m < jointAtoms.size(); m++){ |
642 | + | consElement1 = new ConstraintRigidBody(molInfo.myRigidBodies[rb1], jointAtoms[m].first); |
643 | + | consElement2 = new ConstraintRigidBody(molInfo.myRigidBodies[rb2], jointAtoms[m].second); |
644 | + | |
645 | + | consPair = new JointConstraintPair(consElement1, consElement2); |
646 | + | molInfo.myConstraintPairs.push_back(consPair); |
647 | + | } |
648 | + | |
649 | + | } |
650 | + | } |
651 | + | |
652 | + | */ |
653 | + | // send the arrays off to the forceField for init. |
654 | + | |
655 | the_ff->initializeAtoms(molInfo.nAtoms, molInfo.myAtoms); | |
656 | the_ff->initializeBonds(molInfo.nBonds, molInfo.myBonds, theBonds); | |
657 | the_ff->initializeBends(molInfo.nBends, molInfo.myBends, theBends); | |
658 | the_ff->initializeTorsions(molInfo.nTorsions, molInfo.myTorsions, | |
659 | theTorsions); | |
660 | ||
424 | – | |
661 | info[k].molecules[i].initialize(molInfo); | |
662 | < | |
663 | < | |
662 | > | |
663 | > | |
664 | atomOffset += molInfo.nAtoms; | |
665 | delete[] theBonds; | |
666 | delete[] theBends; | |
667 | delete[] theTorsions; | |
668 | } | |
669 | + | |
670 | + | |
671 | + | |
672 | + | #ifdef IS_MPI |
673 | + | // Since the globalGroupMembership has been zero filled and we've only |
674 | + | // poked values into the atoms we know, we can do an Allreduce |
675 | + | // to get the full globalGroupMembership array (We think). |
676 | + | // This would be prettier if we could use MPI_IN_PLACE like the MPI-2 |
677 | + | // docs said we could. |
678 | + | |
679 | + | int* ggMjunk = new int[mpiSim->getNAtomsGlobal()]; |
680 | + | |
681 | + | MPI_Allreduce(info[k].globalGroupMembership, |
682 | + | ggMjunk, |
683 | + | mpiSim->getNAtomsGlobal(), |
684 | + | MPI_INT, MPI_SUM, MPI_COMM_WORLD); |
685 | + | |
686 | + | for (i = 0; i < mpiSim->getNAtomsGlobal(); i++) |
687 | + | info[k].globalGroupMembership[i] = ggMjunk[i]; |
688 | + | |
689 | + | delete[] ggMjunk; |
690 | + | |
691 | + | #endif |
692 | + | |
693 | + | |
694 | + | |
695 | } | |
696 | ||
697 | #ifdef IS_MPI | |
# | Line 437 | Line 699 | void SimSetup::makeMolecules(void){ | |
699 | MPIcheckPoint(); | |
700 | #endif // is_mpi | |
701 | ||
440 | – | // clean up the forcefield |
441 | – | |
442 | – | the_ff->calcRcut(); |
443 | – | the_ff->cleanMe(); |
702 | } | |
703 | ||
704 | void SimSetup::initFromBass(void){ | |
# | Line 727 | Line 985 | void SimSetup::gatherInfo(void){ | |
985 | } | |
986 | ||
987 | //check whether sample time, status time, thermal time and reset time are divisble by dt | |
988 | < | if (!isDivisible(globals->getSampleTime(), globals->getDt())){ |
988 | > | if (globals->haveSampleTime() && !isDivisible(globals->getSampleTime(), globals->getDt())){ |
989 | sprintf(painCave.errMsg, | |
990 | "Sample time is not divisible by dt.\n" | |
991 | "\tThis will result in samples that are not uniformly\n" | |
# | Line 737 | Line 995 | void SimSetup::gatherInfo(void){ | |
995 | simError(); | |
996 | } | |
997 | ||
998 | < | if (globals->haveStatusTime() && !isDivisible(globals->getSampleTime(), globals->getDt())){ |
998 | > | if (globals->haveStatusTime() && !isDivisible(globals->getStatusTime(), globals->getDt())){ |
999 | sprintf(painCave.errMsg, | |
1000 | "Status time is not divisible by dt.\n" | |
1001 | "\tThis will result in status reports that are not uniformly\n" | |
# | Line 773 | Line 1031 | void SimSetup::gatherInfo(void){ | |
1031 | if (globals->haveSampleTime()){ | |
1032 | info[i].sampleTime = globals->getSampleTime(); | |
1033 | info[i].statusTime = info[i].sampleTime; | |
776 | – | info[i].thermalTime = info[i].sampleTime; |
1034 | } | |
1035 | else{ | |
1036 | info[i].sampleTime = globals->getRunTime(); | |
1037 | info[i].statusTime = info[i].sampleTime; | |
781 | – | info[i].thermalTime = info[i].sampleTime; |
1038 | } | |
1039 | ||
1040 | if (globals->haveStatusTime()){ | |
# | Line 787 | Line 1043 | void SimSetup::gatherInfo(void){ | |
1043 | ||
1044 | if (globals->haveThermalTime()){ | |
1045 | info[i].thermalTime = globals->getThermalTime(); | |
1046 | + | } else { |
1047 | + | info[i].thermalTime = globals->getRunTime(); |
1048 | } | |
1049 | ||
1050 | info[i].resetIntegrator = 0; | |
# | Line 804 | Line 1062 | void SimSetup::gatherInfo(void){ | |
1062 | ||
1063 | info[i].useInitXSstate = globals->getUseInitXSstate(); | |
1064 | info[i].orthoTolerance = globals->getOrthoBoxTolerance(); | |
1065 | < | |
1065 | > | |
1066 | > | // check for thermodynamic integration |
1067 | > | if (globals->getUseSolidThermInt() && !globals->getUseLiquidThermInt()) { |
1068 | > | if (globals->haveThermIntLambda() && globals->haveThermIntK()) { |
1069 | > | info[i].useSolidThermInt = globals->getUseSolidThermInt(); |
1070 | > | info[i].thermIntLambda = globals->getThermIntLambda(); |
1071 | > | info[i].thermIntK = globals->getThermIntK(); |
1072 | > | |
1073 | > | Restraints *myRestraint = new Restraints(tot_nmol, info[i].thermIntLambda, info[i].thermIntK); |
1074 | > | info[i].restraint = myRestraint; |
1075 | > | } |
1076 | > | else { |
1077 | > | sprintf(painCave.errMsg, |
1078 | > | "SimSetup Error:\n" |
1079 | > | "\tKeyword useSolidThermInt was set to 'true' but\n" |
1080 | > | "\tthermodynamicIntegrationLambda (and/or\n" |
1081 | > | "\tthermodynamicIntegrationK) was not specified.\n" |
1082 | > | "\tPlease provide a lambda value and k value in your .bass file.\n"); |
1083 | > | painCave.isFatal = 1; |
1084 | > | simError(); |
1085 | > | } |
1086 | > | } |
1087 | > | else if(globals->getUseLiquidThermInt()) { |
1088 | > | if (globals->getUseSolidThermInt()) { |
1089 | > | sprintf( painCave.errMsg, |
1090 | > | "SimSetup Warning: It appears that you have both solid and\n" |
1091 | > | "\tliquid thermodynamic integration activated in your .bass\n" |
1092 | > | "\tfile. To avoid confusion, specify only one technique in\n" |
1093 | > | "\tyour .bass file. Liquid-state thermodynamic integration\n" |
1094 | > | "\twill be assumed for the current simulation. If this is not\n" |
1095 | > | "\twhat you desire, set useSolidThermInt to 'true' and\n" |
1096 | > | "\tuseLiquidThermInt to 'false' in your .bass file.\n"); |
1097 | > | painCave.isFatal = 0; |
1098 | > | simError(); |
1099 | > | } |
1100 | > | if (globals->haveThermIntLambda() && globals->haveThermIntK()) { |
1101 | > | info[i].useLiquidThermInt = globals->getUseLiquidThermInt(); |
1102 | > | info[i].thermIntLambda = globals->getThermIntLambda(); |
1103 | > | info[i].thermIntK = globals->getThermIntK(); |
1104 | > | } |
1105 | > | else { |
1106 | > | sprintf(painCave.errMsg, |
1107 | > | "SimSetup Error:\n" |
1108 | > | "\tKeyword useLiquidThermInt was set to 'true' but\n" |
1109 | > | "\tthermodynamicIntegrationLambda (and/or\n" |
1110 | > | "\tthermodynamicIntegrationK) was not specified.\n" |
1111 | > | "\tPlease provide a lambda value and k value in your .bass file.\n"); |
1112 | > | painCave.isFatal = 1; |
1113 | > | simError(); |
1114 | > | } |
1115 | > | } |
1116 | > | else if(globals->haveThermIntLambda() || globals->haveThermIntK()){ |
1117 | > | sprintf(painCave.errMsg, |
1118 | > | "SimSetup Warning: If you want to use Thermodynamic\n" |
1119 | > | "\tIntegration, set useSolidThermInt or useLiquidThermInt to\n" |
1120 | > | "\t'true' in your .bass file. These keywords are set to\n" |
1121 | > | "\t'false' by default, so your lambda and/or k values are\n" |
1122 | > | "\tbeing ignored.\n"); |
1123 | > | painCave.isFatal = 0; |
1124 | > | simError(); |
1125 | > | } |
1126 | } | |
1127 | ||
1128 | //setup seed for random number generator | |
# | Line 857 | Line 1175 | void SimSetup::finalInfoCheck(void){ | |
1175 | void SimSetup::finalInfoCheck(void){ | |
1176 | int index; | |
1177 | int usesDipoles; | |
1178 | + | int usesCharges; |
1179 | int i; | |
1180 | ||
1181 | for (i = 0; i < nInfo; i++){ | |
# | Line 868 | Line 1187 | void SimSetup::finalInfoCheck(void){ | |
1187 | usesDipoles = (info[i].atoms[index])->hasDipole(); | |
1188 | index++; | |
1189 | } | |
1190 | < | |
1190 | > | index = 0; |
1191 | > | usesCharges = 0; |
1192 | > | while ((index < info[i].n_atoms) && !usesCharges){ |
1193 | > | usesCharges= (info[i].atoms[index])->hasCharge(); |
1194 | > | index++; |
1195 | > | } |
1196 | #ifdef IS_MPI | |
1197 | int myUse = usesDipoles; | |
1198 | MPI_Allreduce(&myUse, &usesDipoles, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); | |
1199 | #endif //is_mpi | |
1200 | ||
1201 | < | double theEcr, theEst; |
1201 | > | double theRcut, theRsw; |
1202 | ||
1203 | + | if (globals->haveRcut()) { |
1204 | + | theRcut = globals->getRcut(); |
1205 | + | |
1206 | + | if (globals->haveRsw()) |
1207 | + | theRsw = globals->getRsw(); |
1208 | + | else |
1209 | + | theRsw = theRcut; |
1210 | + | |
1211 | + | info[i].setDefaultRcut(theRcut, theRsw); |
1212 | + | |
1213 | + | } else { |
1214 | + | |
1215 | + | the_ff->calcRcut(); |
1216 | + | theRcut = info[i].getRcut(); |
1217 | + | |
1218 | + | if (globals->haveRsw()) |
1219 | + | theRsw = globals->getRsw(); |
1220 | + | else |
1221 | + | theRsw = theRcut; |
1222 | + | |
1223 | + | info[i].setDefaultRcut(theRcut, theRsw); |
1224 | + | } |
1225 | + | |
1226 | if (globals->getUseRF()){ | |
1227 | info[i].useReactionField = 1; | |
1228 | < | |
1229 | < | if (!globals->haveECR()){ |
1228 | > | |
1229 | > | if (!globals->haveRcut()){ |
1230 | sprintf(painCave.errMsg, | |
1231 | < | "SimSetup Warning: No value was set for electrostaticCutoffRadius.\n" |
1231 | > | "SimSetup Warning: No value was set for the cutoffRadius.\n" |
1232 | "\tOOPSE will use a default value of 15.0 angstroms" | |
1233 | < | "\tfor the electrostaticCutoffRadius.\n"); |
1233 | > | "\tfor the cutoffRadius.\n"); |
1234 | painCave.isFatal = 0; | |
1235 | simError(); | |
1236 | < | theEcr = 15.0; |
1236 | > | theRcut = 15.0; |
1237 | } | |
1238 | else{ | |
1239 | < | theEcr = globals->getECR(); |
1239 | > | theRcut = globals->getRcut(); |
1240 | } | |
1241 | ||
1242 | < | if (!globals->haveEST()){ |
1242 | > | if (!globals->haveRsw()){ |
1243 | sprintf(painCave.errMsg, | |
1244 | < | "SimSetup Warning: No value was set for electrostaticSkinThickness.\n" |
1244 | > | "SimSetup Warning: No value was set for switchingRadius.\n" |
1245 | "\tOOPSE will use a default value of\n" | |
1246 | < | "\t0.05 * electrostaticCutoffRadius\n" |
900 | < | "\tfor the electrostaticSkinThickness\n"); |
1246 | > | "\t0.95 * cutoffRadius for the switchingRadius\n"); |
1247 | painCave.isFatal = 0; | |
1248 | simError(); | |
1249 | < | theEst = 0.05 * theEcr; |
1249 | > | theRsw = 0.95 * theRcut; |
1250 | } | |
1251 | else{ | |
1252 | < | theEst = globals->getEST(); |
1252 | > | theRsw = globals->getRsw(); |
1253 | } | |
1254 | ||
1255 | < | info[i].setDefaultEcr(theEcr, theEst); |
1255 | > | info[i].setDefaultRcut(theRcut, theRsw); |
1256 | ||
1257 | if (!globals->haveDielectric()){ | |
1258 | sprintf(painCave.errMsg, | |
# | Line 919 | Line 1265 | void SimSetup::finalInfoCheck(void){ | |
1265 | info[i].dielectric = globals->getDielectric(); | |
1266 | } | |
1267 | else{ | |
1268 | < | if (usesDipoles){ |
1269 | < | if (!globals->haveECR()){ |
1268 | > | if (usesDipoles || usesCharges){ |
1269 | > | |
1270 | > | if (!globals->haveRcut()){ |
1271 | sprintf(painCave.errMsg, | |
1272 | < | "SimSetup Warning: No value was set for electrostaticCutoffRadius.\n" |
1272 | > | "SimSetup Warning: No value was set for the cutoffRadius.\n" |
1273 | "\tOOPSE will use a default value of 15.0 angstroms" | |
1274 | < | "\tfor the electrostaticCutoffRadius.\n"); |
1275 | < | painCave.isFatal = 0; |
1276 | < | simError(); |
1277 | < | theEcr = 15.0; |
1278 | < | } |
1274 | > | "\tfor the cutoffRadius.\n"); |
1275 | > | painCave.isFatal = 0; |
1276 | > | simError(); |
1277 | > | theRcut = 15.0; |
1278 | > | } |
1279 | else{ | |
1280 | < | theEcr = globals->getECR(); |
1280 | > | theRcut = globals->getRcut(); |
1281 | } | |
1282 | < | |
1283 | < | if (!globals->haveEST()){ |
1282 | > | |
1283 | > | if (!globals->haveRsw()){ |
1284 | sprintf(painCave.errMsg, | |
1285 | < | "SimSetup Warning: No value was set for electrostaticSkinThickness.\n" |
1285 | > | "SimSetup Warning: No value was set for switchingRadius.\n" |
1286 | "\tOOPSE will use a default value of\n" | |
1287 | < | "\t0.05 * electrostaticCutoffRadius\n" |
941 | < | "\tfor the electrostaticSkinThickness\n"); |
1287 | > | "\t0.95 * cutoffRadius for the switchingRadius\n"); |
1288 | painCave.isFatal = 0; | |
1289 | simError(); | |
1290 | < | theEst = 0.05 * theEcr; |
1290 | > | theRsw = 0.95 * theRcut; |
1291 | } | |
1292 | else{ | |
1293 | < | theEst = globals->getEST(); |
1293 | > | theRsw = globals->getRsw(); |
1294 | } | |
1295 | + | |
1296 | + | info[i].setDefaultRcut(theRcut, theRsw); |
1297 | ||
950 | – | info[i].setDefaultEcr(theEcr, theEst); |
1298 | } | |
1299 | } | |
1300 | } | |
# | Line 955 | Line 1302 | void SimSetup::finalInfoCheck(void){ | |
1302 | strcpy(checkPointMsg, "post processing checks out"); | |
1303 | MPIcheckPoint(); | |
1304 | #endif // is_mpi | |
1305 | + | |
1306 | + | // clean up the forcefield |
1307 | + | the_ff->cleanMe(); |
1308 | } | |
1309 | ||
1310 | void SimSetup::initSystemCoords(void){ | |
# | Line 1082 | Line 1432 | void SimSetup::makeOutNames(void){ | |
1432 | } | |
1433 | else{ | |
1434 | strcat(info[k].statusName, ".stat"); | |
1435 | + | } |
1436 | + | } |
1437 | + | |
1438 | + | strcpy(info[k].rawPotName, inFileName); |
1439 | + | nameLength = strlen(info[k].rawPotName); |
1440 | + | endTest = &(info[k].rawPotName[nameLength - 5]); |
1441 | + | if (!strcmp(endTest, ".bass")){ |
1442 | + | strcpy(endTest, ".raw"); |
1443 | + | } |
1444 | + | else if (!strcmp(endTest, ".BASS")){ |
1445 | + | strcpy(endTest, ".raw"); |
1446 | + | } |
1447 | + | else{ |
1448 | + | endTest = &(info[k].rawPotName[nameLength - 4]); |
1449 | + | if (!strcmp(endTest, ".bss")){ |
1450 | + | strcpy(endTest, ".raw"); |
1451 | } | |
1452 | + | else if (!strcmp(endTest, ".mdl")){ |
1453 | + | strcpy(endTest, ".raw"); |
1454 | + | } |
1455 | + | else{ |
1456 | + | strcat(info[k].rawPotName, ".raw"); |
1457 | + | } |
1458 | } | |
1459 | ||
1460 | #ifdef IS_MPI | |
# | Line 1169 | Line 1541 | void SimSetup::compList(void){ | |
1541 | LinkedMolStamp* headStamp = new LinkedMolStamp(); | |
1542 | LinkedMolStamp* currentStamp = NULL; | |
1543 | comp_stamps = new MoleculeStamp * [n_components]; | |
1544 | + | bool haveCutoffGroups; |
1545 | ||
1546 | + | haveCutoffGroups = false; |
1547 | + | |
1548 | // make an array of molecule stamps that match the components used. | |
1549 | // also extract the used stamps out into a separate linked list | |
1550 | ||
# | Line 1204 | Line 1579 | void SimSetup::compList(void){ | |
1579 | headStamp->add(currentStamp); | |
1580 | comp_stamps[i] = headStamp->match(id); | |
1581 | } | |
1582 | + | |
1583 | + | if(comp_stamps[i]->getNCutoffGroups() > 0) |
1584 | + | haveCutoffGroups = true; |
1585 | } | |
1586 | + | |
1587 | + | for (i = 0; i < nInfo; i++) |
1588 | + | info[i].haveCutoffGroups = haveCutoffGroups; |
1589 | ||
1590 | #ifdef IS_MPI | |
1591 | strcpy(checkPointMsg, "Component stamps successfully extracted\n"); | |
# | Line 1213 | Line 1594 | void SimSetup::calcSysValues(void){ | |
1594 | } | |
1595 | ||
1596 | void SimSetup::calcSysValues(void){ | |
1597 | < | int i; |
1597 | > | int i, j; |
1598 | > | int ncutgroups, atomsingroups, ngroupsinstamp; |
1599 | ||
1600 | int* molMembershipArray; | |
1601 | + | CutoffGroupStamp* cg; |
1602 | ||
1603 | tot_atoms = 0; | |
1604 | tot_bonds = 0; | |
1605 | tot_bends = 0; | |
1606 | tot_torsions = 0; | |
1607 | + | tot_rigid = 0; |
1608 | + | tot_groups = 0; |
1609 | for (i = 0; i < n_components; i++){ | |
1610 | tot_atoms += components_nmol[i] * comp_stamps[i]->getNAtoms(); | |
1611 | tot_bonds += components_nmol[i] * comp_stamps[i]->getNBonds(); | |
1612 | tot_bends += components_nmol[i] * comp_stamps[i]->getNBends(); | |
1613 | tot_torsions += components_nmol[i] * comp_stamps[i]->getNTorsions(); | |
1614 | < | } |
1614 | > | tot_rigid += components_nmol[i] * comp_stamps[i]->getNRigidBodies(); |
1615 | ||
1616 | + | ncutgroups = comp_stamps[i]->getNCutoffGroups(); |
1617 | + | atomsingroups = 0; |
1618 | + | for (j=0; j < ncutgroups; j++) { |
1619 | + | cg = comp_stamps[i]->getCutoffGroup(j); |
1620 | + | atomsingroups += cg->getNMembers(); |
1621 | + | } |
1622 | + | ngroupsinstamp = comp_stamps[i]->getNAtoms() - atomsingroups + ncutgroups; |
1623 | + | tot_groups += components_nmol[i] * ngroupsinstamp; |
1624 | + | } |
1625 | + | |
1626 | tot_SRI = tot_bonds + tot_bends + tot_torsions; | |
1627 | molMembershipArray = new int[tot_atoms]; | |
1628 | ||
# | Line 1238 | Line 1633 | void SimSetup::calcSysValues(void){ | |
1633 | info[i].n_torsions = tot_torsions; | |
1634 | info[i].n_SRI = tot_SRI; | |
1635 | info[i].n_mol = tot_nmol; | |
1636 | < | |
1636 | > | info[i].ngroup = tot_groups; |
1637 | info[i].molMembershipArray = molMembershipArray; | |
1638 | } | |
1639 | } | |
# | Line 1249 | Line 1644 | void SimSetup::mpiMolDivide(void){ | |
1644 | int i, j, k; | |
1645 | int localMol, allMol; | |
1646 | int local_atoms, local_bonds, local_bends, local_torsions, local_SRI; | |
1647 | + | int local_rigid, local_groups; |
1648 | + | vector<int> globalMolIndex; |
1649 | + | int ncutgroups, atomsingroups, ngroupsinstamp; |
1650 | + | CutoffGroupStamp* cg; |
1651 | ||
1652 | mpiSim = new mpiSimulation(info); | |
1653 | ||
1654 | < | globalIndex = mpiSim->divideLabor(); |
1654 | > | mpiSim->divideLabor(); |
1655 | > | globalAtomIndex = mpiSim->getGlobalAtomIndex(); |
1656 | > | globalGroupIndex = mpiSim->getGlobalGroupIndex(); |
1657 | > | //globalMolIndex = mpiSim->getGlobalMolIndex(); |
1658 | ||
1659 | // set up the local variables | |
1660 | ||
# | Line 1265 | Line 1667 | void SimSetup::mpiMolDivide(void){ | |
1667 | local_bonds = 0; | |
1668 | local_bends = 0; | |
1669 | local_torsions = 0; | |
1670 | < | globalAtomIndex = 0; |
1670 | > | local_rigid = 0; |
1671 | > | local_groups = 0; |
1672 | > | globalAtomCounter = 0; |
1673 | ||
1270 | – | |
1674 | for (i = 0; i < n_components; i++){ | |
1675 | for (j = 0; j < components_nmol[i]; j++){ | |
1676 | if (mol2proc[allMol] == worldRank){ | |
# | Line 1275 | Line 1678 | void SimSetup::mpiMolDivide(void){ | |
1678 | local_bonds += comp_stamps[i]->getNBonds(); | |
1679 | local_bends += comp_stamps[i]->getNBends(); | |
1680 | local_torsions += comp_stamps[i]->getNTorsions(); | |
1681 | + | local_rigid += comp_stamps[i]->getNRigidBodies(); |
1682 | + | |
1683 | + | ncutgroups = comp_stamps[i]->getNCutoffGroups(); |
1684 | + | atomsingroups = 0; |
1685 | + | for (k=0; k < ncutgroups; k++) { |
1686 | + | cg = comp_stamps[i]->getCutoffGroup(k); |
1687 | + | atomsingroups += cg->getNMembers(); |
1688 | + | } |
1689 | + | ngroupsinstamp = comp_stamps[i]->getNAtoms() - atomsingroups + |
1690 | + | ncutgroups; |
1691 | + | local_groups += ngroupsinstamp; |
1692 | + | |
1693 | localMol++; | |
1694 | } | |
1695 | for (k = 0; k < comp_stamps[i]->getNAtoms(); k++){ | |
1696 | < | info[0].molMembershipArray[globalAtomIndex] = allMol; |
1697 | < | globalAtomIndex++; |
1696 | > | info[0].molMembershipArray[globalAtomCounter] = allMol; |
1697 | > | globalAtomCounter++; |
1698 | } | |
1699 | ||
1700 | allMol++; | |
# | Line 1287 | Line 1702 | void SimSetup::mpiMolDivide(void){ | |
1702 | } | |
1703 | local_SRI = local_bonds + local_bends + local_torsions; | |
1704 | ||
1705 | < | info[0].n_atoms = mpiSim->getMyNlocal(); |
1706 | < | |
1705 | > | info[0].n_atoms = mpiSim->getNAtomsLocal(); |
1706 | > | |
1707 | if (local_atoms != info[0].n_atoms){ | |
1708 | sprintf(painCave.errMsg, | |
1709 | "SimSetup error: mpiSim's localAtom (%d) and SimSetup's\n" | |
# | Line 1298 | Line 1713 | void SimSetup::mpiMolDivide(void){ | |
1713 | simError(); | |
1714 | } | |
1715 | ||
1716 | + | info[0].ngroup = mpiSim->getNGroupsLocal(); |
1717 | + | if (local_groups != info[0].ngroup){ |
1718 | + | sprintf(painCave.errMsg, |
1719 | + | "SimSetup error: mpiSim's localGroups (%d) and SimSetup's\n" |
1720 | + | "\tlocalGroups (%d) are not equal.\n", |
1721 | + | info[0].ngroup, local_groups); |
1722 | + | painCave.isFatal = 1; |
1723 | + | simError(); |
1724 | + | } |
1725 | + | |
1726 | info[0].n_bonds = local_bonds; | |
1727 | info[0].n_bends = local_bends; | |
1728 | info[0].n_torsions = local_torsions; | |
# | Line 1320 | Line 1745 | void SimSetup::makeSysArrays(void){ | |
1745 | ||
1746 | Atom** the_atoms; | |
1747 | Molecule* the_molecules; | |
1323 | – | Exclude** the_excludes; |
1748 | ||
1325 | – | |
1749 | for (l = 0; l < nInfo; l++){ | |
1750 | // create the atom and short range interaction arrays | |
1751 | ||
# | Line 1336 | Line 1759 | void SimSetup::makeSysArrays(void){ | |
1759 | ||
1760 | ||
1761 | molIndex = 0; | |
1762 | < | for (i = 0; i < mpiSim->getTotNmol(); i++){ |
1762 | > | for (i = 0; i < mpiSim->getNMolGlobal(); i++){ |
1763 | if (mol2proc[i] == worldRank){ | |
1764 | the_molecules[molIndex].setStampID(molCompType[i]); | |
1765 | the_molecules[molIndex].setMyIndex(molIndex); | |
# | Line 1348 | Line 1771 | void SimSetup::makeSysArrays(void){ | |
1771 | #else // is_mpi | |
1772 | ||
1773 | molIndex = 0; | |
1774 | < | globalAtomIndex = 0; |
1774 | > | globalAtomCounter = 0; |
1775 | for (i = 0; i < n_components; i++){ | |
1776 | for (j = 0; j < components_nmol[i]; j++){ | |
1777 | the_molecules[molIndex].setStampID(i); | |
1778 | the_molecules[molIndex].setMyIndex(molIndex); | |
1779 | the_molecules[molIndex].setGlobalIndex(molIndex); | |
1780 | for (k = 0; k < comp_stamps[i]->getNAtoms(); k++){ | |
1781 | < | info[l].molMembershipArray[globalAtomIndex] = molIndex; |
1782 | < | globalAtomIndex++; |
1781 | > | info[l].molMembershipArray[globalAtomCounter] = molIndex; |
1782 | > | globalAtomCounter++; |
1783 | } | |
1784 | molIndex++; | |
1785 | } | |
# | Line 1365 | Line 1788 | void SimSetup::makeSysArrays(void){ | |
1788 | ||
1789 | #endif // is_mpi | |
1790 | ||
1791 | < | |
1792 | < | if (info[l].n_SRI){ |
1793 | < | Exclude::createArray(info[l].n_SRI); |
1371 | < | the_excludes = new Exclude * [info[l].n_SRI]; |
1372 | < | for (int ex = 0; ex < info[l].n_SRI; ex++){ |
1373 | < | the_excludes[ex] = new Exclude(ex); |
1374 | < | } |
1375 | < | info[l].globalExcludes = new int; |
1376 | < | info[l].n_exclude = info[l].n_SRI; |
1377 | < | } |
1378 | < | else{ |
1379 | < | Exclude::createArray(1); |
1380 | < | the_excludes = new Exclude * ; |
1381 | < | the_excludes[0] = new Exclude(0); |
1382 | < | the_excludes[0]->setPair(0, 0); |
1383 | < | info[l].globalExcludes = new int; |
1384 | < | info[l].globalExcludes[0] = 0; |
1385 | < | info[l].n_exclude = 0; |
1386 | < | } |
1387 | < | |
1791 | > | info[l].globalExcludes = new int; |
1792 | > | info[l].globalExcludes[0] = 0; |
1793 | > | |
1794 | // set the arrays into the SimInfo object | |
1795 | ||
1796 | info[l].atoms = the_atoms; | |
1797 | info[l].molecules = the_molecules; | |
1798 | info[l].nGlobalExcludes = 0; | |
1799 | < | info[l].excludes = the_excludes; |
1394 | < | |
1799 | > | |
1800 | the_ff->setSimInfo(info); | |
1801 | } | |
1802 | } | |
# | Line 1682 | Line 2087 | void SimSetup::setupZConstraint(SimInfo& theInfo){ | |
2087 | theInfo.addProperty(zconsFixtime); | |
2088 | } | |
2089 | ||
2090 | + | //set zconsUsingSMD |
2091 | + | IntData* zconsUsingSMD = new IntData(); |
2092 | + | zconsUsingSMD->setID(ZCONSUSINGSMD_ID); |
2093 | ||
2094 | + | if (globals->haveZConsUsingSMD()){ |
2095 | + | zconsUsingSMD->setData(globals->getZconsUsingSMD()); |
2096 | + | theInfo.addProperty(zconsUsingSMD); |
2097 | + | } |
2098 | + | |
2099 | //Determine the name of ouput file and add it into SimInfo's property list | |
2100 | //Be careful, do not use inFileName, since it is a pointer which | |
2101 | //point to a string at master node, and slave nodes do not contain that string | |
# | Line 1712 | Line 2125 | void SimSetup::setupZConstraint(SimInfo& theInfo){ | |
2125 | tempParaItem.zPos = zconStamp[i]->getZpos(); | |
2126 | tempParaItem.zconsIndex = zconStamp[i]->getMolIndex(); | |
2127 | tempParaItem.kRatio = zconStamp[i]->getKratio(); | |
2128 | < | |
2128 | > | tempParaItem.havingCantVel = zconStamp[i]->haveCantVel(); |
2129 | > | tempParaItem.cantVel = zconStamp[i]->getCantVel(); |
2130 | zconsParaData->addItem(tempParaItem); | |
2131 | } | |
2132 |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |