--- trunk/src/brains/SimInfo.hpp 2005/12/02 15:38:03 770 +++ branches/development/src/brains/SimInfo.hpp 2010/10/02 19:54:41 1503 @@ -6,19 +6,10 @@ * redistribute this software in source and binary code form, provided * that the following conditions are met: * - * 1. Acknowledgement of the program authors must be made in any - * publication of scientific results based in part on use of the - * program. An acceptable form of acknowledgement is citation of - * the article in which the program was described (Matthew - * A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher - * J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented - * Parallel Simulation Engine for Molecular Dynamics," - * J. Comput. Chem. 26, pp. 252-271 (2005)) - * - * 2. Redistributions of source code must retain the above copyright + * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - * 3. Redistributions in binary form must reproduce the above copyright + * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. @@ -37,6 +28,15 @@ * arising out of the use of or inability to use software, even if the * University of Notre Dame has been advised of the possibility of * such damages. + * + * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your + * research, please cite the appropriate papers when you publish your + * work. Good starting points are: + * + * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). + * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). + * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). + * [4] Vardeman & Gezelter, in progress (2009). */ /** @@ -54,7 +54,7 @@ #include #include -#include "brains/Exclude.hpp" +#include "brains/PairList.hpp" #include "io/Globals.hpp" #include "math/Vector3.hpp" #include "math/SquareMatrix3.hpp" @@ -62,27 +62,29 @@ #include "UseTheForce/ForceField.hpp" #include "utils/PropertyMap.hpp" #include "utils/LocalIndexManager.hpp" +#include "nonbonded/Electrostatic.hpp" //another nonsense macro declaration -#define __C +#define __OPENMD_C #include "brains/fSimulation.h" -namespace oopse{ +namespace OpenMD{ //forward decalration class SnapshotManager; class Molecule; class SelectionManager; + class StuntDouble; + class Electrostatic; /** * @class SimInfo SimInfo.hpp "brains/SimInfo.hpp" - * @brief As one of the heavy weight class of OOPSE, SimInfo - * One of the major changes in SimInfo class is the data struct. It only maintains a list of molecules. - * And the Molecule class will maintain all of the concrete objects (atoms, bond, bend, torsions, rigid bodies, - * cutoff groups, constrains). - * Another major change is the index. No matter single version or parallel version, atoms and - * rigid bodies have both global index and local index. Local index is not important to molecule as well as - * cutoff group. - */ + * @brief One of the heavy weight classes of OpenMD, SimInfo maintains a list of molecules. + * The Molecule class maintains all of the concrete objects + * (atoms, bond, bend, torsions, inversions, rigid bodies, cutoff groups, + * constraints). In both the single and parallel versions, atoms and + * rigid bodies have both global and local indices. The local index is + * not relevant to molecules or cutoff groups. + */ class SimInfo { public: typedef std::map::iterator MoleculeIterator; @@ -171,6 +173,10 @@ namespace oopse{ return nTorsions_; } + /** Returns the number of local torsions */ + unsigned int getNInversions() { + return nInversions_; + } /** Returns the number of local rigid bodies */ unsigned int getNRigidBodies() { return nRigidBodies_; @@ -207,7 +213,7 @@ namespace oopse{ /** Returns the number of degrees of freedom */ int getNdf() { - return ndf_; + return ndf_ - getFdf(); } /** Returns the number of raw degrees of freedom */ @@ -220,6 +226,13 @@ namespace oopse{ return ndfTrans_; } + /** sets the current number of frozen degrees of freedom */ + void setFdf(int fdf) { + fdf_local = fdf; + } + + int getFdf(); + //getNZconstraint and setNZconstraint ruin the coherent of SimInfo class, need refactorying /** Returns the total number of z-constraint molecules in the system */ @@ -265,6 +278,10 @@ namespace oopse{ /** Returns system angular momentum */ Vector3d getAngularMomentum(); + /** Returns volume of system as estimated by an ellipsoid defined by the radii of gyration*/ + void getGyrationalVolume(RealType &vol); + /** Overloaded version of gyrational volume that also returns det(I) so dV/dr can be calculated*/ + void getGyrationalVolume(RealType &vol, RealType &detI); /** main driver function to interact with fortran during the initialization and molecule migration */ void update(); @@ -299,26 +316,37 @@ namespace oopse{ return i != molecules_.end() ? i->second : NULL; } - double getRcut() { + int getGlobalMolMembership(int id){ + return globalMolMembership_[id]; + } + + RealType getRcut() { return rcut_; } - double getRsw() { + RealType getRsw() { return rsw_; } - double getList() { + RealType getList() { return rlist_; } std::string getFinalConfigFileName() { return finalConfigFileName_; } - + void setFinalConfigFileName(const std::string& fileName) { finalConfigFileName_ = fileName; } + std::string getRawMetaData() { + return rawMetaData_; + } + void setRawMetaData(const std::string& rawMetaData) { + rawMetaData_ = rawMetaData; + } + std::string getDumpFileName() { return dumpFileName_; } @@ -348,7 +376,7 @@ namespace oopse{ * @see #SimCreator::setGlobalIndex */ void setGlobalGroupMembership(const std::vector& globalGroupMembership) { - assert(globalGroupMembership.size() == nGlobalAtoms_); + assert(globalGroupMembership.size() == static_cast(nGlobalAtoms_)); globalGroupMembership_ = globalGroupMembership; } @@ -357,7 +385,7 @@ namespace oopse{ * @see #SimCreator::setGlobalIndex */ void setGlobalMolMembership(const std::vector& globalMolMembership) { - assert(globalMolMembership.size() == nGlobalAtoms_); + assert(globalMolMembership.size() == static_cast(nGlobalAtoms_)); globalMolMembership_ = globalMolMembership; } @@ -366,6 +394,14 @@ namespace oopse{ return fortranInitialized_; } + bool getCalcBoxDipole() { + return calcBoxDipole_; + } + + bool getUseAtomicVirial() { + return useAtomicVirial_; + } + //below functions are just forward functions //To compose or to inherit is always a hot debate. In general, is-a relation need subclassing, in the //the other hand, has-a relation need composing. @@ -407,23 +443,24 @@ namespace oopse{ GenericData* getPropertyByName(const std::string& propName); /** - * add all exclude pairs of a molecule into exclude list. + * add all special interaction pairs (including excluded + * interactions) in a molecule into the appropriate lists. */ - void addExcludePairs(Molecule* mol); + void addInteractionPairs(Molecule* mol); /** - * remove all exclude pairs which belong to a molecule from exclude list + * remove all special interaction pairs which belong to a molecule + * from the appropriate lists. */ + void removeInteractionPairs(Molecule* mol); - void removeExcludePairs(Molecule* mol); - /** Returns the unique atom types of local processor in an array */ std::set getUniqueAtomTypes(); friend std::ostream& operator <<(std::ostream& o, SimInfo& info); - void getCutoff(double& rcut, double& rsw); + void getCutoff(RealType& rcut, RealType& rsw); private: @@ -445,6 +482,9 @@ namespace oopse{ /** Figure out which polynomial type to use for the switching function */ void setupSwitchingFunction(); + /** Determine if we need to accumulate the simulation box dipole */ + void setupAccumulateBoxDipole(); + /** Calculates the number of degress of freedom in the whole system */ void calcNdf(); void calcNdfRaw(); @@ -463,6 +503,8 @@ namespace oopse{ //degress of freedom int ndf_; /**< number of degress of freedom (excludes constraints), ndf_ is local */ + int fdf_local; /**< number of frozen degrees of freedom */ + int fdf_; /**< number of frozen degrees of freedom */ int ndfRaw_; /**< number of degress of freedom (includes constraints), ndfRaw_ is local */ int ndfTrans_; /**< number of translation degress of freedom, ndfTrans_ is local */ int nZconstraint_; /** number of z-constraint molecules, nZconstraint_ is global */ @@ -481,7 +523,7 @@ namespace oopse{ std::vector globalGroupMembership_; /** - * the size of globalGroupMembership_ is nGlobalAtoms. Its index is global index of an atom, and the + * the size of globalMolMembership_ is nGlobalAtoms. Its index is global index of an atom, and the * corresponding content is the global index of molecule this atom belong to. * It is filled by SimCreator once and only once, since it is never changed during the simulation. */ @@ -492,17 +534,21 @@ namespace oopse{ std::vector moleculeStamps_; /**< molecule stamps array */ //number of local objects - int nAtoms_; /**< number of atoms in local processor */ - int nBonds_; /**< number of bonds in local processor */ - int nBends_; /**< number of bends in local processor */ - int nTorsions_; /**< number of torsions in local processor */ - int nRigidBodies_; /**< number of rigid bodies in local processor */ - int nIntegrableObjects_; /**< number of integrable objects in local processor */ - int nCutoffGroups_; /**< number of cutoff groups in local processor */ - int nConstraints_; /**< number of constraints in local processors */ + int nAtoms_; /**< number of atoms in local processor */ + int nBonds_; /**< number of bonds in local processor */ + int nBends_; /**< number of bends in local processor */ + int nTorsions_; /**< number of torsions in local processor */ + int nInversions_; /**< number of inversions in local processor */ + int nRigidBodies_; /**< number of rigid bodies in local processor */ + int nIntegrableObjects_; /**< number of integrable objects in local processor */ + int nCutoffGroups_; /**< number of cutoff groups in local processor */ + int nConstraints_; /**< number of constraints in local processors */ simtype fInfo_; /**< A dual struct shared by c++/fortran which indicates the atom types in simulation*/ - Exclude exclude_; + PairList excludedInteractions_; + PairList oneTwoInteractions_; + PairList oneThreeInteractions_; + PairList oneFourInteractions_; PropertyMap properties_; /**< Generic Property */ SnapshotManager* sman_; /**< SnapshotManager */ @@ -514,19 +560,49 @@ namespace oopse{ */ LocalIndexManager localIndexMan_; + // unparsed MetaData block for storing in Dump and EOR files: + std::string rawMetaData_; + //file names std::string finalConfigFileName_; std::string dumpFileName_; std::string statFileName_; std::string restFileName_; - double rcut_; /**< cutoff radius*/ - double rsw_; /**< radius of switching function*/ - double rlist_; /**< neighbor list radius */ + RealType rcut_; /**< cutoff radius*/ + RealType rsw_; /**< radius of switching function*/ + RealType rlist_; /**< neighbor list radius */ - bool fortranInitialized_; /**< flag indicate whether fortran side is initialized */ + int ljsp_; /**< use shifted potential for LJ*/ + int ljsf_; /**< use shifted force for LJ*/ -#ifdef IS_MPI + bool fortranInitialized_; /** flag to indicate whether the fortran side is initialized */ + + bool calcBoxDipole_; /**< flag to indicate whether or not we calculate + the simulation box dipole moment */ + + bool useAtomicVirial_; /**< flag to indicate whether or not we use + Atomic Virials to calculate the pressure */ + + public: + /** + * return an integral objects by its global index. In MPI version, if the StuntDouble with specified + * global index does not belong to local processor, a NULL will be return. + */ + StuntDouble* getIOIndexToIntegrableObject(int index); + void setIOIndexToIntegrableObject(const std::vector& v); + private: + std::vector IOIndexToIntegrableObject; + //public: + //void setStuntDoubleFromGlobalIndex(std::vector v); + /** + * return a StuntDouble by its global index. In MPI version, if the StuntDouble with specified + * global index does not belong to local processor, a NULL will be return. + */ + //StuntDouble* getStuntDoubleFromGlobalIndex(int index); + //private: + //std::vector sdByGlobalIndex_; + //in Parallel version, we need MolToProc public: @@ -553,16 +629,15 @@ namespace oopse{ void setupFortranParallel(); /** - * The size of molToProcMap_ is equal to total number of molecules in the system. - * It maps a molecule to the processor on which it resides. it is filled by SimCreator once and only - * once. + * The size of molToProcMap_ is equal to total number of molecules + * in the system. It maps a molecule to the processor on which it + * resides. it is filled by SimCreator once and only once. */ std::vector molToProcMap_; -#endif }; -} //namespace oopse +} //namespace OpenMD #endif //BRAINS_SIMMODEL_HPP