| 347 |
|
|
| 348 |
|
preCalculation(); |
| 349 |
|
shortRangeInteractions(); |
| 350 |
< |
longRangeInteractions(); |
| 350 |
> |
// longRangeInteractions(); |
| 351 |
> |
longRangeInteractionsRapaport(); |
| 352 |
|
postCalculation(); |
| 353 |
|
} |
| 354 |
|
|
| 509 |
|
curSnapshot->statData[Stats::INVERSION_POTENTIAL] = inversionPotential; |
| 510 |
|
} |
| 511 |
|
|
| 512 |
+ |
void ForceManager::longRangeInteractionsRapaport() { |
| 513 |
+ |
|
| 514 |
+ |
Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); |
| 515 |
+ |
DataStorage* config = &(curSnapshot->atomData); |
| 516 |
+ |
DataStorage* cgConfig = &(curSnapshot->cgData); |
| 517 |
+ |
|
| 518 |
+ |
//calculate the center of mass of cutoff group |
| 519 |
+ |
|
| 520 |
+ |
SimInfo::MoleculeIterator mi; |
| 521 |
+ |
Molecule* mol; |
| 522 |
+ |
Molecule::CutoffGroupIterator ci; |
| 523 |
+ |
CutoffGroup* cg; |
| 524 |
+ |
|
| 525 |
+ |
if(info_->getNCutoffGroups() > 0){ |
| 526 |
+ |
for (mol = info_->beginMolecule(mi); mol != NULL; |
| 527 |
+ |
mol = info_->nextMolecule(mi)) { |
| 528 |
+ |
for(cg = mol->beginCutoffGroup(ci); cg != NULL; |
| 529 |
+ |
cg = mol->nextCutoffGroup(ci)) { |
| 530 |
+ |
cerr << "branch1\n"; |
| 531 |
+ |
cerr << "globind = " << cg->getGlobalIndex() << "\n"; |
| 532 |
+ |
cg->updateCOM(); |
| 533 |
+ |
} |
| 534 |
+ |
} |
| 535 |
+ |
} else { |
| 536 |
+ |
// center of mass of the group is the same as position of the atom |
| 537 |
+ |
// if cutoff group does not exist |
| 538 |
+ |
cerr << "branch2\n"; |
| 539 |
+ |
cgConfig->position = config->position; |
| 540 |
+ |
} |
| 541 |
+ |
|
| 542 |
+ |
fDecomp_->zeroWorkArrays(); |
| 543 |
+ |
fDecomp_->distributeData(); |
| 544 |
+ |
|
| 545 |
+ |
int cg1, cg2, atom1, atom2, topoDist; |
| 546 |
+ |
Vector3d d_grp, dag, d; |
| 547 |
+ |
RealType rgrpsq, rgrp, r2, r; |
| 548 |
+ |
RealType electroMult, vdwMult; |
| 549 |
+ |
RealType vij; |
| 550 |
+ |
Vector3d fij, fg, f1; |
| 551 |
+ |
tuple3<RealType, RealType, RealType> cuts; |
| 552 |
+ |
RealType rCutSq; |
| 553 |
+ |
bool in_switching_region; |
| 554 |
+ |
RealType sw, dswdr, swderiv; |
| 555 |
+ |
vector<int> atomListColumn, atomListRow, atomListLocal; |
| 556 |
+ |
InteractionData idat; |
| 557 |
+ |
SelfData sdat; |
| 558 |
+ |
RealType mf; |
| 559 |
+ |
RealType lrPot; |
| 560 |
+ |
RealType vpair; |
| 561 |
+ |
potVec longRangePotential(0.0); |
| 562 |
+ |
potVec workPot(0.0); |
| 563 |
+ |
|
| 564 |
+ |
int loopStart, loopEnd; |
| 565 |
+ |
|
| 566 |
+ |
idat.vdwMult = &vdwMult; |
| 567 |
+ |
idat.electroMult = &electroMult; |
| 568 |
+ |
idat.pot = &workPot; |
| 569 |
+ |
sdat.pot = fDecomp_->getEmbeddingPotential(); |
| 570 |
+ |
idat.vpair = &vpair; |
| 571 |
+ |
idat.f1 = &f1; |
| 572 |
+ |
idat.sw = &sw; |
| 573 |
+ |
idat.shiftedPot = (cutoffMethod_ == SHIFTED_POTENTIAL) ? true : false; |
| 574 |
+ |
idat.shiftedForce = (cutoffMethod_ == SHIFTED_FORCE) ? true : false; |
| 575 |
+ |
|
| 576 |
+ |
loopEnd = PAIR_LOOP; |
| 577 |
+ |
if (info_->requiresPrepair() ) { |
| 578 |
+ |
loopStart = PREPAIR_LOOP; |
| 579 |
+ |
} else { |
| 580 |
+ |
loopStart = PAIR_LOOP; |
| 581 |
+ |
} |
| 582 |
+ |
|
| 583 |
+ |
for (int iLoop = loopStart; iLoop <= loopEnd; iLoop++) { |
| 584 |
+ |
|
| 585 |
+ |
if (iLoop == loopStart) { |
| 586 |
+ |
bool update_nlist = fDecomp_->checkNeighborList(); |
| 587 |
+ |
if (update_nlist) |
| 588 |
+ |
neighborMatW = fDecomp_->buildLayerBasedNeighborList(); |
| 589 |
+ |
} |
| 590 |
+ |
|
| 591 |
+ |
int i; |
| 592 |
+ |
#pragma omp parallel for num_threads(2) private(i) |
| 593 |
+ |
for(i = 0; i < neighborMatW.size(); ++i) |
| 594 |
+ |
for(vector<int>::iterator j = neighborMatW[i].begin(); j != neighborMatW[i].end(); ++j) |
| 595 |
+ |
{ |
| 596 |
+ |
cg1 = i; |
| 597 |
+ |
cg2 = *j; |
| 598 |
+ |
|
| 599 |
+ |
cuts = fDecomp_->getGroupCutoffs(cg1, cg2); |
| 600 |
+ |
|
| 601 |
+ |
d_grp = fDecomp_->getIntergroupVector(cg1, cg2); |
| 602 |
+ |
curSnapshot->wrapVector(d_grp); |
| 603 |
+ |
rgrpsq = d_grp.lengthSquare(); |
| 604 |
+ |
|
| 605 |
+ |
rCutSq = cuts.second; |
| 606 |
+ |
|
| 607 |
+ |
if (rgrpsq < rCutSq) { |
| 608 |
+ |
idat.rcut = &cuts.first; |
| 609 |
+ |
if (iLoop == PAIR_LOOP) { |
| 610 |
+ |
vij = 0.0; |
| 611 |
+ |
fij = V3Zero; |
| 612 |
+ |
} |
| 613 |
+ |
|
| 614 |
+ |
in_switching_region = switcher_->getSwitch(rgrpsq, sw, dswdr, |
| 615 |
+ |
rgrp); |
| 616 |
+ |
|
| 617 |
+ |
atomListRow = fDecomp_->getAtomsInGroupRow(cg1); |
| 618 |
+ |
atomListColumn = fDecomp_->getAtomsInGroupColumn(cg2); |
| 619 |
+ |
|
| 620 |
+ |
for (vector<int>::iterator ia = atomListRow.begin(); |
| 621 |
+ |
ia != atomListRow.end(); ++ia) { |
| 622 |
+ |
atom1 = (*ia); |
| 623 |
+ |
|
| 624 |
+ |
for (vector<int>::iterator jb = atomListColumn.begin(); |
| 625 |
+ |
jb != atomListColumn.end(); ++jb) { |
| 626 |
+ |
atom2 = (*jb); |
| 627 |
+ |
|
| 628 |
+ |
if (!fDecomp_->skipAtomPair(atom1, atom2)) { |
| 629 |
+ |
vpair = 0.0; |
| 630 |
+ |
workPot = 0.0; |
| 631 |
+ |
f1 = V3Zero; |
| 632 |
+ |
|
| 633 |
+ |
fDecomp_->fillInteractionData(idat, atom1, atom2); |
| 634 |
+ |
|
| 635 |
+ |
topoDist = fDecomp_->getTopologicalDistance(atom1, atom2); |
| 636 |
+ |
vdwMult = vdwScale_[topoDist]; |
| 637 |
+ |
electroMult = electrostaticScale_[topoDist]; |
| 638 |
+ |
|
| 639 |
+ |
if (atomListRow.size() == 1 && atomListColumn.size() == 1) { |
| 640 |
+ |
idat.d = &d_grp; |
| 641 |
+ |
idat.r2 = &rgrpsq; |
| 642 |
+ |
cerr << "dgrp = " << d_grp << "\n"; |
| 643 |
+ |
} else { |
| 644 |
+ |
d = fDecomp_->getInteratomicVector(atom1, atom2); |
| 645 |
+ |
curSnapshot->wrapVector( d ); |
| 646 |
+ |
r2 = d.lengthSquare(); |
| 647 |
+ |
cerr << "datm = " << d<< "\n"; |
| 648 |
+ |
idat.d = &d; |
| 649 |
+ |
idat.r2 = &r2; |
| 650 |
+ |
} |
| 651 |
+ |
|
| 652 |
+ |
cerr << "idat.d = " << *(idat.d) << "\n"; |
| 653 |
+ |
r = sqrt( *(idat.r2) ); |
| 654 |
+ |
idat.rij = &r; |
| 655 |
+ |
|
| 656 |
+ |
if (iLoop == PREPAIR_LOOP) { |
| 657 |
+ |
interactionMan_->doPrePair(idat); |
| 658 |
+ |
} else { |
| 659 |
+ |
interactionMan_->doPair(idat); |
| 660 |
+ |
fDecomp_->unpackInteractionData(idat, atom1, atom2); |
| 661 |
+ |
|
| 662 |
+ |
cerr << "d = " << *(idat.d) << "\tv=" << vpair << "\tf=" << f1 << "\n"; |
| 663 |
+ |
vij += vpair; |
| 664 |
+ |
fij += f1; |
| 665 |
+ |
tau -= outProduct( *(idat.d), f1); |
| 666 |
+ |
} |
| 667 |
+ |
} |
| 668 |
+ |
} |
| 669 |
+ |
} |
| 670 |
+ |
|
| 671 |
+ |
if (iLoop == PAIR_LOOP) { |
| 672 |
+ |
if (in_switching_region) { |
| 673 |
+ |
swderiv = vij * dswdr / rgrp; |
| 674 |
+ |
fg = swderiv * d_grp; |
| 675 |
+ |
fij += fg; |
| 676 |
+ |
|
| 677 |
+ |
if (atomListRow.size() == 1 && atomListColumn.size() == 1) { |
| 678 |
+ |
tau -= outProduct( *(idat.d), fg); |
| 679 |
+ |
} |
| 680 |
+ |
|
| 681 |
+ |
for (vector<int>::iterator ia = atomListRow.begin(); |
| 682 |
+ |
ia != atomListRow.end(); ++ia) { |
| 683 |
+ |
atom1 = (*ia); |
| 684 |
+ |
mf = fDecomp_->getMassFactorRow(atom1); |
| 685 |
+ |
// fg is the force on atom ia due to cutoff group's |
| 686 |
+ |
// presence in switching region |
| 687 |
+ |
fg = swderiv * d_grp * mf; |
| 688 |
+ |
fDecomp_->addForceToAtomRow(atom1, fg); |
| 689 |
+ |
|
| 690 |
+ |
if (atomListRow.size() > 1) { |
| 691 |
+ |
if (info_->usesAtomicVirial()) { |
| 692 |
+ |
// find the distance between the atom |
| 693 |
+ |
// and the center of the cutoff group: |
| 694 |
+ |
dag = fDecomp_->getAtomToGroupVectorRow(atom1, cg1); |
| 695 |
+ |
tau -= outProduct(dag, fg); |
| 696 |
+ |
} |
| 697 |
+ |
} |
| 698 |
+ |
} |
| 699 |
+ |
for (vector<int>::iterator jb = atomListColumn.begin(); |
| 700 |
+ |
jb != atomListColumn.end(); ++jb) { |
| 701 |
+ |
atom2 = (*jb); |
| 702 |
+ |
mf = fDecomp_->getMassFactorColumn(atom2); |
| 703 |
+ |
// fg is the force on atom jb due to cutoff group's |
| 704 |
+ |
// presence in switching region |
| 705 |
+ |
fg = -swderiv * d_grp * mf; |
| 706 |
+ |
fDecomp_->addForceToAtomColumn(atom2, fg); |
| 707 |
+ |
|
| 708 |
+ |
if (atomListColumn.size() > 1) { |
| 709 |
+ |
if (info_->usesAtomicVirial()) { |
| 710 |
+ |
// find the distance between the atom |
| 711 |
+ |
// and the center of the cutoff group: |
| 712 |
+ |
dag = fDecomp_->getAtomToGroupVectorColumn(atom2, cg2); |
| 713 |
+ |
tau -= outProduct(dag, fg); |
| 714 |
+ |
} |
| 715 |
+ |
} |
| 716 |
+ |
} |
| 717 |
+ |
} |
| 718 |
+ |
//if (!SIM_uses_AtomicVirial) { |
| 719 |
+ |
// tau -= outProduct(d_grp, fij); |
| 720 |
+ |
//} |
| 721 |
+ |
} |
| 722 |
+ |
} |
| 723 |
+ |
} |
| 724 |
+ |
|
| 725 |
+ |
if (iLoop == PREPAIR_LOOP) { |
| 726 |
+ |
if (info_->requiresPrepair()) { |
| 727 |
+ |
|
| 728 |
+ |
fDecomp_->collectIntermediateData(); |
| 729 |
+ |
|
| 730 |
+ |
for (int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) { |
| 731 |
+ |
fDecomp_->fillSelfData(sdat, atom1); |
| 732 |
+ |
interactionMan_->doPreForce(sdat); |
| 733 |
+ |
} |
| 734 |
+ |
|
| 735 |
+ |
fDecomp_->distributeIntermediateData(); |
| 736 |
+ |
|
| 737 |
+ |
} |
| 738 |
+ |
} |
| 739 |
+ |
|
| 740 |
+ |
} |
| 741 |
+ |
|
| 742 |
+ |
fDecomp_->collectData(); |
| 743 |
+ |
|
| 744 |
+ |
if (info_->requiresSelfCorrection()) { |
| 745 |
+ |
|
| 746 |
+ |
for (int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) { |
| 747 |
+ |
fDecomp_->fillSelfData(sdat, atom1); |
| 748 |
+ |
interactionMan_->doSelfCorrection(sdat); |
| 749 |
+ |
} |
| 750 |
+ |
|
| 751 |
+ |
} |
| 752 |
+ |
|
| 753 |
+ |
longRangePotential = *(fDecomp_->getEmbeddingPotential()) + |
| 754 |
+ |
*(fDecomp_->getPairwisePotential()); |
| 755 |
+ |
|
| 756 |
+ |
lrPot = longRangePotential.sum(); |
| 757 |
+ |
|
| 758 |
+ |
//store the tau and long range potential |
| 759 |
+ |
curSnapshot->statData[Stats::LONG_RANGE_POTENTIAL] = lrPot; |
| 760 |
+ |
curSnapshot->statData[Stats::VANDERWAALS_POTENTIAL] = longRangePotential[VANDERWAALS_FAMILY]; |
| 761 |
+ |
curSnapshot->statData[Stats::ELECTROSTATIC_POTENTIAL] = longRangePotential[ELECTROSTATIC_FAMILY]; |
| 762 |
+ |
} |
| 763 |
+ |
|
| 764 |
|
void ForceManager::longRangeInteractions() { |
| 765 |
|
|
| 766 |
|
Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); |
| 779 |
|
mol = info_->nextMolecule(mi)) { |
| 780 |
|
for(cg = mol->beginCutoffGroup(ci); cg != NULL; |
| 781 |
|
cg = mol->nextCutoffGroup(ci)) { |
| 782 |
+ |
cerr << "branch1\n"; |
| 783 |
+ |
cerr << "globind = " << cg->getGlobalIndex() << "\n"; |
| 784 |
|
cg->updateCOM(); |
| 785 |
|
} |
| 786 |
|
} |
| 787 |
|
} else { |
| 788 |
|
// center of mass of the group is the same as position of the atom |
| 789 |
|
// if cutoff group does not exist |
| 790 |
+ |
cerr << "branch2\n"; |
| 791 |
|
cgConfig->position = config->position; |
| 792 |
|
} |
| 793 |
|
|
| 836 |
|
|
| 837 |
|
if (iLoop == loopStart) { |
| 838 |
|
bool update_nlist = fDecomp_->checkNeighborList(); |
| 839 |
< |
if (update_nlist) |
| 839 |
> |
if (update_nlist) |
| 840 |
|
neighborList = fDecomp_->buildNeighborList(); |
| 841 |
+ |
|
| 842 |
|
} |
| 843 |
|
|
| 844 |
< |
for (vector<pair<int, int> >::iterator it = neighborList.begin(); |
| 845 |
< |
it != neighborList.end(); ++it) { |
| 846 |
< |
|
| 844 |
> |
for (vector<pair<int, int> >::iterator it = neighborList.begin(); |
| 845 |
> |
it != neighborList.end(); ++it) |
| 846 |
> |
{ |
| 847 |
|
cg1 = (*it).first; |
| 848 |
|
cg2 = (*it).second; |
| 849 |
|
|
| 875 |
|
for (vector<int>::iterator jb = atomListColumn.begin(); |
| 876 |
|
jb != atomListColumn.end(); ++jb) { |
| 877 |
|
atom2 = (*jb); |
| 878 |
< |
|
| 878 |
> |
|
| 879 |
|
if (!fDecomp_->skipAtomPair(atom1, atom2)) { |
| 880 |
|
vpair = 0.0; |
| 881 |
|
workPot = 0.0; |
| 890 |
|
if (atomListRow.size() == 1 && atomListColumn.size() == 1) { |
| 891 |
|
idat.d = &d_grp; |
| 892 |
|
idat.r2 = &rgrpsq; |
| 893 |
+ |
cerr << "dgrp = " << d_grp << "\n"; |
| 894 |
|
} else { |
| 895 |
|
d = fDecomp_->getInteratomicVector(atom1, atom2); |
| 896 |
|
curSnapshot->wrapVector( d ); |
| 897 |
|
r2 = d.lengthSquare(); |
| 898 |
+ |
cerr << "datm = " << d<< "\n"; |
| 899 |
|
idat.d = &d; |
| 900 |
|
idat.r2 = &r2; |
| 901 |
|
} |
| 902 |
|
|
| 903 |
+ |
cerr << "idat.d = " << *(idat.d) << "\n"; |
| 904 |
|
r = sqrt( *(idat.r2) ); |
| 905 |
|
idat.rij = &r; |
| 906 |
|
|
| 909 |
|
} else { |
| 910 |
|
interactionMan_->doPair(idat); |
| 911 |
|
fDecomp_->unpackInteractionData(idat, atom1, atom2); |
| 912 |
+ |
|
| 913 |
+ |
cerr << "d = " << *(idat.d) << "\tv=" << vpair << "\tf=" << f1 << "\n"; |
| 914 |
|
vij += vpair; |
| 915 |
|
fij += f1; |
| 916 |
|
tau -= outProduct( *(idat.d), f1); |