# | 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 "ConjugateMinimizer.hpp" |
14 | > | #include "OOPSEMinimizer.hpp" |
15 | ||
16 | #ifdef IS_MPI | |
17 | #include "mpiBASS.h" | |
# | Line 28 | Line 30 | |
30 | #define FF_DUFF 0 | |
31 | #define FF_LJ 1 | |
32 | #define FF_EAM 2 | |
33 | < | #define FF_H2O 3 |
33 | > | #define FF_H2O 3 |
34 | ||
35 | using namespace std; | |
36 | ||
# | Line 145 | Line 147 | void SimSetup::createSim(void){ | |
147 | // make the output filenames | |
148 | ||
149 | makeOutNames(); | |
148 | – | |
149 | – | if (globals->haveMinimizer()) |
150 | – | // make minimizer |
151 | – | makeMinimizer(); |
152 | – | else |
153 | – | // make the integrator |
154 | – | makeIntegrator(); |
150 | ||
151 | #ifdef IS_MPI | |
152 | mpiSim->mpiRefresh(); | |
# | Line 160 | Line 155 | void SimSetup::createSim(void){ | |
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 | ||
186 | – | |
203 | // init the atoms | |
204 | ||
205 | < | double phi, theta, psi; |
190 | < | double sux, suy, suz; |
191 | < | double Axx, Axy, Axz, Ayx, Ayy, Ayz, Azx, Azy, Azz; |
192 | < | 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]); | |
209 | – | molInfo.myExcludes = &(info[k].excludes[excludeOffset]); |
210 | – | molInfo.myBonds = new Bond * [molInfo.nBonds]; |
211 | – | molInfo.myBends = new Bend * [molInfo.nBends]; |
212 | – | 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()); | |
# | Line 232 | Line 259 | void SimSetup::makeMolecules(void){ | |
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 | + | dAtom->setUnitFrameFromEuler(phi, theta, psi); |
264 | ||
265 | < | Axx = (cos(phi) * cos(psi)) - (sin(phi) * cos(theta) * sin(psi)); |
266 | < | Axy = (sin(phi) * cos(psi)) + (cos(phi) * cos(theta) * sin(psi)); |
238 | < | Axz = sin(theta) * sin(psi); |
239 | < | |
240 | < | Ayx = -(cos(phi) * sin(psi)) - (sin(phi) * cos(theta) * cos(psi)); |
241 | < | Ayy = -(sin(phi) * sin(psi)) + (cos(phi) * cos(theta) * cos(psi)); |
242 | < | Ayz = sin(theta) * cos(psi); |
243 | < | |
244 | < | Azx = sin(phi) * sin(theta); |
245 | < | Azy = -cos(phi) * sin(theta); |
246 | < | Azz = cos(theta); |
265 | > | } |
266 | > | else{ |
267 | ||
268 | < | sux = 0.0; |
249 | < | suy = 0.0; |
250 | < | suz = 1.0; |
268 | > | molInfo.myAtoms[j] = new Atom((j + atomOffset), info[k].getConfiguration()); |
269 | ||
252 | – | ux = (Axx * sux) + (Ayx * suy) + (Azx * suz); |
253 | – | uy = (Axy * sux) + (Ayy * suy) + (Azy * suz); |
254 | – | uz = (Axz * sux) + (Ayz * suy) + (Azz * suz); |
255 | – | |
256 | – | uSqr = (ux * ux) + (uy * uy) + (uz * uz); |
257 | – | |
258 | – | u = sqrt(uSqr); |
259 | – | ux = ux / u; |
260 | – | uy = uy / u; |
261 | – | uz = uz / u; |
262 | – | |
263 | – | dAtom->setSUx(ux); |
264 | – | dAtom->setSUy(uy); |
265 | – | dAtom->setSUz(uz); |
270 | } | |
267 | – | else{ |
268 | – | molInfo.myAtoms[j] = new GeneralAtom((j + atomOffset), |
269 | – | info[k].getConfiguration()); |
270 | – | } |
271 | – | 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 | } | |
# | Line 283 | Line 283 | void SimSetup::makeMolecules(void){ | |
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 | ||
289 | – | // exclude_I must always be the smaller of the pair |
290 | – | if (exI > exJ){ |
291 | – | tempEx = exI; |
292 | – | exI = exJ; |
293 | – | exJ = tempEx; |
294 | – | } |
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); |
302 | < | #else // isn't MPI |
303 | < | |
304 | < | info[k].excludes[j + excludeOffset]->setPair((exI + 1), (exJ + 1)); |
305 | < | #endif //is_mpi |
297 | > | info[k].excludes->addPair(exI, exJ); |
298 | } | |
307 | – | excludeOffset += molInfo.nBonds; |
299 | ||
300 | //make the bends | |
301 | for (j = 0; j < molInfo.nBends; j++){ | |
# | Line 354 | Line 345 | void SimSetup::makeMolecules(void){ | |
345 | } | |
346 | } | |
347 | ||
348 | < | if (!theBends[j].isGhost){ |
349 | < | exI = theBends[j].a; |
350 | < | exJ = theBends[j].c; |
351 | < | } |
352 | < | else{ |
362 | < | exI = theBends[j].a; |
363 | < | exJ = theBends[j].b; |
364 | < | } |
365 | < | |
366 | < | // exclude_I must always be the smaller of the pair |
367 | < | if (exI > exJ){ |
368 | < | tempEx = exI; |
369 | < | exI = exJ; |
370 | < | exJ = tempEx; |
371 | < | } |
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 | } | |
383 | – | excludeOffset += molInfo.nBends; |
383 | ||
384 | for (j = 0; j < molInfo.nTorsions; j++){ | |
385 | currentTorsion = comp_stamps[stampID]->getTorsion(j); | |
# | Line 389 | Line 388 | void SimSetup::makeMolecules(void){ | |
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 |
409 | < | info[k].excludes[j + excludeOffset]->setPair((exI + 1), (exJ + 1)); |
410 | < | #endif //is_mpi |
482 | > | molInfo.myRigidBodies.push_back(myRB); |
483 | > | info[k].rigidBodies.push_back(myRB); |
484 | } | |
485 | < | excludeOffset += molInfo.nTorsions; |
485 | > | |
486 | ||
487 | + | //create 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 | ||
423 | – | |
552 | info[k].molecules[i].initialize(molInfo); | |
553 | ||
554 | ||
# | Line 428 | Line 556 | void SimSetup::makeMolecules(void){ | |
556 | delete[] theBonds; | |
557 | delete[] theBends; | |
558 | delete[] theTorsions; | |
559 | < | } |
559 | > | } |
560 | } | |
561 | ||
562 | #ifdef IS_MPI | |
563 | sprintf(checkPointMsg, "all molecules initialized succesfully"); | |
564 | MPIcheckPoint(); | |
565 | #endif // is_mpi | |
438 | – | |
439 | – | // clean up the forcefield |
566 | ||
441 | – | the_ff->calcRcut(); |
442 | – | the_ff->cleanMe(); |
567 | } | |
568 | ||
569 | void SimSetup::initFromBass(void){ | |
# | Line 726 | Line 850 | void SimSetup::gatherInfo(void){ | |
850 | } | |
851 | ||
852 | //check whether sample time, status time, thermal time and reset time are divisble by dt | |
853 | < | if (!isDivisible(globals->getSampleTime(), globals->getDt())){ |
853 | > | if (globals->haveSampleTime() && !isDivisible(globals->getSampleTime(), globals->getDt())){ |
854 | sprintf(painCave.errMsg, | |
855 | "Sample time is not divisible by dt.\n" | |
856 | "\tThis will result in samples that are not uniformly\n" | |
# | Line 736 | Line 860 | void SimSetup::gatherInfo(void){ | |
860 | simError(); | |
861 | } | |
862 | ||
863 | < | if (globals->haveStatusTime() && !isDivisible(globals->getSampleTime(), globals->getDt())){ |
863 | > | if (globals->haveStatusTime() && !isDivisible(globals->getStatusTime(), globals->getDt())){ |
864 | sprintf(painCave.errMsg, | |
865 | "Status time is not divisible by dt.\n" | |
866 | "\tThis will result in status reports that are not uniformly\n" | |
# | Line 772 | Line 896 | void SimSetup::gatherInfo(void){ | |
896 | if (globals->haveSampleTime()){ | |
897 | info[i].sampleTime = globals->getSampleTime(); | |
898 | info[i].statusTime = info[i].sampleTime; | |
775 | – | info[i].thermalTime = info[i].sampleTime; |
899 | } | |
900 | else{ | |
901 | info[i].sampleTime = globals->getRunTime(); | |
902 | info[i].statusTime = info[i].sampleTime; | |
780 | – | info[i].thermalTime = info[i].sampleTime; |
903 | } | |
904 | ||
905 | if (globals->haveStatusTime()){ | |
# | Line 786 | Line 908 | void SimSetup::gatherInfo(void){ | |
908 | ||
909 | if (globals->haveThermalTime()){ | |
910 | info[i].thermalTime = globals->getThermalTime(); | |
911 | + | } else { |
912 | + | info[i].thermalTime = globals->getRunTime(); |
913 | } | |
914 | ||
915 | info[i].resetIntegrator = 0; | |
# | Line 856 | Line 980 | void SimSetup::finalInfoCheck(void){ | |
980 | void SimSetup::finalInfoCheck(void){ | |
981 | int index; | |
982 | int usesDipoles; | |
983 | + | int usesCharges; |
984 | int i; | |
985 | ||
986 | for (i = 0; i < nInfo; i++){ | |
# | Line 867 | Line 992 | void SimSetup::finalInfoCheck(void){ | |
992 | usesDipoles = (info[i].atoms[index])->hasDipole(); | |
993 | index++; | |
994 | } | |
995 | < | |
995 | > | index = 0; |
996 | > | usesCharges = 0; |
997 | > | while ((index < info[i].n_atoms) && !usesCharges){ |
998 | > | usesCharges= (info[i].atoms[index])->hasCharge(); |
999 | > | index++; |
1000 | > | } |
1001 | #ifdef IS_MPI | |
1002 | int myUse = usesDipoles; | |
1003 | MPI_Allreduce(&myUse, &usesDipoles, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); | |
1004 | #endif //is_mpi | |
1005 | ||
1006 | < | double theEcr, theEst; |
1006 | > | double theRcut, theRsw; |
1007 | ||
1008 | + | if (globals->haveRcut()) { |
1009 | + | theRcut = globals->getRcut(); |
1010 | + | |
1011 | + | if (globals->haveRsw()) |
1012 | + | theRsw = globals->getRsw(); |
1013 | + | else |
1014 | + | theRsw = theRcut; |
1015 | + | |
1016 | + | info[i].setDefaultRcut(theRcut, theRsw); |
1017 | + | |
1018 | + | } else { |
1019 | + | |
1020 | + | the_ff->calcRcut(); |
1021 | + | theRcut = info[i].getRcut(); |
1022 | + | |
1023 | + | if (globals->haveRsw()) |
1024 | + | theRsw = globals->getRsw(); |
1025 | + | else |
1026 | + | theRsw = theRcut; |
1027 | + | |
1028 | + | info[i].setDefaultRcut(theRcut, theRsw); |
1029 | + | } |
1030 | + | |
1031 | if (globals->getUseRF()){ | |
1032 | info[i].useReactionField = 1; | |
1033 | < | |
1034 | < | if (!globals->haveECR()){ |
1033 | > | |
1034 | > | if (!globals->haveRcut()){ |
1035 | sprintf(painCave.errMsg, | |
1036 | < | "SimSetup Warning: No value was set for electrostaticCutoffRadius.\n" |
1036 | > | "SimSetup Warning: No value was set for the cutoffRadius.\n" |
1037 | "\tOOPSE will use a default value of 15.0 angstroms" | |
1038 | < | "\tfor the electrostaticCutoffRadius.\n"); |
1038 | > | "\tfor the cutoffRadius.\n"); |
1039 | painCave.isFatal = 0; | |
1040 | simError(); | |
1041 | < | theEcr = 15.0; |
1041 | > | theRcut = 15.0; |
1042 | } | |
1043 | else{ | |
1044 | < | theEcr = globals->getECR(); |
1044 | > | theRcut = globals->getRcut(); |
1045 | } | |
1046 | ||
1047 | < | if (!globals->haveEST()){ |
1047 | > | if (!globals->haveRsw()){ |
1048 | sprintf(painCave.errMsg, | |
1049 | < | "SimSetup Warning: No value was set for electrostaticSkinThickness.\n" |
1049 | > | "SimSetup Warning: No value was set for switchingRadius.\n" |
1050 | "\tOOPSE will use a default value of\n" | |
1051 | < | "\t0.05 * electrostaticCutoffRadius\n" |
899 | < | "\tfor the electrostaticSkinThickness\n"); |
1051 | > | "\t0.95 * cutoffRadius for the switchingRadius\n"); |
1052 | painCave.isFatal = 0; | |
1053 | simError(); | |
1054 | < | theEst = 0.05 * theEcr; |
1054 | > | theRsw = 0.95 * theRcut; |
1055 | } | |
1056 | else{ | |
1057 | < | theEst = globals->getEST(); |
1057 | > | theRsw = globals->getRsw(); |
1058 | } | |
1059 | ||
1060 | < | info[i].setDefaultEcr(theEcr, theEst); |
1060 | > | info[i].setDefaultRcut(theRcut, theRsw); |
1061 | ||
1062 | if (!globals->haveDielectric()){ | |
1063 | sprintf(painCave.errMsg, | |
# | Line 918 | Line 1070 | void SimSetup::finalInfoCheck(void){ | |
1070 | info[i].dielectric = globals->getDielectric(); | |
1071 | } | |
1072 | else{ | |
1073 | < | if (usesDipoles){ |
1074 | < | if (!globals->haveECR()){ |
1073 | > | if (usesDipoles || usesCharges){ |
1074 | > | |
1075 | > | if (!globals->haveRcut()){ |
1076 | sprintf(painCave.errMsg, | |
1077 | < | "SimSetup Warning: No value was set for electrostaticCutoffRadius.\n" |
1077 | > | "SimSetup Warning: No value was set for the cutoffRadius.\n" |
1078 | "\tOOPSE will use a default value of 15.0 angstroms" | |
1079 | < | "\tfor the electrostaticCutoffRadius.\n"); |
1080 | < | painCave.isFatal = 0; |
1081 | < | simError(); |
1082 | < | theEcr = 15.0; |
1083 | < | } |
1084 | < | else{ |
1085 | < | theEcr = globals->getECR(); |
1086 | < | } |
1087 | < | |
1088 | < | if (!globals->haveEST()){ |
1079 | > | "\tfor the cutoffRadius.\n"); |
1080 | > | painCave.isFatal = 0; |
1081 | > | simError(); |
1082 | > | theRcut = 15.0; |
1083 | > | } |
1084 | > | else{ |
1085 | > | theRcut = globals->getRcut(); |
1086 | > | } |
1087 | > | |
1088 | > | if (!globals->haveRsw()){ |
1089 | sprintf(painCave.errMsg, | |
1090 | < | "SimSetup Warning: No value was set for electrostaticSkinThickness.\n" |
1090 | > | "SimSetup Warning: No value was set for switchingRadius.\n" |
1091 | "\tOOPSE will use a default value of\n" | |
1092 | < | "\t0.05 * electrostaticCutoffRadius\n" |
940 | < | "\tfor the electrostaticSkinThickness\n"); |
1092 | > | "\t0.95 * cutoffRadius for the switchingRadius\n"); |
1093 | painCave.isFatal = 0; | |
1094 | simError(); | |
1095 | < | theEst = 0.05 * theEcr; |
1095 | > | theRsw = 0.95 * theRcut; |
1096 | } | |
1097 | else{ | |
1098 | < | theEst = globals->getEST(); |
1098 | > | theRsw = globals->getRsw(); |
1099 | } | |
1100 | + | |
1101 | + | info[i].setDefaultRcut(theRcut, theRsw); |
1102 | ||
949 | – | info[i].setDefaultEcr(theEcr, theEst); |
1103 | } | |
1104 | } | |
1105 | } | |
# | Line 954 | Line 1107 | void SimSetup::finalInfoCheck(void){ | |
1107 | strcpy(checkPointMsg, "post processing checks out"); | |
1108 | MPIcheckPoint(); | |
1109 | #endif // is_mpi | |
1110 | + | |
1111 | + | // clean up the forcefield |
1112 | + | the_ff->cleanMe(); |
1113 | } | |
1114 | ||
1115 | void SimSetup::initSystemCoords(void){ | |
# | Line 1168 | Line 1324 | void SimSetup::compList(void){ | |
1324 | LinkedMolStamp* headStamp = new LinkedMolStamp(); | |
1325 | LinkedMolStamp* currentStamp = NULL; | |
1326 | comp_stamps = new MoleculeStamp * [n_components]; | |
1327 | + | bool haveCutoffGroups; |
1328 | ||
1329 | + | haveCutoffGroups = false; |
1330 | + | |
1331 | // make an array of molecule stamps that match the components used. | |
1332 | // also extract the used stamps out into a separate linked list | |
1333 | ||
# | Line 1203 | Line 1362 | void SimSetup::compList(void){ | |
1362 | headStamp->add(currentStamp); | |
1363 | comp_stamps[i] = headStamp->match(id); | |
1364 | } | |
1365 | + | |
1366 | + | if(comp_stamps[i]->getNCutoffGroups() > 0) |
1367 | + | haveCutoffGroups = true; |
1368 | } | |
1369 | + | |
1370 | + | for (i = 0; i < nInfo; i++) |
1371 | + | info[i].haveCutoffGroups = haveCutoffGroups; |
1372 | ||
1373 | #ifdef IS_MPI | |
1374 | strcpy(checkPointMsg, "Component stamps successfully extracted\n"); | |
# | Line 1220 | Line 1385 | void SimSetup::calcSysValues(void){ | |
1385 | tot_bonds = 0; | |
1386 | tot_bends = 0; | |
1387 | tot_torsions = 0; | |
1388 | + | tot_rigid = 0; |
1389 | for (i = 0; i < n_components; i++){ | |
1390 | tot_atoms += components_nmol[i] * comp_stamps[i]->getNAtoms(); | |
1391 | tot_bonds += components_nmol[i] * comp_stamps[i]->getNBonds(); | |
1392 | tot_bends += components_nmol[i] * comp_stamps[i]->getNBends(); | |
1393 | tot_torsions += components_nmol[i] * comp_stamps[i]->getNTorsions(); | |
1394 | + | tot_rigid += components_nmol[i] * comp_stamps[i]->getNRigidBodies(); |
1395 | } | |
1396 | < | |
1396 | > | |
1397 | tot_SRI = tot_bonds + tot_bends + tot_torsions; | |
1398 | molMembershipArray = new int[tot_atoms]; | |
1399 | ||
# | Line 1248 | Line 1415 | void SimSetup::mpiMolDivide(void){ | |
1415 | int i, j, k; | |
1416 | int localMol, allMol; | |
1417 | int local_atoms, local_bonds, local_bends, local_torsions, local_SRI; | |
1418 | + | int local_rigid; |
1419 | + | vector<int> globalMolIndex; |
1420 | ||
1421 | mpiSim = new mpiSimulation(info); | |
1422 | ||
1423 | < | globalIndex = mpiSim->divideLabor(); |
1423 | > | mpiSim->divideLabor(); |
1424 | > | globalAtomIndex = mpiSim->getGlobalAtomIndex(); |
1425 | > | //globalMolIndex = mpiSim->getGlobalMolIndex(); |
1426 | ||
1427 | // set up the local variables | |
1428 | ||
# | Line 1264 | Line 1435 | void SimSetup::mpiMolDivide(void){ | |
1435 | local_bonds = 0; | |
1436 | local_bends = 0; | |
1437 | local_torsions = 0; | |
1438 | < | globalAtomIndex = 0; |
1438 | > | local_rigid = 0; |
1439 | > | globalAtomCounter = 0; |
1440 | ||
1269 | – | |
1441 | for (i = 0; i < n_components; i++){ | |
1442 | for (j = 0; j < components_nmol[i]; j++){ | |
1443 | if (mol2proc[allMol] == worldRank){ | |
# | Line 1274 | Line 1445 | void SimSetup::mpiMolDivide(void){ | |
1445 | local_bonds += comp_stamps[i]->getNBonds(); | |
1446 | local_bends += comp_stamps[i]->getNBends(); | |
1447 | local_torsions += comp_stamps[i]->getNTorsions(); | |
1448 | + | local_rigid += comp_stamps[i]->getNRigidBodies(); |
1449 | localMol++; | |
1450 | } | |
1451 | for (k = 0; k < comp_stamps[i]->getNAtoms(); k++){ | |
1452 | < | info[0].molMembershipArray[globalAtomIndex] = allMol; |
1453 | < | globalAtomIndex++; |
1452 | > | info[0].molMembershipArray[globalAtomCounter] = allMol; |
1453 | > | globalAtomCounter++; |
1454 | } | |
1455 | ||
1456 | allMol++; | |
# | Line 1287 | Line 1459 | void SimSetup::mpiMolDivide(void){ | |
1459 | local_SRI = local_bonds + local_bends + local_torsions; | |
1460 | ||
1461 | info[0].n_atoms = mpiSim->getMyNlocal(); | |
1462 | + | |
1463 | ||
1464 | if (local_atoms != info[0].n_atoms){ | |
1465 | sprintf(painCave.errMsg, | |
# | Line 1319 | Line 1492 | void SimSetup::makeSysArrays(void){ | |
1492 | ||
1493 | Atom** the_atoms; | |
1494 | Molecule* the_molecules; | |
1322 | – | Exclude** the_excludes; |
1495 | ||
1324 | – | |
1496 | for (l = 0; l < nInfo; l++){ | |
1497 | // create the atom and short range interaction arrays | |
1498 | ||
# | Line 1347 | Line 1518 | void SimSetup::makeSysArrays(void){ | |
1518 | #else // is_mpi | |
1519 | ||
1520 | molIndex = 0; | |
1521 | < | globalAtomIndex = 0; |
1521 | > | globalAtomCounter = 0; |
1522 | for (i = 0; i < n_components; i++){ | |
1523 | for (j = 0; j < components_nmol[i]; j++){ | |
1524 | the_molecules[molIndex].setStampID(i); | |
1525 | the_molecules[molIndex].setMyIndex(molIndex); | |
1526 | the_molecules[molIndex].setGlobalIndex(molIndex); | |
1527 | for (k = 0; k < comp_stamps[i]->getNAtoms(); k++){ | |
1528 | < | info[l].molMembershipArray[globalAtomIndex] = molIndex; |
1529 | < | globalAtomIndex++; |
1528 | > | info[l].molMembershipArray[globalAtomCounter] = molIndex; |
1529 | > | globalAtomCounter++; |
1530 | } | |
1531 | molIndex++; | |
1532 | } | |
# | Line 1364 | Line 1535 | void SimSetup::makeSysArrays(void){ | |
1535 | ||
1536 | #endif // is_mpi | |
1537 | ||
1538 | < | |
1539 | < | if (info[l].n_SRI){ |
1540 | < | Exclude::createArray(info[l].n_SRI); |
1370 | < | the_excludes = new Exclude * [info[l].n_SRI]; |
1371 | < | for (int ex = 0; ex < info[l].n_SRI; ex++){ |
1372 | < | the_excludes[ex] = new Exclude(ex); |
1373 | < | } |
1374 | < | info[l].globalExcludes = new int; |
1375 | < | info[l].n_exclude = info[l].n_SRI; |
1376 | < | } |
1377 | < | else{ |
1378 | < | Exclude::createArray(1); |
1379 | < | the_excludes = new Exclude * ; |
1380 | < | the_excludes[0] = new Exclude(0); |
1381 | < | the_excludes[0]->setPair(0, 0); |
1382 | < | info[l].globalExcludes = new int; |
1383 | < | info[l].globalExcludes[0] = 0; |
1384 | < | info[l].n_exclude = 0; |
1385 | < | } |
1386 | < | |
1538 | > | info[l].globalExcludes = new int; |
1539 | > | info[l].globalExcludes[0] = 0; |
1540 | > | |
1541 | // set the arrays into the SimInfo object | |
1542 | ||
1543 | info[l].atoms = the_atoms; | |
1544 | info[l].molecules = the_molecules; | |
1545 | info[l].nGlobalExcludes = 0; | |
1546 | < | info[l].excludes = the_excludes; |
1393 | < | |
1546 | > | |
1547 | the_ff->setSimInfo(info); | |
1548 | } | |
1549 | } | |
# | Line 1662 | Line 1815 | void SimSetup::setupZConstraint(SimInfo& theInfo){ | |
1815 | } | |
1816 | ||
1817 | theInfo.addProperty(zconsForcePolicy); | |
1818 | + | |
1819 | + | //set zcons gap |
1820 | + | DoubleData* zconsGap = new DoubleData(); |
1821 | + | zconsGap->setID(ZCONSGAP_ID); |
1822 | + | |
1823 | + | if (globals->haveZConsGap()){ |
1824 | + | zconsGap->setData(globals->getZconsGap()); |
1825 | + | theInfo.addProperty(zconsGap); |
1826 | + | } |
1827 | ||
1828 | + | //set zcons fixtime |
1829 | + | DoubleData* zconsFixtime = new DoubleData(); |
1830 | + | zconsFixtime->setID(ZCONSFIXTIME_ID); |
1831 | + | |
1832 | + | if (globals->haveZConsFixTime()){ |
1833 | + | zconsFixtime->setData(globals->getZconsFixtime()); |
1834 | + | theInfo.addProperty(zconsFixtime); |
1835 | + | } |
1836 | + | |
1837 | + | //set zconsUsingSMD |
1838 | + | IntData* zconsUsingSMD = new IntData(); |
1839 | + | zconsUsingSMD->setID(ZCONSUSINGSMD_ID); |
1840 | + | |
1841 | + | if (globals->haveZConsUsingSMD()){ |
1842 | + | zconsUsingSMD->setData(globals->getZconsUsingSMD()); |
1843 | + | theInfo.addProperty(zconsUsingSMD); |
1844 | + | } |
1845 | + | |
1846 | //Determine the name of ouput file and add it into SimInfo's property list | |
1847 | //Be careful, do not use inFileName, since it is a pointer which | |
1848 | //point to a string at master node, and slave nodes do not contain that string | |
# | Line 1692 | Line 1872 | void SimSetup::setupZConstraint(SimInfo& theInfo){ | |
1872 | tempParaItem.zPos = zconStamp[i]->getZpos(); | |
1873 | tempParaItem.zconsIndex = zconStamp[i]->getMolIndex(); | |
1874 | tempParaItem.kRatio = zconStamp[i]->getKratio(); | |
1875 | < | |
1875 | > | tempParaItem.havingCantVel = zconStamp[i]->haveCantVel(); |
1876 | > | tempParaItem.cantVel = zconStamp[i]->getCantVel(); |
1877 | zconsParaData->addItem(tempParaItem); | |
1878 | } | |
1879 | ||
# | Line 1712 | Line 1893 | void SimSetup::makeMinimizer(){ | |
1893 | } | |
1894 | ||
1895 | void SimSetup::makeMinimizer(){ | |
1896 | < | /* |
1897 | < | OOPSEMinimizerBase* myOOPSEMinimizerBase; |
1717 | < | ObjFunctor1 * objFunc; |
1718 | < | OutputFunctor* outputFunc; |
1719 | < | ConcreteNLModel1* nlp; |
1896 | > | |
1897 | > | OOPSEMinimizer* myOOPSEMinimizer; |
1898 | MinimizerParameterSet* param; | |
1899 | < | ConjugateMinimizerBase* minimizer; |
1722 | < | int dim; |
1899 | > | char minimizerName[100]; |
1900 | ||
1901 | for (int i = 0; i < nInfo; i++){ | |
1902 | < | //creat |
1726 | < | myOOPSEMinimizerBase = new OOPSEMinimizerBase(&(info[i]), the_ff); |
1727 | < | |
1728 | < | //creat the object functor; |
1729 | < | objFunc = (ObjFunctor1*) new ClassMemObjFunctor1<OOPSEMinimizerBase> |
1730 | < | (myOOPSEMinimizerBase, &OOPSEMinimizerBase::calcGradient); |
1731 | < | |
1732 | < | //creat output functor; |
1733 | < | outputFunc = new ClassMemOutputFunctor<OOPSEMinimizerBase> |
1734 | < | (myOOPSEMinimizerBase, &OOPSEMinimizerBase::output); |
1735 | < | |
1736 | < | //creat nonlinear model |
1737 | < | dim = myOOPSEMinimizerBase->getDim(); |
1738 | < | nlp = new ConcreteNLModel1(dim, objFunc); |
1739 | < | |
1902 | > | |
1903 | //prepare parameter set for minimizer | |
1904 | param = new MinimizerParameterSet(); | |
1905 | param->setDefaultParameter(); | |
# | Line 1761 | Line 1924 | void SimSetup::makeMinimizer(){ | |
1924 | param->setWriteFrq(globals->getMinWriteFrq()); | |
1925 | } | |
1926 | ||
1927 | < | if (globals->haveMinResetFrq()){ |
1928 | < | param->setResetFrq(globals->getMinResetFrq()); |
1927 | > | if (globals->haveMinStepSize()){ |
1928 | > | param->setStepSize(globals->getMinStepSize()); |
1929 | } | |
1930 | ||
1931 | if (globals->haveMinLSMaxIter()){ | |
# | Line 1772 | Line 1935 | void SimSetup::makeMinimizer(){ | |
1935 | if (globals->haveMinLSTol()){ | |
1936 | param->setLineSearchTol(globals->getMinLSTol()); | |
1937 | } | |
1775 | – | |
1776 | – | //creat the minimizer |
1777 | – | minimizer = new PRCGMinimizer(nlp, param); |
1778 | – | minimizer->setLineSearchStrategy(nlp, GoldenSection); |
1779 | – | minimizer->setOutputFunctor(outputFunc); |
1938 | ||
1939 | + | strcpy(minimizerName, globals->getMinimizer()); |
1940 | + | |
1941 | + | if (!strcasecmp(minimizerName, "CG")){ |
1942 | + | myOOPSEMinimizer = new PRCGMinimizer(&(info[i]), the_ff, param); |
1943 | + | } |
1944 | + | else if (!strcasecmp(minimizerName, "SD")){ |
1945 | + | //myOOPSEMinimizer = MinimizerFactory.creatMinimizer("", &(info[i]), the_ff, param); |
1946 | + | myOOPSEMinimizer = new SDMinimizer(&(info[i]), the_ff, param); |
1947 | + | } |
1948 | + | else{ |
1949 | + | sprintf(painCave.errMsg, |
1950 | + | "SimSetup error: Unrecognized Minimizer, use Conjugate Gradient \n"); |
1951 | + | painCave.isFatal = 0; |
1952 | + | simError(); |
1953 | + | |
1954 | + | myOOPSEMinimizer = new PRCGMinimizer(&(info[i]), the_ff, param); |
1955 | + | } |
1956 | + | info[i].the_integrator = myOOPSEMinimizer; |
1957 | + | |
1958 | //store the minimizer into simInfo | |
1959 | < | info[i].the_minimizer = minimizer; |
1959 | > | info[i].the_minimizer = myOOPSEMinimizer; |
1960 | info[i].has_minimizer = true; | |
1961 | } | |
1962 | < | */ |
1962 | > | |
1963 | } |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |