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; |
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); |
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 |
|
} |
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 |
123 |
|
MemoryUtils::deleteVectorOfPointer(moleculeStamps_); |
124 |
|
|
125 |
|
delete sman_; |
126 |
< |
delete globals_; |
126 |
> |
delete simParams_; |
127 |
|
delete forceField_; |
128 |
|
|
129 |
|
} |
133 |
|
MoleculeIterator i; |
134 |
|
|
135 |
|
i = molecules_.find(mol->getGlobalIndex()); |
136 |
< |
if (i != molecules_.end() ) { |
136 |
> |
if (i == molecules_.end() ) { |
137 |
|
|
138 |
|
molecules_.insert(std::make_pair(mol->getGlobalIndex(), mol)); |
139 |
|
|
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) { |
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" |
602 |
|
//molMembershipArray is filled by SimCreator |
603 |
|
std::vector<int> molMembershipArray(nGlobalAtoms_); |
604 |
|
for (int i = 0; i < nGlobalAtoms_; i++) { |
605 |
< |
molMembershipArray.push_back(globalMolMembership_[i] + 1); |
605 |
> |
molMembershipArray[i] = globalMolMembership_[i] + 1; |
606 |
|
} |
607 |
|
|
608 |
|
//setup fortran simulation |
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" |
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" |
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 |
|
} |
814 |
|
rb->setSnapshotManager(sman_); |
815 |
|
} |
816 |
|
} |
817 |
+ |
|
818 |
+ |
} |
819 |
+ |
|
820 |
+ |
Vector3d SimInfo::getComVel(){ |
821 |
+ |
SimInfo::MoleculeIterator i; |
822 |
+ |
Molecule* mol; |
823 |
+ |
|
824 |
+ |
Vector3d comVel(0.0); |
825 |
+ |
double totalMass = 0.0; |
826 |
|
|
827 |
+ |
|
828 |
+ |
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
829 |
+ |
double mass = mol->getMass(); |
830 |
+ |
totalMass += mass; |
831 |
+ |
comVel += mass * mol->getComVel(); |
832 |
+ |
} |
833 |
+ |
|
834 |
+ |
comVel /= totalMass; |
835 |
+ |
|
836 |
+ |
return comVel; |
837 |
|
} |
838 |
|
|
839 |
+ |
Vector3d SimInfo::getCom(){ |
840 |
+ |
SimInfo::MoleculeIterator i; |
841 |
+ |
Molecule* mol; |
842 |
+ |
|
843 |
+ |
Vector3d com(0.0); |
844 |
+ |
double totalMass = 0.0; |
845 |
+ |
|
846 |
+ |
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
847 |
+ |
double mass = mol->getMass(); |
848 |
+ |
totalMass += mass; |
849 |
+ |
com += mass * mol->getCom(); |
850 |
+ |
} |
851 |
+ |
|
852 |
+ |
com /= totalMass; |
853 |
+ |
|
854 |
+ |
return com; |
855 |
+ |
|
856 |
+ |
} |
857 |
+ |
|
858 |
|
std::ostream& operator <<(std::ostream& o, SimInfo& info) { |
859 |
|
|
860 |
|
return o; |
861 |
|
} |
862 |
|
|
863 |
|
}//end namespace oopse |
864 |
+ |
|