| 48 |
|
|
| 49 |
|
#include <algorithm> |
| 50 |
|
#include <set> |
| 51 |
+ |
#include <map> |
| 52 |
|
|
| 53 |
|
#include "brains/SimInfo.hpp" |
| 54 |
|
#include "math/Vector3.hpp" |
| 55 |
|
#include "primitives/Molecule.hpp" |
| 56 |
+ |
#include "UseTheForce/fCutoffPolicy.h" |
| 57 |
+ |
#include "UseTheForce/DarkSide/fElectrostaticSummationMethod.h" |
| 58 |
+ |
#include "UseTheForce/DarkSide/fElectrostaticScreeningMethod.h" |
| 59 |
+ |
#include "UseTheForce/DarkSide/fSwitchingFunctionType.h" |
| 60 |
|
#include "UseTheForce/doForces_interface.h" |
| 61 |
< |
#include "UseTheForce/notifyCutoffs_interface.h" |
| 61 |
> |
#include "UseTheForce/DarkSide/electrostatic_interface.h" |
| 62 |
> |
#include "UseTheForce/DarkSide/switcheroo_interface.h" |
| 63 |
|
#include "utils/MemoryUtils.hpp" |
| 64 |
|
#include "utils/simError.h" |
| 65 |
|
#include "selection/SelectionManager.hpp" |
| 70 |
|
#endif |
| 71 |
|
|
| 72 |
|
namespace oopse { |
| 73 |
+ |
std::set<int> getRigidSet(int index, std::map<int, std::set<int> >& container) { |
| 74 |
+ |
std::map<int, std::set<int> >::iterator i = container.find(index); |
| 75 |
+ |
std::set<int> result; |
| 76 |
+ |
if (i != container.end()) { |
| 77 |
+ |
result = i->second; |
| 78 |
+ |
} |
| 79 |
|
|
| 80 |
+ |
return result; |
| 81 |
+ |
} |
| 82 |
+ |
|
| 83 |
|
SimInfo::SimInfo(MakeStamps* stamps, std::vector<std::pair<MoleculeStamp*, int> >& molStampPairs, |
| 84 |
|
ForceField* ff, Globals* simParams) : |
| 85 |
|
stamps_(stamps), forceField_(ff), simParams_(simParams), |
| 95 |
|
MoleculeStamp* molStamp; |
| 96 |
|
int nMolWithSameStamp; |
| 97 |
|
int nCutoffAtoms = 0; // number of atoms belong to cutoff groups |
| 98 |
< |
int nGroups = 0; //total cutoff groups defined in meta-data file |
| 98 |
> |
int nGroups = 0; //total cutoff groups defined in meta-data file |
| 99 |
|
CutoffGroupStamp* cgStamp; |
| 100 |
|
RigidBodyStamp* rbStamp; |
| 101 |
|
int nRigidAtoms = 0; |
| 120 |
|
} |
| 121 |
|
|
| 122 |
|
nGroups += nCutoffGroupsInStamp * nMolWithSameStamp; |
| 123 |
+ |
|
| 124 |
|
nCutoffAtoms += nAtomsInGroups * nMolWithSameStamp; |
| 125 |
|
|
| 126 |
|
//calculate atoms in rigid bodies |
| 137 |
|
|
| 138 |
|
} |
| 139 |
|
|
| 140 |
< |
//every free atom (atom does not belong to cutoff groups) is a cutoff group |
| 141 |
< |
//therefore the total number of cutoff groups in the system is equal to |
| 142 |
< |
//the total number of atoms minus number of atoms belong to cutoff group defined in meta-data |
| 143 |
< |
//file plus the number of cutoff groups defined in meta-data file |
| 140 |
> |
//every free atom (atom does not belong to cutoff groups) is a cutoff |
| 141 |
> |
//group therefore the total number of cutoff groups in the system is |
| 142 |
> |
//equal to the total number of atoms minus number of atoms belong to |
| 143 |
> |
//cutoff group defined in meta-data file plus the number of cutoff |
| 144 |
> |
//groups defined in meta-data file |
| 145 |
|
nGlobalCutoffGroups_ = nGlobalAtoms_ - nCutoffAtoms + nGroups; |
| 146 |
|
|
| 147 |
< |
//every free atom (atom does not belong to rigid bodies) is an integrable object |
| 148 |
< |
//therefore the total number of integrable objects in the system is equal to |
| 149 |
< |
//the total number of atoms minus number of atoms belong to rigid body defined in meta-data |
| 150 |
< |
//file plus the number of rigid bodies defined in meta-data file |
| 151 |
< |
nGlobalIntegrableObjects_ = nGlobalAtoms_ - nRigidAtoms + nGlobalRigidBodies_; |
| 152 |
< |
|
| 147 |
> |
//every free atom (atom does not belong to rigid bodies) is an |
| 148 |
> |
//integrable object therefore the total number of integrable objects |
| 149 |
> |
//in the system is equal to the total number of atoms minus number of |
| 150 |
> |
//atoms belong to rigid body defined in meta-data file plus the number |
| 151 |
> |
//of rigid bodies defined in meta-data file |
| 152 |
> |
nGlobalIntegrableObjects_ = nGlobalAtoms_ - nRigidAtoms |
| 153 |
> |
+ nGlobalRigidBodies_; |
| 154 |
> |
|
| 155 |
|
nGlobalMols_ = molStampIds_.size(); |
| 156 |
|
|
| 157 |
|
#ifdef IS_MPI |
| 354 |
|
int b; |
| 355 |
|
int c; |
| 356 |
|
int d; |
| 357 |
+ |
|
| 358 |
+ |
std::map<int, std::set<int> > atomGroups; |
| 359 |
+ |
|
| 360 |
+ |
Molecule::RigidBodyIterator rbIter; |
| 361 |
+ |
RigidBody* rb; |
| 362 |
+ |
Molecule::IntegrableObjectIterator ii; |
| 363 |
+ |
StuntDouble* integrableObject; |
| 364 |
|
|
| 365 |
+ |
for (integrableObject = mol->beginIntegrableObject(ii); integrableObject != NULL; |
| 366 |
+ |
integrableObject = mol->nextIntegrableObject(ii)) { |
| 367 |
+ |
|
| 368 |
+ |
if (integrableObject->isRigidBody()) { |
| 369 |
+ |
rb = static_cast<RigidBody*>(integrableObject); |
| 370 |
+ |
std::vector<Atom*> atoms = rb->getAtoms(); |
| 371 |
+ |
std::set<int> rigidAtoms; |
| 372 |
+ |
for (int i = 0; i < atoms.size(); ++i) { |
| 373 |
+ |
rigidAtoms.insert(atoms[i]->getGlobalIndex()); |
| 374 |
+ |
} |
| 375 |
+ |
for (int i = 0; i < atoms.size(); ++i) { |
| 376 |
+ |
atomGroups.insert(std::map<int, std::set<int> >::value_type(atoms[i]->getGlobalIndex(), rigidAtoms)); |
| 377 |
+ |
} |
| 378 |
+ |
} else { |
| 379 |
+ |
std::set<int> oneAtomSet; |
| 380 |
+ |
oneAtomSet.insert(integrableObject->getGlobalIndex()); |
| 381 |
+ |
atomGroups.insert(std::map<int, std::set<int> >::value_type(integrableObject->getGlobalIndex(), oneAtomSet)); |
| 382 |
+ |
} |
| 383 |
+ |
} |
| 384 |
+ |
|
| 385 |
+ |
|
| 386 |
+ |
|
| 387 |
|
for (bond= mol->beginBond(bondIter); bond != NULL; bond = mol->nextBond(bondIter)) { |
| 388 |
|
a = bond->getAtomA()->getGlobalIndex(); |
| 389 |
|
b = bond->getAtomB()->getGlobalIndex(); |
| 394 |
|
a = bend->getAtomA()->getGlobalIndex(); |
| 395 |
|
b = bend->getAtomB()->getGlobalIndex(); |
| 396 |
|
c = bend->getAtomC()->getGlobalIndex(); |
| 397 |
+ |
std::set<int> rigidSetA = getRigidSet(a, atomGroups); |
| 398 |
+ |
std::set<int> rigidSetB = getRigidSet(b, atomGroups); |
| 399 |
+ |
std::set<int> rigidSetC = getRigidSet(c, atomGroups); |
| 400 |
|
|
| 401 |
< |
exclude_.addPair(a, b); |
| 402 |
< |
exclude_.addPair(a, c); |
| 403 |
< |
exclude_.addPair(b, c); |
| 401 |
> |
exclude_.addPairs(rigidSetA, rigidSetB); |
| 402 |
> |
exclude_.addPairs(rigidSetA, rigidSetC); |
| 403 |
> |
exclude_.addPairs(rigidSetB, rigidSetC); |
| 404 |
> |
|
| 405 |
> |
//exclude_.addPair(a, b); |
| 406 |
> |
//exclude_.addPair(a, c); |
| 407 |
> |
//exclude_.addPair(b, c); |
| 408 |
|
} |
| 409 |
|
|
| 410 |
|
for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; torsion = mol->nextTorsion(torsionIter)) { |
| 412 |
|
b = torsion->getAtomB()->getGlobalIndex(); |
| 413 |
|
c = torsion->getAtomC()->getGlobalIndex(); |
| 414 |
|
d = torsion->getAtomD()->getGlobalIndex(); |
| 415 |
+ |
std::set<int> rigidSetA = getRigidSet(a, atomGroups); |
| 416 |
+ |
std::set<int> rigidSetB = getRigidSet(b, atomGroups); |
| 417 |
+ |
std::set<int> rigidSetC = getRigidSet(c, atomGroups); |
| 418 |
+ |
std::set<int> rigidSetD = getRigidSet(d, atomGroups); |
| 419 |
|
|
| 420 |
+ |
exclude_.addPairs(rigidSetA, rigidSetB); |
| 421 |
+ |
exclude_.addPairs(rigidSetA, rigidSetC); |
| 422 |
+ |
exclude_.addPairs(rigidSetA, rigidSetD); |
| 423 |
+ |
exclude_.addPairs(rigidSetB, rigidSetC); |
| 424 |
+ |
exclude_.addPairs(rigidSetB, rigidSetD); |
| 425 |
+ |
exclude_.addPairs(rigidSetC, rigidSetD); |
| 426 |
+ |
|
| 427 |
+ |
/* |
| 428 |
+ |
exclude_.addPairs(rigidSetA.begin(), rigidSetA.end(), rigidSetB.begin(), rigidSetB.end()); |
| 429 |
+ |
exclude_.addPairs(rigidSetA.begin(), rigidSetA.end(), rigidSetC.begin(), rigidSetC.end()); |
| 430 |
+ |
exclude_.addPairs(rigidSetA.begin(), rigidSetA.end(), rigidSetD.begin(), rigidSetD.end()); |
| 431 |
+ |
exclude_.addPairs(rigidSetB.begin(), rigidSetB.end(), rigidSetC.begin(), rigidSetC.end()); |
| 432 |
+ |
exclude_.addPairs(rigidSetB.begin(), rigidSetB.end(), rigidSetD.begin(), rigidSetD.end()); |
| 433 |
+ |
exclude_.addPairs(rigidSetC.begin(), rigidSetC.end(), rigidSetD.begin(), rigidSetD.end()); |
| 434 |
+ |
|
| 435 |
+ |
|
| 436 |
|
exclude_.addPair(a, b); |
| 437 |
|
exclude_.addPair(a, c); |
| 438 |
|
exclude_.addPair(a, d); |
| 439 |
|
exclude_.addPair(b, c); |
| 440 |
|
exclude_.addPair(b, d); |
| 441 |
|
exclude_.addPair(c, d); |
| 442 |
+ |
*/ |
| 443 |
|
} |
| 444 |
|
|
| 369 |
– |
Molecule::RigidBodyIterator rbIter; |
| 370 |
– |
RigidBody* rb; |
| 445 |
|
for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
| 446 |
|
std::vector<Atom*> atoms = rb->getAtoms(); |
| 447 |
|
for (int i = 0; i < atoms.size() -1 ; ++i) { |
| 466 |
|
int b; |
| 467 |
|
int c; |
| 468 |
|
int d; |
| 469 |
+ |
|
| 470 |
+ |
std::map<int, std::set<int> > atomGroups; |
| 471 |
+ |
|
| 472 |
+ |
Molecule::RigidBodyIterator rbIter; |
| 473 |
+ |
RigidBody* rb; |
| 474 |
+ |
Molecule::IntegrableObjectIterator ii; |
| 475 |
+ |
StuntDouble* integrableObject; |
| 476 |
|
|
| 477 |
+ |
for (integrableObject = mol->beginIntegrableObject(ii); integrableObject != NULL; |
| 478 |
+ |
integrableObject = mol->nextIntegrableObject(ii)) { |
| 479 |
+ |
|
| 480 |
+ |
if (integrableObject->isRigidBody()) { |
| 481 |
+ |
rb = static_cast<RigidBody*>(integrableObject); |
| 482 |
+ |
std::vector<Atom*> atoms = rb->getAtoms(); |
| 483 |
+ |
std::set<int> rigidAtoms; |
| 484 |
+ |
for (int i = 0; i < atoms.size(); ++i) { |
| 485 |
+ |
rigidAtoms.insert(atoms[i]->getGlobalIndex()); |
| 486 |
+ |
} |
| 487 |
+ |
for (int i = 0; i < atoms.size(); ++i) { |
| 488 |
+ |
atomGroups.insert(std::map<int, std::set<int> >::value_type(atoms[i]->getGlobalIndex(), rigidAtoms)); |
| 489 |
+ |
} |
| 490 |
+ |
} else { |
| 491 |
+ |
std::set<int> oneAtomSet; |
| 492 |
+ |
oneAtomSet.insert(integrableObject->getGlobalIndex()); |
| 493 |
+ |
atomGroups.insert(std::map<int, std::set<int> >::value_type(integrableObject->getGlobalIndex(), oneAtomSet)); |
| 494 |
+ |
} |
| 495 |
+ |
} |
| 496 |
+ |
|
| 497 |
+ |
|
| 498 |
|
for (bond= mol->beginBond(bondIter); bond != NULL; bond = mol->nextBond(bondIter)) { |
| 499 |
|
a = bond->getAtomA()->getGlobalIndex(); |
| 500 |
|
b = bond->getAtomB()->getGlobalIndex(); |
| 506 |
|
b = bend->getAtomB()->getGlobalIndex(); |
| 507 |
|
c = bend->getAtomC()->getGlobalIndex(); |
| 508 |
|
|
| 509 |
< |
exclude_.removePair(a, b); |
| 510 |
< |
exclude_.removePair(a, c); |
| 511 |
< |
exclude_.removePair(b, c); |
| 509 |
> |
std::set<int> rigidSetA = getRigidSet(a, atomGroups); |
| 510 |
> |
std::set<int> rigidSetB = getRigidSet(b, atomGroups); |
| 511 |
> |
std::set<int> rigidSetC = getRigidSet(c, atomGroups); |
| 512 |
> |
|
| 513 |
> |
exclude_.removePairs(rigidSetA, rigidSetB); |
| 514 |
> |
exclude_.removePairs(rigidSetA, rigidSetC); |
| 515 |
> |
exclude_.removePairs(rigidSetB, rigidSetC); |
| 516 |
> |
|
| 517 |
> |
//exclude_.removePair(a, b); |
| 518 |
> |
//exclude_.removePair(a, c); |
| 519 |
> |
//exclude_.removePair(b, c); |
| 520 |
|
} |
| 521 |
|
|
| 522 |
|
for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; torsion = mol->nextTorsion(torsionIter)) { |
| 525 |
|
c = torsion->getAtomC()->getGlobalIndex(); |
| 526 |
|
d = torsion->getAtomD()->getGlobalIndex(); |
| 527 |
|
|
| 528 |
+ |
std::set<int> rigidSetA = getRigidSet(a, atomGroups); |
| 529 |
+ |
std::set<int> rigidSetB = getRigidSet(b, atomGroups); |
| 530 |
+ |
std::set<int> rigidSetC = getRigidSet(c, atomGroups); |
| 531 |
+ |
std::set<int> rigidSetD = getRigidSet(d, atomGroups); |
| 532 |
+ |
|
| 533 |
+ |
exclude_.removePairs(rigidSetA, rigidSetB); |
| 534 |
+ |
exclude_.removePairs(rigidSetA, rigidSetC); |
| 535 |
+ |
exclude_.removePairs(rigidSetA, rigidSetD); |
| 536 |
+ |
exclude_.removePairs(rigidSetB, rigidSetC); |
| 537 |
+ |
exclude_.removePairs(rigidSetB, rigidSetD); |
| 538 |
+ |
exclude_.removePairs(rigidSetC, rigidSetD); |
| 539 |
+ |
|
| 540 |
+ |
/* |
| 541 |
+ |
exclude_.removePairs(rigidSetA.begin(), rigidSetA.end(), rigidSetB.begin(), rigidSetB.end()); |
| 542 |
+ |
exclude_.removePairs(rigidSetA.begin(), rigidSetA.end(), rigidSetC.begin(), rigidSetC.end()); |
| 543 |
+ |
exclude_.removePairs(rigidSetA.begin(), rigidSetA.end(), rigidSetD.begin(), rigidSetD.end()); |
| 544 |
+ |
exclude_.removePairs(rigidSetB.begin(), rigidSetB.end(), rigidSetC.begin(), rigidSetC.end()); |
| 545 |
+ |
exclude_.removePairs(rigidSetB.begin(), rigidSetB.end(), rigidSetD.begin(), rigidSetD.end()); |
| 546 |
+ |
exclude_.removePairs(rigidSetC.begin(), rigidSetC.end(), rigidSetD.begin(), rigidSetD.end()); |
| 547 |
+ |
|
| 548 |
+ |
|
| 549 |
|
exclude_.removePair(a, b); |
| 550 |
|
exclude_.removePair(a, c); |
| 551 |
|
exclude_.removePair(a, d); |
| 552 |
|
exclude_.removePair(b, c); |
| 553 |
|
exclude_.removePair(b, d); |
| 554 |
|
exclude_.removePair(c, d); |
| 555 |
+ |
*/ |
| 556 |
|
} |
| 557 |
|
|
| 426 |
– |
Molecule::RigidBodyIterator rbIter; |
| 427 |
– |
RigidBody* rb; |
| 558 |
|
for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
| 559 |
|
std::vector<Atom*> atoms = rb->getAtoms(); |
| 560 |
|
for (int i = 0; i < atoms.size() -1 ; ++i) { |
| 592 |
|
//setup fortran force field |
| 593 |
|
/** @deprecate */ |
| 594 |
|
int isError = 0; |
| 595 |
< |
initFortranFF( &fInfo_.SIM_uses_RF , &isError ); |
| 595 |
> |
|
| 596 |
> |
setupElectrostaticSummationMethod( isError ); |
| 597 |
> |
setupSwitchingFunction(); |
| 598 |
> |
|
| 599 |
|
if(isError){ |
| 600 |
|
sprintf( painCave.errMsg, |
| 601 |
|
"ForceField error: There was an error initializing the forceField in fortran.\n" ); |
| 639 |
|
int useLennardJones = 0; |
| 640 |
|
int useElectrostatic = 0; |
| 641 |
|
int useEAM = 0; |
| 642 |
+ |
int useSC = 0; |
| 643 |
|
int useCharge = 0; |
| 644 |
|
int useDirectional = 0; |
| 645 |
|
int useDipole = 0; |
| 651 |
|
int useDirectionalAtom = 0; |
| 652 |
|
int useElectrostatics = 0; |
| 653 |
|
//usePBC and useRF are from simParams |
| 654 |
< |
int usePBC = simParams_->getPBC(); |
| 655 |
< |
int useRF = simParams_->getUseRF(); |
| 654 |
> |
int usePBC = simParams_->getUsePeriodicBoundaryConditions(); |
| 655 |
> |
int useRF; |
| 656 |
> |
int useSF; |
| 657 |
> |
std::string myMethod; |
| 658 |
|
|
| 659 |
+ |
// set the useRF logical |
| 660 |
+ |
useRF = 0; |
| 661 |
+ |
useSF = 0; |
| 662 |
+ |
|
| 663 |
+ |
|
| 664 |
+ |
if (simParams_->haveElectrostaticSummationMethod()) { |
| 665 |
+ |
std::string myMethod = simParams_->getElectrostaticSummationMethod(); |
| 666 |
+ |
toUpper(myMethod); |
| 667 |
+ |
if (myMethod == "REACTION_FIELD") { |
| 668 |
+ |
useRF=1; |
| 669 |
+ |
} else { |
| 670 |
+ |
if (myMethod == "SHIFTED_FORCE") { |
| 671 |
+ |
useSF = 1; |
| 672 |
+ |
} |
| 673 |
+ |
} |
| 674 |
+ |
} |
| 675 |
+ |
|
| 676 |
|
//loop over all of the atom types |
| 677 |
|
for (i = atomTypes.begin(); i != atomTypes.end(); ++i) { |
| 678 |
|
useLennardJones |= (*i)->isLennardJones(); |
| 679 |
|
useElectrostatic |= (*i)->isElectrostatic(); |
| 680 |
|
useEAM |= (*i)->isEAM(); |
| 681 |
+ |
useSC |= (*i)->isSC(); |
| 682 |
|
useCharge |= (*i)->isCharge(); |
| 683 |
|
useDirectional |= (*i)->isDirectional(); |
| 684 |
|
useDipole |= (*i)->isDipole(); |
| 729 |
|
temp = useEAM; |
| 730 |
|
MPI_Allreduce(&temp, &useEAM, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
| 731 |
|
|
| 732 |
+ |
temp = useSC; |
| 733 |
+ |
MPI_Allreduce(&temp, &useSC, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
| 734 |
+ |
|
| 735 |
|
temp = useShape; |
| 736 |
|
MPI_Allreduce(&temp, &useShape, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
| 737 |
|
|
| 740 |
|
|
| 741 |
|
temp = useRF; |
| 742 |
|
MPI_Allreduce(&temp, &useRF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
| 743 |
< |
|
| 743 |
> |
|
| 744 |
> |
temp = useSF; |
| 745 |
> |
MPI_Allreduce(&temp, &useSF, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
| 746 |
> |
|
| 747 |
|
#endif |
| 748 |
|
|
| 749 |
|
fInfo_.SIM_uses_PBC = usePBC; |
| 756 |
|
fInfo_.SIM_uses_StickyPower = useStickyPower; |
| 757 |
|
fInfo_.SIM_uses_GayBerne = useGayBerne; |
| 758 |
|
fInfo_.SIM_uses_EAM = useEAM; |
| 759 |
+ |
fInfo_.SIM_uses_SC = useSC; |
| 760 |
|
fInfo_.SIM_uses_Shapes = useShape; |
| 761 |
|
fInfo_.SIM_uses_FLARB = useFLARB; |
| 762 |
|
fInfo_.SIM_uses_RF = useRF; |
| 763 |
+ |
fInfo_.SIM_uses_SF = useSF; |
| 764 |
|
|
| 765 |
< |
if( fInfo_.SIM_uses_Dipoles && fInfo_.SIM_uses_RF) { |
| 766 |
< |
|
| 765 |
> |
if( myMethod == "REACTION_FIELD") { |
| 766 |
> |
|
| 767 |
|
if (simParams_->haveDielectric()) { |
| 768 |
|
fInfo_.dielect = simParams_->getDielectric(); |
| 769 |
|
} else { |
| 773 |
|
"\tsetting a dielectric constant!\n"); |
| 774 |
|
painCave.isFatal = 1; |
| 775 |
|
simError(); |
| 776 |
< |
} |
| 615 |
< |
|
| 616 |
< |
} else { |
| 617 |
< |
fInfo_.dielect = 0.0; |
| 776 |
> |
} |
| 777 |
|
} |
| 778 |
|
|
| 779 |
|
} |
| 809 |
|
|
| 810 |
|
totalMass = cg->getMass(); |
| 811 |
|
for(atom = cg->beginAtom(ai); atom != NULL; atom = cg->nextAtom(ai)) { |
| 812 |
< |
mfact.push_back(atom->getMass()/totalMass); |
| 812 |
> |
// Check for massless groups - set mfact to 1 if true |
| 813 |
> |
if (totalMass != 0) |
| 814 |
> |
mfact.push_back(atom->getMass()/totalMass); |
| 815 |
> |
else |
| 816 |
> |
mfact.push_back( 1.0 ); |
| 817 |
|
} |
| 818 |
|
|
| 819 |
|
} |
| 922 |
|
|
| 923 |
|
#endif |
| 924 |
|
|
| 925 |
< |
double SimInfo::calcMaxCutoffRadius() { |
| 763 |
< |
|
| 764 |
< |
|
| 765 |
< |
std::set<AtomType*> atomTypes; |
| 766 |
< |
std::set<AtomType*>::iterator i; |
| 767 |
< |
std::vector<double> cutoffRadius; |
| 768 |
< |
|
| 769 |
< |
//get the unique atom types |
| 770 |
< |
atomTypes = getUniqueAtomTypes(); |
| 771 |
< |
|
| 772 |
< |
//query the max cutoff radius among these atom types |
| 773 |
< |
for (i = atomTypes.begin(); i != atomTypes.end(); ++i) { |
| 774 |
< |
cutoffRadius.push_back(forceField_->getRcutFromAtomType(*i)); |
| 775 |
< |
} |
| 776 |
< |
|
| 777 |
< |
double maxCutoffRadius = *(std::max_element(cutoffRadius.begin(), cutoffRadius.end())); |
| 778 |
< |
#ifdef IS_MPI |
| 779 |
< |
//pick the max cutoff radius among the processors |
| 780 |
< |
#endif |
| 781 |
< |
|
| 782 |
< |
return maxCutoffRadius; |
| 783 |
< |
} |
| 784 |
< |
|
| 785 |
< |
void SimInfo::getCutoff(double& rcut, double& rsw) { |
| 925 |
> |
void SimInfo::setupCutoff() { |
| 926 |
|
|
| 927 |
< |
if (fInfo_.SIM_uses_Charges | fInfo_.SIM_uses_Dipoles | fInfo_.SIM_uses_RF) { |
| 927 |
> |
// Check the cutoff policy |
| 928 |
> |
int cp = TRADITIONAL_CUTOFF_POLICY; |
| 929 |
> |
if (simParams_->haveCutoffPolicy()) { |
| 930 |
> |
std::string myPolicy = simParams_->getCutoffPolicy(); |
| 931 |
> |
toUpper(myPolicy); |
| 932 |
> |
if (myPolicy == "MIX") { |
| 933 |
> |
cp = MIX_CUTOFF_POLICY; |
| 934 |
> |
} else { |
| 935 |
> |
if (myPolicy == "MAX") { |
| 936 |
> |
cp = MAX_CUTOFF_POLICY; |
| 937 |
> |
} else { |
| 938 |
> |
if (myPolicy == "TRADITIONAL") { |
| 939 |
> |
cp = TRADITIONAL_CUTOFF_POLICY; |
| 940 |
> |
} else { |
| 941 |
> |
// throw error |
| 942 |
> |
sprintf( painCave.errMsg, |
| 943 |
> |
"SimInfo error: Unknown cutoffPolicy. (Input file specified %s .)\n\tcutoffPolicy must be one of: \"Mix\", \"Max\", or \"Traditional\".", myPolicy.c_str() ); |
| 944 |
> |
painCave.isFatal = 1; |
| 945 |
> |
simError(); |
| 946 |
> |
} |
| 947 |
> |
} |
| 948 |
> |
} |
| 949 |
> |
} |
| 950 |
> |
notifyFortranCutoffPolicy(&cp); |
| 951 |
> |
|
| 952 |
> |
// Check the Skin Thickness for neighborlists |
| 953 |
> |
double skin; |
| 954 |
> |
if (simParams_->haveSkinThickness()) { |
| 955 |
> |
skin = simParams_->getSkinThickness(); |
| 956 |
> |
notifyFortranSkinThickness(&skin); |
| 957 |
> |
} |
| 958 |
|
|
| 959 |
< |
if (!simParams_->haveRcut()){ |
| 960 |
< |
sprintf(painCave.errMsg, |
| 959 |
> |
// Check if the cutoff was set explicitly: |
| 960 |
> |
if (simParams_->haveCutoffRadius()) { |
| 961 |
> |
rcut_ = simParams_->getCutoffRadius(); |
| 962 |
> |
if (simParams_->haveSwitchingRadius()) { |
| 963 |
> |
rsw_ = simParams_->getSwitchingRadius(); |
| 964 |
> |
} else { |
| 965 |
> |
rsw_ = rcut_; |
| 966 |
> |
} |
| 967 |
> |
notifyFortranCutoffs(&rcut_, &rsw_); |
| 968 |
> |
|
| 969 |
> |
} else { |
| 970 |
> |
|
| 971 |
> |
// For electrostatic atoms, we'll assume a large safe value: |
| 972 |
> |
if (fInfo_.SIM_uses_Charges | fInfo_.SIM_uses_Dipoles | fInfo_.SIM_uses_RF) { |
| 973 |
> |
sprintf(painCave.errMsg, |
| 974 |
|
"SimCreator Warning: No value was set for the cutoffRadius.\n" |
| 975 |
|
"\tOOPSE will use a default value of 15.0 angstroms" |
| 976 |
|
"\tfor the cutoffRadius.\n"); |
| 977 |
< |
painCave.isFatal = 0; |
| 977 |
> |
painCave.isFatal = 0; |
| 978 |
|
simError(); |
| 979 |
< |
rcut = 15.0; |
| 980 |
< |
} else{ |
| 981 |
< |
rcut = simParams_->getRcut(); |
| 982 |
< |
} |
| 979 |
> |
rcut_ = 15.0; |
| 980 |
> |
|
| 981 |
> |
if (simParams_->haveElectrostaticSummationMethod()) { |
| 982 |
> |
std::string myMethod = simParams_->getElectrostaticSummationMethod(); |
| 983 |
> |
toUpper(myMethod); |
| 984 |
> |
if (myMethod == "SHIFTED_POTENTIAL" || myMethod == "SHIFTED_FORCE") { |
| 985 |
> |
if (simParams_->haveSwitchingRadius()){ |
| 986 |
> |
sprintf(painCave.errMsg, |
| 987 |
> |
"SimInfo Warning: A value was set for the switchingRadius\n" |
| 988 |
> |
"\teven though the electrostaticSummationMethod was\n" |
| 989 |
> |
"\tset to %s\n", myMethod.c_str()); |
| 990 |
> |
painCave.isFatal = 1; |
| 991 |
> |
simError(); |
| 992 |
> |
} |
| 993 |
> |
} |
| 994 |
> |
} |
| 995 |
> |
|
| 996 |
> |
if (simParams_->haveSwitchingRadius()){ |
| 997 |
> |
rsw_ = simParams_->getSwitchingRadius(); |
| 998 |
> |
} else { |
| 999 |
> |
sprintf(painCave.errMsg, |
| 1000 |
> |
"SimCreator Warning: No value was set for switchingRadius.\n" |
| 1001 |
> |
"\tOOPSE will use a default value of\n" |
| 1002 |
> |
"\t0.85 * cutoffRadius for the switchingRadius\n"); |
| 1003 |
> |
painCave.isFatal = 0; |
| 1004 |
> |
simError(); |
| 1005 |
> |
rsw_ = 0.85 * rcut_; |
| 1006 |
> |
} |
| 1007 |
> |
notifyFortranCutoffs(&rcut_, &rsw_); |
| 1008 |
> |
} else { |
| 1009 |
> |
// We didn't set rcut explicitly, and we don't have electrostatic atoms, so |
| 1010 |
> |
// We'll punt and let fortran figure out the cutoffs later. |
| 1011 |
> |
|
| 1012 |
> |
notifyFortranYouAreOnYourOwn(); |
| 1013 |
|
|
| 801 |
– |
if (!simParams_->haveRsw()){ |
| 802 |
– |
sprintf(painCave.errMsg, |
| 803 |
– |
"SimCreator Warning: No value was set for switchingRadius.\n" |
| 804 |
– |
"\tOOPSE will use a default value of\n" |
| 805 |
– |
"\t0.95 * cutoffRadius for the switchingRadius\n"); |
| 806 |
– |
painCave.isFatal = 0; |
| 807 |
– |
simError(); |
| 808 |
– |
rsw = 0.95 * rcut; |
| 809 |
– |
} else{ |
| 810 |
– |
rsw = simParams_->getRsw(); |
| 1014 |
|
} |
| 1015 |
+ |
} |
| 1016 |
+ |
} |
| 1017 |
|
|
| 1018 |
< |
} else { |
| 1019 |
< |
// if charge, dipole or reaction field is not used and the cutofff radius is not specified in |
| 1020 |
< |
//meta-data file, the maximum cutoff radius calculated from forcefiled will be used |
| 1021 |
< |
|
| 1022 |
< |
if (simParams_->haveRcut()) { |
| 1023 |
< |
rcut = simParams_->getRcut(); |
| 1024 |
< |
} else { |
| 820 |
< |
//set cutoff radius to the maximum cutoff radius based on atom types in the whole system |
| 821 |
< |
rcut = calcMaxCutoffRadius(); |
| 822 |
< |
} |
| 1018 |
> |
void SimInfo::setupElectrostaticSummationMethod( int isError ) { |
| 1019 |
> |
|
| 1020 |
> |
int errorOut; |
| 1021 |
> |
int esm = NONE; |
| 1022 |
> |
int sm = UNDAMPED; |
| 1023 |
> |
double alphaVal; |
| 1024 |
> |
double dielectric; |
| 1025 |
|
|
| 1026 |
< |
if (simParams_->haveRsw()) { |
| 1027 |
< |
rsw = simParams_->getRsw(); |
| 1028 |
< |
} else { |
| 1029 |
< |
rsw = rcut; |
| 1026 |
> |
errorOut = isError; |
| 1027 |
> |
alphaVal = simParams_->getDampingAlpha(); |
| 1028 |
> |
dielectric = simParams_->getDielectric(); |
| 1029 |
> |
|
| 1030 |
> |
if (simParams_->haveElectrostaticSummationMethod()) { |
| 1031 |
> |
std::string myMethod = simParams_->getElectrostaticSummationMethod(); |
| 1032 |
> |
toUpper(myMethod); |
| 1033 |
> |
if (myMethod == "NONE") { |
| 1034 |
> |
esm = NONE; |
| 1035 |
> |
} else { |
| 1036 |
> |
if (myMethod == "SWITCHING_FUNCTION") { |
| 1037 |
> |
esm = SWITCHING_FUNCTION; |
| 1038 |
> |
} else { |
| 1039 |
> |
if (myMethod == "SHIFTED_POTENTIAL") { |
| 1040 |
> |
esm = SHIFTED_POTENTIAL; |
| 1041 |
> |
} else { |
| 1042 |
> |
if (myMethod == "SHIFTED_FORCE") { |
| 1043 |
> |
esm = SHIFTED_FORCE; |
| 1044 |
> |
} else { |
| 1045 |
> |
if (myMethod == "REACTION_FIELD") { |
| 1046 |
> |
esm = REACTION_FIELD; |
| 1047 |
> |
} else { |
| 1048 |
> |
// throw error |
| 1049 |
> |
sprintf( painCave.errMsg, |
| 1050 |
> |
"SimInfo error: Unknown electrostaticSummationMethod.\n" |
| 1051 |
> |
"\t(Input file specified %s .)\n" |
| 1052 |
> |
"\telectrostaticSummationMethod must be one of: \"none\",\n" |
| 1053 |
> |
"\t\"shifted_potential\", \"shifted_force\", or \n" |
| 1054 |
> |
"\t\"reaction_field\".\n", myMethod.c_str() ); |
| 1055 |
> |
painCave.isFatal = 1; |
| 1056 |
> |
simError(); |
| 1057 |
> |
} |
| 1058 |
> |
} |
| 1059 |
> |
} |
| 1060 |
> |
} |
| 1061 |
|
} |
| 1062 |
+ |
} |
| 1063 |
|
|
| 1064 |
+ |
if (simParams_->haveElectrostaticScreeningMethod()) { |
| 1065 |
+ |
std::string myScreen = simParams_->getElectrostaticScreeningMethod(); |
| 1066 |
+ |
toUpper(myScreen); |
| 1067 |
+ |
if (myScreen == "UNDAMPED") { |
| 1068 |
+ |
sm = UNDAMPED; |
| 1069 |
+ |
} else { |
| 1070 |
+ |
if (myScreen == "DAMPED") { |
| 1071 |
+ |
sm = DAMPED; |
| 1072 |
+ |
if (!simParams_->haveDampingAlpha()) { |
| 1073 |
+ |
//throw error |
| 1074 |
+ |
sprintf( painCave.errMsg, |
| 1075 |
+ |
"SimInfo warning: dampingAlpha was not specified in the input file.\n" |
| 1076 |
+ |
"\tA default value of %f (1/ang) will be used.\n", alphaVal); |
| 1077 |
+ |
painCave.isFatal = 0; |
| 1078 |
+ |
simError(); |
| 1079 |
+ |
} |
| 1080 |
+ |
} else { |
| 1081 |
+ |
// throw error |
| 1082 |
+ |
sprintf( painCave.errMsg, |
| 1083 |
+ |
"SimInfo error: Unknown electrostaticScreeningMethod.\n" |
| 1084 |
+ |
"\t(Input file specified %s .)\n" |
| 1085 |
+ |
"\telectrostaticScreeningMethod must be one of: \"undamped\"\n" |
| 1086 |
+ |
"or \"damped\".\n", myScreen.c_str() ); |
| 1087 |
+ |
painCave.isFatal = 1; |
| 1088 |
+ |
simError(); |
| 1089 |
+ |
} |
| 1090 |
+ |
} |
| 1091 |
|
} |
| 1092 |
+ |
|
| 1093 |
+ |
// let's pass some summation method variables to fortran |
| 1094 |
+ |
setElectrostaticSummationMethod( &esm ); |
| 1095 |
+ |
notifyFortranElectrostaticMethod( &esm ); |
| 1096 |
+ |
setScreeningMethod( &sm ); |
| 1097 |
+ |
setDampingAlpha( &alphaVal ); |
| 1098 |
+ |
setReactionFieldDielectric( &dielectric ); |
| 1099 |
+ |
initFortranFF( &errorOut ); |
| 1100 |
|
} |
| 1101 |
|
|
| 1102 |
< |
void SimInfo::setupCutoff() { |
| 1103 |
< |
getCutoff(rcut_, rsw_); |
| 835 |
< |
double rnblist = rcut_ + 1; // skin of neighbor list |
| 1102 |
> |
void SimInfo::setupSwitchingFunction() { |
| 1103 |
> |
int ft = CUBIC; |
| 1104 |
|
|
| 1105 |
< |
//Pass these cutoff radius etc. to fortran. This function should be called once and only once |
| 1106 |
< |
notifyFortranCutoffs(&rcut_, &rsw_, &rnblist); |
| 1105 |
> |
if (simParams_->haveSwitchingFunctionType()) { |
| 1106 |
> |
std::string funcType = simParams_->getSwitchingFunctionType(); |
| 1107 |
> |
toUpper(funcType); |
| 1108 |
> |
if (funcType == "CUBIC") { |
| 1109 |
> |
ft = CUBIC; |
| 1110 |
> |
} else { |
| 1111 |
> |
if (funcType == "FIFTH_ORDER_POLYNOMIAL") { |
| 1112 |
> |
ft = FIFTH_ORDER_POLY; |
| 1113 |
> |
} else { |
| 1114 |
> |
// throw error |
| 1115 |
> |
sprintf( painCave.errMsg, |
| 1116 |
> |
"SimInfo error: Unknown switchingFunctionType. (Input file specified %s .)\n\tswitchingFunctionType must be one of: \"cubic\" or \"fifth_order_polynomial\".", funcType.c_str() ); |
| 1117 |
> |
painCave.isFatal = 1; |
| 1118 |
> |
simError(); |
| 1119 |
> |
} |
| 1120 |
> |
} |
| 1121 |
> |
} |
| 1122 |
> |
|
| 1123 |
> |
// send switching function notification to switcheroo |
| 1124 |
> |
setFunctionType(&ft); |
| 1125 |
> |
|
| 1126 |
|
} |
| 1127 |
|
|
| 1128 |
|
void SimInfo::addProperty(GenericData* genData) { |
| 1268 |
|
|
| 1269 |
|
/* |
| 1270 |
|
Return intertia tensor for entire system and angular momentum Vector. |
| 1271 |
+ |
|
| 1272 |
+ |
|
| 1273 |
+ |
[ Ixx -Ixy -Ixz ] |
| 1274 |
+ |
J =| -Iyx Iyy -Iyz | |
| 1275 |
+ |
[ -Izx -Iyz Izz ] |
| 1276 |
|
*/ |
| 1277 |
|
|
| 1278 |
|
void SimInfo::getInertiaTensor(Mat3x3d &inertiaTensor, Vector3d &angularMomentum){ |
| 1324 |
|
inertiaTensor(0,1) = -xy; |
| 1325 |
|
inertiaTensor(0,2) = -xz; |
| 1326 |
|
inertiaTensor(1,0) = -xy; |
| 1327 |
< |
inertiaTensor(2,0) = xx + zz; |
| 1327 |
> |
inertiaTensor(1,1) = xx + zz; |
| 1328 |
|
inertiaTensor(1,2) = -yz; |
| 1329 |
|
inertiaTensor(2,0) = -xz; |
| 1330 |
|
inertiaTensor(2,1) = -yz; |
| 1352 |
|
SimInfo::MoleculeIterator i; |
| 1353 |
|
Molecule* mol; |
| 1354 |
|
|
| 1355 |
< |
Vector3d thisq(0.0); |
| 1356 |
< |
Vector3d thisv(0.0); |
| 1355 |
> |
Vector3d thisr(0.0); |
| 1356 |
> |
Vector3d thisp(0.0); |
| 1357 |
|
|
| 1358 |
< |
double thisMass = 0.0; |
| 1358 |
> |
double thisMass; |
| 1359 |
|
|
| 1360 |
|
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
| 1361 |
< |
thisq = mol->getCom()-com; |
| 1362 |
< |
thisv = mol->getComVel()-comVel; |
| 1363 |
< |
thisMass = mol->getMass(); |
| 1072 |
< |
angularMomentum += cross( thisq, thisv ) * thisMass; |
| 1361 |
> |
thisMass = mol->getMass(); |
| 1362 |
> |
thisr = mol->getCom()-com; |
| 1363 |
> |
thisp = (mol->getComVel()-comVel)*thisMass; |
| 1364 |
|
|
| 1365 |
+ |
angularMomentum += cross( thisr, thisp ); |
| 1366 |
+ |
|
| 1367 |
|
} |
| 1368 |
|
|
| 1369 |
|
#ifdef IS_MPI |