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 1856 by tim, Mon Dec 6 04:49:53 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;
67 <    
68 <    nGroups = 0;
69 <    nCutoffAtoms = 0;
70 <    nRigidBodies = 0;
62 >    int nRigidAtoms = 0;
63      
64      for (i = molStampPairs.begin(); i !=molStampPairs.end(); ++i) {
65          molStamp = i->first;
# 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 157 | Line 146 | bool SimInfo::addMolecule(Molecule* mol) {
146          nCutoffGroups_ += mol->getNCutoffGroups();
147          nConstraints_ += mol->getNConstraints();
148  
149 +        addExcludePairs(mol);
150 +        
151          return true;
152      } else {
153          return false;
# Line 180 | Line 171 | bool SimInfo::removeMolecule(Molecule* mol) {
171          nCutoffGroups_ -= mol->getNCutoffGroups();
172          nConstraints_ -= mol->getNConstraints();
173  
174 +        removeExcludePairs(mol);
175          molecules_.erase(mol->getGlobalIndex());
176  
177          delete mol;
# Line 462 | Line 454 | void SimInfo::setupSimType() {
454      int useFLARB = 0; //it is not in AtomType yet
455      int useDirectionalAtom = 0;    
456      int useElectrostatics = 0;
457 <    //usePBC and useRF are from globals
458 <    bool usePBC = globals_->getPBC();
459 <    bool useRF = globals_->getUseRF();
457 >    //usePBC and useRF are from simParams
458 >    bool usePBC = simParams_->getPBC();
459 >    bool useRF = simParams_->getUseRF();
460  
461      //loop over all of the atom types
462      for (i = atomTypes.begin(); i != atomTypes.end(); ++i) {
# Line 543 | Line 535 | void SimInfo::setupSimType() {
535  
536      if( fInfo_.SIM_uses_Dipoles && fInfo_.SIM_uses_RF) {
537  
538 <        if (globals_->haveDielectric()) {
539 <            fInfo_.dielect = globals_->getDielectric();
538 >        if (simParams_->haveDielectric()) {
539 >            fInfo_.dielect = simParams_->getDielectric();
540          } else {
541              sprintf(painCave.errMsg,
542                      "SimSetup Error: No Dielectric constant was set.\n"
# Line 613 | Line 605 | void SimInfo::setupFortranSim() {
605      //molMembershipArray is filled by SimCreator    
606      std::vector<int> molMembershipArray(nGlobalAtoms_);
607      for (int i = 0; i < nGlobalAtoms_; i++) {
608 <        molMembershipArray.push_back(globalMolMembership_[i] + 1);
608 >        molMembershipArray[i] = globalMolMembership_[i] + 1;
609      }
610      
611      //setup fortran simulation
# Line 732 | Line 724 | void SimInfo::setupCutoff() {
724      
725      if (fInfo_.SIM_uses_Charges | fInfo_.SIM_uses_Dipoles | fInfo_.SIM_uses_RF) {
726          
727 <        if (!globals_->haveRcut()){
727 >        if (!simParams_->haveRcut()){
728              sprintf(painCave.errMsg,
729                  "SimCreator Warning: No value was set for the cutoffRadius.\n"
730                  "\tOOPSE will use a default value of 15.0 angstroms"
# Line 741 | Line 733 | void SimInfo::setupCutoff() {
733              simError();
734              rcut_ = 15.0;
735          } else{
736 <            rcut_ = globals_->getRcut();
736 >            rcut_ = simParams_->getRcut();
737          }
738  
739 <        if (!globals_->haveRsw()){
739 >        if (!simParams_->haveRsw()){
740              sprintf(painCave.errMsg,
741                  "SimCreator Warning: No value was set for switchingRadius.\n"
742                  "\tOOPSE will use a default value of\n"
# Line 753 | Line 745 | void SimInfo::setupCutoff() {
745              simError();
746              rsw_ = 0.95 * rcut_;
747          } else{
748 <            rsw_ = globals_->getRsw();
748 >            rsw_ = simParams_->getRsw();
749          }
750  
751      } else {
752          // if charge, dipole or reaction field is not used and the cutofff radius is not specified in
753          //meta-data file, the maximum cutoff radius calculated from forcefiled will be used
754          
755 <        if (globals_->haveRcut()) {
756 <            rcut_ = globals_->getRcut();
755 >        if (simParams_->haveRcut()) {
756 >            rcut_ = simParams_->getRcut();
757          } else {
758              //set cutoff radius to the maximum cutoff radius based on atom types in the whole system
759              rcut_ = calcMaxCutoffRadius();
760          }
761  
762 <        if (globals_->haveRsw()) {
763 <            rsw_  = globals_->getRsw();
762 >        if (simParams_->haveRsw()) {
763 >            rsw_  = simParams_->getRsw();
764          } else {
765              rsw_ = rcut_;
766          }
# Line 828 | Line 820 | std::ostream& operator <<(ostream& o, SimInfo& info) {
820      
821   }
822  
823 < std::ostream& operator <<(ostream& o, SimInfo& info) {
823 > Vector3d SimInfo::getComVel(){
824 >    SimInfo::MoleculeIterator i;
825 >    Molecule* mol;
826 >
827 >    Vector3d comVel(0.0);
828 >    double totalMass = 0.0;
829 >    
830 >
831 >    for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) {
832 >        double mass = mol->getMass();
833 >        totalMass += mass;
834 >        comVel += mass * mol->getComVel();
835 >    }  
836  
837 +    comVel /= totalMass;
838 +
839 +    return comVel;
840 + }
841 +
842 + Vector3d SimInfo::getCom(){
843 +    SimInfo::MoleculeIterator i;
844 +    Molecule* mol;
845 +
846 +    Vector3d com(0.0);
847 +    double totalMass = 0.0;
848 +    
849 +    for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) {
850 +        double mass = mol->getMass();
851 +        totalMass += mass;
852 +        com += mass * mol->getCom();
853 +    }  
854 +
855 +    com /= totalMass;
856 +
857 +    return com;
858 +
859 + }        
860 +
861 + std::ostream& operator <<(std::ostream& o, SimInfo& info) {
862 +
863      return o;
864   }
865  
866   }//end namespace oopse
867 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines