ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/brains/SimInfo.cpp
(Generate patch)

Comparing:
trunk/src/brains/SimInfo.cpp (file contents), Revision 1277 by gezelter, Mon Jul 14 12:35:58 2008 UTC vs.
branches/development/src/brains/SimInfo.cpp (file contents), Revision 1532 by gezelter, Wed Dec 29 19:59:21 2010 UTC

# Line 6 | Line 6
6   * redistribute this software in source and binary code form, provided
7   * that the following conditions are met:
8   *
9 < * 1. Acknowledgement of the program authors must be made in any
10 < *    publication of scientific results based in part on use of the
11 < *    program.  An acceptable form of acknowledgement is citation of
12 < *    the article in which the program was described (Matthew
13 < *    A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14 < *    J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15 < *    Parallel Simulation Engine for Molecular Dynamics,"
16 < *    J. Comput. Chem. 26, pp. 252-271 (2005))
17 < *
18 < * 2. Redistributions of source code must retain the above copyright
9 > * 1. Redistributions of source code must retain the above copyright
10   *    notice, this list of conditions and the following disclaimer.
11   *
12 < * 3. Redistributions in binary form must reproduce the above copyright
12 > * 2. Redistributions in binary form must reproduce the above copyright
13   *    notice, this list of conditions and the following disclaimer in the
14   *    documentation and/or other materials provided with the
15   *    distribution.
# Line 37 | Line 28
28   * arising out of the use of or inability to use software, even if the
29   * University of Notre Dame has been advised of the possibility of
30   * such damages.
31 + *
32 + * SUPPORT OPEN SCIENCE!  If you use OpenMD or its source code in your
33 + * research, please cite the appropriate papers when you publish your
34 + * work.  Good starting points are:
35 + *                                                                      
36 + * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).            
37 + * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).          
38 + * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008).          
39 + * [4]  Vardeman & Gezelter, in progress (2009).                        
40   */
41  
42   /**
# Line 54 | Line 54
54   #include "math/Vector3.hpp"
55   #include "primitives/Molecule.hpp"
56   #include "primitives/StuntDouble.hpp"
57 #include "UseTheForce/fCutoffPolicy.h"
58 #include "UseTheForce/DarkSide/fElectrostaticSummationMethod.h"
59 #include "UseTheForce/DarkSide/fElectrostaticScreeningMethod.h"
60 #include "UseTheForce/DarkSide/fSwitchingFunctionType.h"
57   #include "UseTheForce/doForces_interface.h"
58   #include "UseTheForce/DarkSide/neighborLists_interface.h"
63 #include "UseTheForce/DarkSide/electrostatic_interface.h"
64 #include "UseTheForce/DarkSide/switcheroo_interface.h"
59   #include "utils/MemoryUtils.hpp"
60   #include "utils/simError.h"
61   #include "selection/SelectionManager.hpp"
62   #include "io/ForceFieldOptions.hpp"
63   #include "UseTheForce/ForceField.hpp"
64 + #include "nonbonded/SwitchingFunction.hpp"
65  
66  
67   #ifdef IS_MPI
# Line 74 | Line 69
69   #include "UseTheForce/DarkSide/simParallel_interface.h"
70   #endif
71  
72 < namespace oopse {
73 <  std::set<int> getRigidSet(int index, std::map<int, std::set<int> >& container) {
79 <    std::map<int, std::set<int> >::iterator i = container.find(index);
80 <    std::set<int> result;
81 <    if (i != container.end()) {
82 <        result = i->second;
83 <    }
84 <
85 <    return result;
86 <  }
72 > using namespace std;
73 > namespace OpenMD {
74    
75    SimInfo::SimInfo(ForceField* ff, Globals* simParams) :
76      forceField_(ff), simParams_(simParams),
# Line 93 | Line 80 | namespace oopse {
80      nAtoms_(0), nBonds_(0),  nBends_(0), nTorsions_(0), nInversions_(0),
81      nRigidBodies_(0), nIntegrableObjects_(0), nCutoffGroups_(0),
82      nConstraints_(0), sman_(NULL), fortranInitialized_(false),
83 <    calcBoxDipole_(false), useAtomicVirial_(true) {
84 <
85 <
86 <      MoleculeStamp* molStamp;
87 <      int nMolWithSameStamp;
88 <      int nCutoffAtoms = 0; // number of atoms belong to cutoff groups
89 <      int nGroups = 0;      //total cutoff groups defined in meta-data file
90 <      CutoffGroupStamp* cgStamp;    
91 <      RigidBodyStamp* rbStamp;
92 <      int nRigidAtoms = 0;
93 <
94 <      std::vector<Component*> components = simParams->getComponents();
83 >    calcBoxDipole_(false), useAtomicVirial_(true) {    
84 >    
85 >    MoleculeStamp* molStamp;
86 >    int nMolWithSameStamp;
87 >    int nCutoffAtoms = 0; // number of atoms belong to cutoff groups
88 >    int nGroups = 0;       //total cutoff groups defined in meta-data file
89 >    CutoffGroupStamp* cgStamp;    
90 >    RigidBodyStamp* rbStamp;
91 >    int nRigidAtoms = 0;
92 >    
93 >    vector<Component*> components = simParams->getComponents();
94 >    
95 >    for (vector<Component*>::iterator i = components.begin(); i !=components.end(); ++i) {
96 >      molStamp = (*i)->getMoleculeStamp();
97 >      nMolWithSameStamp = (*i)->getNMol();
98        
99 <      for (std::vector<Component*>::iterator i = components.begin(); i !=components.end(); ++i) {
100 <        molStamp = (*i)->getMoleculeStamp();
101 <        nMolWithSameStamp = (*i)->getNMol();
102 <        
103 <        addMoleculeStamp(molStamp, nMolWithSameStamp);
104 <
105 <        //calculate atoms in molecules
106 <        nGlobalAtoms_ += molStamp->getNAtoms() *nMolWithSameStamp;  
107 <
108 <        //calculate atoms in cutoff groups
109 <        int nAtomsInGroups = 0;
110 <        int nCutoffGroupsInStamp = molStamp->getNCutoffGroups();
121 <        
122 <        for (int j=0; j < nCutoffGroupsInStamp; j++) {
123 <          cgStamp = molStamp->getCutoffGroupStamp(j);
124 <          nAtomsInGroups += cgStamp->getNMembers();
125 <        }
126 <
127 <        nGroups += nCutoffGroupsInStamp * nMolWithSameStamp;
128 <
129 <        nCutoffAtoms += nAtomsInGroups * nMolWithSameStamp;            
130 <
131 <        //calculate atoms in rigid bodies
132 <        int nAtomsInRigidBodies = 0;
133 <        int nRigidBodiesInStamp = molStamp->getNRigidBodies();
134 <        
135 <        for (int j=0; j < nRigidBodiesInStamp; j++) {
136 <          rbStamp = molStamp->getRigidBodyStamp(j);
137 <          nAtomsInRigidBodies += rbStamp->getNMembers();
138 <        }
139 <
140 <        nGlobalRigidBodies_ += nRigidBodiesInStamp * nMolWithSameStamp;
141 <        nRigidAtoms += nAtomsInRigidBodies * nMolWithSameStamp;            
142 <        
99 >      addMoleculeStamp(molStamp, nMolWithSameStamp);
100 >      
101 >      //calculate atoms in molecules
102 >      nGlobalAtoms_ += molStamp->getNAtoms() *nMolWithSameStamp;  
103 >      
104 >      //calculate atoms in cutoff groups
105 >      int nAtomsInGroups = 0;
106 >      int nCutoffGroupsInStamp = molStamp->getNCutoffGroups();
107 >      
108 >      for (int j=0; j < nCutoffGroupsInStamp; j++) {
109 >        cgStamp = molStamp->getCutoffGroupStamp(j);
110 >        nAtomsInGroups += cgStamp->getNMembers();
111        }
112 <
113 <      //every free atom (atom does not belong to cutoff groups) is a cutoff
114 <      //group therefore the total number of cutoff groups in the system is
115 <      //equal to the total number of atoms minus number of atoms belong to
116 <      //cutoff group defined in meta-data file plus the number of cutoff
117 <      //groups defined in meta-data file
118 <      nGlobalCutoffGroups_ = nGlobalAtoms_ - nCutoffAtoms + nGroups;
119 <
120 <      //every free atom (atom does not belong to rigid bodies) is an
121 <      //integrable object therefore the total number of integrable objects
122 <      //in the system is equal to the total number of atoms minus number of
123 <      //atoms belong to rigid body defined in meta-data file plus the number
124 <      //of rigid bodies defined in meta-data file
125 <      nGlobalIntegrableObjects_ = nGlobalAtoms_ - nRigidAtoms
126 <                                                + nGlobalRigidBodies_;
127 <  
128 <      nGlobalMols_ = molStampIds_.size();
161 <      molToProcMap_.resize(nGlobalMols_);
112 >      
113 >      nGroups += nCutoffGroupsInStamp * nMolWithSameStamp;
114 >      
115 >      nCutoffAtoms += nAtomsInGroups * nMolWithSameStamp;            
116 >      
117 >      //calculate atoms in rigid bodies
118 >      int nAtomsInRigidBodies = 0;
119 >      int nRigidBodiesInStamp = molStamp->getNRigidBodies();
120 >      
121 >      for (int j=0; j < nRigidBodiesInStamp; j++) {
122 >        rbStamp = molStamp->getRigidBodyStamp(j);
123 >        nAtomsInRigidBodies += rbStamp->getNMembers();
124 >      }
125 >      
126 >      nGlobalRigidBodies_ += nRigidBodiesInStamp * nMolWithSameStamp;
127 >      nRigidAtoms += nAtomsInRigidBodies * nMolWithSameStamp;            
128 >      
129      }
130 <
130 >    
131 >    //every free atom (atom does not belong to cutoff groups) is a cutoff
132 >    //group therefore the total number of cutoff groups in the system is
133 >    //equal to the total number of atoms minus number of atoms belong to
134 >    //cutoff group defined in meta-data file plus the number of cutoff
135 >    //groups defined in meta-data file
136 >    nGlobalCutoffGroups_ = nGlobalAtoms_ - nCutoffAtoms + nGroups;
137 >    
138 >    //every free atom (atom does not belong to rigid bodies) is an
139 >    //integrable object therefore the total number of integrable objects
140 >    //in the system is equal to the total number of atoms minus number of
141 >    //atoms belong to rigid body defined in meta-data file plus the number
142 >    //of rigid bodies defined in meta-data file
143 >    nGlobalIntegrableObjects_ = nGlobalAtoms_ - nRigidAtoms
144 >      + nGlobalRigidBodies_;
145 >    
146 >    nGlobalMols_ = molStampIds_.size();
147 >    molToProcMap_.resize(nGlobalMols_);
148 >  }
149 >  
150    SimInfo::~SimInfo() {
151 <    std::map<int, Molecule*>::iterator i;
151 >    map<int, Molecule*>::iterator i;
152      for (i = molecules_.begin(); i != molecules_.end(); ++i) {
153        delete i->second;
154      }
# Line 173 | Line 159 | namespace oopse {
159      delete forceField_;
160    }
161  
176  int SimInfo::getNGlobalConstraints() {
177    int nGlobalConstraints;
178 #ifdef IS_MPI
179    MPI_Allreduce(&nConstraints_, &nGlobalConstraints, 1, MPI_INT, MPI_SUM,
180                  MPI_COMM_WORLD);    
181 #else
182    nGlobalConstraints =  nConstraints_;
183 #endif
184    return nGlobalConstraints;
185  }
162  
163    bool SimInfo::addMolecule(Molecule* mol) {
164      MoleculeIterator i;
165 <
165 >    
166      i = molecules_.find(mol->getGlobalIndex());
167      if (i == molecules_.end() ) {
168 <
169 <      molecules_.insert(std::make_pair(mol->getGlobalIndex(), mol));
170 <        
168 >      
169 >      molecules_.insert(make_pair(mol->getGlobalIndex(), mol));
170 >      
171        nAtoms_ += mol->getNAtoms();
172        nBonds_ += mol->getNBonds();
173        nBends_ += mol->getNBends();
# Line 201 | Line 177 | namespace oopse {
177        nIntegrableObjects_ += mol->getNIntegrableObjects();
178        nCutoffGroups_ += mol->getNCutoffGroups();
179        nConstraints_ += mol->getNConstraintPairs();
180 <
181 <      addExcludePairs(mol);
182 <        
180 >      
181 >      addInteractionPairs(mol);
182 >      
183        return true;
184      } else {
185        return false;
186      }
187    }
188 <
188 >  
189    bool SimInfo::removeMolecule(Molecule* mol) {
190      MoleculeIterator i;
191      i = molecules_.find(mol->getGlobalIndex());
# Line 228 | Line 204 | namespace oopse {
204        nCutoffGroups_ -= mol->getNCutoffGroups();
205        nConstraints_ -= mol->getNConstraintPairs();
206  
207 <      removeExcludePairs(mol);
207 >      removeInteractionPairs(mol);
208        molecules_.erase(mol->getGlobalIndex());
209  
210        delete mol;
# Line 237 | Line 213 | namespace oopse {
213      } else {
214        return false;
215      }
240
241
216    }    
217  
218          
# Line 256 | Line 230 | namespace oopse {
230    void SimInfo::calcNdf() {
231      int ndf_local;
232      MoleculeIterator i;
233 <    std::vector<StuntDouble*>::iterator j;
233 >    vector<StuntDouble*>::iterator j;
234      Molecule* mol;
235      StuntDouble* integrableObject;
236  
# Line 307 | Line 281 | namespace oopse {
281      int ndfRaw_local;
282  
283      MoleculeIterator i;
284 <    std::vector<StuntDouble*>::iterator j;
284 >    vector<StuntDouble*>::iterator j;
285      Molecule* mol;
286      StuntDouble* integrableObject;
287  
# Line 354 | Line 328 | namespace oopse {
328  
329    }
330  
331 <  void SimInfo::addExcludePairs(Molecule* mol) {
332 <    std::vector<Bond*>::iterator bondIter;
333 <    std::vector<Bend*>::iterator bendIter;
334 <    std::vector<Torsion*>::iterator torsionIter;
335 <    std::vector<Inversion*>::iterator inversionIter;
331 >  void SimInfo::addInteractionPairs(Molecule* mol) {
332 >    ForceFieldOptions& options_ = forceField_->getForceFieldOptions();
333 >    vector<Bond*>::iterator bondIter;
334 >    vector<Bend*>::iterator bendIter;
335 >    vector<Torsion*>::iterator torsionIter;
336 >    vector<Inversion*>::iterator inversionIter;
337      Bond* bond;
338      Bend* bend;
339      Torsion* torsion;
# Line 368 | Line 343 | namespace oopse {
343      int c;
344      int d;
345  
346 <    std::map<int, std::set<int> > atomGroups;
346 >    // atomGroups can be used to add special interaction maps between
347 >    // groups of atoms that are in two separate rigid bodies.
348 >    // However, most site-site interactions between two rigid bodies
349 >    // are probably not special, just the ones between the physically
350 >    // bonded atoms.  Interactions *within* a single rigid body should
351 >    // always be excluded.  These are done at the bottom of this
352 >    // function.
353  
354 +    map<int, set<int> > atomGroups;
355      Molecule::RigidBodyIterator rbIter;
356      RigidBody* rb;
357      Molecule::IntegrableObjectIterator ii;
358      StuntDouble* integrableObject;
359      
360 <    for (integrableObject = mol->beginIntegrableObject(ii); integrableObject != NULL;
361 <           integrableObject = mol->nextIntegrableObject(ii)) {
362 <
360 >    for (integrableObject = mol->beginIntegrableObject(ii);
361 >         integrableObject != NULL;
362 >         integrableObject = mol->nextIntegrableObject(ii)) {
363 >      
364        if (integrableObject->isRigidBody()) {
365 <          rb = static_cast<RigidBody*>(integrableObject);
366 <          std::vector<Atom*> atoms = rb->getAtoms();
367 <          std::set<int> rigidAtoms;
368 <          for (int i = 0; i < atoms.size(); ++i) {
369 <            rigidAtoms.insert(atoms[i]->getGlobalIndex());
370 <          }
371 <          for (int i = 0; i < atoms.size(); ++i) {
372 <            atomGroups.insert(std::map<int, std::set<int> >::value_type(atoms[i]->getGlobalIndex(), rigidAtoms));
373 <          }      
365 >        rb = static_cast<RigidBody*>(integrableObject);
366 >        vector<Atom*> atoms = rb->getAtoms();
367 >        set<int> rigidAtoms;
368 >        for (int i = 0; i < static_cast<int>(atoms.size()); ++i) {
369 >          rigidAtoms.insert(atoms[i]->getGlobalIndex());
370 >        }
371 >        for (int i = 0; i < static_cast<int>(atoms.size()); ++i) {
372 >          atomGroups.insert(map<int, set<int> >::value_type(atoms[i]->getGlobalIndex(), rigidAtoms));
373 >        }      
374        } else {
375 <        std::set<int> oneAtomSet;
375 >        set<int> oneAtomSet;
376          oneAtomSet.insert(integrableObject->getGlobalIndex());
377 <        atomGroups.insert(std::map<int, std::set<int> >::value_type(integrableObject->getGlobalIndex(), oneAtomSet));        
377 >        atomGroups.insert(map<int, set<int> >::value_type(integrableObject->getGlobalIndex(), oneAtomSet));        
378        }
379      }  
380 +          
381 +    for (bond= mol->beginBond(bondIter); bond != NULL;
382 +         bond = mol->nextBond(bondIter)) {
383  
398    
399    
400    for (bond= mol->beginBond(bondIter); bond != NULL; bond = mol->nextBond(bondIter)) {
384        a = bond->getAtomA()->getGlobalIndex();
385 <      b = bond->getAtomB()->getGlobalIndex();        
386 <      exclude_.addPair(a, b);
385 >      b = bond->getAtomB()->getGlobalIndex();  
386 >    
387 >      if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) {
388 >        oneTwoInteractions_.addPair(a, b);
389 >      } else {
390 >        excludedInteractions_.addPair(a, b);
391 >      }
392      }
393  
394 <    for (bend= mol->beginBend(bendIter); bend != NULL; bend = mol->nextBend(bendIter)) {
394 >    for (bend= mol->beginBend(bendIter); bend != NULL;
395 >         bend = mol->nextBend(bendIter)) {
396 >
397        a = bend->getAtomA()->getGlobalIndex();
398        b = bend->getAtomB()->getGlobalIndex();        
399        c = bend->getAtomC()->getGlobalIndex();
410      std::set<int> rigidSetA = getRigidSet(a, atomGroups);
411      std::set<int> rigidSetB = getRigidSet(b, atomGroups);
412      std::set<int> rigidSetC = getRigidSet(c, atomGroups);
413
414      exclude_.addPairs(rigidSetA, rigidSetB);
415      exclude_.addPairs(rigidSetA, rigidSetC);
416      exclude_.addPairs(rigidSetB, rigidSetC);
400        
401 <      //exclude_.addPair(a, b);
402 <      //exclude_.addPair(a, c);
403 <      //exclude_.addPair(b, c);        
401 >      if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) {
402 >        oneTwoInteractions_.addPair(a, b);      
403 >        oneTwoInteractions_.addPair(b, c);
404 >      } else {
405 >        excludedInteractions_.addPair(a, b);
406 >        excludedInteractions_.addPair(b, c);
407 >      }
408 >
409 >      if (options_.havevdw13scale() || options_.haveelectrostatic13scale()) {
410 >        oneThreeInteractions_.addPair(a, c);      
411 >      } else {
412 >        excludedInteractions_.addPair(a, c);
413 >      }
414      }
415  
416 <    for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; torsion = mol->nextTorsion(torsionIter)) {
416 >    for (torsion= mol->beginTorsion(torsionIter); torsion != NULL;
417 >         torsion = mol->nextTorsion(torsionIter)) {
418 >
419        a = torsion->getAtomA()->getGlobalIndex();
420        b = torsion->getAtomB()->getGlobalIndex();        
421        c = torsion->getAtomC()->getGlobalIndex();        
422 <      d = torsion->getAtomD()->getGlobalIndex();        
428 <      std::set<int> rigidSetA = getRigidSet(a, atomGroups);
429 <      std::set<int> rigidSetB = getRigidSet(b, atomGroups);
430 <      std::set<int> rigidSetC = getRigidSet(c, atomGroups);
431 <      std::set<int> rigidSetD = getRigidSet(d, atomGroups);
422 >      d = torsion->getAtomD()->getGlobalIndex();      
423  
424 <      exclude_.addPairs(rigidSetA, rigidSetB);
425 <      exclude_.addPairs(rigidSetA, rigidSetC);
426 <      exclude_.addPairs(rigidSetA, rigidSetD);
427 <      exclude_.addPairs(rigidSetB, rigidSetC);
428 <      exclude_.addPairs(rigidSetB, rigidSetD);
429 <      exclude_.addPairs(rigidSetC, rigidSetD);
424 >      if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) {
425 >        oneTwoInteractions_.addPair(a, b);      
426 >        oneTwoInteractions_.addPair(b, c);
427 >        oneTwoInteractions_.addPair(c, d);
428 >      } else {
429 >        excludedInteractions_.addPair(a, b);
430 >        excludedInteractions_.addPair(b, c);
431 >        excludedInteractions_.addPair(c, d);
432 >      }
433  
434 <      /*
435 <      exclude_.addPairs(rigidSetA.begin(), rigidSetA.end(), rigidSetB.begin(), rigidSetB.end());
436 <      exclude_.addPairs(rigidSetA.begin(), rigidSetA.end(), rigidSetC.begin(), rigidSetC.end());
437 <      exclude_.addPairs(rigidSetA.begin(), rigidSetA.end(), rigidSetD.begin(), rigidSetD.end());
438 <      exclude_.addPairs(rigidSetB.begin(), rigidSetB.end(), rigidSetC.begin(), rigidSetC.end());
439 <      exclude_.addPairs(rigidSetB.begin(), rigidSetB.end(), rigidSetD.begin(), rigidSetD.end());
440 <      exclude_.addPairs(rigidSetC.begin(), rigidSetC.end(), rigidSetD.begin(), rigidSetD.end());
441 <        
442 <      
443 <      exclude_.addPair(a, b);
444 <      exclude_.addPair(a, c);
445 <      exclude_.addPair(a, d);
446 <      exclude_.addPair(b, c);
453 <      exclude_.addPair(b, d);
454 <      exclude_.addPair(c, d);        
455 <      */
434 >      if (options_.havevdw13scale() || options_.haveelectrostatic13scale()) {
435 >        oneThreeInteractions_.addPair(a, c);      
436 >        oneThreeInteractions_.addPair(b, d);      
437 >      } else {
438 >        excludedInteractions_.addPair(a, c);
439 >        excludedInteractions_.addPair(b, d);
440 >      }
441 >
442 >      if (options_.havevdw14scale() || options_.haveelectrostatic14scale()) {
443 >        oneFourInteractions_.addPair(a, d);      
444 >      } else {
445 >        excludedInteractions_.addPair(a, d);
446 >      }
447      }
448  
449      for (inversion= mol->beginInversion(inversionIter); inversion != NULL;
450           inversion = mol->nextInversion(inversionIter)) {
451 +
452        a = inversion->getAtomA()->getGlobalIndex();
453        b = inversion->getAtomB()->getGlobalIndex();        
454        c = inversion->getAtomC()->getGlobalIndex();        
455        d = inversion->getAtomD()->getGlobalIndex();        
464      std::set<int> rigidSetA = getRigidSet(a, atomGroups);
465      std::set<int> rigidSetB = getRigidSet(b, atomGroups);
466      std::set<int> rigidSetC = getRigidSet(c, atomGroups);
467      std::set<int> rigidSetD = getRigidSet(d, atomGroups);
456  
457 <      exclude_.addPairs(rigidSetA, rigidSetB);
458 <      exclude_.addPairs(rigidSetA, rigidSetC);
459 <      exclude_.addPairs(rigidSetA, rigidSetD);
460 <      exclude_.addPairs(rigidSetB, rigidSetC);
461 <      exclude_.addPairs(rigidSetB, rigidSetD);
462 <      exclude_.addPairs(rigidSetC, rigidSetD);
457 >      if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) {
458 >        oneTwoInteractions_.addPair(a, b);      
459 >        oneTwoInteractions_.addPair(a, c);
460 >        oneTwoInteractions_.addPair(a, d);
461 >      } else {
462 >        excludedInteractions_.addPair(a, b);
463 >        excludedInteractions_.addPair(a, c);
464 >        excludedInteractions_.addPair(a, d);
465 >      }
466  
467 <      /*
468 <      exclude_.addPairs(rigidSetA.begin(), rigidSetA.end(), rigidSetB.begin(), rigidSetB.end());
469 <      exclude_.addPairs(rigidSetA.begin(), rigidSetA.end(), rigidSetC.begin(), rigidSetC.end());
470 <      exclude_.addPairs(rigidSetA.begin(), rigidSetA.end(), rigidSetD.begin(), rigidSetD.end());
471 <      exclude_.addPairs(rigidSetB.begin(), rigidSetB.end(), rigidSetC.begin(), rigidSetC.end());
472 <      exclude_.addPairs(rigidSetB.begin(), rigidSetB.end(), rigidSetD.begin(), rigidSetD.end());
473 <      exclude_.addPairs(rigidSetC.begin(), rigidSetC.end(), rigidSetD.begin(), rigidSetD.end());
474 <        
475 <      
485 <      exclude_.addPair(a, b);
486 <      exclude_.addPair(a, c);
487 <      exclude_.addPair(a, d);
488 <      exclude_.addPair(b, c);
489 <      exclude_.addPair(b, d);
490 <      exclude_.addPair(c, d);        
491 <      */
467 >      if (options_.havevdw13scale() || options_.haveelectrostatic13scale()) {
468 >        oneThreeInteractions_.addPair(b, c);    
469 >        oneThreeInteractions_.addPair(b, d);    
470 >        oneThreeInteractions_.addPair(c, d);      
471 >      } else {
472 >        excludedInteractions_.addPair(b, c);
473 >        excludedInteractions_.addPair(b, d);
474 >        excludedInteractions_.addPair(c, d);
475 >      }
476      }
477  
478 <    for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) {
479 <      std::vector<Atom*> atoms = rb->getAtoms();
480 <      for (int i = 0; i < atoms.size() -1 ; ++i) {
481 <        for (int j = i + 1; j < atoms.size(); ++j) {
478 >    for (rb = mol->beginRigidBody(rbIter); rb != NULL;
479 >         rb = mol->nextRigidBody(rbIter)) {
480 >      vector<Atom*> atoms = rb->getAtoms();
481 >      for (int i = 0; i < static_cast<int>(atoms.size()) -1 ; ++i) {
482 >        for (int j = i + 1; j < static_cast<int>(atoms.size()); ++j) {
483            a = atoms[i]->getGlobalIndex();
484            b = atoms[j]->getGlobalIndex();
485 <          exclude_.addPair(a, b);
485 >          excludedInteractions_.addPair(a, b);
486          }
487        }
488      }        
489  
490    }
491  
492 <  void SimInfo::removeExcludePairs(Molecule* mol) {
493 <    std::vector<Bond*>::iterator bondIter;
494 <    std::vector<Bend*>::iterator bendIter;
495 <    std::vector<Torsion*>::iterator torsionIter;
496 <    std::vector<Inversion*>::iterator inversionIter;
492 >  void SimInfo::removeInteractionPairs(Molecule* mol) {
493 >    ForceFieldOptions& options_ = forceField_->getForceFieldOptions();
494 >    vector<Bond*>::iterator bondIter;
495 >    vector<Bend*>::iterator bendIter;
496 >    vector<Torsion*>::iterator torsionIter;
497 >    vector<Inversion*>::iterator inversionIter;
498      Bond* bond;
499      Bend* bend;
500      Torsion* torsion;
# Line 518 | Line 504 | namespace oopse {
504      int c;
505      int d;
506  
507 <    std::map<int, std::set<int> > atomGroups;
522 <
507 >    map<int, set<int> > atomGroups;
508      Molecule::RigidBodyIterator rbIter;
509      RigidBody* rb;
510      Molecule::IntegrableObjectIterator ii;
511      StuntDouble* integrableObject;
512      
513 <    for (integrableObject = mol->beginIntegrableObject(ii); integrableObject != NULL;
514 <           integrableObject = mol->nextIntegrableObject(ii)) {
515 <
513 >    for (integrableObject = mol->beginIntegrableObject(ii);
514 >         integrableObject != NULL;
515 >         integrableObject = mol->nextIntegrableObject(ii)) {
516 >      
517        if (integrableObject->isRigidBody()) {
518 <          rb = static_cast<RigidBody*>(integrableObject);
519 <          std::vector<Atom*> atoms = rb->getAtoms();
520 <          std::set<int> rigidAtoms;
521 <          for (int i = 0; i < atoms.size(); ++i) {
522 <            rigidAtoms.insert(atoms[i]->getGlobalIndex());
523 <          }
524 <          for (int i = 0; i < atoms.size(); ++i) {
525 <            atomGroups.insert(std::map<int, std::set<int> >::value_type(atoms[i]->getGlobalIndex(), rigidAtoms));
526 <          }      
518 >        rb = static_cast<RigidBody*>(integrableObject);
519 >        vector<Atom*> atoms = rb->getAtoms();
520 >        set<int> rigidAtoms;
521 >        for (int i = 0; i < static_cast<int>(atoms.size()); ++i) {
522 >          rigidAtoms.insert(atoms[i]->getGlobalIndex());
523 >        }
524 >        for (int i = 0; i < static_cast<int>(atoms.size()); ++i) {
525 >          atomGroups.insert(map<int, set<int> >::value_type(atoms[i]->getGlobalIndex(), rigidAtoms));
526 >        }      
527        } else {
528 <        std::set<int> oneAtomSet;
528 >        set<int> oneAtomSet;
529          oneAtomSet.insert(integrableObject->getGlobalIndex());
530 <        atomGroups.insert(std::map<int, std::set<int> >::value_type(integrableObject->getGlobalIndex(), oneAtomSet));        
530 >        atomGroups.insert(map<int, set<int> >::value_type(integrableObject->getGlobalIndex(), oneAtomSet));        
531        }
532      }  
533  
534 <    
535 <    for (bond= mol->beginBond(bondIter); bond != NULL; bond = mol->nextBond(bondIter)) {
534 >    for (bond= mol->beginBond(bondIter); bond != NULL;
535 >         bond = mol->nextBond(bondIter)) {
536 >      
537        a = bond->getAtomA()->getGlobalIndex();
538 <      b = bond->getAtomB()->getGlobalIndex();        
539 <      exclude_.removePair(a, b);
538 >      b = bond->getAtomB()->getGlobalIndex();  
539 >    
540 >      if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) {
541 >        oneTwoInteractions_.removePair(a, b);
542 >      } else {
543 >        excludedInteractions_.removePair(a, b);
544 >      }
545      }
546  
547 <    for (bend= mol->beginBend(bendIter); bend != NULL; bend = mol->nextBend(bendIter)) {
547 >    for (bend= mol->beginBend(bendIter); bend != NULL;
548 >         bend = mol->nextBend(bendIter)) {
549 >
550        a = bend->getAtomA()->getGlobalIndex();
551        b = bend->getAtomB()->getGlobalIndex();        
552        c = bend->getAtomC()->getGlobalIndex();
559
560      std::set<int> rigidSetA = getRigidSet(a, atomGroups);
561      std::set<int> rigidSetB = getRigidSet(b, atomGroups);
562      std::set<int> rigidSetC = getRigidSet(c, atomGroups);
563
564      exclude_.removePairs(rigidSetA, rigidSetB);
565      exclude_.removePairs(rigidSetA, rigidSetC);
566      exclude_.removePairs(rigidSetB, rigidSetC);
553        
554 <      //exclude_.removePair(a, b);
555 <      //exclude_.removePair(a, c);
556 <      //exclude_.removePair(b, c);        
554 >      if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) {
555 >        oneTwoInteractions_.removePair(a, b);      
556 >        oneTwoInteractions_.removePair(b, c);
557 >      } else {
558 >        excludedInteractions_.removePair(a, b);
559 >        excludedInteractions_.removePair(b, c);
560 >      }
561 >
562 >      if (options_.havevdw13scale() || options_.haveelectrostatic13scale()) {
563 >        oneThreeInteractions_.removePair(a, c);      
564 >      } else {
565 >        excludedInteractions_.removePair(a, c);
566 >      }
567      }
568  
569 <    for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; torsion = mol->nextTorsion(torsionIter)) {
569 >    for (torsion= mol->beginTorsion(torsionIter); torsion != NULL;
570 >         torsion = mol->nextTorsion(torsionIter)) {
571 >
572        a = torsion->getAtomA()->getGlobalIndex();
573        b = torsion->getAtomB()->getGlobalIndex();        
574        c = torsion->getAtomC()->getGlobalIndex();        
575 <      d = torsion->getAtomD()->getGlobalIndex();        
575 >      d = torsion->getAtomD()->getGlobalIndex();      
576 >  
577 >      if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) {
578 >        oneTwoInteractions_.removePair(a, b);      
579 >        oneTwoInteractions_.removePair(b, c);
580 >        oneTwoInteractions_.removePair(c, d);
581 >      } else {
582 >        excludedInteractions_.removePair(a, b);
583 >        excludedInteractions_.removePair(b, c);
584 >        excludedInteractions_.removePair(c, d);
585 >      }
586  
587 <      std::set<int> rigidSetA = getRigidSet(a, atomGroups);
588 <      std::set<int> rigidSetB = getRigidSet(b, atomGroups);
589 <      std::set<int> rigidSetC = getRigidSet(c, atomGroups);
590 <      std::set<int> rigidSetD = getRigidSet(d, atomGroups);
587 >      if (options_.havevdw13scale() || options_.haveelectrostatic13scale()) {
588 >        oneThreeInteractions_.removePair(a, c);      
589 >        oneThreeInteractions_.removePair(b, d);      
590 >      } else {
591 >        excludedInteractions_.removePair(a, c);
592 >        excludedInteractions_.removePair(b, d);
593 >      }
594  
595 <      exclude_.removePairs(rigidSetA, rigidSetB);
596 <      exclude_.removePairs(rigidSetA, rigidSetC);
597 <      exclude_.removePairs(rigidSetA, rigidSetD);
598 <      exclude_.removePairs(rigidSetB, rigidSetC);
599 <      exclude_.removePairs(rigidSetB, rigidSetD);
589 <      exclude_.removePairs(rigidSetC, rigidSetD);
590 <
591 <      /*
592 <      exclude_.removePairs(rigidSetA.begin(), rigidSetA.end(), rigidSetB.begin(), rigidSetB.end());
593 <      exclude_.removePairs(rigidSetA.begin(), rigidSetA.end(), rigidSetC.begin(), rigidSetC.end());
594 <      exclude_.removePairs(rigidSetA.begin(), rigidSetA.end(), rigidSetD.begin(), rigidSetD.end());
595 <      exclude_.removePairs(rigidSetB.begin(), rigidSetB.end(), rigidSetC.begin(), rigidSetC.end());
596 <      exclude_.removePairs(rigidSetB.begin(), rigidSetB.end(), rigidSetD.begin(), rigidSetD.end());
597 <      exclude_.removePairs(rigidSetC.begin(), rigidSetC.end(), rigidSetD.begin(), rigidSetD.end());
598 <
599 <      
600 <      exclude_.removePair(a, b);
601 <      exclude_.removePair(a, c);
602 <      exclude_.removePair(a, d);
603 <      exclude_.removePair(b, c);
604 <      exclude_.removePair(b, d);
605 <      exclude_.removePair(c, d);        
606 <      */
595 >      if (options_.havevdw14scale() || options_.haveelectrostatic14scale()) {
596 >        oneFourInteractions_.removePair(a, d);      
597 >      } else {
598 >        excludedInteractions_.removePair(a, d);
599 >      }
600      }
601  
602 <    for (inversion= mol->beginInversion(inversionIter); inversion != NULL; inversion = mol->nextInversion(inversionIter)) {
602 >    for (inversion= mol->beginInversion(inversionIter); inversion != NULL;
603 >         inversion = mol->nextInversion(inversionIter)) {
604 >
605        a = inversion->getAtomA()->getGlobalIndex();
606        b = inversion->getAtomB()->getGlobalIndex();        
607        c = inversion->getAtomC()->getGlobalIndex();        
608        d = inversion->getAtomD()->getGlobalIndex();        
609  
610 <      std::set<int> rigidSetA = getRigidSet(a, atomGroups);
611 <      std::set<int> rigidSetB = getRigidSet(b, atomGroups);
612 <      std::set<int> rigidSetC = getRigidSet(c, atomGroups);
613 <      std::set<int> rigidSetD = getRigidSet(d, atomGroups);
610 >      if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) {
611 >        oneTwoInteractions_.removePair(a, b);      
612 >        oneTwoInteractions_.removePair(a, c);
613 >        oneTwoInteractions_.removePair(a, d);
614 >      } else {
615 >        excludedInteractions_.removePair(a, b);
616 >        excludedInteractions_.removePair(a, c);
617 >        excludedInteractions_.removePair(a, d);
618 >      }
619  
620 <      exclude_.removePairs(rigidSetA, rigidSetB);
621 <      exclude_.removePairs(rigidSetA, rigidSetC);
622 <      exclude_.removePairs(rigidSetA, rigidSetD);
623 <      exclude_.removePairs(rigidSetB, rigidSetC);
624 <      exclude_.removePairs(rigidSetB, rigidSetD);
625 <      exclude_.removePairs(rigidSetC, rigidSetD);
626 <
627 <      /*
628 <      exclude_.removePairs(rigidSetA.begin(), rigidSetA.end(), rigidSetB.begin(), rigidSetB.end());
629 <      exclude_.removePairs(rigidSetA.begin(), rigidSetA.end(), rigidSetC.begin(), rigidSetC.end());
630 <      exclude_.removePairs(rigidSetA.begin(), rigidSetA.end(), rigidSetD.begin(), rigidSetD.end());
631 <      exclude_.removePairs(rigidSetB.begin(), rigidSetB.end(), rigidSetC.begin(), rigidSetC.end());
632 <      exclude_.removePairs(rigidSetB.begin(), rigidSetB.end(), rigidSetD.begin(), rigidSetD.end());
633 <      exclude_.removePairs(rigidSetC.begin(), rigidSetC.end(), rigidSetD.begin(), rigidSetD.end());
634 <
635 <      
636 <      exclude_.removePair(a, b);
637 <      exclude_.removePair(a, c);
638 <      exclude_.removePair(a, d);
639 <      exclude_.removePair(b, c);
640 <      exclude_.removePair(b, d);
641 <      exclude_.removePair(c, d);        
642 <      */
620 >      if (options_.havevdw13scale() || options_.haveelectrostatic13scale()) {
621 >        oneThreeInteractions_.removePair(b, c);    
622 >        oneThreeInteractions_.removePair(b, d);    
623 >        oneThreeInteractions_.removePair(c, d);      
624 >      } else {
625 >        excludedInteractions_.removePair(b, c);
626 >        excludedInteractions_.removePair(b, d);
627 >        excludedInteractions_.removePair(c, d);
628 >      }
629      }
630  
631 <    for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) {
632 <      std::vector<Atom*> atoms = rb->getAtoms();
633 <      for (int i = 0; i < atoms.size() -1 ; ++i) {
634 <        for (int j = i + 1; j < atoms.size(); ++j) {
631 >    for (rb = mol->beginRigidBody(rbIter); rb != NULL;
632 >         rb = mol->nextRigidBody(rbIter)) {
633 >      vector<Atom*> atoms = rb->getAtoms();
634 >      for (int i = 0; i < static_cast<int>(atoms.size()) -1 ; ++i) {
635 >        for (int j = i + 1; j < static_cast<int>(atoms.size()); ++j) {
636            a = atoms[i]->getGlobalIndex();
637            b = atoms[j]->getGlobalIndex();
638 <          exclude_.removePair(a, b);
638 >          excludedInteractions_.removePair(a, b);
639          }
640        }
641      }        
642 <
642 >    
643    }
644 <
645 <
644 >  
645 >  
646    void SimInfo::addMoleculeStamp(MoleculeStamp* molStamp, int nmol) {
647      int curStampId;
648 <
648 >    
649      //index from 0
650      curStampId = moleculeStamps_.size();
651  
# Line 666 | Line 653 | namespace oopse {
653      molStampIds_.insert(molStampIds_.end(), nmol, curStampId);
654    }
655  
656 +
657 +  /**
658 +   * update
659 +   *
660 +   *  Performs the global checks and variable settings after the objects have been
661 +   *  created.
662 +   *
663 +   */
664    void SimInfo::update() {
665 +    
666 +    setupSimVariables();
667 +    setupCutoffs();
668 +    setupSwitching();
669 +    setupElectrostatics();
670 +    setupNeighborlists();
671  
671    setupSimType();
672
672   #ifdef IS_MPI
673      setupFortranParallel();
674   #endif
676
675      setupFortranSim();
676 +    fortranInitialized_ = true;
677  
679    //setup fortran force field
680    /** @deprecate */    
681    int isError = 0;
682    
683    setupCutoff();
684    
685    setupElectrostaticSummationMethod( isError );
686    setupSwitchingFunction();
687    setupAccumulateBoxDipole();
688
689    if(isError){
690      sprintf( painCave.errMsg,
691               "ForceField error: There was an error initializing the forceField in fortran.\n" );
692      painCave.isFatal = 1;
693      simError();
694    }
695
678      calcNdf();
679      calcNdfRaw();
680      calcNdfTrans();
699
700    fortranInitialized_ = true;
681    }
682 <
683 <  std::set<AtomType*> SimInfo::getUniqueAtomTypes() {
682 >  
683 >  set<AtomType*> SimInfo::getSimulatedAtomTypes() {
684      SimInfo::MoleculeIterator mi;
685      Molecule* mol;
686      Molecule::AtomIterator ai;
687      Atom* atom;
688 <    std::set<AtomType*> atomTypes;
689 <
690 <    for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) {
711 <
688 >    set<AtomType*> atomTypes;
689 >    
690 >    for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) {      
691        for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) {
692          atomTypes.insert(atom->getAtomType());
693 +      }      
694 +    }    
695 +    return atomTypes;        
696 +  }
697 +
698 +  /**
699 +   * setupCutoffs
700 +   *
701 +   * Sets the values of cutoffRadius and cutoffMethod
702 +   *
703 +   * cutoffRadius : realType
704 +   *  If the cutoffRadius was explicitly set, use that value.
705 +   *  If the cutoffRadius was not explicitly set:
706 +   *      Are there electrostatic atoms?  Use 12.0 Angstroms.
707 +   *      No electrostatic atoms?  Poll the atom types present in the
708 +   *      simulation for suggested cutoff values (e.g. 2.5 * sigma).
709 +   *      Use the maximum suggested value that was found.
710 +   *
711 +   * cutoffMethod : (one of HARD, SWITCHED, SHIFTED_FORCE, SHIFTED_POTENTIAL)
712 +   *      If cutoffMethod was explicitly set, use that choice.
713 +   *      If cutoffMethod was not explicitly set, use SHIFTED_FORCE
714 +   */
715 +  void SimInfo::setupCutoffs() {
716 +    
717 +    if (simParams_->haveCutoffRadius()) {
718 +      cutoffRadius_ = simParams_->getCutoffRadius();
719 +    } else {      
720 +      if (usesElectrostaticAtoms_) {
721 +        sprintf(painCave.errMsg,
722 +                "SimInfo: No value was set for the cutoffRadius.\n"
723 +                "\tOpenMD will use a default value of 12.0 angstroms"
724 +                "\tfor the cutoffRadius.\n");
725 +        painCave.isFatal = 0;
726 +        painCave.severity = OPENMD_INFO;
727 +        simError();
728 +        cutoffRadius_ = 12.0;
729 +      } else {
730 +        RealType thisCut;
731 +        set<AtomType*>::iterator i;
732 +        set<AtomType*> atomTypes;
733 +        atomTypes = getSimulatedAtomTypes();        
734 +        for (i = atomTypes.begin(); i != atomTypes.end(); ++i) {
735 +          thisCut = InteractionManager::Instance()->getSuggestedCutoffRadius((*i));
736 +          cutoffRadius_ = max(thisCut, cutoffRadius_);
737 +        }
738 +        sprintf(painCave.errMsg,
739 +                "SimInfo: No value was set for the cutoffRadius.\n"
740 +                "\tOpenMD will use %lf angstroms.\n",
741 +                cutoffRadius_);
742 +        painCave.isFatal = 0;
743 +        painCave.severity = OPENMD_INFO;
744 +        simError();
745 +      }            
746 +    }
747 +
748 +    InteractionManager::Instance()->setCutoffRadius(cutoffRadius_);
749 +
750 +    map<string, CutoffMethod> stringToCutoffMethod;
751 +    stringToCutoffMethod["HARD"] = HARD;
752 +    stringToCutoffMethod["SWITCHING_FUNCTION"] = SWITCHING_FUNCTION;
753 +    stringToCutoffMethod["SHIFTED_POTENTIAL"] = SHIFTED_POTENTIAL;    
754 +    stringToCutoffMethod["SHIFTED_FORCE"] = SHIFTED_FORCE;
755 +  
756 +    if (simParams_->haveCutoffMethod()) {
757 +      string cutMeth = toUpperCopy(simParams_->getCutoffMethod());
758 +      map<string, CutoffMethod>::iterator i;
759 +      i = stringToCutoffMethod.find(cutMeth);
760 +      if (i == stringToCutoffMethod.end()) {
761 +        sprintf(painCave.errMsg,
762 +                "SimInfo: Could not find chosen cutoffMethod %s\n"
763 +                "\tShould be one of: "
764 +                "HARD, SWITCHING_FUNCTION, SHIFTED_POTENTIAL, or SHIFTED_FORCE\n",
765 +                cutMeth.c_str());
766 +        painCave.isFatal = 1;
767 +        painCave.severity = OPENMD_ERROR;
768 +        simError();
769 +      } else {
770 +        cutoffMethod_ = i->second;
771        }
772 <        
772 >    } else {
773 >      sprintf(painCave.errMsg,
774 >              "SimInfo: No value was set for the cutoffMethod.\n"
775 >              "\tOpenMD will use SHIFTED_FORCE.\n");
776 >        painCave.isFatal = 0;
777 >        painCave.severity = OPENMD_INFO;
778 >        simError();
779 >        cutoffMethod_ = SHIFTED_FORCE;        
780      }
781  
782 <    return atomTypes;        
782 >    InteractionManager::Instance()->setCutoffMethod(cutoffMethod_);
783    }
784 +  
785 +  /**
786 +   * setupSwitching
787 +   *
788 +   * Sets the values of switchingRadius and
789 +   *  If the switchingRadius was explicitly set, use that value (but check it)
790 +   *  If the switchingRadius was not explicitly set: use 0.85 * cutoffRadius_
791 +   */
792 +  void SimInfo::setupSwitching() {
793 +    
794 +    if (simParams_->haveSwitchingRadius()) {
795 +      switchingRadius_ = simParams_->getSwitchingRadius();
796 +      if (switchingRadius_ > cutoffRadius_) {        
797 +        sprintf(painCave.errMsg,
798 +                "SimInfo: switchingRadius (%f) is larger than cutoffRadius(%f)\n",
799 +                switchingRadius_, cutoffRadius_);
800 +        painCave.isFatal = 1;
801 +        painCave.severity = OPENMD_ERROR;
802 +        simError();
803 +      }
804 +    } else {      
805 +      switchingRadius_ = 0.85 * cutoffRadius_;
806 +      sprintf(painCave.errMsg,
807 +              "SimInfo: No value was set for the switchingRadius.\n"
808 +              "\tOpenMD will use a default value of 85 percent of the cutoffRadius.\n"
809 +              "\tswitchingRadius = %f. for this simulation\n", switchingRadius_);
810 +      painCave.isFatal = 0;
811 +      painCave.severity = OPENMD_WARNING;
812 +      simError();
813 +    }          
814 +  
815 +    InteractionManager::Instance()->setSwitchingRadius(switchingRadius_);
816  
817 <  void SimInfo::setupSimType() {
722 <    std::set<AtomType*>::iterator i;
723 <    std::set<AtomType*> atomTypes;
724 <    atomTypes = getUniqueAtomTypes();
817 >    SwitchingFunctionType ft;
818      
819 <    int useLennardJones = 0;
820 <    int useElectrostatic = 0;
821 <    int useEAM = 0;
822 <    int useSC = 0;
823 <    int useCharge = 0;
824 <    int useDirectional = 0;
825 <    int useDipole = 0;
826 <    int useGayBerne = 0;
827 <    int useSticky = 0;
828 <    int useStickyPower = 0;
829 <    int useShape = 0;
830 <    int useFLARB = 0; //it is not in AtomType yet
831 <    int useDirectionalAtom = 0;    
832 <    int useElectrostatics = 0;
833 <    //usePBC and useRF are from simParams
834 <    int usePBC = simParams_->getUsePeriodicBoundaryConditions();
835 <    int useRF;
836 <    int useSF;
837 <    int useSP;
838 <    int useBoxDipole;
819 >    if (simParams_->haveSwitchingFunctionType()) {
820 >      string funcType = simParams_->getSwitchingFunctionType();
821 >      toUpper(funcType);
822 >      if (funcType == "CUBIC") {
823 >        ft = cubic;
824 >      } else {
825 >        if (funcType == "FIFTH_ORDER_POLYNOMIAL") {
826 >          ft = fifth_order_poly;
827 >        } else {
828 >          // throw error        
829 >          sprintf( painCave.errMsg,
830 >                   "SimInfo : Unknown switchingFunctionType. (Input file specified %s .)\n"
831 >                   "\tswitchingFunctionType must be one of: "
832 >                   "\"cubic\" or \"fifth_order_polynomial\".",
833 >                   funcType.c_str() );
834 >          painCave.isFatal = 1;
835 >          painCave.severity = OPENMD_ERROR;
836 >          simError();
837 >        }          
838 >      }
839 >    }
840  
841 <    std::string myMethod;
841 >    InteractionManager::Instance()->setSwitchingFunctionType(ft);
842 >  }
843  
844 <    // set the useRF logical
845 <    useRF = 0;
846 <    useSF = 0;
847 <    useSP = 0;
844 >  /**
845 >   * setupSkinThickness
846 >   *
847 >   *  If the skinThickness was explicitly set, use that value (but check it)
848 >   *  If the skinThickness was not explicitly set: use 1.0 angstroms
849 >   */
850 >  void SimInfo::setupSkinThickness() {    
851 >    if (simParams_->haveSkinThickness()) {
852 >      skinThickness_ = simParams_->getSkinThickness();
853 >    } else {      
854 >      skinThickness_ = 1.0;
855 >      sprintf(painCave.errMsg,
856 >              "SimInfo Warning: No value was set for the skinThickness.\n"
857 >              "\tOpenMD will use a default value of %f Angstroms\n"
858 >              "\tfor this simulation\n", skinThickness_);
859 >      painCave.isFatal = 0;
860 >      simError();
861 >    }            
862 >  }
863  
864 +  void SimInfo::setupSimType() {
865 +    set<AtomType*>::iterator i;
866 +    set<AtomType*> atomTypes;
867 +    atomTypes = getSimulatedAtomTypes();
868  
755    if (simParams_->haveElectrostaticSummationMethod()) {
756      std::string myMethod = simParams_->getElectrostaticSummationMethod();
757      toUpper(myMethod);
758      if (myMethod == "REACTION_FIELD"){
759        useRF = 1;
760      } else if (myMethod == "SHIFTED_FORCE"){
761        useSF = 1;
762      } else if (myMethod == "SHIFTED_POTENTIAL"){
763        useSP = 1;
764      }
765    }
766    
767    if (simParams_->haveAccumulateBoxDipole())
768      if (simParams_->getAccumulateBoxDipole())
769        useBoxDipole = 1;
770
869      useAtomicVirial_ = simParams_->getUseAtomicVirial();
870  
871 +    int usesElectrostatic = 0;
872 +    int usesMetallic = 0;
873 +    int usesDirectional = 0;
874      //loop over all of the atom types
875      for (i = atomTypes.begin(); i != atomTypes.end(); ++i) {
876 <      useLennardJones |= (*i)->isLennardJones();
877 <      useElectrostatic |= (*i)->isElectrostatic();
878 <      useEAM |= (*i)->isEAM();
778 <      useSC |= (*i)->isSC();
779 <      useCharge |= (*i)->isCharge();
780 <      useDirectional |= (*i)->isDirectional();
781 <      useDipole |= (*i)->isDipole();
782 <      useGayBerne |= (*i)->isGayBerne();
783 <      useSticky |= (*i)->isSticky();
784 <      useStickyPower |= (*i)->isStickyPower();
785 <      useShape |= (*i)->isShape();
876 >      usesElectrostatic |= (*i)->isElectrostatic();
877 >      usesMetallic |= (*i)->isMetal();
878 >      usesDirectional |= (*i)->isDirectional();
879      }
880  
788    if (useSticky || useStickyPower || useDipole || useGayBerne || useShape) {
789      useDirectionalAtom = 1;
790    }
791
792    if (useCharge || useDipole) {
793      useElectrostatics = 1;
794    }
795
881   #ifdef IS_MPI    
882      int temp;
883 +    temp = usesDirectional;
884 +    MPI_Allreduce(&temp, &usesDirectionalAtoms_, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);    
885  
886 <    temp = usePBC;
887 <    MPI_Allreduce(&temp, &usePBC, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);    
886 >    temp = usesMetallic;
887 >    MPI_Allreduce(&temp, &usesMetallicAtoms_, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);    
888  
889 <    temp = useDirectionalAtom;
890 <    MPI_Allreduce(&temp, &useDirectionalAtom, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);    
804 <
805 <    temp = useLennardJones;
806 <    MPI_Allreduce(&temp, &useLennardJones, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);    
807 <
808 <    temp = useElectrostatics;
809 <    MPI_Allreduce(&temp, &useElectrostatics, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);    
810 <
811 <    temp = useCharge;
812 <    MPI_Allreduce(&temp, &useCharge, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);    
813 <
814 <    temp = useDipole;
815 <    MPI_Allreduce(&temp, &useDipole, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);    
816 <
817 <    temp = useSticky;
818 <    MPI_Allreduce(&temp, &useSticky, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);    
819 <
820 <    temp = useStickyPower;
821 <    MPI_Allreduce(&temp, &useStickyPower, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);    
822 <    
823 <    temp = useGayBerne;
824 <    MPI_Allreduce(&temp, &useGayBerne, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);    
825 <
826 <    temp = useEAM;
827 <    MPI_Allreduce(&temp, &useEAM, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);    
828 <
829 <    temp = useSC;
830 <    MPI_Allreduce(&temp, &useSC, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);
831 <    
832 <    temp = useShape;
833 <    MPI_Allreduce(&temp, &useShape, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);  
834 <
835 <    temp = useFLARB;
836 <    MPI_Allreduce(&temp, &useFLARB, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);    
837 <
838 <    temp = useRF;
839 <    MPI_Allreduce(&temp, &useRF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);    
840 <
841 <    temp = useSF;
842 <    MPI_Allreduce(&temp, &useSF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);  
843 <
844 <    temp = useSP;
845 <    MPI_Allreduce(&temp, &useSP, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);
846 <
847 <    temp = useBoxDipole;
848 <    MPI_Allreduce(&temp, &useBoxDipole, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);
849 <
850 <    temp = useAtomicVirial_;
851 <    MPI_Allreduce(&temp, &useAtomicVirial_, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);
852 <
889 >    temp = usesElectrostatic;
890 >    MPI_Allreduce(&temp, &usesElectrostaticAtoms_, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);
891   #endif
892 <
893 <    fInfo_.SIM_uses_PBC = usePBC;    
894 <    fInfo_.SIM_uses_DirectionalAtoms = useDirectionalAtom;
895 <    fInfo_.SIM_uses_LennardJones = useLennardJones;
896 <    fInfo_.SIM_uses_Electrostatics = useElectrostatics;    
897 <    fInfo_.SIM_uses_Charges = useCharge;
860 <    fInfo_.SIM_uses_Dipoles = useDipole;
861 <    fInfo_.SIM_uses_Sticky = useSticky;
862 <    fInfo_.SIM_uses_StickyPower = useStickyPower;
863 <    fInfo_.SIM_uses_GayBerne = useGayBerne;
864 <    fInfo_.SIM_uses_EAM = useEAM;
865 <    fInfo_.SIM_uses_SC = useSC;
866 <    fInfo_.SIM_uses_Shapes = useShape;
867 <    fInfo_.SIM_uses_FLARB = useFLARB;
868 <    fInfo_.SIM_uses_RF = useRF;
869 <    fInfo_.SIM_uses_SF = useSF;
870 <    fInfo_.SIM_uses_SP = useSP;
871 <    fInfo_.SIM_uses_BoxDipole = useBoxDipole;
872 <    fInfo_.SIM_uses_AtomicVirial = useAtomicVirial_;
892 >    fInfo_.SIM_uses_PBC = usesPeriodicBoundaries_;    
893 >    fInfo_.SIM_uses_DirectionalAtoms = usesDirectionalAtoms_;
894 >    fInfo_.SIM_uses_MetallicAtoms = usesMetallicAtoms_;
895 >    fInfo_.SIM_requires_SkipCorrection = usesElectrostaticAtoms_;
896 >    fInfo_.SIM_requires_SelfCorrection = usesElectrostaticAtoms_;
897 >    fInfo_.SIM_uses_AtomicVirial = usesAtomicVirial_;
898    }
899  
900    void SimInfo::setupFortranSim() {
901      int isError;
902 <    int nExclude;
903 <    std::vector<int> fortranGlobalGroupMembership;
902 >    int nExclude, nOneTwo, nOneThree, nOneFour;
903 >    vector<int> fortranGlobalGroupMembership;
904      
905 <    nExclude = exclude_.getSize();
905 >    notifyFortranSkinThickness(&skinThickness_);
906 >
907 >    int ljsp = cutoffMethod_ == SHIFTED_POTENTIAL ? 1 : 0;
908 >    int ljsf = cutoffMethod_ == SHIFTED_FORCE ? 1 : 0;
909 >    notifyFortranCutoffs(&cutoffRadius_, &switchingRadius_, &ljsp, &ljsf);
910 >
911      isError = 0;
912  
913      //globalGroupMembership_ is filled by SimCreator    
# Line 886 | Line 916 | namespace oopse {
916      }
917  
918      //calculate mass ratio of cutoff group
919 <    std::vector<RealType> mfact;
919 >    vector<RealType> mfact;
920      SimInfo::MoleculeIterator mi;
921      Molecule* mol;
922      Molecule::CutoffGroupIterator ci;
# Line 909 | Line 939 | namespace oopse {
939            else
940              mfact.push_back( 1.0 );
941          }
912
942        }      
943      }
944  
945      //fill ident array of local atoms (it is actually ident of AtomType, it is so confusing !!!)
946 <    std::vector<int> identArray;
946 >    vector<int> identArray;
947  
948      //to avoid memory reallocation, reserve enough space identArray
949      identArray.reserve(getNAtoms());
# Line 927 | Line 956 | namespace oopse {
956  
957      //fill molMembershipArray
958      //molMembershipArray is filled by SimCreator    
959 <    std::vector<int> molMembershipArray(nGlobalAtoms_);
959 >    vector<int> molMembershipArray(nGlobalAtoms_);
960      for (int i = 0; i < nGlobalAtoms_; i++) {
961        molMembershipArray[i] = globalMolMembership_[i] + 1;
962      }
963      
964      //setup fortran simulation
965 <    int nGlobalExcludes = 0;
966 <    int* globalExcludes = NULL;
967 <    int* excludeList = exclude_.getExcludeList();
965 >
966 >    nExclude = excludedInteractions_.getSize();
967 >    nOneTwo = oneTwoInteractions_.getSize();
968 >    nOneThree = oneThreeInteractions_.getSize();
969 >    nOneFour = oneFourInteractions_.getSize();
970 >
971 >    int* excludeList = excludedInteractions_.getPairList();
972 >    int* oneTwoList = oneTwoInteractions_.getPairList();
973 >    int* oneThreeList = oneThreeInteractions_.getPairList();
974 >    int* oneFourList = oneFourInteractions_.getPairList();
975 >
976      setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray[0],
977 <                   &nExclude, excludeList , &nGlobalExcludes, globalExcludes,
977 >                   &nExclude, excludeList,
978 >                   &nOneTwo, oneTwoList,
979 >                   &nOneThree, oneThreeList,
980 >                   &nOneFour, oneFourList,
981                     &molMembershipArray[0], &mfact[0], &nCutoffGroups_,
982                     &fortranGlobalGroupMembership[0], &isError);
983      
# Line 946 | Line 986 | namespace oopse {
986        sprintf( painCave.errMsg,
987                 "There was an error setting the simulation information in fortran.\n" );
988        painCave.isFatal = 1;
989 <      painCave.severity = OOPSE_ERROR;
989 >      painCave.severity = OPENMD_ERROR;
990        simError();
991      }
992      
# Line 969 | Line 1009 | namespace oopse {
1009    void SimInfo::setupFortranParallel() {
1010   #ifdef IS_MPI    
1011      //SimInfo is responsible for creating localToGlobalAtomIndex and localToGlobalGroupIndex
1012 <    std::vector<int> localToGlobalAtomIndex(getNAtoms(), 0);
1013 <    std::vector<int> localToGlobalCutoffGroupIndex;
1012 >    vector<int> localToGlobalAtomIndex(getNAtoms(), 0);
1013 >    vector<int> localToGlobalCutoffGroupIndex;
1014      SimInfo::MoleculeIterator mi;
1015      Molecule::AtomIterator ai;
1016      Molecule::CutoffGroupIterator ci;
# Line 1022 | Line 1062 | namespace oopse {
1062   #endif
1063    }
1064  
1025  void SimInfo::setupCutoff() {          
1026    
1027    ForceFieldOptions& forceFieldOptions_ = forceField_->getForceFieldOptions();
1065  
1029    // Check the cutoff policy
1030    int cp =  TRADITIONAL_CUTOFF_POLICY; // Set to traditional by default
1031
1032    // Set LJ shifting bools to false
1033    ljsp_ = false;
1034    ljsf_ = false;
1035
1036    std::string myPolicy;
1037    if (forceFieldOptions_.haveCutoffPolicy()){
1038      myPolicy = forceFieldOptions_.getCutoffPolicy();
1039    }else if (simParams_->haveCutoffPolicy()) {
1040      myPolicy = simParams_->getCutoffPolicy();
1041    }
1042
1043    if (!myPolicy.empty()){
1044      toUpper(myPolicy);
1045      if (myPolicy == "MIX") {
1046        cp = MIX_CUTOFF_POLICY;
1047      } else {
1048        if (myPolicy == "MAX") {
1049          cp = MAX_CUTOFF_POLICY;
1050        } else {
1051          if (myPolicy == "TRADITIONAL") {            
1052            cp = TRADITIONAL_CUTOFF_POLICY;
1053          } else {
1054            // throw error        
1055            sprintf( painCave.errMsg,
1056                     "SimInfo error: Unknown cutoffPolicy. (Input file specified %s .)\n\tcutoffPolicy must be one of: \"Mix\", \"Max\", or \"Traditional\".", myPolicy.c_str() );
1057            painCave.isFatal = 1;
1058            simError();
1059          }    
1060        }          
1061      }
1062    }          
1063    notifyFortranCutoffPolicy(&cp);
1064
1065    // Check the Skin Thickness for neighborlists
1066    RealType skin;
1067    if (simParams_->haveSkinThickness()) {
1068      skin = simParams_->getSkinThickness();
1069      notifyFortranSkinThickness(&skin);
1070    }            
1071        
1072    // Check if the cutoff was set explicitly:
1073    if (simParams_->haveCutoffRadius()) {
1074      rcut_ = simParams_->getCutoffRadius();
1075      if (simParams_->haveSwitchingRadius()) {
1076        rsw_  = simParams_->getSwitchingRadius();
1077      } else {
1078        if (fInfo_.SIM_uses_Charges |
1079            fInfo_.SIM_uses_Dipoles |
1080            fInfo_.SIM_uses_RF) {
1081          
1082          rsw_ = 0.85 * rcut_;
1083          sprintf(painCave.errMsg,
1084                  "SimCreator Warning: No value was set for the switchingRadius.\n"
1085                  "\tOOPSE will use a default value of 85 percent of the cutoffRadius.\n"
1086                  "\tswitchingRadius = %f. for this simulation\n", rsw_);
1087        painCave.isFatal = 0;
1088        simError();
1089        } else {
1090          rsw_ = rcut_;
1091          sprintf(painCave.errMsg,
1092                  "SimCreator Warning: No value was set for the switchingRadius.\n"
1093                  "\tOOPSE will use the same value as the cutoffRadius.\n"
1094                  "\tswitchingRadius = %f. for this simulation\n", rsw_);
1095          painCave.isFatal = 0;
1096          simError();
1097        }
1098      }
1099
1100      if (simParams_->haveElectrostaticSummationMethod()) {
1101        std::string myMethod = simParams_->getElectrostaticSummationMethod();
1102        toUpper(myMethod);
1103        
1104        if (myMethod == "SHIFTED_POTENTIAL") {
1105          ljsp_ = true;
1106        } else if (myMethod == "SHIFTED_FORCE") {
1107          ljsf_ = true;
1108        }
1109      }
1110      notifyFortranCutoffs(&rcut_, &rsw_, &ljsp_, &ljsf_);
1111      
1112    } else {
1113      
1114      // For electrostatic atoms, we'll assume a large safe value:
1115      if (fInfo_.SIM_uses_Charges | fInfo_.SIM_uses_Dipoles | fInfo_.SIM_uses_RF) {
1116        sprintf(painCave.errMsg,
1117                "SimCreator Warning: No value was set for the cutoffRadius.\n"
1118                "\tOOPSE will use a default value of 15.0 angstroms"
1119                "\tfor the cutoffRadius.\n");
1120        painCave.isFatal = 0;
1121        simError();
1122        rcut_ = 15.0;
1123      
1124        if (simParams_->haveElectrostaticSummationMethod()) {
1125          std::string myMethod = simParams_->getElectrostaticSummationMethod();
1126          toUpper(myMethod);
1127      
1128      // For the time being, we're tethering the LJ shifted behavior to the
1129      // electrostaticSummationMethod keyword options
1130          if (myMethod == "SHIFTED_POTENTIAL") {
1131            ljsp_ = true;
1132          } else if (myMethod == "SHIFTED_FORCE") {
1133            ljsf_ = true;
1134          }
1135          if (myMethod == "SHIFTED_POTENTIAL" || myMethod == "SHIFTED_FORCE") {
1136            if (simParams_->haveSwitchingRadius()){
1137              sprintf(painCave.errMsg,
1138                      "SimInfo Warning: A value was set for the switchingRadius\n"
1139                      "\teven though the electrostaticSummationMethod was\n"
1140                      "\tset to %s\n", myMethod.c_str());
1141              painCave.isFatal = 1;
1142              simError();            
1143            }
1144          }
1145        }
1146      
1147        if (simParams_->haveSwitchingRadius()){
1148          rsw_ = simParams_->getSwitchingRadius();
1149        } else {        
1150          sprintf(painCave.errMsg,
1151                  "SimCreator Warning: No value was set for switchingRadius.\n"
1152                  "\tOOPSE will use a default value of\n"
1153                  "\t0.85 * cutoffRadius for the switchingRadius\n");
1154          painCave.isFatal = 0;
1155          simError();
1156          rsw_ = 0.85 * rcut_;
1157        }
1158
1159        notifyFortranCutoffs(&rcut_, &rsw_, &ljsp_, &ljsf_);
1160
1161      } else {
1162        // We didn't set rcut explicitly, and we don't have electrostatic atoms, so
1163        // We'll punt and let fortran figure out the cutoffs later.
1164        
1165        notifyFortranYouAreOnYourOwn();
1166
1167      }
1168    }
1169  }
1170
1171  void SimInfo::setupElectrostaticSummationMethod( int isError ) {    
1172    
1173    int errorOut;
1174    int esm =  NONE;
1175    int sm = UNDAMPED;
1176    RealType alphaVal;
1177    RealType dielectric;
1178    
1179    errorOut = isError;
1180
1181    if (simParams_->haveElectrostaticSummationMethod()) {
1182      std::string myMethod = simParams_->getElectrostaticSummationMethod();
1183      toUpper(myMethod);
1184      if (myMethod == "NONE") {
1185        esm = NONE;
1186      } else {
1187        if (myMethod == "SWITCHING_FUNCTION") {
1188          esm = SWITCHING_FUNCTION;
1189        } else {
1190          if (myMethod == "SHIFTED_POTENTIAL") {
1191            esm = SHIFTED_POTENTIAL;
1192          } else {
1193            if (myMethod == "SHIFTED_FORCE") {            
1194              esm = SHIFTED_FORCE;
1195            } else {
1196              if (myMethod == "REACTION_FIELD") {
1197                esm = REACTION_FIELD;
1198                dielectric = simParams_->getDielectric();
1199                if (!simParams_->haveDielectric()) {
1200                  // throw warning
1201                  sprintf( painCave.errMsg,
1202                           "SimInfo warning: dielectric was not specified in the input file\n\tfor the reaction field correction method.\n"
1203                           "\tA default value of %f will be used for the dielectric.\n", dielectric);
1204                  painCave.isFatal = 0;
1205                  simError();
1206                }
1207              } else {
1208                // throw error        
1209                sprintf( painCave.errMsg,
1210                         "SimInfo error: Unknown electrostaticSummationMethod.\n"
1211                         "\t(Input file specified %s .)\n"
1212                         "\telectrostaticSummationMethod must be one of: \"none\",\n"
1213                         "\t\"shifted_potential\", \"shifted_force\", or \n"
1214                         "\t\"reaction_field\".\n", myMethod.c_str() );
1215                painCave.isFatal = 1;
1216                simError();
1217              }    
1218            }          
1219          }
1220        }
1221      }
1222    }
1223    
1224    if (simParams_->haveElectrostaticScreeningMethod()) {
1225      std::string myScreen = simParams_->getElectrostaticScreeningMethod();
1226      toUpper(myScreen);
1227      if (myScreen == "UNDAMPED") {
1228        sm = UNDAMPED;
1229      } else {
1230        if (myScreen == "DAMPED") {
1231          sm = DAMPED;
1232          if (!simParams_->haveDampingAlpha()) {
1233            // first set a cutoff dependent alpha value
1234            // we assume alpha depends linearly with rcut from 0 to 20.5 ang
1235            alphaVal = 0.5125 - rcut_* 0.025;
1236            // for values rcut > 20.5, alpha is zero
1237            if (alphaVal < 0) alphaVal = 0;
1238
1239            // throw warning
1240            sprintf( painCave.errMsg,
1241                     "SimInfo warning: dampingAlpha was not specified in the input file.\n"
1242                     "\tA default value of %f (1/ang) will be used for the cutoff of\n\t%f (ang).\n", alphaVal, rcut_);
1243            painCave.isFatal = 0;
1244            simError();
1245          } else {
1246            alphaVal = simParams_->getDampingAlpha();
1247          }
1248          
1249        } else {
1250          // throw error        
1251          sprintf( painCave.errMsg,
1252                   "SimInfo error: Unknown electrostaticScreeningMethod.\n"
1253                   "\t(Input file specified %s .)\n"
1254                   "\telectrostaticScreeningMethod must be one of: \"undamped\"\n"
1255                   "or \"damped\".\n", myScreen.c_str() );
1256          painCave.isFatal = 1;
1257          simError();
1258        }
1259      }
1260    }
1261    
1262    // let's pass some summation method variables to fortran
1263    setElectrostaticSummationMethod( &esm );
1264    setFortranElectrostaticMethod( &esm );
1265    setScreeningMethod( &sm );
1266    setDampingAlpha( &alphaVal );
1267    setReactionFieldDielectric( &dielectric );
1268    initFortranFF( &errorOut );
1269  }
1270
1066    void SimInfo::setupSwitchingFunction() {    
1272    int ft = CUBIC;
1067  
1274    if (simParams_->haveSwitchingFunctionType()) {
1275      std::string funcType = simParams_->getSwitchingFunctionType();
1276      toUpper(funcType);
1277      if (funcType == "CUBIC") {
1278        ft = CUBIC;
1279      } else {
1280        if (funcType == "FIFTH_ORDER_POLYNOMIAL") {
1281          ft = FIFTH_ORDER_POLY;
1282        } else {
1283          // throw error        
1284          sprintf( painCave.errMsg,
1285                   "SimInfo error: Unknown switchingFunctionType. (Input file specified %s .)\n\tswitchingFunctionType must be one of: \"cubic\" or \"fifth_order_polynomial\".", funcType.c_str() );
1286          painCave.isFatal = 1;
1287          simError();
1288        }          
1289      }
1290    }
1291
1292    // send switching function notification to switcheroo
1293    setFunctionType(&ft);
1294
1068    }
1069  
1070    void SimInfo::setupAccumulateBoxDipole() {    
# Line 1299 | Line 1072 | namespace oopse {
1072      // we only call setAccumulateBoxDipole if the accumulateBoxDipole parameter is true
1073      if ( simParams_->haveAccumulateBoxDipole() )
1074        if ( simParams_->getAccumulateBoxDipole() ) {
1302        setAccumulateBoxDipole();
1075          calcBoxDipole_ = true;
1076        }
1077  
# Line 1309 | Line 1081 | namespace oopse {
1081      properties_.addProperty(genData);  
1082    }
1083  
1084 <  void SimInfo::removeProperty(const std::string& propName) {
1084 >  void SimInfo::removeProperty(const string& propName) {
1085      properties_.removeProperty(propName);  
1086    }
1087  
# Line 1317 | Line 1089 | namespace oopse {
1089      properties_.clearProperties();
1090    }
1091  
1092 <  std::vector<std::string> SimInfo::getPropertyNames() {
1092 >  vector<string> SimInfo::getPropertyNames() {
1093      return properties_.getPropertyNames();  
1094    }
1095        
1096 <  std::vector<GenericData*> SimInfo::getProperties() {
1096 >  vector<GenericData*> SimInfo::getProperties() {
1097      return properties_.getProperties();
1098    }
1099  
1100 <  GenericData* SimInfo::getPropertyByName(const std::string& propName) {
1100 >  GenericData* SimInfo::getPropertyByName(const string& propName) {
1101      return properties_.getPropertyByName(propName);
1102    }
1103  
# Line 1408 | Line 1180 | namespace oopse {
1180  
1181    }        
1182  
1183 <  std::ostream& operator <<(std::ostream& o, SimInfo& info) {
1183 >  ostream& operator <<(ostream& o, SimInfo& info) {
1184  
1185      return o;
1186    }
# Line 1451 | Line 1223 | namespace oopse {
1223  
1224  
1225         [  Ixx -Ixy  -Ixz ]
1226 <  J =| -Iyx  Iyy  -Iyz |
1226 >    J =| -Iyx  Iyy  -Iyz |
1227         [ -Izx -Iyz   Izz ]
1228      */
1229  
# Line 1558 | Line 1330 | namespace oopse {
1330      return IOIndexToIntegrableObject.at(index);
1331    }
1332    
1333 <  void SimInfo::setIOIndexToIntegrableObject(const std::vector<StuntDouble*>& v) {
1333 >  void SimInfo::setIOIndexToIntegrableObject(const vector<StuntDouble*>& v) {
1334      IOIndexToIntegrableObject= v;
1335    }
1336  
# Line 1600 | Line 1372 | namespace oopse {
1372      return;
1373    }
1374   /*
1375 <   void SimInfo::setStuntDoubleFromGlobalIndex(std::vector<StuntDouble*> v) {
1375 >   void SimInfo::setStuntDoubleFromGlobalIndex(vector<StuntDouble*> v) {
1376        assert( v.size() == nAtoms_ + nRigidBodies_);
1377        sdByGlobalIndex_ = v;
1378      }
# Line 1610 | Line 1382 | namespace oopse {
1382        return sdByGlobalIndex_.at(index);
1383      }  
1384   */  
1385 < }//end namespace oopse
1385 >  int SimInfo::getNGlobalConstraints() {
1386 >    int nGlobalConstraints;
1387 > #ifdef IS_MPI
1388 >    MPI_Allreduce(&nConstraints_, &nGlobalConstraints, 1, MPI_INT, MPI_SUM,
1389 >                  MPI_COMM_WORLD);    
1390 > #else
1391 >    nGlobalConstraints =  nConstraints_;
1392 > #endif
1393 >    return nGlobalConstraints;
1394 >  }
1395  
1396 + }//end namespace OpenMD
1397 +

Comparing:
trunk/src/brains/SimInfo.cpp (property svn:keywords), Revision 1277 by gezelter, Mon Jul 14 12:35:58 2008 UTC vs.
branches/development/src/brains/SimInfo.cpp (property svn:keywords), Revision 1532 by gezelter, Wed Dec 29 19:59:21 2010 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines