ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-3.0/src/brains/SimInfo.hpp
(Generate patch)

Comparing:
trunk/OOPSE-3.0/src/brains/SimInfo.hpp (file contents), Revision 1490 by gezelter, Fri Sep 24 04:16:43 2004 UTC vs.
branches/new_design/OOPSE-3.0/src/brains/SimInfo.hpp (file contents), Revision 1733 by tim, Fri Nov 12 06:19:04 2004 UTC

# Line 1 | Line 1
1 < #ifndef __SIMINFO_H__
2 < #define __SIMINFO_H__
1 > /*
2 > * Copyright (C) 2000-2004  Object Oriented Parallel Simulation Engine (OOPSE) project
3 > *
4 > * Contact: oopse@oopse.org
5 > *
6 > * This program is free software; you can redistribute it and/or
7 > * modify it under the terms of the GNU Lesser General Public License
8 > * as published by the Free Software Foundation; either version 2.1
9 > * of the License, or (at your option) any later version.
10 > * All we ask is that proper credit is given for our work, which includes
11 > * - but is not limited to - adding the above copyright notice to the beginning
12 > * of your source code files, and to any copyright notice that you may distribute
13 > * with programs based on this work.
14 > *
15 > * This program is distributed in the hope that it will be useful,
16 > * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 > * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 > * GNU Lesser General Public License for more details.
19 > *
20 > * You should have received a copy of the GNU Lesser General Public License
21 > * along with this program; if not, write to the Free Software
22 > * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23 > *
24 > */
25  
26 < #include <map>
27 < #include <string>
28 < #include <vector>
26 > /**
27 > * @file SimInfo.hpp
28 > * @author    tlin
29 > * @date  11/02/2004
30 > * @version 1.0
31 > */
32  
33 < #include "Atom.hpp"
34 < #include "RigidBody.hpp"
10 < #include "Molecule.hpp"
11 < #include "Exclude.hpp"
12 < #include "SkipList.hpp"
13 < #include "AbstractClasses.hpp"
14 < #include "MakeStamps.hpp"
15 < #include "SimState.hpp"
16 < #include "Restraints.hpp"
33 > #ifndef BRAINS_SIMMODEL_HPP
34 > #define BRAINS_SIMMODEL_HPP
35  
36 < #define __C
37 < #include "fSimulation.h"
38 < #include "fortranWrapDefines.hpp"
21 < #include "GenericData.hpp"
36 > #include <iostream>
37 > #include <vector>
38 > #include <utility>
39  
40 + #include "brains/fSimulation.h"
41 + #include "primitives/Molecule.hpp"
42 + #include "types/MoleculeStamp.hpp"
43 + #include "utils/PropertyMap.hpp"
44 + #include "io/Globals.hpp"
45  
46 < //#include "Minimizer.hpp"
25 < //#include "OOPSEMinimizer.hpp"
46 > namespace oopse{
47  
48 + /**
49 + * @class SimInfo SimInfo.hpp "brains/SimInfo.hpp"
50 + * @brief
51 + */
52 + class SimInfo {
53 +    public:
54 +        typedef MoleculeIterator MoleculeIterator;
55  
56 < double roundMe( double x );
57 < class OOPSEMinimizer;
58 < class SimInfo{
56 >        /**
57 >         * Constructor of SimInfo
58 >         * @param molStampPairs MoleculeStamp Array. The first element of the pair is molecule stamp, the
59 >         * second element is the total number of molecules with the same molecule stamp in the system
60 >         * @param ff pointer of a concrete ForceField instance
61 >         * @param globals
62 >         * @note
63 >         * <p>
64 >         * The major change of SimInfo
65 >         * </p>
66 >         */
67 >        SimInfo(const std::vector<std::pair<MoleculeStamp*, int> >& molStampPairs, ForceField* ff, Globals* globals);
68 >        virtual ~SimInfo();
69  
70 < public:
70 >        /**
71 >         * Adds a molecule
72 >         * @return return true if adding successfully, return false if the molecule is already in SimInfo
73 >         * @param mol molecule to be added
74 >         */
75 >        bool addMolecule(Molecule* mol);
76  
77 <  SimInfo();
78 <  ~SimInfo();
77 >        /**
78 >         * Removes a molecule from SimInfo
79 >         * @return true if removing successfully, return false if molecule is not in this SimInfo
80 >         */
81 >        bool removeMolecule(Molecule* mol);
82  
83 <  int n_atoms; // the number of atoms
84 <  Atom **atoms; // the array of atom objects
83 >        /** Returns the total number of molecules in the system. */
84 >        int getNGlobalMolecules() {
85 >            return nGlobalMols_;
86 >        }
87  
88 <  vector<RigidBody*> rigidBodies;  // A vector of rigid bodies
89 <  vector<StuntDouble*> integrableObjects;
90 <  
91 <  double tau[9]; // the stress tensor
88 >        /** Returns the total number of atoms in the system. */
89 >        int getNGlobalAtoms() {
90 >            return nGlobalAtoms_;
91 >        }
92  
93 <  int n_bonds;    // number of bends
94 <  int n_bends;    // number of bends
95 <  int n_torsions; // number of torsions
96 <  int n_oriented; // number of of atoms with orientation
97 <  int ndf;        // number of actual degrees of freedom
98 <  int ndfRaw;     // number of settable degrees of freedom
99 <  int ndfTrans;   // number of translational degrees of freedom
100 <  int nZconstraints; // the number of zConstraints
93 >        /** Returns the total number of cutoff groups in the system. */
94 >        int getNGlobalCutoffGroups() {
95 >            return nGlobalCutoffGroups_;
96 >        }
97 >        
98 >        /**
99 >         * Returns the number of local molecules.
100 >         * @return the number of local molecules
101 >         */
102 >        int getNMolecules() {
103 >            return molecules_.size();
104 >        }
105  
106 <  int setTemp;   // boolean to set the temperature at each sampleTime
107 <  int resetIntegrator; // boolean to reset the integrator
106 >        /** Returns the number of local atoms */
107 >        unsigned int getNAtoms() {
108 >            return nAtoms_;
109 >        }
110  
111 <  int n_dipoles; // number of dipoles
111 >        /** Returns the number of local bonds */        
112 >        unsigned int getNBonds(){
113 >            return nBonds_;
114 >        }
115  
116 <  int n_exclude;
117 <  Exclude* excludes;  // the exclude list for ignoring pairs in fortran
118 <  int nGlobalExcludes;
119 <  int* globalExcludes; // same as above, but these guys participate in
63 <                       // no long range forces.
116 >        /** Returns the number of local bends */        
117 >        unsigned int getNBends() {
118 >            return nBends_;
119 >        }
120  
121 <  int* identArray;     // array of unique identifiers for the atoms
122 <  int* molMembershipArray;  // map of atom numbers onto molecule numbers
121 >        /** Returns the number of local torsions */        
122 >        unsigned int getNTorsions() {
123 >            return nTorsions_;
124 >        }
125  
126 <  int n_constraints; // the number of constraints on the system
126 >        /** Returns the number of local rigid bodies */        
127 >        unsigned int getNRigidBodies() {
128 >            return nRigidBodies_;
129 >        }
130  
131 <  int n_SRI;   // the number of short range interactions
131 >        /** Returns the number of local integrable objects */
132 >        unsigned int getNIntegrableObjects() {
133 >            return nIntegrableObjects_;
134 >        }
135  
136 <  double lrPot; // the potential energy from the long range calculations.
136 >        /** Returns the number of local cutoff groups */
137 >        unsigned int getNCutoffGroups() {
138 >            return nCutoffGroups_;
139 >        }
140  
141 <  double Hmat[3][3];  // the periodic boundry conditions. The Hmat is the
142 <                      // column vectors of the x, y, and z box vectors.
143 <                      //   h1  h2  h3
144 <                      // [ Xx  Yx  Zx ]
145 <                      // [ Xy  Yy  Zy ]
146 <                      // [ Xz  Yz  Zz ]
147 <                      //  
148 <  double HmatInv[3][3];
141 >        /** Returns the total number of constraints in this SimInfo */
142 >        unsigned int getNConstraints() {
143 >            return nConstraints_;
144 >        }
145 >        
146 >        /**
147 >         * Returns the first molecule in this SimInfo and intialize the iterator.
148 >         * @return the first molecule, return NULL if there is not molecule in this SimInfo
149 >         * @param i the iterator of molecule array (user shouldn't change it)
150 >         */
151 >        Molecule* beginMolecule(MoleculeIterator& i);
152  
153 <  double boxL[3]; // The Lengths of the 3 column vectors of Hmat
154 <  double boxVol;
155 <  int orthoRhombic;
156 <  
153 >        /**
154 >          * Returns the next avaliable Molecule based on the iterator.
155 >          * @return the next avaliable molecule, return NULL if reaching the end of the array
156 >          * @param i the iterator of molecule array
157 >          */
158 >        Molecule* nextMolecule(MoleculeIterator& i);
159  
160 <  double dielectric;      // the dielectric of the medium for reaction field
160 >        /** Returns the number of degrees of freedom */
161 >        int getNdf() {
162 >            return ndf_;
163 >        }
164  
165 <  
166 <  int usePBC; // whether we use periodic boundry conditions.
167 <  int useLJ;
168 <  int useSticky;
94 <  int useCharges;
95 <  int useDipoles;
96 <  int useReactionField;
97 <  int useGB;
98 <  int useEAM;
99 <  bool haveCutoffGroups;
100 <  bool useInitXSstate;
101 <  double orthoTolerance;
165 >        /** Returns the number of raw degrees of freedom */
166 >        int getNdfRaw() {
167 >            return ndfRaw_;
168 >        }
169  
170 <  double dt, run_time;           // the time step and total time
171 <  double sampleTime, statusTime; // the position and energy dump frequencies
172 <  double target_temp;            // the target temperature of the system
173 <  double thermalTime;            // the temp kick interval
107 <  double currentTime;            // Used primarily for correlation Functions
108 <  double resetTime;              // Use to reset the integrator periodically
109 <  short int have_target_temp;
170 >        /** Returns the number of translational degrees of freedom */
171 >        int getNdfTrans() {
172 >            return ndfTrans_;
173 >        }
174  
175 <  int n_mol;           // n_molecules;
176 <  Molecule* molecules; // the array of molecules
177 <  
178 <  int nComponents;           // the number of components in the system
179 <  int* componentsNmol;       // the number of molecules of each component
180 <  MoleculeStamp** compStamps;// the stamps matching the components
117 <  LinkedMolStamp* headStamp; // list of stamps used in the simulation
118 <  
119 <  
120 <  char ensemble[100]; // the enesemble of the simulation (NVT, NVE, etc. )
121 <  char mixingRule[100]; // the mixing rules for Lennard jones/van der walls
122 <  BaseIntegrator *the_integrator; // the integrator of the simulation
175 >        //getNZconstraint and setNZconstraint ruin the coherent of SimInfo class, need refactorying
176 >        
177 >        /** Returns the total number of z-constraint molecules in the system */
178 >        int getNZconstraint() {
179 >            return nZconstraint_;
180 >        }
181  
182 <  OOPSEMinimizer* the_minimizer; // the energy minimizer
183 <  Restraints* restraint;
184 <  bool has_minimizer;
182 >        /**
183 >         * Sets the number of z-constraint molecules in the system.
184 >         */
185 >        int setNZconstraint(int nZconstraint) {
186 >            nZconstraint_ = nZconstraint;
187 >        }
188 >        
189 >        /** Returns the snapshot manager. */
190 >        SnapshotManager* getSnapshotManager() {
191 >            return sman_;
192 >        }
193  
194 <  string finalName;  // the name of the eor file to be written
195 <  string sampleName; // the name of the dump file to be written
196 <  string statusName; // the name of the stat file to be written
194 >        /** Sets the snapshot manager. */
195 >        void setSnapshotManager(SnapshotManager* sman) {
196 >            sman_ = sman;
197 >        }
198  
199 <  int seed;                    //seed for random number generator
199 >        /** Returns the force field */
200 >        ForceField* getForceField() {
201 >            return forceField_;
202 >        }
203  
204 <  int useSolidThermInt;  // is solid-state thermodynamic integration being used
205 <  int useLiquidThermInt; // is liquid thermodynamic integration being used
206 <  double thermIntLambda; // lambda for TI
137 <  double thermIntK;      // power of lambda for TI
138 <  double vRaw;           // unperturbed potential for TI
139 <  double vHarm;          // harmonic potential for TI
140 <  int i;                 // just an int
204 >        Globals* getGlobals() {
205 >            return globals_;
206 >        }
207  
208 <  vector<double> mfact;
209 <  vector<int> FglobalGroupMembership;
144 <  int ngroup;
145 <  int* globalGroupMembership;
208 >        /** Returns the velocity of center of mass of the whole system.*/
209 >        Vector3d getComVel();
210  
211 <  // refreshes the sim if things get changed (load balanceing, volume
212 <  // adjustment, etc.)
211 >        /** Returns the center of the mass of the whole system.*/
212 >        Vector3d getCom();
213  
214 <  void refreshSim( void );
215 <  
214 >        /** Returns the seed (used for random number generator) */
215 >        int getSeed() {
216 >            return seed_;
217 >        }
218  
219 <  // sets the internal function pointer to fortran.
219 >        /** Sets the seed*/
220 >        void setSeed(int seed) {
221 >            seed_ = seed;
222 >        }
223  
224 <  void setInternal( setFortranSim_TD fSetup,
225 <                    setFortranBox_TD fBox,
157 <                    notifyFortranCutOff_TD fCut){
158 <    setFsimulation = fSetup;
159 <    setFortranBoxSize = fBox;
160 <    notifyFortranCutOffs = fCut;
161 <  }
224 >        /** main driver function to interact with fortran during the initialization and molecule migration */
225 >        void update();
226  
227 <  int getNDF();
228 <  int getNDFraw();
229 <  int getNDFtranslational();
230 <  int getTotIntegrableObjects();
167 <  void setBox( double newBox[3] );
168 <  void setBoxM( double newBox[3][3] );
169 <  void getBoxM( double theBox[3][3] );
170 <  void scaleBox( double scale );
171 <  
172 <  void setDefaultRcut( double theRcut );
173 <  void setDefaultRcut( double theRcut, double theRsw );
174 <  void checkCutOffs( void );
227 >        /** Returns the local index manager */
228 >        LocalIndexManager* getLocalIndexManager() {
229 >            return localIndexMan_;
230 >        }
231  
232 <  double getRcut( void )  { return rCut; }
233 <  double getRlist( void ) { return rList; }
234 <  double getRsw( void )   { return rSw; }
235 <  double getMaxCutoff( void ) { return maxCutoff; }
180 <  
181 <  void setTime( double theTime ) { currentTime = theTime; }
182 <  void incrTime( double the_dt ) { currentTime += the_dt; }
183 <  void decrTime( double the_dt ) { currentTime -= the_dt; }
184 <  double getTime( void ) { return currentTime; }
232 >        int getMoleculeStampId(int globalIndex) {
233 >            //assert(globalIndex < molStampIds_.size())
234 >            return molStampIds_[globalIndex];
235 >        }
236  
237 <  void wrapVector( double thePos[3] );
237 >        /** Returns the molecule stamp */
238 >        MoleculeStamp* getMoleculeStamp(int id) {
239 >            return moleculeStamps_[id];
240 >        }
241 >        
242 >        /**
243 >         * Finds a molecule with a specified global index
244 >         * @return a pointer point to found molecule
245 >         * @param index
246 >         */
247 >        Molecule* getMoleculeByGlobalIndex(int index) {
248 >            std::map<int, Molecule*> i;
249 >            i = molecules_.find(index);
250  
251 <  SimState* getConfiguration( void ) { return myConfiguration; }
252 <  
190 <  void addProperty(GenericData* prop);
191 <  GenericData* getProperty(const string& propName);
192 <  //vector<GenericData*>& getProperties()  {return properties;}    
251 >            return i != molecules_.end() ? i->second : NULL;
252 >        }
253  
254 <  int getSeed(void) {  return seed; }
255 <  void setSeed(int theSeed) {  seed = theSeed;}
254 >        /** Returns the unique atom types of local processor in an array */
255 >        std::set<AtomType*> SimInfo::getUniqueAtomTypes();
256  
257 < private:
257 >        std::string getFinalConfigFileName() {
258 >            return finalConfigFileName_;
259 >        }
260 >        
261 >        void setFinalConfigFileName(const std::string& fileName) {
262 >            finalConfigFileName_ = fileName;
263 >        }
264  
199  SimState* myConfiguration;
265  
266 <  int boxIsInit, haveRcut, haveRsw;
266 >        std::string getDumpFileName() {
267 >            return dumpFileName_;
268 >        }
269 >        
270 >        void setDumpFileName(const std::string& fileName) {
271 >            dumpFileName_ = fileName;
272 >        }
273  
274 <  double rList, rCut; // variables for the neighborlist
275 <  double rSw;         // the switching radius
274 >        std::string getStatFileName() {
275 >            return statFileName_;
276 >        }
277 >        
278 >        void setStatFileName(const std::string& fileName) {
279 >            statFileName_ = fileName;
280 >        }
281  
282 <  double maxCutoff;
282 >        int* getGlobalGroupMembershipPointer() {
283 >            return globalGroupMembership_[0];
284 >        }
285  
286 <  double distXY;
287 <  double distYZ;
288 <  double distZX;
289 <  
290 <  void calcHmatInv( void );
291 <  void calcBoxL();
292 <  double calcMaxCutOff();
286 >        //below functions are just forward functions
287 >        //To compose or to inherit is always a hot debate. In general, is-a relation need subclassing, in the
288 >        //the other hand, has-a relation need composing.
289 >        /**
290 >         * Adds property into property map
291 >         * @param genData GenericData to be added into PropertyMap
292 >         */
293 >        void addProperty(GenericData* genData);
294  
295 <  // private function to initialize the fortran side of the simulation
296 <  setFortranSim_TD setFsimulation;
295 >        /**
296 >         * Removes property from PropertyMap by name
297 >         * @param propName the name of property to be removed
298 >         */
299 >        void removeProperty(const std::string& propName);
300  
301 <  setFortranBox_TD setFortranBoxSize;
302 <  
303 <  notifyFortranCutOff_TD notifyFortranCutOffs;
304 <  
223 <  //Addtional Properties of SimInfo
224 <  map<string, GenericData*> properties;
225 <  void getFortranGroupArrays(SimInfo* info,
226 <                             vector<int>& FglobalGroupMembership,
227 <                             vector<double>& mfact);
301 >        /**
302 >         * clear all of the properties
303 >         */
304 >        void clearProperties();
305  
306 +        /**
307 +         * Returns all names of properties
308 +         * @return all names of properties
309 +         */
310 +        std::vector<std::string> getPropertyNames();
311  
312 < };
312 >        /**
313 >         * Returns all of the properties in PropertyMap
314 >         * @return all of the properties in PropertyMap
315 >         */      
316 >        std::vector<GenericData*> getProperties();
317  
318 +        /**
319 +         * Returns property
320 +         * @param propName name of property
321 +         * @return a pointer point to property with propName. If no property named propName
322 +         * exists, return NULL
323 +         */      
324 +        GenericData* getPropertyByName(const std::string& propName);
325 +                
326 +        friend std::ostream& operator <<(ostream& o, SimInfo& info);
327 +        
328 +    private:
329  
330 +        void setupSimType();
331 +
332 +        /**
333 +         * Setup Fortran Simulation
334 +         * @see #setupFortranParallel
335 +         */
336 +        void setupFortranSim();
337 +
338 +        /** Calculates the number of degress of freedom in the whole system */
339 +        void calcNdf();
340 +        void calcNdfRaw();
341 +        void calcNdfTrans();
342 +
343 +        void addExcludePairs(Molecule* mol);
344 +        void removeExcludePairs(Molecule* mol);
345 +
346 +        /**
347 +         * Adds molecule stamps into
348 +         */
349 +        void addMoleculeStamp(MoleculeStamp* molStamp, int nmol);
350 +
351 +        std::map<int, Molecule*>  molecules_; /**< Molecule array */
352 +        
353 +        //degress of freedom
354 +        int ndf_;           /**< number of degress of freedom (excludes constraints),  ndf_ is local */
355 +        int ndfRaw_;    /**< number of degress of freedom (includes constraints),  ndfRaw_ is local */
356 +        int ndfTrans_; /**< number of translation degress of freedom, ndfTrans_ is local */
357 +        int nZconstraint_; /** number of  z-constraint molecules, nZconstraint_ is global */
358 +        
359 +        //number of global objects
360 +        int nGlobalMols_;       /**< number of molecules in the system */
361 +        int nGlobalAtoms_;   /**< number of atoms in the system */
362 +        int nGlobalCutoffGroups_; /**< number of cutoff groups in this system */
363 +
364 +        /**
365 +         * the size of globalGroupMembership_  is nGlobalAtoms. Its index is  global index of an atom, and the
366 +         * corresponding content is the global index of cutoff group this atom belong to.
367 +         * It is filled by SimCreator once and only once, since it is never changed during the simulation.
368 +         */
369 +        std::vector<int> globalGroupMembership_;
370 +        
371 +        std::vector<int> molStampIds_;                                /**< stamp id array of all molecules in the system */
372 +        std::vector<MoleculeStamp*> moleculeStamps_;      /**< molecule stamps array */        
373 +        
374 +        //number of local objects
375 +        int nAtoms_;                        /**< number of atoms in local processor */
376 +        int nBonds_;                        /**< number of bonds in local processor */
377 +        int nBends_;                        /**< number of bends in local processor */
378 +        int nTorsions_;                    /**< number of torsions in local processor */
379 +        int nRigidBodies_;              /**< number of rigid bodies in local processor */
380 +        int nIntegrableObjects_;    /**< number of integrable objects in local processor */
381 +        int nCutoffGroups_;             /**< number of cutoff groups in local processor */
382 +        int nConstraints_;              /**< number of constraints in local processors */
383 +
384 +        simtype fInfo_; /**< A dual struct shared by c++/fortran which indicates the atom types in simulation*/
385 +        Exclude exclude_;
386 +        ForceField* forceField_;            
387 +        PropertyMap properties_;                  /**< Generic Property */
388 +        SnapshotManager* sman_;               /**< SnapshotManager */
389 +        Globals* globals_;
390 +        int seed_; /**< seed for random number generator */
391 +
392 +        LocalIndexManager localIndexMan_;
393 +
394 +        std::string finalConfigFileName_;
395 +        std::string dumpFileName_;
396 +        std::string statFileName_;
397 +        
398 + #ifdef IS_MPI
399 +    //in Parallel version, we need MolToProc
400 +    public:
401 +                
402 +        /**
403 +         * Finds the processor where a molecule resides
404 +         * @return the id of the processor which contains the molecule
405 +         * @param globalIndex global Index of the molecule
406 +         */
407 +        int getMolToProc(int globalIndex) {
408 +            //assert(globalIndex < molToProcMap_.size());
409 +            return molToProcMap_[globalIndex];
410 +        }
411 +
412 +        int* getMolToProcMapPointer() {
413 +            return &molToProcMap_[0];
414 +        }
415 +        
416 +    private:
417 +
418 +        void setupFortranParallel();
419 +        
420 +        /**
421 +         * The size of molToProcMap_ is equal to total number of molecules in the system.
422 +         *  It maps a molecule to the processor on which it resides. it is filled by SimCreator once and only
423 +         * once.
424 +         */        
425 +        std::vector<int> molToProcMap_;
426   #endif
427 +
428 + };
429 +
430 + } //namespace oopse
431 + #endif //BRAINS_SIMMODEL_HPP

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines