6 |
|
* redistribute this software in source and binary code form, provided |
7 |
|
* that the following conditions are met: |
8 |
|
* |
9 |
< |
* 1. Acknowledgement of the program authors must be made in any |
10 |
< |
* publication of scientific results based in part on use of the |
11 |
< |
* program. An acceptable form of acknowledgement is citation of |
12 |
< |
* the article in which the program was described (Matthew |
13 |
< |
* A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher |
14 |
< |
* J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented |
15 |
< |
* Parallel Simulation Engine for Molecular Dynamics," |
16 |
< |
* J. Comput. Chem. 26, pp. 252-271 (2005)) |
17 |
< |
* |
18 |
< |
* 2. Redistributions of source code must retain the above copyright |
9 |
> |
* 1. Redistributions of source code must retain the above copyright |
10 |
|
* notice, this list of conditions and the following disclaimer. |
11 |
|
* |
12 |
< |
* 3. Redistributions in binary form must reproduce the above copyright |
12 |
> |
* 2. Redistributions in binary form must reproduce the above copyright |
13 |
|
* notice, this list of conditions and the following disclaimer in the |
14 |
|
* documentation and/or other materials provided with the |
15 |
|
* distribution. |
28 |
|
* arising out of the use of or inability to use software, even if the |
29 |
|
* University of Notre Dame has been advised of the possibility of |
30 |
|
* such damages. |
31 |
+ |
* |
32 |
+ |
* SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your |
33 |
+ |
* research, please cite the appropriate papers when you publish your |
34 |
+ |
* work. Good starting points are: |
35 |
+ |
* |
36 |
+ |
* [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |
37 |
+ |
* [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). |
38 |
+ |
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). |
39 |
+ |
* [4] Vardeman & Gezelter, in progress (2009). |
40 |
|
*/ |
41 |
|
|
42 |
|
/** |
54 |
|
#include <utility> |
55 |
|
#include <vector> |
56 |
|
|
57 |
< |
#include "brains/Exclude.hpp" |
57 |
> |
#include "brains/PairList.hpp" |
58 |
|
#include "io/Globals.hpp" |
59 |
|
#include "math/Vector3.hpp" |
60 |
|
#include "math/SquareMatrix3.hpp" |
62 |
|
#include "UseTheForce/ForceField.hpp" |
63 |
|
#include "utils/PropertyMap.hpp" |
64 |
|
#include "utils/LocalIndexManager.hpp" |
65 |
+ |
#include "nonbonded/Electrostatic.hpp" |
66 |
|
|
67 |
|
//another nonsense macro declaration |
68 |
< |
#define __C |
68 |
> |
#define __OPENMD_C |
69 |
|
#include "brains/fSimulation.h" |
70 |
|
|
71 |
< |
namespace oopse{ |
71 |
> |
namespace OpenMD{ |
72 |
|
|
73 |
|
//forward decalration |
74 |
|
class SnapshotManager; |
75 |
|
class Molecule; |
76 |
|
class SelectionManager; |
77 |
+ |
class StuntDouble; |
78 |
+ |
class Electrostatic; |
79 |
|
/** |
80 |
|
* @class SimInfo SimInfo.hpp "brains/SimInfo.hpp" |
81 |
< |
* @brief As one of the heavy weight class of OOPSE, SimInfo |
82 |
< |
* One of the major changes in SimInfo class is the data struct. It only maintains a list of molecules. |
83 |
< |
* And the Molecule class will maintain all of the concrete objects (atoms, bond, bend, torsions, rigid bodies, |
84 |
< |
* cutoff groups, constrains). |
85 |
< |
* Another major change is the index. No matter single version or parallel version, atoms and |
86 |
< |
* rigid bodies have both global index and local index. Local index is not important to molecule as well as |
87 |
< |
* cutoff group. |
85 |
< |
*/ |
81 |
> |
* @brief One of the heavy weight classes of OpenMD, SimInfo maintains a list of molecules. |
82 |
> |
* The Molecule class maintains all of the concrete objects |
83 |
> |
* (atoms, bond, bend, torsions, inversions, rigid bodies, cutoff groups, |
84 |
> |
* constraints). In both the single and parallel versions, atoms and |
85 |
> |
* rigid bodies have both global and local indices. The local index is |
86 |
> |
* not relevant to molecules or cutoff groups. |
87 |
> |
*/ |
88 |
|
class SimInfo { |
89 |
|
public: |
90 |
|
typedef std::map<int, Molecule*>::iterator MoleculeIterator; |
97 |
|
* @param simParams |
98 |
|
* @note |
99 |
|
*/ |
100 |
< |
SimInfo(MakeStamps* stamps, std::vector<std::pair<MoleculeStamp*, int> >& molStampPairs, ForceField* ff, Globals* simParams); |
100 |
> |
SimInfo(ForceField* ff, Globals* simParams); |
101 |
|
virtual ~SimInfo(); |
102 |
|
|
103 |
|
/** |
173 |
|
return nTorsions_; |
174 |
|
} |
175 |
|
|
176 |
+ |
/** Returns the number of local torsions */ |
177 |
+ |
unsigned int getNInversions() { |
178 |
+ |
return nInversions_; |
179 |
+ |
} |
180 |
|
/** Returns the number of local rigid bodies */ |
181 |
|
unsigned int getNRigidBodies() { |
182 |
|
return nRigidBodies_; |
213 |
|
|
214 |
|
/** Returns the number of degrees of freedom */ |
215 |
|
int getNdf() { |
216 |
< |
return ndf_; |
216 |
> |
return ndf_ - getFdf(); |
217 |
|
} |
218 |
|
|
219 |
|
/** Returns the number of raw degrees of freedom */ |
226 |
|
return ndfTrans_; |
227 |
|
} |
228 |
|
|
229 |
+ |
/** sets the current number of frozen degrees of freedom */ |
230 |
+ |
void setFdf(int fdf) { |
231 |
+ |
fdf_local = fdf; |
232 |
+ |
} |
233 |
+ |
|
234 |
+ |
int getFdf(); |
235 |
+ |
|
236 |
|
//getNZconstraint and setNZconstraint ruin the coherent of SimInfo class, need refactorying |
237 |
|
|
238 |
|
/** Returns the total number of z-constraint molecules in the system */ |
278 |
|
/** Returns system angular momentum */ |
279 |
|
Vector3d getAngularMomentum(); |
280 |
|
|
281 |
+ |
/** Returns volume of system as estimated by an ellipsoid defined by the radii of gyration*/ |
282 |
+ |
void getGyrationalVolume(RealType &vol); |
283 |
+ |
/** Overloaded version of gyrational volume that also returns det(I) so dV/dr can be calculated*/ |
284 |
+ |
void getGyrationalVolume(RealType &vol, RealType &detI); |
285 |
|
/** main driver function to interact with fortran during the initialization and molecule migration */ |
286 |
|
void update(); |
287 |
|
|
316 |
|
return i != molecules_.end() ? i->second : NULL; |
317 |
|
} |
318 |
|
|
319 |
< |
/** Calculate the maximum cutoff radius based on the atom types */ |
320 |
< |
double calcMaxCutoffRadius(); |
319 |
> |
int getGlobalMolMembership(int id){ |
320 |
> |
return globalMolMembership_[id]; |
321 |
> |
} |
322 |
|
|
323 |
< |
double getRcut() { |
323 |
> |
RealType getRcut() { |
324 |
|
return rcut_; |
325 |
|
} |
326 |
|
|
327 |
< |
double getRsw() { |
327 |
> |
RealType getRsw() { |
328 |
|
return rsw_; |
329 |
|
} |
330 |
+ |
|
331 |
+ |
RealType getList() { |
332 |
+ |
return rlist_; |
333 |
+ |
} |
334 |
|
|
335 |
|
std::string getFinalConfigFileName() { |
336 |
|
return finalConfigFileName_; |
337 |
|
} |
338 |
< |
|
338 |
> |
|
339 |
|
void setFinalConfigFileName(const std::string& fileName) { |
340 |
|
finalConfigFileName_ = fileName; |
341 |
|
} |
342 |
|
|
343 |
+ |
std::string getRawMetaData() { |
344 |
+ |
return rawMetaData_; |
345 |
+ |
} |
346 |
+ |
void setRawMetaData(const std::string& rawMetaData) { |
347 |
+ |
rawMetaData_ = rawMetaData; |
348 |
+ |
} |
349 |
+ |
|
350 |
|
std::string getDumpFileName() { |
351 |
|
return dumpFileName_; |
352 |
|
} |
376 |
|
* @see #SimCreator::setGlobalIndex |
377 |
|
*/ |
378 |
|
void setGlobalGroupMembership(const std::vector<int>& globalGroupMembership) { |
379 |
< |
assert(globalGroupMembership.size() == nGlobalAtoms_); |
379 |
> |
assert(globalGroupMembership.size() == static_cast<size_t>(nGlobalAtoms_)); |
380 |
|
globalGroupMembership_ = globalGroupMembership; |
381 |
|
} |
382 |
|
|
385 |
|
* @see #SimCreator::setGlobalIndex |
386 |
|
*/ |
387 |
|
void setGlobalMolMembership(const std::vector<int>& globalMolMembership) { |
388 |
< |
assert(globalMolMembership.size() == nGlobalAtoms_); |
388 |
> |
assert(globalMolMembership.size() == static_cast<size_t>(nGlobalAtoms_)); |
389 |
|
globalMolMembership_ = globalMolMembership; |
390 |
|
} |
391 |
|
|
394 |
|
return fortranInitialized_; |
395 |
|
} |
396 |
|
|
397 |
+ |
bool getCalcBoxDipole() { |
398 |
+ |
return calcBoxDipole_; |
399 |
+ |
} |
400 |
+ |
|
401 |
+ |
bool getUseAtomicVirial() { |
402 |
+ |
return useAtomicVirial_; |
403 |
+ |
} |
404 |
+ |
|
405 |
|
//below functions are just forward functions |
406 |
|
//To compose or to inherit is always a hot debate. In general, is-a relation need subclassing, in the |
407 |
|
//the other hand, has-a relation need composing. |
443 |
|
GenericData* getPropertyByName(const std::string& propName); |
444 |
|
|
445 |
|
/** |
446 |
< |
* add all exclude pairs of a molecule into exclude list. |
446 |
> |
* add all special interaction pairs (including excluded |
447 |
> |
* interactions) in a molecule into the appropriate lists. |
448 |
|
*/ |
449 |
< |
void addExcludePairs(Molecule* mol); |
449 |
> |
void addInteractionPairs(Molecule* mol); |
450 |
|
|
451 |
|
/** |
452 |
< |
* remove all exclude pairs which belong to a molecule from exclude list |
452 |
> |
* remove all special interaction pairs which belong to a molecule |
453 |
> |
* from the appropriate lists. |
454 |
|
*/ |
455 |
+ |
void removeInteractionPairs(Molecule* mol); |
456 |
|
|
417 |
– |
void removeExcludePairs(Molecule* mol); |
457 |
|
|
419 |
– |
|
458 |
|
/** Returns the unique atom types of local processor in an array */ |
459 |
|
std::set<AtomType*> getUniqueAtomTypes(); |
460 |
|
|
461 |
|
friend std::ostream& operator <<(std::ostream& o, SimInfo& info); |
462 |
|
|
463 |
< |
void getCutoff(double& rcut, double& rsw); |
463 |
> |
void getCutoff(RealType& rcut, RealType& rsw); |
464 |
|
|
465 |
|
private: |
466 |
|
|
476 |
|
/** Figure out the radius of cutoff, radius of switching function and pass them to fortran */ |
477 |
|
void setupCutoff(); |
478 |
|
|
479 |
+ |
/** Figure out which coulombic correction method to use and pass to fortran */ |
480 |
+ |
void setupElectrostaticSummationMethod( int isError ); |
481 |
+ |
|
482 |
+ |
/** Figure out which polynomial type to use for the switching function */ |
483 |
+ |
void setupSwitchingFunction(); |
484 |
+ |
|
485 |
+ |
/** Determine if we need to accumulate the simulation box dipole */ |
486 |
+ |
void setupAccumulateBoxDipole(); |
487 |
+ |
|
488 |
|
/** Calculates the number of degress of freedom in the whole system */ |
489 |
|
void calcNdf(); |
490 |
|
void calcNdfRaw(); |
491 |
|
void calcNdfTrans(); |
492 |
|
|
493 |
+ |
ForceField* forceField_; |
494 |
+ |
Globals* simParams_; |
495 |
+ |
|
496 |
+ |
std::map<int, Molecule*> molecules_; /**< Molecule array */ |
497 |
+ |
|
498 |
|
/** |
499 |
|
* Adds molecule stamp and the total number of the molecule with same molecule stamp in the whole |
500 |
|
* system. |
501 |
|
*/ |
502 |
|
void addMoleculeStamp(MoleculeStamp* molStamp, int nmol); |
451 |
– |
|
452 |
– |
MakeStamps* stamps_; |
453 |
– |
ForceField* forceField_; |
454 |
– |
Globals* simParams_; |
455 |
– |
|
456 |
– |
std::map<int, Molecule*> molecules_; /**< Molecule array */ |
503 |
|
|
504 |
|
//degress of freedom |
505 |
|
int ndf_; /**< number of degress of freedom (excludes constraints), ndf_ is local */ |
506 |
+ |
int fdf_local; /**< number of frozen degrees of freedom */ |
507 |
+ |
int fdf_; /**< number of frozen degrees of freedom */ |
508 |
|
int ndfRaw_; /**< number of degress of freedom (includes constraints), ndfRaw_ is local */ |
509 |
|
int ndfTrans_; /**< number of translation degress of freedom, ndfTrans_ is local */ |
510 |
|
int nZconstraint_; /** number of z-constraint molecules, nZconstraint_ is global */ |
523 |
|
std::vector<int> globalGroupMembership_; |
524 |
|
|
525 |
|
/** |
526 |
< |
* the size of globalGroupMembership_ is nGlobalAtoms. Its index is global index of an atom, and the |
526 |
> |
* the size of globalMolMembership_ is nGlobalAtoms. Its index is global index of an atom, and the |
527 |
|
* corresponding content is the global index of molecule this atom belong to. |
528 |
|
* It is filled by SimCreator once and only once, since it is never changed during the simulation. |
529 |
|
*/ |
534 |
|
std::vector<MoleculeStamp*> moleculeStamps_; /**< molecule stamps array */ |
535 |
|
|
536 |
|
//number of local objects |
537 |
< |
int nAtoms_; /**< number of atoms in local processor */ |
538 |
< |
int nBonds_; /**< number of bonds in local processor */ |
539 |
< |
int nBends_; /**< number of bends in local processor */ |
540 |
< |
int nTorsions_; /**< number of torsions in local processor */ |
541 |
< |
int nRigidBodies_; /**< number of rigid bodies in local processor */ |
542 |
< |
int nIntegrableObjects_; /**< number of integrable objects in local processor */ |
543 |
< |
int nCutoffGroups_; /**< number of cutoff groups in local processor */ |
544 |
< |
int nConstraints_; /**< number of constraints in local processors */ |
537 |
> |
int nAtoms_; /**< number of atoms in local processor */ |
538 |
> |
int nBonds_; /**< number of bonds in local processor */ |
539 |
> |
int nBends_; /**< number of bends in local processor */ |
540 |
> |
int nTorsions_; /**< number of torsions in local processor */ |
541 |
> |
int nInversions_; /**< number of inversions in local processor */ |
542 |
> |
int nRigidBodies_; /**< number of rigid bodies in local processor */ |
543 |
> |
int nIntegrableObjects_; /**< number of integrable objects in local processor */ |
544 |
> |
int nCutoffGroups_; /**< number of cutoff groups in local processor */ |
545 |
> |
int nConstraints_; /**< number of constraints in local processors */ |
546 |
|
|
547 |
|
simtype fInfo_; /**< A dual struct shared by c++/fortran which indicates the atom types in simulation*/ |
548 |
< |
Exclude exclude_; |
548 |
> |
PairList excludedInteractions_; |
549 |
> |
PairList oneTwoInteractions_; |
550 |
> |
PairList oneThreeInteractions_; |
551 |
> |
PairList oneFourInteractions_; |
552 |
|
PropertyMap properties_; /**< Generic Property */ |
553 |
|
SnapshotManager* sman_; /**< SnapshotManager */ |
554 |
|
|
560 |
|
*/ |
561 |
|
LocalIndexManager localIndexMan_; |
562 |
|
|
563 |
+ |
// unparsed MetaData block for storing in Dump and EOR files: |
564 |
+ |
std::string rawMetaData_; |
565 |
+ |
|
566 |
|
//file names |
567 |
|
std::string finalConfigFileName_; |
568 |
|
std::string dumpFileName_; |
569 |
|
std::string statFileName_; |
570 |
|
std::string restFileName_; |
571 |
|
|
572 |
< |
double rcut_; /**< cutoff radius*/ |
573 |
< |
double rsw_; /**< radius of switching function*/ |
572 |
> |
RealType rcut_; /**< cutoff radius*/ |
573 |
> |
RealType rsw_; /**< radius of switching function*/ |
574 |
> |
RealType rlist_; /**< neighbor list radius */ |
575 |
|
|
576 |
< |
bool fortranInitialized_; /**< flag indicate whether fortran side is initialized */ |
576 |
> |
int ljsp_; /**< use shifted potential for LJ*/ |
577 |
> |
int ljsf_; /**< use shifted force for LJ*/ |
578 |
|
|
579 |
< |
#ifdef IS_MPI |
579 |
> |
bool fortranInitialized_; /** flag to indicate whether the fortran side is initialized */ |
580 |
> |
|
581 |
> |
bool calcBoxDipole_; /**< flag to indicate whether or not we calculate |
582 |
> |
the simulation box dipole moment */ |
583 |
> |
|
584 |
> |
bool useAtomicVirial_; /**< flag to indicate whether or not we use |
585 |
> |
Atomic Virials to calculate the pressure */ |
586 |
> |
|
587 |
> |
public: |
588 |
> |
/** |
589 |
> |
* return an integral objects by its global index. In MPI version, if the StuntDouble with specified |
590 |
> |
* global index does not belong to local processor, a NULL will be return. |
591 |
> |
*/ |
592 |
> |
StuntDouble* getIOIndexToIntegrableObject(int index); |
593 |
> |
void setIOIndexToIntegrableObject(const std::vector<StuntDouble*>& v); |
594 |
> |
private: |
595 |
> |
std::vector<StuntDouble*> IOIndexToIntegrableObject; |
596 |
> |
//public: |
597 |
> |
//void setStuntDoubleFromGlobalIndex(std::vector<StuntDouble*> v); |
598 |
> |
/** |
599 |
> |
* return a StuntDouble by its global index. In MPI version, if the StuntDouble with specified |
600 |
> |
* global index does not belong to local processor, a NULL will be return. |
601 |
> |
*/ |
602 |
> |
//StuntDouble* getStuntDoubleFromGlobalIndex(int index); |
603 |
> |
//private: |
604 |
> |
//std::vector<StuntDouble*> sdByGlobalIndex_; |
605 |
> |
|
606 |
|
//in Parallel version, we need MolToProc |
607 |
|
public: |
608 |
|
|
629 |
|
void setupFortranParallel(); |
630 |
|
|
631 |
|
/** |
632 |
< |
* The size of molToProcMap_ is equal to total number of molecules in the system. |
633 |
< |
* It maps a molecule to the processor on which it resides. it is filled by SimCreator once and only |
634 |
< |
* once. |
632 |
> |
* The size of molToProcMap_ is equal to total number of molecules |
633 |
> |
* in the system. It maps a molecule to the processor on which it |
634 |
> |
* resides. it is filled by SimCreator once and only once. |
635 |
|
*/ |
636 |
|
std::vector<int> molToProcMap_; |
637 |
|
|
555 |
– |
#endif |
638 |
|
|
639 |
|
}; |
640 |
|
|
641 |
< |
} //namespace oopse |
641 |
> |
} //namespace OpenMD |
642 |
|
#endif //BRAINS_SIMMODEL_HPP |
643 |
|
|