64 |
|
|
65 |
|
ForceManager::ForceManager(SimInfo * info) : info_(info) { |
66 |
|
forceField_ = info_->getForceField(); |
67 |
– |
fDecomp_ = new ForceMatrixDecomposition(info_); |
67 |
|
interactionMan_ = new InteractionManager(); |
68 |
+ |
fDecomp_ = new ForceMatrixDecomposition(info_, interactionMan_); |
69 |
|
} |
70 |
|
|
71 |
|
/** |
122 |
|
painCave.isFatal = 0; |
123 |
|
painCave.severity = OPENMD_INFO; |
124 |
|
simError(); |
125 |
< |
} |
125 |
> |
} |
126 |
> |
fDecomp_->setUserCutoff(rCut_); |
127 |
|
} |
128 |
|
|
129 |
|
map<string, CutoffMethod> stringToCutoffMethod; |
196 |
|
simError(); |
197 |
|
cutoffPolicy_ = TRADITIONAL; |
198 |
|
} |
199 |
+ |
fDecomp_->setCutoffPolicy(cutoffPolicy_); |
200 |
|
} |
201 |
|
|
202 |
|
/** |
476 |
|
|
477 |
|
void ForceManager::longRangeInteractions() { |
478 |
|
|
477 |
– |
// some of this initial stuff will go away: |
479 |
|
Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); |
480 |
|
DataStorage* config = &(curSnapshot->atomData); |
481 |
|
DataStorage* cgConfig = &(curSnapshot->cgData); |
481 |
– |
RealType* frc = config->getArrayPointer(DataStorage::dslForce); |
482 |
– |
RealType* pos = config->getArrayPointer(DataStorage::dslPosition); |
483 |
– |
RealType* trq = config->getArrayPointer(DataStorage::dslTorque); |
484 |
– |
RealType* A = config->getArrayPointer(DataStorage::dslAmat); |
485 |
– |
RealType* electroFrame = config->getArrayPointer(DataStorage::dslElectroFrame); |
486 |
– |
RealType* particlePot = config->getArrayPointer(DataStorage::dslParticlePot); |
487 |
– |
RealType* rc; |
482 |
|
|
483 |
< |
if(info_->getNGlobalCutoffGroups() != info_->getNGlobalAtoms()){ |
484 |
< |
rc = cgConfig->getArrayPointer(DataStorage::dslPosition); |
483 |
> |
//calculate the center of mass of cutoff group |
484 |
> |
|
485 |
> |
SimInfo::MoleculeIterator mi; |
486 |
> |
Molecule* mol; |
487 |
> |
Molecule::CutoffGroupIterator ci; |
488 |
> |
CutoffGroup* cg; |
489 |
> |
|
490 |
> |
if(info_->getNCutoffGroups() > 0){ |
491 |
> |
for (mol = info_->beginMolecule(mi); mol != NULL; |
492 |
> |
mol = info_->nextMolecule(mi)) { |
493 |
> |
for(cg = mol->beginCutoffGroup(ci); cg != NULL; |
494 |
> |
cg = mol->nextCutoffGroup(ci)) { |
495 |
> |
cg->updateCOM(); |
496 |
> |
} |
497 |
> |
} |
498 |
|
} else { |
499 |
|
// center of mass of the group is the same as position of the atom |
500 |
|
// if cutoff group does not exist |
501 |
< |
rc = pos; |
501 |
> |
cgConfig->position = config->position; |
502 |
|
} |
503 |
< |
|
497 |
< |
// new stuff starts here: |
503 |
> |
|
504 |
|
fDecomp_->zeroWorkArrays(); |
505 |
|
fDecomp_->distributeData(); |
506 |
< |
|
507 |
< |
int cg1, cg2, atom1, atom2; |
508 |
< |
Vector3d d_grp, dag; |
509 |
< |
RealType rgrpsq, rgrp; |
506 |
> |
|
507 |
> |
int cg1, cg2, atom1, atom2, topoDist; |
508 |
> |
Vector3d d_grp, dag, d; |
509 |
> |
RealType rgrpsq, rgrp, r2, r; |
510 |
> |
RealType electroMult, vdwMult; |
511 |
|
RealType vij; |
512 |
< |
Vector3d fij, fg; |
512 |
> |
Vector3d fij, fg, f1; |
513 |
|
tuple3<RealType, RealType, RealType> cuts; |
514 |
|
RealType rCutSq; |
515 |
|
bool in_switching_region; |
521 |
|
potVec pot(0.0); |
522 |
|
potVec longRangePotential(0.0); |
523 |
|
RealType lrPot; |
524 |
+ |
RealType vpair; |
525 |
|
|
526 |
|
int loopStart, loopEnd; |
527 |
|
|
528 |
+ |
idat.vdwMult = &vdwMult; |
529 |
+ |
idat.electroMult = &electroMult; |
530 |
+ |
idat.pot = &pot; |
531 |
+ |
idat.vpair = &vpair; |
532 |
+ |
idat.f1 = &f1; |
533 |
+ |
idat.sw = &sw; |
534 |
+ |
|
535 |
|
loopEnd = PAIR_LOOP; |
536 |
|
if (info_->requiresPrepair() ) { |
537 |
|
loopStart = PREPAIR_LOOP; |
538 |
|
} else { |
539 |
|
loopStart = PAIR_LOOP; |
540 |
|
} |
541 |
< |
|
542 |
< |
for (int iLoop = loopStart; iLoop < loopEnd; iLoop++) { |
543 |
< |
|
541 |
> |
|
542 |
> |
for (int iLoop = loopStart; iLoop <= loopEnd; iLoop++) { |
543 |
> |
|
544 |
|
if (iLoop == loopStart) { |
545 |
|
bool update_nlist = fDecomp_->checkNeighborList(); |
546 |
|
if (update_nlist) |
547 |
|
neighborList = fDecomp_->buildNeighborList(); |
548 |
< |
} |
549 |
< |
|
548 |
> |
} |
549 |
> |
|
550 |
|
for (vector<pair<int, int> >::iterator it = neighborList.begin(); |
551 |
|
it != neighborList.end(); ++it) { |
552 |
< |
|
552 |
> |
|
553 |
|
cg1 = (*it).first; |
554 |
|
cg2 = (*it).second; |
555 |
|
|
562 |
|
rCutSq = cuts.second; |
563 |
|
|
564 |
|
if (rgrpsq < rCutSq) { |
565 |
< |
*(idat.rcut) = cuts.first; |
565 |
> |
idat.rcut = &cuts.first; |
566 |
|
if (iLoop == PAIR_LOOP) { |
567 |
|
vij *= 0.0; |
568 |
|
fij = V3Zero; |
569 |
|
} |
570 |
|
|
571 |
< |
in_switching_region = switcher_->getSwitch(rgrpsq, *(idat.sw), dswdr, |
571 |
> |
in_switching_region = switcher_->getSwitch(rgrpsq, sw, dswdr, |
572 |
|
rgrp); |
573 |
|
|
574 |
|
atomListRow = fDecomp_->getAtomsInGroupRow(cg1); |
584 |
|
|
585 |
|
if (!fDecomp_->skipAtomPair(atom1, atom2)) { |
586 |
|
|
587 |
< |
pot *= 0.0; |
587 |
> |
vpair = 0.0; |
588 |
> |
f1 = V3Zero; |
589 |
|
|
590 |
< |
idat = fDecomp_->fillInteractionData(atom1, atom2); |
591 |
< |
*(idat.pot) = pot; |
590 |
> |
fDecomp_->fillInteractionData(idat, atom1, atom2); |
591 |
> |
|
592 |
> |
topoDist = fDecomp_->getTopologicalDistance(atom1, atom2); |
593 |
> |
vdwMult = vdwScale_[topoDist]; |
594 |
> |
electroMult = electrostaticScale_[topoDist]; |
595 |
|
|
596 |
|
if (atomListRow.size() == 1 && atomListColumn.size() == 1) { |
597 |
< |
*(idat.d) = d_grp; |
598 |
< |
*(idat.r2) = rgrpsq; |
597 |
> |
idat.d = &d_grp; |
598 |
> |
idat.r2 = &rgrpsq; |
599 |
|
} else { |
600 |
< |
*(idat.d) = fDecomp_->getInteratomicVector(atom1, atom2); |
601 |
< |
curSnapshot->wrapVector( *(idat.d) ); |
602 |
< |
*(idat.r2) = idat.d->lengthSquare(); |
600 |
> |
d = fDecomp_->getInteratomicVector(atom1, atom2); |
601 |
> |
curSnapshot->wrapVector( d ); |
602 |
> |
r2 = d.lengthSquare(); |
603 |
> |
idat.d = &d; |
604 |
> |
idat.r2 = &r2; |
605 |
|
} |
606 |
|
|
607 |
< |
*(idat.rij) = sqrt( *(idat.r2) ); |
607 |
> |
r = sqrt( *(idat.r2) ); |
608 |
> |
idat.rij = &r; |
609 |
|
|
610 |
|
if (iLoop == PREPAIR_LOOP) { |
611 |
|
interactionMan_->doPrePair(idat); |
612 |
|
} else { |
613 |
|
interactionMan_->doPair(idat); |
614 |
|
fDecomp_->unpackInteractionData(idat, atom1, atom2); |
615 |
< |
vij += *(idat.vpair); |
616 |
< |
fij += *(idat.f1); |
617 |
< |
tau -= outProduct( *(idat.d), *(idat.f1)); |
615 |
> |
vij += vpair; |
616 |
> |
fij += f1; |
617 |
> |
tau -= outProduct( *(idat.d), f1); |
618 |
|
} |
619 |
|
} |
620 |
|
} |
680 |
|
fDecomp_->collectIntermediateData(); |
681 |
|
|
682 |
|
for (int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) { |
683 |
< |
sdat = fDecomp_->fillSelfData(atom1); |
683 |
> |
fDecomp_->fillSelfData(sdat, atom1); |
684 |
|
interactionMan_->doPreForce(sdat); |
685 |
|
} |
686 |
|
|
696 |
|
|
697 |
|
for (int atom1 = 0; atom1 < fDecomp_->getNAtomsInRow(); atom1++) { |
698 |
|
|
699 |
< |
vector<int> skipList = fDecomp_->getSkipsForRowAtom( atom1 ); |
699 |
> |
vector<int> skipList = fDecomp_->getSkipsForAtom( atom1 ); |
700 |
|
|
701 |
|
for (vector<int>::iterator jb = skipList.begin(); |
702 |
|
jb != skipList.end(); ++jb) { |
703 |
|
|
704 |
|
atom2 = (*jb); |
705 |
< |
idat = fDecomp_->fillSkipData(atom1, atom2); |
705 |
> |
fDecomp_->fillSkipData(idat, atom1, atom2); |
706 |
|
interactionMan_->doSkipCorrection(idat); |
707 |
|
|
708 |
|
} |
712 |
|
if (info_->requiresSelfCorrection()) { |
713 |
|
|
714 |
|
for (int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) { |
715 |
< |
sdat = fDecomp_->fillSelfData(atom1); |
715 |
> |
fDecomp_->fillSelfData(sdat, atom1); |
716 |
|
interactionMan_->doSelfCorrection(sdat); |
717 |
|
} |
718 |
|
|