| 1 | gezelter | 507 | /* | 
| 2 | gezelter | 246 | * 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 | gezelter | 1390 | * 1. Redistributions of source code must retain the above copyright | 
| 10 | gezelter | 246 | *    notice, this list of conditions and the following disclaimer. | 
| 11 |  |  | * | 
| 12 | gezelter | 1390 | * 2. Redistributions in binary form must reproduce the above copyright | 
| 13 | gezelter | 246 | *    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 | gezelter | 1390 | * | 
| 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 | gezelter | 1879 | * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). | 
| 39 | gezelter | 1782 | * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010). | 
| 40 |  |  | * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). | 
| 41 | gezelter | 246 | */ | 
| 42 |  |  |  | 
| 43 |  |  | /** | 
| 44 |  |  | * @file SimInfo.hpp | 
| 45 |  |  | * @author    tlin | 
| 46 |  |  | * @date  11/02/2004 | 
| 47 |  |  | * @version 1.0 | 
| 48 |  |  | */ | 
| 49 | gezelter | 2 |  | 
| 50 | gezelter | 246 | #ifndef BRAINS_SIMMODEL_HPP | 
| 51 |  |  | #define BRAINS_SIMMODEL_HPP | 
| 52 |  |  |  | 
| 53 |  |  | #include <iostream> | 
| 54 |  |  | #include <set> | 
| 55 |  |  | #include <utility> | 
| 56 | gezelter | 2 | #include <vector> | 
| 57 |  |  |  | 
| 58 | gezelter | 1287 | #include "brains/PairList.hpp" | 
| 59 | gezelter | 246 | #include "io/Globals.hpp" | 
| 60 |  |  | #include "math/Vector3.hpp" | 
| 61 | chuckv | 555 | #include "math/SquareMatrix3.hpp" | 
| 62 | gezelter | 246 | #include "types/MoleculeStamp.hpp" | 
| 63 | gezelter | 1782 | #include "brains/ForceField.hpp" | 
| 64 | gezelter | 246 | #include "utils/PropertyMap.hpp" | 
| 65 |  |  | #include "utils/LocalIndexManager.hpp" | 
| 66 | gezelter | 1782 | #include "nonbonded/SwitchingFunction.hpp" | 
| 67 | tim | 316 |  | 
| 68 | gezelter | 1782 | using namespace std; | 
| 69 | gezelter | 1390 | namespace OpenMD{ | 
| 70 | gezelter | 1782 | //forward declaration | 
| 71 | gezelter | 507 | class SnapshotManager; | 
| 72 |  |  | class Molecule; | 
| 73 |  |  | class SelectionManager; | 
| 74 | tim | 1024 | class StuntDouble; | 
| 75 | gezelter | 1782 |  | 
| 76 | gezelter | 507 | /** | 
| 77 | gezelter | 1782 | * @class SimInfo SimInfo.hpp "brains/SimInfo.hpp" | 
| 78 |  |  | * | 
| 79 |  |  | * @brief One of the heavy-weight classes of OpenMD, SimInfo | 
| 80 |  |  | * maintains objects and variables relating to the current | 
| 81 |  |  | * simulation.  This includes the master list of Molecules.  The | 
| 82 |  |  | * Molecule class maintains all of the concrete objects (Atoms, | 
| 83 |  |  | * Bond, Bend, Torsions, Inversions, RigidBodies, CutoffGroups, | 
| 84 |  |  | * Constraints). In both the single and parallel versions, Atoms and | 
| 85 |  |  | * RigidBodies have both global and local indices. | 
| 86 |  |  | */ | 
| 87 | gezelter | 507 | class SimInfo { | 
| 88 |  |  | public: | 
| 89 | gezelter | 1782 | typedef map<int, Molecule*>::iterator  MoleculeIterator; | 
| 90 |  |  |  | 
| 91 | gezelter | 507 | /** | 
| 92 |  |  | * Constructor of SimInfo | 
| 93 | gezelter | 1782 | * | 
| 94 | gezelter | 1879 | * @param ff pointer to a concrete ForceField instance | 
| 95 | gezelter | 1782 | * | 
| 96 | gezelter | 1879 | * @param simParams pointer to the simulation parameters in a Globals object | 
| 97 | gezelter | 507 | */ | 
| 98 | tim | 770 | SimInfo(ForceField* ff, Globals* simParams); | 
| 99 | gezelter | 507 | virtual ~SimInfo(); | 
| 100 | gezelter | 2 |  | 
| 101 | gezelter | 507 | /** | 
| 102 |  |  | * Adds a molecule | 
| 103 | gezelter | 1782 | * | 
| 104 |  |  | * @return return true if adding successfully, return false if the | 
| 105 |  |  | * molecule is already in SimInfo | 
| 106 |  |  | * | 
| 107 | gezelter | 1879 | * @param mol Molecule to be added | 
| 108 | gezelter | 507 | */ | 
| 109 |  |  | bool addMolecule(Molecule* mol); | 
| 110 | gezelter | 2 |  | 
| 111 | gezelter | 507 | /** | 
| 112 |  |  | * Removes a molecule from SimInfo | 
| 113 | gezelter | 1782 | * | 
| 114 |  |  | * @return true if removing successfully, return false if molecule | 
| 115 |  |  | * is not in this SimInfo | 
| 116 | gezelter | 507 | */ | 
| 117 |  |  | bool removeMolecule(Molecule* mol); | 
| 118 | gezelter | 2 |  | 
| 119 | gezelter | 507 | /** Returns the total number of molecules in the system. */ | 
| 120 |  |  | int getNGlobalMolecules() { | 
| 121 |  |  | return nGlobalMols_; | 
| 122 |  |  | } | 
| 123 | gezelter | 2 |  | 
| 124 | gezelter | 507 | /** Returns the total number of atoms in the system. */ | 
| 125 |  |  | int getNGlobalAtoms() { | 
| 126 |  |  | return nGlobalAtoms_; | 
| 127 |  |  | } | 
| 128 | gezelter | 2 |  | 
| 129 | gezelter | 507 | /** Returns the total number of cutoff groups in the system. */ | 
| 130 |  |  | int getNGlobalCutoffGroups() { | 
| 131 |  |  | return nGlobalCutoffGroups_; | 
| 132 |  |  | } | 
| 133 | gezelter | 2 |  | 
| 134 | gezelter | 507 | /** | 
| 135 | gezelter | 1782 | * Returns the total number of integrable objects (total number of | 
| 136 |  |  | * rigid bodies plus the total number of atoms which do not belong | 
| 137 |  |  | * to the rigid bodies) in the system | 
| 138 | gezelter | 507 | */ | 
| 139 |  |  | int getNGlobalIntegrableObjects() { | 
| 140 |  |  | return nGlobalIntegrableObjects_; | 
| 141 |  |  | } | 
| 142 | gezelter | 2 |  | 
| 143 | gezelter | 507 | /** | 
| 144 | gezelter | 1782 | * Returns the total number of integrable objects (total number of | 
| 145 |  |  | * rigid bodies plus the total number of atoms which do not belong | 
| 146 |  |  | * to the rigid bodies) in the system | 
| 147 | gezelter | 507 | */ | 
| 148 |  |  | int getNGlobalRigidBodies() { | 
| 149 |  |  | return nGlobalRigidBodies_; | 
| 150 |  |  | } | 
| 151 | gezelter | 2 |  | 
| 152 | gezelter | 1953 | /** Returns the number of global bonds */ | 
| 153 |  |  | unsigned int getNGlobalBonds(){ | 
| 154 |  |  | return nGlobalBonds_; | 
| 155 |  |  | } | 
| 156 |  |  |  | 
| 157 |  |  | /** Returns the number of global bends */ | 
| 158 |  |  | unsigned int getNGlobalBends() { | 
| 159 |  |  | return nGlobalBends_; | 
| 160 |  |  | } | 
| 161 |  |  |  | 
| 162 |  |  | /** Returns the number of global torsions */ | 
| 163 |  |  | unsigned int getNGlobalTorsions() { | 
| 164 |  |  | return nGlobalTorsions_; | 
| 165 |  |  | } | 
| 166 |  |  |  | 
| 167 |  |  | /** Returns the number of global inversions */ | 
| 168 |  |  | unsigned int getNGlobalInversions() { | 
| 169 |  |  | return nGlobalInversions_; | 
| 170 |  |  | } | 
| 171 |  |  |  | 
| 172 | gezelter | 507 | int getNGlobalConstraints(); | 
| 173 |  |  | /** | 
| 174 |  |  | * Returns the number of local molecules. | 
| 175 |  |  | * @return the number of local molecules | 
| 176 |  |  | */ | 
| 177 |  |  | int getNMolecules() { | 
| 178 |  |  | return molecules_.size(); | 
| 179 |  |  | } | 
| 180 | gezelter | 2 |  | 
| 181 | gezelter | 507 | /** Returns the number of local atoms */ | 
| 182 |  |  | unsigned int getNAtoms() { | 
| 183 |  |  | return nAtoms_; | 
| 184 |  |  | } | 
| 185 | gezelter | 2 |  | 
| 186 | gezelter | 1782 | /** Returns the number of effective cutoff groups on local processor */ | 
| 187 |  |  | unsigned int getNLocalCutoffGroups(); | 
| 188 |  |  |  | 
| 189 | gezelter | 507 | /** Returns the number of local bonds */ | 
| 190 |  |  | unsigned int getNBonds(){ | 
| 191 |  |  | return nBonds_; | 
| 192 |  |  | } | 
| 193 | gezelter | 2 |  | 
| 194 | gezelter | 507 | /** Returns the number of local bends */ | 
| 195 |  |  | unsigned int getNBends() { | 
| 196 |  |  | return nBends_; | 
| 197 |  |  | } | 
| 198 | gezelter | 2 |  | 
| 199 | gezelter | 507 | /** Returns the number of local torsions */ | 
| 200 |  |  | unsigned int getNTorsions() { | 
| 201 |  |  | return nTorsions_; | 
| 202 |  |  | } | 
| 203 | gezelter | 2 |  | 
| 204 | gezelter | 1953 | /** Returns the number of local inversions */ | 
| 205 | gezelter | 1277 | unsigned int getNInversions() { | 
| 206 |  |  | return nInversions_; | 
| 207 |  |  | } | 
| 208 | gezelter | 507 | /** Returns the number of local rigid bodies */ | 
| 209 |  |  | unsigned int getNRigidBodies() { | 
| 210 |  |  | return nRigidBodies_; | 
| 211 |  |  | } | 
| 212 | gezelter | 2 |  | 
| 213 | gezelter | 507 | /** Returns the number of local integrable objects */ | 
| 214 |  |  | unsigned int getNIntegrableObjects() { | 
| 215 |  |  | return nIntegrableObjects_; | 
| 216 |  |  | } | 
| 217 | gezelter | 2 |  | 
| 218 | gezelter | 507 | /** Returns the number of local cutoff groups */ | 
| 219 |  |  | unsigned int getNCutoffGroups() { | 
| 220 |  |  | return nCutoffGroups_; | 
| 221 |  |  | } | 
| 222 | gezelter | 2 |  | 
| 223 | gezelter | 507 | /** Returns the total number of constraints in this SimInfo */ | 
| 224 |  |  | unsigned int getNConstraints() { | 
| 225 |  |  | return nConstraints_; | 
| 226 |  |  | } | 
| 227 | gezelter | 246 |  | 
| 228 | gezelter | 507 | /** | 
| 229 |  |  | * Returns the first molecule in this SimInfo and intialize the iterator. | 
| 230 |  |  | * @return the first molecule, return NULL if there is not molecule in this SimInfo | 
| 231 |  |  | * @param i the iterator of molecule array (user shouldn't change it) | 
| 232 |  |  | */ | 
| 233 |  |  | Molecule* beginMolecule(MoleculeIterator& i); | 
| 234 | gezelter | 2 |  | 
| 235 | gezelter | 507 | /** | 
| 236 |  |  | * Returns the next avaliable Molecule based on the iterator. | 
| 237 |  |  | * @return the next avaliable molecule, return NULL if reaching the end of the array | 
| 238 |  |  | * @param i the iterator of molecule array | 
| 239 |  |  | */ | 
| 240 |  |  | Molecule* nextMolecule(MoleculeIterator& i); | 
| 241 | gezelter | 2 |  | 
| 242 | gezelter | 1782 | /** Returns the total number of fluctuating charges that are present */ | 
| 243 |  |  | int getNFluctuatingCharges() { | 
| 244 |  |  | return nGlobalFluctuatingCharges_; | 
| 245 |  |  | } | 
| 246 |  |  |  | 
| 247 | gezelter | 507 | /** Returns the number of degrees of freedom */ | 
| 248 |  |  | int getNdf() { | 
| 249 | gezelter | 945 | return ndf_ - getFdf(); | 
| 250 | gezelter | 507 | } | 
| 251 | gezelter | 2 |  | 
| 252 | gezelter | 1782 | /** Returns the number of degrees of freedom (LOCAL) */ | 
| 253 |  |  | int getNdfLocal() { | 
| 254 |  |  | return ndfLocal_; | 
| 255 |  |  | } | 
| 256 |  |  |  | 
| 257 | gezelter | 507 | /** Returns the number of raw degrees of freedom */ | 
| 258 |  |  | int getNdfRaw() { | 
| 259 |  |  | return ndfRaw_; | 
| 260 |  |  | } | 
| 261 | gezelter | 2 |  | 
| 262 | gezelter | 507 | /** Returns the number of translational degrees of freedom */ | 
| 263 |  |  | int getNdfTrans() { | 
| 264 |  |  | return ndfTrans_; | 
| 265 |  |  | } | 
| 266 | gezelter | 2 |  | 
| 267 | gezelter | 945 | /** sets the current number of frozen degrees of freedom */ | 
| 268 |  |  | void setFdf(int fdf) { | 
| 269 |  |  | fdf_local = fdf; | 
| 270 |  |  | } | 
| 271 |  |  |  | 
| 272 |  |  | int getFdf(); | 
| 273 |  |  |  | 
| 274 | gezelter | 1782 | //getNZconstraint and setNZconstraint ruin the coherence of | 
| 275 |  |  | //SimInfo class, need refactoring | 
| 276 | gezelter | 246 |  | 
| 277 | gezelter | 507 | /** Returns the total number of z-constraint molecules in the system */ | 
| 278 |  |  | int getNZconstraint() { | 
| 279 |  |  | return nZconstraint_; | 
| 280 |  |  | } | 
| 281 | gezelter | 2 |  | 
| 282 | gezelter | 507 | /** | 
| 283 |  |  | * Sets the number of z-constraint molecules in the system. | 
| 284 |  |  | */ | 
| 285 |  |  | void setNZconstraint(int nZconstraint) { | 
| 286 |  |  | nZconstraint_ = nZconstraint; | 
| 287 |  |  | } | 
| 288 | gezelter | 246 |  | 
| 289 | gezelter | 507 | /** Returns the snapshot manager. */ | 
| 290 |  |  | SnapshotManager* getSnapshotManager() { | 
| 291 |  |  | return sman_; | 
| 292 |  |  | } | 
| 293 | gezelter | 1879 | /** Returns the storage layout (computed by SimCreator) */ | 
| 294 |  |  | int getStorageLayout() { | 
| 295 |  |  | return storageLayout_; | 
| 296 |  |  | } | 
| 297 |  |  | /** Sets the storage layout (computed by SimCreator) */ | 
| 298 |  |  | void setStorageLayout(int sl) { | 
| 299 |  |  | storageLayout_ = sl; | 
| 300 |  |  | } | 
| 301 |  |  |  | 
| 302 | gezelter | 507 | /** Sets the snapshot manager. */ | 
| 303 |  |  | void setSnapshotManager(SnapshotManager* sman); | 
| 304 | gezelter | 246 |  | 
| 305 | gezelter | 507 | /** Returns the force field */ | 
| 306 |  |  | ForceField* getForceField() { | 
| 307 |  |  | return forceField_; | 
| 308 |  |  | } | 
| 309 | gezelter | 2 |  | 
| 310 | gezelter | 507 | Globals* getSimParams() { | 
| 311 |  |  | return simParams_; | 
| 312 |  |  | } | 
| 313 | gezelter | 2 |  | 
| 314 | gezelter | 1782 | void update(); | 
| 315 |  |  | /** | 
| 316 |  |  | * Do final bookkeeping before Force managers need their data. | 
| 317 |  |  | */ | 
| 318 |  |  | void prepareTopology(); | 
| 319 | gezelter | 2 |  | 
| 320 |  |  |  | 
| 321 | gezelter | 507 | /** Returns the local index manager */ | 
| 322 |  |  | LocalIndexManager* getLocalIndexManager() { | 
| 323 |  |  | return &localIndexMan_; | 
| 324 |  |  | } | 
| 325 | gezelter | 2 |  | 
| 326 | gezelter | 507 | int getMoleculeStampId(int globalIndex) { | 
| 327 |  |  | //assert(globalIndex < molStampIds_.size()) | 
| 328 |  |  | return molStampIds_[globalIndex]; | 
| 329 |  |  | } | 
| 330 | gezelter | 2 |  | 
| 331 | gezelter | 507 | /** Returns the molecule stamp */ | 
| 332 |  |  | MoleculeStamp* getMoleculeStamp(int id) { | 
| 333 |  |  | return moleculeStamps_[id]; | 
| 334 |  |  | } | 
| 335 | gezelter | 2 |  | 
| 336 | gezelter | 507 | /** Return the total number of the molecule stamps */ | 
| 337 |  |  | int getNMoleculeStamp() { | 
| 338 |  |  | return moleculeStamps_.size(); | 
| 339 |  |  | } | 
| 340 |  |  | /** | 
| 341 |  |  | * Finds a molecule with a specified global index | 
| 342 |  |  | * @return a pointer point to found molecule | 
| 343 |  |  | * @param index | 
| 344 |  |  | */ | 
| 345 |  |  | Molecule* getMoleculeByGlobalIndex(int index) { | 
| 346 |  |  | MoleculeIterator i; | 
| 347 |  |  | i = molecules_.find(index); | 
| 348 | gezelter | 2 |  | 
| 349 | gezelter | 507 | return i != molecules_.end() ? i->second : NULL; | 
| 350 |  |  | } | 
| 351 | gezelter | 2 |  | 
| 352 | chuckv | 1292 | int getGlobalMolMembership(int id){ | 
| 353 |  |  | return globalMolMembership_[id]; | 
| 354 |  |  | } | 
| 355 |  |  |  | 
| 356 | gezelter | 1782 | /** | 
| 357 |  |  | * returns a vector which maps the local atom index on this | 
| 358 |  |  | * processor to the global atom index.  With only one processor, | 
| 359 |  |  | * these should be identical. | 
| 360 |  |  | */ | 
| 361 |  |  | vector<int> getGlobalAtomIndices(); | 
| 362 | gezelter | 2 |  | 
| 363 | gezelter | 1782 | /** | 
| 364 |  |  | * returns a vector which maps the local cutoff group index on | 
| 365 |  |  | * this processor to the global cutoff group index.  With only one | 
| 366 |  |  | * processor, these should be identical. | 
| 367 |  |  | */ | 
| 368 |  |  | vector<int> getGlobalGroupIndices(); | 
| 369 | gezelter | 764 |  | 
| 370 | gezelter | 246 |  | 
| 371 | gezelter | 1782 | string getFinalConfigFileName() { | 
| 372 | gezelter | 507 | return finalConfigFileName_; | 
| 373 |  |  | } | 
| 374 | tim | 1024 |  | 
| 375 | gezelter | 1782 | void setFinalConfigFileName(const string& fileName) { | 
| 376 | gezelter | 507 | finalConfigFileName_ = fileName; | 
| 377 |  |  | } | 
| 378 | gezelter | 2 |  | 
| 379 | gezelter | 1782 | string getRawMetaData() { | 
| 380 | tim | 1024 | return rawMetaData_; | 
| 381 |  |  | } | 
| 382 | gezelter | 1782 | void setRawMetaData(const string& rawMetaData) { | 
| 383 | tim | 1024 | rawMetaData_ = rawMetaData; | 
| 384 |  |  | } | 
| 385 |  |  |  | 
| 386 | gezelter | 1782 | string getDumpFileName() { | 
| 387 | gezelter | 507 | return dumpFileName_; | 
| 388 |  |  | } | 
| 389 | gezelter | 246 |  | 
| 390 | gezelter | 1782 | void setDumpFileName(const string& fileName) { | 
| 391 | gezelter | 507 | dumpFileName_ = fileName; | 
| 392 |  |  | } | 
| 393 | gezelter | 2 |  | 
| 394 | gezelter | 1782 | string getStatFileName() { | 
| 395 | gezelter | 507 | return statFileName_; | 
| 396 |  |  | } | 
| 397 | gezelter | 246 |  | 
| 398 | gezelter | 1782 | void setStatFileName(const string& fileName) { | 
| 399 | gezelter | 507 | statFileName_ = fileName; | 
| 400 |  |  | } | 
| 401 | chrisfen | 417 |  | 
| 402 | gezelter | 1782 | string getRestFileName() { | 
| 403 | gezelter | 507 | return restFileName_; | 
| 404 |  |  | } | 
| 405 | chrisfen | 417 |  | 
| 406 | gezelter | 1782 | void setRestFileName(const string& fileName) { | 
| 407 | gezelter | 507 | restFileName_ = fileName; | 
| 408 |  |  | } | 
| 409 | gezelter | 2 |  | 
| 410 | gezelter | 507 | /** | 
| 411 |  |  | * Sets GlobalGroupMembership | 
| 412 |  |  | */ | 
| 413 | gezelter | 1846 | void setGlobalGroupMembership(const vector<int>& ggm) { | 
| 414 |  |  | assert(ggm.size() == static_cast<size_t>(nGlobalAtoms_)); | 
| 415 |  |  | globalGroupMembership_ = ggm; | 
| 416 | gezelter | 507 | } | 
| 417 | gezelter | 2 |  | 
| 418 | gezelter | 507 | /** | 
| 419 |  |  | * Sets GlobalMolMembership | 
| 420 |  |  | */ | 
| 421 | gezelter | 1846 | void setGlobalMolMembership(const vector<int>& gmm) { | 
| 422 |  |  | assert(gmm.size() == (static_cast<size_t>(nGlobalAtoms_ + | 
| 423 |  |  | nGlobalRigidBodies_))); | 
| 424 |  |  | globalMolMembership_ = gmm; | 
| 425 | gezelter | 507 | } | 
| 426 | gezelter | 246 |  | 
| 427 |  |  |  | 
| 428 | gezelter | 1782 | bool isTopologyDone() { | 
| 429 |  |  | return topologyDone_; | 
| 430 | gezelter | 507 | } | 
| 431 | gezelter | 246 |  | 
| 432 | chrisfen | 998 | bool getCalcBoxDipole() { | 
| 433 |  |  | return calcBoxDipole_; | 
| 434 |  |  | } | 
| 435 |  |  |  | 
| 436 | gezelter | 1126 | bool getUseAtomicVirial() { | 
| 437 |  |  | return useAtomicVirial_; | 
| 438 |  |  | } | 
| 439 |  |  |  | 
| 440 | gezelter | 507 | /** | 
| 441 |  |  | * Adds property into property map | 
| 442 |  |  | * @param genData GenericData to be added into PropertyMap | 
| 443 |  |  | */ | 
| 444 |  |  | void addProperty(GenericData* genData); | 
| 445 | gezelter | 246 |  | 
| 446 | gezelter | 507 | /** | 
| 447 |  |  | * Removes property from PropertyMap by name | 
| 448 |  |  | * @param propName the name of property to be removed | 
| 449 |  |  | */ | 
| 450 | gezelter | 1782 | void removeProperty(const string& propName); | 
| 451 | gezelter | 246 |  | 
| 452 | gezelter | 507 | /** | 
| 453 |  |  | * clear all of the properties | 
| 454 |  |  | */ | 
| 455 |  |  | void clearProperties(); | 
| 456 | gezelter | 246 |  | 
| 457 | gezelter | 507 | /** | 
| 458 |  |  | * Returns all names of properties | 
| 459 |  |  | * @return all names of properties | 
| 460 |  |  | */ | 
| 461 | gezelter | 1782 | vector<string> getPropertyNames(); | 
| 462 | gezelter | 246 |  | 
| 463 | gezelter | 507 | /** | 
| 464 |  |  | * Returns all of the properties in PropertyMap | 
| 465 |  |  | * @return all of the properties in PropertyMap | 
| 466 |  |  | */ | 
| 467 | gezelter | 1782 | vector<GenericData*> getProperties(); | 
| 468 | gezelter | 246 |  | 
| 469 | gezelter | 507 | /** | 
| 470 |  |  | * Returns property | 
| 471 |  |  | * @param propName name of property | 
| 472 |  |  | * @return a pointer point to property with propName. If no property named propName | 
| 473 |  |  | * exists, return NULL | 
| 474 |  |  | */ | 
| 475 | gezelter | 1782 | GenericData* getPropertyByName(const string& propName); | 
| 476 | gezelter | 246 |  | 
| 477 | gezelter | 507 | /** | 
| 478 | gezelter | 1287 | * add all special interaction pairs (including excluded | 
| 479 |  |  | * interactions) in a molecule into the appropriate lists. | 
| 480 | gezelter | 507 | */ | 
| 481 | gezelter | 1287 | void addInteractionPairs(Molecule* mol); | 
| 482 | gezelter | 246 |  | 
| 483 | gezelter | 507 | /** | 
| 484 | gezelter | 1287 | * remove all special interaction pairs which belong to a molecule | 
| 485 |  |  | * from the appropriate lists. | 
| 486 | gezelter | 507 | */ | 
| 487 | gezelter | 1287 | void removeInteractionPairs(Molecule* mol); | 
| 488 | gezelter | 246 |  | 
| 489 | gezelter | 1782 | /** Returns the set of atom types present in this simulation */ | 
| 490 |  |  | set<AtomType*> getSimulatedAtomTypes(); | 
| 491 | gezelter | 1879 |  | 
| 492 |  |  | /** Returns the global count of atoms of a particular type */ | 
| 493 |  |  | int getGlobalCountOfType(AtomType* atype); | 
| 494 | tim | 292 |  | 
| 495 | gezelter | 1782 | friend ostream& operator <<(ostream& o, SimInfo& info); | 
| 496 | tim | 326 |  | 
| 497 | tim | 963 | void getCutoff(RealType& rcut, RealType& rsw); | 
| 498 | gezelter | 246 |  | 
| 499 | gezelter | 507 | private: | 
| 500 | gezelter | 246 |  | 
| 501 | gezelter | 1782 | /** fill up the simtype struct and other simulation-related variables */ | 
| 502 |  |  | void setupSimVariables(); | 
| 503 | gezelter | 246 |  | 
| 504 |  |  |  | 
| 505 | chrisfen | 998 | /** Determine if we need to accumulate the simulation box dipole */ | 
| 506 |  |  | void setupAccumulateBoxDipole(); | 
| 507 |  |  |  | 
| 508 | gezelter | 507 | /** Calculates the number of degress of freedom in the whole system */ | 
| 509 |  |  | void calcNdf(); | 
| 510 |  |  | void calcNdfRaw(); | 
| 511 |  |  | void calcNdfTrans(); | 
| 512 | gezelter | 246 |  | 
| 513 | gezelter | 507 | /** | 
| 514 | gezelter | 1782 | * Adds molecule stamp and the total number of the molecule with | 
| 515 |  |  | * same molecule stamp in the whole system. | 
| 516 | gezelter | 507 | */ | 
| 517 |  |  | void addMoleculeStamp(MoleculeStamp* molStamp, int nmol); | 
| 518 | gezelter | 246 |  | 
| 519 | gezelter | 1782 | // Other classes holdingn important information | 
| 520 |  |  | ForceField* forceField_; /**< provides access to defined atom types, bond types, etc. */ | 
| 521 |  |  | Globals* simParams_;     /**< provides access to simulation parameters set by user */ | 
| 522 | gezelter | 246 |  | 
| 523 | gezelter | 1782 | ///  Counts of local objects | 
| 524 | gezelter | 1277 | int nAtoms_;              /**< number of atoms in local processor */ | 
| 525 |  |  | int nBonds_;              /**< number of bonds in local processor */ | 
| 526 |  |  | int nBends_;              /**< number of bends in local processor */ | 
| 527 |  |  | int nTorsions_;           /**< number of torsions in local processor */ | 
| 528 |  |  | int nInversions_;         /**< number of inversions in local processor */ | 
| 529 |  |  | int nRigidBodies_;        /**< number of rigid bodies in local processor */ | 
| 530 |  |  | int nIntegrableObjects_;  /**< number of integrable objects in local processor */ | 
| 531 |  |  | int nCutoffGroups_;       /**< number of cutoff groups in local processor */ | 
| 532 |  |  | int nConstraints_;        /**< number of constraints in local processors */ | 
| 533 | gezelter | 1782 | int nFluctuatingCharges_; /**< number of fluctuating charges in local processor */ | 
| 534 |  |  |  | 
| 535 |  |  | /// Counts of global objects | 
| 536 |  |  | int nGlobalMols_;              /**< number of molecules in the system (GLOBAL) */ | 
| 537 |  |  | int nGlobalAtoms_;             /**< number of atoms in the system (GLOBAL) */ | 
| 538 |  |  | int nGlobalCutoffGroups_;      /**< number of cutoff groups in this system (GLOBAL) */ | 
| 539 |  |  | int nGlobalIntegrableObjects_; /**< number of integrable objects in this system */ | 
| 540 |  |  | int nGlobalRigidBodies_;       /**< number of rigid bodies in this system (GLOBAL) */ | 
| 541 |  |  | int nGlobalFluctuatingCharges_;/**< number of fluctuating charges in this system (GLOBAL) */ | 
| 542 | gezelter | 1953 | int nGlobalBonds_;              /**< number of bonds in the system */ | 
| 543 |  |  | int nGlobalBends_;              /**< number of bends in the system */ | 
| 544 |  |  | int nGlobalTorsions_;           /**< number of torsions in the system */ | 
| 545 |  |  | int nGlobalInversions_;         /**< number of inversions in the system */ | 
| 546 |  |  |  | 
| 547 | gezelter | 1782 | /// Degress of freedom | 
| 548 |  |  | int ndf_;          /**< number of degress of freedom (excludes constraints) (LOCAL) */ | 
| 549 |  |  | int ndfLocal_;     /**< number of degrees of freedom (LOCAL, excludes constraints) */ | 
| 550 |  |  | int fdf_local;     /**< number of frozen degrees of freedom (LOCAL) */ | 
| 551 |  |  | int fdf_;          /**< number of frozen degrees of freedom (GLOBAL) */ | 
| 552 |  |  | int ndfRaw_;       /**< number of degress of freedom (includes constraints),  (LOCAL) */ | 
| 553 |  |  | int ndfTrans_;     /**< number of translation degress of freedom, (LOCAL) */ | 
| 554 |  |  | int nZconstraint_; /**< number of  z-constraint molecules (GLOBAL) */ | 
| 555 | gezelter | 246 |  | 
| 556 | gezelter | 1782 | /// logicals | 
| 557 |  |  | bool usesPeriodicBoundaries_; /**< use periodic boundary conditions? */ | 
| 558 |  |  | bool usesDirectionalAtoms_;   /**< are there atoms with position AND orientation? */ | 
| 559 |  |  | bool usesMetallicAtoms_;      /**< are there transition metal atoms? */ | 
| 560 |  |  | bool usesElectrostaticAtoms_; /**< are there electrostatic atoms? */ | 
| 561 |  |  | bool usesFluctuatingCharges_; /**< are there fluctuating charges? */ | 
| 562 |  |  | bool usesAtomicVirial_;       /**< are we computing atomic virials? */ | 
| 563 |  |  | bool requiresPrepair_;        /**< does this simulation require a pre-pair loop? */ | 
| 564 |  |  | bool requiresSkipCorrection_; /**< does this simulation require a skip-correction? */ | 
| 565 |  |  | bool requiresSelfCorrection_; /**< does this simulation require a self-correction? */ | 
| 566 | gezelter | 246 |  | 
| 567 | gezelter | 1782 | public: | 
| 568 |  |  | bool usesElectrostaticAtoms() { return usesElectrostaticAtoms_; } | 
| 569 |  |  | bool usesDirectionalAtoms() { return usesDirectionalAtoms_; } | 
| 570 |  |  | bool usesFluctuatingCharges() { return usesFluctuatingCharges_; } | 
| 571 |  |  | bool usesAtomicVirial() { return usesAtomicVirial_; } | 
| 572 |  |  | bool requiresPrepair() { return requiresPrepair_; } | 
| 573 |  |  | bool requiresSkipCorrection() { return requiresSkipCorrection_;} | 
| 574 |  |  | bool requiresSelfCorrection() { return requiresSelfCorrection_;} | 
| 575 |  |  |  | 
| 576 |  |  | private: | 
| 577 |  |  | /// Data structures holding primary simulation objects | 
| 578 |  |  | map<int, Molecule*>  molecules_;  /**< map holding pointers to LOCAL molecules */ | 
| 579 |  |  |  | 
| 580 |  |  | /// Stamps are templates for objects that are then used to create | 
| 581 |  |  | /// groups of objects.  For example, a molecule stamp contains | 
| 582 |  |  | /// information on how to build that molecule (i.e. the topology, | 
| 583 |  |  | /// the atoms, the bonds, etc.)  Once the system is built, the | 
| 584 |  |  | /// stamps are no longer useful. | 
| 585 |  |  | vector<int> molStampIds_;                /**< stamp id for molecules in the system */ | 
| 586 |  |  | vector<MoleculeStamp*> moleculeStamps_;  /**< molecule stamps array */ | 
| 587 |  |  |  | 
| 588 |  |  | /** | 
| 589 |  |  | * A vector that maps between the global index of an atom, and the | 
| 590 |  |  | * global index of cutoff group the atom belong to.  It is filled | 
| 591 |  |  | * by SimCreator once and only once, since it never changed during | 
| 592 |  |  | * the simulation.  It should be nGlobalAtoms_ in size. | 
| 593 |  |  | */ | 
| 594 |  |  | vector<int> globalGroupMembership_; | 
| 595 |  |  | public: | 
| 596 |  |  | vector<int> getGlobalGroupMembership() { return globalGroupMembership_; } | 
| 597 |  |  | private: | 
| 598 |  |  |  | 
| 599 |  |  | /** | 
| 600 |  |  | * A vector that maps between the global index of an atom and the | 
| 601 |  |  | * global index of the molecule the atom belongs to.  It is filled | 
| 602 |  |  | * by SimCreator once and only once, since it is never changed | 
| 603 |  |  | * during the simulation. It shoudl be nGlobalAtoms_ in size. | 
| 604 |  |  | */ | 
| 605 |  |  | vector<int> globalMolMembership_; | 
| 606 |  |  |  | 
| 607 | gezelter | 507 | /** | 
| 608 | gezelter | 1782 | * A vector that maps between the local index of an atom and the | 
| 609 |  |  | * index of the AtomType. | 
| 610 |  |  | */ | 
| 611 |  |  | vector<int> identArray_; | 
| 612 |  |  | public: | 
| 613 |  |  | vector<int> getIdentArray() { return identArray_; } | 
| 614 | gezelter | 1929 |  | 
| 615 |  |  | /** | 
| 616 |  |  | * A vector that contains information about the local region of an | 
| 617 |  |  | * atom (used for fluctuating charges, etc.) | 
| 618 |  |  | */ | 
| 619 | gezelter | 1782 | private: | 
| 620 | gezelter | 1929 | vector<int> regions_; | 
| 621 |  |  | public: | 
| 622 |  |  | vector<int> getRegions() { return regions_; } | 
| 623 |  |  | private: | 
| 624 | gezelter | 1782 | /** | 
| 625 |  |  | * A vector which contains the fractional contribution of an | 
| 626 |  |  | * atom's mass to the total mass of the cutoffGroup that atom | 
| 627 |  |  | * belongs to.  In the case of single atom cutoff groups, the mass | 
| 628 |  |  | * factor for that atom is 1.  For massless atoms, the factor is | 
| 629 |  |  | * also 1. | 
| 630 |  |  | */ | 
| 631 |  |  | vector<RealType> massFactors_; | 
| 632 |  |  | public: | 
| 633 |  |  | vector<RealType> getMassFactors() { return massFactors_; } | 
| 634 |  |  |  | 
| 635 |  |  | PairList* getExcludedInteractions() { return &excludedInteractions_; } | 
| 636 |  |  | PairList* getOneTwoInteractions() { return &oneTwoInteractions_; } | 
| 637 |  |  | PairList* getOneThreeInteractions() { return &oneThreeInteractions_; } | 
| 638 |  |  | PairList* getOneFourInteractions() { return &oneFourInteractions_; } | 
| 639 |  |  |  | 
| 640 |  |  | private: | 
| 641 |  |  |  | 
| 642 |  |  | /// lists to handle atoms needing special treatment in the non-bonded interactions | 
| 643 |  |  | PairList excludedInteractions_;  /**< atoms excluded from interacting with each other */ | 
| 644 |  |  | PairList oneTwoInteractions_;    /**< atoms that are directly Bonded */ | 
| 645 |  |  | PairList oneThreeInteractions_;  /**< atoms sharing a Bend */ | 
| 646 |  |  | PairList oneFourInteractions_;   /**< atoms sharing a Torsion */ | 
| 647 |  |  |  | 
| 648 |  |  | PropertyMap properties_;       /**< Generic Properties can be added */ | 
| 649 |  |  | SnapshotManager* sman_;        /**< SnapshotManager (handles particle positions, etc.) */ | 
| 650 | gezelter | 1879 | int storageLayout_;            /**< Bits to tell how much data to store on each object */ | 
| 651 | gezelter | 1782 |  | 
| 652 |  |  | /** | 
| 653 |  |  | * The reason to have a local index manager is that when molecule | 
| 654 |  |  | * is migrating to other processors, the atoms and the | 
| 655 |  |  | * rigid-bodies will release their local indices to | 
| 656 |  |  | * LocalIndexManager. Combining the information of molecule | 
| 657 |  |  | * migrating to current processor, Migrator class can query the | 
| 658 |  |  | * LocalIndexManager to make a efficient data moving plan. | 
| 659 | gezelter | 507 | */ | 
| 660 |  |  | LocalIndexManager localIndexMan_; | 
| 661 | gezelter | 246 |  | 
| 662 | tim | 1024 | // unparsed MetaData block for storing in Dump and EOR files: | 
| 663 | gezelter | 1782 | string rawMetaData_; | 
| 664 | tim | 1024 |  | 
| 665 | gezelter | 1782 | // file names | 
| 666 |  |  | string finalConfigFileName_; | 
| 667 |  |  | string dumpFileName_; | 
| 668 |  |  | string statFileName_; | 
| 669 |  |  | string restFileName_; | 
| 670 | gezelter | 246 |  | 
| 671 | gezelter | 1782 | bool topologyDone_;  /** flag to indicate whether the topology has | 
| 672 |  |  | been scanned and all the relevant | 
| 673 |  |  | bookkeeping has been done*/ | 
| 674 | gezelter | 1126 |  | 
| 675 |  |  | bool calcBoxDipole_; /**< flag to indicate whether or not we calculate | 
| 676 |  |  | the simulation box dipole moment */ | 
| 677 |  |  |  | 
| 678 |  |  | bool useAtomicVirial_; /**< flag to indicate whether or not we use | 
| 679 |  |  | Atomic Virials to calculate the pressure */ | 
| 680 | gezelter | 1782 |  | 
| 681 |  |  | public: | 
| 682 |  |  | /** | 
| 683 |  |  | * return an integral objects by its global index. In MPI | 
| 684 |  |  | * version, if the StuntDouble with specified global index does | 
| 685 |  |  | * not belong to local processor, a NULL will be return. | 
| 686 | tim | 1024 | */ | 
| 687 | gezelter | 1782 | StuntDouble* getIOIndexToIntegrableObject(int index); | 
| 688 |  |  | void setIOIndexToIntegrableObject(const vector<StuntDouble*>& v); | 
| 689 | tim | 1024 |  | 
| 690 | gezelter | 1782 | private: | 
| 691 |  |  | vector<StuntDouble*> IOIndexToIntegrableObject; | 
| 692 |  |  |  | 
| 693 | gezelter | 507 | public: | 
| 694 | gezelter | 246 |  | 
| 695 | gezelter | 507 | /** | 
| 696 |  |  | * Finds the processor where a molecule resides | 
| 697 |  |  | * @return the id of the processor which contains the molecule | 
| 698 |  |  | * @param globalIndex global Index of the molecule | 
| 699 |  |  | */ | 
| 700 |  |  | int getMolToProc(int globalIndex) { | 
| 701 |  |  | //assert(globalIndex < molToProcMap_.size()); | 
| 702 |  |  | return molToProcMap_[globalIndex]; | 
| 703 |  |  | } | 
| 704 | gezelter | 1782 |  | 
| 705 | gezelter | 507 | /** | 
| 706 |  |  | * Set MolToProcMap array | 
| 707 |  |  | */ | 
| 708 | gezelter | 1782 | void setMolToProcMap(const vector<int>& molToProcMap) { | 
| 709 | gezelter | 507 | molToProcMap_ = molToProcMap; | 
| 710 |  |  | } | 
| 711 | gezelter | 246 |  | 
| 712 | gezelter | 507 | private: | 
| 713 | gezelter | 246 |  | 
| 714 | gezelter | 507 | /** | 
| 715 | gezelter | 1241 | * The size of molToProcMap_ is equal to total number of molecules | 
| 716 |  |  | * in the system.  It maps a molecule to the processor on which it | 
| 717 |  |  | * resides. it is filled by SimCreator once and only once. | 
| 718 | gezelter | 507 | */ | 
| 719 | gezelter | 1782 | vector<int> molToProcMap_; | 
| 720 | tim | 292 |  | 
| 721 | gezelter | 507 | }; | 
| 722 | gezelter | 2 |  | 
| 723 | gezelter | 1390 | } //namespace OpenMD | 
| 724 | gezelter | 246 | #endif //BRAINS_SIMMODEL_HPP | 
| 725 | gezelter | 2 |  |