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 143 by chrisfen, Fri Oct 22 22:54:01 2004 UTC vs.
branches/development/src/brains/SimInfo.cpp (file contents), Revision 1535 by gezelter, Fri Dec 31 18:31:56 2010 UTC

# Line 1 | Line 1
1 < #include <stdlib.h>
2 < #include <string.h>
3 < #include <math.h>
1 > /*
2 > * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3 > *
4 > * The University of Notre Dame grants you ("Licensee") a
5 > * non-exclusive, royalty free, license to use, modify and
6 > * redistribute this software in source and binary code form, provided
7 > * that the following conditions are met:
8 > *
9 > * 1. Redistributions of source code must retain the above copyright
10 > *    notice, this list of conditions and the following disclaimer.
11 > *
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.
16 > *
17 > * This software is provided "AS IS," without a warranty of any
18 > * kind. All express or implied conditions, representations and
19 > * warranties, including any implied warranty of merchantability,
20 > * fitness for a particular purpose or non-infringement, are hereby
21 > * excluded.  The University of Notre Dame and its licensors shall not
22 > * be liable for any damages suffered by licensee as a result of
23 > * using, modifying or distributing the software or its
24 > * derivatives. In no event will the University of Notre Dame or its
25 > * licensors be liable for any lost revenue, profit or data, or for
26 > * direct, indirect, special, consequential, incidental or punitive
27 > * damages, however caused and regardless of the theory of liability,
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 > /**
43 > * @file SimInfo.cpp
44 > * @author    tlin
45 > * @date  11/02/2004
46 > * @version 1.0
47 > */
48  
49 < #include <iostream>
50 < using namespace std;
49 > #include <algorithm>
50 > #include <set>
51 > #include <map>
52  
53   #include "brains/SimInfo.hpp"
54 < #define __C
55 < #include "brains/fSimulation.h"
54 > #include "math/Vector3.hpp"
55 > #include "primitives/Molecule.hpp"
56 > #include "primitives/StuntDouble.hpp"
57 > #include "UseTheForce/DarkSide/neighborLists_interface.h"
58 > #include "utils/MemoryUtils.hpp"
59   #include "utils/simError.h"
60 < #include "UseTheForce/DarkSide/simulation_interface.h"
61 < #include "UseTheForce/notifyCutoffs_interface.h"
60 > #include "selection/SelectionManager.hpp"
61 > #include "io/ForceFieldOptions.hpp"
62 > #include "UseTheForce/ForceField.hpp"
63 > #include "nonbonded/SwitchingFunction.hpp"
64  
65 < //#include "UseTheForce/fortranWrappers.hpp"
65 > #ifdef IS_MPI
66 > #include "UseTheForce/mpiComponentPlan.h"
67 > #include "UseTheForce/DarkSide/simParallel_interface.h"
68 > #endif
69  
70 < #include "math/MatVec3.h"
70 > using namespace std;
71 > namespace OpenMD {
72 >  
73 >  SimInfo::SimInfo(ForceField* ff, Globals* simParams) :
74 >    forceField_(ff), simParams_(simParams),
75 >    ndf_(0), fdf_local(0), ndfRaw_(0), ndfTrans_(0), nZconstraint_(0),
76 >    nGlobalMols_(0), nGlobalAtoms_(0), nGlobalCutoffGroups_(0),
77 >    nGlobalIntegrableObjects_(0), nGlobalRigidBodies_(0),
78 >    nAtoms_(0), nBonds_(0),  nBends_(0), nTorsions_(0), nInversions_(0),
79 >    nRigidBodies_(0), nIntegrableObjects_(0), nCutoffGroups_(0),
80 >    nConstraints_(0), sman_(NULL), fortranInitialized_(false),
81 >    calcBoxDipole_(false), useAtomicVirial_(true) {    
82 >    
83 >    MoleculeStamp* molStamp;
84 >    int nMolWithSameStamp;
85 >    int nCutoffAtoms = 0; // number of atoms belong to cutoff groups
86 >    int nGroups = 0;       //total cutoff groups defined in meta-data file
87 >    CutoffGroupStamp* cgStamp;    
88 >    RigidBodyStamp* rbStamp;
89 >    int nRigidAtoms = 0;
90 >    
91 >    vector<Component*> components = simParams->getComponents();
92 >    
93 >    for (vector<Component*>::iterator i = components.begin(); i !=components.end(); ++i) {
94 >      molStamp = (*i)->getMoleculeStamp();
95 >      nMolWithSameStamp = (*i)->getNMol();
96 >      
97 >      addMoleculeStamp(molStamp, nMolWithSameStamp);
98 >      
99 >      //calculate atoms in molecules
100 >      nGlobalAtoms_ += molStamp->getNAtoms() *nMolWithSameStamp;  
101 >      
102 >      //calculate atoms in cutoff groups
103 >      int nAtomsInGroups = 0;
104 >      int nCutoffGroupsInStamp = molStamp->getNCutoffGroups();
105 >      
106 >      for (int j=0; j < nCutoffGroupsInStamp; j++) {
107 >        cgStamp = molStamp->getCutoffGroupStamp(j);
108 >        nAtomsInGroups += cgStamp->getNMembers();
109 >      }
110 >      
111 >      nGroups += nCutoffGroupsInStamp * nMolWithSameStamp;
112 >      
113 >      nCutoffAtoms += nAtomsInGroups * nMolWithSameStamp;            
114 >      
115 >      //calculate atoms in rigid bodies
116 >      int nAtomsInRigidBodies = 0;
117 >      int nRigidBodiesInStamp = molStamp->getNRigidBodies();
118 >      
119 >      for (int j=0; j < nRigidBodiesInStamp; j++) {
120 >        rbStamp = molStamp->getRigidBodyStamp(j);
121 >        nAtomsInRigidBodies += rbStamp->getNMembers();
122 >      }
123 >      
124 >      nGlobalRigidBodies_ += nRigidBodiesInStamp * nMolWithSameStamp;
125 >      nRigidAtoms += nAtomsInRigidBodies * nMolWithSameStamp;            
126 >      
127 >    }
128 >    
129 >    //every free atom (atom does not belong to cutoff groups) is a cutoff
130 >    //group therefore the total number of cutoff groups in the system is
131 >    //equal to the total number of atoms minus number of atoms belong to
132 >    //cutoff group defined in meta-data file plus the number of cutoff
133 >    //groups defined in meta-data file
134 >    nGlobalCutoffGroups_ = nGlobalAtoms_ - nCutoffAtoms + nGroups;
135 >    
136 >    //every free atom (atom does not belong to rigid bodies) is an
137 >    //integrable object therefore the total number of integrable objects
138 >    //in the system is equal to the total number of atoms minus number of
139 >    //atoms belong to rigid body defined in meta-data file plus the number
140 >    //of rigid bodies defined in meta-data file
141 >    nGlobalIntegrableObjects_ = nGlobalAtoms_ - nRigidAtoms
142 >      + nGlobalRigidBodies_;
143 >    
144 >    nGlobalMols_ = molStampIds_.size();
145 >    molToProcMap_.resize(nGlobalMols_);
146 >  }
147 >  
148 >  SimInfo::~SimInfo() {
149 >    map<int, Molecule*>::iterator i;
150 >    for (i = molecules_.begin(); i != molecules_.end(); ++i) {
151 >      delete i->second;
152 >    }
153 >    molecules_.clear();
154 >      
155 >    delete sman_;
156 >    delete simParams_;
157 >    delete forceField_;
158 >  }
159  
19 #ifdef IS_MPI
20 #include "brains/mpiSimulation.hpp"
21 #endif
160  
161 < inline double roundMe( double x ){
162 <  return ( x >= 0 ) ? floor( x + 0.5 ) : ceil( x - 0.5 );
163 < }
164 <          
165 < inline double min( double a, double b ){
166 <  return (a < b ) ? a : b;
167 < }
161 >  bool SimInfo::addMolecule(Molecule* mol) {
162 >    MoleculeIterator i;
163 >    
164 >    i = molecules_.find(mol->getGlobalIndex());
165 >    if (i == molecules_.end() ) {
166 >      
167 >      molecules_.insert(make_pair(mol->getGlobalIndex(), mol));
168 >      
169 >      nAtoms_ += mol->getNAtoms();
170 >      nBonds_ += mol->getNBonds();
171 >      nBends_ += mol->getNBends();
172 >      nTorsions_ += mol->getNTorsions();
173 >      nInversions_ += mol->getNInversions();
174 >      nRigidBodies_ += mol->getNRigidBodies();
175 >      nIntegrableObjects_ += mol->getNIntegrableObjects();
176 >      nCutoffGroups_ += mol->getNCutoffGroups();
177 >      nConstraints_ += mol->getNConstraintPairs();
178 >      
179 >      addInteractionPairs(mol);
180 >      
181 >      return true;
182 >    } else {
183 >      return false;
184 >    }
185 >  }
186 >  
187 >  bool SimInfo::removeMolecule(Molecule* mol) {
188 >    MoleculeIterator i;
189 >    i = molecules_.find(mol->getGlobalIndex());
190  
191 < SimInfo* currentInfo;
191 >    if (i != molecules_.end() ) {
192  
193 < SimInfo::SimInfo(){
193 >      assert(mol == i->second);
194 >        
195 >      nAtoms_ -= mol->getNAtoms();
196 >      nBonds_ -= mol->getNBonds();
197 >      nBends_ -= mol->getNBends();
198 >      nTorsions_ -= mol->getNTorsions();
199 >      nInversions_ -= mol->getNInversions();
200 >      nRigidBodies_ -= mol->getNRigidBodies();
201 >      nIntegrableObjects_ -= mol->getNIntegrableObjects();
202 >      nCutoffGroups_ -= mol->getNCutoffGroups();
203 >      nConstraints_ -= mol->getNConstraintPairs();
204  
205 <  n_constraints = 0;
206 <  nZconstraints = 0;
37 <  n_oriented = 0;
38 <  n_dipoles = 0;
39 <  ndf = 0;
40 <  ndfRaw = 0;
41 <  nZconstraints = 0;
42 <  the_integrator = NULL;
43 <  setTemp = 0;
44 <  thermalTime = 0.0;
45 <  currentTime = 0.0;
46 <  rCut = 0.0;
47 <  rSw = 0.0;
205 >      removeInteractionPairs(mol);
206 >      molecules_.erase(mol->getGlobalIndex());
207  
208 <  haveRcut = 0;
209 <  haveRsw = 0;
210 <  boxIsInit = 0;
211 <  
212 <  resetTime = 1e99;
208 >      delete mol;
209 >        
210 >      return true;
211 >    } else {
212 >      return false;
213 >    }
214 >  }    
215  
216 <  orthoRhombic = 0;
217 <  orthoTolerance = 1E-6;
218 <  useInitXSstate = true;
216 >        
217 >  Molecule* SimInfo::beginMolecule(MoleculeIterator& i) {
218 >    i = molecules_.begin();
219 >    return i == molecules_.end() ? NULL : i->second;
220 >  }    
221  
222 <  usePBC = 0;
223 <  useDirectionalAtoms = 0;
224 <  useLennardJones = 0;
225 <  useElectrostatics = 0;
63 <  useCharges = 0;
64 <  useDipoles = 0;
65 <  useSticky = 0;
66 <  useGayBerne = 0;
67 <  useEAM = 0;
68 <  useShapes = 0;
69 <  useFLARB = 0;
222 >  Molecule* SimInfo::nextMolecule(MoleculeIterator& i) {
223 >    ++i;
224 >    return i == molecules_.end() ? NULL : i->second;    
225 >  }
226  
71  useSolidThermInt = 0;
72  useLiquidThermInt = 0;
227  
228 <  haveCutoffGroups = false;
228 >  void SimInfo::calcNdf() {
229 >    int ndf_local;
230 >    MoleculeIterator i;
231 >    vector<StuntDouble*>::iterator j;
232 >    Molecule* mol;
233 >    StuntDouble* integrableObject;
234  
235 <  excludes = Exclude::Instance();
235 >    ndf_local = 0;
236 >    
237 >    for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) {
238 >      for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL;
239 >           integrableObject = mol->nextIntegrableObject(j)) {
240  
241 <  myConfiguration = new SimState();
241 >        ndf_local += 3;
242  
243 <  has_minimizer = false;
244 <  the_minimizer =NULL;
243 >        if (integrableObject->isDirectional()) {
244 >          if (integrableObject->isLinear()) {
245 >            ndf_local += 2;
246 >          } else {
247 >            ndf_local += 3;
248 >          }
249 >        }
250 >            
251 >      }
252 >    }
253 >    
254 >    // n_constraints is local, so subtract them on each processor
255 >    ndf_local -= nConstraints_;
256  
257 <  ngroup = 0;
257 > #ifdef IS_MPI
258 >    MPI_Allreduce(&ndf_local,&ndf_,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD);
259 > #else
260 >    ndf_ = ndf_local;
261 > #endif
262  
263 < }
263 >    // nZconstraints_ is global, as are the 3 COM translations for the
264 >    // entire system:
265 >    ndf_ = ndf_ - 3 - nZconstraint_;
266  
267 +  }
268  
269 < SimInfo::~SimInfo(){
269 >  int SimInfo::getFdf() {
270 > #ifdef IS_MPI
271 >    MPI_Allreduce(&fdf_local,&fdf_,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD);
272 > #else
273 >    fdf_ = fdf_local;
274 > #endif
275 >    return fdf_;
276 >  }
277 >    
278 >  void SimInfo::calcNdfRaw() {
279 >    int ndfRaw_local;
280  
281 <  delete myConfiguration;
281 >    MoleculeIterator i;
282 >    vector<StuntDouble*>::iterator j;
283 >    Molecule* mol;
284 >    StuntDouble* integrableObject;
285  
286 <  map<string, GenericData*>::iterator i;
287 <  
288 <  for(i = properties.begin(); i != properties.end(); i++)
289 <    delete (*i).second;
286 >    // Raw degrees of freedom that we have to set
287 >    ndfRaw_local = 0;
288 >    
289 >    for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) {
290 >      for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL;
291 >           integrableObject = mol->nextIntegrableObject(j)) {
292  
293 < }
293 >        ndfRaw_local += 3;
294  
295 < void SimInfo::setBox(double newBox[3]) {
296 <  
297 <  int i, j;
298 <  double tempMat[3][3];
299 <
300 <  for(i=0; i<3; i++)
301 <    for (j=0; j<3; j++) tempMat[i][j] = 0.0;;
302 <
303 <  tempMat[0][0] = newBox[0];
108 <  tempMat[1][1] = newBox[1];
109 <  tempMat[2][2] = newBox[2];
110 <
111 <  setBoxM( tempMat );
112 <
113 < }
114 <
115 < void SimInfo::setBoxM( double theBox[3][3] ){
116 <  
117 <  int i, j;
118 <  double FortranHmat[9]; // to preserve compatibility with Fortran the
119 <                         // ordering in the array is as follows:
120 <                         // [ 0 3 6 ]
121 <                         // [ 1 4 7 ]
122 <                         // [ 2 5 8 ]
123 <  double FortranHmatInv[9]; // the inverted Hmat (for Fortran);
124 <
125 <  if( !boxIsInit ) boxIsInit = 1;
126 <
127 <  for(i=0; i < 3; i++)
128 <    for (j=0; j < 3; j++) Hmat[i][j] = theBox[i][j];
129 <  
130 <  calcBoxL();
131 <  calcHmatInv();
132 <
133 <  for(i=0; i < 3; i++) {
134 <    for (j=0; j < 3; j++) {
135 <      FortranHmat[3*j + i] = Hmat[i][j];
136 <      FortranHmatInv[3*j + i] = HmatInv[i][j];
295 >        if (integrableObject->isDirectional()) {
296 >          if (integrableObject->isLinear()) {
297 >            ndfRaw_local += 2;
298 >          } else {
299 >            ndfRaw_local += 3;
300 >          }
301 >        }
302 >            
303 >      }
304      }
305 +    
306 + #ifdef IS_MPI
307 +    MPI_Allreduce(&ndfRaw_local,&ndfRaw_,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD);
308 + #else
309 +    ndfRaw_ = ndfRaw_local;
310 + #endif
311    }
312  
313 <  setFortranBox(FortranHmat, FortranHmatInv, &orthoRhombic);
314 <
142 < }
143 <
313 >  void SimInfo::calcNdfTrans() {
314 >    int ndfTrans_local;
315  
316 < void SimInfo::getBoxM (double theBox[3][3]) {
316 >    ndfTrans_local = 3 * nIntegrableObjects_ - nConstraints_;
317  
147  int i, j;
148  for(i=0; i<3; i++)
149    for (j=0; j<3; j++) theBox[i][j] = Hmat[i][j];
150 }
318  
319 + #ifdef IS_MPI
320 +    MPI_Allreduce(&ndfTrans_local,&ndfTrans_,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD);
321 + #else
322 +    ndfTrans_ = ndfTrans_local;
323 + #endif
324  
325 < void SimInfo::scaleBox(double scale) {
326 <  double theBox[3][3];
155 <  int i, j;
156 <
157 <  // cerr << "Scaling box by " << scale << "\n";
158 <
159 <  for(i=0; i<3; i++)
160 <    for (j=0; j<3; j++) theBox[i][j] = Hmat[i][j]*scale;
161 <
162 <  setBoxM(theBox);
163 <
164 < }
165 <
166 < void SimInfo::calcHmatInv( void ) {
167 <  
168 <  int oldOrtho;
169 <  int i,j;
170 <  double smallDiag;
171 <  double tol;
172 <  double sanity[3][3];
173 <
174 <  invertMat3( Hmat, HmatInv );
175 <
176 <  // check to see if Hmat is orthorhombic
177 <  
178 <  oldOrtho = orthoRhombic;
179 <
180 <  smallDiag = fabs(Hmat[0][0]);
181 <  if(smallDiag > fabs(Hmat[1][1])) smallDiag = fabs(Hmat[1][1]);
182 <  if(smallDiag > fabs(Hmat[2][2])) smallDiag = fabs(Hmat[2][2]);
183 <  tol = smallDiag * orthoTolerance;
184 <
185 <  orthoRhombic = 1;
186 <  
187 <  for (i = 0; i < 3; i++ ) {
188 <    for (j = 0 ; j < 3; j++) {
189 <      if (i != j) {
190 <        if (orthoRhombic) {
191 <          if ( fabs(Hmat[i][j]) >= tol) orthoRhombic = 0;
192 <        }        
193 <      }
194 <    }
325 >    ndfTrans_ = ndfTrans_ - 3 - nZconstraint_;
326 >
327    }
328  
329 <  if( oldOrtho != orthoRhombic ){
329 >  void SimInfo::addInteractionPairs(Molecule* mol) {
330 >    ForceFieldOptions& options_ = forceField_->getForceFieldOptions();
331 >    vector<Bond*>::iterator bondIter;
332 >    vector<Bend*>::iterator bendIter;
333 >    vector<Torsion*>::iterator torsionIter;
334 >    vector<Inversion*>::iterator inversionIter;
335 >    Bond* bond;
336 >    Bend* bend;
337 >    Torsion* torsion;
338 >    Inversion* inversion;
339 >    int a;
340 >    int b;
341 >    int c;
342 >    int d;
343 >
344 >    // atomGroups can be used to add special interaction maps between
345 >    // groups of atoms that are in two separate rigid bodies.
346 >    // However, most site-site interactions between two rigid bodies
347 >    // are probably not special, just the ones between the physically
348 >    // bonded atoms.  Interactions *within* a single rigid body should
349 >    // always be excluded.  These are done at the bottom of this
350 >    // function.
351 >
352 >    map<int, set<int> > atomGroups;
353 >    Molecule::RigidBodyIterator rbIter;
354 >    RigidBody* rb;
355 >    Molecule::IntegrableObjectIterator ii;
356 >    StuntDouble* integrableObject;
357      
358 <    if( orthoRhombic ) {
359 <      sprintf( painCave.errMsg,
360 <               "OOPSE is switching from the default Non-Orthorhombic\n"
361 <               "\tto the faster Orthorhombic periodic boundary computations.\n"
362 <               "\tThis is usually a good thing, but if you wan't the\n"
363 <               "\tNon-Orthorhombic computations, make the orthoBoxTolerance\n"
364 <               "\tvariable ( currently set to %G ) smaller.\n",
365 <               orthoTolerance);
366 <      painCave.severity = OOPSE_INFO;
367 <      simError();
358 >    for (integrableObject = mol->beginIntegrableObject(ii);
359 >         integrableObject != NULL;
360 >         integrableObject = mol->nextIntegrableObject(ii)) {
361 >      
362 >      if (integrableObject->isRigidBody()) {
363 >        rb = static_cast<RigidBody*>(integrableObject);
364 >        vector<Atom*> atoms = rb->getAtoms();
365 >        set<int> rigidAtoms;
366 >        for (int i = 0; i < static_cast<int>(atoms.size()); ++i) {
367 >          rigidAtoms.insert(atoms[i]->getGlobalIndex());
368 >        }
369 >        for (int i = 0; i < static_cast<int>(atoms.size()); ++i) {
370 >          atomGroups.insert(map<int, set<int> >::value_type(atoms[i]->getGlobalIndex(), rigidAtoms));
371 >        }      
372 >      } else {
373 >        set<int> oneAtomSet;
374 >        oneAtomSet.insert(integrableObject->getGlobalIndex());
375 >        atomGroups.insert(map<int, set<int> >::value_type(integrableObject->getGlobalIndex(), oneAtomSet));        
376 >      }
377 >    }  
378 >          
379 >    for (bond= mol->beginBond(bondIter); bond != NULL;
380 >         bond = mol->nextBond(bondIter)) {
381 >
382 >      a = bond->getAtomA()->getGlobalIndex();
383 >      b = bond->getAtomB()->getGlobalIndex();  
384 >    
385 >      if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) {
386 >        oneTwoInteractions_.addPair(a, b);
387 >      } else {
388 >        excludedInteractions_.addPair(a, b);
389 >      }
390      }
210    else {
211      sprintf( painCave.errMsg,
212               "OOPSE is switching from the faster Orthorhombic to the more\n"
213               "\tflexible Non-Orthorhombic periodic boundary computations.\n"
214               "\tThis is usually because the box has deformed under\n"
215               "\tNPTf integration. If you wan't to live on the edge with\n"
216               "\tthe Orthorhombic computations, make the orthoBoxTolerance\n"
217               "\tvariable ( currently set to %G ) larger.\n",
218               orthoTolerance);
219      painCave.severity = OOPSE_WARNING;
220      simError();
221    }
222  }
223 }
391  
392 < void SimInfo::calcBoxL( void ){
392 >    for (bend= mol->beginBend(bendIter); bend != NULL;
393 >         bend = mol->nextBend(bendIter)) {
394  
395 <  double dx, dy, dz, dsq;
395 >      a = bend->getAtomA()->getGlobalIndex();
396 >      b = bend->getAtomB()->getGlobalIndex();        
397 >      c = bend->getAtomC()->getGlobalIndex();
398 >      
399 >      if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) {
400 >        oneTwoInteractions_.addPair(a, b);      
401 >        oneTwoInteractions_.addPair(b, c);
402 >      } else {
403 >        excludedInteractions_.addPair(a, b);
404 >        excludedInteractions_.addPair(b, c);
405 >      }
406  
407 <  // boxVol = Determinant of Hmat
407 >      if (options_.havevdw13scale() || options_.haveelectrostatic13scale()) {
408 >        oneThreeInteractions_.addPair(a, c);      
409 >      } else {
410 >        excludedInteractions_.addPair(a, c);
411 >      }
412 >    }
413  
414 <  boxVol = matDet3( Hmat );
414 >    for (torsion= mol->beginTorsion(torsionIter); torsion != NULL;
415 >         torsion = mol->nextTorsion(torsionIter)) {
416  
417 <  // boxLx
418 <  
419 <  dx = Hmat[0][0]; dy = Hmat[1][0]; dz = Hmat[2][0];
420 <  dsq = dx*dx + dy*dy + dz*dz;
237 <  boxL[0] = sqrt( dsq );
238 <  //maxCutoff = 0.5 * boxL[0];
417 >      a = torsion->getAtomA()->getGlobalIndex();
418 >      b = torsion->getAtomB()->getGlobalIndex();        
419 >      c = torsion->getAtomC()->getGlobalIndex();        
420 >      d = torsion->getAtomD()->getGlobalIndex();      
421  
422 <  // boxLy
423 <  
424 <  dx = Hmat[0][1]; dy = Hmat[1][1]; dz = Hmat[2][1];
425 <  dsq = dx*dx + dy*dy + dz*dz;
426 <  boxL[1] = sqrt( dsq );
427 <  //if( (0.5 * boxL[1]) < maxCutoff ) maxCutoff = 0.5 * boxL[1];
422 >      if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) {
423 >        oneTwoInteractions_.addPair(a, b);      
424 >        oneTwoInteractions_.addPair(b, c);
425 >        oneTwoInteractions_.addPair(c, d);
426 >      } else {
427 >        excludedInteractions_.addPair(a, b);
428 >        excludedInteractions_.addPair(b, c);
429 >        excludedInteractions_.addPair(c, d);
430 >      }
431  
432 +      if (options_.havevdw13scale() || options_.haveelectrostatic13scale()) {
433 +        oneThreeInteractions_.addPair(a, c);      
434 +        oneThreeInteractions_.addPair(b, d);      
435 +      } else {
436 +        excludedInteractions_.addPair(a, c);
437 +        excludedInteractions_.addPair(b, d);
438 +      }
439  
440 <  // boxLz
441 <  
442 <  dx = Hmat[0][2]; dy = Hmat[1][2]; dz = Hmat[2][2];
443 <  dsq = dx*dx + dy*dy + dz*dz;
444 <  boxL[2] = sqrt( dsq );
445 <  //if( (0.5 * boxL[2]) < maxCutoff ) maxCutoff = 0.5 * boxL[2];
440 >      if (options_.havevdw14scale() || options_.haveelectrostatic14scale()) {
441 >        oneFourInteractions_.addPair(a, d);      
442 >      } else {
443 >        excludedInteractions_.addPair(a, d);
444 >      }
445 >    }
446  
447 <  //calculate the max cutoff
448 <  maxCutoff =  calcMaxCutOff();
257 <  
258 <  checkCutOffs();
447 >    for (inversion= mol->beginInversion(inversionIter); inversion != NULL;
448 >         inversion = mol->nextInversion(inversionIter)) {
449  
450 < }
450 >      a = inversion->getAtomA()->getGlobalIndex();
451 >      b = inversion->getAtomB()->getGlobalIndex();        
452 >      c = inversion->getAtomC()->getGlobalIndex();        
453 >      d = inversion->getAtomD()->getGlobalIndex();        
454  
455 +      if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) {
456 +        oneTwoInteractions_.addPair(a, b);      
457 +        oneTwoInteractions_.addPair(a, c);
458 +        oneTwoInteractions_.addPair(a, d);
459 +      } else {
460 +        excludedInteractions_.addPair(a, b);
461 +        excludedInteractions_.addPair(a, c);
462 +        excludedInteractions_.addPair(a, d);
463 +      }
464  
465 < double SimInfo::calcMaxCutOff(){
465 >      if (options_.havevdw13scale() || options_.haveelectrostatic13scale()) {
466 >        oneThreeInteractions_.addPair(b, c);    
467 >        oneThreeInteractions_.addPair(b, d);    
468 >        oneThreeInteractions_.addPair(c, d);      
469 >      } else {
470 >        excludedInteractions_.addPair(b, c);
471 >        excludedInteractions_.addPair(b, d);
472 >        excludedInteractions_.addPair(c, d);
473 >      }
474 >    }
475  
476 <  double ri[3], rj[3], rk[3];
477 <  double rij[3], rjk[3], rki[3];
478 <  double minDist;
476 >    for (rb = mol->beginRigidBody(rbIter); rb != NULL;
477 >         rb = mol->nextRigidBody(rbIter)) {
478 >      vector<Atom*> atoms = rb->getAtoms();
479 >      for (int i = 0; i < static_cast<int>(atoms.size()) -1 ; ++i) {
480 >        for (int j = i + 1; j < static_cast<int>(atoms.size()); ++j) {
481 >          a = atoms[i]->getGlobalIndex();
482 >          b = atoms[j]->getGlobalIndex();
483 >          excludedInteractions_.addPair(a, b);
484 >        }
485 >      }
486 >    }        
487  
488 <  ri[0] = Hmat[0][0];
270 <  ri[1] = Hmat[1][0];
271 <  ri[2] = Hmat[2][0];
488 >  }
489  
490 <  rj[0] = Hmat[0][1];
491 <  rj[1] = Hmat[1][1];
492 <  rj[2] = Hmat[2][1];
490 >  void SimInfo::removeInteractionPairs(Molecule* mol) {
491 >    ForceFieldOptions& options_ = forceField_->getForceFieldOptions();
492 >    vector<Bond*>::iterator bondIter;
493 >    vector<Bend*>::iterator bendIter;
494 >    vector<Torsion*>::iterator torsionIter;
495 >    vector<Inversion*>::iterator inversionIter;
496 >    Bond* bond;
497 >    Bend* bend;
498 >    Torsion* torsion;
499 >    Inversion* inversion;
500 >    int a;
501 >    int b;
502 >    int c;
503 >    int d;
504  
505 <  rk[0] = Hmat[0][2];
506 <  rk[1] = Hmat[1][2];
507 <  rk[2] = Hmat[2][2];
505 >    map<int, set<int> > atomGroups;
506 >    Molecule::RigidBodyIterator rbIter;
507 >    RigidBody* rb;
508 >    Molecule::IntegrableObjectIterator ii;
509 >    StuntDouble* integrableObject;
510      
511 <  crossProduct3(ri, rj, rij);
512 <  distXY = dotProduct3(rk,rij) / norm3(rij);
511 >    for (integrableObject = mol->beginIntegrableObject(ii);
512 >         integrableObject != NULL;
513 >         integrableObject = mol->nextIntegrableObject(ii)) {
514 >      
515 >      if (integrableObject->isRigidBody()) {
516 >        rb = static_cast<RigidBody*>(integrableObject);
517 >        vector<Atom*> atoms = rb->getAtoms();
518 >        set<int> rigidAtoms;
519 >        for (int i = 0; i < static_cast<int>(atoms.size()); ++i) {
520 >          rigidAtoms.insert(atoms[i]->getGlobalIndex());
521 >        }
522 >        for (int i = 0; i < static_cast<int>(atoms.size()); ++i) {
523 >          atomGroups.insert(map<int, set<int> >::value_type(atoms[i]->getGlobalIndex(), rigidAtoms));
524 >        }      
525 >      } else {
526 >        set<int> oneAtomSet;
527 >        oneAtomSet.insert(integrableObject->getGlobalIndex());
528 >        atomGroups.insert(map<int, set<int> >::value_type(integrableObject->getGlobalIndex(), oneAtomSet));        
529 >      }
530 >    }  
531  
532 <  crossProduct3(rj,rk, rjk);
533 <  distYZ = dotProduct3(ri,rjk) / norm3(rjk);
532 >    for (bond= mol->beginBond(bondIter); bond != NULL;
533 >         bond = mol->nextBond(bondIter)) {
534 >      
535 >      a = bond->getAtomA()->getGlobalIndex();
536 >      b = bond->getAtomB()->getGlobalIndex();  
537 >    
538 >      if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) {
539 >        oneTwoInteractions_.removePair(a, b);
540 >      } else {
541 >        excludedInteractions_.removePair(a, b);
542 >      }
543 >    }
544  
545 <  crossProduct3(rk,ri, rki);
546 <  distZX = dotProduct3(rj,rki) / norm3(rki);
545 >    for (bend= mol->beginBend(bendIter); bend != NULL;
546 >         bend = mol->nextBend(bendIter)) {
547  
548 <  minDist = min(min(distXY, distYZ), distZX);
549 <  return minDist/2;
550 <  
551 < }
548 >      a = bend->getAtomA()->getGlobalIndex();
549 >      b = bend->getAtomB()->getGlobalIndex();        
550 >      c = bend->getAtomC()->getGlobalIndex();
551 >      
552 >      if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) {
553 >        oneTwoInteractions_.removePair(a, b);      
554 >        oneTwoInteractions_.removePair(b, c);
555 >      } else {
556 >        excludedInteractions_.removePair(a, b);
557 >        excludedInteractions_.removePair(b, c);
558 >      }
559  
560 < void SimInfo::wrapVector( double thePos[3] ){
560 >      if (options_.havevdw13scale() || options_.haveelectrostatic13scale()) {
561 >        oneThreeInteractions_.removePair(a, c);      
562 >      } else {
563 >        excludedInteractions_.removePair(a, c);
564 >      }
565 >    }
566  
567 <  int i;
568 <  double scaled[3];
567 >    for (torsion= mol->beginTorsion(torsionIter); torsion != NULL;
568 >         torsion = mol->nextTorsion(torsionIter)) {
569  
570 <  if( !orthoRhombic ){
571 <    // calc the scaled coordinates.
570 >      a = torsion->getAtomA()->getGlobalIndex();
571 >      b = torsion->getAtomB()->getGlobalIndex();        
572 >      c = torsion->getAtomC()->getGlobalIndex();        
573 >      d = torsion->getAtomD()->getGlobalIndex();      
574    
575 +      if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) {
576 +        oneTwoInteractions_.removePair(a, b);      
577 +        oneTwoInteractions_.removePair(b, c);
578 +        oneTwoInteractions_.removePair(c, d);
579 +      } else {
580 +        excludedInteractions_.removePair(a, b);
581 +        excludedInteractions_.removePair(b, c);
582 +        excludedInteractions_.removePair(c, d);
583 +      }
584  
585 <    matVecMul3(HmatInv, thePos, scaled);
586 <    
587 <    for(i=0; i<3; i++)
588 <      scaled[i] -= roundMe(scaled[i]);
589 <    
590 <    // calc the wrapped real coordinates from the wrapped scaled coordinates
591 <    
311 <    matVecMul3(Hmat, scaled, thePos);
585 >      if (options_.havevdw13scale() || options_.haveelectrostatic13scale()) {
586 >        oneThreeInteractions_.removePair(a, c);      
587 >        oneThreeInteractions_.removePair(b, d);      
588 >      } else {
589 >        excludedInteractions_.removePair(a, c);
590 >        excludedInteractions_.removePair(b, d);
591 >      }
592  
593 <  }
594 <  else{
595 <    // calc the scaled coordinates.
593 >      if (options_.havevdw14scale() || options_.haveelectrostatic14scale()) {
594 >        oneFourInteractions_.removePair(a, d);      
595 >      } else {
596 >        excludedInteractions_.removePair(a, d);
597 >      }
598 >    }
599 >
600 >    for (inversion= mol->beginInversion(inversionIter); inversion != NULL;
601 >         inversion = mol->nextInversion(inversionIter)) {
602 >
603 >      a = inversion->getAtomA()->getGlobalIndex();
604 >      b = inversion->getAtomB()->getGlobalIndex();        
605 >      c = inversion->getAtomC()->getGlobalIndex();        
606 >      d = inversion->getAtomD()->getGlobalIndex();        
607 >
608 >      if (options_.havevdw12scale() || options_.haveelectrostatic12scale()) {
609 >        oneTwoInteractions_.removePair(a, b);      
610 >        oneTwoInteractions_.removePair(a, c);
611 >        oneTwoInteractions_.removePair(a, d);
612 >      } else {
613 >        excludedInteractions_.removePair(a, b);
614 >        excludedInteractions_.removePair(a, c);
615 >        excludedInteractions_.removePair(a, d);
616 >      }
617 >
618 >      if (options_.havevdw13scale() || options_.haveelectrostatic13scale()) {
619 >        oneThreeInteractions_.removePair(b, c);    
620 >        oneThreeInteractions_.removePair(b, d);    
621 >        oneThreeInteractions_.removePair(c, d);      
622 >      } else {
623 >        excludedInteractions_.removePair(b, c);
624 >        excludedInteractions_.removePair(b, d);
625 >        excludedInteractions_.removePair(c, d);
626 >      }
627 >    }
628 >
629 >    for (rb = mol->beginRigidBody(rbIter); rb != NULL;
630 >         rb = mol->nextRigidBody(rbIter)) {
631 >      vector<Atom*> atoms = rb->getAtoms();
632 >      for (int i = 0; i < static_cast<int>(atoms.size()) -1 ; ++i) {
633 >        for (int j = i + 1; j < static_cast<int>(atoms.size()); ++j) {
634 >          a = atoms[i]->getGlobalIndex();
635 >          b = atoms[j]->getGlobalIndex();
636 >          excludedInteractions_.removePair(a, b);
637 >        }
638 >      }
639 >    }        
640      
317    for(i=0; i<3; i++)
318      scaled[i] = thePos[i]*HmatInv[i][i];
319    
320    // wrap the scaled coordinates
321    
322    for(i=0; i<3; i++)
323      scaled[i] -= roundMe(scaled[i]);
324    
325    // calc the wrapped real coordinates from the wrapped scaled coordinates
326    
327    for(i=0; i<3; i++)
328      thePos[i] = scaled[i]*Hmat[i][i];
641    }
642 +  
643 +  
644 +  void SimInfo::addMoleculeStamp(MoleculeStamp* molStamp, int nmol) {
645 +    int curStampId;
646      
647 < }
647 >    //index from 0
648 >    curStampId = moleculeStamps_.size();
649  
650 +    moleculeStamps_.push_back(molStamp);
651 +    molStampIds_.insert(molStampIds_.end(), nmol, curStampId);
652 +  }
653  
334 int SimInfo::getNDF(){
335  int ndf_local;
654  
655 <  ndf_local = 0;
656 <  
657 <  for(int i = 0; i < integrableObjects.size(); i++){
658 <    ndf_local += 3;
659 <    if (integrableObjects[i]->isDirectional()) {
660 <      if (integrableObjects[i]->isLinear())
661 <        ndf_local += 2;
662 <      else
663 <        ndf_local += 3;
664 <    }
655 >  /**
656 >   * update
657 >   *
658 >   *  Performs the global checks and variable settings after the
659 >   *  objects have been created.
660 >   *
661 >   */
662 >  void SimInfo::update() {  
663 >    setupSimVariables();
664 >    calcNdf();
665 >    calcNdfRaw();
666 >    calcNdfTrans();
667    }
668 +  
669 +  /**
670 +   * getSimulatedAtomTypes
671 +   *
672 +   * Returns an STL set of AtomType* that are actually present in this
673 +   * simulation.  Must query all processors to assemble this information.
674 +   *
675 +   */
676 +  set<AtomType*> SimInfo::getSimulatedAtomTypes() {
677 +    SimInfo::MoleculeIterator mi;
678 +    Molecule* mol;
679 +    Molecule::AtomIterator ai;
680 +    Atom* atom;
681 +    set<AtomType*> atomTypes;
682 +    
683 +    for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) {      
684 +      for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) {
685 +        atomTypes.insert(atom->getAtomType());
686 +      }      
687 +    }    
688  
689 <  // n_constraints is local, so subtract them on each processor:
689 > #ifdef IS_MPI
690  
691 <  ndf_local -= n_constraints;
691 >    // loop over the found atom types on this processor, and add their
692 >    // numerical idents to a vector:
693  
694 < #ifdef IS_MPI
695 <  MPI_Allreduce(&ndf_local,&ndf,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD);
696 < #else
697 <  ndf = ndf_local;
357 < #endif
694 >    vector<int> foundTypes;
695 >    set<AtomType*>::iterator i;
696 >    for (i = atomTypes.begin(); i != atomTypes.end(); ++i)
697 >      foundTypes.push_back( (*i)->getIdent() );
698  
699 <  // nZconstraints is global, as are the 3 COM translations for the
700 <  // entire system:
699 >    // count_local holds the number of found types on this processor
700 >    int count_local = foundTypes.size();
701  
702 <  ndf = ndf - 3 - nZconstraints;
702 >    // count holds the total number of found types on all processors
703 >    // (some will be redundant with the ones found locally):
704 >    int count;
705 >    MPI::COMM_WORLD.Allreduce(&count_local, &count, 1, MPI::INT, MPI::SUM);
706  
707 <  return ndf;
708 < }
707 >    // create a vector to hold the globally found types, and resize it:
708 >    vector<int> ftGlobal;
709 >    ftGlobal.resize(count);
710 >    vector<int> counts;
711  
712 < int SimInfo::getNDFraw() {
713 <  int ndfRaw_local;
712 >    int nproc = MPI::COMM_WORLD.Get_size();
713 >    counts.resize(nproc);
714 >    vector<int> disps;
715 >    disps.resize(nproc);
716  
717 <  // Raw degrees of freedom that we have to set
718 <  ndfRaw_local = 0;
717 >    // now spray out the foundTypes to all the other processors:
718 >    
719 >    MPI::COMM_WORLD.Allgatherv(&foundTypes[0], count_local, MPI::INT,
720 >                               &ftGlobal[0], &counts[0], &disps[0], MPI::INT);
721  
722 <  for(int i = 0; i < integrableObjects.size(); i++){
723 <    ndfRaw_local += 3;
724 <    if (integrableObjects[i]->isDirectional()) {
725 <       if (integrableObjects[i]->isLinear())
726 <        ndfRaw_local += 2;
727 <      else
379 <        ndfRaw_local += 3;
380 <    }
381 <  }
722 >    // foundIdents is a stl set, so inserting an already found ident
723 >    // will have no effect.
724 >    set<int> foundIdents;
725 >    vector<int>::iterator j;
726 >    for (j = ftGlobal.begin(); j != ftGlobal.end(); ++j)
727 >      foundIdents.insert((*j));
728      
729 < #ifdef IS_MPI
730 <  MPI_Allreduce(&ndfRaw_local,&ndfRaw,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD);
731 < #else
732 <  ndfRaw = ndfRaw_local;
729 >    // now iterate over the foundIdents and get the actual atom types
730 >    // that correspond to these:
731 >    set<int>::iterator it;
732 >    for (it = foundIdents.begin(); it != foundIdents.end(); ++it)
733 >      atomTypes.insert( forceField_->getAtomType((*it)) );
734 >
735   #endif
736 +    
737 +    return atomTypes;        
738 +  }
739  
740 <  return ndfRaw;
741 < }
740 >  void SimInfo::setupSimVariables() {
741 >    useAtomicVirial_ = simParams_->getUseAtomicVirial();
742 >    // we only call setAccumulateBoxDipole if the accumulateBoxDipole parameter is true
743 >    calcBoxDipole_ = false;
744 >    if ( simParams_->haveAccumulateBoxDipole() )
745 >      if ( simParams_->getAccumulateBoxDipole() ) {
746 >        calcBoxDipole_ = true;      
747 >      }
748  
749 < int SimInfo::getNDFtranslational() {
750 <  int ndfTrans_local;
749 >    set<AtomType*>::iterator i;
750 >    set<AtomType*> atomTypes;
751 >    atomTypes = getSimulatedAtomTypes();    
752 >    int usesElectrostatic = 0;
753 >    int usesMetallic = 0;
754 >    int usesDirectional = 0;
755 >    //loop over all of the atom types
756 >    for (i = atomTypes.begin(); i != atomTypes.end(); ++i) {
757 >      usesElectrostatic |= (*i)->isElectrostatic();
758 >      usesMetallic |= (*i)->isMetal();
759 >      usesDirectional |= (*i)->isDirectional();
760 >    }
761  
762 <  ndfTrans_local = 3 * integrableObjects.size() - n_constraints;
762 > #ifdef IS_MPI    
763 >    int temp;
764 >    temp = usesDirectional;
765 >    MPI_Allreduce(&temp, &usesDirectionalAtoms_, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);    
766  
767 +    temp = usesMetallic;
768 +    MPI_Allreduce(&temp, &usesMetallicAtoms_, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);    
769  
770 < #ifdef IS_MPI
771 <  MPI_Allreduce(&ndfTrans_local,&ndfTrans,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD);
400 < #else
401 <  ndfTrans = ndfTrans_local;
770 >    temp = usesElectrostatic;
771 >    MPI_Allreduce(&temp, &usesElectrostaticAtoms_, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);
772   #endif
773 +    fInfo_.SIM_uses_PBC = usesPeriodicBoundaries_;    
774 +    fInfo_.SIM_uses_DirectionalAtoms = usesDirectionalAtoms_;
775 +    fInfo_.SIM_uses_MetallicAtoms = usesMetallicAtoms_;
776 +    fInfo_.SIM_requires_SkipCorrection = usesElectrostaticAtoms_;
777 +    fInfo_.SIM_requires_SelfCorrection = usesElectrostaticAtoms_;
778 +    fInfo_.SIM_uses_AtomicVirial = usesAtomicVirial_;
779 +  }
780  
781 <  ndfTrans = ndfTrans - 3 - nZconstraints;
781 >  void SimInfo::setupFortran() {
782 >    int isError;
783 >    int nExclude, nOneTwo, nOneThree, nOneFour;
784 >    vector<int> fortranGlobalGroupMembership;
785 >    
786 >    isError = 0;
787  
788 <  return ndfTrans;
789 < }
788 >    //globalGroupMembership_ is filled by SimCreator    
789 >    for (int i = 0; i < nGlobalAtoms_; i++) {
790 >      fortranGlobalGroupMembership.push_back(globalGroupMembership_[i] + 1);
791 >    }
792  
793 < int SimInfo::getTotIntegrableObjects() {
794 <  int nObjs_local;
795 <  int nObjs;
793 >    //calculate mass ratio of cutoff group
794 >    vector<RealType> mfact;
795 >    SimInfo::MoleculeIterator mi;
796 >    Molecule* mol;
797 >    Molecule::CutoffGroupIterator ci;
798 >    CutoffGroup* cg;
799 >    Molecule::AtomIterator ai;
800 >    Atom* atom;
801 >    RealType totalMass;
802  
803 <  nObjs_local =  integrableObjects.size();
803 >    //to avoid memory reallocation, reserve enough space for mfact
804 >    mfact.reserve(getNCutoffGroups());
805 >    
806 >    for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) {        
807 >      for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) {
808  
809 +        totalMass = cg->getMass();
810 +        for(atom = cg->beginAtom(ai); atom != NULL; atom = cg->nextAtom(ai)) {
811 +          // Check for massless groups - set mfact to 1 if true
812 +          if (totalMass != 0)
813 +            mfact.push_back(atom->getMass()/totalMass);
814 +          else
815 +            mfact.push_back( 1.0 );
816 +        }
817 +      }      
818 +    }
819  
820 < #ifdef IS_MPI
821 <  MPI_Allreduce(&nObjs_local,&nObjs,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD);
822 < #else
419 <  nObjs = nObjs_local;
420 < #endif
820 >    //fill ident array of local atoms (it is actually ident of
821 >    //AtomType, it is so confusing !!!)
822 >    vector<int> identArray;
823  
824 +    //to avoid memory reallocation, reserve enough space identArray
825 +    identArray.reserve(getNAtoms());
826 +    
827 +    for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) {        
828 +      for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) {
829 +        identArray.push_back(atom->getIdent());
830 +      }
831 +    }    
832  
833 <  return nObjs;
834 < }
833 >    //fill molMembershipArray
834 >    //molMembershipArray is filled by SimCreator    
835 >    vector<int> molMembershipArray(nGlobalAtoms_);
836 >    for (int i = 0; i < nGlobalAtoms_; i++) {
837 >      molMembershipArray[i] = globalMolMembership_[i] + 1;
838 >    }
839 >    
840 >    //setup fortran simulation
841  
842 < void SimInfo::refreshSim(){
842 >    nExclude = excludedInteractions_.getSize();
843 >    nOneTwo = oneTwoInteractions_.getSize();
844 >    nOneThree = oneThreeInteractions_.getSize();
845 >    nOneFour = oneFourInteractions_.getSize();
846  
847 <  simtype fInfo;
848 <  int isError;
849 <  int n_global;
850 <  int* excl;
847 >    int* excludeList = excludedInteractions_.getPairList();
848 >    int* oneTwoList = oneTwoInteractions_.getPairList();
849 >    int* oneThreeList = oneThreeInteractions_.getPairList();
850 >    int* oneFourList = oneFourInteractions_.getPairList();
851  
852 <  fInfo.dielect = 0.0;
852 >    setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray[0],
853 >                   &nExclude, excludeList,
854 >                   &nOneTwo, oneTwoList,
855 >                   &nOneThree, oneThreeList,
856 >                   &nOneFour, oneFourList,
857 >                   &molMembershipArray[0], &mfact[0], &nCutoffGroups_,
858 >                   &fortranGlobalGroupMembership[0], &isError);
859 >    
860 >    if( isError ){
861 >      
862 >      sprintf( painCave.errMsg,
863 >               "There was an error setting the simulation information in fortran.\n" );
864 >      painCave.isFatal = 1;
865 >      painCave.severity = OPENMD_ERROR;
866 >      simError();
867 >    }
868 >    
869 >    
870 >    sprintf( checkPointMsg,
871 >             "succesfully sent the simulation information to fortran.\n");
872 >    
873 >    errorCheckPoint();
874 >    
875 >    // Setup number of neighbors in neighbor list if present
876 >    if (simParams_->haveNeighborListNeighbors()) {
877 >      int nlistNeighbors = simParams_->getNeighborListNeighbors();
878 >      setNeighbors(&nlistNeighbors);
879 >    }
880 >  
881 > #ifdef IS_MPI    
882 >    //SimInfo is responsible for creating localToGlobalAtomIndex and
883 >    //localToGlobalGroupIndex
884 >    vector<int> localToGlobalAtomIndex(getNAtoms(), 0);
885 >    vector<int> localToGlobalCutoffGroupIndex;
886 >    mpiSimData parallelData;
887  
888 <  if( useDipoles ){
436 <    if( useReactionField )fInfo.dielect = dielectric;
437 <  }
888 >    for (mol = beginMolecule(mi); mol != NULL; mol  = nextMolecule(mi)) {
889  
890 <  fInfo.SIM_uses_PBC = usePBC;
890 >      //local index(index in DataStorge) of atom is important
891 >      for (atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) {
892 >        localToGlobalAtomIndex[atom->getLocalIndex()] = atom->getGlobalIndex() + 1;
893 >      }
894  
895 <  if (useSticky || useDipoles || useGayBerne || useShapes) {
896 <    useDirectionalAtoms = 1;
897 <    fInfo.SIM_uses_DirectionalAtoms = useDirectionalAtoms;
898 <  }
895 >      //local index of cutoff group is trivial, it only depends on the order of travesing
896 >      for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) {
897 >        localToGlobalCutoffGroupIndex.push_back(cg->getGlobalIndex() + 1);
898 >      }        
899 >        
900 >    }
901  
902 <  fInfo.SIM_uses_LennardJones = useLennardJones;
902 >    //fill up mpiSimData struct
903 >    parallelData.nMolGlobal = getNGlobalMolecules();
904 >    parallelData.nMolLocal = getNMolecules();
905 >    parallelData.nAtomsGlobal = getNGlobalAtoms();
906 >    parallelData.nAtomsLocal = getNAtoms();
907 >    parallelData.nGroupsGlobal = getNGlobalCutoffGroups();
908 >    parallelData.nGroupsLocal = getNCutoffGroups();
909 >    parallelData.myNode = worldRank;
910 >    MPI_Comm_size(MPI_COMM_WORLD, &(parallelData.nProcessors));
911  
912 <  if (useCharges || useDipoles) {
913 <    useElectrostatics = 1;
914 <    fInfo.SIM_uses_Electrostatics = useElectrostatics;
915 <  }
912 >    //pass mpiSimData struct and index arrays to fortran
913 >    setFsimParallel(&parallelData, &(parallelData.nAtomsLocal),
914 >                    &localToGlobalAtomIndex[0],  &(parallelData.nGroupsLocal),
915 >                    &localToGlobalCutoffGroupIndex[0], &isError);
916  
917 <  fInfo.SIM_uses_Charges = useCharges;
918 <  fInfo.SIM_uses_Dipoles = useDipoles;
919 <  fInfo.SIM_uses_Sticky = useSticky;
920 <  fInfo.SIM_uses_GayBerne = useGayBerne;
921 <  fInfo.SIM_uses_EAM = useEAM;
922 <  fInfo.SIM_uses_Shapes = useShapes;
459 <  fInfo.SIM_uses_FLARB = useFLARB;
460 <  fInfo.SIM_uses_RF = useReactionField;
917 >    if (isError) {
918 >      sprintf(painCave.errMsg,
919 >              "mpiRefresh errror: fortran didn't like something we gave it.\n");
920 >      painCave.isFatal = 1;
921 >      simError();
922 >    }
923  
924 <  n_exclude = excludes->getSize();
925 <  excl = excludes->getFortranArray();
464 <  
465 < #ifdef IS_MPI
466 <  n_global = mpiSim->getNAtomsGlobal();
467 < #else
468 <  n_global = n_atoms;
924 >    sprintf(checkPointMsg, " mpiRefresh successful.\n");
925 >    errorCheckPoint();
926   #endif
927 <  
928 <  isError = 0;
472 <  
473 <  getFortranGroupArrays(this, FglobalGroupMembership, mfact);
474 <  //it may not be a good idea to pass the address of first element in vector
475 <  //since c++ standard does not require vector to be stored continuously in meomory
476 <  //Most of the compilers will organize the memory of vector continuously
477 <  setFortranSim( &fInfo, &n_global, &n_atoms, identArray, &n_exclude, excl,
478 <                  &nGlobalExcludes, globalExcludes, molMembershipArray,
479 <                  &mfact[0], &ngroup, &FglobalGroupMembership[0], &isError);
927 >    fortranInitialized_ = true;
928 >  }
929  
930 <  if( isError ){
931 <    
483 <    sprintf( painCave.errMsg,
484 <             "There was an error setting the simulation information in fortran.\n" );
485 <    painCave.isFatal = 1;
486 <    painCave.severity = OOPSE_ERROR;
487 <    simError();
930 >  void SimInfo::addProperty(GenericData* genData) {
931 >    properties_.addProperty(genData);  
932    }
489  
490 #ifdef IS_MPI
491  sprintf( checkPointMsg,
492           "succesfully sent the simulation information to fortran.\n");
493  MPIcheckPoint();
494 #endif // is_mpi
495  
496  this->ndf = this->getNDF();
497  this->ndfRaw = this->getNDFraw();
498  this->ndfTrans = this->getNDFtranslational();
499 }
933  
934 < void SimInfo::setDefaultRcut( double theRcut ){
935 <  
936 <  haveRcut = 1;
504 <  rCut = theRcut;
505 <  rList = rCut + 1.0;
506 <  
507 <  notifyFortranCutoffs( &rCut, &rSw, &rList );
508 < }
934 >  void SimInfo::removeProperty(const string& propName) {
935 >    properties_.removeProperty(propName);  
936 >  }
937  
938 < void SimInfo::setDefaultRcut( double theRcut, double theRsw ){
938 >  void SimInfo::clearProperties() {
939 >    properties_.clearProperties();
940 >  }
941  
942 <  rSw = theRsw;
943 <  setDefaultRcut( theRcut );
944 < }
942 >  vector<string> SimInfo::getPropertyNames() {
943 >    return properties_.getPropertyNames();  
944 >  }
945 >      
946 >  vector<GenericData*> SimInfo::getProperties() {
947 >    return properties_.getProperties();
948 >  }
949  
950 +  GenericData* SimInfo::getPropertyByName(const string& propName) {
951 +    return properties_.getPropertyByName(propName);
952 +  }
953  
954 < void SimInfo::checkCutOffs( void ){
955 <  
956 <  if( boxIsInit ){
957 <    
958 <    //we need to check cutOffs against the box
959 <    
960 <    if( rCut > maxCutoff ){
961 <      sprintf( painCave.errMsg,
962 <               "cutoffRadius is too large for the current periodic box.\n"
963 <               "\tCurrent Value of cutoffRadius = %G at time %G\n "
964 <               "\tThis is larger than half of at least one of the\n"
965 <               "\tperiodic box vectors.  Right now, the Box matrix is:\n"
966 <               "\n"
967 <               "\t[ %G %G %G ]\n"
968 <               "\t[ %G %G %G ]\n"
969 <               "\t[ %G %G %G ]\n",
970 <               rCut, currentTime,
971 <               Hmat[0][0], Hmat[0][1], Hmat[0][2],
972 <               Hmat[1][0], Hmat[1][1], Hmat[1][2],
973 <               Hmat[2][0], Hmat[2][1], Hmat[2][2]);
974 <      painCave.severity = OOPSE_ERROR;
975 <      painCave.isFatal = 1;
976 <      simError();
954 >  void SimInfo::setSnapshotManager(SnapshotManager* sman) {
955 >    if (sman_ == sman) {
956 >      return;
957 >    }    
958 >    delete sman_;
959 >    sman_ = sman;
960 >
961 >    Molecule* mol;
962 >    RigidBody* rb;
963 >    Atom* atom;
964 >    SimInfo::MoleculeIterator mi;
965 >    Molecule::RigidBodyIterator rbIter;
966 >    Molecule::AtomIterator atomIter;;
967 >
968 >    for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) {
969 >        
970 >      for (atom = mol->beginAtom(atomIter); atom != NULL; atom = mol->nextAtom(atomIter)) {
971 >        atom->setSnapshotManager(sman_);
972 >      }
973 >        
974 >      for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) {
975 >        rb->setSnapshotManager(sman_);
976 >      }
977      }    
978 <  } else {
542 <    // initialize this stuff before using it, OK?
543 <    sprintf( painCave.errMsg,
544 <             "Trying to check cutoffs without a box.\n"
545 <             "\tOOPSE should have better programmers than that.\n" );
546 <    painCave.severity = OOPSE_ERROR;
547 <    painCave.isFatal = 1;
548 <    simError();      
978 >    
979    }
550  
551 }
980  
981 < void SimInfo::addProperty(GenericData* prop){
981 >  Vector3d SimInfo::getComVel(){
982 >    SimInfo::MoleculeIterator i;
983 >    Molecule* mol;
984  
985 <  map<string, GenericData*>::iterator result;
986 <  result = properties.find(prop->getID());
557 <  
558 <  //we can't simply use  properties[prop->getID()] = prop,
559 <  //it will cause memory leak if we already contain a propery which has the same name of prop
560 <  
561 <  if(result != properties.end()){
985 >    Vector3d comVel(0.0);
986 >    RealType totalMass = 0.0;
987      
988 <    delete (*result).second;
989 <    (*result).second = prop;
990 <      
988 >
989 >    for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) {
990 >      RealType mass = mol->getMass();
991 >      totalMass += mass;
992 >      comVel += mass * mol->getComVel();
993 >    }  
994 >
995 > #ifdef IS_MPI
996 >    RealType tmpMass = totalMass;
997 >    Vector3d tmpComVel(comVel);    
998 >    MPI_Allreduce(&tmpMass,&totalMass,1,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
999 >    MPI_Allreduce(tmpComVel.getArrayPointer(), comVel.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1000 > #endif
1001 >
1002 >    comVel /= totalMass;
1003 >
1004 >    return comVel;
1005    }
567  else{
1006  
1007 <    properties[prop->getID()] = prop;
1007 >  Vector3d SimInfo::getCom(){
1008 >    SimInfo::MoleculeIterator i;
1009 >    Molecule* mol;
1010  
1011 +    Vector3d com(0.0);
1012 +    RealType totalMass = 0.0;
1013 +    
1014 +    for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) {
1015 +      RealType mass = mol->getMass();
1016 +      totalMass += mass;
1017 +      com += mass * mol->getCom();
1018 +    }  
1019 +
1020 + #ifdef IS_MPI
1021 +    RealType tmpMass = totalMass;
1022 +    Vector3d tmpCom(com);    
1023 +    MPI_Allreduce(&tmpMass,&totalMass,1,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1024 +    MPI_Allreduce(tmpCom.getArrayPointer(), com.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1025 + #endif
1026 +
1027 +    com /= totalMass;
1028 +
1029 +    return com;
1030 +
1031 +  }        
1032 +
1033 +  ostream& operator <<(ostream& o, SimInfo& info) {
1034 +
1035 +    return o;
1036    }
1037 +  
1038 +  
1039 +   /*
1040 +   Returns center of mass and center of mass velocity in one function call.
1041 +   */
1042 +  
1043 +   void SimInfo::getComAll(Vector3d &com, Vector3d &comVel){
1044 +      SimInfo::MoleculeIterator i;
1045 +      Molecule* mol;
1046 +      
1047      
1048 < }
1048 >      RealType totalMass = 0.0;
1049 >    
1050  
1051 < GenericData* SimInfo::getProperty(const string& propName){
1052 <
1053 <  map<string, GenericData*>::iterator result;
1054 <  
1055 <  //string lowerCaseName = ();
1056 <  
1057 <  result = properties.find(propName);
1058 <  
1059 <  if(result != properties.end())
1060 <    return (*result).second;  
1061 <  else  
1062 <    return NULL;  
1063 < }
1051 >      for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) {
1052 >         RealType mass = mol->getMass();
1053 >         totalMass += mass;
1054 >         com += mass * mol->getCom();
1055 >         comVel += mass * mol->getComVel();          
1056 >      }  
1057 >      
1058 > #ifdef IS_MPI
1059 >      RealType tmpMass = totalMass;
1060 >      Vector3d tmpCom(com);  
1061 >      Vector3d tmpComVel(comVel);
1062 >      MPI_Allreduce(&tmpMass,&totalMass,1,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1063 >      MPI_Allreduce(tmpCom.getArrayPointer(), com.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1064 >      MPI_Allreduce(tmpComVel.getArrayPointer(), comVel.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1065 > #endif
1066 >      
1067 >      com /= totalMass;
1068 >      comVel /= totalMass;
1069 >   }        
1070 >  
1071 >   /*
1072 >   Return intertia tensor for entire system and angular momentum Vector.
1073  
1074  
1075 < void SimInfo::getFortranGroupArrays(SimInfo* info,
1076 <                                    vector<int>& FglobalGroupMembership,
1077 <                                    vector<double>& mfact){
1078 <  
594 <  Molecule* myMols;
595 <  Atom** myAtoms;
596 <  int numAtom;
597 <  double mtot;
598 <  int numMol;
599 <  int numCutoffGroups;
600 <  CutoffGroup* myCutoffGroup;
601 <  vector<CutoffGroup*>::iterator iterCutoff;
602 <  Atom* cutoffAtom;
603 <  vector<Atom*>::iterator iterAtom;
604 <  int atomIndex;
605 <  double totalMass;
606 <  
607 <  mfact.clear();
608 <  FglobalGroupMembership.clear();
609 <  
1075 >       [  Ixx -Ixy  -Ixz ]
1076 >    J =| -Iyx  Iyy  -Iyz |
1077 >       [ -Izx -Iyz   Izz ]
1078 >    */
1079  
1080 <  // Fix the silly fortran indexing problem
1080 >   void SimInfo::getInertiaTensor(Mat3x3d &inertiaTensor, Vector3d &angularMomentum){
1081 >      
1082 >
1083 >      RealType xx = 0.0;
1084 >      RealType yy = 0.0;
1085 >      RealType zz = 0.0;
1086 >      RealType xy = 0.0;
1087 >      RealType xz = 0.0;
1088 >      RealType yz = 0.0;
1089 >      Vector3d com(0.0);
1090 >      Vector3d comVel(0.0);
1091 >      
1092 >      getComAll(com, comVel);
1093 >      
1094 >      SimInfo::MoleculeIterator i;
1095 >      Molecule* mol;
1096 >      
1097 >      Vector3d thisq(0.0);
1098 >      Vector3d thisv(0.0);
1099 >
1100 >      RealType thisMass = 0.0;
1101 >    
1102 >      
1103 >      
1104 >  
1105 >      for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) {
1106 >        
1107 >         thisq = mol->getCom()-com;
1108 >         thisv = mol->getComVel()-comVel;
1109 >         thisMass = mol->getMass();
1110 >         // Compute moment of intertia coefficients.
1111 >         xx += thisq[0]*thisq[0]*thisMass;
1112 >         yy += thisq[1]*thisq[1]*thisMass;
1113 >         zz += thisq[2]*thisq[2]*thisMass;
1114 >        
1115 >         // compute products of intertia
1116 >         xy += thisq[0]*thisq[1]*thisMass;
1117 >         xz += thisq[0]*thisq[2]*thisMass;
1118 >         yz += thisq[1]*thisq[2]*thisMass;
1119 >            
1120 >         angularMomentum += cross( thisq, thisv ) * thisMass;
1121 >            
1122 >      }  
1123 >      
1124 >      
1125 >      inertiaTensor(0,0) = yy + zz;
1126 >      inertiaTensor(0,1) = -xy;
1127 >      inertiaTensor(0,2) = -xz;
1128 >      inertiaTensor(1,0) = -xy;
1129 >      inertiaTensor(1,1) = xx + zz;
1130 >      inertiaTensor(1,2) = -yz;
1131 >      inertiaTensor(2,0) = -xz;
1132 >      inertiaTensor(2,1) = -yz;
1133 >      inertiaTensor(2,2) = xx + yy;
1134 >      
1135   #ifdef IS_MPI
1136 <  numAtom = mpiSim->getNAtomsGlobal();
1137 < #else
1138 <  numAtom = n_atoms;
1136 >      Mat3x3d tmpI(inertiaTensor);
1137 >      Vector3d tmpAngMom;
1138 >      MPI_Allreduce(tmpI.getArrayPointer(), inertiaTensor.getArrayPointer(),9,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1139 >      MPI_Allreduce(tmpAngMom.getArrayPointer(), angularMomentum.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1140   #endif
1141 <  for (int i = 0; i < numAtom; i++)
1142 <    FglobalGroupMembership.push_back(globalGroupMembership[i] + 1);
1143 <  
1141 >              
1142 >      return;
1143 >   }
1144  
1145 <  myMols = info->molecules;
1146 <  numMol = info->n_mol;
623 <  for(int i  = 0; i < numMol; i++){
624 <    numCutoffGroups = myMols[i].getNCutoffGroups();
625 <    for(myCutoffGroup =myMols[i].beginCutoffGroup(iterCutoff);
626 <        myCutoffGroup != NULL;
627 <        myCutoffGroup =myMols[i].nextCutoffGroup(iterCutoff)){
628 <
629 <      totalMass = myCutoffGroup->getMass();
1145 >   //Returns the angular momentum of the system
1146 >   Vector3d SimInfo::getAngularMomentum(){
1147        
1148 <      for(cutoffAtom = myCutoffGroup->beginAtom(iterAtom);
1149 <          cutoffAtom != NULL;
1150 <          cutoffAtom = myCutoffGroup->nextAtom(iterAtom)){
1151 <        mfact.push_back(cutoffAtom->getMass()/totalMass);
1148 >      Vector3d com(0.0);
1149 >      Vector3d comVel(0.0);
1150 >      Vector3d angularMomentum(0.0);
1151 >      
1152 >      getComAll(com,comVel);
1153 >      
1154 >      SimInfo::MoleculeIterator i;
1155 >      Molecule* mol;
1156 >      
1157 >      Vector3d thisr(0.0);
1158 >      Vector3d thisp(0.0);
1159 >      
1160 >      RealType thisMass;
1161 >      
1162 >      for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) {        
1163 >        thisMass = mol->getMass();
1164 >        thisr = mol->getCom()-com;
1165 >        thisp = (mol->getComVel()-comVel)*thisMass;
1166 >        
1167 >        angularMomentum += cross( thisr, thisp );
1168 >        
1169        }  
1170 +      
1171 + #ifdef IS_MPI
1172 +      Vector3d tmpAngMom;
1173 +      MPI_Allreduce(tmpAngMom.getArrayPointer(), angularMomentum.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD);
1174 + #endif
1175 +      
1176 +      return angularMomentum;
1177 +   }
1178 +  
1179 +  StuntDouble* SimInfo::getIOIndexToIntegrableObject(int index) {
1180 +    return IOIndexToIntegrableObject.at(index);
1181 +  }
1182 +  
1183 +  void SimInfo::setIOIndexToIntegrableObject(const vector<StuntDouble*>& v) {
1184 +    IOIndexToIntegrableObject= v;
1185 +  }
1186 +
1187 +  /* Returns the Volume of the simulation based on a ellipsoid with semi-axes
1188 +     based on the radius of gyration V=4/3*Pi*R_1*R_2*R_3
1189 +     where R_i are related to the principle inertia moments R_i = sqrt(C*I_i/N), this reduces to
1190 +     V = 4/3*Pi*(C/N)^3/2*sqrt(det(I)). See S.E. Baltazar et. al. Comp. Mat. Sci. 37 (2006) 526-536.
1191 +  */
1192 +  void SimInfo::getGyrationalVolume(RealType &volume){
1193 +    Mat3x3d intTensor;
1194 +    RealType det;
1195 +    Vector3d dummyAngMom;
1196 +    RealType sysconstants;
1197 +    RealType geomCnst;
1198 +
1199 +    geomCnst = 3.0/2.0;
1200 +    /* Get the inertial tensor and angular momentum for free*/
1201 +    getInertiaTensor(intTensor,dummyAngMom);
1202 +    
1203 +    det = intTensor.determinant();
1204 +    sysconstants = geomCnst/(RealType)nGlobalIntegrableObjects_;
1205 +    volume = 4.0/3.0*NumericConstant::PI*pow(sysconstants,3.0/2.0)*sqrt(det);
1206 +    return;
1207 +  }
1208 +
1209 +  void SimInfo::getGyrationalVolume(RealType &volume, RealType &detI){
1210 +    Mat3x3d intTensor;
1211 +    Vector3d dummyAngMom;
1212 +    RealType sysconstants;
1213 +    RealType geomCnst;
1214 +
1215 +    geomCnst = 3.0/2.0;
1216 +    /* Get the inertial tensor and angular momentum for free*/
1217 +    getInertiaTensor(intTensor,dummyAngMom);
1218 +    
1219 +    detI = intTensor.determinant();
1220 +    sysconstants = geomCnst/(RealType)nGlobalIntegrableObjects_;
1221 +    volume = 4.0/3.0*NumericConstant::PI*pow(sysconstants,3.0/2.0)*sqrt(detI);
1222 +    return;
1223 +  }
1224 + /*
1225 +   void SimInfo::setStuntDoubleFromGlobalIndex(vector<StuntDouble*> v) {
1226 +      assert( v.size() == nAtoms_ + nRigidBodies_);
1227 +      sdByGlobalIndex_ = v;
1228      }
1229 +
1230 +    StuntDouble* SimInfo::getStuntDoubleFromGlobalIndex(int index) {
1231 +      //assert(index < nAtoms_ + nRigidBodies_);
1232 +      return sdByGlobalIndex_.at(index);
1233 +    }  
1234 + */  
1235 +  int SimInfo::getNGlobalConstraints() {
1236 +    int nGlobalConstraints;
1237 + #ifdef IS_MPI
1238 +    MPI_Allreduce(&nConstraints_, &nGlobalConstraints, 1, MPI_INT, MPI_SUM,
1239 +                  MPI_COMM_WORLD);    
1240 + #else
1241 +    nGlobalConstraints =  nConstraints_;
1242 + #endif
1243 +    return nGlobalConstraints;
1244    }
1245  
1246 < }
1246 > }//end namespace OpenMD
1247 >

Comparing:
trunk/src/brains/SimInfo.cpp (property svn:keywords), Revision 143 by chrisfen, Fri Oct 22 22:54:01 2004 UTC vs.
branches/development/src/brains/SimInfo.cpp (property svn:keywords), Revision 1535 by gezelter, Fri Dec 31 18:31:56 2010 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines