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 1710 by gezelter, Fri May 18 21:44:02 2012 UTC vs.
Revision 1733 by jmichalk, Tue Jun 5 17:48:40 2012 UTC

# Line 388 | Line 388 | namespace OpenMD {
388        setupCutoffs();
389  
390        info_->prepareTopology();      
391 +
392 +      doParticlePot_ = info_->getSimParams()->getOutputParticlePotential();
393 +      doHeatFlux_ = info_->getSimParams()->getPrintHeatFlux();
394 +      if (doHeatFlux_) doParticlePot_ = true;
395 +  
396      }
397  
398      ForceFieldOptions& fopts = forceField_->getForceFieldOptions();
# Line 468 | Line 473 | namespace OpenMD {
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() {
# Line 502 | Line 508 | namespace OpenMD {
508  
509        for (bond = mol->beginBond(bondIter); bond != NULL;
510             bond = mol->nextBond(bondIter)) {
511 <        bond->calcForce();
511 >        bond->calcForce(doParticlePot_);
512          bondPotential += bond->getPotential();
513        }
514  
# Line 510 | Line 516 | namespace OpenMD {
516             bend = mol->nextBend(bendIter)) {
517          
518          RealType angle;
519 <        bend->calcForce(angle);
519 >        bend->calcForce(angle, doParticlePot_);
520          RealType currBendPot = bend->getPotential();          
521          
522          bendPotential += bend->getPotential();
# Line 535 | Line 541 | namespace OpenMD {
541        for (torsion = mol->beginTorsion(torsionIter); torsion != NULL;
542             torsion = mol->nextTorsion(torsionIter)) {
543          RealType angle;
544 <        torsion->calcForce(angle);
544 >        torsion->calcForce(angle, doParticlePot_);
545          RealType currTorsionPot = torsion->getPotential();
546          torsionPotential += torsion->getPotential();
547          map<Torsion*, TorsionDataSet>::iterator i = torsionDataSets.find(torsion);
# Line 559 | Line 565 | namespace OpenMD {
565             inversion != NULL;
566             inversion = mol->nextInversion(inversionIter)) {
567          RealType angle;
568 <        inversion->calcForce(angle);
568 >        inversion->calcForce(angle, doParticlePot_);
569          RealType currInversionPot = inversion->getPotential();
570          inversionPotential += inversion->getPotential();
571          map<Inversion*, InversionDataSet>::iterator i = inversionDataSets.find(inversion);
# Line 592 | Line 598 | namespace OpenMD {
598    
599    void ForceManager::longRangeInteractions() {
600  
601 +
602      Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot();
603      DataStorage* config = &(curSnapshot->atomData);
604      DataStorage* cgConfig = &(curSnapshot->cgData);
# Line 615 | Line 622 | namespace OpenMD {
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;
# Line 636 | Line 644 | namespace OpenMD {
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;
652  
653      int loopStart, loopEnd;
654  
# Line 646 | Line 657 | namespace OpenMD {
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;
665      idat.shiftedForce = (cutoffMethod_ == SHIFTED_FORCE) ? true : false;
666 +    idat.doParticlePot = doParticlePot_;
667 +    sdat.doParticlePot = doParticlePot_;
668      
669      loopEnd = PAIR_LOOP;
670      if (info_->requiresPrepair() ) {
# Line 693 | Line 708 | namespace OpenMD {
708            atomListRow = fDecomp_->getAtomsInGroupRow(cg1);
709            atomListColumn = fDecomp_->getAtomsInGroupColumn(cg2);
710  
711 <          for (vector<int>::iterator ia = atomListRow.begin();
711 >          if (doHeatFlux_)
712 >            gvel2 = fDecomp_->getGroupVelocityColumn(cg2);
713 >        
714 >          for (ia = atomListRow.begin();
715                 ia != atomListRow.end(); ++ia) {            
716              atom1 = (*ia);
717              
718 <            for (vector<int>::iterator jb = atomListColumn.begin();
718 >            for (jb = atomListColumn.begin();
719                   jb != atomListColumn.end(); ++jb) {              
720                atom2 = (*jb);
721  
# Line 705 | Line 723 | namespace OpenMD {
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                  
# Line 715 | Line 735 | namespace OpenMD {
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) );
# Line 733 | Line 757 | namespace OpenMD {
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              }
# Line 746 | Line 772 | namespace OpenMD {
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 (vector<int>::iterator ia = atomListRow.begin();
781 >              for (ia = atomListRow.begin();
782                     ia != atomListRow.end(); ++ia) {            
783                  atom1 = (*ia);                
784                  mf = fDecomp_->getMassFactorRow(atom1);
# Line 762 | Line 791 | namespace OpenMD {
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                }
800 <              for (vector<int>::iterator jb = atomListColumn.begin();
800 >              for (jb = atomListColumn.begin();
801                     jb != atomListColumn.end(); ++jb) {              
802                  atom2 = (*jb);
803                  mf = fDecomp_->getMassFactorColumn(atom2);
# Line 780 | Line 811 | namespace OpenMD {
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          }
# Line 824 | Line 859 | namespace OpenMD {
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];
# Line 845 | Line 880 | namespace OpenMD {
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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines