ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/SimSetup.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/SimSetup.cpp (file contents):
Revision 736 by tim, Thu Aug 28 21:09:47 2003 UTC vs.
Revision 1104 by gezelter, Tue Apr 13 16:26:03 2004 UTC

# Line 1 | Line 1
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
7   #include "SimSetup.hpp"
8   #include "ReadWrite.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"
# Line 22 | Line 24
24   #define NVT_ENS        1
25   #define NPTi_ENS       2
26   #define NPTf_ENS       3
27 < #define NPTim_ENS      4
26 < #define NPTfm_ENS      5
27 > #define NPTxyz_ENS     4
28  
28 #define FF_DUFF 0
29 #define FF_LJ   1
30 #define FF_EAM  2
29  
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;
64    isInfoArray = 0;
65    nInfo = 1;
66  
# Line 54 | Line 83 | void SimSetup::setSimInfo(SimInfo* the_info, int theNi
83    info = the_info;
84    nInfo = theNinfo;
85    isInfoArray = 1;
86 +  initSuspend = true;
87   }
88  
89  
# Line 92 | Line 122 | void SimSetup::createSim(void){
122   #endif // is_mpi
123  
124   void SimSetup::createSim(void){
95  int i, j, k, globalAtomIndex;
125  
126    // gather all of the information from the Bass file
127  
# Line 108 | Line 137 | void SimSetup::createSim(void){
137  
138    // initialize the system coordinates
139  
140 <  if (!isInfoArray){
140 >  if ( !initSuspend ){
141      initSystemCoords();
142 +
143 +    if( !(globals->getUseInitTime()) )
144 +      info[0].currentTime = 0.0;
145    }  
146  
147    // make the output filenames
148  
149    makeOutNames();
150  
151 <  // make the integrator
152 <
153 <  makeIntegrator();
154 <
151 >  if (globals->haveMinimizer())
152 >    // make minimizer
153 >    makeMinimizer();
154 >  else
155 >    // make the integrator
156 >    makeIntegrator();
157 >  
158   #ifdef IS_MPI
159    mpiSim->mpiRefresh();
160   #endif
# Line 131 | Line 166 | void SimSetup::makeMolecules(void){
166  
167  
168   void SimSetup::makeMolecules(void){
169 <  int k, l;
170 <  int i, j, exI, exJ, tempEx, stampID, atomOffset, excludeOffset;
169 >  int i, j, k;
170 >  int exI, exJ, exK, exL, slI, slJ;
171 >  int tempI, tempJ, tempK, tempL;
172 >  int molI;
173 >  int stampID, atomOffset, rbOffset;
174    molInit molInfo;
175    DirectionalAtom* dAtom;
176 +  RigidBody* myRB;
177 +  StuntDouble* mySD;
178    LinkedAssign* extras;
179    LinkedAssign* current_extra;
180    AtomStamp* currentAtom;
181    BondStamp* currentBond;
182    BendStamp* currentBend;
183    TorsionStamp* currentTorsion;
184 +  RigidBodyStamp* currentRigidBody;
185  
186    bond_pair* theBonds;
187    bend_set* theBends;
188    torsion_set* theTorsions;
189  
190 +  set<int> skipList;
191  
192 +  double phi, theta, psi;
193 +
194    //init the forceField paramters
195  
196    the_ff->readParams();
197  
154
198    // init the atoms
199  
200 <  double ux, uy, uz, u, uSqr;
200 >  int nMembers, nNew, rb1, rb2;
201  
202    for (k = 0; k < nInfo; k++){
203      the_ff->setSimInfo(&(info[k]));
204  
205      atomOffset = 0;
206 <    excludeOffset = 0;
206 >
207      for (i = 0; i < info[k].n_mol; i++){
208        stampID = info[k].molecules[i].getStampID();
209  
# Line 168 | Line 211 | void SimSetup::makeMolecules(void){
211        molInfo.nBonds = comp_stamps[stampID]->getNBonds();
212        molInfo.nBends = comp_stamps[stampID]->getNBends();
213        molInfo.nTorsions = comp_stamps[stampID]->getNTorsions();
214 <      molInfo.nExcludes = molInfo.nBonds + molInfo.nBends + molInfo.nTorsions;
215 <
214 >      molInfo.nRigidBodies = comp_stamps[stampID]->getNRigidBodies();
215 >      
216        molInfo.myAtoms = &(info[k].atoms[atomOffset]);
174      molInfo.myExcludes = &(info[k].excludes[excludeOffset]);
175      molInfo.myBonds = new Bond * [molInfo.nBonds];
176      molInfo.myBends = new Bend * [molInfo.nBends];
177      molInfo.myTorsions = new Torsion * [molInfo.nTorsions];
217  
218 +      if (molInfo.nBonds > 0)
219 +        molInfo.myBonds = new (Bond *) [molInfo.nBonds];
220 +      else
221 +        molInfo.myBonds = NULL;
222 +
223 +      if (molInfo.nBends > 0)
224 +        molInfo.myBends = new (Bend *) [molInfo.nBends];
225 +      else
226 +        molInfo.myBends = NULL;
227 +
228 +      if (molInfo.nTorsions > 0)
229 +        molInfo.myTorsions = new (Torsion *) [molInfo.nTorsions];
230 +      else
231 +        molInfo.myTorsions = NULL;
232 +
233        theBonds = new bond_pair[molInfo.nBonds];
234        theBends = new bend_set[molInfo.nBends];
235        theTorsions = new torsion_set[molInfo.nTorsions];
236 <
236 >      
237        // make the Atoms
238  
239        for (j = 0; j < molInfo.nAtoms; j++){
240          currentAtom = comp_stamps[stampID]->getAtom(j);
241 +
242          if (currentAtom->haveOrientation()){
243            dAtom = new DirectionalAtom((j + atomOffset),
244                                        info[k].getConfiguration());
245            info[k].n_oriented++;
246            molInfo.myAtoms[j] = dAtom;
247  
248 <          ux = currentAtom->getOrntX();
249 <          uy = currentAtom->getOrntY();
250 <          uz = currentAtom->getOrntZ();
248 >          // Directional Atoms have standard unit vectors which are oriented
249 >          // in space using the three Euler angles.  We assume the standard
250 >          // unit vector was originally along the z axis below.
251  
252 <          uSqr = (ux * ux) + (uy * uy) + (uz * uz);
252 >          phi = currentAtom->getEulerPhi() * M_PI / 180.0;
253 >          theta = currentAtom->getEulerTheta() * M_PI / 180.0;
254 >          psi = currentAtom->getEulerPsi()* M_PI / 180.0;
255  
256 <          u = sqrt(uSqr);
257 <          ux = ux / u;
201 <          uy = uy / u;
202 <          uz = uz / u;
203 <
204 <          dAtom->setSUx(ux);
205 <          dAtom->setSUy(uy);
206 <          dAtom->setSUz(uz);
256 >          dAtom->setUnitFrameFromEuler(phi, theta, psi);
257 >            
258          }
259          else{
260 <          molInfo.myAtoms[j] = new GeneralAtom((j + atomOffset),
261 <                                               info[k].getConfiguration());
260 >
261 >          molInfo.myAtoms[j] = new Atom((j + atomOffset), info[k].getConfiguration());
262          }
263 +
264          molInfo.myAtoms[j]->setType(currentAtom->getType());
265  
266   #ifdef IS_MPI
# Line 224 | Line 276 | void SimSetup::makeMolecules(void){
276          theBonds[j].a = currentBond->getA() + atomOffset;
277          theBonds[j].b = currentBond->getB() + atomOffset;
278  
279 <        exI = theBonds[j].a;
280 <        exJ = theBonds[j].b;
279 >        tempI = theBonds[j].a;
280 >        tempJ = theBonds[j].b;
281  
230        // exclude_I must always be the smaller of the pair
231        if (exI > exJ){
232          tempEx = exI;
233          exI = exJ;
234          exJ = tempEx;
235        }
282   #ifdef IS_MPI
283 <        tempEx = exI;
284 <        exI = info[k].atoms[tempEx]->getGlobalIndex() + 1;
285 <        tempEx = exJ;
286 <        exJ = info[k].atoms[tempEx]->getGlobalIndex() + 1;
283 >        exI = info[k].atoms[tempI]->getGlobalIndex() + 1;
284 >        exJ = info[k].atoms[tempJ]->getGlobalIndex() + 1;
285 > #else
286 >        exI = tempI + 1;
287 >        exJ = tempJ + 1;
288 > #endif
289  
290 <        info[k].excludes[j + excludeOffset]->setPair(exI, exJ);
243 < #else  // isn't MPI
244 <
245 <        info[k].excludes[j + excludeOffset]->setPair((exI + 1), (exJ + 1));
246 < #endif  //is_mpi
290 >        info[k].excludes->addPair(exI, exJ);
291        }
248      excludeOffset += molInfo.nBonds;
292  
293        //make the bends
294        for (j = 0; j < molInfo.nBends; j++){
# Line 295 | Line 338 | void SimSetup::makeMolecules(void){
338            }
339          }
340  
341 <        if (!theBends[j].isGhost){
342 <          exI = theBends[j].a;
343 <          exJ = theBends[j].c;
344 <        }
345 <        else{
303 <          exI = theBends[j].a;
304 <          exJ = theBends[j].b;
305 <        }
306 <
307 <        // exclude_I must always be the smaller of the pair
308 <        if (exI > exJ){
309 <          tempEx = exI;
310 <          exI = exJ;
311 <          exJ = tempEx;
312 <        }
341 >        if (theBends[j].isGhost) {
342 >          
343 >          tempI = theBends[j].a;
344 >          tempJ = theBends[j].b;
345 >          
346   #ifdef IS_MPI
347 <        tempEx = exI;
348 <        exI = info[k].atoms[tempEx]->getGlobalIndex() + 1;
349 <        tempEx = exJ;
350 <        exJ = info[k].atoms[tempEx]->getGlobalIndex() + 1;
347 >          exI = info[k].atoms[tempI]->getGlobalIndex() + 1;
348 >          exJ = info[k].atoms[tempJ]->getGlobalIndex() + 1;
349 > #else
350 >          exI = tempI + 1;
351 >          exJ = tempJ + 1;
352 > #endif          
353 >          info[k].excludes->addPair(exI, exJ);
354  
355 <        info[k].excludes[j + excludeOffset]->setPair(exI, exJ);
356 < #else  // isn't MPI
357 <        info[k].excludes[j + excludeOffset]->setPair((exI + 1), (exJ + 1));
358 < #endif  //is_mpi
355 >        } else {
356 >
357 >          tempI = theBends[j].a;
358 >          tempJ = theBends[j].b;
359 >          tempK = theBends[j].c;
360 >          
361 > #ifdef IS_MPI
362 >          exI = info[k].atoms[tempI]->getGlobalIndex() + 1;
363 >          exJ = info[k].atoms[tempJ]->getGlobalIndex() + 1;
364 >          exK = info[k].atoms[tempK]->getGlobalIndex() + 1;
365 > #else
366 >          exI = tempI + 1;
367 >          exJ = tempJ + 1;
368 >          exK = tempK + 1;
369 > #endif
370 >          
371 >          info[k].excludes->addPair(exI, exK);
372 >          info[k].excludes->addPair(exI, exJ);
373 >          info[k].excludes->addPair(exJ, exK);
374 >        }
375        }
324      excludeOffset += molInfo.nBends;
376  
377        for (j = 0; j < molInfo.nTorsions; j++){
378          currentTorsion = comp_stamps[stampID]->getTorsion(j);
# Line 330 | Line 381 | void SimSetup::makeMolecules(void){
381          theTorsions[j].c = currentTorsion->getC() + atomOffset;
382          theTorsions[j].d = currentTorsion->getD() + atomOffset;
383  
384 <        exI = theTorsions[j].a;
385 <        exJ = theTorsions[j].d;
384 >        tempI = theTorsions[j].a;      
385 >        tempJ = theTorsions[j].b;
386 >        tempK = theTorsions[j].c;
387 >        tempL = theTorsions[j].d;
388  
389 <        // exclude_I must always be the smaller of the pair
390 <        if (exI > exJ){
391 <          tempEx = exI;
392 <          exI = exJ;
393 <          exJ = tempEx;
389 > #ifdef IS_MPI
390 >        exI = info[k].atoms[tempI]->getGlobalIndex() + 1;
391 >        exJ = info[k].atoms[tempJ]->getGlobalIndex() + 1;
392 >        exK = info[k].atoms[tempK]->getGlobalIndex() + 1;
393 >        exL = info[k].atoms[tempL]->getGlobalIndex() + 1;
394 > #else
395 >        exI = tempI + 1;
396 >        exJ = tempJ + 1;
397 >        exK = tempK + 1;
398 >        exL = tempL + 1;
399 > #endif
400 >
401 >        info[k].excludes->addPair(exI, exJ);
402 >        info[k].excludes->addPair(exI, exK);
403 >        info[k].excludes->addPair(exI, exL);        
404 >        info[k].excludes->addPair(exJ, exK);
405 >        info[k].excludes->addPair(exJ, exL);
406 >        info[k].excludes->addPair(exK, exL);
407 >      }
408 >
409 >      for (j = 0; j < molInfo.nRigidBodies; j++){
410 >
411 >        currentRigidBody = comp_stamps[stampID]->getRigidBody(j);
412 >        nMembers = currentRigidBody->getNMembers();
413 >
414 >        // Create the Rigid Body:
415 >
416 >        myRB = new RigidBody();
417 >        
418 >        for (rb1 = 0; rb1 < nMembers; rb1++) {
419 >
420 >          // molI is atom numbering inside this molecule
421 >          molI = currentRigidBody->getMember(rb1);    
422 >
423 >          // tempI is atom numbering on local processor
424 >          tempI = molI + atomOffset;
425 >
426 >          // currentAtom is the AtomStamp (which we need for
427 >          // rigid body reference positions)
428 >          currentAtom = comp_stamps[stampID]->getAtom(molI);
429 >
430 >          // When we add to the rigid body, add the atom itself and
431 >          // the stamp info:
432 >
433 >          myRB->addAtom(info[k].atoms[tempI], currentAtom);
434 >          
435 >          // Add this atom to the Skip List for the integrators
436 > #ifdef IS_MPI
437 >          slI = info[k].atoms[tempI]->getGlobalIndex();
438 > #else
439 >          slI = tempI;
440 > #endif
441 >          skipList.insert(slI);
442 >          
443          }
444 +        
445 +        for(rb1 = 0; rb1 < nMembers - 1; rb1++) {
446 +          for(rb2 = rb1+1; rb2 < nMembers; rb2++) {
447 +            
448 +            tempI = currentRigidBody->getMember(rb1);
449 +            tempJ = currentRigidBody->getMember(rb2);
450 +            
451 +            // Some explanation is required here.
452 +            // Fortran indexing starts at 1, while c indexing starts at 0
453 +            // Also, in parallel computations, the GlobalIndex is
454 +            // used for the exclude list:
455 +            
456   #ifdef IS_MPI
457 <        tempEx = exI;
458 <        exI = info[k].atoms[tempEx]->getGlobalIndex() + 1;
459 <        tempEx = exJ;
460 <        exJ = info[k].atoms[tempEx]->getGlobalIndex() + 1;
457 >            exI = info[k].atoms[tempI]->getGlobalIndex() + 1;
458 >            exJ = info[k].atoms[tempJ]->getGlobalIndex() + 1;
459 > #else
460 >            exI = tempI + 1;
461 >            exJ = tempJ + 1;
462 > #endif
463 >            
464 >            info[k].excludes->addPair(exI, exJ);
465 >            
466 >          }
467 >        }
468  
469 <        info[k].excludes[j + excludeOffset]->setPair(exI, exJ);
470 < #else  // isn't MPI
350 <        info[k].excludes[j + excludeOffset]->setPair((exI + 1), (exJ + 1));
351 < #endif  //is_mpi
469 >        molInfo.myRigidBodies.push_back(myRB);
470 >        info[k].rigidBodies.push_back(myRB);
471        }
472 <      excludeOffset += molInfo.nTorsions;
472 >      
473  
474 +      // After this is all set up, scan through the atoms to
475 +      // see if they can be added to the integrableObjects:
476  
477 <      // send the arrays off to the forceField for init.
477 >      for (j = 0; j < molInfo.nAtoms; j++){
478 >
479 > #ifdef IS_MPI
480 >        slJ = molInfo.myAtoms[j]->getGlobalIndex();
481 > #else
482 >        slJ = j+atomOffset;
483 > #endif
484  
485 +        // if they aren't on the skip list, then they can be integrated
486 +
487 +        if (skipList.find(slJ) == skipList.end()) {
488 +          mySD = (StuntDouble *) molInfo.myAtoms[j];
489 +          info[k].integrableObjects.push_back(mySD);
490 +          molInfo.myIntegrableObjects.push_back(mySD);
491 +        }
492 +      }
493 +
494 +      // all rigid bodies are integrated:
495 +
496 +      for (j = 0; j < molInfo.nRigidBodies; j++) {
497 +        mySD = (StuntDouble *) molInfo.myRigidBodies[j];
498 +        info[k].integrableObjects.push_back(mySD);      
499 +        molInfo.myIntegrableObjects.push_back(mySD);
500 +      }
501 +    
502 +      
503 +      // send the arrays off to the forceField for init.
504 +      
505        the_ff->initializeAtoms(molInfo.nAtoms, molInfo.myAtoms);
506        the_ff->initializeBonds(molInfo.nBonds, molInfo.myBonds, theBonds);
507        the_ff->initializeBends(molInfo.nBends, molInfo.myBends, theBends);
508        the_ff->initializeTorsions(molInfo.nTorsions, molInfo.myTorsions,
509                                   theTorsions);
510  
364
511        info[k].molecules[i].initialize(molInfo);
512  
513  
# Line 369 | Line 515 | void SimSetup::makeMolecules(void){
515        delete[] theBonds;
516        delete[] theBends;
517        delete[] theTorsions;
518 <    }
518 >    }    
519    }
520  
521   #ifdef IS_MPI
# Line 379 | Line 525 | void SimSetup::makeMolecules(void){
525  
526    // clean up the forcefield
527  
528 <  the_ff->calcRcut();
528 >  if (!globals->haveLJrcut()){
529 >
530 >    the_ff->calcRcut();
531 >
532 >  } else {
533 >    
534 >    the_ff->setRcut( globals->getLJrcut() );
535 >  }
536 >
537    the_ff->cleanMe();
538   }
539  
# Line 553 | Line 707 | void SimSetup::gatherInfo(void){
707  
708  
709   void SimSetup::gatherInfo(void){
710 <  int i, j, k;
710 >  int i;
711  
712    ensembleCase = -1;
713    ffCase = -1;
# Line 581 | Line 735 | void SimSetup::gatherInfo(void){
735    else if (!strcasecmp(force_field, "EAM")){
736      ffCase = FF_EAM;
737    }
738 +  else if (!strcasecmp(force_field, "WATER")){
739 +    ffCase = FF_H2O;
740 +  }
741    else{
742      sprintf(painCave.errMsg, "SimSetup Error. Unrecognized force field -> %s\n",
743              force_field);
# Line 604 | Line 761 | void SimSetup::gatherInfo(void){
761    else if (!strcasecmp(ensemble, "NPTf")){
762      ensembleCase = NPTf_ENS;
763    }
764 <  else if (!strcasecmp(ensemble, "NPTim")){
765 <    ensembleCase = NPTim_ENS;
764 >  else if (!strcasecmp(ensemble, "NPTxyz")){
765 >    ensembleCase = NPTxyz_ENS;
766    }
610  else if (!strcasecmp(ensemble, "NPTfm")){
611    ensembleCase = NPTfm_ENS;
612  }
767    else{
768      sprintf(painCave.errMsg,
769 <            "SimSetup Warning. Unrecognized Ensemble -> %s, "
770 <            "reverting to NVE for this simulation.\n",
769 >            "SimSetup Warning. Unrecognized Ensemble -> %s \n"
770 >            "\treverting to NVE for this simulation.\n",
771              ensemble);
772           painCave.isFatal = 0;
773           simError();
# Line 645 | Line 799 | void SimSetup::gatherInfo(void){
799        if (!the_components[i]->haveNMol()){
800          // we have a problem
801          sprintf(painCave.errMsg,
802 <                "SimSetup Error. No global NMol or component NMol"
803 <                " given. Cannot calculate the number of atoms.\n");
802 >                "SimSetup Error. No global NMol or component NMol given.\n"
803 >                "\tCannot calculate the number of atoms.\n");
804          painCave.isFatal = 1;
805          simError();
806        }
# Line 666 | Line 820 | void SimSetup::gatherInfo(void){
820      simError();
821    }
822  
823 +  //check whether sample time, status time, thermal time and reset time are divisble by dt
824 +  if (!isDivisible(globals->getSampleTime(), globals->getDt())){
825 +    sprintf(painCave.errMsg,
826 +            "Sample time is not divisible by dt.\n"
827 +            "\tThis will result in samples that are not uniformly\n"
828 +            "\tdistributed in time.  If this is a problem, change\n"
829 +            "\tyour sampleTime variable.\n");
830 +    painCave.isFatal = 0;
831 +    simError();    
832 +  }
833 +
834 +  if (globals->haveStatusTime() && !isDivisible(globals->getSampleTime(), globals->getDt())){
835 +    sprintf(painCave.errMsg,
836 +            "Status time is not divisible by dt.\n"
837 +            "\tThis will result in status reports that are not uniformly\n"
838 +            "\tdistributed in time.  If this is a problem, change \n"
839 +            "\tyour statusTime variable.\n");
840 +    painCave.isFatal = 0;
841 +    simError();    
842 +  }
843 +
844 +  if (globals->haveThermalTime() && !isDivisible(globals->getThermalTime(), globals->getDt())){
845 +    sprintf(painCave.errMsg,
846 +            "Thermal time is not divisible by dt.\n"
847 +            "\tThis will result in thermalizations that are not uniformly\n"
848 +            "\tdistributed in time.  If this is a problem, change \n"
849 +            "\tyour thermalTime variable.\n");
850 +    painCave.isFatal = 0;
851 +    simError();    
852 +  }  
853 +
854 +  if (globals->haveResetTime() && !isDivisible(globals->getResetTime(), globals->getDt())){
855 +    sprintf(painCave.errMsg,
856 +            "Reset time is not divisible by dt.\n"
857 +            "\tThis will result in integrator resets that are not uniformly\n"
858 +            "\tdistributed in time.  If this is a problem, change\n"
859 +            "\tyour resetTime variable.\n");
860 +    painCave.isFatal = 0;
861 +    simError();    
862 +  }
863 +
864    // set the status, sample, and thermal kick times
865  
866    for (i = 0; i < nInfo; i++){
# Line 688 | Line 883 | void SimSetup::gatherInfo(void){
883        info[i].thermalTime = globals->getThermalTime();
884      }
885  
886 <    // check for the temperature set flag
886 >    info[i].resetIntegrator = 0;
887 >    if( globals->haveResetTime() ){
888 >      info[i].resetTime = globals->getResetTime();
889 >      info[i].resetIntegrator = 1;
890 >    }
891  
892 +    // check for the temperature set flag
893 +    
894      if (globals->haveTempSet())
895        info[i].setTemp = globals->getTempSet();
896  
897 <    // get some of the tricky things that may still be in the globals
897 >    // check for the extended State init
898  
899 <    double boxVector[3];
900 <    if (globals->haveBox()){
901 <      boxVector[0] = globals->getBox();
701 <      boxVector[1] = globals->getBox();
702 <      boxVector[2] = globals->getBox();
703 <
704 <      info[i].setBox(boxVector);
705 <    }
706 <    else if (globals->haveDensity()){
707 <      double vol;
708 <      vol = (double) tot_nmol / globals->getDensity();
709 <      boxVector[0] = pow(vol, (1.0 / 3.0));
710 <      boxVector[1] = boxVector[0];
711 <      boxVector[2] = boxVector[0];
712 <
713 <      info[i].setBox(boxVector);
714 <    }
715 <    else{
716 <      if (!globals->haveBoxX()){
717 <        sprintf(painCave.errMsg,
718 <                "SimSetup error, no periodic BoxX size given.\n");
719 <        painCave.isFatal = 1;
720 <        simError();
721 <      }
722 <      boxVector[0] = globals->getBoxX();
723 <
724 <      if (!globals->haveBoxY()){
725 <        sprintf(painCave.errMsg,
726 <                "SimSetup error, no periodic BoxY size given.\n");
727 <        painCave.isFatal = 1;
728 <        simError();
729 <      }
730 <      boxVector[1] = globals->getBoxY();
731 <
732 <      if (!globals->haveBoxZ()){
733 <        sprintf(painCave.errMsg,
734 <                "SimSetup error, no periodic BoxZ size given.\n");
735 <        painCave.isFatal = 1;
736 <        simError();
737 <      }
738 <      boxVector[2] = globals->getBoxZ();
739 <
740 <      info[i].setBox(boxVector);
741 <    }
899 >    info[i].useInitXSstate = globals->getUseInitXSstate();
900 >    info[i].orthoTolerance = globals->getOrthoBoxTolerance();
901 >    
902    }
903 <
903 >  
904    //setup seed for random number generator
905    int seedValue;
906  
# Line 780 | Line 940 | void SimSetup::gatherInfo(void){
940    for (int i = 0; i < nInfo; i++){
941      info[i].setSeed(seedValue);
942    }
943 <
943 >  
944   #ifdef IS_MPI
945 <  strcpy(checkPointMsg, "Succesfully gathered all information from Bass\n");
945 >  strcpy(checkPointMsg, "Successfully gathered all information from Bass\n");
946    MPIcheckPoint();
947   #endif // is_mpi
948   }
# Line 815 | Line 975 | void SimSetup::finalInfoCheck(void){
975  
976        if (!globals->haveECR()){
977          sprintf(painCave.errMsg,
978 <                "SimSetup Warning: using default value of 1/2 the smallest "
979 <                "box length for the electrostaticCutoffRadius.\n"
980 <                "I hope you have a very fast processor!\n");
978 >                "SimSetup Warning: No value was set for electrostaticCutoffRadius.\n"
979 >                "\tOOPSE will use a default value of 15.0 angstroms"
980 >                "\tfor the electrostaticCutoffRadius.\n");
981          painCave.isFatal = 0;
982          simError();
983 <        double smallest;
824 <        smallest = info[i].boxL[0];
825 <        if (info[i].boxL[1] <= smallest)
826 <          smallest = info[i].boxL[1];
827 <        if (info[i].boxL[2] <= smallest)
828 <          smallest = info[i].boxL[2];
829 <        theEcr = 0.5 * smallest;
983 >        theEcr = 15.0;
984        }
985        else{
986          theEcr = globals->getECR();
# Line 834 | Line 988 | void SimSetup::finalInfoCheck(void){
988  
989        if (!globals->haveEST()){
990          sprintf(painCave.errMsg,
991 <                "SimSetup Warning: using default value of 0.05 * the "
992 <                "electrostaticCutoffRadius for the electrostaticSkinThickness\n");
991 >                "SimSetup Warning: No value was set for electrostaticSkinThickness.\n"
992 >                "\tOOPSE will use a default value of\n"
993 >                "\t0.05 * electrostaticCutoffRadius\n"
994 >                "\tfor the electrostaticSkinThickness\n");
995          painCave.isFatal = 0;
996          simError();
997          theEst = 0.05 * theEcr;
# Line 844 | Line 1000 | void SimSetup::finalInfoCheck(void){
1000          theEst = globals->getEST();
1001        }
1002  
1003 <      info[i].setEcr(theEcr, theEst);
1003 >      info[i].setDefaultEcr(theEcr, theEst);
1004  
1005        if (!globals->haveDielectric()){
1006          sprintf(painCave.errMsg,
1007 <                "SimSetup Error: You are trying to use Reaction Field without"
1008 <                "setting a dielectric constant!\n");
1007 >                "SimSetup Error: No Dielectric constant was set.\n"
1008 >                "\tYou are trying to use Reaction Field without"
1009 >                "\tsetting a dielectric constant!\n");
1010          painCave.isFatal = 1;
1011          simError();
1012        }
# Line 859 | Line 1016 | void SimSetup::finalInfoCheck(void){
1016        if (usesDipoles){
1017          if (!globals->haveECR()){
1018            sprintf(painCave.errMsg,
1019 <                  "SimSetup Warning: using default value of 1/2 the smallest "
1020 <                  "box length for the electrostaticCutoffRadius.\n"
1021 <                  "I hope you have a very fast processor!\n");
1022 <          painCave.isFatal = 0;
1023 <          simError();
1024 <          double smallest;
868 <          smallest = info[i].boxL[0];
869 <          if (info[i].boxL[1] <= smallest)
870 <            smallest = info[i].boxL[1];
871 <          if (info[i].boxL[2] <= smallest)
872 <            smallest = info[i].boxL[2];
873 <          theEcr = 0.5 * smallest;
1019 >                  "SimSetup Warning: No value was set for electrostaticCutoffRadius.\n"
1020 >                  "\tOOPSE will use a default value of 15.0 angstroms"
1021 >                  "\tfor the electrostaticCutoffRadius.\n");
1022 >          painCave.isFatal = 0;
1023 >          simError();
1024 >          theEcr = 15.0;
1025          }
1026          else{
1027            theEcr = globals->getECR();
1028          }
1029 <
1029 >        
1030          if (!globals->haveEST()){
1031            sprintf(painCave.errMsg,
1032 <                  "SimSetup Warning: using default value of 0.05 * the "
1033 <                  "electrostaticCutoffRadius for the "
1034 <                  "electrostaticSkinThickness\n");
1032 >                  "SimSetup Warning: No value was set for electrostaticSkinThickness.\n"
1033 >                  "\tOOPSE will use a default value of\n"
1034 >                  "\t0.05 * electrostaticCutoffRadius\n"
1035 >                  "\tfor the electrostaticSkinThickness\n");
1036            painCave.isFatal = 0;
1037            simError();
1038            theEst = 0.05 * theEcr;
# Line 888 | Line 1040 | void SimSetup::finalInfoCheck(void){
1040          else{
1041            theEst = globals->getEST();
1042          }
1043 <
1044 <        info[i].setEcr(theEcr, theEst);
1043 >        
1044 >        info[i].setDefaultEcr(theEcr, theEst);
1045        }
1046      }
1047    }
896
1048   #ifdef IS_MPI
1049    strcpy(checkPointMsg, "post processing checks out");
1050    MPIcheckPoint();
1051   #endif // is_mpi
1052   }
1053 <
1053 >  
1054   void SimSetup::initSystemCoords(void){
1055    int i;
1056  
# Line 916 | Line 1067 | void SimSetup::initSystemCoords(void){
1067      if (worldRank == 0){
1068   #endif //is_mpi
1069        inName = globals->getInitialConfig();
919      double* tempDouble = new double[1000000];
1070        fileInit = new InitializeFromFile(inName);
1071   #ifdef IS_MPI
1072      }
# Line 928 | Line 1078 | void SimSetup::initSystemCoords(void){
1078      delete fileInit;
1079    }
1080    else{
1081 < #ifdef IS_MPI
932 <
1081 >    
1082      // no init from bass
1083 <
1083 >    
1084      sprintf(painCave.errMsg,
1085 <            "Cannot intialize a parallel simulation without an initial configuration file.\n");
1086 <    painCave.isFatal;
1085 >            "Cannot intialize a simulation without an initial configuration file.\n");
1086 >    painCave.isFatal = 1;;
1087      simError();
1088 <
940 < #else
941 <
942 <    initFromBass();
943 <
944 <
945 < #endif
1088 >    
1089    }
1090  
1091   #ifdef IS_MPI
# Line 1096 | Line 1239 | void SimSetup::createFF(void){
1239        the_ff = new EAM_FF();
1240        break;
1241  
1242 +    case FF_H2O:
1243 +      the_ff = new WATER();
1244 +      break;
1245 +
1246      default:
1247        sprintf(painCave.errMsg,
1248                "SimSetup Error. Unrecognized force field in case statement.\n");
# Line 1160 | Line 1307 | void SimSetup::calcSysValues(void){
1307   }
1308  
1309   void SimSetup::calcSysValues(void){
1310 <  int i, j, k;
1310 >  int i;
1311  
1312    int* molMembershipArray;
1313  
# Line 1168 | Line 1315 | void SimSetup::calcSysValues(void){
1315    tot_bonds = 0;
1316    tot_bends = 0;
1317    tot_torsions = 0;
1318 +  tot_rigid = 0;
1319    for (i = 0; i < n_components; i++){
1320      tot_atoms += components_nmol[i] * comp_stamps[i]->getNAtoms();
1321      tot_bonds += components_nmol[i] * comp_stamps[i]->getNBonds();
1322      tot_bends += components_nmol[i] * comp_stamps[i]->getNBends();
1323      tot_torsions += components_nmol[i] * comp_stamps[i]->getNTorsions();
1324 +    tot_rigid += components_nmol[i] * comp_stamps[i]->getNRigidBodies();
1325    }
1326 <
1326 >  
1327    tot_SRI = tot_bonds + tot_bends + tot_torsions;
1328    molMembershipArray = new int[tot_atoms];
1329  
# Line 1196 | Line 1345 | void SimSetup::mpiMolDivide(void){
1345    int i, j, k;
1346    int localMol, allMol;
1347    int local_atoms, local_bonds, local_bends, local_torsions, local_SRI;
1348 +  int local_rigid;
1349  
1350    mpiSim = new mpiSimulation(info);
1351  
# Line 1212 | Line 1362 | void SimSetup::mpiMolDivide(void){
1362    local_bonds = 0;
1363    local_bends = 0;
1364    local_torsions = 0;
1365 +  local_rigid = 0;
1366    globalAtomIndex = 0;
1367  
1217
1368    for (i = 0; i < n_components; i++){
1369      for (j = 0; j < components_nmol[i]; j++){
1370        if (mol2proc[allMol] == worldRank){
# Line 1222 | Line 1372 | void SimSetup::mpiMolDivide(void){
1372          local_bonds += comp_stamps[i]->getNBonds();
1373          local_bends += comp_stamps[i]->getNBends();
1374          local_torsions += comp_stamps[i]->getNTorsions();
1375 +        local_rigid += comp_stamps[i]->getNRigidBodies();
1376          localMol++;
1377        }      
1378        for (k = 0; k < comp_stamps[i]->getNAtoms(); k++){
# Line 1235 | Line 1386 | void SimSetup::mpiMolDivide(void){
1386    local_SRI = local_bonds + local_bends + local_torsions;
1387  
1388    info[0].n_atoms = mpiSim->getMyNlocal();  
1389 +  
1390  
1391    if (local_atoms != info[0].n_atoms){
1392      sprintf(painCave.errMsg,
1393 <            "SimSetup error: mpiSim's localAtom (%d) and SimSetup's"
1394 <            " localAtom (%d) are not equal.\n",
1393 >            "SimSetup error: mpiSim's localAtom (%d) and SimSetup's\n"
1394 >            "\tlocalAtom (%d) are not equal.\n",
1395              info[0].n_atoms, local_atoms);
1396      painCave.isFatal = 1;
1397      simError();
# Line 1259 | Line 1411 | void SimSetup::makeSysArrays(void){
1411  
1412  
1413   void SimSetup::makeSysArrays(void){
1414 <  int i, j, k, l;
1414 >
1415 > #ifndef IS_MPI
1416 >  int k, j;
1417 > #endif // is_mpi
1418 >  int i, l;
1419  
1420    Atom** the_atoms;
1421    Molecule* the_molecules;
1266  Exclude** the_excludes;
1422  
1268
1423    for (l = 0; l < nInfo; l++){
1424      // create the atom and short range interaction arrays
1425  
# Line 1308 | Line 1462 | void SimSetup::makeSysArrays(void){
1462  
1463   #endif // is_mpi
1464  
1465 <
1466 <    if (info[l].n_SRI){
1467 <      Exclude::createArray(info[l].n_SRI);
1314 <      the_excludes = new Exclude * [info[l].n_SRI];
1315 <      for (int ex = 0; ex < info[l].n_SRI; ex++){
1316 <        the_excludes[ex] = new Exclude(ex);
1317 <      }
1318 <      info[l].globalExcludes = new int;
1319 <      info[l].n_exclude = info[l].n_SRI;
1320 <    }
1321 <    else{
1322 <      Exclude::createArray(1);
1323 <      the_excludes = new Exclude * ;
1324 <      the_excludes[0] = new Exclude(0);
1325 <      the_excludes[0]->setPair(0, 0);
1326 <      info[l].globalExcludes = new int;
1327 <      info[l].globalExcludes[0] = 0;
1328 <      info[l].n_exclude = 0;
1329 <    }
1330 <
1465 >    info[l].globalExcludes = new int;
1466 >    info[l].globalExcludes[0] = 0;
1467 >    
1468      // set the arrays into the SimInfo object
1469  
1470      info[l].atoms = the_atoms;
1471      info[l].molecules = the_molecules;
1472      info[l].nGlobalExcludes = 0;
1336    info[l].excludes = the_excludes;
1473  
1474      the_ff->setSimInfo(info);
1475    }
# Line 1342 | Line 1478 | void SimSetup::makeIntegrator(void){
1478   void SimSetup::makeIntegrator(void){
1479    int k;
1480  
1481 +  NVE<RealIntegrator>* myNVE = NULL;
1482    NVT<RealIntegrator>* myNVT = NULL;
1483 <  NPTi<RealIntegrator>* myNPTi = NULL;
1484 <  NPTf<RealIntegrator>* myNPTf = NULL;
1485 <  NPTim<RealIntegrator>* myNPTim = NULL;
1349 <  NPTfm<RealIntegrator>* myNPTfm = NULL;
1483 >  NPTi<NPT<RealIntegrator> >* myNPTi = NULL;
1484 >  NPTf<NPT<RealIntegrator> >* myNPTf = NULL;
1485 >  NPTxyz<NPT<RealIntegrator> >* myNPTxyz = NULL;
1486    
1487    for (k = 0; k < nInfo; k++){
1488      switch (ensembleCase){
1489        case NVE_ENS:
1490          if (globals->haveZconstraints()){
1491            setupZConstraint(info[k]);
1492 <          new ZConstraint<NVE<RealIntegrator> >(&(info[k]), the_ff);
1492 >          myNVE = new ZConstraint<NVE<RealIntegrator> >(&(info[k]), the_ff);
1493          }
1494 <        else
1495 <          new NVE<RealIntegrator>(&(info[k]), the_ff);
1494 >        else{
1495 >          myNVE = new NVE<RealIntegrator>(&(info[k]), the_ff);
1496 >        }
1497 >        
1498 >        info->the_integrator = myNVE;
1499          break;
1500  
1501        case NVT_ENS:
# Line 1374 | Line 1513 | void SimSetup::makeIntegrator(void){
1513          else{
1514            sprintf(painCave.errMsg,
1515                    "SimSetup error: If you use the NVT\n"
1516 <                  "    ensemble, you must set tauThermostat.\n");
1516 >                  "\tensemble, you must set tauThermostat.\n");
1517            painCave.isFatal = 1;
1518            simError();
1519          }
1520 +
1521 +        info->the_integrator = myNVT;
1522          break;
1523  
1524        case NPTi_ENS:
1525          if (globals->haveZconstraints()){
1526            setupZConstraint(info[k]);
1527 <          myNPTi = new ZConstraint<NPTi<RealIntegrator> >(&(info[k]), the_ff);
1527 >          myNPTi = new ZConstraint<NPTi<NPT <RealIntegrator> > >(&(info[k]), the_ff);
1528          }
1529          else
1530 <          myNPTi = new NPTi<RealIntegrator>(&(info[k]), the_ff);
1530 >          myNPTi = new NPTi<NPT<RealIntegrator> >(&(info[k]), the_ff);
1531  
1532          myNPTi->setTargetTemp(globals->getTargetTemp());
1533  
# Line 1395 | Line 1536 | void SimSetup::makeIntegrator(void){
1536          else{
1537            sprintf(painCave.errMsg,
1538                    "SimSetup error: If you use a constant pressure\n"
1539 <                  "    ensemble, you must set targetPressure in the BASS file.\n");
1539 >                  "\tensemble, you must set targetPressure in the BASS file.\n");
1540            painCave.isFatal = 1;
1541            simError();
1542          }
# Line 1405 | Line 1546 | void SimSetup::makeIntegrator(void){
1546          else{
1547            sprintf(painCave.errMsg,
1548                    "SimSetup error: If you use an NPT\n"
1549 <                  "    ensemble, you must set tauThermostat.\n");
1549 >                  "\tensemble, you must set tauThermostat.\n");
1550            painCave.isFatal = 1;
1551            simError();
1552          }
# Line 1415 | Line 1556 | void SimSetup::makeIntegrator(void){
1556          else{
1557            sprintf(painCave.errMsg,
1558                    "SimSetup error: If you use an NPT\n"
1559 <                  "    ensemble, you must set tauBarostat.\n");
1559 >                  "\tensemble, you must set tauBarostat.\n");
1560            painCave.isFatal = 1;
1561            simError();
1562          }
1563 +
1564 +        info->the_integrator = myNPTi;
1565          break;
1566  
1567        case NPTf_ENS:
1568          if (globals->haveZconstraints()){
1569            setupZConstraint(info[k]);
1570 <          myNPTf = new ZConstraint<NPTf<RealIntegrator> >(&(info[k]), the_ff);
1570 >          myNPTf = new ZConstraint<NPTf<NPT <RealIntegrator> > >(&(info[k]), the_ff);
1571          }
1572          else
1573 <          myNPTf = new NPTf<RealIntegrator>(&(info[k]), the_ff);
1573 >          myNPTf = new NPTf<NPT <RealIntegrator> >(&(info[k]), the_ff);
1574  
1575          myNPTf->setTargetTemp(globals->getTargetTemp());
1576  
# Line 1436 | Line 1579 | void SimSetup::makeIntegrator(void){
1579          else{
1580            sprintf(painCave.errMsg,
1581                    "SimSetup error: If you use a constant pressure\n"
1582 <                  "    ensemble, you must set targetPressure in the BASS file.\n");
1582 >                  "\tensemble, you must set targetPressure in the BASS file.\n");
1583            painCave.isFatal = 1;
1584            simError();
1585          }    
1586  
1587          if (globals->haveTauThermostat())
1588            myNPTf->setTauThermostat(globals->getTauThermostat());
1589 +
1590          else{
1591            sprintf(painCave.errMsg,
1592                    "SimSetup error: If you use an NPT\n"
1593 <                  "    ensemble, you must set tauThermostat.\n");
1593 >                  "\tensemble, you must set tauThermostat.\n");
1594            painCave.isFatal = 1;
1595            simError();
1596          }
1597  
1598          if (globals->haveTauBarostat())
1599            myNPTf->setTauBarostat(globals->getTauBarostat());
1456        else{
1457          sprintf(painCave.errMsg,
1458                  "SimSetup error: If you use an NPT\n"
1459                  "    ensemble, you must set tauBarostat.\n");
1460          painCave.isFatal = 1;
1461          simError();
1462        }
1463        break;
1600  
1465      case NPTim_ENS:
1466        if (globals->haveZconstraints()){
1467          setupZConstraint(info[k]);
1468          myNPTim = new ZConstraint<NPTim<RealIntegrator> >(&(info[k]), the_ff);
1469        }
1470        else
1471          myNPTim = new NPTim<RealIntegrator>(&(info[k]), the_ff);
1472
1473        myNPTim->setTargetTemp(globals->getTargetTemp());
1474
1475        if (globals->haveTargetPressure())
1476          myNPTim->setTargetPressure(globals->getTargetPressure());
1601          else{
1602            sprintf(painCave.errMsg,
1479                  "SimSetup error: If you use a constant pressure\n"
1480                  "    ensemble, you must set targetPressure in the BASS file.\n");
1481          painCave.isFatal = 1;
1482          simError();
1483        }
1484
1485        if (globals->haveTauThermostat())
1486          myNPTim->setTauThermostat(globals->getTauThermostat());
1487        else{
1488          sprintf(painCave.errMsg,
1603                    "SimSetup error: If you use an NPT\n"
1604 <                  "    ensemble, you must set tauThermostat.\n");
1604 >                  "\tensemble, you must set tauBarostat.\n");
1605            painCave.isFatal = 1;
1606            simError();
1607          }
1608  
1609 <        if (globals->haveTauBarostat())
1496 <          myNPTim->setTauBarostat(globals->getTauBarostat());
1497 <        else{
1498 <          sprintf(painCave.errMsg,
1499 <                  "SimSetup error: If you use an NPT\n"
1500 <                  "    ensemble, you must set tauBarostat.\n");
1501 <          painCave.isFatal = 1;
1502 <          simError();
1503 <        }
1609 >        info->the_integrator = myNPTf;
1610          break;
1611  
1612 <      case NPTfm_ENS:
1612 >      case NPTxyz_ENS:
1613          if (globals->haveZconstraints()){
1614            setupZConstraint(info[k]);
1615 <          myNPTfm = new ZConstraint<NPTfm<RealIntegrator> >(&(info[k]), the_ff);
1615 >          myNPTxyz = new ZConstraint<NPTxyz<NPT <RealIntegrator> > >(&(info[k]), the_ff);
1616          }
1617          else
1618 <          myNPTfm = new NPTfm<RealIntegrator>(&(info[k]), the_ff);
1618 >          myNPTxyz = new NPTxyz<NPT <RealIntegrator> >(&(info[k]), the_ff);
1619  
1620 <        myNPTfm->setTargetTemp(globals->getTargetTemp());
1620 >        myNPTxyz->setTargetTemp(globals->getTargetTemp());
1621  
1622          if (globals->haveTargetPressure())
1623 <          myNPTfm->setTargetPressure(globals->getTargetPressure());
1623 >          myNPTxyz->setTargetPressure(globals->getTargetPressure());
1624          else{
1625            sprintf(painCave.errMsg,
1626                    "SimSetup error: If you use a constant pressure\n"
1627 <                  "    ensemble, you must set targetPressure in the BASS file.\n");
1627 >                  "\tensemble, you must set targetPressure in the BASS file.\n");
1628            painCave.isFatal = 1;
1629            simError();
1630 <        }
1630 >        }    
1631  
1632          if (globals->haveTauThermostat())
1633 <          myNPTfm->setTauThermostat(globals->getTauThermostat());
1633 >          myNPTxyz->setTauThermostat(globals->getTauThermostat());
1634          else{
1635            sprintf(painCave.errMsg,
1636                    "SimSetup error: If you use an NPT\n"
1637 <                  "    ensemble, you must set tauThermostat.\n");
1637 >                  "\tensemble, you must set tauThermostat.\n");
1638            painCave.isFatal = 1;
1639            simError();
1640          }
1641  
1642          if (globals->haveTauBarostat())
1643 <          myNPTfm->setTauBarostat(globals->getTauBarostat());
1643 >          myNPTxyz->setTauBarostat(globals->getTauBarostat());
1644          else{
1645            sprintf(painCave.errMsg,
1646                    "SimSetup error: If you use an NPT\n"
1647 <                  "    ensemble, you must set tauBarostat.\n");
1647 >                  "\tensemble, you must set tauBarostat.\n");
1648            painCave.isFatal = 1;
1649            simError();
1650          }
1651 +
1652 +        info->the_integrator = myNPTxyz;
1653          break;
1654  
1655        default:
# Line 1589 | Line 1697 | void SimSetup::setupZConstraint(SimInfo& theInfo){
1697    }
1698    else{
1699      sprintf(painCave.errMsg,
1700 <            "ZConstraint error: If you use an ZConstraint\n"
1701 <            " , you must set sample time.\n");
1700 >            "ZConstraint error: If you use a ZConstraint,\n"
1701 >            "\tyou must set zconsTime.\n");
1702      painCave.isFatal = 1;
1703      simError();
1704    }
# Line 1605 | Line 1713 | void SimSetup::setupZConstraint(SimInfo& theInfo){
1713    else{
1714      double defaultZConsTol = 0.01;
1715      sprintf(painCave.errMsg,
1716 <            "ZConstraint Waring: Tolerance for z-constraint methodl is not specified\n"
1717 <            " , default value %f is used.\n",
1716 >            "ZConstraint Warning: Tolerance for z-constraint method is not specified.\n"
1717 >            "\tOOPSE will use a default value of %f.\n"
1718 >            "\tTo set the tolerance, use the zconsTol variable.\n",
1719              defaultZConsTol);
1720      painCave.isFatal = 0;
1721      simError();      
# Line 1615 | Line 1724 | void SimSetup::setupZConstraint(SimInfo& theInfo){
1724    }
1725    theInfo.addProperty(zconsTol);
1726  
1727 <  //set Force Substraction Policy
1727 >  //set Force Subtraction Policy
1728    StringData* zconsForcePolicy = new StringData();
1729    zconsForcePolicy->setID(ZCONSFORCEPOLICY_ID);
1730  
# Line 1624 | Line 1733 | void SimSetup::setupZConstraint(SimInfo& theInfo){
1733    }
1734    else{
1735      sprintf(painCave.errMsg,
1736 <            "ZConstraint Warning: User does not set force substraction policy, "
1737 <            "PolicyByMass is used\n");
1736 >            "ZConstraint Warning: No force subtraction policy was set.\n"
1737 >            "\tOOPSE will use PolicyByMass.\n"
1738 >            "\tTo set the policy, use the zconsForcePolicy variable.\n");
1739      painCave.isFatal = 0;
1740      simError();
1741      zconsForcePolicy->setData("BYMASS");
# Line 1633 | Line 1743 | void SimSetup::setupZConstraint(SimInfo& theInfo){
1743  
1744    theInfo.addProperty(zconsForcePolicy);
1745  
1746 +  //set zcons gap
1747 +  DoubleData* zconsGap = new DoubleData();
1748 +  zconsGap->setID(ZCONSGAP_ID);
1749 +
1750 +  if (globals->haveZConsGap()){
1751 +    zconsGap->setData(globals->getZconsGap());
1752 +    theInfo.addProperty(zconsGap);  
1753 +  }
1754 +
1755 +  //set zcons fixtime
1756 +  DoubleData* zconsFixtime = new DoubleData();
1757 +  zconsFixtime->setID(ZCONSFIXTIME_ID);
1758 +
1759 +  if (globals->haveZConsFixTime()){
1760 +    zconsFixtime->setData(globals->getZconsFixtime());
1761 +    theInfo.addProperty(zconsFixtime);  
1762 +  }
1763 +
1764 +  //set zconsUsingSMD
1765 +  IntData* zconsUsingSMD = new IntData();
1766 +  zconsUsingSMD->setID(ZCONSUSINGSMD_ID);
1767 +
1768 +  if (globals->haveZConsUsingSMD()){
1769 +    zconsUsingSMD->setData(globals->getZconsUsingSMD());
1770 +    theInfo.addProperty(zconsUsingSMD);  
1771 +  }
1772 +
1773    //Determine the name of ouput file and add it into SimInfo's property list
1774    //Be careful, do not use inFileName, since it is a pointer which
1775    //point to a string at master node, and slave nodes do not contain that string
# Line 1662 | Line 1799 | void SimSetup::setupZConstraint(SimInfo& theInfo){
1799      tempParaItem.zPos = zconStamp[i]->getZpos();
1800      tempParaItem.zconsIndex = zconStamp[i]->getMolIndex();
1801      tempParaItem.kRatio = zconStamp[i]->getKratio();
1802 <
1802 >    tempParaItem.havingCantVel = zconStamp[i]->haveCantVel();
1803 >    tempParaItem.cantVel = zconStamp[i]->getCantVel();    
1804      zconsParaData->addItem(tempParaItem);
1805    }
1806  
1807    //check the uniqueness of index  
1808    if(!zconsParaData->isIndexUnique()){
1809      sprintf(painCave.errMsg,
1810 <            "ZConstraint Error: molIndex is not unique\n");
1810 >            "ZConstraint Error: molIndex is not unique!\n");
1811      painCave.isFatal = 1;
1812      simError();
1813    }
# Line 1680 | Line 1818 | void SimSetup::setupZConstraint(SimInfo& theInfo){
1818    //push data into siminfo, therefore, we can retrieve later
1819    theInfo.addProperty(zconsParaData);
1820   }
1821 +
1822 + void SimSetup::makeMinimizer(){
1823 +
1824 +  OOPSEMinimizer* myOOPSEMinimizer;
1825 +  MinimizerParameterSet* param;
1826 +  char minimizerName[100];
1827 +  
1828 +  for (int i = 0; i < nInfo; i++){
1829 +    
1830 +    //prepare parameter set for minimizer
1831 +    param = new MinimizerParameterSet();
1832 +    param->setDefaultParameter();
1833 +
1834 +    if (globals->haveMinimizer()){
1835 +      param->setFTol(globals->getMinFTol());
1836 +    }
1837 +
1838 +    if (globals->haveMinGTol()){
1839 +      param->setGTol(globals->getMinGTol());
1840 +    }
1841 +
1842 +    if (globals->haveMinMaxIter()){
1843 +      param->setMaxIteration(globals->getMinMaxIter());
1844 +    }
1845 +
1846 +    if (globals->haveMinWriteFrq()){
1847 +      param->setMaxIteration(globals->getMinMaxIter());
1848 +    }
1849 +
1850 +    if (globals->haveMinWriteFrq()){
1851 +      param->setWriteFrq(globals->getMinWriteFrq());
1852 +    }
1853 +    
1854 +    if (globals->haveMinStepSize()){
1855 +      param->setStepSize(globals->getMinStepSize());
1856 +    }
1857 +
1858 +    if (globals->haveMinLSMaxIter()){
1859 +      param->setLineSearchMaxIteration(globals->getMinLSMaxIter());
1860 +    }    
1861 +
1862 +    if (globals->haveMinLSTol()){
1863 +      param->setLineSearchTol(globals->getMinLSTol());
1864 +    }    
1865 +
1866 +    strcpy(minimizerName, globals->getMinimizer());
1867 +
1868 +    if (!strcasecmp(minimizerName, "CG")){
1869 +      myOOPSEMinimizer = new PRCGMinimizer(&(info[i]), the_ff, param);
1870 +    }
1871 +    else if (!strcasecmp(minimizerName, "SD")){
1872 +    //myOOPSEMinimizer = MinimizerFactory.creatMinimizer("", &(info[i]), the_ff, param);
1873 +      myOOPSEMinimizer = new SDMinimizer(&(info[i]), the_ff, param);
1874 +    }
1875 +    else{
1876 +          sprintf(painCave.errMsg,
1877 +                  "SimSetup error: Unrecognized Minimizer, use Conjugate Gradient \n");
1878 +          painCave.isFatal = 0;
1879 +          simError();
1880 +
1881 +      myOOPSEMinimizer = new PRCGMinimizer(&(info[i]), the_ff, param);          
1882 +    }
1883 +     info[i].the_integrator = myOOPSEMinimizer;
1884 +
1885 +     //store the minimizer into simInfo
1886 +     info[i].the_minimizer = myOOPSEMinimizer;
1887 +     info[i].has_minimizer = true;
1888 +  }
1889 +
1890 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines