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() { |
598 |
|
|
599 |
|
void ForceManager::longRangeInteractions() { |
600 |
|
|
601 |
+ |
|
602 |
|
Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); |
603 |
|
DataStorage* config = &(curSnapshot->atomData); |
604 |
|
DataStorage* cgConfig = &(curSnapshot->cgData); |
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; |
644 |
|
RealType mf; |
645 |
|
RealType lrPot; |
646 |
|
RealType vpair; |
647 |
+ |
RealType dVdFQ1(0.0); |
648 |
+ |
RealType dVdFQ2(0.0); |
649 |
|
potVec longRangePotential(0.0); |
650 |
|
potVec workPot(0.0); |
651 |
|
vector<int>::iterator ia, jb; |
657 |
|
idat.pot = &workPot; |
658 |
|
sdat.pot = fDecomp_->getEmbeddingPotential(); |
659 |
|
idat.vpair = &vpair; |
660 |
+ |
idat.dVdFQ1 = &dVdFQ1; |
661 |
+ |
idat.dVdFQ2 = &dVdFQ2; |
662 |
|
idat.f1 = &f1; |
663 |
|
idat.sw = &sw; |
664 |
|
idat.shiftedPot = (cutoffMethod_ == SHIFTED_POTENTIAL) ? true : false; |
708 |
|
atomListRow = fDecomp_->getAtomsInGroupRow(cg1); |
709 |
|
atomListColumn = fDecomp_->getAtomsInGroupColumn(cg2); |
710 |
|
|
711 |
+ |
if (doHeatFlux_) |
712 |
+ |
gvel2 = fDecomp_->getGroupVelocityColumn(cg2); |
713 |
+ |
|
714 |
|
for (ia = atomListRow.begin(); |
715 |
|
ia != atomListRow.end(); ++ia) { |
716 |
|
atom1 = (*ia); |
723 |
|
vpair = 0.0; |
724 |
|
workPot = 0.0; |
725 |
|
f1 = V3Zero; |
726 |
+ |
dVdFQ1 = 0.0; |
727 |
+ |
dVdFQ2 = 0.0; |
728 |
|
|
729 |
|
fDecomp_->fillInteractionData(idat, atom1, atom2); |
730 |
|
|
735 |
|
if (atomListRow.size() == 1 && atomListColumn.size() == 1) { |
736 |
|
idat.d = &d_grp; |
737 |
|
idat.r2 = &rgrpsq; |
738 |
+ |
if (doHeatFlux_) |
739 |
+ |
vel2 = gvel2; |
740 |
|
} else { |
741 |
|
d = fDecomp_->getInteratomicVector(atom1, atom2); |
742 |
|
curSnapshot->wrapVector( d ); |
743 |
|
r2 = d.lengthSquare(); |
744 |
|
idat.d = &d; |
745 |
|
idat.r2 = &r2; |
746 |
+ |
if (doHeatFlux_) |
747 |
+ |
vel2 = fDecomp_->getAtomVelocityColumn(atom2); |
748 |
|
} |
749 |
|
|
750 |
|
r = sqrt( *(idat.r2) ); |
757 |
|
fDecomp_->unpackInteractionData(idat, atom1, atom2); |
758 |
|
vij += vpair; |
759 |
|
fij += f1; |
760 |
< |
tau -= outProduct( *(idat.d), f1); |
760 |
> |
stressTensor -= outProduct( *(idat.d), f1); |
761 |
> |
if (doHeatFlux_) |
762 |
> |
fDecomp_->addToHeatFlux(*(idat.d) * dot(f1, vel2)); |
763 |
|
} |
764 |
|
} |
765 |
|
} |
772 |
|
fij += fg; |
773 |
|
|
774 |
|
if (atomListRow.size() == 1 && atomListColumn.size() == 1) { |
775 |
< |
tau -= outProduct( *(idat.d), fg); |
775 |
> |
stressTensor -= outProduct( *(idat.d), fg); |
776 |
> |
if (doHeatFlux_) |
777 |
> |
fDecomp_->addToHeatFlux(*(idat.d) * dot(fg, vel2)); |
778 |
> |
|
779 |
|
} |
780 |
|
|
781 |
|
for (ia = atomListRow.begin(); |
791 |
|
// find the distance between the atom |
792 |
|
// and the center of the cutoff group: |
793 |
|
dag = fDecomp_->getAtomToGroupVectorRow(atom1, cg1); |
794 |
< |
tau -= outProduct(dag, fg); |
794 |
> |
stressTensor -= outProduct(dag, fg); |
795 |
> |
if (doHeatFlux_) |
796 |
> |
fDecomp_->addToHeatFlux( dag * dot(fg, vel2)); |
797 |
|
} |
798 |
|
} |
799 |
|
} |
811 |
|
// find the distance between the atom |
812 |
|
// and the center of the cutoff group: |
813 |
|
dag = fDecomp_->getAtomToGroupVectorColumn(atom2, cg2); |
814 |
< |
tau -= outProduct(dag, fg); |
814 |
> |
stressTensor -= outProduct(dag, fg); |
815 |
> |
if (doHeatFlux_) |
816 |
> |
fDecomp_->addToHeatFlux( dag * dot(fg, vel2)); |
817 |
|
} |
818 |
|
} |
819 |
|
} |
820 |
|
} |
821 |
|
//if (!info_->usesAtomicVirial()) { |
822 |
< |
// tau -= outProduct(d_grp, fij); |
822 |
> |
// stressTensor -= outProduct(d_grp, fij); |
823 |
> |
// if (doHeatFlux_) |
824 |
> |
// fDecomp_->addToHeatFlux( d_grp * dot(fij, vel2)); |
825 |
|
//} |
826 |
|
} |
827 |
|
} |
859 |
|
|
860 |
|
lrPot = longRangePotential.sum(); |
861 |
|
|
862 |
< |
//store the tau and long range potential |
862 |
> |
//store the stressTensor and long range potential |
863 |
|
curSnapshot->statData[Stats::LONG_RANGE_POTENTIAL] = lrPot; |
864 |
|
curSnapshot->statData[Stats::VANDERWAALS_POTENTIAL] = longRangePotential[VANDERWAALS_FAMILY]; |
865 |
|
curSnapshot->statData[Stats::ELECTROSTATIC_POTENTIAL] = longRangePotential[ELECTROSTATIC_FAMILY]; |
880 |
|
for (rb = mol->beginRigidBody(rbIter); rb != NULL; |
881 |
|
rb = mol->nextRigidBody(rbIter)) { |
882 |
|
Mat3x3d rbTau = rb->calcForcesAndTorquesAndVirial(); |
883 |
< |
tau += rbTau; |
883 |
> |
stressTensor += rbTau; |
884 |
|
} |
885 |
|
} |
886 |
|
|
887 |
|
#ifdef IS_MPI |
888 |
< |
Mat3x3d tmpTau(tau); |
889 |
< |
MPI_Allreduce(tmpTau.getArrayPointer(), tau.getArrayPointer(), |
890 |
< |
9, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); |
888 |
> |
|
889 |
> |
MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, stressTensor.getArrayPointer(), 9, |
890 |
> |
MPI::REALTYPE, MPI::SUM); |
891 |
|
#endif |
892 |
< |
curSnapshot->setTau(tau); |
892 |
> |
curSnapshot->setStressTensor(stressTensor); |
893 |
> |
|
894 |
|
} |
895 |
|
|
896 |
|
} //end namespace OpenMD |