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 878 by chrisfen, Wed Feb 1 20:54:46 2006 UTC vs.
branches/development/src/brains/SimInfo.cpp (file contents), Revision 1503 by gezelter, Sat Oct 2 19:54:41 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 53 | Line 53
53   #include "brains/SimInfo.hpp"
54   #include "math/Vector3.hpp"
55   #include "primitives/Molecule.hpp"
56 + #include "primitives/StuntDouble.hpp"
57   #include "UseTheForce/fCutoffPolicy.h"
57 #include "UseTheForce/DarkSide/fElectrostaticSummationMethod.h"
58 #include "UseTheForce/DarkSide/fElectrostaticScreeningMethod.h"
58   #include "UseTheForce/DarkSide/fSwitchingFunctionType.h"
59   #include "UseTheForce/doForces_interface.h"
60 < #include "UseTheForce/DarkSide/electrostatic_interface.h"
60 > #include "UseTheForce/DarkSide/neighborLists_interface.h"
61   #include "UseTheForce/DarkSide/switcheroo_interface.h"
62   #include "utils/MemoryUtils.hpp"
63   #include "utils/simError.h"
# Line 66 | Line 65
65   #include "io/ForceFieldOptions.hpp"
66   #include "UseTheForce/ForceField.hpp"
67  
68 +
69   #ifdef IS_MPI
70   #include "UseTheForce/mpiComponentPlan.h"
71   #include "UseTheForce/DarkSide/simParallel_interface.h"
72   #endif
73  
74 < namespace oopse {
74 > namespace OpenMD {
75    std::set<int> getRigidSet(int index, std::map<int, std::set<int> >& container) {
76      std::map<int, std::set<int> >::iterator i = container.find(index);
77      std::set<int> result;
# Line 84 | Line 84 | namespace oopse {
84    
85    SimInfo::SimInfo(ForceField* ff, Globals* simParams) :
86      forceField_(ff), simParams_(simParams),
87 <    ndf_(0), ndfRaw_(0), ndfTrans_(0), nZconstraint_(0),
87 >    ndf_(0), fdf_local(0), ndfRaw_(0), ndfTrans_(0), nZconstraint_(0),
88      nGlobalMols_(0), nGlobalAtoms_(0), nGlobalCutoffGroups_(0),
89      nGlobalIntegrableObjects_(0), nGlobalRigidBodies_(0),
90 <    nAtoms_(0), nBonds_(0),  nBends_(0), nTorsions_(0), nRigidBodies_(0),
91 <    nIntegrableObjects_(0),  nCutoffGroups_(0), nConstraints_(0),
92 <    sman_(NULL), fortranInitialized_(false) {
90 >    nAtoms_(0), nBonds_(0),  nBends_(0), nTorsions_(0), nInversions_(0),
91 >    nRigidBodies_(0), nIntegrableObjects_(0), nCutoffGroups_(0),
92 >    nConstraints_(0), sman_(NULL), fortranInitialized_(false),
93 >    calcBoxDipole_(false), useAtomicVirial_(true) {
94  
95 +
96        MoleculeStamp* molStamp;
97        int nMolWithSameStamp;
98        int nCutoffAtoms = 0; // number of atoms belong to cutoff groups
# Line 98 | Line 100 | namespace oopse {
100        CutoffGroupStamp* cgStamp;    
101        RigidBodyStamp* rbStamp;
102        int nRigidAtoms = 0;
103 +
104        std::vector<Component*> components = simParams->getComponents();
105        
106        for (std::vector<Component*>::iterator i = components.begin(); i !=components.end(); ++i) {
# Line 152 | Line 155 | namespace oopse {
155                                                  + nGlobalRigidBodies_;
156    
157        nGlobalMols_ = molStampIds_.size();
155
156 #ifdef IS_MPI    
158        molToProcMap_.resize(nGlobalMols_);
158 #endif
159
159      }
160  
161    SimInfo::~SimInfo() {
# Line 194 | Line 193 | namespace oopse {
193        nBonds_ += mol->getNBonds();
194        nBends_ += mol->getNBends();
195        nTorsions_ += mol->getNTorsions();
196 +      nInversions_ += mol->getNInversions();
197        nRigidBodies_ += mol->getNRigidBodies();
198        nIntegrableObjects_ += mol->getNIntegrableObjects();
199        nCutoffGroups_ += mol->getNCutoffGroups();
200        nConstraints_ += mol->getNConstraintPairs();
201  
202 <      addExcludePairs(mol);
203 <        
202 >      addInteractionPairs(mol);
203 >  
204        return true;
205      } else {
206        return false;
# Line 219 | Line 219 | namespace oopse {
219        nBonds_ -= mol->getNBonds();
220        nBends_ -= mol->getNBends();
221        nTorsions_ -= mol->getNTorsions();
222 +      nInversions_ -= mol->getNInversions();
223        nRigidBodies_ -= mol->getNRigidBodies();
224        nIntegrableObjects_ -= mol->getNIntegrableObjects();
225        nCutoffGroups_ -= mol->getNCutoffGroups();
226        nConstraints_ -= mol->getNConstraintPairs();
227  
228 <      removeExcludePairs(mol);
228 >      removeInteractionPairs(mol);
229        molecules_.erase(mol->getGlobalIndex());
230  
231        delete mol;
# Line 290 | Line 291 | namespace oopse {
291  
292    }
293  
294 +  int SimInfo::getFdf() {
295 + #ifdef IS_MPI
296 +    MPI_Allreduce(&fdf_local,&fdf_,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD);
297 + #else
298 +    fdf_ = fdf_local;
299 + #endif
300 +    return fdf_;
301 +  }
302 +    
303    void SimInfo::calcNdfRaw() {
304      int ndfRaw_local;
305  
# Line 341 | Line 351 | namespace oopse {
351  
352    }
353  
354 <  void SimInfo::addExcludePairs(Molecule* mol) {
354 >  void SimInfo::addInteractionPairs(Molecule* mol) {
355 >    ForceFieldOptions& options_ = forceField_->getForceFieldOptions();
356      std::vector<Bond*>::iterator bondIter;
357      std::vector<Bend*>::iterator bendIter;
358      std::vector<Torsion*>::iterator torsionIter;
359 +    std::vector<Inversion*>::iterator inversionIter;
360      Bond* bond;
361      Bend* bend;
362      Torsion* torsion;
363 +    Inversion* inversion;
364      int a;
365      int b;
366      int c;
367      int d;
368  
369 <    std::map<int, std::set<int> > atomGroups;
369 >    // atomGroups can be used to add special interaction maps between
370 >    // groups of atoms that are in two separate rigid bodies.
371 >    // However, most site-site interactions between two rigid bodies
372 >    // are probably not special, just the ones between the physically
373 >    // bonded atoms.  Interactions *within* a single rigid body should
374 >    // always be excluded.  These are done at the bottom of this
375 >    // function.
376  
377 +    std::map<int, std::set<int> > atomGroups;
378      Molecule::RigidBodyIterator rbIter;
379      RigidBody* rb;
380      Molecule::IntegrableObjectIterator ii;
381      StuntDouble* integrableObject;
382      
383 <    for (integrableObject = mol->beginIntegrableObject(ii); integrableObject != NULL;
384 <           integrableObject = mol->nextIntegrableObject(ii)) {
385 <
383 >    for (integrableObject = mol->beginIntegrableObject(ii);
384 >         integrableObject != NULL;
385 >         integrableObject = mol->nextIntegrableObject(ii)) {
386 >      
387        if (integrableObject->isRigidBody()) {
388 <          rb = static_cast<RigidBody*>(integrableObject);
389 <          std::vector<Atom*> atoms = rb->getAtoms();
390 <          std::set<int> rigidAtoms;
391 <          for (int i = 0; i < atoms.size(); ++i) {
392 <            rigidAtoms.insert(atoms[i]->getGlobalIndex());
393 <          }
394 <          for (int i = 0; i < atoms.size(); ++i) {
395 <            atomGroups.insert(std::map<int, std::set<int> >::value_type(atoms[i]->getGlobalIndex(), rigidAtoms));
396 <          }      
388 >        rb = static_cast<RigidBody*>(integrableObject);
389 >        std::vector<Atom*> atoms = rb->getAtoms();
390 >        std::set<int> rigidAtoms;
391 >        for (int i = 0; i < static_cast<int>(atoms.size()); ++i) {
392 >          rigidAtoms.insert(atoms[i]->getGlobalIndex());
393 >        }
394 >        for (int i = 0; i < static_cast<int>(atoms.size()); ++i) {
395 >          atomGroups.insert(std::map<int, std::set<int> >::value_type(atoms[i]->getGlobalIndex(), rigidAtoms));
396 >        }      
397        } else {
398          std::set<int> oneAtomSet;
399          oneAtomSet.insert(integrableObject->getGlobalIndex());
400          atomGroups.insert(std::map<int, std::set<int> >::value_type(integrableObject->getGlobalIndex(), oneAtomSet));        
401        }
402      }  
403 +          
404 +    for (bond= mol->beginBond(bondIter); bond != NULL;
405 +         bond = mol->nextBond(bondIter)) {
406  
407 <    
407 >      a = bond->getAtomA()->getGlobalIndex();
408 >      b = bond->getAtomB()->getGlobalIndex();  
409      
410 <    for (bond= mol->beginBond(bondIter); bond != NULL; bond = mol->nextBond(bondIter)) {
411 <      a = bond->getAtomA()->getGlobalIndex();
412 <      b = bond->getAtomB()->getGlobalIndex();        
413 <      exclude_.addPair(a, b);
410 >      if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) {
411 >        oneTwoInteractions_.addPair(a, b);
412 >      } else {
413 >        excludedInteractions_.addPair(a, b);
414 >      }
415      }
416  
417 <    for (bend= mol->beginBend(bendIter); bend != NULL; bend = mol->nextBend(bendIter)) {
417 >    for (bend= mol->beginBend(bendIter); bend != NULL;
418 >         bend = mol->nextBend(bendIter)) {
419 >
420        a = bend->getAtomA()->getGlobalIndex();
421        b = bend->getAtomB()->getGlobalIndex();        
422        c = bend->getAtomC()->getGlobalIndex();
395      std::set<int> rigidSetA = getRigidSet(a, atomGroups);
396      std::set<int> rigidSetB = getRigidSet(b, atomGroups);
397      std::set<int> rigidSetC = getRigidSet(c, atomGroups);
398
399      exclude_.addPairs(rigidSetA, rigidSetB);
400      exclude_.addPairs(rigidSetA, rigidSetC);
401      exclude_.addPairs(rigidSetB, rigidSetC);
423        
424 <      //exclude_.addPair(a, b);
425 <      //exclude_.addPair(a, c);
426 <      //exclude_.addPair(b, c);        
424 >      if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) {
425 >        oneTwoInteractions_.addPair(a, b);      
426 >        oneTwoInteractions_.addPair(b, c);
427 >      } else {
428 >        excludedInteractions_.addPair(a, b);
429 >        excludedInteractions_.addPair(b, c);
430 >      }
431 >
432 >      if (options_.havevdw13scale() || options_.haveelectrostatic13scale()) {
433 >        oneThreeInteractions_.addPair(a, c);      
434 >      } else {
435 >        excludedInteractions_.addPair(a, c);
436 >      }
437      }
438  
439 <    for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; torsion = mol->nextTorsion(torsionIter)) {
439 >    for (torsion= mol->beginTorsion(torsionIter); torsion != NULL;
440 >         torsion = mol->nextTorsion(torsionIter)) {
441 >
442        a = torsion->getAtomA()->getGlobalIndex();
443        b = torsion->getAtomB()->getGlobalIndex();        
444        c = torsion->getAtomC()->getGlobalIndex();        
445 <      d = torsion->getAtomD()->getGlobalIndex();        
413 <      std::set<int> rigidSetA = getRigidSet(a, atomGroups);
414 <      std::set<int> rigidSetB = getRigidSet(b, atomGroups);
415 <      std::set<int> rigidSetC = getRigidSet(c, atomGroups);
416 <      std::set<int> rigidSetD = getRigidSet(d, atomGroups);
445 >      d = torsion->getAtomD()->getGlobalIndex();      
446  
447 <      exclude_.addPairs(rigidSetA, rigidSetB);
448 <      exclude_.addPairs(rigidSetA, rigidSetC);
449 <      exclude_.addPairs(rigidSetA, rigidSetD);
450 <      exclude_.addPairs(rigidSetB, rigidSetC);
451 <      exclude_.addPairs(rigidSetB, rigidSetD);
452 <      exclude_.addPairs(rigidSetC, rigidSetD);
447 >      if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) {
448 >        oneTwoInteractions_.addPair(a, b);      
449 >        oneTwoInteractions_.addPair(b, c);
450 >        oneTwoInteractions_.addPair(c, d);
451 >      } else {
452 >        excludedInteractions_.addPair(a, b);
453 >        excludedInteractions_.addPair(b, c);
454 >        excludedInteractions_.addPair(c, d);
455 >      }
456  
457 <      /*
458 <      exclude_.addPairs(rigidSetA.begin(), rigidSetA.end(), rigidSetB.begin(), rigidSetB.end());
459 <      exclude_.addPairs(rigidSetA.begin(), rigidSetA.end(), rigidSetC.begin(), rigidSetC.end());
460 <      exclude_.addPairs(rigidSetA.begin(), rigidSetA.end(), rigidSetD.begin(), rigidSetD.end());
461 <      exclude_.addPairs(rigidSetB.begin(), rigidSetB.end(), rigidSetC.begin(), rigidSetC.end());
462 <      exclude_.addPairs(rigidSetB.begin(), rigidSetB.end(), rigidSetD.begin(), rigidSetD.end());
463 <      exclude_.addPairs(rigidSetC.begin(), rigidSetC.end(), rigidSetD.begin(), rigidSetD.end());
464 <        
465 <      
466 <      exclude_.addPair(a, b);
467 <      exclude_.addPair(a, c);
468 <      exclude_.addPair(a, d);
469 <      exclude_.addPair(b, c);
438 <      exclude_.addPair(b, d);
439 <      exclude_.addPair(c, d);        
440 <      */
457 >      if (options_.havevdw13scale() || options_.haveelectrostatic13scale()) {
458 >        oneThreeInteractions_.addPair(a, c);      
459 >        oneThreeInteractions_.addPair(b, d);      
460 >      } else {
461 >        excludedInteractions_.addPair(a, c);
462 >        excludedInteractions_.addPair(b, d);
463 >      }
464 >
465 >      if (options_.havevdw14scale() || options_.haveelectrostatic14scale()) {
466 >        oneFourInteractions_.addPair(a, d);      
467 >      } else {
468 >        excludedInteractions_.addPair(a, d);
469 >      }
470      }
471  
472 <    for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) {
472 >    for (inversion= mol->beginInversion(inversionIter); inversion != NULL;
473 >         inversion = mol->nextInversion(inversionIter)) {
474 >
475 >      a = inversion->getAtomA()->getGlobalIndex();
476 >      b = inversion->getAtomB()->getGlobalIndex();        
477 >      c = inversion->getAtomC()->getGlobalIndex();        
478 >      d = inversion->getAtomD()->getGlobalIndex();        
479 >
480 >      if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) {
481 >        oneTwoInteractions_.addPair(a, b);      
482 >        oneTwoInteractions_.addPair(a, c);
483 >        oneTwoInteractions_.addPair(a, d);
484 >      } else {
485 >        excludedInteractions_.addPair(a, b);
486 >        excludedInteractions_.addPair(a, c);
487 >        excludedInteractions_.addPair(a, d);
488 >      }
489 >
490 >      if (options_.havevdw13scale() || options_.haveelectrostatic13scale()) {
491 >        oneThreeInteractions_.addPair(b, c);    
492 >        oneThreeInteractions_.addPair(b, d);    
493 >        oneThreeInteractions_.addPair(c, d);      
494 >      } else {
495 >        excludedInteractions_.addPair(b, c);
496 >        excludedInteractions_.addPair(b, d);
497 >        excludedInteractions_.addPair(c, d);
498 >      }
499 >    }
500 >
501 >    for (rb = mol->beginRigidBody(rbIter); rb != NULL;
502 >         rb = mol->nextRigidBody(rbIter)) {
503        std::vector<Atom*> atoms = rb->getAtoms();
504 <      for (int i = 0; i < atoms.size() -1 ; ++i) {
505 <        for (int j = i + 1; j < atoms.size(); ++j) {
504 >      for (int i = 0; i < static_cast<int>(atoms.size()) -1 ; ++i) {
505 >        for (int j = i + 1; j < static_cast<int>(atoms.size()); ++j) {
506            a = atoms[i]->getGlobalIndex();
507            b = atoms[j]->getGlobalIndex();
508 <          exclude_.addPair(a, b);
508 >          excludedInteractions_.addPair(a, b);
509          }
510        }
511      }        
512  
513    }
514  
515 <  void SimInfo::removeExcludePairs(Molecule* mol) {
515 >  void SimInfo::removeInteractionPairs(Molecule* mol) {
516 >    ForceFieldOptions& options_ = forceField_->getForceFieldOptions();
517      std::vector<Bond*>::iterator bondIter;
518      std::vector<Bend*>::iterator bendIter;
519      std::vector<Torsion*>::iterator torsionIter;
520 +    std::vector<Inversion*>::iterator inversionIter;
521      Bond* bond;
522      Bend* bend;
523      Torsion* torsion;
524 +    Inversion* inversion;
525      int a;
526      int b;
527      int c;
528      int d;
529  
530      std::map<int, std::set<int> > atomGroups;
469
531      Molecule::RigidBodyIterator rbIter;
532      RigidBody* rb;
533      Molecule::IntegrableObjectIterator ii;
534      StuntDouble* integrableObject;
535      
536 <    for (integrableObject = mol->beginIntegrableObject(ii); integrableObject != NULL;
537 <           integrableObject = mol->nextIntegrableObject(ii)) {
538 <
536 >    for (integrableObject = mol->beginIntegrableObject(ii);
537 >         integrableObject != NULL;
538 >         integrableObject = mol->nextIntegrableObject(ii)) {
539 >      
540        if (integrableObject->isRigidBody()) {
541 <          rb = static_cast<RigidBody*>(integrableObject);
542 <          std::vector<Atom*> atoms = rb->getAtoms();
543 <          std::set<int> rigidAtoms;
544 <          for (int i = 0; i < atoms.size(); ++i) {
545 <            rigidAtoms.insert(atoms[i]->getGlobalIndex());
546 <          }
547 <          for (int i = 0; i < atoms.size(); ++i) {
548 <            atomGroups.insert(std::map<int, std::set<int> >::value_type(atoms[i]->getGlobalIndex(), rigidAtoms));
549 <          }      
541 >        rb = static_cast<RigidBody*>(integrableObject);
542 >        std::vector<Atom*> atoms = rb->getAtoms();
543 >        std::set<int> rigidAtoms;
544 >        for (int i = 0; i < static_cast<int>(atoms.size()); ++i) {
545 >          rigidAtoms.insert(atoms[i]->getGlobalIndex());
546 >        }
547 >        for (int i = 0; i < static_cast<int>(atoms.size()); ++i) {
548 >          atomGroups.insert(std::map<int, std::set<int> >::value_type(atoms[i]->getGlobalIndex(), rigidAtoms));
549 >        }      
550        } else {
551          std::set<int> oneAtomSet;
552          oneAtomSet.insert(integrableObject->getGlobalIndex());
# Line 492 | Line 554 | namespace oopse {
554        }
555      }  
556  
557 <    
558 <    for (bond= mol->beginBond(bondIter); bond != NULL; bond = mol->nextBond(bondIter)) {
557 >    for (bond= mol->beginBond(bondIter); bond != NULL;
558 >         bond = mol->nextBond(bondIter)) {
559 >      
560        a = bond->getAtomA()->getGlobalIndex();
561 <      b = bond->getAtomB()->getGlobalIndex();        
562 <      exclude_.removePair(a, b);
561 >      b = bond->getAtomB()->getGlobalIndex();  
562 >    
563 >      if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) {
564 >        oneTwoInteractions_.removePair(a, b);
565 >      } else {
566 >        excludedInteractions_.removePair(a, b);
567 >      }
568      }
569  
570 <    for (bend= mol->beginBend(bendIter); bend != NULL; bend = mol->nextBend(bendIter)) {
570 >    for (bend= mol->beginBend(bendIter); bend != NULL;
571 >         bend = mol->nextBend(bendIter)) {
572 >
573        a = bend->getAtomA()->getGlobalIndex();
574        b = bend->getAtomB()->getGlobalIndex();        
575        c = bend->getAtomC()->getGlobalIndex();
506
507      std::set<int> rigidSetA = getRigidSet(a, atomGroups);
508      std::set<int> rigidSetB = getRigidSet(b, atomGroups);
509      std::set<int> rigidSetC = getRigidSet(c, atomGroups);
510
511      exclude_.removePairs(rigidSetA, rigidSetB);
512      exclude_.removePairs(rigidSetA, rigidSetC);
513      exclude_.removePairs(rigidSetB, rigidSetC);
576        
577 <      //exclude_.removePair(a, b);
578 <      //exclude_.removePair(a, c);
579 <      //exclude_.removePair(b, c);        
577 >      if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) {
578 >        oneTwoInteractions_.removePair(a, b);      
579 >        oneTwoInteractions_.removePair(b, c);
580 >      } else {
581 >        excludedInteractions_.removePair(a, b);
582 >        excludedInteractions_.removePair(b, c);
583 >      }
584 >
585 >      if (options_.havevdw13scale() || options_.haveelectrostatic13scale()) {
586 >        oneThreeInteractions_.removePair(a, c);      
587 >      } else {
588 >        excludedInteractions_.removePair(a, c);
589 >      }
590      }
591  
592 <    for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; torsion = mol->nextTorsion(torsionIter)) {
592 >    for (torsion= mol->beginTorsion(torsionIter); torsion != NULL;
593 >         torsion = mol->nextTorsion(torsionIter)) {
594 >
595        a = torsion->getAtomA()->getGlobalIndex();
596        b = torsion->getAtomB()->getGlobalIndex();        
597        c = torsion->getAtomC()->getGlobalIndex();        
598 <      d = torsion->getAtomD()->getGlobalIndex();        
598 >      d = torsion->getAtomD()->getGlobalIndex();      
599 >  
600 >      if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) {
601 >        oneTwoInteractions_.removePair(a, b);      
602 >        oneTwoInteractions_.removePair(b, c);
603 >        oneTwoInteractions_.removePair(c, d);
604 >      } else {
605 >        excludedInteractions_.removePair(a, b);
606 >        excludedInteractions_.removePair(b, c);
607 >        excludedInteractions_.removePair(c, d);
608 >      }
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_.havevdw13scale() || options_.haveelectrostatic13scale()) {
611 >        oneThreeInteractions_.removePair(a, c);      
612 >        oneThreeInteractions_.removePair(b, d);      
613 >      } else {
614 >        excludedInteractions_.removePair(a, c);
615 >        excludedInteractions_.removePair(b, d);
616 >      }
617  
618 <      exclude_.removePairs(rigidSetA, rigidSetB);
619 <      exclude_.removePairs(rigidSetA, rigidSetC);
620 <      exclude_.removePairs(rigidSetA, rigidSetD);
621 <      exclude_.removePairs(rigidSetB, rigidSetC);
622 <      exclude_.removePairs(rigidSetB, rigidSetD);
623 <      exclude_.removePairs(rigidSetC, rigidSetD);
618 >      if (options_.havevdw14scale() || options_.haveelectrostatic14scale()) {
619 >        oneFourInteractions_.removePair(a, d);      
620 >      } else {
621 >        excludedInteractions_.removePair(a, d);
622 >      }
623 >    }
624  
625 <      /*
626 <      exclude_.removePairs(rigidSetA.begin(), rigidSetA.end(), rigidSetB.begin(), rigidSetB.end());
540 <      exclude_.removePairs(rigidSetA.begin(), rigidSetA.end(), rigidSetC.begin(), rigidSetC.end());
541 <      exclude_.removePairs(rigidSetA.begin(), rigidSetA.end(), rigidSetD.begin(), rigidSetD.end());
542 <      exclude_.removePairs(rigidSetB.begin(), rigidSetB.end(), rigidSetC.begin(), rigidSetC.end());
543 <      exclude_.removePairs(rigidSetB.begin(), rigidSetB.end(), rigidSetD.begin(), rigidSetD.end());
544 <      exclude_.removePairs(rigidSetC.begin(), rigidSetC.end(), rigidSetD.begin(), rigidSetD.end());
625 >    for (inversion= mol->beginInversion(inversionIter); inversion != NULL;
626 >         inversion = mol->nextInversion(inversionIter)) {
627  
628 <      
629 <      exclude_.removePair(a, b);
630 <      exclude_.removePair(a, c);
631 <      exclude_.removePair(a, d);
550 <      exclude_.removePair(b, c);
551 <      exclude_.removePair(b, d);
552 <      exclude_.removePair(c, d);        
553 <      */
554 <    }
628 >      a = inversion->getAtomA()->getGlobalIndex();
629 >      b = inversion->getAtomB()->getGlobalIndex();        
630 >      c = inversion->getAtomC()->getGlobalIndex();        
631 >      d = inversion->getAtomD()->getGlobalIndex();        
632  
633 <    for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) {
633 >      if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) {
634 >        oneTwoInteractions_.removePair(a, b);      
635 >        oneTwoInteractions_.removePair(a, c);
636 >        oneTwoInteractions_.removePair(a, d);
637 >      } else {
638 >        excludedInteractions_.removePair(a, b);
639 >        excludedInteractions_.removePair(a, c);
640 >        excludedInteractions_.removePair(a, d);
641 >      }
642 >
643 >      if (options_.havevdw13scale() || options_.haveelectrostatic13scale()) {
644 >        oneThreeInteractions_.removePair(b, c);    
645 >        oneThreeInteractions_.removePair(b, d);    
646 >        oneThreeInteractions_.removePair(c, d);      
647 >      } else {
648 >        excludedInteractions_.removePair(b, c);
649 >        excludedInteractions_.removePair(b, d);
650 >        excludedInteractions_.removePair(c, d);
651 >      }
652 >    }
653 >
654 >    for (rb = mol->beginRigidBody(rbIter); rb != NULL;
655 >         rb = mol->nextRigidBody(rbIter)) {
656        std::vector<Atom*> atoms = rb->getAtoms();
657 <      for (int i = 0; i < atoms.size() -1 ; ++i) {
658 <        for (int j = i + 1; j < atoms.size(); ++j) {
657 >      for (int i = 0; i < static_cast<int>(atoms.size()) -1 ; ++i) {
658 >        for (int j = i + 1; j < static_cast<int>(atoms.size()); ++j) {
659            a = atoms[i]->getGlobalIndex();
660            b = atoms[j]->getGlobalIndex();
661 <          exclude_.removePair(a, b);
661 >          excludedInteractions_.removePair(a, b);
662          }
663        }
664      }        
665 <
665 >    
666    }
667 <
668 <
667 >  
668 >  
669    void SimInfo::addMoleculeStamp(MoleculeStamp* molStamp, int nmol) {
670      int curStampId;
671 <
671 >    
672      //index from 0
673      curStampId = moleculeStamps_.size();
674  
# Line 591 | Line 690 | namespace oopse {
690      /** @deprecate */    
691      int isError = 0;
692      
693 +    setupCutoff();
694 +    
695      setupElectrostaticSummationMethod( isError );
696      setupSwitchingFunction();
697 +    setupAccumulateBoxDipole();
698  
699      if(isError){
700        sprintf( painCave.errMsg,
# Line 600 | Line 702 | namespace oopse {
702        painCave.isFatal = 1;
703        simError();
704      }
603  
604    
605    setupCutoff();
705  
706      calcNdf();
707      calcNdfRaw();
# Line 652 | Line 751 | namespace oopse {
751      int usePBC = simParams_->getUsePeriodicBoundaryConditions();
752      int useRF;
753      int useSF;
754 +    int useSP;
755 +    int useBoxDipole;
756 +
757      std::string myMethod;
758  
759      // set the useRF logical
760      useRF = 0;
761      useSF = 0;
762 +    useSP = 0;
763 +    useBoxDipole = 0;
764  
765  
766      if (simParams_->haveElectrostaticSummationMethod()) {
767        std::string myMethod = simParams_->getElectrostaticSummationMethod();
768        toUpper(myMethod);
769 <      if (myMethod == "REACTION_FIELD") {
770 <        useRF=1;
771 <      } else {
772 <        if (myMethod == "SHIFTED_FORCE") {
773 <          useSF = 1;
774 <        }
769 >      if (myMethod == "REACTION_FIELD"){
770 >        useRF = 1;
771 >      } else if (myMethod == "SHIFTED_FORCE"){
772 >        useSF = 1;
773 >      } else if (myMethod == "SHIFTED_POTENTIAL"){
774 >        useSP = 1;
775        }
776      }
777 +    
778 +    if (simParams_->haveAccumulateBoxDipole())
779 +      if (simParams_->getAccumulateBoxDipole())
780 +        useBoxDipole = 1;
781  
782 +    useAtomicVirial_ = simParams_->getUseAtomicVirial();
783 +
784      //loop over all of the atom types
785      for (i = atomTypes.begin(); i != atomTypes.end(); ++i) {
786        useLennardJones |= (*i)->isLennardJones();
# Line 740 | Line 850 | namespace oopse {
850      MPI_Allreduce(&temp, &useRF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);    
851  
852      temp = useSF;
853 <    MPI_Allreduce(&temp, &useSF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);    
853 >    MPI_Allreduce(&temp, &useSF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);  
854  
855 +    temp = useSP;
856 +    MPI_Allreduce(&temp, &useSP, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);
857 +
858 +    temp = useBoxDipole;
859 +    MPI_Allreduce(&temp, &useBoxDipole, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);
860 +
861 +    temp = useAtomicVirial_;
862 +    MPI_Allreduce(&temp, &useAtomicVirial_, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);
863 +
864   #endif
865  
866      fInfo_.SIM_uses_PBC = usePBC;    
# Line 759 | Line 878 | namespace oopse {
878      fInfo_.SIM_uses_FLARB = useFLARB;
879      fInfo_.SIM_uses_RF = useRF;
880      fInfo_.SIM_uses_SF = useSF;
881 <
882 <    if( myMethod == "REACTION_FIELD") {
883 <      
765 <      if (simParams_->haveDielectric()) {
766 <        fInfo_.dielect = simParams_->getDielectric();
767 <      } else {
768 <        sprintf(painCave.errMsg,
769 <                "SimSetup Error: No Dielectric constant was set.\n"
770 <                "\tYou are trying to use Reaction Field without"
771 <                "\tsetting a dielectric constant!\n");
772 <        painCave.isFatal = 1;
773 <        simError();
774 <      }      
775 <    }
776 <
881 >    fInfo_.SIM_uses_SP = useSP;
882 >    fInfo_.SIM_uses_BoxDipole = useBoxDipole;
883 >    fInfo_.SIM_uses_AtomicVirial = useAtomicVirial_;
884    }
885  
886    void SimInfo::setupFortranSim() {
887      int isError;
888 <    int nExclude;
888 >    int nExclude, nOneTwo, nOneThree, nOneFour;
889      std::vector<int> fortranGlobalGroupMembership;
890      
784    nExclude = exclude_.getSize();
891      isError = 0;
892  
893      //globalGroupMembership_ is filled by SimCreator    
# Line 790 | Line 896 | namespace oopse {
896      }
897  
898      //calculate mass ratio of cutoff group
899 <    std::vector<double> mfact;
899 >    std::vector<RealType> mfact;
900      SimInfo::MoleculeIterator mi;
901      Molecule* mol;
902      Molecule::CutoffGroupIterator ci;
903      CutoffGroup* cg;
904      Molecule::AtomIterator ai;
905      Atom* atom;
906 <    double totalMass;
906 >    RealType totalMass;
907  
908      //to avoid memory reallocation, reserve enough space for mfact
909      mfact.reserve(getNCutoffGroups());
# Line 813 | Line 919 | namespace oopse {
919            else
920              mfact.push_back( 1.0 );
921          }
816
922        }      
923      }
924  
# Line 837 | Line 942 | namespace oopse {
942      }
943      
944      //setup fortran simulation
840    int nGlobalExcludes = 0;
841    int* globalExcludes = NULL;
842    int* excludeList = exclude_.getExcludeList();
843    setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray[0], &nExclude, excludeList ,
844                   &nGlobalExcludes, globalExcludes, &molMembershipArray[0],
845                   &mfact[0], &nCutoffGroups_, &fortranGlobalGroupMembership[0], &isError);
945  
946 <    if( isError ){
946 >    nExclude = excludedInteractions_.getSize();
947 >    nOneTwo = oneTwoInteractions_.getSize();
948 >    nOneThree = oneThreeInteractions_.getSize();
949 >    nOneFour = oneFourInteractions_.getSize();
950  
951 +    int* excludeList = excludedInteractions_.getPairList();
952 +    int* oneTwoList = oneTwoInteractions_.getPairList();
953 +    int* oneThreeList = oneThreeInteractions_.getPairList();
954 +    int* oneFourList = oneFourInteractions_.getPairList();
955 +
956 +    setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray[0],
957 +                   &nExclude, excludeList,
958 +                   &nOneTwo, oneTwoList,
959 +                   &nOneThree, oneThreeList,
960 +                   &nOneFour, oneFourList,
961 +                   &molMembershipArray[0], &mfact[0], &nCutoffGroups_,
962 +                   &fortranGlobalGroupMembership[0], &isError);
963 +    
964 +    if( isError ){
965 +      
966        sprintf( painCave.errMsg,
967                 "There was an error setting the simulation information in fortran.\n" );
968        painCave.isFatal = 1;
969 <      painCave.severity = OOPSE_ERROR;
969 >      painCave.severity = OPENMD_ERROR;
970        simError();
971      }
972 <
973 < #ifdef IS_MPI
972 >    
973 >    
974      sprintf( checkPointMsg,
975               "succesfully sent the simulation information to fortran.\n");
976 <    MPIcheckPoint();
977 < #endif // is_mpi
976 >    
977 >    errorCheckPoint();
978 >    
979 >    // Setup number of neighbors in neighbor list if present
980 >    if (simParams_->haveNeighborListNeighbors()) {
981 >      int nlistNeighbors = simParams_->getNeighborListNeighbors();
982 >      setNeighbors(&nlistNeighbors);
983 >    }
984 >  
985 >
986    }
987  
988  
864 #ifdef IS_MPI
989    void SimInfo::setupFortranParallel() {
990 <    
990 > #ifdef IS_MPI    
991      //SimInfo is responsible for creating localToGlobalAtomIndex and localToGlobalGroupIndex
992      std::vector<int> localToGlobalAtomIndex(getNAtoms(), 0);
993      std::vector<int> localToGlobalCutoffGroupIndex;
# Line 913 | Line 1037 | namespace oopse {
1037      }
1038  
1039      sprintf(checkPointMsg, " mpiRefresh successful.\n");
1040 <    MPIcheckPoint();
1040 >    errorCheckPoint();
1041  
1042 <
1042 > #endif
1043    }
1044  
921 #endif
922
1045    void SimInfo::setupCutoff() {          
1046      
1047      ForceFieldOptions& forceFieldOptions_ = forceField_->getForceFieldOptions();
# Line 927 | Line 1049 | namespace oopse {
1049      // Check the cutoff policy
1050      int cp =  TRADITIONAL_CUTOFF_POLICY; // Set to traditional by default
1051  
1052 +    // Set LJ shifting bools to false
1053 +    ljsp_ = 0;
1054 +    ljsf_ = 0;
1055 +
1056      std::string myPolicy;
1057      if (forceFieldOptions_.haveCutoffPolicy()){
1058        myPolicy = forceFieldOptions_.getCutoffPolicy();
# Line 957 | Line 1083 | namespace oopse {
1083      notifyFortranCutoffPolicy(&cp);
1084  
1085      // Check the Skin Thickness for neighborlists
1086 <    double skin;
1086 >    RealType skin;
1087      if (simParams_->haveSkinThickness()) {
1088        skin = simParams_->getSkinThickness();
1089        notifyFortranSkinThickness(&skin);
# Line 976 | Line 1102 | namespace oopse {
1102            rsw_ = 0.85 * rcut_;
1103            sprintf(painCave.errMsg,
1104                    "SimCreator Warning: No value was set for the switchingRadius.\n"
1105 <                  "\tOOPSE will use a default value of 85\% of the cutoffRadius"
1105 >                  "\tOpenMD will use a default value of 85 percent of the cutoffRadius.\n"
1106                    "\tswitchingRadius = %f. for this simulation\n", rsw_);
1107          painCave.isFatal = 0;
1108          simError();
# Line 984 | Line 1110 | namespace oopse {
1110            rsw_ = rcut_;
1111            sprintf(painCave.errMsg,
1112                    "SimCreator Warning: No value was set for the switchingRadius.\n"
1113 <                  "\tOOPSE will use the same value as the cutoffRadius.\n"
1113 >                  "\tOpenMD will use the same value as the cutoffRadius.\n"
1114                    "\tswitchingRadius = %f. for this simulation\n", rsw_);
1115            painCave.isFatal = 0;
1116            simError();
1117          }
1118 <          
1119 <      notifyFortranCutoffs(&rcut_, &rsw_);
1118 >      }
1119 >
1120 >      if (simParams_->haveElectrostaticSummationMethod()) {
1121 >        std::string myMethod = simParams_->getElectrostaticSummationMethod();
1122 >        toUpper(myMethod);
1123 >        
1124 >        if (myMethod == "SHIFTED_POTENTIAL") {
1125 >          ljsp_ = 1;
1126 >        } else if (myMethod == "SHIFTED_FORCE") {
1127 >          ljsf_ = 1;
1128 >        }
1129 >      }
1130 >
1131 >      notifyFortranCutoffs(&rcut_, &rsw_, &ljsp_, &ljsf_);
1132        
1133      } else {
1134        
# Line 998 | Line 1136 | namespace oopse {
1136        if (fInfo_.SIM_uses_Charges | fInfo_.SIM_uses_Dipoles | fInfo_.SIM_uses_RF) {
1137          sprintf(painCave.errMsg,
1138                  "SimCreator Warning: No value was set for the cutoffRadius.\n"
1139 <                "\tOOPSE will use a default value of 15.0 angstroms"
1139 >                "\tOpenMD will use a default value of 15.0 angstroms"
1140                  "\tfor the cutoffRadius.\n");
1141          painCave.isFatal = 0;
1142          simError();
# Line 1007 | Line 1145 | namespace oopse {
1145          if (simParams_->haveElectrostaticSummationMethod()) {
1146            std::string myMethod = simParams_->getElectrostaticSummationMethod();
1147            toUpper(myMethod);
1148 <          if (myMethod == "SHIFTED_POTENTIAL" || myMethod == "SHIFTED_FORCE") {
1148 >          
1149 >          // For the time being, we're tethering the LJ shifted behavior to the
1150 >          // electrostaticSummationMethod keyword options
1151 >          if (myMethod == "SHIFTED_POTENTIAL") {
1152 >            ljsp_ = 1;
1153 >          } else if (myMethod == "SHIFTED_FORCE") {
1154 >            ljsf_ = 1;
1155 >          }
1156 >          if (myMethod == "SHIFTED_POTENTIAL" || myMethod == "SHIFTED_FORCE") {
1157              if (simParams_->haveSwitchingRadius()){
1158                sprintf(painCave.errMsg,
1159                        "SimInfo Warning: A value was set for the switchingRadius\n"
# Line 1024 | Line 1170 | namespace oopse {
1170          } else {        
1171            sprintf(painCave.errMsg,
1172                    "SimCreator Warning: No value was set for switchingRadius.\n"
1173 <                  "\tOOPSE will use a default value of\n"
1173 >                  "\tOpenMD will use a default value of\n"
1174                    "\t0.85 * cutoffRadius for the switchingRadius\n");
1175            painCave.isFatal = 0;
1176            simError();
1177            rsw_ = 0.85 * rcut_;
1178          }
1179 <        notifyFortranCutoffs(&rcut_, &rsw_);
1179 >
1180 >        Electrostatic::setElectrostaticCutoffRadius(rcut_, rsw_);
1181 >        notifyFortranCutoffs(&rcut_, &rsw_, &ljsp_, &ljsf_);
1182 >
1183        } else {
1184          // We didn't set rcut explicitly, and we don't have electrostatic atoms, so
1185          // We'll punt and let fortran figure out the cutoffs later.
# Line 1044 | Line 1193 | namespace oopse {
1193    void SimInfo::setupElectrostaticSummationMethod( int isError ) {    
1194      
1195      int errorOut;
1196 <    int esm =  NONE;
1197 <    int sm = UNDAMPED;
1198 <    double alphaVal;
1199 <    double dielectric;
1200 <
1196 >    ElectrostaticSummationMethod esm = NONE;
1197 >    ElectrostaticScreeningMethod sm = UNDAMPED;
1198 >    RealType alphaVal;
1199 >    RealType dielectric;
1200 >    
1201      errorOut = isError;
1053    alphaVal = simParams_->getDampingAlpha();
1054    dielectric = simParams_->getDielectric();
1202  
1203      if (simParams_->haveElectrostaticSummationMethod()) {
1204        std::string myMethod = simParams_->getElectrostaticSummationMethod();
# Line 1068 | Line 1215 | namespace oopse {
1215              if (myMethod == "SHIFTED_FORCE") {            
1216                esm = SHIFTED_FORCE;
1217              } else {
1218 <              if (myMethod == "REACTION_FIELD") {            
1218 >              if (myMethod == "REACTION_FIELD") {
1219                  esm = REACTION_FIELD;
1220 +                dielectric = simParams_->getDielectric();
1221 +                if (!simParams_->haveDielectric()) {
1222 +                  // throw warning
1223 +                  sprintf( painCave.errMsg,
1224 +                           "SimInfo warning: dielectric was not specified in the input file\n\tfor the reaction field correction method.\n"
1225 +                           "\tA default value of %f will be used for the dielectric.\n", dielectric);
1226 +                  painCave.isFatal = 0;
1227 +                  simError();
1228 +                }
1229                } else {
1230                  // throw error        
1231                  sprintf( painCave.errMsg,
# Line 1096 | Line 1252 | namespace oopse {
1252          if (myScreen == "DAMPED") {
1253            sm = DAMPED;
1254            if (!simParams_->haveDampingAlpha()) {
1255 <            //throw error
1255 >            // first set a cutoff dependent alpha value
1256 >            // we assume alpha depends linearly with rcut from 0 to 20.5 ang
1257 >            alphaVal = 0.5125 - rcut_* 0.025;
1258 >            // for values rcut > 20.5, alpha is zero
1259 >            if (alphaVal < 0) alphaVal = 0;
1260 >
1261 >            // throw warning
1262              sprintf( painCave.errMsg,
1263                       "SimInfo warning: dampingAlpha was not specified in the input file.\n"
1264 <                     "\tA default value of %f (1/ang) will be used.\n", alphaVal);
1264 >                     "\tA default value of %f (1/ang) will be used for the cutoff of\n\t%f (ang).\n", alphaVal, rcut_);
1265              painCave.isFatal = 0;
1266              simError();
1267 +          } else {
1268 +            alphaVal = simParams_->getDampingAlpha();
1269            }
1270 +          
1271          } else {
1272            // throw error        
1273            sprintf( painCave.errMsg,
# Line 1116 | Line 1281 | namespace oopse {
1281        }
1282      }
1283      
1284 <    // let's pass some summation method variables to fortran
1285 <    setElectrostaticSummationMethod( &esm );
1286 <    setFortranElectrostaticMethod( &esm );
1287 <    setScreeningMethod( &sm );
1288 <    setDampingAlpha( &alphaVal );
1124 <    setReactionFieldDielectric( &dielectric );
1284 >
1285 >    Electrostatic::setElectrostaticSummationMethod( esm );
1286 >    Electrostatic::setElectrostaticScreeningMethod( sm );
1287 >    Electrostatic::setDampingAlpha( alphaVal );
1288 >    Electrostatic::setReactionFieldDielectric( dielectric );
1289      initFortranFF( &errorOut );
1290    }
1291  
# Line 1151 | Line 1315 | namespace oopse {
1315  
1316    }
1317  
1318 +  void SimInfo::setupAccumulateBoxDipole() {    
1319 +
1320 +    // we only call setAccumulateBoxDipole if the accumulateBoxDipole parameter is true
1321 +    if ( simParams_->haveAccumulateBoxDipole() )
1322 +      if ( simParams_->getAccumulateBoxDipole() ) {
1323 +        setAccumulateBoxDipole();
1324 +        calcBoxDipole_ = true;
1325 +      }
1326 +
1327 +  }
1328 +
1329    void SimInfo::addProperty(GenericData* genData) {
1330      properties_.addProperty(genData);  
1331    }
# Line 1207 | Line 1382 | namespace oopse {
1382      Molecule* mol;
1383  
1384      Vector3d comVel(0.0);
1385 <    double totalMass = 0.0;
1385 >    RealType totalMass = 0.0;
1386      
1387  
1388      for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) {
1389 <      double mass = mol->getMass();
1389 >      RealType mass = mol->getMass();
1390        totalMass += mass;
1391        comVel += mass * mol->getComVel();
1392      }  
1393  
1394   #ifdef IS_MPI
1395 <    double tmpMass = totalMass;
1395 >    RealType tmpMass = totalMass;
1396      Vector3d tmpComVel(comVel);    
1397 <    MPI_Allreduce(&tmpMass,&totalMass,1,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);
1398 <    MPI_Allreduce(tmpComVel.getArrayPointer(), comVel.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);
1397 >    MPI_Allreduce(&tmpMass,&totalMass,1,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1398 >    MPI_Allreduce(tmpComVel.getArrayPointer(), comVel.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1399   #endif
1400  
1401      comVel /= totalMass;
# Line 1233 | Line 1408 | namespace oopse {
1408      Molecule* mol;
1409  
1410      Vector3d com(0.0);
1411 <    double totalMass = 0.0;
1411 >    RealType totalMass = 0.0;
1412      
1413      for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) {
1414 <      double mass = mol->getMass();
1414 >      RealType mass = mol->getMass();
1415        totalMass += mass;
1416        com += mass * mol->getCom();
1417      }  
1418  
1419   #ifdef IS_MPI
1420 <    double tmpMass = totalMass;
1420 >    RealType tmpMass = totalMass;
1421      Vector3d tmpCom(com);    
1422 <    MPI_Allreduce(&tmpMass,&totalMass,1,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);
1423 <    MPI_Allreduce(tmpCom.getArrayPointer(), com.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);
1422 >    MPI_Allreduce(&tmpMass,&totalMass,1,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1423 >    MPI_Allreduce(tmpCom.getArrayPointer(), com.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1424   #endif
1425  
1426      com /= totalMass;
# Line 1269 | Line 1444 | namespace oopse {
1444        Molecule* mol;
1445        
1446      
1447 <      double totalMass = 0.0;
1447 >      RealType totalMass = 0.0;
1448      
1449  
1450        for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) {
1451 <         double mass = mol->getMass();
1451 >         RealType mass = mol->getMass();
1452           totalMass += mass;
1453           com += mass * mol->getCom();
1454           comVel += mass * mol->getComVel();          
1455        }  
1456        
1457   #ifdef IS_MPI
1458 <      double tmpMass = totalMass;
1458 >      RealType tmpMass = totalMass;
1459        Vector3d tmpCom(com);  
1460        Vector3d tmpComVel(comVel);
1461 <      MPI_Allreduce(&tmpMass,&totalMass,1,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);
1462 <      MPI_Allreduce(tmpCom.getArrayPointer(), com.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);
1463 <      MPI_Allreduce(tmpComVel.getArrayPointer(), comVel.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);
1461 >      MPI_Allreduce(&tmpMass,&totalMass,1,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1462 >      MPI_Allreduce(tmpCom.getArrayPointer(), com.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1463 >      MPI_Allreduce(tmpComVel.getArrayPointer(), comVel.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1464   #endif
1465        
1466        com /= totalMass;
# Line 1304 | Line 1479 | namespace oopse {
1479     void SimInfo::getInertiaTensor(Mat3x3d &inertiaTensor, Vector3d &angularMomentum){
1480        
1481  
1482 <      double xx = 0.0;
1483 <      double yy = 0.0;
1484 <      double zz = 0.0;
1485 <      double xy = 0.0;
1486 <      double xz = 0.0;
1487 <      double yz = 0.0;
1482 >      RealType xx = 0.0;
1483 >      RealType yy = 0.0;
1484 >      RealType zz = 0.0;
1485 >      RealType xy = 0.0;
1486 >      RealType xz = 0.0;
1487 >      RealType yz = 0.0;
1488        Vector3d com(0.0);
1489        Vector3d comVel(0.0);
1490        
# Line 1321 | Line 1496 | namespace oopse {
1496        Vector3d thisq(0.0);
1497        Vector3d thisv(0.0);
1498  
1499 <      double thisMass = 0.0;
1499 >      RealType thisMass = 0.0;
1500      
1501        
1502        
# Line 1359 | Line 1534 | namespace oopse {
1534   #ifdef IS_MPI
1535        Mat3x3d tmpI(inertiaTensor);
1536        Vector3d tmpAngMom;
1537 <      MPI_Allreduce(tmpI.getArrayPointer(), inertiaTensor.getArrayPointer(),9,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);
1538 <      MPI_Allreduce(tmpAngMom.getArrayPointer(), angularMomentum.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);
1537 >      MPI_Allreduce(tmpI.getArrayPointer(), inertiaTensor.getArrayPointer(),9,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1538 >      MPI_Allreduce(tmpAngMom.getArrayPointer(), angularMomentum.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1539   #endif
1540                
1541        return;
# Line 1381 | Line 1556 | namespace oopse {
1556        Vector3d thisr(0.0);
1557        Vector3d thisp(0.0);
1558        
1559 <      double thisMass;
1559 >      RealType thisMass;
1560        
1561        for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) {        
1562          thisMass = mol->getMass();
# Line 1394 | Line 1569 | namespace oopse {
1569        
1570   #ifdef IS_MPI
1571        Vector3d tmpAngMom;
1572 <      MPI_Allreduce(tmpAngMom.getArrayPointer(), angularMomentum.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD);
1572 >      MPI_Allreduce(tmpAngMom.getArrayPointer(), angularMomentum.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1573   #endif
1574        
1575        return angularMomentum;
1576     }
1577    
1578 <  
1579 < }//end namespace oopse
1578 >  StuntDouble* SimInfo::getIOIndexToIntegrableObject(int index) {
1579 >    return IOIndexToIntegrableObject.at(index);
1580 >  }
1581 >  
1582 >  void SimInfo::setIOIndexToIntegrableObject(const std::vector<StuntDouble*>& v) {
1583 >    IOIndexToIntegrableObject= v;
1584 >  }
1585  
1586 +  /* Returns the Volume of the simulation based on a ellipsoid with semi-axes
1587 +     based on the radius of gyration V=4/3*Pi*R_1*R_2*R_3
1588 +     where R_i are related to the principle inertia moments R_i = sqrt(C*I_i/N), this reduces to
1589 +     V = 4/3*Pi*(C/N)^3/2*sqrt(det(I)). See S.E. Baltazar et. al. Comp. Mat. Sci. 37 (2006) 526-536.
1590 +  */
1591 +  void SimInfo::getGyrationalVolume(RealType &volume){
1592 +    Mat3x3d intTensor;
1593 +    RealType det;
1594 +    Vector3d dummyAngMom;
1595 +    RealType sysconstants;
1596 +    RealType geomCnst;
1597 +
1598 +    geomCnst = 3.0/2.0;
1599 +    /* Get the inertial tensor and angular momentum for free*/
1600 +    getInertiaTensor(intTensor,dummyAngMom);
1601 +    
1602 +    det = intTensor.determinant();
1603 +    sysconstants = geomCnst/(RealType)nGlobalIntegrableObjects_;
1604 +    volume = 4.0/3.0*NumericConstant::PI*pow(sysconstants,3.0/2.0)*sqrt(det);
1605 +    return;
1606 +  }
1607 +
1608 +  void SimInfo::getGyrationalVolume(RealType &volume, RealType &detI){
1609 +    Mat3x3d intTensor;
1610 +    Vector3d dummyAngMom;
1611 +    RealType sysconstants;
1612 +    RealType geomCnst;
1613 +
1614 +    geomCnst = 3.0/2.0;
1615 +    /* Get the inertial tensor and angular momentum for free*/
1616 +    getInertiaTensor(intTensor,dummyAngMom);
1617 +    
1618 +    detI = intTensor.determinant();
1619 +    sysconstants = geomCnst/(RealType)nGlobalIntegrableObjects_;
1620 +    volume = 4.0/3.0*NumericConstant::PI*pow(sysconstants,3.0/2.0)*sqrt(detI);
1621 +    return;
1622 +  }
1623 + /*
1624 +   void SimInfo::setStuntDoubleFromGlobalIndex(std::vector<StuntDouble*> v) {
1625 +      assert( v.size() == nAtoms_ + nRigidBodies_);
1626 +      sdByGlobalIndex_ = v;
1627 +    }
1628 +
1629 +    StuntDouble* SimInfo::getStuntDoubleFromGlobalIndex(int index) {
1630 +      //assert(index < nAtoms_ + nRigidBodies_);
1631 +      return sdByGlobalIndex_.at(index);
1632 +    }  
1633 + */  
1634 + }//end namespace OpenMD
1635 +

Comparing:
trunk/src/brains/SimInfo.cpp (property svn:keywords), Revision 878 by chrisfen, Wed Feb 1 20:54:46 2006 UTC vs.
branches/development/src/brains/SimInfo.cpp (property svn:keywords), Revision 1503 by gezelter, Sat Oct 2 19:54:41 2010 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines