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 1725 by tim, Wed Nov 10 22:01:06 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 std::vector<Molecule*>::iterator MoleculeIterator;
55 +        SimInfo();
56 +        virtual ~SimInfo();
57  
58 < double roundMe( double x );
59 < class OOPSEMinimizer;
60 < class SimInfo{
58 >        /**
59 >         * Adds a molecule
60 >         * @return return true if adding successfully, return false if the molecule is already in SimInfo
61 >         * @param mol molecule to be added
62 >         */
63 >        bool addMolecule(Molecule* mol);
64  
65 < public:
65 >        /**
66 >         * Removes a molecule from SimInfo
67 >         * @return true if removing successfully, return false if molecule is not in this SimInfo
68 >         */
69 >        bool removeMolecule(Molecule* mol);
70  
71 <  SimInfo();
72 <  ~SimInfo();
71 >        /** Returns the total number of molecules in the system. */
72 >        int getNGlobalMolecules() {
73  
74 <  int n_atoms; // the number of atoms
75 <  Atom **atoms; // the array of atom objects
74 > #ifdef IS_MPI
75 >        int nmols;
76 >        int totNMols;
77  
78 <  vector<RigidBody*> rigidBodies;  // A vector of rigid bodies
79 <  vector<StuntDouble*> integrableObjects;
42 <  
43 <  double tau[9]; // the stress tensor
78 >        nmols = getNMolecules();
79 >        MPI_Allreduce(&nmols, &totNMols, 1, MPI_INT,MPI_SUM, MPI_COMM_WORLD);
80  
81 <  int n_bonds;    // number of bends
82 <  int n_bends;    // number of bends
83 <  int n_torsions; // number of torsions
84 <  int n_oriented; // number of of atoms with orientation
85 <  int ndf;        // number of actual degrees of freedom
50 <  int ndfRaw;     // number of settable degrees of freedom
51 <  int ndfTrans;   // number of translational degrees of freedom
52 <  int nZconstraints; // the number of zConstraints
81 >        return totNMols;
82 > #else
83 >            return getNMolecules();
84 > #endif
85 >        }
86  
87 <  int setTemp;   // boolean to set the temperature at each sampleTime
88 <  int resetIntegrator; // boolean to reset the integrator
87 >        /** Returns the total number of atoms in the system. */
88 >        int getNGlobalAtoms() {
89  
90 <  int n_dipoles; // number of dipoles
90 > #ifdef IS_MPI
91 >        int totNAtoms;
92 >        MPI_Allreduce(&nAtoms_, &totNAtoms, 1, MPI_INT,MPI_SUM, MPI_COMM_WORLD);
93 >        return totNAtoms;
94 > #else
95 >            return nAtoms_;
96 > #endif
97 >        }
98  
99 <  int n_exclude;
100 <  Exclude* excludes;  // the exclude list for ignoring pairs in fortran
101 <  int nGlobalExcludes;
102 <  int* globalExcludes; // same as above, but these guys participate in
103 <                       // no long range forces.
99 >        /** Returns the total number of cutoff groups in the system. */
100 >        int getNGlobalCutoffGroups() {
101 > #ifdef IS_MPI
102 >        int totNGroups;
103 >        MPI_Allreduce(&nCutoffGroups_, &totNGroups, 1, MPI_INT,MPI_SUM, MPI_COMM_WORLD);
104 >        return totNGroups;
105 > #else
106 >            return nCutoffGroups_;
107 > #endif
108 >        }
109 >        
110 >        /**
111 >         * Returns the number of local molecules.
112 >         * @return the number of local molecules
113 >         */
114 >        int getNMolecules() {
115 >            return molecules_.size();
116 >        }
117  
118 <  int* identArray;     // array of unique identifiers for the atoms
119 <  int* molMembershipArray;  // map of atom numbers onto molecule numbers
118 >        /** Returns the number of local atoms */
119 >        unsigned int getNAtoms() {
120 >            return nAtoms_;
121 >        }
122  
123 <  int n_constraints; // the number of constraints on the system
123 >        /** Returns the number of local bonds */        
124 >        unsigned int getNBonds(){
125 >            return nBonds_;
126 >        }
127  
128 <  int n_SRI;   // the number of short range interactions
128 >        /** Returns the number of local bends */        
129 >        unsigned int getNBends() {
130 >            return nBends_;
131 >        }
132  
133 <  double lrPot; // the potential energy from the long range calculations.
133 >        /** Returns the number of local torsions */        
134 >        unsigned int getNTorsions() {
135 >            return nTorsions_;
136 >        }
137  
138 <  double Hmat[3][3];  // the periodic boundry conditions. The Hmat is the
139 <                      // column vectors of the x, y, and z box vectors.
140 <                      //   h1  h2  h3
141 <                      // [ Xx  Yx  Zx ]
78 <                      // [ Xy  Yy  Zy ]
79 <                      // [ Xz  Yz  Zz ]
80 <                      //  
81 <  double HmatInv[3][3];
138 >        /** Returns the number of local rigid bodies */        
139 >        unsigned int getNRigidBodies() {
140 >            return nRigidBodies_;
141 >        }
142  
143 <  double boxL[3]; // The Lengths of the 3 column vectors of Hmat
144 <  double boxVol;
145 <  int orthoRhombic;
146 <  
143 >        /** Returns the number of local integrable objects */
144 >        unsigned int getNIntegrableObjects() {
145 >            return nIntegrableObjects_;
146 >        }
147  
148 <  double dielectric;      // the dielectric of the medium for reaction field
148 >        /** Returns the number of local cutoff groups */
149 >        unsigned int getNCutoffGroups() {
150 >            return nCutoffGroups_;
151 >        }
152  
153 <  
154 <  int usePBC; // whether we use periodic boundry conditions.
155 <  int useLJ;
156 <  int useSticky;
157 <  int useCharges;
158 <  int useDipoles;
159 <  int useReactionField;
160 <  int useGB;
161 <  int useEAM;
162 <  bool haveCutoffGroups;
163 <  bool useInitXSstate;
101 <  double orthoTolerance;
153 >        /** Returns the total number of constraints in this SimInfo */
154 >        unsigned int getNConstraints() {
155 >            return nConstraints_;
156 >        }
157 >        
158 >        /**
159 >         * Returns the first molecule in this SimInfo and intialize the iterator.
160 >         * @return the first molecule, return NULL if there is not molecule in this SimInfo
161 >         * @param i the iterator of molecule array (user shouldn't change it)
162 >         */
163 >        Molecule* beginMolecule(std::vector<Molecule*>::iterator& i);
164  
165 <  double dt, run_time;           // the time step and total time
166 <  double sampleTime, statusTime; // the position and energy dump frequencies
167 <  double target_temp;            // the target temperature of the system
168 <  double thermalTime;            // the temp kick interval
169 <  double currentTime;            // Used primarily for correlation Functions
170 <  double resetTime;              // Use to reset the integrator periodically
109 <  short int have_target_temp;
165 >        /**
166 >          * Returns the next avaliable Molecule based on the iterator.
167 >          * @return the next avaliable molecule, return NULL if reaching the end of the array
168 >          * @param i the iterator of molecule array
169 >          */
170 >        Molecule* nextMolecule(std::vector<Molecule*>::iterator& i);
171  
172 <  int n_mol;           // n_molecules;
173 <  Molecule* molecules; // the array of molecules
174 <  
175 <  int nComponents;           // the number of components in the system
115 <  int* componentsNmol;       // the number of molecules of each component
116 <  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
172 >        /** Returns the number of degrees of freedom */
173 >        int getNdf() {
174 >            return ndf_;
175 >        }
176  
177 <  OOPSEMinimizer* the_minimizer; // the energy minimizer
178 <  Restraints* restraint;
179 <  bool has_minimizer;
177 >        /** Returns the number of raw degrees of freedom */
178 >        int getNdfRaw() {
179 >            return ndfRaw_;
180 >        }
181  
182 <  string finalName;  // the name of the eor file to be written
183 <  string sampleName; // the name of the dump file to be written
184 <  string statusName; // the name of the stat file to be written
182 >        /** Returns the number of translational degrees of freedom */
183 >        int getNdfTrans() {
184 >            return ndfTrans_;
185 >        }
186  
187 <  int seed;                    //seed for random number generator
187 >        /** Returns the snapshot manager. */
188 >        SnapshotManager* getSnapshotManager() {
189 >            return sman_;
190 >        }
191  
192 <  int useSolidThermInt;  // is solid-state thermodynamic integration being used
193 <  int useLiquidThermInt; // is liquid thermodynamic integration being used
194 <  double thermIntLambda; // lambda for TI
195 <  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
192 >        /** Sets the snapshot manager. */
193 >        void setSnapshotManager(SnapshotManager* sman) {
194 >            sman_ = sman;
195 >        }
196  
197 <  vector<double> mfact;
198 <  vector<int> FglobalGroupMembership;
199 <  int ngroup;
200 <  int* globalGroupMembership;
197 >        /** Returns the force field */
198 >        ForceField* getForceField() {
199 >            return forceField_;
200 >        }
201  
202 <  // refreshes the sim if things get changed (load balanceing, volume
203 <  // adjustment, etc.)
202 >        /** Sets the force field */
203 >        void setForceField(ForceField* ff) {
204 >            forceField_ = ff;
205 >        }
206  
207 <  void refreshSim( void );
208 <  
207 >        Globals* getGlobals() {
208 >            return globals_;
209 >        }
210 >        
211 >        void setGlobals(Globals* globals) {
212 >            globals_ = globals;
213 >        }
214  
215 <  // sets the internal function pointer to fortran.
215 >        /** Returns the velocity of center of mass of the whole system.*/
216 >        Vector3d getComVel();
217  
218 <  void setInternal( setFortranSim_TD fSetup,
219 <                    setFortranBox_TD fBox,
157 <                    notifyFortranCutOff_TD fCut){
158 <    setFsimulation = fSetup;
159 <    setFortranBoxSize = fBox;
160 <    notifyFortranCutOffs = fCut;
161 <  }
218 >        /** Returns the center of the mass of the whole system.*/
219 >        Vector3d getCom();
220  
221 <  int getNDF();
222 <  int getNDFraw();
223 <  int getNDFtranslational();
224 <  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 );
221 >        /** Returns the seed (used for random number generator) */
222 >        int getSeed() {
223 >            return seed_;
224 >        }
225  
226 <  double getRcut( void )  { return rCut; }
227 <  double getRlist( void ) { return rList; }
228 <  double getRsw( void )   { return rSw; }
229 <  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; }
226 >        /** Sets the seed*/
227 >        void setSeed(int seed) {
228 >            seed_ = seed;
229 >        }
230  
231 <  void wrapVector( double thePos[3] );
231 >        
232 >        void update();
233  
188  SimState* getConfiguration( void ) { return myConfiguration; }
189  
190  void addProperty(GenericData* prop);
191  GenericData* getProperty(const string& propName);
192  //vector<GenericData*>& getProperties()  {return properties;}    
234  
235 <  int getSeed(void) {  return seed; }
236 <  void setSeed(int theSeed) {  seed = theSeed;}
235 >        /** Returns the local index manager */
236 >        LocalIndexManager* getLocalIndexManager() {
237 >            return localIndexMan_;
238 >        }
239  
197 private:
240  
241 <  SimState* myConfiguration;
241 >        /**
242 >         *
243 >         */
244 >        void addMoleculeStamp(MoleculeStamp* molStamp, int nmol);
245  
246 <  int boxIsInit, haveRcut, haveRsw;
246 >        int getMoleculeStampId(int globalIndex) {
247 >            //assert(globalIndex < molStampIds_.size())
248 >            return molStampIds_[globalIndex];
249 >        }
250  
251 <  double rList, rCut; // variables for the neighborlist
252 <  double rSw;         // the switching radius
251 >        /** Returns the molecule stamp */
252 >        MoleculeStamp* getMoleculeStamp(int id) {
253 >            return moleculeStamps_[id];
254 >        }
255 >        
256 >        /**
257 >         * Finds the processor where a molecule resides
258 >         * @return the id of the processor which contains the molecule
259 >         * @param globalIndex global Index of the molecule
260 >         */
261 >        int getMolToProc(int globalIndex) {
262 >            //assert(globalIndex < molToProcMap_.size());
263 >            return molToProcMap_[globalIndex];
264 >        }
265  
266 <  double maxCutoff;
266 >        /**
267 >         * Finds a molecule with a specified global index
268 >         * @return a pointer point to found molecule
269 >         * @param index
270 >         */
271 >        Molecule* getMoleculeByGlobalIndex(int index) {
272 >            std::map<int, Molecule*> i;
273 >            i = globalIndexToMol_.find(index);
274  
275 <  double distXY;
276 <  double distYZ;
210 <  double distZX;
211 <  
212 <  void calcHmatInv( void );
213 <  void calcBoxL();
214 <  double calcMaxCutOff();
275 >            return i != globalIndexToMol_.end() ? i->second : NULL;
276 >        }
277  
216  // private function to initialize the fortran side of the simulation
217  setFortranSim_TD setFsimulation;
278  
279 <  setFortranBox_TD setFortranBoxSize;
280 <  
281 <  notifyFortranCutOff_TD notifyFortranCutOffs;
222 <  
223 <  //Addtional Properties of SimInfo
224 <  map<string, GenericData*> properties;
225 <  void getFortranGroupArrays(SimInfo* info,
226 <                             vector<int>& FglobalGroupMembership,
227 <                             vector<double>& mfact);
279 >        friend std::ostream& operator <<(ostream& o, SimInfo& info);
280 >        
281 >    private:
282  
283 +        void calcNdf();
284 +        void calcNdfRaw();
285 +        void calcNdfTrans();
286  
287 < };
287 >        int* getExcludeList() {
288 >            return exclude_.getExcludeList();
289 >        }
290  
291 +        void addExcludePairs(Molecule* mol);
292 +        void removeExcludePairs(Molecule* mol);
293  
294 < #endif
294 >        //degress of freedom
295 >        int ndf_;           /** number of degress of freedom */
296 >        int ndfRaw_;
297 >        int ndfTrans_; /**< number of translation degress of freedom */
298 >
299 >        //number of local objects
300 >        int nAtoms_;
301 >        int nBonds_;
302 >        int nBends_;
303 >        int nTorsions_;
304 >        int nRigidBodies_;
305 >        int nIntegrableObjects_;
306 >        int nCutoffGroups_;
307 >        int nConstraints_;
308 >
309 >        simtype fInfo_;
310 >        Exclude exclude_;
311 >        ForceField* forceField_;
312 >        
313 >        std::vector<Molecule*> molecules_; /**< Molecule array */
314 >        PropertyMap properties_;                  /**< Generic Property */
315 >        SnapshotManager* sman_;               /**< SnapshotManager */
316 >
317 >        Globals* globals_;
318 >
319 >        int seed_; /**< seed for random number generator */
320 >
321 >        LocalIndexManager localIndexMan_;
322 >
323 >        //
324 >        std::vector<int> molToProcMap_;
325 >        std::map<int, Molecule*> globalIndexToMol_;
326 >        std::vector<int> molStampIds_;                                /**< stamp id array of all molecules in the system */
327 >        std::vector<MoleculeStamp*> moleculeStamps_; /**< molecule stamps array */      
328 >
329 > };
330 >
331 > } //namespace oopse
332 > #endif //BRAINS_SIMMODEL_HPP

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines