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

Comparing branches/new_design/OOPSE-3.0/src/brains/SimInfo.cpp (file contents):
Revision 1824 by tim, Thu Dec 2 03:12:25 2004 UTC vs.
Revision 1842 by tim, Fri Dec 3 20:30:07 2004 UTC

# Line 42 | Line 42 | SimInfo::SimInfo(std::vector<std::pair<MoleculeStamp*,
42   namespace oopse {
43  
44   SimInfo::SimInfo(std::vector<std::pair<MoleculeStamp*, int> >& molStampPairs,
45 <                                ForceField* ff, Globals* globals) :
46 <                                forceField_(ff), globals_(globals), nAtoms_(0), nBonds_(0),
47 <                                nBends_(0), nTorsions_(0), nRigidBodies_(0), nIntegrableObjects_(0),
48 <                                nCutoffGroups_(0), nConstraints_(0), nZconstraint_(0), sman_(NULL),
49 <                                fortranInitialized_(false) {
45 >                                ForceField* ff, Globals* simParams) :
46 >                                forceField_(ff), simParams_(simParams),
47 >                                ndf_(0), ndfRaw_(0), ndfTrans_(0), nZconstraint_(0),
48 >                                nGlobalMols_(0), nGlobalAtoms_(0), nGlobalCutoffGroups_(0),
49 >                                nGlobalIntegrableObjects_(0), nGlobalRigidBodies_(0),
50 >                                nAtoms_(0), nBonds_(0),  nBends_(0), nTorsions_(0), nRigidBodies_(0),
51 >                                nIntegrableObjects_(0),  nCutoffGroups_(0), nConstraints_(0),
52 >                                sman_(NULL), fortranInitialized_(false) {
53  
54 +            
55      std::vector<std::pair<MoleculeStamp*, int> >::iterator i;
56      MoleculeStamp* molStamp;
57      int nMolWithSameStamp;
58 <    int nCutoffAtoms; // number of atoms belong to cutoff groups
59 <    int nGroups;          //total cutoff groups defined in meta-data file
60 <    CutoffGroupStamp* cgStamp;
57 <    int nAtomsInGroups;
58 <    int nCutoffGroupsInStamp;
59 <    
58 >    int nCutoffAtoms = 0; // number of atoms belong to cutoff groups
59 >    int nGroups = 0;          //total cutoff groups defined in meta-data file
60 >    CutoffGroupStamp* cgStamp;    
61      RigidBodyStamp* rbStamp;
62 <    int nAtomsInRigidBodies;
62 <    int nRigidBodiesInStamp;
63 <    int nRigidAtoms;
64 <    int nRigidBodies;
65 <        
66 <    nGlobalAtoms_ =  0;
62 >    int nRigidAtoms = 0;
63      
68    nGroups = 0;
69    nCutoffAtoms = 0;
70    nRigidBodies = 0;
71    
64      for (i = molStampPairs.begin(); i !=molStampPairs.end(); ++i) {
65          molStamp = i->first;
66          nMolWithSameStamp = i->second;
# Line 80 | Line 72 | SimInfo::SimInfo(std::vector<std::pair<MoleculeStamp*,
72  
73  
74          //calculate atoms in cutoff groups
75 <        nAtomsInGroups = 0;
76 <        nCutoffGroupsInStamp = molStamp->getNCutoffGroups();
75 >        int nAtomsInGroups = 0;
76 >        int nCutoffGroupsInStamp = molStamp->getNCutoffGroups();
77          
78          for (int j=0; j < nCutoffGroupsInStamp; j++) {
79              cgStamp = molStamp->getCutoffGroup(j);
# Line 92 | Line 84 | SimInfo::SimInfo(std::vector<std::pair<MoleculeStamp*,
84          nCutoffAtoms += nAtomsInGroups * nMolWithSameStamp;            
85  
86          //calculate atoms in rigid bodies
87 <        nAtomsInRigidBodies = 0;
88 <        nRigidBodiesInStamp = molStamp->getNCutoffGroups();
87 >        int nAtomsInRigidBodies = 0;
88 >        int nRigidBodiesInStamp = molStamp->getNCutoffGroups();
89          
90          for (int j=0; j < nRigidBodiesInStamp; j++) {
91              rbStamp = molStamp->getRigidBody(j);
92 <            nRigidBodiesInStamp += rbStamp->getNMembers();
92 >            nAtomsInRigidBodies += rbStamp->getNMembers();
93          }
94  
95 <        nRigidBodies += nRigidBodiesInStamp * nMolWithSameStamp;
95 >        nGlobalRigidBodies_ += nRigidBodiesInStamp * nMolWithSameStamp;
96          nRigidAtoms += nAtomsInRigidBodies * nMolWithSameStamp;            
97          
98      }
# Line 111 | Line 103 | SimInfo::SimInfo(std::vector<std::pair<MoleculeStamp*,
103      //file plus the number of cutoff groups defined in meta-data file
104      nGlobalCutoffGroups_ = nGlobalAtoms_ - nCutoffAtoms + nGroups;
105  
106 <    //every free atom (atom does not belong to rigid bodies) is a rigid body
107 <    //therefore the total number of cutoff groups in the system is equal to
106 >    //every free atom (atom does not belong to rigid bodies) is an integrable object
107 >    //therefore the total number of  integrable objects in the system is equal to
108      //the total number of atoms minus number of atoms belong to  rigid body defined in meta-data
109      //file plus the number of  rigid bodies defined in meta-data file
110 <    nGlobalIntegrableObjects_ = nGlobalAtoms_ - nRigidAtoms + nRigidBodies;
110 >    nGlobalIntegrableObjects_ = nGlobalAtoms_ - nRigidAtoms + nGlobalRigidBodies_;
111  
120    //initialize globalGroupMembership_, every element of this array will be 0
121    globalGroupMembership_.insert(globalGroupMembership_.end(), nGlobalAtoms_, 0);
122
112      nGlobalMols_ = molStampIds_.size();
113  
114   #ifdef IS_MPI    
# Line 134 | Line 123 | SimInfo::~SimInfo() {
123      MemoryUtils::deleteVectorOfPointer(moleculeStamps_);
124      
125      delete sman_;
126 <    delete globals_;
126 >    delete simParams_;
127      delete forceField_;
128  
129   }
# Line 144 | Line 133 | bool SimInfo::addMolecule(Molecule* mol) {
133      MoleculeIterator i;
134  
135      i = molecules_.find(mol->getGlobalIndex());
136 <    if (i != molecules_.end() ) {
136 >    if (i == molecules_.end() ) {
137  
138 <        molecules_.insert(make_pair(mol->getGlobalIndex(), mol));
138 >        molecules_.insert(std::make_pair(mol->getGlobalIndex(), mol));
139          
140          nAtoms_ += mol->getNAtoms();
141          nBonds_ += mol->getNBonds();
# Line 462 | Line 451 | void SimInfo::setupSimType() {
451      int useFLARB = 0; //it is not in AtomType yet
452      int useDirectionalAtom = 0;    
453      int useElectrostatics = 0;
454 <    //usePBC and useRF are from globals
455 <    bool usePBC = globals_->getPBC();
456 <    bool useRF = globals_->getUseRF();
454 >    //usePBC and useRF are from simParams
455 >    bool usePBC = simParams_->getPBC();
456 >    bool useRF = simParams_->getUseRF();
457  
458      //loop over all of the atom types
459      for (i = atomTypes.begin(); i != atomTypes.end(); ++i) {
# Line 543 | Line 532 | void SimInfo::setupSimType() {
532  
533      if( fInfo_.SIM_uses_Dipoles && fInfo_.SIM_uses_RF) {
534  
535 <        if (globals_->haveDielectric()) {
536 <            fInfo_.dielect = globals_->getDielectric();
535 >        if (simParams_->haveDielectric()) {
536 >            fInfo_.dielect = simParams_->getDielectric();
537          } else {
538              sprintf(painCave.errMsg,
539                      "SimSetup Error: No Dielectric constant was set.\n"
# Line 732 | Line 721 | void SimInfo::setupCutoff() {
721      
722      if (fInfo_.SIM_uses_Charges | fInfo_.SIM_uses_Dipoles | fInfo_.SIM_uses_RF) {
723          
724 <        if (!globals_->haveRcut()){
724 >        if (!simParams_->haveRcut()){
725              sprintf(painCave.errMsg,
726                  "SimCreator Warning: No value was set for the cutoffRadius.\n"
727                  "\tOOPSE will use a default value of 15.0 angstroms"
# Line 741 | Line 730 | void SimInfo::setupCutoff() {
730              simError();
731              rcut_ = 15.0;
732          } else{
733 <            rcut_ = globals_->getRcut();
733 >            rcut_ = simParams_->getRcut();
734          }
735  
736 <        if (!globals_->haveRsw()){
736 >        if (!simParams_->haveRsw()){
737              sprintf(painCave.errMsg,
738                  "SimCreator Warning: No value was set for switchingRadius.\n"
739                  "\tOOPSE will use a default value of\n"
# Line 753 | Line 742 | void SimInfo::setupCutoff() {
742              simError();
743              rsw_ = 0.95 * rcut_;
744          } else{
745 <            rsw_ = globals_->getRsw();
745 >            rsw_ = simParams_->getRsw();
746          }
747  
748      } else {
749          // if charge, dipole or reaction field is not used and the cutofff radius is not specified in
750          //meta-data file, the maximum cutoff radius calculated from forcefiled will be used
751          
752 <        if (globals_->haveRcut()) {
753 <            rcut_ = globals_->getRcut();
752 >        if (simParams_->haveRcut()) {
753 >            rcut_ = simParams_->getRcut();
754          } else {
755              //set cutoff radius to the maximum cutoff radius based on atom types in the whole system
756              rcut_ = calcMaxCutoffRadius();
757          }
758  
759 <        if (globals_->haveRsw()) {
760 <            rsw_  = globals_->getRsw();
759 >        if (simParams_->haveRsw()) {
760 >            rsw_  = simParams_->getRsw();
761          } else {
762              rsw_ = rcut_;
763          }
# Line 828 | Line 817 | std::ostream& operator <<(ostream& o, SimInfo& info) {
817      
818   }
819  
820 < std::ostream& operator <<(ostream& o, SimInfo& info) {
820 > std::ostream& operator <<(std::ostream& o, SimInfo& info) {
821  
822      return o;
823   }
824  
825   }//end namespace oopse
826 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines