| 390 |
|
info_->prepareTopology(); |
| 391 |
|
|
| 392 |
|
doParticlePot_ = info_->getSimParams()->getOutputParticlePotential(); |
| 393 |
+ |
doHeatFlux_ = info_->getSimParams()->getPrintHeatFlux(); |
| 394 |
+ |
if (doHeatFlux_) doParticlePot_ = true; |
| 395 |
|
|
| 396 |
|
} |
| 397 |
|
|
| 473 |
|
} |
| 474 |
|
|
| 475 |
|
// Zero out the stress tensor |
| 476 |
< |
tau *= 0.0; |
| 477 |
< |
|
| 476 |
> |
stressTensor *= 0.0; |
| 477 |
> |
// Zero out the heatFlux |
| 478 |
> |
fDecomp_->setHeatFlux( V3Zero ); |
| 479 |
|
} |
| 480 |
|
|
| 481 |
|
void ForceManager::shortRangeInteractions() { |
| 597 |
|
} |
| 598 |
|
|
| 599 |
|
void ForceManager::longRangeInteractions() { |
| 600 |
+ |
|
| 601 |
|
|
| 602 |
|
Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); |
| 603 |
|
DataStorage* config = &(curSnapshot->atomData); |
| 622 |
|
// center of mass of the group is the same as position of the atom |
| 623 |
|
// if cutoff group does not exist |
| 624 |
|
cgConfig->position = config->position; |
| 625 |
+ |
cgConfig->velocity = config->velocity; |
| 626 |
|
} |
| 627 |
|
|
| 628 |
|
fDecomp_->zeroWorkArrays(); |
| 629 |
|
fDecomp_->distributeData(); |
| 630 |
|
|
| 631 |
|
int cg1, cg2, atom1, atom2, topoDist; |
| 632 |
< |
Vector3d d_grp, dag, d; |
| 632 |
> |
Vector3d d_grp, dag, d, gvel2, vel2; |
| 633 |
|
RealType rgrpsq, rgrp, r2, r; |
| 634 |
|
RealType electroMult, vdwMult; |
| 635 |
|
RealType vij; |
| 646 |
|
RealType vpair; |
| 647 |
|
potVec longRangePotential(0.0); |
| 648 |
|
potVec workPot(0.0); |
| 649 |
+ |
vector<int>::iterator ia, jb; |
| 650 |
|
|
| 651 |
|
int loopStart, loopEnd; |
| 652 |
|
|
| 704 |
|
atomListRow = fDecomp_->getAtomsInGroupRow(cg1); |
| 705 |
|
atomListColumn = fDecomp_->getAtomsInGroupColumn(cg2); |
| 706 |
|
|
| 707 |
< |
for (vector<int>::iterator ia = atomListRow.begin(); |
| 707 |
> |
if (doHeatFlux_) |
| 708 |
> |
gvel2 = fDecomp_->getGroupVelocityColumn(cg2); |
| 709 |
> |
|
| 710 |
> |
for (ia = atomListRow.begin(); |
| 711 |
|
ia != atomListRow.end(); ++ia) { |
| 712 |
|
atom1 = (*ia); |
| 713 |
|
|
| 714 |
< |
for (vector<int>::iterator jb = atomListColumn.begin(); |
| 714 |
> |
for (jb = atomListColumn.begin(); |
| 715 |
|
jb != atomListColumn.end(); ++jb) { |
| 716 |
|
atom2 = (*jb); |
| 717 |
|
|
| 729 |
|
if (atomListRow.size() == 1 && atomListColumn.size() == 1) { |
| 730 |
|
idat.d = &d_grp; |
| 731 |
|
idat.r2 = &rgrpsq; |
| 732 |
+ |
if (doHeatFlux_) |
| 733 |
+ |
vel2 = gvel2; |
| 734 |
|
} else { |
| 735 |
|
d = fDecomp_->getInteratomicVector(atom1, atom2); |
| 736 |
|
curSnapshot->wrapVector( d ); |
| 737 |
|
r2 = d.lengthSquare(); |
| 738 |
|
idat.d = &d; |
| 739 |
|
idat.r2 = &r2; |
| 740 |
+ |
if (doHeatFlux_) |
| 741 |
+ |
vel2 = fDecomp_->getAtomVelocityColumn(atom2); |
| 742 |
|
} |
| 743 |
|
|
| 744 |
|
r = sqrt( *(idat.r2) ); |
| 751 |
|
fDecomp_->unpackInteractionData(idat, atom1, atom2); |
| 752 |
|
vij += vpair; |
| 753 |
|
fij += f1; |
| 754 |
< |
tau -= outProduct( *(idat.d), f1); |
| 754 |
> |
stressTensor -= outProduct( *(idat.d), f1); |
| 755 |
> |
if (doHeatFlux_) |
| 756 |
> |
fDecomp_->addToHeatFlux(*(idat.d) * dot(f1, vel2)); |
| 757 |
|
} |
| 758 |
|
} |
| 759 |
|
} |
| 766 |
|
fij += fg; |
| 767 |
|
|
| 768 |
|
if (atomListRow.size() == 1 && atomListColumn.size() == 1) { |
| 769 |
< |
tau -= outProduct( *(idat.d), fg); |
| 769 |
> |
stressTensor -= outProduct( *(idat.d), fg); |
| 770 |
> |
if (doHeatFlux_) |
| 771 |
> |
fDecomp_->addToHeatFlux(*(idat.d) * dot(fg, vel2)); |
| 772 |
> |
|
| 773 |
|
} |
| 774 |
|
|
| 775 |
< |
for (vector<int>::iterator ia = atomListRow.begin(); |
| 775 |
> |
for (ia = atomListRow.begin(); |
| 776 |
|
ia != atomListRow.end(); ++ia) { |
| 777 |
|
atom1 = (*ia); |
| 778 |
|
mf = fDecomp_->getMassFactorRow(atom1); |
| 785 |
|
// find the distance between the atom |
| 786 |
|
// and the center of the cutoff group: |
| 787 |
|
dag = fDecomp_->getAtomToGroupVectorRow(atom1, cg1); |
| 788 |
< |
tau -= outProduct(dag, fg); |
| 788 |
> |
stressTensor -= outProduct(dag, fg); |
| 789 |
> |
if (doHeatFlux_) |
| 790 |
> |
fDecomp_->addToHeatFlux( dag * dot(fg, vel2)); |
| 791 |
|
} |
| 792 |
|
} |
| 793 |
|
} |
| 794 |
< |
for (vector<int>::iterator jb = atomListColumn.begin(); |
| 794 |
> |
for (jb = atomListColumn.begin(); |
| 795 |
|
jb != atomListColumn.end(); ++jb) { |
| 796 |
|
atom2 = (*jb); |
| 797 |
|
mf = fDecomp_->getMassFactorColumn(atom2); |
| 805 |
|
// find the distance between the atom |
| 806 |
|
// and the center of the cutoff group: |
| 807 |
|
dag = fDecomp_->getAtomToGroupVectorColumn(atom2, cg2); |
| 808 |
< |
tau -= outProduct(dag, fg); |
| 808 |
> |
stressTensor -= outProduct(dag, fg); |
| 809 |
> |
if (doHeatFlux_) |
| 810 |
> |
fDecomp_->addToHeatFlux( dag * dot(fg, vel2)); |
| 811 |
|
} |
| 812 |
|
} |
| 813 |
|
} |
| 814 |
|
} |
| 815 |
|
//if (!info_->usesAtomicVirial()) { |
| 816 |
< |
// tau -= outProduct(d_grp, fij); |
| 816 |
> |
// stressTensor -= outProduct(d_grp, fij); |
| 817 |
> |
// if (doHeatFlux_) |
| 818 |
> |
// fDecomp_->addToHeatFlux( d_grp * dot(fij, vel2)); |
| 819 |
|
//} |
| 820 |
|
} |
| 821 |
|
} |
| 853 |
|
|
| 854 |
|
lrPot = longRangePotential.sum(); |
| 855 |
|
|
| 856 |
< |
//store the tau and long range potential |
| 856 |
> |
//store the stressTensor and long range potential |
| 857 |
|
curSnapshot->statData[Stats::LONG_RANGE_POTENTIAL] = lrPot; |
| 858 |
|
curSnapshot->statData[Stats::VANDERWAALS_POTENTIAL] = longRangePotential[VANDERWAALS_FAMILY]; |
| 859 |
|
curSnapshot->statData[Stats::ELECTROSTATIC_POTENTIAL] = longRangePotential[ELECTROSTATIC_FAMILY]; |
| 874 |
|
for (rb = mol->beginRigidBody(rbIter); rb != NULL; |
| 875 |
|
rb = mol->nextRigidBody(rbIter)) { |
| 876 |
|
Mat3x3d rbTau = rb->calcForcesAndTorquesAndVirial(); |
| 877 |
< |
tau += rbTau; |
| 877 |
> |
stressTensor += rbTau; |
| 878 |
|
} |
| 879 |
|
} |
| 880 |
|
|
| 881 |
|
#ifdef IS_MPI |
| 882 |
< |
Mat3x3d tmpTau(tau); |
| 883 |
< |
MPI_Allreduce(tmpTau.getArrayPointer(), tau.getArrayPointer(), |
| 884 |
< |
9, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); |
| 882 |
> |
|
| 883 |
> |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, stressTensor.getArrayPointer(), 9, |
| 884 |
> |
MPI::REALTYPE, MPI::SUM); |
| 885 |
|
#endif |
| 886 |
< |
curSnapshot->setTau(tau); |
| 886 |
> |
curSnapshot->setStressTensor(stressTensor); |
| 887 |
> |
|
| 888 |
|
} |
| 889 |
|
|
| 890 |
|
} //end namespace OpenMD |