ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/brains/ForceManager.cpp
(Generate patch)

Comparing branches/development/src/brains/ForceManager.cpp (file contents):
Revision 1579 by gezelter, Thu Jun 9 20:26:29 2011 UTC vs.
Revision 1584 by gezelter, Fri Jun 17 20:16:35 2011 UTC

# Line 59 | Line 59
59   #include "nonbonded/NonBondedInteraction.hpp"
60   #include "parallel/ForceMatrixDecomposition.hpp"
61  
62 + #include <cstdio>
63 + #include <iostream>
64 + #include <iomanip>
65 +
66   using namespace std;
67   namespace OpenMD {
68    
# Line 123 | Line 127 | namespace OpenMD {
127          painCave.severity = OPENMD_INFO;
128          simError();
129        }
126      fDecomp_->setUserCutoff(rCut_);
130      }
131 +
132 +    fDecomp_->setUserCutoff(rCut_);
133 +    interactionMan_->setCutoffRadius(rCut_);
134  
135      map<string, CutoffMethod> stringToCutoffMethod;
136      stringToCutoffMethod["HARD"] = HARD;
# Line 258 | Line 264 | namespace OpenMD {
264      }
265      switcher_->setSwitchType(sft_);
266      switcher_->setSwitch(rSwitch_, rCut_);
267 +    interactionMan_->setSwitchingRadius(rSwitch_);
268    }
269    
270    void ForceManager::initialize() {
# Line 475 | Line 482 | namespace OpenMD {
482    }
483    
484    void ForceManager::longRangeInteractions() {
485 <    // some of this initial stuff will go away:
485 >
486      Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot();
487      DataStorage* config = &(curSnapshot->atomData);
488      DataStorage* cgConfig = &(curSnapshot->cgData);
482    RealType* frc = config->getArrayPointer(DataStorage::dslForce);
483    RealType* pos = config->getArrayPointer(DataStorage::dslPosition);
484    RealType* trq = config->getArrayPointer(DataStorage::dslTorque);
485    RealType* A = config->getArrayPointer(DataStorage::dslAmat);
486    RealType* electroFrame = config->getArrayPointer(DataStorage::dslElectroFrame);
487    RealType* particlePot = config->getArrayPointer(DataStorage::dslParticlePot);
489  
490 <    // new stuff starts here:
491 <    
490 >    //calculate the center of mass of cutoff group
491 >
492 >    SimInfo::MoleculeIterator mi;
493 >    Molecule* mol;
494 >    Molecule::CutoffGroupIterator ci;
495 >    CutoffGroup* cg;
496 >
497 >    if(info_->getNCutoffGroups() > 0){      
498 >      for (mol = info_->beginMolecule(mi); mol != NULL;
499 >           mol = info_->nextMolecule(mi)) {
500 >        for(cg = mol->beginCutoffGroup(ci); cg != NULL;
501 >            cg = mol->nextCutoffGroup(ci)) {
502 >          cg->updateCOM();
503 >        }
504 >      }      
505 >    } else {
506 >      // center of mass of the group is the same as position of the atom  
507 >      // if cutoff group does not exist
508 >      cgConfig->position = config->position;
509 >    }
510 >
511      fDecomp_->zeroWorkArrays();
512      fDecomp_->distributeData();
513      
# Line 496 | Line 516 | namespace OpenMD {
516      RealType rgrpsq, rgrp, r2, r;
517      RealType electroMult, vdwMult;
518      RealType vij;
519 <    Vector3d fij, fg;
519 >    Vector3d fij, fg, f1;
520      tuple3<RealType, RealType, RealType> cuts;
521      RealType rCutSq;
522      bool in_switching_region;
# Line 505 | Line 525 | namespace OpenMD {
525      InteractionData idat;
526      SelfData sdat;
527      RealType mf;
508    potVec pot(0.0);
509    potVec longRangePotential(0.0);
528      RealType lrPot;
529      RealType vpair;
530 +    potVec longRangePotential(0.0);
531 +    potVec workPot(0.0);
532  
533      int loopStart, loopEnd;
534  
535 +    idat.vdwMult = &vdwMult;
536 +    idat.electroMult = &electroMult;
537 +    idat.pot = &workPot;
538 +    sdat.pot = fDecomp_->getEmbeddingPotential();
539 +    idat.vpair = &vpair;
540 +    idat.f1 = &f1;
541 +    idat.sw = &sw;
542 +    idat.shiftedPot = (cutoffMethod_ == SHIFTED_POTENTIAL) ? true : false;
543 +    idat.shiftedForce = (cutoffMethod_ == SHIFTED_FORCE) ? true : false;
544 +    
545      loopEnd = PAIR_LOOP;
546      if (info_->requiresPrepair() ) {
547        loopStart = PREPAIR_LOOP;
548      } else {
549        loopStart = PAIR_LOOP;
550      }
551 <    
522 <
551 >  
552      for (int iLoop = loopStart; iLoop <= loopEnd; iLoop++) {
553      
554        if (iLoop == loopStart) {
# Line 551 | Line 580 | namespace OpenMD {
580            
581            in_switching_region = switcher_->getSwitch(rgrpsq, sw, dswdr,
582                                                       rgrp);
554
555          idat.sw = &sw;
583                
584            atomListRow = fDecomp_->getAtomsInGroupRow(cg1);
585            atomListColumn = fDecomp_->getAtomsInGroupColumn(cg2);
# Line 564 | Line 591 | namespace OpenMD {
591              for (vector<int>::iterator jb = atomListColumn.begin();
592                   jb != atomListColumn.end(); ++jb) {              
593                atom2 = (*jb);
594 <              
568 <              cerr << "doing atoms " << atom1 << " " << atom2 << "\n";
594 >            
595                if (!fDecomp_->skipAtomPair(atom1, atom2)) {
570                
596                  vpair = 0.0;
597 +                workPot = 0.0;
598 +                f1 = V3Zero;
599  
600 <                cerr << "filling idat atoms " << atom1 << " " << atom2 << "\n";
574 <                idat = fDecomp_->fillInteractionData(atom1, atom2);
575 <                cerr << "done with idat\n";
600 >                fDecomp_->fillInteractionData(idat, atom1, atom2);
601                  
602                  topoDist = fDecomp_->getTopologicalDistance(atom1, atom2);
603                  vdwMult = vdwScale_[topoDist];
604                  electroMult = electrostaticScale_[topoDist];
605  
581                idat.vdwMult = &vdwMult;
582                idat.electroMult = &electroMult;
583                idat.pot = &pot;
584                idat.vpair = &vpair;
585
606                  if (atomListRow.size() == 1 && atomListColumn.size() == 1) {
607                    idat.d = &d_grp;
608                    idat.r2 = &rgrpsq;
# Line 594 | Line 614 | namespace OpenMD {
614                    idat.r2 = &r2;
615                  }
616                  
617 <                cerr << "d = " << d << "\n";
598 <                cerr << "r2 = " << r2 << "\n";
599 <                r = sqrt( r2 );
617 >                r = sqrt( *(idat.r2) );
618                  idat.rij = &r;
619                
620                  if (iLoop == PREPAIR_LOOP) {
621                    interactionMan_->doPrePair(idat);
622                  } else {
605                  cerr << "doing doPair " << atom1 << " " << atom2 << " " << r << "\n";
623                    interactionMan_->doPair(idat);
624                    fDecomp_->unpackInteractionData(idat, atom1, atom2);
625 <                  vij += *(idat.vpair);
626 <                  fij += *(idat.f1);
627 <                  tau -= outProduct( *(idat.d), *(idat.f1));
625 >                  vij += vpair;
626 >                  fij += f1;
627 >                  tau -= outProduct( *(idat.d), f1);
628                  }
629                }
630              }
# Line 673 | Line 690 | namespace OpenMD {
690            fDecomp_->collectIntermediateData();
691  
692            for (int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) {
693 <            sdat = fDecomp_->fillSelfData(atom1);
693 >            fDecomp_->fillSelfData(sdat, atom1);
694              interactionMan_->doPreForce(sdat);
695            }
696 <
696 >          
697 >          
698            fDecomp_->distributeIntermediateData();        
699          }
700        }
# Line 695 | Line 713 | namespace OpenMD {
713               jb != skipList.end(); ++jb) {        
714      
715            atom2 = (*jb);
716 <          idat = fDecomp_->fillSkipData(atom1, atom2);
716 >          fDecomp_->fillSkipData(idat, atom1, atom2);
717            interactionMan_->doSkipCorrection(idat);
718 +          fDecomp_->unpackSkipData(idat, atom1, atom2);
719  
720          }
721        }
# Line 705 | Line 724 | namespace OpenMD {
724      if (info_->requiresSelfCorrection()) {
725  
726        for (int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) {          
727 <        sdat = fDecomp_->fillSelfData(atom1);
727 >        fDecomp_->fillSelfData(sdat, atom1);
728          interactionMan_->doSelfCorrection(sdat);
729        }
730  
731      }
732  
733 <    longRangePotential = fDecomp_->getLongRangePotential();
733 >    longRangePotential = *(fDecomp_->getEmbeddingPotential()) +
734 >      *(fDecomp_->getPairwisePotential());
735 >
736      lrPot = longRangePotential.sum();
737  
738      //store the tau and long range potential    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines