| 1 | < | /* | 
| 1 | > | /* | 
| 2 |  | * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. | 
| 3 |  | * | 
| 4 |  | * The University of Notre Dame grants you ("Licensee") a | 
| 48 |  |  | 
| 49 |  | #include <algorithm> | 
| 50 |  | #include <set> | 
| 51 | + | #include <map> | 
| 52 |  |  | 
| 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" | 
| 58 | + | #include "UseTheForce/DarkSide/fElectrostaticSummationMethod.h" | 
| 59 | + | #include "UseTheForce/DarkSide/fElectrostaticScreeningMethod.h" | 
| 60 | + | #include "UseTheForce/DarkSide/fSwitchingFunctionType.h" | 
| 61 |  | #include "UseTheForce/doForces_interface.h" | 
| 62 | < | #include "UseTheForce/notifyCutoffs_interface.h" | 
| 62 | > | #include "UseTheForce/DarkSide/neighborLists_interface.h" | 
| 63 | > | #include "UseTheForce/DarkSide/electrostatic_interface.h" | 
| 64 | > | #include "UseTheForce/DarkSide/switcheroo_interface.h" | 
| 65 |  | #include "utils/MemoryUtils.hpp" | 
| 66 |  | #include "utils/simError.h" | 
| 67 |  | #include "selection/SelectionManager.hpp" | 
| 68 | + | #include "io/ForceFieldOptions.hpp" | 
| 69 | + | #include "UseTheForce/ForceField.hpp" | 
| 70 |  |  | 
| 71 | + |  | 
| 72 |  | #ifdef IS_MPI | 
| 73 |  | #include "UseTheForce/mpiComponentPlan.h" | 
| 74 |  | #include "UseTheForce/DarkSide/simParallel_interface.h" | 
| 75 |  | #endif | 
| 76 |  |  | 
| 77 |  | namespace oopse { | 
| 78 | + | std::set<int> getRigidSet(int index, std::map<int, std::set<int> >& container) { | 
| 79 | + | std::map<int, std::set<int> >::iterator i = container.find(index); | 
| 80 | + | std::set<int> result; | 
| 81 | + | if (i != container.end()) { | 
| 82 | + | result = i->second; | 
| 83 | + | } | 
| 84 |  |  | 
| 85 | < | SimInfo::SimInfo(std::vector<std::pair<MoleculeStamp*, int> >& molStampPairs, | 
| 86 | < | ForceField* ff, Globals* simParams) : | 
| 87 | < | forceField_(ff), simParams_(simParams), | 
| 88 | < | ndf_(0), ndfRaw_(0), ndfTrans_(0), nZconstraint_(0), | 
| 89 | < | nGlobalMols_(0), nGlobalAtoms_(0), nGlobalCutoffGroups_(0), | 
| 90 | < | nGlobalIntegrableObjects_(0), nGlobalRigidBodies_(0), | 
| 91 | < | nAtoms_(0), nBonds_(0),  nBends_(0), nTorsions_(0), nRigidBodies_(0), | 
| 92 | < | nIntegrableObjects_(0),  nCutoffGroups_(0), nConstraints_(0), | 
| 93 | < | sman_(NULL), fortranInitialized_(false), selectMan_(NULL) { | 
| 85 | > | return result; | 
| 86 | > | } | 
| 87 | > |  | 
| 88 | > | SimInfo::SimInfo(ForceField* ff, Globals* simParams) : | 
| 89 | > | forceField_(ff), simParams_(simParams), | 
| 90 | > | ndf_(0), fdf_local(0), ndfRaw_(0), ndfTrans_(0), nZconstraint_(0), | 
| 91 | > | nGlobalMols_(0), nGlobalAtoms_(0), nGlobalCutoffGroups_(0), | 
| 92 | > | nGlobalIntegrableObjects_(0), nGlobalRigidBodies_(0), | 
| 93 | > | nAtoms_(0), nBonds_(0),  nBends_(0), nTorsions_(0), nRigidBodies_(0), | 
| 94 | > | nIntegrableObjects_(0),  nCutoffGroups_(0), nConstraints_(0), | 
| 95 | > | sman_(NULL), fortranInitialized_(false), calcBoxDipole_(false) { | 
| 96 |  |  | 
| 97 | < |  | 
| 98 | < | std::vector<std::pair<MoleculeStamp*, int> >::iterator i; | 
| 99 | < | MoleculeStamp* molStamp; | 
| 100 | < | int nMolWithSameStamp; | 
| 101 | < | int nCutoffAtoms = 0; // number of atoms belong to cutoff groups | 
| 102 | < | int nGroups = 0;          //total cutoff groups defined in meta-data file | 
| 103 | < | CutoffGroupStamp* cgStamp; | 
| 104 | < | RigidBodyStamp* rbStamp; | 
| 105 | < | int nRigidAtoms = 0; | 
| 106 | < |  | 
| 107 | < | for (i = molStampPairs.begin(); i !=molStampPairs.end(); ++i) { | 
| 108 | < | molStamp = i->first; | 
| 90 | < | nMolWithSameStamp = i->second; | 
| 97 | > | MoleculeStamp* molStamp; | 
| 98 | > | int nMolWithSameStamp; | 
| 99 | > | int nCutoffAtoms = 0; // number of atoms belong to cutoff groups | 
| 100 | > | int nGroups = 0;      //total cutoff groups defined in meta-data file | 
| 101 | > | CutoffGroupStamp* cgStamp; | 
| 102 | > | RigidBodyStamp* rbStamp; | 
| 103 | > | int nRigidAtoms = 0; | 
| 104 | > | std::vector<Component*> components = simParams->getComponents(); | 
| 105 | > |  | 
| 106 | > | for (std::vector<Component*>::iterator i = components.begin(); i !=components.end(); ++i) { | 
| 107 | > | molStamp = (*i)->getMoleculeStamp(); | 
| 108 | > | nMolWithSameStamp = (*i)->getNMol(); | 
| 109 |  |  | 
| 110 |  | addMoleculeStamp(molStamp, nMolWithSameStamp); | 
| 111 |  |  | 
| 112 |  | //calculate atoms in molecules | 
| 113 |  | nGlobalAtoms_ += molStamp->getNAtoms() *nMolWithSameStamp; | 
| 114 |  |  | 
| 97 | – |  | 
| 115 |  | //calculate atoms in cutoff groups | 
| 116 |  | int nAtomsInGroups = 0; | 
| 117 |  | int nCutoffGroupsInStamp = molStamp->getNCutoffGroups(); | 
| 118 |  |  | 
| 119 |  | for (int j=0; j < nCutoffGroupsInStamp; j++) { | 
| 120 | < | cgStamp = molStamp->getCutoffGroup(j); | 
| 121 | < | nAtomsInGroups += cgStamp->getNMembers(); | 
| 120 | > | cgStamp = molStamp->getCutoffGroupStamp(j); | 
| 121 | > | nAtomsInGroups += cgStamp->getNMembers(); | 
| 122 |  | } | 
| 123 |  |  | 
| 124 |  | nGroups += nCutoffGroupsInStamp * nMolWithSameStamp; | 
| 125 | + |  | 
| 126 |  | nCutoffAtoms += nAtomsInGroups * nMolWithSameStamp; | 
| 127 |  |  | 
| 128 |  | //calculate atoms in rigid bodies | 
| 130 |  | int nRigidBodiesInStamp = molStamp->getNRigidBodies(); | 
| 131 |  |  | 
| 132 |  | for (int j=0; j < nRigidBodiesInStamp; j++) { | 
| 133 | < | rbStamp = molStamp->getRigidBody(j); | 
| 134 | < | nAtomsInRigidBodies += rbStamp->getNMembers(); | 
| 133 | > | rbStamp = molStamp->getRigidBodyStamp(j); | 
| 134 | > | nAtomsInRigidBodies += rbStamp->getNMembers(); | 
| 135 |  | } | 
| 136 |  |  | 
| 137 |  | nGlobalRigidBodies_ += nRigidBodiesInStamp * nMolWithSameStamp; | 
| 138 |  | nRigidAtoms += nAtomsInRigidBodies * nMolWithSameStamp; | 
| 139 |  |  | 
| 140 | < | } | 
| 140 | > | } | 
| 141 |  |  | 
| 142 | < | //every free atom (atom does not belong to cutoff groups) is a cutoff group | 
| 143 | < | //therefore the total number of cutoff groups in the system is equal to | 
| 144 | < | //the total number of atoms minus number of atoms belong to cutoff group defined in meta-data | 
| 145 | < | //file plus the number of cutoff groups defined in meta-data file | 
| 146 | < | nGlobalCutoffGroups_ = nGlobalAtoms_ - nCutoffAtoms + nGroups; | 
| 142 | > | //every free atom (atom does not belong to cutoff groups) is a cutoff | 
| 143 | > | //group therefore the total number of cutoff groups in the system is | 
| 144 | > | //equal to the total number of atoms minus number of atoms belong to | 
| 145 | > | //cutoff group defined in meta-data file plus the number of cutoff | 
| 146 | > | //groups defined in meta-data file | 
| 147 | > | nGlobalCutoffGroups_ = nGlobalAtoms_ - nCutoffAtoms + nGroups; | 
| 148 |  |  | 
| 149 | < | //every free atom (atom does not belong to rigid bodies) is an integrable object | 
| 150 | < | //therefore the total number of  integrable objects in the system is equal to | 
| 151 | < | //the total number of atoms minus number of atoms belong to  rigid body defined in meta-data | 
| 152 | < | //file plus the number of  rigid bodies defined in meta-data file | 
| 153 | < | nGlobalIntegrableObjects_ = nGlobalAtoms_ - nRigidAtoms + nGlobalRigidBodies_; | 
| 149 | > | //every free atom (atom does not belong to rigid bodies) is an | 
| 150 | > | //integrable object therefore the total number of integrable objects | 
| 151 | > | //in the system is equal to the total number of atoms minus number of | 
| 152 | > | //atoms belong to rigid body defined in meta-data file plus the number | 
| 153 | > | //of rigid bodies defined in meta-data file | 
| 154 | > | nGlobalIntegrableObjects_ = nGlobalAtoms_ - nRigidAtoms | 
| 155 | > | + nGlobalRigidBodies_; | 
| 156 | > |  | 
| 157 | > | nGlobalMols_ = molStampIds_.size(); | 
| 158 |  |  | 
| 136 | – | nGlobalMols_ = molStampIds_.size(); | 
| 137 | – |  | 
| 159 |  | #ifdef IS_MPI | 
| 160 | < | molToProcMap_.resize(nGlobalMols_); | 
| 160 | > | molToProcMap_.resize(nGlobalMols_); | 
| 161 |  | #endif | 
| 162 |  |  | 
| 163 | < | selectMan_ = new SelectionManager(this); | 
| 143 | < | selectMan_->selectAll(); | 
| 144 | < | } | 
| 163 | > | } | 
| 164 |  |  | 
| 165 | < | SimInfo::~SimInfo() { | 
| 166 | < | //MemoryUtils::deleteVectorOfPointer(molecules_); | 
| 167 | < |  | 
| 168 | < | MemoryUtils::deleteVectorOfPointer(moleculeStamps_); | 
| 169 | < |  | 
| 165 | > | SimInfo::~SimInfo() { | 
| 166 | > | std::map<int, Molecule*>::iterator i; | 
| 167 | > | for (i = molecules_.begin(); i != molecules_.end(); ++i) { | 
| 168 | > | delete i->second; | 
| 169 | > | } | 
| 170 | > | molecules_.clear(); | 
| 171 | > |  | 
| 172 |  | delete sman_; | 
| 173 |  | delete simParams_; | 
| 174 |  | delete forceField_; | 
| 175 | < | delete selectMan_; | 
| 155 | < | } | 
| 175 | > | } | 
| 176 |  |  | 
| 177 | < | int SimInfo::getNGlobalConstraints() { | 
| 177 | > | int SimInfo::getNGlobalConstraints() { | 
| 178 |  | int nGlobalConstraints; | 
| 179 |  | #ifdef IS_MPI | 
| 180 |  | MPI_Allreduce(&nConstraints_, &nGlobalConstraints, 1, MPI_INT, MPI_SUM, | 
| 183 |  | nGlobalConstraints =  nConstraints_; | 
| 184 |  | #endif | 
| 185 |  | return nGlobalConstraints; | 
| 186 | < | } | 
| 186 | > | } | 
| 187 |  |  | 
| 188 | < | bool SimInfo::addMolecule(Molecule* mol) { | 
| 188 | > | bool SimInfo::addMolecule(Molecule* mol) { | 
| 189 |  | MoleculeIterator i; | 
| 190 |  |  | 
| 191 |  | i = molecules_.find(mol->getGlobalIndex()); | 
| 192 |  | if (i == molecules_.end() ) { | 
| 193 |  |  | 
| 194 | < | molecules_.insert(std::make_pair(mol->getGlobalIndex(), mol)); | 
| 194 | > | molecules_.insert(std::make_pair(mol->getGlobalIndex(), mol)); | 
| 195 |  |  | 
| 196 | < | nAtoms_ += mol->getNAtoms(); | 
| 197 | < | nBonds_ += mol->getNBonds(); | 
| 198 | < | nBends_ += mol->getNBends(); | 
| 199 | < | nTorsions_ += mol->getNTorsions(); | 
| 200 | < | nRigidBodies_ += mol->getNRigidBodies(); | 
| 201 | < | nIntegrableObjects_ += mol->getNIntegrableObjects(); | 
| 202 | < | nCutoffGroups_ += mol->getNCutoffGroups(); | 
| 203 | < | nConstraints_ += mol->getNConstraintPairs(); | 
| 196 | > | nAtoms_ += mol->getNAtoms(); | 
| 197 | > | nBonds_ += mol->getNBonds(); | 
| 198 | > | nBends_ += mol->getNBends(); | 
| 199 | > | nTorsions_ += mol->getNTorsions(); | 
| 200 | > | nRigidBodies_ += mol->getNRigidBodies(); | 
| 201 | > | nIntegrableObjects_ += mol->getNIntegrableObjects(); | 
| 202 | > | nCutoffGroups_ += mol->getNCutoffGroups(); | 
| 203 | > | nConstraints_ += mol->getNConstraintPairs(); | 
| 204 |  |  | 
| 205 | < | addExcludePairs(mol); | 
| 205 | > | addExcludePairs(mol); | 
| 206 |  |  | 
| 207 | < | return true; | 
| 207 | > | return true; | 
| 208 |  | } else { | 
| 209 | < | return false; | 
| 209 | > | return false; | 
| 210 |  | } | 
| 211 | < | } | 
| 211 | > | } | 
| 212 |  |  | 
| 213 | < | bool SimInfo::removeMolecule(Molecule* mol) { | 
| 213 | > | bool SimInfo::removeMolecule(Molecule* mol) { | 
| 214 |  | MoleculeIterator i; | 
| 215 |  | i = molecules_.find(mol->getGlobalIndex()); | 
| 216 |  |  | 
| 217 |  | if (i != molecules_.end() ) { | 
| 218 |  |  | 
| 219 | < | assert(mol == i->second); | 
| 219 | > | assert(mol == i->second); | 
| 220 |  |  | 
| 221 | < | nAtoms_ -= mol->getNAtoms(); | 
| 222 | < | nBonds_ -= mol->getNBonds(); | 
| 223 | < | nBends_ -= mol->getNBends(); | 
| 224 | < | nTorsions_ -= mol->getNTorsions(); | 
| 225 | < | nRigidBodies_ -= mol->getNRigidBodies(); | 
| 226 | < | nIntegrableObjects_ -= mol->getNIntegrableObjects(); | 
| 227 | < | nCutoffGroups_ -= mol->getNCutoffGroups(); | 
| 228 | < | nConstraints_ -= mol->getNConstraintPairs(); | 
| 221 | > | nAtoms_ -= mol->getNAtoms(); | 
| 222 | > | nBonds_ -= mol->getNBonds(); | 
| 223 | > | nBends_ -= mol->getNBends(); | 
| 224 | > | nTorsions_ -= mol->getNTorsions(); | 
| 225 | > | nRigidBodies_ -= mol->getNRigidBodies(); | 
| 226 | > | nIntegrableObjects_ -= mol->getNIntegrableObjects(); | 
| 227 | > | nCutoffGroups_ -= mol->getNCutoffGroups(); | 
| 228 | > | nConstraints_ -= mol->getNConstraintPairs(); | 
| 229 |  |  | 
| 230 | < | removeExcludePairs(mol); | 
| 231 | < | molecules_.erase(mol->getGlobalIndex()); | 
| 230 | > | removeExcludePairs(mol); | 
| 231 | > | molecules_.erase(mol->getGlobalIndex()); | 
| 232 |  |  | 
| 233 | < | delete mol; | 
| 233 | > | delete mol; | 
| 234 |  |  | 
| 235 | < | return true; | 
| 235 | > | return true; | 
| 236 |  | } else { | 
| 237 | < | return false; | 
| 237 | > | return false; | 
| 238 |  | } | 
| 239 |  |  | 
| 240 |  |  | 
| 241 | < | } | 
| 241 | > | } | 
| 242 |  |  | 
| 243 |  |  | 
| 244 | < | Molecule* SimInfo::beginMolecule(MoleculeIterator& i) { | 
| 244 | > | Molecule* SimInfo::beginMolecule(MoleculeIterator& i) { | 
| 245 |  | i = molecules_.begin(); | 
| 246 |  | return i == molecules_.end() ? NULL : i->second; | 
| 247 | < | } | 
| 247 | > | } | 
| 248 |  |  | 
| 249 | < | Molecule* SimInfo::nextMolecule(MoleculeIterator& i) { | 
| 249 | > | Molecule* SimInfo::nextMolecule(MoleculeIterator& i) { | 
| 250 |  | ++i; | 
| 251 |  | return i == molecules_.end() ? NULL : i->second; | 
| 252 | < | } | 
| 252 | > | } | 
| 253 |  |  | 
| 254 |  |  | 
| 255 | < | void SimInfo::calcNdf() { | 
| 255 | > | void SimInfo::calcNdf() { | 
| 256 |  | int ndf_local; | 
| 257 |  | MoleculeIterator i; | 
| 258 |  | std::vector<StuntDouble*>::iterator j; | 
| 262 |  | ndf_local = 0; | 
| 263 |  |  | 
| 264 |  | for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { | 
| 265 | < | for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL; | 
| 266 | < | integrableObject = mol->nextIntegrableObject(j)) { | 
| 265 | > | for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL; | 
| 266 | > | integrableObject = mol->nextIntegrableObject(j)) { | 
| 267 |  |  | 
| 268 | < | ndf_local += 3; | 
| 268 | > | ndf_local += 3; | 
| 269 |  |  | 
| 270 | < | if (integrableObject->isDirectional()) { | 
| 271 | < | if (integrableObject->isLinear()) { | 
| 272 | < | ndf_local += 2; | 
| 273 | < | } else { | 
| 274 | < | ndf_local += 3; | 
| 275 | < | } | 
| 276 | < | } | 
| 270 | > | if (integrableObject->isDirectional()) { | 
| 271 | > | if (integrableObject->isLinear()) { | 
| 272 | > | ndf_local += 2; | 
| 273 | > | } else { | 
| 274 | > | ndf_local += 3; | 
| 275 | > | } | 
| 276 | > | } | 
| 277 |  |  | 
| 278 | < | }//end for (integrableObject) | 
| 279 | < | }// end for (mol) | 
| 278 | > | } | 
| 279 | > | } | 
| 280 |  |  | 
| 281 |  | // n_constraints is local, so subtract them on each processor | 
| 282 |  | ndf_local -= nConstraints_; | 
| 291 |  | // entire system: | 
| 292 |  | ndf_ = ndf_ - 3 - nZconstraint_; | 
| 293 |  |  | 
| 294 | < | } | 
| 294 | > | } | 
| 295 |  |  | 
| 296 | < | void SimInfo::calcNdfRaw() { | 
| 296 | > | int SimInfo::getFdf() { | 
| 297 | > | #ifdef IS_MPI | 
| 298 | > | MPI_Allreduce(&fdf_local,&fdf_,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD); | 
| 299 | > | #else | 
| 300 | > | fdf_ = fdf_local; | 
| 301 | > | #endif | 
| 302 | > | return fdf_; | 
| 303 | > | } | 
| 304 | > |  | 
| 305 | > | void SimInfo::calcNdfRaw() { | 
| 306 |  | int ndfRaw_local; | 
| 307 |  |  | 
| 308 |  | MoleculeIterator i; | 
| 314 |  | ndfRaw_local = 0; | 
| 315 |  |  | 
| 316 |  | for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { | 
| 317 | < | for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL; | 
| 318 | < | integrableObject = mol->nextIntegrableObject(j)) { | 
| 317 | > | for (integrableObject = mol->beginIntegrableObject(j); integrableObject != NULL; | 
| 318 | > | integrableObject = mol->nextIntegrableObject(j)) { | 
| 319 |  |  | 
| 320 | < | ndfRaw_local += 3; | 
| 320 | > | ndfRaw_local += 3; | 
| 321 |  |  | 
| 322 | < | if (integrableObject->isDirectional()) { | 
| 323 | < | if (integrableObject->isLinear()) { | 
| 324 | < | ndfRaw_local += 2; | 
| 325 | < | } else { | 
| 326 | < | ndfRaw_local += 3; | 
| 327 | < | } | 
| 328 | < | } | 
| 322 | > | if (integrableObject->isDirectional()) { | 
| 323 | > | if (integrableObject->isLinear()) { | 
| 324 | > | ndfRaw_local += 2; | 
| 325 | > | } else { | 
| 326 | > | ndfRaw_local += 3; | 
| 327 | > | } | 
| 328 | > | } | 
| 329 |  |  | 
| 330 | < | } | 
| 330 | > | } | 
| 331 |  | } | 
| 332 |  |  | 
| 333 |  | #ifdef IS_MPI | 
| 335 |  | #else | 
| 336 |  | ndfRaw_ = ndfRaw_local; | 
| 337 |  | #endif | 
| 338 | < | } | 
| 338 | > | } | 
| 339 |  |  | 
| 340 | < | void SimInfo::calcNdfTrans() { | 
| 340 | > | void SimInfo::calcNdfTrans() { | 
| 341 |  | int ndfTrans_local; | 
| 342 |  |  | 
| 343 |  | ndfTrans_local = 3 * nIntegrableObjects_ - nConstraints_; | 
| 351 |  |  | 
| 352 |  | ndfTrans_ = ndfTrans_ - 3 - nZconstraint_; | 
| 353 |  |  | 
| 354 | < | } | 
| 354 | > | } | 
| 355 |  |  | 
| 356 | < | void SimInfo::addExcludePairs(Molecule* mol) { | 
| 356 | > | void SimInfo::addExcludePairs(Molecule* mol) { | 
| 357 |  | std::vector<Bond*>::iterator bondIter; | 
| 358 |  | std::vector<Bend*>::iterator bendIter; | 
| 359 |  | std::vector<Torsion*>::iterator torsionIter; | 
| 364 |  | int b; | 
| 365 |  | int c; | 
| 366 |  | int d; | 
| 367 | + |  | 
| 368 | + | std::map<int, std::set<int> > atomGroups; | 
| 369 | + |  | 
| 370 | + | Molecule::RigidBodyIterator rbIter; | 
| 371 | + | RigidBody* rb; | 
| 372 | + | Molecule::IntegrableObjectIterator ii; | 
| 373 | + | StuntDouble* integrableObject; | 
| 374 |  |  | 
| 375 | + | for (integrableObject = mol->beginIntegrableObject(ii); integrableObject != NULL; | 
| 376 | + | integrableObject = mol->nextIntegrableObject(ii)) { | 
| 377 | + |  | 
| 378 | + | if (integrableObject->isRigidBody()) { | 
| 379 | + | rb = static_cast<RigidBody*>(integrableObject); | 
| 380 | + | std::vector<Atom*> atoms = rb->getAtoms(); | 
| 381 | + | std::set<int> rigidAtoms; | 
| 382 | + | for (int i = 0; i < atoms.size(); ++i) { | 
| 383 | + | rigidAtoms.insert(atoms[i]->getGlobalIndex()); | 
| 384 | + | } | 
| 385 | + | for (int i = 0; i < atoms.size(); ++i) { | 
| 386 | + | atomGroups.insert(std::map<int, std::set<int> >::value_type(atoms[i]->getGlobalIndex(), rigidAtoms)); | 
| 387 | + | } | 
| 388 | + | } else { | 
| 389 | + | std::set<int> oneAtomSet; | 
| 390 | + | oneAtomSet.insert(integrableObject->getGlobalIndex()); | 
| 391 | + | atomGroups.insert(std::map<int, std::set<int> >::value_type(integrableObject->getGlobalIndex(), oneAtomSet)); | 
| 392 | + | } | 
| 393 | + | } | 
| 394 | + |  | 
| 395 | + |  | 
| 396 | + |  | 
| 397 |  | for (bond= mol->beginBond(bondIter); bond != NULL; bond = mol->nextBond(bondIter)) { | 
| 398 | < | a = bond->getAtomA()->getGlobalIndex(); | 
| 399 | < | b = bond->getAtomB()->getGlobalIndex(); | 
| 400 | < | exclude_.addPair(a, b); | 
| 398 | > | a = bond->getAtomA()->getGlobalIndex(); | 
| 399 | > | b = bond->getAtomB()->getGlobalIndex(); | 
| 400 | > | exclude_.addPair(a, b); | 
| 401 |  | } | 
| 402 |  |  | 
| 403 |  | for (bend= mol->beginBend(bendIter); bend != NULL; bend = mol->nextBend(bendIter)) { | 
| 404 | < | a = bend->getAtomA()->getGlobalIndex(); | 
| 405 | < | b = bend->getAtomB()->getGlobalIndex(); | 
| 406 | < | c = bend->getAtomC()->getGlobalIndex(); | 
| 404 | > | a = bend->getAtomA()->getGlobalIndex(); | 
| 405 | > | b = bend->getAtomB()->getGlobalIndex(); | 
| 406 | > | c = bend->getAtomC()->getGlobalIndex(); | 
| 407 | > | std::set<int> rigidSetA = getRigidSet(a, atomGroups); | 
| 408 | > | std::set<int> rigidSetB = getRigidSet(b, atomGroups); | 
| 409 | > | std::set<int> rigidSetC = getRigidSet(c, atomGroups); | 
| 410 |  |  | 
| 411 | < | exclude_.addPair(a, b); | 
| 412 | < | exclude_.addPair(a, c); | 
| 413 | < | exclude_.addPair(b, c); | 
| 411 | > | exclude_.addPairs(rigidSetA, rigidSetB); | 
| 412 | > | exclude_.addPairs(rigidSetA, rigidSetC); | 
| 413 | > | exclude_.addPairs(rigidSetB, rigidSetC); | 
| 414 | > |  | 
| 415 | > | //exclude_.addPair(a, b); | 
| 416 | > | //exclude_.addPair(a, c); | 
| 417 | > | //exclude_.addPair(b, c); | 
| 418 |  | } | 
| 419 |  |  | 
| 420 |  | for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; torsion = mol->nextTorsion(torsionIter)) { | 
| 421 | < | a = torsion->getAtomA()->getGlobalIndex(); | 
| 422 | < | b = torsion->getAtomB()->getGlobalIndex(); | 
| 423 | < | c = torsion->getAtomC()->getGlobalIndex(); | 
| 424 | < | d = torsion->getAtomD()->getGlobalIndex(); | 
| 421 | > | a = torsion->getAtomA()->getGlobalIndex(); | 
| 422 | > | b = torsion->getAtomB()->getGlobalIndex(); | 
| 423 | > | c = torsion->getAtomC()->getGlobalIndex(); | 
| 424 | > | d = torsion->getAtomD()->getGlobalIndex(); | 
| 425 | > | std::set<int> rigidSetA = getRigidSet(a, atomGroups); | 
| 426 | > | std::set<int> rigidSetB = getRigidSet(b, atomGroups); | 
| 427 | > | std::set<int> rigidSetC = getRigidSet(c, atomGroups); | 
| 428 | > | std::set<int> rigidSetD = getRigidSet(d, atomGroups); | 
| 429 |  |  | 
| 430 | < | exclude_.addPair(a, b); | 
| 431 | < | exclude_.addPair(a, c); | 
| 432 | < | exclude_.addPair(a, d); | 
| 433 | < | exclude_.addPair(b, c); | 
| 434 | < | exclude_.addPair(b, d); | 
| 435 | < | exclude_.addPair(c, d); | 
| 367 | < | } | 
| 430 | > | exclude_.addPairs(rigidSetA, rigidSetB); | 
| 431 | > | exclude_.addPairs(rigidSetA, rigidSetC); | 
| 432 | > | exclude_.addPairs(rigidSetA, rigidSetD); | 
| 433 | > | exclude_.addPairs(rigidSetB, rigidSetC); | 
| 434 | > | exclude_.addPairs(rigidSetB, rigidSetD); | 
| 435 | > | exclude_.addPairs(rigidSetC, rigidSetD); | 
| 436 |  |  | 
| 437 | < |  | 
| 438 | < | } | 
| 437 | > | /* | 
| 438 | > | exclude_.addPairs(rigidSetA.begin(), rigidSetA.end(), rigidSetB.begin(), rigidSetB.end()); | 
| 439 | > | exclude_.addPairs(rigidSetA.begin(), rigidSetA.end(), rigidSetC.begin(), rigidSetC.end()); | 
| 440 | > | exclude_.addPairs(rigidSetA.begin(), rigidSetA.end(), rigidSetD.begin(), rigidSetD.end()); | 
| 441 | > | exclude_.addPairs(rigidSetB.begin(), rigidSetB.end(), rigidSetC.begin(), rigidSetC.end()); | 
| 442 | > | exclude_.addPairs(rigidSetB.begin(), rigidSetB.end(), rigidSetD.begin(), rigidSetD.end()); | 
| 443 | > | exclude_.addPairs(rigidSetC.begin(), rigidSetC.end(), rigidSetD.begin(), rigidSetD.end()); | 
| 444 | > |  | 
| 445 | > |  | 
| 446 | > | exclude_.addPair(a, b); | 
| 447 | > | exclude_.addPair(a, c); | 
| 448 | > | exclude_.addPair(a, d); | 
| 449 | > | exclude_.addPair(b, c); | 
| 450 | > | exclude_.addPair(b, d); | 
| 451 | > | exclude_.addPair(c, d); | 
| 452 | > | */ | 
| 453 | > | } | 
| 454 |  |  | 
| 455 | < | void SimInfo::removeExcludePairs(Molecule* mol) { | 
| 455 | > | for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { | 
| 456 | > | std::vector<Atom*> atoms = rb->getAtoms(); | 
| 457 | > | for (int i = 0; i < atoms.size() -1 ; ++i) { | 
| 458 | > | for (int j = i + 1; j < atoms.size(); ++j) { | 
| 459 | > | a = atoms[i]->getGlobalIndex(); | 
| 460 | > | b = atoms[j]->getGlobalIndex(); | 
| 461 | > | exclude_.addPair(a, b); | 
| 462 | > | } | 
| 463 | > | } | 
| 464 | > | } | 
| 465 | > |  | 
| 466 | > | } | 
| 467 | > |  | 
| 468 | > | void SimInfo::removeExcludePairs(Molecule* mol) { | 
| 469 |  | std::vector<Bond*>::iterator bondIter; | 
| 470 |  | std::vector<Bend*>::iterator bendIter; | 
| 471 |  | std::vector<Torsion*>::iterator torsionIter; | 
| 476 |  | int b; | 
| 477 |  | int c; | 
| 478 |  | int d; | 
| 479 | + |  | 
| 480 | + | std::map<int, std::set<int> > atomGroups; | 
| 481 | + |  | 
| 482 | + | Molecule::RigidBodyIterator rbIter; | 
| 483 | + | RigidBody* rb; | 
| 484 | + | Molecule::IntegrableObjectIterator ii; | 
| 485 | + | StuntDouble* integrableObject; | 
| 486 |  |  | 
| 487 | + | for (integrableObject = mol->beginIntegrableObject(ii); integrableObject != NULL; | 
| 488 | + | integrableObject = mol->nextIntegrableObject(ii)) { | 
| 489 | + |  | 
| 490 | + | if (integrableObject->isRigidBody()) { | 
| 491 | + | rb = static_cast<RigidBody*>(integrableObject); | 
| 492 | + | std::vector<Atom*> atoms = rb->getAtoms(); | 
| 493 | + | std::set<int> rigidAtoms; | 
| 494 | + | for (int i = 0; i < atoms.size(); ++i) { | 
| 495 | + | rigidAtoms.insert(atoms[i]->getGlobalIndex()); | 
| 496 | + | } | 
| 497 | + | for (int i = 0; i < atoms.size(); ++i) { | 
| 498 | + | atomGroups.insert(std::map<int, std::set<int> >::value_type(atoms[i]->getGlobalIndex(), rigidAtoms)); | 
| 499 | + | } | 
| 500 | + | } else { | 
| 501 | + | std::set<int> oneAtomSet; | 
| 502 | + | oneAtomSet.insert(integrableObject->getGlobalIndex()); | 
| 503 | + | atomGroups.insert(std::map<int, std::set<int> >::value_type(integrableObject->getGlobalIndex(), oneAtomSet)); | 
| 504 | + | } | 
| 505 | + | } | 
| 506 | + |  | 
| 507 | + |  | 
| 508 |  | for (bond= mol->beginBond(bondIter); bond != NULL; bond = mol->nextBond(bondIter)) { | 
| 509 | < | a = bond->getAtomA()->getGlobalIndex(); | 
| 510 | < | b = bond->getAtomB()->getGlobalIndex(); | 
| 511 | < | exclude_.removePair(a, b); | 
| 509 | > | a = bond->getAtomA()->getGlobalIndex(); | 
| 510 | > | b = bond->getAtomB()->getGlobalIndex(); | 
| 511 | > | exclude_.removePair(a, b); | 
| 512 |  | } | 
| 513 |  |  | 
| 514 |  | for (bend= mol->beginBend(bendIter); bend != NULL; bend = mol->nextBend(bendIter)) { | 
| 515 | < | a = bend->getAtomA()->getGlobalIndex(); | 
| 516 | < | b = bend->getAtomB()->getGlobalIndex(); | 
| 517 | < | c = bend->getAtomC()->getGlobalIndex(); | 
| 515 | > | a = bend->getAtomA()->getGlobalIndex(); | 
| 516 | > | b = bend->getAtomB()->getGlobalIndex(); | 
| 517 | > | c = bend->getAtomC()->getGlobalIndex(); | 
| 518 |  |  | 
| 519 | < | exclude_.removePair(a, b); | 
| 520 | < | exclude_.removePair(a, c); | 
| 521 | < | exclude_.removePair(b, c); | 
| 519 | > | std::set<int> rigidSetA = getRigidSet(a, atomGroups); | 
| 520 | > | std::set<int> rigidSetB = getRigidSet(b, atomGroups); | 
| 521 | > | std::set<int> rigidSetC = getRigidSet(c, atomGroups); | 
| 522 | > |  | 
| 523 | > | exclude_.removePairs(rigidSetA, rigidSetB); | 
| 524 | > | exclude_.removePairs(rigidSetA, rigidSetC); | 
| 525 | > | exclude_.removePairs(rigidSetB, rigidSetC); | 
| 526 | > |  | 
| 527 | > | //exclude_.removePair(a, b); | 
| 528 | > | //exclude_.removePair(a, c); | 
| 529 | > | //exclude_.removePair(b, c); | 
| 530 |  | } | 
| 531 |  |  | 
| 532 |  | for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; torsion = mol->nextTorsion(torsionIter)) { | 
| 533 | < | a = torsion->getAtomA()->getGlobalIndex(); | 
| 534 | < | b = torsion->getAtomB()->getGlobalIndex(); | 
| 535 | < | c = torsion->getAtomC()->getGlobalIndex(); | 
| 536 | < | d = torsion->getAtomD()->getGlobalIndex(); | 
| 533 | > | a = torsion->getAtomA()->getGlobalIndex(); | 
| 534 | > | b = torsion->getAtomB()->getGlobalIndex(); | 
| 535 | > | c = torsion->getAtomC()->getGlobalIndex(); | 
| 536 | > | d = torsion->getAtomD()->getGlobalIndex(); | 
| 537 |  |  | 
| 538 | < | exclude_.removePair(a, b); | 
| 539 | < | exclude_.removePair(a, c); | 
| 540 | < | exclude_.removePair(a, d); | 
| 541 | < | exclude_.removePair(b, c); | 
| 542 | < | exclude_.removePair(b, d); | 
| 543 | < | exclude_.removePair(c, d); | 
| 538 | > | std::set<int> rigidSetA = getRigidSet(a, atomGroups); | 
| 539 | > | std::set<int> rigidSetB = getRigidSet(b, atomGroups); | 
| 540 | > | std::set<int> rigidSetC = getRigidSet(c, atomGroups); | 
| 541 | > | std::set<int> rigidSetD = getRigidSet(d, atomGroups); | 
| 542 | > |  | 
| 543 | > | exclude_.removePairs(rigidSetA, rigidSetB); | 
| 544 | > | exclude_.removePairs(rigidSetA, rigidSetC); | 
| 545 | > | exclude_.removePairs(rigidSetA, rigidSetD); | 
| 546 | > | exclude_.removePairs(rigidSetB, rigidSetC); | 
| 547 | > | exclude_.removePairs(rigidSetB, rigidSetD); | 
| 548 | > | exclude_.removePairs(rigidSetC, rigidSetD); | 
| 549 | > |  | 
| 550 | > | /* | 
| 551 | > | exclude_.removePairs(rigidSetA.begin(), rigidSetA.end(), rigidSetB.begin(), rigidSetB.end()); | 
| 552 | > | exclude_.removePairs(rigidSetA.begin(), rigidSetA.end(), rigidSetC.begin(), rigidSetC.end()); | 
| 553 | > | exclude_.removePairs(rigidSetA.begin(), rigidSetA.end(), rigidSetD.begin(), rigidSetD.end()); | 
| 554 | > | exclude_.removePairs(rigidSetB.begin(), rigidSetB.end(), rigidSetC.begin(), rigidSetC.end()); | 
| 555 | > | exclude_.removePairs(rigidSetB.begin(), rigidSetB.end(), rigidSetD.begin(), rigidSetD.end()); | 
| 556 | > | exclude_.removePairs(rigidSetC.begin(), rigidSetC.end(), rigidSetD.begin(), rigidSetD.end()); | 
| 557 | > |  | 
| 558 | > |  | 
| 559 | > | exclude_.removePair(a, b); | 
| 560 | > | exclude_.removePair(a, c); | 
| 561 | > | exclude_.removePair(a, d); | 
| 562 | > | exclude_.removePair(b, c); | 
| 563 | > | exclude_.removePair(b, d); | 
| 564 | > | exclude_.removePair(c, d); | 
| 565 | > | */ | 
| 566 |  | } | 
| 567 |  |  | 
| 568 | < | } | 
| 568 | > | for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { | 
| 569 | > | std::vector<Atom*> atoms = rb->getAtoms(); | 
| 570 | > | for (int i = 0; i < atoms.size() -1 ; ++i) { | 
| 571 | > | for (int j = i + 1; j < atoms.size(); ++j) { | 
| 572 | > | a = atoms[i]->getGlobalIndex(); | 
| 573 | > | b = atoms[j]->getGlobalIndex(); | 
| 574 | > | exclude_.removePair(a, b); | 
| 575 | > | } | 
| 576 | > | } | 
| 577 | > | } | 
| 578 |  |  | 
| 579 | + | } | 
| 580 |  |  | 
| 581 | < | void SimInfo::addMoleculeStamp(MoleculeStamp* molStamp, int nmol) { | 
| 581 | > |  | 
| 582 | > | void SimInfo::addMoleculeStamp(MoleculeStamp* molStamp, int nmol) { | 
| 583 |  | int curStampId; | 
| 584 |  |  | 
| 585 |  | //index from 0 | 
| 587 |  |  | 
| 588 |  | moleculeStamps_.push_back(molStamp); | 
| 589 |  | molStampIds_.insert(molStampIds_.end(), nmol, curStampId); | 
| 590 | < | } | 
| 590 | > | } | 
| 591 |  |  | 
| 592 | < | void SimInfo::update() { | 
| 592 | > | void SimInfo::update() { | 
| 593 |  |  | 
| 594 |  | setupSimType(); | 
| 595 |  |  | 
| 602 |  | //setup fortran force field | 
| 603 |  | /** @deprecate */ | 
| 604 |  | int isError = 0; | 
| 440 | – | initFortranFF( &fInfo_.SIM_uses_RF , &isError ); | 
| 441 | – | if(isError){ | 
| 442 | – | sprintf( painCave.errMsg, | 
| 443 | – | "ForceField error: There was an error initializing the forceField in fortran.\n" ); | 
| 444 | – | painCave.isFatal = 1; | 
| 445 | – | simError(); | 
| 446 | – | } | 
| 447 | – |  | 
| 605 |  |  | 
| 606 |  | setupCutoff(); | 
| 607 | + |  | 
| 608 | + | setupElectrostaticSummationMethod( isError ); | 
| 609 | + | setupSwitchingFunction(); | 
| 610 | + | setupAccumulateBoxDipole(); | 
| 611 |  |  | 
| 612 | + | if(isError){ | 
| 613 | + | sprintf( painCave.errMsg, | 
| 614 | + | "ForceField error: There was an error initializing the forceField in fortran.\n" ); | 
| 615 | + | painCave.isFatal = 1; | 
| 616 | + | simError(); | 
| 617 | + | } | 
| 618 | + |  | 
| 619 |  | calcNdf(); | 
| 620 |  | calcNdfRaw(); | 
| 621 |  | calcNdfTrans(); | 
| 622 |  |  | 
| 623 |  | fortranInitialized_ = true; | 
| 624 | < | } | 
| 624 | > | } | 
| 625 |  |  | 
| 626 | < | std::set<AtomType*> SimInfo::getUniqueAtomTypes() { | 
| 626 | > | std::set<AtomType*> SimInfo::getUniqueAtomTypes() { | 
| 627 |  | SimInfo::MoleculeIterator mi; | 
| 628 |  | Molecule* mol; | 
| 629 |  | Molecule::AtomIterator ai; | 
| 632 |  |  | 
| 633 |  | for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { | 
| 634 |  |  | 
| 635 | < | for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { | 
| 636 | < | atomTypes.insert(atom->getAtomType()); | 
| 637 | < | } | 
| 635 | > | for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { | 
| 636 | > | atomTypes.insert(atom->getAtomType()); | 
| 637 | > | } | 
| 638 |  |  | 
| 639 |  | } | 
| 640 |  |  | 
| 641 |  | return atomTypes; | 
| 642 | < | } | 
| 642 | > | } | 
| 643 |  |  | 
| 644 | < | void SimInfo::setupSimType() { | 
| 644 | > | void SimInfo::setupSimType() { | 
| 645 |  | std::set<AtomType*>::iterator i; | 
| 646 |  | std::set<AtomType*> atomTypes; | 
| 647 |  | atomTypes = getUniqueAtomTypes(); | 
| 649 |  | int useLennardJones = 0; | 
| 650 |  | int useElectrostatic = 0; | 
| 651 |  | int useEAM = 0; | 
| 652 | + | int useSC = 0; | 
| 653 |  | int useCharge = 0; | 
| 654 |  | int useDirectional = 0; | 
| 655 |  | int useDipole = 0; | 
| 656 |  | int useGayBerne = 0; | 
| 657 |  | int useSticky = 0; | 
| 658 | + | int useStickyPower = 0; | 
| 659 |  | int useShape = 0; | 
| 660 |  | int useFLARB = 0; //it is not in AtomType yet | 
| 661 |  | int useDirectionalAtom = 0; | 
| 662 |  | int useElectrostatics = 0; | 
| 663 |  | //usePBC and useRF are from simParams | 
| 664 | < | int usePBC = simParams_->getPBC(); | 
| 665 | < | int useRF = simParams_->getUseRF(); | 
| 664 | > | int usePBC = simParams_->getUsePeriodicBoundaryConditions(); | 
| 665 | > | int useRF; | 
| 666 | > | int useSF; | 
| 667 | > | int useSP; | 
| 668 | > | int useBoxDipole; | 
| 669 | > | std::string myMethod; | 
| 670 |  |  | 
| 671 | + | // set the useRF logical | 
| 672 | + | useRF = 0; | 
| 673 | + | useSF = 0; | 
| 674 | + | useSP = 0; | 
| 675 | + |  | 
| 676 | + |  | 
| 677 | + | if (simParams_->haveElectrostaticSummationMethod()) { | 
| 678 | + | std::string myMethod = simParams_->getElectrostaticSummationMethod(); | 
| 679 | + | toUpper(myMethod); | 
| 680 | + | if (myMethod == "REACTION_FIELD"){ | 
| 681 | + | useRF = 1; | 
| 682 | + | } else if (myMethod == "SHIFTED_FORCE"){ | 
| 683 | + | useSF = 1; | 
| 684 | + | } else if (myMethod == "SHIFTED_POTENTIAL"){ | 
| 685 | + | useSP = 1; | 
| 686 | + | } | 
| 687 | + | } | 
| 688 | + |  | 
| 689 | + | if (simParams_->haveAccumulateBoxDipole()) | 
| 690 | + | if (simParams_->getAccumulateBoxDipole()) | 
| 691 | + | useBoxDipole = 1; | 
| 692 | + |  | 
| 693 |  | //loop over all of the atom types | 
| 694 |  | for (i = atomTypes.begin(); i != atomTypes.end(); ++i) { | 
| 695 | < | useLennardJones |= (*i)->isLennardJones(); | 
| 696 | < | useElectrostatic |= (*i)->isElectrostatic(); | 
| 697 | < | useEAM |= (*i)->isEAM(); | 
| 698 | < | useCharge |= (*i)->isCharge(); | 
| 699 | < | useDirectional |= (*i)->isDirectional(); | 
| 700 | < | useDipole |= (*i)->isDipole(); | 
| 701 | < | useGayBerne |= (*i)->isGayBerne(); | 
| 702 | < | useSticky |= (*i)->isSticky(); | 
| 703 | < | useShape |= (*i)->isShape(); | 
| 695 | > | useLennardJones |= (*i)->isLennardJones(); | 
| 696 | > | useElectrostatic |= (*i)->isElectrostatic(); | 
| 697 | > | useEAM |= (*i)->isEAM(); | 
| 698 | > | useSC |= (*i)->isSC(); | 
| 699 | > | useCharge |= (*i)->isCharge(); | 
| 700 | > | useDirectional |= (*i)->isDirectional(); | 
| 701 | > | useDipole |= (*i)->isDipole(); | 
| 702 | > | useGayBerne |= (*i)->isGayBerne(); | 
| 703 | > | useSticky |= (*i)->isSticky(); | 
| 704 | > | useStickyPower |= (*i)->isStickyPower(); | 
| 705 | > | useShape |= (*i)->isShape(); | 
| 706 |  | } | 
| 707 |  |  | 
| 708 | < | if (useSticky || useDipole || useGayBerne || useShape) { | 
| 709 | < | useDirectionalAtom = 1; | 
| 708 | > | if (useSticky || useStickyPower || useDipole || useGayBerne || useShape) { | 
| 709 | > | useDirectionalAtom = 1; | 
| 710 |  | } | 
| 711 |  |  | 
| 712 |  | if (useCharge || useDipole) { | 
| 713 | < | useElectrostatics = 1; | 
| 713 | > | useElectrostatics = 1; | 
| 714 |  | } | 
| 715 |  |  | 
| 716 |  | #ifdef IS_MPI | 
| 737 |  | temp = useSticky; | 
| 738 |  | MPI_Allreduce(&temp, &useSticky, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); | 
| 739 |  |  | 
| 740 | + | temp = useStickyPower; | 
| 741 | + | MPI_Allreduce(&temp, &useStickyPower, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); | 
| 742 | + |  | 
| 743 |  | temp = useGayBerne; | 
| 744 |  | MPI_Allreduce(&temp, &useGayBerne, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); | 
| 745 |  |  | 
| 746 |  | temp = useEAM; | 
| 747 |  | MPI_Allreduce(&temp, &useEAM, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); | 
| 748 |  |  | 
| 749 | + | temp = useSC; | 
| 750 | + | MPI_Allreduce(&temp, &useSC, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); | 
| 751 | + |  | 
| 752 |  | temp = useShape; | 
| 753 |  | MPI_Allreduce(&temp, &useShape, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); | 
| 754 |  |  | 
| 757 |  |  | 
| 758 |  | temp = useRF; | 
| 759 |  | MPI_Allreduce(&temp, &useRF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); | 
| 760 | < |  | 
| 760 | > |  | 
| 761 | > | temp = useSF; | 
| 762 | > | MPI_Allreduce(&temp, &useSF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); | 
| 763 | > |  | 
| 764 | > | temp = useSP; | 
| 765 | > | MPI_Allreduce(&temp, &useSP, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); | 
| 766 | > |  | 
| 767 | > | temp = useBoxDipole; | 
| 768 | > | MPI_Allreduce(&temp, &useBoxDipole, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); | 
| 769 | > |  | 
| 770 |  | #endif | 
| 771 |  |  | 
| 772 |  | fInfo_.SIM_uses_PBC = usePBC; | 
| 776 |  | fInfo_.SIM_uses_Charges = useCharge; | 
| 777 |  | fInfo_.SIM_uses_Dipoles = useDipole; | 
| 778 |  | fInfo_.SIM_uses_Sticky = useSticky; | 
| 779 | + | fInfo_.SIM_uses_StickyPower = useStickyPower; | 
| 780 |  | fInfo_.SIM_uses_GayBerne = useGayBerne; | 
| 781 |  | fInfo_.SIM_uses_EAM = useEAM; | 
| 782 | + | fInfo_.SIM_uses_SC = useSC; | 
| 783 |  | fInfo_.SIM_uses_Shapes = useShape; | 
| 784 |  | fInfo_.SIM_uses_FLARB = useFLARB; | 
| 785 |  | fInfo_.SIM_uses_RF = useRF; | 
| 786 | + | fInfo_.SIM_uses_SF = useSF; | 
| 787 | + | fInfo_.SIM_uses_SP = useSP; | 
| 788 | + | fInfo_.SIM_uses_BoxDipole = useBoxDipole; | 
| 789 | + | } | 
| 790 |  |  | 
| 791 | < | if( fInfo_.SIM_uses_Dipoles && fInfo_.SIM_uses_RF) { | 
| 573 | < |  | 
| 574 | < | if (simParams_->haveDielectric()) { | 
| 575 | < | fInfo_.dielect = simParams_->getDielectric(); | 
| 576 | < | } else { | 
| 577 | < | sprintf(painCave.errMsg, | 
| 578 | < | "SimSetup Error: No Dielectric constant was set.\n" | 
| 579 | < | "\tYou are trying to use Reaction Field without" | 
| 580 | < | "\tsetting a dielectric constant!\n"); | 
| 581 | < | painCave.isFatal = 1; | 
| 582 | < | simError(); | 
| 583 | < | } | 
| 584 | < |  | 
| 585 | < | } else { | 
| 586 | < | fInfo_.dielect = 0.0; | 
| 587 | < | } | 
| 588 | < |  | 
| 589 | < | } | 
| 590 | < |  | 
| 591 | < | void SimInfo::setupFortranSim() { | 
| 791 | > | void SimInfo::setupFortranSim() { | 
| 792 |  | int isError; | 
| 793 |  | int nExclude; | 
| 794 |  | std::vector<int> fortranGlobalGroupMembership; | 
| 798 |  |  | 
| 799 |  | //globalGroupMembership_ is filled by SimCreator | 
| 800 |  | for (int i = 0; i < nGlobalAtoms_; i++) { | 
| 801 | < | fortranGlobalGroupMembership.push_back(globalGroupMembership_[i] + 1); | 
| 801 | > | fortranGlobalGroupMembership.push_back(globalGroupMembership_[i] + 1); | 
| 802 |  | } | 
| 803 |  |  | 
| 804 |  | //calculate mass ratio of cutoff group | 
| 805 | < | std::vector<double> mfact; | 
| 805 | > | std::vector<RealType> mfact; | 
| 806 |  | SimInfo::MoleculeIterator mi; | 
| 807 |  | Molecule* mol; | 
| 808 |  | Molecule::CutoffGroupIterator ci; | 
| 809 |  | CutoffGroup* cg; | 
| 810 |  | Molecule::AtomIterator ai; | 
| 811 |  | Atom* atom; | 
| 812 | < | double totalMass; | 
| 812 | > | RealType totalMass; | 
| 813 |  |  | 
| 814 |  | //to avoid memory reallocation, reserve enough space for mfact | 
| 815 |  | mfact.reserve(getNCutoffGroups()); | 
| 816 |  |  | 
| 817 |  | for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { | 
| 818 | < | for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { | 
| 818 | > | for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { | 
| 819 |  |  | 
| 820 | < | totalMass = cg->getMass(); | 
| 821 | < | for(atom = cg->beginAtom(ai); atom != NULL; atom = cg->nextAtom(ai)) { | 
| 822 | < | mfact.push_back(atom->getMass()/totalMass); | 
| 823 | < | } | 
| 820 | > | totalMass = cg->getMass(); | 
| 821 | > | for(atom = cg->beginAtom(ai); atom != NULL; atom = cg->nextAtom(ai)) { | 
| 822 | > | // Check for massless groups - set mfact to 1 if true | 
| 823 | > | if (totalMass != 0) | 
| 824 | > | mfact.push_back(atom->getMass()/totalMass); | 
| 825 | > | else | 
| 826 | > | mfact.push_back( 1.0 ); | 
| 827 | > | } | 
| 828 |  |  | 
| 829 | < | } | 
| 829 | > | } | 
| 830 |  | } | 
| 831 |  |  | 
| 832 |  | //fill ident array of local atoms (it is actually ident of AtomType, it is so confusing !!!) | 
| 836 |  | identArray.reserve(getNAtoms()); | 
| 837 |  |  | 
| 838 |  | for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { | 
| 839 | < | for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { | 
| 840 | < | identArray.push_back(atom->getIdent()); | 
| 841 | < | } | 
| 839 | > | for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { | 
| 840 | > | identArray.push_back(atom->getIdent()); | 
| 841 | > | } | 
| 842 |  | } | 
| 843 |  |  | 
| 844 |  | //fill molMembershipArray | 
| 845 |  | //molMembershipArray is filled by SimCreator | 
| 846 |  | std::vector<int> molMembershipArray(nGlobalAtoms_); | 
| 847 |  | for (int i = 0; i < nGlobalAtoms_; i++) { | 
| 848 | < | molMembershipArray[i] = globalMolMembership_[i] + 1; | 
| 848 | > | molMembershipArray[i] = globalMolMembership_[i] + 1; | 
| 849 |  | } | 
| 850 |  |  | 
| 851 |  | //setup fortran simulation | 
| 648 | – | //gloalExcludes and molMembershipArray should go away (They are never used) | 
| 649 | – | //why the hell fortran need to know molecule? | 
| 650 | – | //OOPSE = Object-Obfuscated Parallel Simulation Engine | 
| 852 |  | int nGlobalExcludes = 0; | 
| 853 |  | int* globalExcludes = NULL; | 
| 854 |  | int* excludeList = exclude_.getExcludeList(); | 
| 855 |  | setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray[0], &nExclude, excludeList , | 
| 856 | < | &nGlobalExcludes, globalExcludes, &molMembershipArray[0], | 
| 857 | < | &mfact[0], &nCutoffGroups_, &fortranGlobalGroupMembership[0], &isError); | 
| 856 | > | &nGlobalExcludes, globalExcludes, &molMembershipArray[0], | 
| 857 | > | &mfact[0], &nCutoffGroups_, &fortranGlobalGroupMembership[0], &isError); | 
| 858 |  |  | 
| 859 |  | if( isError ){ | 
| 860 |  |  | 
| 861 | < | sprintf( painCave.errMsg, | 
| 862 | < | "There was an error setting the simulation information in fortran.\n" ); | 
| 863 | < | painCave.isFatal = 1; | 
| 864 | < | painCave.severity = OOPSE_ERROR; | 
| 865 | < | simError(); | 
| 861 | > | sprintf( painCave.errMsg, | 
| 862 | > | "There was an error setting the simulation information in fortran.\n" ); | 
| 863 | > | painCave.isFatal = 1; | 
| 864 | > | painCave.severity = OOPSE_ERROR; | 
| 865 | > | simError(); | 
| 866 |  | } | 
| 867 |  |  | 
| 868 |  | #ifdef IS_MPI | 
| 869 |  | sprintf( checkPointMsg, | 
| 870 | < | "succesfully sent the simulation information to fortran.\n"); | 
| 870 | > | "succesfully sent the simulation information to fortran.\n"); | 
| 871 |  | MPIcheckPoint(); | 
| 872 |  | #endif // is_mpi | 
| 873 | < | } | 
| 873 | > |  | 
| 874 | > | // Setup number of neighbors in neighbor list if present | 
| 875 | > | if (simParams_->haveNeighborListNeighbors()) { | 
| 876 | > | int nlistNeighbors = simParams_->getNeighborListNeighbors(); | 
| 877 | > | setNeighbors(&nlistNeighbors); | 
| 878 | > | } | 
| 879 | > |  | 
| 880 |  |  | 
| 881 | + | } | 
| 882 |  |  | 
| 883 | + |  | 
| 884 |  | #ifdef IS_MPI | 
| 885 | < | void SimInfo::setupFortranParallel() { | 
| 885 | > | void SimInfo::setupFortranParallel() { | 
| 886 |  |  | 
| 887 |  | //SimInfo is responsible for creating localToGlobalAtomIndex and localToGlobalGroupIndex | 
| 888 |  | std::vector<int> localToGlobalAtomIndex(getNAtoms(), 0); | 
| 898 |  |  | 
| 899 |  | for (mol = beginMolecule(mi); mol != NULL; mol  = nextMolecule(mi)) { | 
| 900 |  |  | 
| 901 | < | //local index(index in DataStorge) of atom is important | 
| 902 | < | for (atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { | 
| 903 | < | localToGlobalAtomIndex[atom->getLocalIndex()] = atom->getGlobalIndex() + 1; | 
| 904 | < | } | 
| 901 | > | //local index(index in DataStorge) of atom is important | 
| 902 | > | for (atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { | 
| 903 | > | localToGlobalAtomIndex[atom->getLocalIndex()] = atom->getGlobalIndex() + 1; | 
| 904 | > | } | 
| 905 |  |  | 
| 906 | < | //local index of cutoff group is trivial, it only depends on the order of travesing | 
| 907 | < | for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { | 
| 908 | < | localToGlobalCutoffGroupIndex.push_back(cg->getGlobalIndex() + 1); | 
| 909 | < | } | 
| 906 | > | //local index of cutoff group is trivial, it only depends on the order of travesing | 
| 907 | > | for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { | 
| 908 | > | localToGlobalCutoffGroupIndex.push_back(cg->getGlobalIndex() + 1); | 
| 909 | > | } | 
| 910 |  |  | 
| 911 |  | } | 
| 912 |  |  | 
| 926 |  | &localToGlobalCutoffGroupIndex[0], &isError); | 
| 927 |  |  | 
| 928 |  | if (isError) { | 
| 929 | < | sprintf(painCave.errMsg, | 
| 930 | < | "mpiRefresh errror: fortran didn't like something we gave it.\n"); | 
| 931 | < | painCave.isFatal = 1; | 
| 932 | < | simError(); | 
| 929 | > | sprintf(painCave.errMsg, | 
| 930 | > | "mpiRefresh errror: fortran didn't like something we gave it.\n"); | 
| 931 | > | painCave.isFatal = 1; | 
| 932 | > | simError(); | 
| 933 |  | } | 
| 934 |  |  | 
| 935 |  | sprintf(checkPointMsg, " mpiRefresh successful.\n"); | 
| 936 |  | MPIcheckPoint(); | 
| 937 |  |  | 
| 938 |  |  | 
| 939 | < | } | 
| 939 | > | } | 
| 940 |  |  | 
| 941 |  | #endif | 
| 942 |  |  | 
| 943 | < | double SimInfo::calcMaxCutoffRadius() { | 
| 943 | > | void SimInfo::setupCutoff() { | 
| 944 | > |  | 
| 945 | > | ForceFieldOptions& forceFieldOptions_ = forceField_->getForceFieldOptions(); | 
| 946 |  |  | 
| 947 | + | // Check the cutoff policy | 
| 948 | + | int cp =  TRADITIONAL_CUTOFF_POLICY; // Set to traditional by default | 
| 949 |  |  | 
| 950 | < | std::set<AtomType*> atomTypes; | 
| 951 | < | std::set<AtomType*>::iterator i; | 
| 952 | < | std::vector<double> cutoffRadius; | 
| 953 | < |  | 
| 954 | < | //get the unique atom types | 
| 742 | < | atomTypes = getUniqueAtomTypes(); | 
| 743 | < |  | 
| 744 | < | //query the max cutoff radius among these atom types | 
| 745 | < | for (i = atomTypes.begin(); i != atomTypes.end(); ++i) { | 
| 746 | < | cutoffRadius.push_back(forceField_->getRcutFromAtomType(*i)); | 
| 950 | > | std::string myPolicy; | 
| 951 | > | if (forceFieldOptions_.haveCutoffPolicy()){ | 
| 952 | > | myPolicy = forceFieldOptions_.getCutoffPolicy(); | 
| 953 | > | }else if (simParams_->haveCutoffPolicy()) { | 
| 954 | > | myPolicy = simParams_->getCutoffPolicy(); | 
| 955 |  | } | 
| 956 |  |  | 
| 957 | < | double maxCutoffRadius = *(std::max_element(cutoffRadius.begin(), cutoffRadius.end())); | 
| 958 | < | #ifdef IS_MPI | 
| 959 | < | //pick the max cutoff radius among the processors | 
| 960 | < | #endif | 
| 957 | > | if (!myPolicy.empty()){ | 
| 958 | > | toUpper(myPolicy); | 
| 959 | > | if (myPolicy == "MIX") { | 
| 960 | > | cp = MIX_CUTOFF_POLICY; | 
| 961 | > | } else { | 
| 962 | > | if (myPolicy == "MAX") { | 
| 963 | > | cp = MAX_CUTOFF_POLICY; | 
| 964 | > | } else { | 
| 965 | > | if (myPolicy == "TRADITIONAL") { | 
| 966 | > | cp = TRADITIONAL_CUTOFF_POLICY; | 
| 967 | > | } else { | 
| 968 | > | // throw error | 
| 969 | > | sprintf( painCave.errMsg, | 
| 970 | > | "SimInfo error: Unknown cutoffPolicy. (Input file specified %s .)\n\tcutoffPolicy must be one of: \"Mix\", \"Max\", or \"Traditional\".", myPolicy.c_str() ); | 
| 971 | > | painCave.isFatal = 1; | 
| 972 | > | simError(); | 
| 973 | > | } | 
| 974 | > | } | 
| 975 | > | } | 
| 976 | > | } | 
| 977 | > | notifyFortranCutoffPolicy(&cp); | 
| 978 |  |  | 
| 979 | < | return maxCutoffRadius; | 
| 980 | < | } | 
| 981 | < |  | 
| 982 | < | void SimInfo::getCutoff(double& rcut, double& rsw) { | 
| 983 | < |  | 
| 984 | < | if (fInfo_.SIM_uses_Charges | fInfo_.SIM_uses_Dipoles | fInfo_.SIM_uses_RF) { | 
| 979 | > | // Check the Skin Thickness for neighborlists | 
| 980 | > | RealType skin; | 
| 981 | > | if (simParams_->haveSkinThickness()) { | 
| 982 | > | skin = simParams_->getSkinThickness(); | 
| 983 | > | notifyFortranSkinThickness(&skin); | 
| 984 | > | } | 
| 985 |  |  | 
| 986 | < | if (!simParams_->haveRcut()){ | 
| 987 | < | sprintf(painCave.errMsg, | 
| 986 | > | // Check if the cutoff was set explicitly: | 
| 987 | > | if (simParams_->haveCutoffRadius()) { | 
| 988 | > | rcut_ = simParams_->getCutoffRadius(); | 
| 989 | > | if (simParams_->haveSwitchingRadius()) { | 
| 990 | > | rsw_  = simParams_->getSwitchingRadius(); | 
| 991 | > | } else { | 
| 992 | > | if (fInfo_.SIM_uses_Charges | | 
| 993 | > | fInfo_.SIM_uses_Dipoles | | 
| 994 | > | fInfo_.SIM_uses_RF) { | 
| 995 | > |  | 
| 996 | > | rsw_ = 0.85 * rcut_; | 
| 997 | > | sprintf(painCave.errMsg, | 
| 998 | > | "SimCreator Warning: No value was set for the switchingRadius.\n" | 
| 999 | > | "\tOOPSE will use a default value of 85 percent of the cutoffRadius.\n" | 
| 1000 | > | "\tswitchingRadius = %f. for this simulation\n", rsw_); | 
| 1001 | > | painCave.isFatal = 0; | 
| 1002 | > | simError(); | 
| 1003 | > | } else { | 
| 1004 | > | rsw_ = rcut_; | 
| 1005 | > | sprintf(painCave.errMsg, | 
| 1006 | > | "SimCreator Warning: No value was set for the switchingRadius.\n" | 
| 1007 | > | "\tOOPSE will use the same value as the cutoffRadius.\n" | 
| 1008 | > | "\tswitchingRadius = %f. for this simulation\n", rsw_); | 
| 1009 | > | painCave.isFatal = 0; | 
| 1010 | > | simError(); | 
| 1011 | > | } | 
| 1012 | > | } | 
| 1013 | > |  | 
| 1014 | > | notifyFortranCutoffs(&rcut_, &rsw_); | 
| 1015 | > |  | 
| 1016 | > | } else { | 
| 1017 | > |  | 
| 1018 | > | // For electrostatic atoms, we'll assume a large safe value: | 
| 1019 | > | if (fInfo_.SIM_uses_Charges | fInfo_.SIM_uses_Dipoles | fInfo_.SIM_uses_RF) { | 
| 1020 | > | sprintf(painCave.errMsg, | 
| 1021 |  | "SimCreator Warning: No value was set for the cutoffRadius.\n" | 
| 1022 |  | "\tOOPSE will use a default value of 15.0 angstroms" | 
| 1023 |  | "\tfor the cutoffRadius.\n"); | 
| 1024 | < | painCave.isFatal = 0; | 
| 1025 | < | simError(); | 
| 1026 | < | rcut_ = 15.0; | 
| 1027 | < | } else{ | 
| 1028 | < | rcut_ = simParams_->getRcut(); | 
| 1024 | > | painCave.isFatal = 0; | 
| 1025 | > | simError(); | 
| 1026 | > | rcut_ = 15.0; | 
| 1027 | > |  | 
| 1028 | > | if (simParams_->haveElectrostaticSummationMethod()) { | 
| 1029 | > | std::string myMethod = simParams_->getElectrostaticSummationMethod(); | 
| 1030 | > | toUpper(myMethod); | 
| 1031 | > | if (myMethod == "SHIFTED_POTENTIAL" || myMethod == "SHIFTED_FORCE") { | 
| 1032 | > | if (simParams_->haveSwitchingRadius()){ | 
| 1033 | > | sprintf(painCave.errMsg, | 
| 1034 | > | "SimInfo Warning: A value was set for the switchingRadius\n" | 
| 1035 | > | "\teven though the electrostaticSummationMethod was\n" | 
| 1036 | > | "\tset to %s\n", myMethod.c_str()); | 
| 1037 | > | painCave.isFatal = 1; | 
| 1038 | > | simError(); | 
| 1039 | > | } | 
| 1040 | > | } | 
| 1041 |  | } | 
| 1042 | < |  | 
| 1043 | < | if (!simParams_->haveRsw()){ | 
| 1044 | < | sprintf(painCave.errMsg, | 
| 1045 | < | "SimCreator Warning: No value was set for switchingRadius.\n" | 
| 1046 | < | "\tOOPSE will use a default value of\n" | 
| 1047 | < | "\t0.95 * cutoffRadius for the switchingRadius\n"); | 
| 1048 | < | painCave.isFatal = 0; | 
| 1049 | < | simError(); | 
| 1050 | < | rsw_ = 0.95 * rcut_; | 
| 1051 | < | } else{ | 
| 1052 | < | rsw_ = simParams_->getRsw(); | 
| 1042 | > |  | 
| 1043 | > | if (simParams_->haveSwitchingRadius()){ | 
| 1044 | > | rsw_ = simParams_->getSwitchingRadius(); | 
| 1045 | > | } else { | 
| 1046 | > | sprintf(painCave.errMsg, | 
| 1047 | > | "SimCreator Warning: No value was set for switchingRadius.\n" | 
| 1048 | > | "\tOOPSE will use a default value of\n" | 
| 1049 | > | "\t0.85 * cutoffRadius for the switchingRadius\n"); | 
| 1050 | > | painCave.isFatal = 0; | 
| 1051 | > | simError(); | 
| 1052 | > | rsw_ = 0.85 * rcut_; | 
| 1053 |  | } | 
| 1054 | < |  | 
| 1055 | < | } else { | 
| 1056 | < | // if charge, dipole or reaction field is not used and the cutofff radius is not specified in | 
| 1057 | < | //meta-data file, the maximum cutoff radius calculated from forcefiled will be used | 
| 1054 | > | notifyFortranCutoffs(&rcut_, &rsw_); | 
| 1055 | > | } else { | 
| 1056 | > | // We didn't set rcut explicitly, and we don't have electrostatic atoms, so | 
| 1057 | > | // We'll punt and let fortran figure out the cutoffs later. | 
| 1058 |  |  | 
| 1059 | < | if (simParams_->haveRcut()) { | 
| 790 | < | rcut_ = simParams_->getRcut(); | 
| 791 | < | } else { | 
| 792 | < | //set cutoff radius to the maximum cutoff radius based on atom types in the whole system | 
| 793 | < | rcut_ = calcMaxCutoffRadius(); | 
| 794 | < | } | 
| 1059 | > | notifyFortranYouAreOnYourOwn(); | 
| 1060 |  |  | 
| 1061 | < | if (simParams_->haveRsw()) { | 
| 1062 | < | rsw_  = simParams_->getRsw(); | 
| 1061 | > | } | 
| 1062 | > | } | 
| 1063 | > | } | 
| 1064 | > |  | 
| 1065 | > | void SimInfo::setupElectrostaticSummationMethod( int isError ) { | 
| 1066 | > |  | 
| 1067 | > | int errorOut; | 
| 1068 | > | int esm =  NONE; | 
| 1069 | > | int sm = UNDAMPED; | 
| 1070 | > | RealType alphaVal; | 
| 1071 | > | RealType dielectric; | 
| 1072 | > |  | 
| 1073 | > | errorOut = isError; | 
| 1074 | > |  | 
| 1075 | > | if (simParams_->haveElectrostaticSummationMethod()) { | 
| 1076 | > | std::string myMethod = simParams_->getElectrostaticSummationMethod(); | 
| 1077 | > | toUpper(myMethod); | 
| 1078 | > | if (myMethod == "NONE") { | 
| 1079 | > | esm = NONE; | 
| 1080 | > | } else { | 
| 1081 | > | if (myMethod == "SWITCHING_FUNCTION") { | 
| 1082 | > | esm = SWITCHING_FUNCTION; | 
| 1083 |  | } else { | 
| 1084 | < | rsw_ = rcut_; | 
| 1085 | < | } | 
| 1084 | > | if (myMethod == "SHIFTED_POTENTIAL") { | 
| 1085 | > | esm = SHIFTED_POTENTIAL; | 
| 1086 | > | } else { | 
| 1087 | > | if (myMethod == "SHIFTED_FORCE") { | 
| 1088 | > | esm = SHIFTED_FORCE; | 
| 1089 | > | } else { | 
| 1090 | > | if (myMethod == "REACTION_FIELD") { | 
| 1091 | > | esm = REACTION_FIELD; | 
| 1092 | > | dielectric = simParams_->getDielectric(); | 
| 1093 | > | if (!simParams_->haveDielectric()) { | 
| 1094 | > | // throw warning | 
| 1095 | > | sprintf( painCave.errMsg, | 
| 1096 | > | "SimInfo warning: dielectric was not specified in the input file\n\tfor the reaction field correction method.\n" | 
| 1097 | > | "\tA default value of %f will be used for the dielectric.\n", dielectric); | 
| 1098 | > | painCave.isFatal = 0; | 
| 1099 | > | simError(); | 
| 1100 | > | } | 
| 1101 | > | } else { | 
| 1102 | > | // throw error | 
| 1103 | > | sprintf( painCave.errMsg, | 
| 1104 | > | "SimInfo error: Unknown electrostaticSummationMethod.\n" | 
| 1105 | > | "\t(Input file specified %s .)\n" | 
| 1106 | > | "\telectrostaticSummationMethod must be one of: \"none\",\n" | 
| 1107 | > | "\t\"shifted_potential\", \"shifted_force\", or \n" | 
| 1108 | > | "\t\"reaction_field\".\n", myMethod.c_str() ); | 
| 1109 | > | painCave.isFatal = 1; | 
| 1110 | > | simError(); | 
| 1111 | > | } | 
| 1112 | > | } | 
| 1113 | > | } | 
| 1114 | > | } | 
| 1115 | > | } | 
| 1116 | > | } | 
| 1117 |  |  | 
| 1118 | + | if (simParams_->haveElectrostaticScreeningMethod()) { | 
| 1119 | + | std::string myScreen = simParams_->getElectrostaticScreeningMethod(); | 
| 1120 | + | toUpper(myScreen); | 
| 1121 | + | if (myScreen == "UNDAMPED") { | 
| 1122 | + | sm = UNDAMPED; | 
| 1123 | + | } else { | 
| 1124 | + | if (myScreen == "DAMPED") { | 
| 1125 | + | sm = DAMPED; | 
| 1126 | + | if (!simParams_->haveDampingAlpha()) { | 
| 1127 | + | // first set a cutoff dependent alpha value | 
| 1128 | + | // we assume alpha depends linearly with rcut from 0 to 20.5 ang | 
| 1129 | + | alphaVal = 0.5125 - rcut_* 0.025; | 
| 1130 | + | // for values rcut > 20.5, alpha is zero | 
| 1131 | + | if (alphaVal < 0) alphaVal = 0; | 
| 1132 | + |  | 
| 1133 | + | // throw warning | 
| 1134 | + | sprintf( painCave.errMsg, | 
| 1135 | + | "SimInfo warning: dampingAlpha was not specified in the input file.\n" | 
| 1136 | + | "\tA default value of %f (1/ang) will be used for the cutoff of\n\t%f (ang).\n", alphaVal, rcut_); | 
| 1137 | + | painCave.isFatal = 0; | 
| 1138 | + | simError(); | 
| 1139 | + | } else { | 
| 1140 | + | alphaVal = simParams_->getDampingAlpha(); | 
| 1141 | + | } | 
| 1142 | + |  | 
| 1143 | + | } else { | 
| 1144 | + | // throw error | 
| 1145 | + | sprintf( painCave.errMsg, | 
| 1146 | + | "SimInfo error: Unknown electrostaticScreeningMethod.\n" | 
| 1147 | + | "\t(Input file specified %s .)\n" | 
| 1148 | + | "\telectrostaticScreeningMethod must be one of: \"undamped\"\n" | 
| 1149 | + | "or \"damped\".\n", myScreen.c_str() ); | 
| 1150 | + | painCave.isFatal = 1; | 
| 1151 | + | simError(); | 
| 1152 | + | } | 
| 1153 | + | } | 
| 1154 |  | } | 
| 1155 | < | } | 
| 1155 | > |  | 
| 1156 | > | // let's pass some summation method variables to fortran | 
| 1157 | > | setElectrostaticSummationMethod( &esm ); | 
| 1158 | > | setFortranElectrostaticMethod( &esm ); | 
| 1159 | > | setScreeningMethod( &sm ); | 
| 1160 | > | setDampingAlpha( &alphaVal ); | 
| 1161 | > | setReactionFieldDielectric( &dielectric ); | 
| 1162 | > | initFortranFF( &errorOut ); | 
| 1163 | > | } | 
| 1164 |  |  | 
| 1165 | < | void SimInfo::setupCutoff() { | 
| 1166 | < | getCutoff(rcut_, rsw_); | 
| 807 | < | double rnblist = rcut_ + 1; // skin of neighbor list | 
| 1165 | > | void SimInfo::setupSwitchingFunction() { | 
| 1166 | > | int ft = CUBIC; | 
| 1167 |  |  | 
| 1168 | < | //Pass these cutoff radius etc. to fortran. This function should be called once and only once | 
| 1169 | < | notifyFortranCutoffs(&rcut_, &rsw_, &rnblist); | 
| 1170 | < | } | 
| 1168 | > | if (simParams_->haveSwitchingFunctionType()) { | 
| 1169 | > | std::string funcType = simParams_->getSwitchingFunctionType(); | 
| 1170 | > | toUpper(funcType); | 
| 1171 | > | if (funcType == "CUBIC") { | 
| 1172 | > | ft = CUBIC; | 
| 1173 | > | } else { | 
| 1174 | > | if (funcType == "FIFTH_ORDER_POLYNOMIAL") { | 
| 1175 | > | ft = FIFTH_ORDER_POLY; | 
| 1176 | > | } else { | 
| 1177 | > | // throw error | 
| 1178 | > | sprintf( painCave.errMsg, | 
| 1179 | > | "SimInfo error: Unknown switchingFunctionType. (Input file specified %s .)\n\tswitchingFunctionType must be one of: \"cubic\" or \"fifth_order_polynomial\".", funcType.c_str() ); | 
| 1180 | > | painCave.isFatal = 1; | 
| 1181 | > | simError(); | 
| 1182 | > | } | 
| 1183 | > | } | 
| 1184 | > | } | 
| 1185 |  |  | 
| 1186 | < | void SimInfo::addProperty(GenericData* genData) { | 
| 1187 | < | properties_.addProperty(genData); | 
| 815 | < | } | 
| 1186 | > | // send switching function notification to switcheroo | 
| 1187 | > | setFunctionType(&ft); | 
| 1188 |  |  | 
| 1189 | < | void SimInfo::removeProperty(const std::string& propName) { | 
| 1190 | < | properties_.removeProperty(propName); | 
| 1191 | < | } | 
| 1192 | < |  | 
| 1193 | < | void SimInfo::clearProperties() { | 
| 1189 | > | } | 
| 1190 | > |  | 
| 1191 | > | void SimInfo::setupAccumulateBoxDipole() { | 
| 1192 | > |  | 
| 1193 | > | // we only call setAccumulateBoxDipole if the accumulateBoxDipole parameter is true | 
| 1194 | > | if ( simParams_->haveAccumulateBoxDipole() ) | 
| 1195 | > | if ( simParams_->getAccumulateBoxDipole() ) { | 
| 1196 | > | setAccumulateBoxDipole(); | 
| 1197 | > | calcBoxDipole_ = true; | 
| 1198 | > | } | 
| 1199 | > |  | 
| 1200 | > | } | 
| 1201 | > |  | 
| 1202 | > | void SimInfo::addProperty(GenericData* genData) { | 
| 1203 | > | properties_.addProperty(genData); | 
| 1204 | > | } | 
| 1205 | > |  | 
| 1206 | > | void SimInfo::removeProperty(const std::string& propName) { | 
| 1207 | > | properties_.removeProperty(propName); | 
| 1208 | > | } | 
| 1209 | > |  | 
| 1210 | > | void SimInfo::clearProperties() { | 
| 1211 |  | properties_.clearProperties(); | 
| 1212 | < | } | 
| 1212 | > | } | 
| 1213 |  |  | 
| 1214 | < | std::vector<std::string> SimInfo::getPropertyNames() { | 
| 1214 | > | std::vector<std::string> SimInfo::getPropertyNames() { | 
| 1215 |  | return properties_.getPropertyNames(); | 
| 1216 | < | } | 
| 1216 | > | } | 
| 1217 |  |  | 
| 1218 | < | std::vector<GenericData*> SimInfo::getProperties() { | 
| 1218 | > | std::vector<GenericData*> SimInfo::getProperties() { | 
| 1219 |  | return properties_.getProperties(); | 
| 1220 | < | } | 
| 1220 | > | } | 
| 1221 |  |  | 
| 1222 | < | GenericData* SimInfo::getPropertyByName(const std::string& propName) { | 
| 1222 | > | GenericData* SimInfo::getPropertyByName(const std::string& propName) { | 
| 1223 |  | return properties_.getPropertyByName(propName); | 
| 1224 | < | } | 
| 1224 | > | } | 
| 1225 |  |  | 
| 1226 | < | void SimInfo::setSnapshotManager(SnapshotManager* sman) { | 
| 1226 | > | void SimInfo::setSnapshotManager(SnapshotManager* sman) { | 
| 1227 | > | if (sman_ == sman) { | 
| 1228 | > | return; | 
| 1229 | > | } | 
| 1230 | > | delete sman_; | 
| 1231 |  | sman_ = sman; | 
| 1232 |  |  | 
| 1233 |  | Molecule* mol; | 
| 1239 |  |  | 
| 1240 |  | for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { | 
| 1241 |  |  | 
| 1242 | < | for (atom = mol->beginAtom(atomIter); atom != NULL; atom = mol->nextAtom(atomIter)) { | 
| 1243 | < | atom->setSnapshotManager(sman_); | 
| 1244 | < | } | 
| 1242 | > | for (atom = mol->beginAtom(atomIter); atom != NULL; atom = mol->nextAtom(atomIter)) { | 
| 1243 | > | atom->setSnapshotManager(sman_); | 
| 1244 | > | } | 
| 1245 |  |  | 
| 1246 | < | for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { | 
| 1247 | < | rb->setSnapshotManager(sman_); | 
| 1248 | < | } | 
| 1246 | > | for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { | 
| 1247 | > | rb->setSnapshotManager(sman_); | 
| 1248 | > | } | 
| 1249 |  | } | 
| 1250 |  |  | 
| 1251 | < | } | 
| 1251 | > | } | 
| 1252 |  |  | 
| 1253 | < | Vector3d SimInfo::getComVel(){ | 
| 1253 | > | Vector3d SimInfo::getComVel(){ | 
| 1254 |  | SimInfo::MoleculeIterator i; | 
| 1255 |  | Molecule* mol; | 
| 1256 |  |  | 
| 1257 |  | Vector3d comVel(0.0); | 
| 1258 | < | double totalMass = 0.0; | 
| 1258 | > | RealType totalMass = 0.0; | 
| 1259 |  |  | 
| 1260 |  |  | 
| 1261 |  | for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { | 
| 1262 | < | double mass = mol->getMass(); | 
| 1263 | < | totalMass += mass; | 
| 1264 | < | comVel += mass * mol->getComVel(); | 
| 1262 | > | RealType mass = mol->getMass(); | 
| 1263 | > | totalMass += mass; | 
| 1264 | > | comVel += mass * mol->getComVel(); | 
| 1265 |  | } | 
| 1266 |  |  | 
| 1267 |  | #ifdef IS_MPI | 
| 1268 | < | double tmpMass = totalMass; | 
| 1268 | > | RealType tmpMass = totalMass; | 
| 1269 |  | Vector3d tmpComVel(comVel); | 
| 1270 | < | MPI_Allreduce(&tmpMass,&totalMass,1,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); | 
| 1271 | < | MPI_Allreduce(tmpComVel.getArrayPointer(), comVel.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); | 
| 1270 | > | MPI_Allreduce(&tmpMass,&totalMass,1,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); | 
| 1271 | > | MPI_Allreduce(tmpComVel.getArrayPointer(), comVel.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); | 
| 1272 |  | #endif | 
| 1273 |  |  | 
| 1274 |  | comVel /= totalMass; | 
| 1275 |  |  | 
| 1276 |  | return comVel; | 
| 1277 | < | } | 
| 1277 | > | } | 
| 1278 |  |  | 
| 1279 | < | Vector3d SimInfo::getCom(){ | 
| 1279 | > | Vector3d SimInfo::getCom(){ | 
| 1280 |  | SimInfo::MoleculeIterator i; | 
| 1281 |  | Molecule* mol; | 
| 1282 |  |  | 
| 1283 |  | Vector3d com(0.0); | 
| 1284 | < | double totalMass = 0.0; | 
| 1284 | > | RealType totalMass = 0.0; | 
| 1285 |  |  | 
| 1286 |  | for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { | 
| 1287 | < | double mass = mol->getMass(); | 
| 1288 | < | totalMass += mass; | 
| 1289 | < | com += mass * mol->getCom(); | 
| 1287 | > | RealType mass = mol->getMass(); | 
| 1288 | > | totalMass += mass; | 
| 1289 | > | com += mass * mol->getCom(); | 
| 1290 |  | } | 
| 1291 |  |  | 
| 1292 |  | #ifdef IS_MPI | 
| 1293 | < | double tmpMass = totalMass; | 
| 1293 | > | RealType tmpMass = totalMass; | 
| 1294 |  | Vector3d tmpCom(com); | 
| 1295 | < | MPI_Allreduce(&tmpMass,&totalMass,1,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); | 
| 1296 | < | MPI_Allreduce(tmpCom.getArrayPointer(), com.getArrayPointer(),3,MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); | 
| 1295 | > | MPI_Allreduce(&tmpMass,&totalMass,1,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); | 
| 1296 | > | MPI_Allreduce(tmpCom.getArrayPointer(), com.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); | 
| 1297 |  | #endif | 
| 1298 |  |  | 
| 1299 |  | com /= totalMass; | 
| 1300 |  |  | 
| 1301 |  | return com; | 
| 1302 |  |  | 
| 1303 | < | } | 
| 1303 | > | } | 
| 1304 |  |  | 
| 1305 | < | std::ostream& operator <<(std::ostream& o, SimInfo& info) { | 
| 1305 | > | std::ostream& operator <<(std::ostream& o, SimInfo& info) { | 
| 1306 |  |  | 
| 1307 |  | return o; | 
| 1308 | < | } | 
| 1308 | > | } | 
| 1309 | > |  | 
| 1310 | > |  | 
| 1311 | > | /* | 
| 1312 | > | Returns center of mass and center of mass velocity in one function call. | 
| 1313 | > | */ | 
| 1314 | > |  | 
| 1315 | > | void SimInfo::getComAll(Vector3d &com, Vector3d &comVel){ | 
| 1316 | > | SimInfo::MoleculeIterator i; | 
| 1317 | > | Molecule* mol; | 
| 1318 | > |  | 
| 1319 | > |  | 
| 1320 | > | RealType totalMass = 0.0; | 
| 1321 | > |  | 
| 1322 |  |  | 
| 1323 | + | for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { | 
| 1324 | + | RealType mass = mol->getMass(); | 
| 1325 | + | totalMass += mass; | 
| 1326 | + | com += mass * mol->getCom(); | 
| 1327 | + | comVel += mass * mol->getComVel(); | 
| 1328 | + | } | 
| 1329 | + |  | 
| 1330 | + | #ifdef IS_MPI | 
| 1331 | + | RealType tmpMass = totalMass; | 
| 1332 | + | Vector3d tmpCom(com); | 
| 1333 | + | Vector3d tmpComVel(comVel); | 
| 1334 | + | MPI_Allreduce(&tmpMass,&totalMass,1,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); | 
| 1335 | + | MPI_Allreduce(tmpCom.getArrayPointer(), com.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); | 
| 1336 | + | MPI_Allreduce(tmpComVel.getArrayPointer(), comVel.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); | 
| 1337 | + | #endif | 
| 1338 | + |  | 
| 1339 | + | com /= totalMass; | 
| 1340 | + | comVel /= totalMass; | 
| 1341 | + | } | 
| 1342 | + |  | 
| 1343 | + | /* | 
| 1344 | + | Return intertia tensor for entire system and angular momentum Vector. | 
| 1345 | + |  | 
| 1346 | + |  | 
| 1347 | + | [  Ixx -Ixy  -Ixz ] | 
| 1348 | + | J =| -Iyx  Iyy  -Iyz | | 
| 1349 | + | [ -Izx -Iyz   Izz ] | 
| 1350 | + | */ | 
| 1351 | + |  | 
| 1352 | + | void SimInfo::getInertiaTensor(Mat3x3d &inertiaTensor, Vector3d &angularMomentum){ | 
| 1353 | + |  | 
| 1354 | + |  | 
| 1355 | + | RealType xx = 0.0; | 
| 1356 | + | RealType yy = 0.0; | 
| 1357 | + | RealType zz = 0.0; | 
| 1358 | + | RealType xy = 0.0; | 
| 1359 | + | RealType xz = 0.0; | 
| 1360 | + | RealType yz = 0.0; | 
| 1361 | + | Vector3d com(0.0); | 
| 1362 | + | Vector3d comVel(0.0); | 
| 1363 | + |  | 
| 1364 | + | getComAll(com, comVel); | 
| 1365 | + |  | 
| 1366 | + | SimInfo::MoleculeIterator i; | 
| 1367 | + | Molecule* mol; | 
| 1368 | + |  | 
| 1369 | + | Vector3d thisq(0.0); | 
| 1370 | + | Vector3d thisv(0.0); | 
| 1371 | + |  | 
| 1372 | + | RealType thisMass = 0.0; | 
| 1373 | + |  | 
| 1374 | + |  | 
| 1375 | + |  | 
| 1376 | + |  | 
| 1377 | + | for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { | 
| 1378 | + |  | 
| 1379 | + | thisq = mol->getCom()-com; | 
| 1380 | + | thisv = mol->getComVel()-comVel; | 
| 1381 | + | thisMass = mol->getMass(); | 
| 1382 | + | // Compute moment of intertia coefficients. | 
| 1383 | + | xx += thisq[0]*thisq[0]*thisMass; | 
| 1384 | + | yy += thisq[1]*thisq[1]*thisMass; | 
| 1385 | + | zz += thisq[2]*thisq[2]*thisMass; | 
| 1386 | + |  | 
| 1387 | + | // compute products of intertia | 
| 1388 | + | xy += thisq[0]*thisq[1]*thisMass; | 
| 1389 | + | xz += thisq[0]*thisq[2]*thisMass; | 
| 1390 | + | yz += thisq[1]*thisq[2]*thisMass; | 
| 1391 | + |  | 
| 1392 | + | angularMomentum += cross( thisq, thisv ) * thisMass; | 
| 1393 | + |  | 
| 1394 | + | } | 
| 1395 | + |  | 
| 1396 | + |  | 
| 1397 | + | inertiaTensor(0,0) = yy + zz; | 
| 1398 | + | inertiaTensor(0,1) = -xy; | 
| 1399 | + | inertiaTensor(0,2) = -xz; | 
| 1400 | + | inertiaTensor(1,0) = -xy; | 
| 1401 | + | inertiaTensor(1,1) = xx + zz; | 
| 1402 | + | inertiaTensor(1,2) = -yz; | 
| 1403 | + | inertiaTensor(2,0) = -xz; | 
| 1404 | + | inertiaTensor(2,1) = -yz; | 
| 1405 | + | inertiaTensor(2,2) = xx + yy; | 
| 1406 | + |  | 
| 1407 | + | #ifdef IS_MPI | 
| 1408 | + | Mat3x3d tmpI(inertiaTensor); | 
| 1409 | + | Vector3d tmpAngMom; | 
| 1410 | + | MPI_Allreduce(tmpI.getArrayPointer(), inertiaTensor.getArrayPointer(),9,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); | 
| 1411 | + | MPI_Allreduce(tmpAngMom.getArrayPointer(), angularMomentum.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); | 
| 1412 | + | #endif | 
| 1413 | + |  | 
| 1414 | + | return; | 
| 1415 | + | } | 
| 1416 | + |  | 
| 1417 | + | //Returns the angular momentum of the system | 
| 1418 | + | Vector3d SimInfo::getAngularMomentum(){ | 
| 1419 | + |  | 
| 1420 | + | Vector3d com(0.0); | 
| 1421 | + | Vector3d comVel(0.0); | 
| 1422 | + | Vector3d angularMomentum(0.0); | 
| 1423 | + |  | 
| 1424 | + | getComAll(com,comVel); | 
| 1425 | + |  | 
| 1426 | + | SimInfo::MoleculeIterator i; | 
| 1427 | + | Molecule* mol; | 
| 1428 | + |  | 
| 1429 | + | Vector3d thisr(0.0); | 
| 1430 | + | Vector3d thisp(0.0); | 
| 1431 | + |  | 
| 1432 | + | RealType thisMass; | 
| 1433 | + |  | 
| 1434 | + | for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { | 
| 1435 | + | thisMass = mol->getMass(); | 
| 1436 | + | thisr = mol->getCom()-com; | 
| 1437 | + | thisp = (mol->getComVel()-comVel)*thisMass; | 
| 1438 | + |  | 
| 1439 | + | angularMomentum += cross( thisr, thisp ); | 
| 1440 | + |  | 
| 1441 | + | } | 
| 1442 | + |  | 
| 1443 | + | #ifdef IS_MPI | 
| 1444 | + | Vector3d tmpAngMom; | 
| 1445 | + | MPI_Allreduce(tmpAngMom.getArrayPointer(), angularMomentum.getArrayPointer(),3,MPI_REALTYPE,MPI_SUM, MPI_COMM_WORLD); | 
| 1446 | + | #endif | 
| 1447 | + |  | 
| 1448 | + | return angularMomentum; | 
| 1449 | + | } | 
| 1450 | + |  | 
| 1451 | + | StuntDouble* SimInfo::getIOIndexToIntegrableObject(int index) { | 
| 1452 | + | return IOIndexToIntegrableObject.at(index); | 
| 1453 | + | } | 
| 1454 | + |  | 
| 1455 | + | void SimInfo::setIOIndexToIntegrableObject(const std::vector<StuntDouble*>& v) { | 
| 1456 | + | IOIndexToIntegrableObject= v; | 
| 1457 | + | } | 
| 1458 | + |  | 
| 1459 | + | /* Returns the Volume of the simulation based on a ellipsoid with semi-axes | 
| 1460 | + | based on the radius of gyration V=4/3*Pi*R_1*R_2*R_3 | 
| 1461 | + | where R_i are related to the principle inertia moments R_i = sqrt(C*I_i/N), this reduces to | 
| 1462 | + | V = 4/3*Pi*(C/N)^3/2*sqrt(det(I)). See S.E. Baltazar et. al. Comp. Mat. Sci. 37 (2006) 526-536. | 
| 1463 | + | */ | 
| 1464 | + | void SimInfo::getGyrationalVolume(RealType &volume){ | 
| 1465 | + | Mat3x3d intTensor; | 
| 1466 | + | RealType det; | 
| 1467 | + | Vector3d dummyAngMom; | 
| 1468 | + | RealType sysconstants; | 
| 1469 | + | RealType geomCnst; | 
| 1470 | + |  | 
| 1471 | + | geomCnst = 3.0/2.0; | 
| 1472 | + | /* Get the inertial tensor and angular momentum for free*/ | 
| 1473 | + | getInertiaTensor(intTensor,dummyAngMom); | 
| 1474 | + |  | 
| 1475 | + | det = intTensor.determinant(); | 
| 1476 | + | sysconstants = geomCnst/(RealType)nGlobalIntegrableObjects_; | 
| 1477 | + | volume = 4.0/3.0*NumericConstant::PI*pow(sysconstants,3.0/2.0)*sqrt(det); | 
| 1478 | + | return; | 
| 1479 | + | } | 
| 1480 | + |  | 
| 1481 | + | void SimInfo::getGyrationalVolume(RealType &volume, RealType &detI){ | 
| 1482 | + | Mat3x3d intTensor; | 
| 1483 | + | Vector3d dummyAngMom; | 
| 1484 | + | RealType sysconstants; | 
| 1485 | + | RealType geomCnst; | 
| 1486 | + |  | 
| 1487 | + | geomCnst = 3.0/2.0; | 
| 1488 | + | /* Get the inertial tensor and angular momentum for free*/ | 
| 1489 | + | getInertiaTensor(intTensor,dummyAngMom); | 
| 1490 | + |  | 
| 1491 | + | detI = intTensor.determinant(); | 
| 1492 | + | sysconstants = geomCnst/(RealType)nGlobalIntegrableObjects_; | 
| 1493 | + | volume = 4.0/3.0*NumericConstant::PI*pow(sysconstants,3.0/2.0)*sqrt(detI); | 
| 1494 | + | return; | 
| 1495 | + | } | 
| 1496 | + | /* | 
| 1497 | + | void SimInfo::setStuntDoubleFromGlobalIndex(std::vector<StuntDouble*> v) { | 
| 1498 | + | assert( v.size() == nAtoms_ + nRigidBodies_); | 
| 1499 | + | sdByGlobalIndex_ = v; | 
| 1500 | + | } | 
| 1501 | + |  | 
| 1502 | + | StuntDouble* SimInfo::getStuntDoubleFromGlobalIndex(int index) { | 
| 1503 | + | //assert(index < nAtoms_ + nRigidBodies_); | 
| 1504 | + | return sdByGlobalIndex_.at(index); | 
| 1505 | + | } | 
| 1506 | + | */ | 
| 1507 |  | }//end namespace oopse | 
| 1508 |  |  |