37 |
|
|
38 |
|
namespace oopse { |
39 |
|
|
40 |
< |
SimInfo::SimInfo() : nAtoms_(0), nBonds_(0), nBends_(0), nTorsions_(0), nRigidBodies_(0), |
41 |
< |
nIntegrableObjects_(0), nCutoffGroups_(0), nConstraints_(0), sman_(NULL){ |
40 |
> |
SimInfo::SimInfo(const std::vector<std::pair<MoleculeStamp*, int> >& molStampPairs, |
41 |
> |
ForceField* ff, Globals* globals) : |
42 |
> |
forceField_(ff), globals_(globals), nAtoms_(0), nBonds_(0), |
43 |
> |
nBends_(0), nTorsions_(0), nRigidBodies_(0), nIntegrableObjects_(0), |
44 |
> |
nCutoffGroups_(0), nConstraints_(0), nZConstraint_(0), sman_(NULL), |
45 |
> |
fortranInitialized_(false) { |
46 |
> |
|
47 |
> |
std::vector<std::pair<MoleculeStamp*, int> >::iterator i; |
48 |
> |
MoleculeStamp* molStamp; |
49 |
> |
int nMolWithSameStamp; |
50 |
> |
int nCutoffAtoms; // number of atoms belong to cutoff groups |
51 |
> |
int nGroups; //total cutoff groups defined in meta-data file |
52 |
> |
CutoffGroupStamp* cgStamp; |
53 |
> |
int nAtomsInGroups; |
54 |
> |
int nCutoffGroupsInStamp; |
55 |
> |
|
56 |
> |
RigidBodyStamp* rbStamp; |
57 |
> |
int nAtomsInRigidBodies; |
58 |
> |
int nRigidBodiesInStamp; |
59 |
> |
int nRigidAtoms; |
60 |
> |
int nRigidBodies; |
61 |
> |
|
62 |
> |
nGlobalAtoms_ = 0; |
63 |
> |
|
64 |
> |
nGroups = 0; |
65 |
> |
nCutoffAtoms = 0; |
66 |
> |
|
67 |
> |
nRigidBodies |
68 |
> |
nRigidBodies = 0; |
69 |
> |
|
70 |
> |
for (i = molStampPairs.begin(); i !=molStampPairs.end(); ++i) { |
71 |
> |
molStamp = i->first; |
72 |
> |
nMolWithSameStamp = i->second; |
73 |
> |
|
74 |
> |
addMoleculeStamp(molStamp, nMolWithSameStamp); |
75 |
> |
|
76 |
> |
//calculate atoms in molecules |
77 |
> |
nGlobalAtoms_ += molStamp->getNAtoms() *nMolWithSameStamp; |
78 |
> |
|
79 |
> |
|
80 |
> |
//calculate atoms in cutoff groups |
81 |
> |
nAtomsInGroups = 0; |
82 |
> |
nCutoffGroupsInStamp = molStamp->getNCutoffGroups(); |
83 |
> |
|
84 |
> |
for (int j=0; j < nCutoffGroupsInStamp; j++) { |
85 |
> |
cgStamp = molStamp->getCutoffGroup(j); |
86 |
> |
nAtomsInGroups += cgStamp->getNMembers(); |
87 |
> |
} |
88 |
> |
|
89 |
> |
nGroups += nCutoffGroupsInStamp * nMolWithSameStamp; |
90 |
> |
nCutoffAtoms += nAtomsInGroups * nMolWithSameStamp; |
91 |
> |
|
92 |
> |
//calculate atoms in rigid bodies |
93 |
> |
nAtomsInRigidBodies = 0; |
94 |
> |
nRigidBodiesInStamp = molStamp->getNCutoffGroups(); |
95 |
> |
|
96 |
> |
for (int j=0; j < nRigidBodiesInStamp; j++) { |
97 |
> |
rbStamp = molStamp->getRigidBody(j); |
98 |
> |
nRigidBodiesInStamp += rbStamp->getNMembers(); |
99 |
> |
} |
100 |
|
|
101 |
+ |
nRigidBodies += nRigidBodiesInStamp * nMolWithSameStamp; |
102 |
+ |
nRigidAtoms += nAtomsInRigidBodies * nMolWithSameStamp; |
103 |
+ |
|
104 |
+ |
} |
105 |
+ |
|
106 |
+ |
//every free atom (atom does not belong to cutoff groups) is a cutoff group |
107 |
+ |
//therefore the total number of cutoff groups in the system is equal to |
108 |
+ |
//the total number of atoms minus number of atoms belong to cutoff group defined in meta-data |
109 |
+ |
//file plus the number of cutoff groups defined in meta-data file |
110 |
+ |
nGlobalCutoffGroups_ = nGlobalAtoms_ - nCutoffAtoms + nGroups; |
111 |
+ |
|
112 |
+ |
//every free atom (atom does not belong to rigid bodies) is a rigid body |
113 |
+ |
//therefore the total number of cutoff groups in the system is equal to |
114 |
+ |
//the total number of atoms minus number of atoms belong to rigid body defined in meta-data |
115 |
+ |
//file plus the number of rigid bodies defined in meta-data file |
116 |
+ |
nGlobalIntegrableObjects_ = nGlobalAtoms_ - nRigidAtoms + nRigidBodies; |
117 |
+ |
|
118 |
+ |
//initialize globalGroupMembership_, every element of this array will be 0 |
119 |
+ |
globalGroupMembership_.insert(globalGroupMembership_.end(), nGlobalAtoms_, 0); |
120 |
+ |
|
121 |
+ |
nGlobalMols_ = molStampIds_.size(); |
122 |
+ |
|
123 |
+ |
#ifdef IS_MPI |
124 |
+ |
molToProcMap_.resize(nGlobalMols_); |
125 |
+ |
#endif |
126 |
+ |
|
127 |
|
} |
128 |
|
|
129 |
|
SimInfo::~SimInfo() { |
130 |
|
//MemoryUtils::deleteVectorOfPointer(molecules_); |
131 |
+ |
|
132 |
+ |
MemoryUtils::deleteVectorOfPointer(moleculeStamps_); |
133 |
+ |
|
134 |
|
delete sman_; |
135 |
+ |
delete globals_; |
136 |
+ |
delete forceField_; |
137 |
|
|
138 |
|
} |
139 |
|
|
140 |
|
|
141 |
|
bool SimInfo::addMolecule(Molecule* mol) { |
142 |
|
MoleculeIterator i; |
143 |
< |
i = std::find(molecules_.begin(), molecules_.end(), mol); |
143 |
> |
|
144 |
> |
i = molecules_.find(mol->getGlobalIndex()); |
145 |
|
if (i != molecules_.end() ) { |
146 |
|
|
147 |
|
molecules_.insert(make_pair(mol->getGlobalIndex(), mol)); |
163 |
|
|
164 |
|
bool SimInfo::removeMolecule(Molecule* mol) { |
165 |
|
MoleculeIterator i; |
166 |
< |
i = std::find(molecules_.begin(), molecules_.end(), mol); |
166 |
> |
i = molecules_.find(mol->getGlobalIndex()); |
167 |
|
|
168 |
|
if (i != molecules_.end() ) { |
169 |
|
|
170 |
+ |
assert(mol == i->second); |
171 |
+ |
|
172 |
|
nAtoms_ -= mol->getNAtoms(); |
173 |
|
nBonds_ -= mol->getNBonds(); |
174 |
|
nBends_ -= mol->getNBends(); |
193 |
|
|
194 |
|
Molecule* SimInfo::beginMolecule(MoleculeIterator& i) { |
195 |
|
i = molecules_.begin(); |
196 |
< |
return i == molecules_.end() ? NULL : *i; |
196 |
> |
return i == molecules_.end() ? NULL : i->second; |
197 |
|
} |
198 |
|
|
199 |
|
Molecule* SimInfo::nextMolecule(MoleculeIterator& i) { |
200 |
|
++i; |
201 |
< |
return i == molecules_.end() ? NULL : *i; |
201 |
> |
return i == molecules_.end() ? NULL : i->second; |
202 |
|
} |
203 |
|
|
204 |
|
|
237 |
|
ndf_ = ndf_local; |
238 |
|
#endif |
239 |
|
|
240 |
< |
// nZconstraints is global, as are the 3 COM translations for the |
240 |
> |
// nZconstraints_ is global, as are the 3 COM translations for the |
241 |
|
// entire system: |
242 |
< |
ndf_ = ndf_ - 3 - nZconstraints; |
242 |
> |
ndf_ = ndf_ - 3 - nZconstraints_; |
243 |
|
|
244 |
|
} |
245 |
|
|
290 |
|
ndfTrans_ = ndfTrans_local; |
291 |
|
#endif |
292 |
|
|
293 |
< |
ndfTrans_ = ndfTrans_ - 3 - nZconstraints; |
293 |
> |
ndfTrans_ = ndfTrans_ - 3 - nZconstraints_; |
294 |
|
|
295 |
|
} |
296 |
|
|
396 |
|
|
397 |
|
void SimInfo::update() { |
398 |
|
|
399 |
+ |
setupSimType(); |
400 |
|
|
401 |
+ |
#ifdef IS_MPI |
402 |
+ |
setupFortranParallel(); |
403 |
+ |
#endif |
404 |
+ |
|
405 |
+ |
setupFortranSim(); |
406 |
+ |
|
407 |
+ |
setupCutoff(); |
408 |
+ |
|
409 |
+ |
//notify fortran whether reaction field is used or not. It is deprecated now |
410 |
+ |
//int isError = 0; |
411 |
+ |
//initFortranFF( &useReactionField, &isError ); |
412 |
+ |
|
413 |
+ |
//if(isError){ |
414 |
+ |
// sprintf( painCave.errMsg, |
415 |
+ |
// "SimCreator::initFortran() error: There was an error initializing the forceField in fortran.\n" ); |
416 |
+ |
// painCave.isFatal = 1; |
417 |
+ |
// simError(); |
418 |
+ |
//} |
419 |
|
|
420 |
+ |
calcNdf(); |
421 |
+ |
calcNdfRaw(); |
422 |
+ |
calcNdfTrans(); |
423 |
+ |
|
424 |
+ |
fortranInitialized_ = true; |
425 |
+ |
} |
426 |
+ |
|
427 |
+ |
std::set<AtomType*> SimInfo::getUniqueAtomTypes() { |
428 |
+ |
typename SimInfo::MoleculeIterator mi; |
429 |
+ |
Molecule* mol; |
430 |
+ |
typename Molecule::AtomIterator ai; |
431 |
+ |
Atom* atom; |
432 |
+ |
std::set<AtomType*> atomTypes; |
433 |
+ |
|
434 |
+ |
for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
435 |
+ |
|
436 |
+ |
for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
437 |
+ |
atomTypes.insert(atom->getAtomType()); |
438 |
+ |
} |
439 |
+ |
|
440 |
+ |
} |
441 |
+ |
|
442 |
+ |
return atomTypes; |
443 |
+ |
} |
444 |
+ |
|
445 |
+ |
void SimInfo::setupSimType() { |
446 |
+ |
std::set<AtomType*>::iterator i; |
447 |
+ |
std::set<AtomType*> atomTypes; |
448 |
+ |
atomTypes = getUniqueAtomTypes(); |
449 |
+ |
|
450 |
+ |
int useLennardJones = 0; |
451 |
+ |
int useElectrostatic = 0; |
452 |
+ |
int useEAM = 0; |
453 |
+ |
int useCharge = 0; |
454 |
+ |
int useDirectional = 0; |
455 |
+ |
int useDipole = 0; |
456 |
+ |
int useGayBerne = 0; |
457 |
+ |
int useSticky = 0; |
458 |
+ |
int useShape = 0; |
459 |
+ |
int useFLARB = 0; //it is not in AtomType yet |
460 |
+ |
int useDirectionalAtom = 0; |
461 |
+ |
int useElectrostatics = 0; |
462 |
+ |
//usePBC and useRF are from globals |
463 |
+ |
bool usePBC = globals_->getPBC(); |
464 |
+ |
bool useRF = globals_->getUseRF(); |
465 |
+ |
|
466 |
+ |
//loop over all of the atom types |
467 |
+ |
for (i = atomTypes.begin(); i != atomTypes.end(); ++i) { |
468 |
+ |
useLennardJones |= i->isLennardJones(); |
469 |
+ |
useElectrostatic |= i->isElectrostatic(); |
470 |
+ |
useEAM |= i->isEAM(); |
471 |
+ |
useCharge |= i->isCharge(); |
472 |
+ |
useDirectional |= i->isDirectional(); |
473 |
+ |
useDipole |= i->isDipole(); |
474 |
+ |
useGayBerne |= i->isGayBerne(); |
475 |
+ |
useSticky |= i->isSticky(); |
476 |
+ |
useShape |= i->isShape(); |
477 |
+ |
} |
478 |
+ |
|
479 |
+ |
if (useSticky || useDipole || useGayBerne || useShape) { |
480 |
+ |
useDirectionalAtom = 1; |
481 |
+ |
} |
482 |
+ |
|
483 |
+ |
if (useCharge || useDipole) { |
484 |
+ |
useElectrostatics = 1; |
485 |
+ |
} |
486 |
+ |
|
487 |
+ |
#ifdef IS_MPI |
488 |
+ |
int temp; |
489 |
+ |
|
490 |
+ |
temp = usePBC; |
491 |
+ |
MPI_Allreduce(&temp, &usePBC, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
492 |
+ |
|
493 |
+ |
temp = useDirectionalAtom; |
494 |
+ |
MPI_Allreduce(&temp, &useDirectionalAtom, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
495 |
+ |
|
496 |
+ |
temp = useLennardJones; |
497 |
+ |
MPI_Allreduce(&temp, &useLennardJones, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
498 |
+ |
|
499 |
+ |
temp = useElectrostatics; |
500 |
+ |
MPI_Allreduce(&temp, &useElectrostatics, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
501 |
+ |
|
502 |
+ |
temp = useCharge; |
503 |
+ |
MPI_Allreduce(&temp, &useCharge, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
504 |
+ |
|
505 |
+ |
temp = useDipole; |
506 |
+ |
MPI_Allreduce(&temp, &useDipole, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
507 |
+ |
|
508 |
+ |
temp = useSticky; |
509 |
+ |
MPI_Allreduce(&temp, &useSticky, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
510 |
+ |
|
511 |
+ |
temp = useGayBerne; |
512 |
+ |
MPI_Allreduce(&temp, &useGayBerne, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
513 |
+ |
|
514 |
+ |
temp = useEAM; |
515 |
+ |
MPI_Allreduce(&temp, &useEAM, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
516 |
+ |
|
517 |
+ |
temp = useShape; |
518 |
+ |
MPI_Allreduce(&temp, &useShape, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
519 |
+ |
|
520 |
+ |
temp = useFLARB; |
521 |
+ |
MPI_Allreduce(&temp, &useFLARB, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
522 |
+ |
|
523 |
+ |
temp = useRF; |
524 |
+ |
MPI_Allreduce(&temp, &useRF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
525 |
+ |
|
526 |
+ |
#endif |
527 |
+ |
|
528 |
+ |
fInfo_.SIM_uses_PBC = usePBC; |
529 |
+ |
fInfo_.SIM_uses_DirectionalAtoms = useDirectionalAtom; |
530 |
+ |
fInfo_.SIM_uses_LennardJones = useLennardJones; |
531 |
+ |
fInfo_.SIM_uses_Electrostatics = useElectrostatics; |
532 |
+ |
fInfo_.SIM_uses_Charges = useCharge; |
533 |
+ |
fInfo_.SIM_uses_Dipoles = useDipole; |
534 |
+ |
fInfo_.SIM_uses_Sticky = useSticky; |
535 |
+ |
fInfo_.SIM_uses_GayBerne = useGayBerne; |
536 |
+ |
fInfo_.SIM_uses_EAM = useEAM; |
537 |
+ |
fInfo_.SIM_uses_Shapes = useShape; |
538 |
+ |
fInfo_.SIM_uses_FLARB = useFLARB; |
539 |
+ |
fInfo_.SIM_uses_RF = useRF; |
540 |
+ |
|
541 |
+ |
if( fInfo_.SIM_uses_Dipoles && fInfo_.SIM_uses_RF) { |
542 |
+ |
fInfo_.dielect = dielectric; |
543 |
+ |
} else { |
544 |
+ |
fInfo_.dielect = 0.0; |
545 |
+ |
} |
546 |
+ |
|
547 |
+ |
} |
548 |
+ |
|
549 |
+ |
void SimInfo::setupFortranSim() { |
550 |
+ |
int isError; |
551 |
+ |
int nExclude; |
552 |
+ |
std::vector<int> fortranGlobalGroupMembership; |
553 |
+ |
|
554 |
+ |
nExclude = exclude_.getSize(); |
555 |
+ |
isError = 0; |
556 |
+ |
|
557 |
+ |
//globalGroupMembership_ is filled by SimCreator |
558 |
+ |
for (int i = 0; i < nGlobalAtoms_; i++) { |
559 |
+ |
fortranGlobalGroupMembership.push_back(globalGroupMembership_[i] + 1); |
560 |
+ |
} |
561 |
+ |
|
562 |
+ |
//calculate mass ratio of cutoff group |
563 |
+ |
std::vector<double> mfact; |
564 |
+ |
typename SimInfo::MoleculeIterator mi; |
565 |
+ |
Molecule* mol; |
566 |
+ |
typename Molecule::CutoffGroupIterator ci; |
567 |
+ |
CutoffGroup* cg; |
568 |
+ |
typename Molecule::AtomIterator ai; |
569 |
+ |
Atom* atom; |
570 |
+ |
double totalMass; |
571 |
+ |
|
572 |
+ |
//to avoid memory reallocation, reserve enough space for mfact |
573 |
+ |
mfact.reserve(getNCutoffGroups()); |
574 |
+ |
|
575 |
+ |
for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
576 |
+ |
for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { |
577 |
+ |
|
578 |
+ |
totalMass = cg->getMass(); |
579 |
+ |
for(atom = cg->beginAtom(ai); atom != NULL; atom = cg->nextAtom(ai)) { |
580 |
+ |
mfact.push_back(atom->getMass()/totalMass); |
581 |
+ |
} |
582 |
+ |
|
583 |
+ |
} |
584 |
+ |
} |
585 |
+ |
|
586 |
+ |
//fill ident array of local atoms (it is actually ident of AtomType, it is so confusing !!!) |
587 |
+ |
std::vector<int> identArray; |
588 |
+ |
|
589 |
+ |
//to avoid memory reallocation, reserve enough space identArray |
590 |
+ |
identArray.reserve(getNAtoms()); |
591 |
+ |
|
592 |
+ |
for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
593 |
+ |
for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
594 |
+ |
identArray.push_back(atom->getIdent()); |
595 |
+ |
} |
596 |
+ |
} |
597 |
+ |
|
598 |
+ |
//fill molMembershipArray |
599 |
+ |
//molMembershipArray is filled by SimCreator |
600 |
+ |
std::vector<int> molMembershipArray(nGlobalAtoms_); |
601 |
+ |
for (int i = 0; i < nGlobalAtoms_; i++) { |
602 |
+ |
molMembershipArray.push_back(globalMolMembership_[i] + 1); |
603 |
+ |
} |
604 |
+ |
|
605 |
+ |
//setup fortran simulation |
606 |
+ |
//gloalExcludes and molMembershipArray should go away (They are never used) |
607 |
+ |
//why the hell fortran need to know molecule? |
608 |
+ |
//OOPSE = Object-Obfuscated Parallel Simulation Engine |
609 |
+ |
|
610 |
+ |
setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray[0], &nExclude, exclude_->getExcludeList(), |
611 |
+ |
&nGlobalExcludes, globalExcludes, molMembershipArray, |
612 |
+ |
&mfact[0], &nCutoffGroups_, &fortranGlobalGroupMembership[0], &isError); |
613 |
+ |
|
614 |
+ |
if( isError ){ |
615 |
+ |
|
616 |
+ |
sprintf( painCave.errMsg, |
617 |
+ |
"There was an error setting the simulation information in fortran.\n" ); |
618 |
+ |
painCave.isFatal = 1; |
619 |
+ |
painCave.severity = OOPSE_ERROR; |
620 |
+ |
simError(); |
621 |
+ |
} |
622 |
+ |
|
623 |
+ |
#ifdef IS_MPI |
624 |
+ |
sprintf( checkPointMsg, |
625 |
+ |
"succesfully sent the simulation information to fortran.\n"); |
626 |
+ |
MPIcheckPoint(); |
627 |
+ |
#endif // is_mpi |
628 |
+ |
} |
629 |
+ |
|
630 |
+ |
|
631 |
+ |
#ifdef IS_MPI |
632 |
+ |
void SimInfo::setupFortranParallel() { |
633 |
+ |
|
634 |
|
//SimInfo is responsible for creating localToGlobalAtomIndex and localToGlobalGroupIndex |
635 |
|
std::vector<int> localToGlobalAtomIndex(getNAtoms(), 0); |
636 |
|
std::vector<int> localToGlobalCutoffGroupIndex; |
657 |
|
|
658 |
|
} |
659 |
|
|
660 |
< |
//Setup Parallel Data and pass the index arrays to fortran |
661 |
< |
parallelData.nMolGlobal = getNMolGlobal(); |
662 |
< |
parallelData.nMolLocal = ; |
663 |
< |
parallelData.nAtomsGlobal = ; |
664 |
< |
parallelData.nAtomsLocal = ; |
665 |
< |
parallelData.nGroupsGlobal = ; |
666 |
< |
parallelData.nGroupsLocal = ; |
660 |
> |
//fill up mpiSimData struct |
661 |
> |
parallelData.nMolGlobal = getNGlobalMolecules(); |
662 |
> |
parallelData.nMolLocal = getNMolecules(); |
663 |
> |
parallelData.nAtomsGlobal = getNGlobalAtoms(); |
664 |
> |
parallelData.nAtomsLocal = getNAtoms(); |
665 |
> |
parallelData.nGroupsGlobal = getNGlobalCutoffGroups(); |
666 |
> |
parallelData.nGroupsLocal = getNCutoffGroups(); |
667 |
|
parallelData.myNode = worldRank; |
668 |
|
MPI_Comm_size(MPI_COMM_WORLD, &(parallelData->nProcessors)); |
669 |
< |
|
670 |
< |
setFsimParallel(parallelData, &(parallelData->nAtomsLocal), |
669 |
> |
|
670 |
> |
//pass mpiSimData struct and index arrays to fortran |
671 |
> |
setFsimParallel(parallelData, &(parallelData->nAtomsLocal), |
672 |
|
&localToGlobalAtomIndex[0], &(parallelData->nGroupsLocal), |
673 |
|
&localToGlobalCutoffGroupIndex[0], &isError); |
674 |
|
|
685 |
|
|
686 |
|
} |
687 |
|
|
688 |
+ |
#endif |
689 |
+ |
|
690 |
+ |
double SimInfo::calcMaxCutoffRadius() { |
691 |
+ |
|
692 |
+ |
|
693 |
+ |
std::vector<AtomType*> atomTypes; |
694 |
+ |
std::vector<AtomType*>::iterator i; |
695 |
+ |
std::vector<double> cutoffRadius; |
696 |
+ |
|
697 |
+ |
//get the unique atom types |
698 |
+ |
atomTypes = getUniqueAtomTypes(); |
699 |
+ |
|
700 |
+ |
//query the max cutoff radius among these atom types |
701 |
+ |
for (i = atomTypes.begin(); i != atomTypes.end(); ++i) { |
702 |
+ |
cutoffRadius.push_back(forceField_->getRcutFromAtomType(*i)); |
703 |
+ |
} |
704 |
+ |
|
705 |
+ |
double maxCutoffRadius = std::max_element(cutoffRadius.begin(), cutoffRadius.end()); |
706 |
+ |
#ifdef IS_MPI |
707 |
+ |
//pick the max cutoff radius among the processors |
708 |
+ |
#endif |
709 |
+ |
|
710 |
+ |
return maxCutoffRadius; |
711 |
+ |
} |
712 |
+ |
|
713 |
+ |
void SimInfo::setupCutoff() { |
714 |
+ |
double rcut_; //cutoff radius |
715 |
+ |
double rsw_; //switching radius |
716 |
+ |
|
717 |
+ |
if (fInfo_.SIM_uses_Charges | fInfo_.SIM_uses_Dipoles | fInfo_.SIM_uses_RF) { |
718 |
+ |
|
719 |
+ |
if (!globals_->haveRcut()){ |
720 |
+ |
sprintf(painCave.errMsg, |
721 |
+ |
"SimCreator Warning: No value was set for the cutoffRadius.\n" |
722 |
+ |
"\tOOPSE will use a default value of 15.0 angstroms" |
723 |
+ |
"\tfor the cutoffRadius.\n"); |
724 |
+ |
painCave.isFatal = 0; |
725 |
+ |
simError(); |
726 |
+ |
rcut_ = 15.0; |
727 |
+ |
} else{ |
728 |
+ |
rcut_ = globals_->getRcut(); |
729 |
+ |
} |
730 |
+ |
|
731 |
+ |
if (!globals_->haveRsw()){ |
732 |
+ |
sprintf(painCave.errMsg, |
733 |
+ |
"SimCreator Warning: No value was set for switchingRadius.\n" |
734 |
+ |
"\tOOPSE will use a default value of\n" |
735 |
+ |
"\t0.95 * cutoffRadius for the switchingRadius\n"); |
736 |
+ |
painCave.isFatal = 0; |
737 |
+ |
simError(); |
738 |
+ |
rsw_ = 0.95 * rcut_; |
739 |
+ |
} else{ |
740 |
+ |
rsw_ = globals_->getRsw(); |
741 |
+ |
} |
742 |
+ |
|
743 |
+ |
} else { |
744 |
+ |
// if charge, dipole or reaction field is not used and the cutofff radius is not specified in |
745 |
+ |
//meta-data file, the maximum cutoff radius calculated from forcefiled will be used |
746 |
+ |
|
747 |
+ |
if (globals_->haveRcut()) { |
748 |
+ |
rcut_ = globals_->getRcut(); |
749 |
+ |
} else { |
750 |
+ |
//set cutoff radius to the maximum cutoff radius based on atom types in the whole system |
751 |
+ |
rcut_ = calcMaxCutoffRadius(); |
752 |
+ |
} |
753 |
+ |
|
754 |
+ |
if (globals_->haveRsw()) { |
755 |
+ |
rsw_ = globals_->getRsw() |
756 |
+ |
} else { |
757 |
+ |
rsw_ = rcut_; |
758 |
+ |
} |
759 |
+ |
|
760 |
+ |
} |
761 |
+ |
|
762 |
+ |
double rnblist = rcut_ + 1; // skin of neighbor list |
763 |
+ |
|
764 |
+ |
//Pass these cutoff radius etc. to fortran. This function should be called once and only once |
765 |
+ |
notifyFortranCutoffs(&rcut_, &rsw_, &rnblist); |
766 |
+ |
} |
767 |
+ |
|
768 |
+ |
void SimInfo::addProperty(GenericData* genData) { |
769 |
+ |
properties_.addProperty(genData); |
770 |
+ |
} |
771 |
+ |
|
772 |
+ |
void SimInfo::removeProperty(const std::string& propName) { |
773 |
+ |
properties_.removeProperty(propName); |
774 |
+ |
} |
775 |
+ |
|
776 |
+ |
void SimInfo::clearProperties() { |
777 |
+ |
properties_.clearProperties(); |
778 |
+ |
} |
779 |
+ |
|
780 |
+ |
std::vector<std::string> SimInfo::getPropertyNames() { |
781 |
+ |
return properties_.getPropertyNames(); |
782 |
+ |
} |
783 |
+ |
|
784 |
+ |
std::vector<GenericData*> SimInfo::getProperties() { |
785 |
+ |
return properties_.getProperties(); |
786 |
+ |
} |
787 |
+ |
|
788 |
+ |
GenericData* SimInfo::getPropertyByName(const std::string& propName) { |
789 |
+ |
return properties_.getPropertyByName(propName); |
790 |
+ |
} |
791 |
+ |
|
792 |
+ |
|
793 |
|
std::ostream& operator <<(ostream& o, SimInfo& info) { |
794 |
|
|
795 |
|
return o; |