ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/ZConstraint.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/ZConstraint.cpp (file contents):
Revision 711 by mmeineke, Fri Aug 22 20:04:39 2003 UTC vs.
Revision 726 by tim, Tue Aug 26 20:37:30 2003 UTC

# Line 32 | Line 32 | template<typename T> ZConstraint<T>::ZConstraint(SimIn
32    if(!data){
33      sprintf( painCave.errMsg,
34                 "ZConstraint Warning: User does not set force substraction policy, "
35 <               "average force substraction policy is used\n");
35 >               "PolicyByMass is used\n");
36      painCave.isFatal = 0;
37      simError();      
38  
39 <    forcePolicy = (ForceSubstractionPolicy*) new PolicyByNumber(this);
39 >    forcePolicy = (ForceSubstractionPolicy*) new PolicyByMass(this);
40    }
41    else{
42      policy = dynamic_cast<StringData*>(data);
# Line 44 | Line 44 | template<typename T> ZConstraint<T>::ZConstraint(SimIn
44      if(!policy){
45        sprintf( painCave.errMsg,
46                   "ZConstraint Error: Convertion from GenericData to StringData failure, "
47 <                 "average force substraction policy is used\n");
47 >                 "PolicyByMass is used\n");
48        painCave.isFatal = 0;
49        simError();      
50  
51 <      forcePolicy = (ForceSubstractionPolicy*) new PolicyByNumber(this);
51 >      forcePolicy = (ForceSubstractionPolicy*) new PolicyByMass(this);
52      }
53      else{
54        if(policy->getData() == "BYNUMBER")
# Line 276 | Line 276 | template<typename T> ZConstraint<T>::ZConstraint(SimIn
276        massOfZConsMols.push_back(molecules[i].getTotalMass());  
277  
278        zPos.push_back((*parameters)[searchResult].zPos);
279 <      cout << "index: "<< (*parameters)[searchResult].zconsIndex
280 <             <<"\tzPos = " << (*parameters)[searchResult].zPos << endl;
279 > //       cout << "index: "<< (*parameters)[searchResult].zconsIndex
280 > //              <<"\tzPos = " << (*parameters)[searchResult].zPos << endl;
281        kz.push_back((*parameters)[searchResult]. kRatio * zForceConst);
282        
283        molecules[i].getCOM(COM);
# Line 536 | Line 536 | template<typename T> void ZConstraint<T>::calcForce(in
536   #ifdef IS_MPI
537      if(worldRank == 0){
538   #endif
539 <      std::cerr << "\n"
540 <                << "*******************************************\n"
541 <                << " about to call zeroOutVel()\n"
542 <                << "*******************************************\n"
543 <                << "\n";
539 > //       std::cerr << "\n"
540 > //              << "*******************************************\n"
541 > //              << " about to call zeroOutVel()\n"
542 > //              << "*******************************************\n"
543 > //              << "\n";
544   #ifdef IS_MPI
545      }
546   #endif
# Line 549 | Line 549 | template<typename T> void ZConstraint<T>::calcForce(in
549   #ifdef IS_MPI
550      if(worldRank == 0){
551   #endif
552 <      std::cerr << "\n"
553 <                << "*******************************************\n"
554 <                << " finished zeroOutVel()\n"
555 <                << "*******************************************\n"
556 <                << "\n";
552 > //       std::cerr << "\n"
553 > //              << "*******************************************\n"
554 > //              << " finished zeroOutVel()\n"
555 > //              << "*******************************************\n"
556 > //              << "\n";
557   #ifdef IS_MPI
558      }
559   #endif
# Line 566 | Line 566 | template<typename T> void ZConstraint<T>::calcForce(in
566   #ifdef IS_MPI
567    if(worldRank == 0){
568   #endif
569 <    cout << "---------------------------------------------------------------------" <<endl;
570 <    cout << "current time: " << info->getTime() << endl;
571 <    cout << "center of mass at z: " << zsys << endl;    
572 <    cout << "before calcForce, the COMVel of system is " << zSysCOMVel <<endl;
569 > //     cout << "---------------------------------------------------------------------" <<endl;
570 > //     cout << "current time: " << info->getTime() << endl;
571 > //     cout << "center of mass at z: " << zsys << endl;    
572 > //     cout << "before calcForce, the COMVel of system is " << zSysCOMVel <<endl;
573  
574   #ifdef IS_MPI
575    }
# Line 608 | Line 608 | template<typename T> void ZConstraint<T>::calcForce(in
608   #ifdef IS_MPI
609    if(worldRank == 0){
610   #endif
611 <    cout << "after calcForce, the COMVel of system is " << zSysCOMVel <<endl;
611 > //    cout << "after calcForce, the COMVel of system is " << zSysCOMVel <<endl;
612   #ifdef IS_MPI
613    }
614   #endif
# Line 708 | Line 708 | template<typename T> void ZConstraint<T>::zeroOutVel()
708   #ifdef IS_MPI
709    if(worldRank == 0){
710   #endif
711 <    cout << "before resetting the COMVel of sytem is " << zSysCOMVel << endl;  
711 > //     cout << "before resetting the COMVel of sytem is " << zSysCOMVel << endl;  
712   #ifdef IS_MPI
713    }
714   #endif
# Line 782 | Line 782 | template<typename T> void ZConstraint<T>::zeroOutVel()
782   #ifdef IS_MPI
783    if(worldRank == 0){
784   #endif
785 <    cout << "after resetting the COMVel of moving molecules is " << zSysCOMVel << endl;  
785 > //     cout << "after resetting the COMVel of moving molecules is " << zSysCOMVel << endl;  
786   #ifdef IS_MPI
787    }
788   #endif
# Line 825 | Line 825 | template<typename T> void ZConstraint<T>::doZconstrain
825        }
826        totalFZ_local += fz[i];
827  
828 < //       cout << "Fixed Molecule\tindex: " << indexOfZConsMols[i]
829 < //              <<"\tcurrent zpos: " << COM[whichDirection]
830 < //              << "\tcurrent fz: " <<fz[i] << endl;
828 >      //cout << "Fixed Molecule\tindex: " << indexOfZConsMols[i]
829 >      //      <<"\tcurrent zpos: " << COM[whichDirection]
830 >      //       << "\tcurrent fz: " <<fz[i] << endl;
831  
832 +
833      }
834      
835    }
# Line 854 | Line 855 | template<typename T> void ZConstraint<T>::doZconstrain
855        zconsAtoms = zconsMols[i]->getMyAtoms();  
856      
857        for(int j =0; j < nAtomOfCurZConsMol; j++) {
858 <      force[whichDirection] = -fz[i]/ nAtomOfCurZConsMol;
859 <        //force[whichDirection] = - forcePolicy->getZFOfFixedZMols(zconsMols[i], zconsAtoms[j], fz[i]);
858 >        //force[whichDirection] = -fz[i]/ nAtomOfCurZConsMol;
859 >        force[whichDirection] = - forcePolicy->getZFOfFixedZMols(zconsMols[i], zconsAtoms[j], fz[i]);
860          zconsAtoms[j]->addFrc(force);
861        }
862      
# Line 892 | Line 893 | template<typename T> void ZConstraint<T>::doZconstrain
893       Atom** unconsAtoms = unconsMols[i]->getMyAtoms();
894      
895       for(int j = 0; j < unconsMols[i]->getNAtoms(); j++){          
896 <       force[whichDirection] = totalFZ / (totNumOfUnconsAtoms + nMovingZAtoms);
897 <       //force[whichDirection] = forcePolicy->getZFOfMovingMols(unconsAtoms[j],totalFZ);
896 >       //force[whichDirection] = totalFZ / (totNumOfUnconsAtoms + nMovingZAtoms);
897 >       force[whichDirection] = forcePolicy->getZFOfMovingMols(unconsAtoms[j],totalFZ);
898         unconsAtoms[j]->addFrc(force);
899       }
900      
# Line 906 | Line 907 | template<typename T> void ZConstraint<T>::doZconstrain
907        Atom** movingZAtoms = zconsMols[i]->getMyAtoms();    
908  
909        for(int j = 0; j < zconsMols[i]->getNAtoms(); j++){
910 <        force[whichDirection] = totalFZ / (totNumOfUnconsAtoms + nMovingZAtoms);
911 <        //force[whichDirection] = forcePolicy->getZFOfMovingMols(movingZAtoms[j],totalFZ);
910 >        //force[whichDirection] = totalFZ / (totNumOfUnconsAtoms + nMovingZAtoms);
911 >        force[whichDirection] = forcePolicy->getZFOfMovingMols(movingZAtoms[j],totalFZ);
912          movingZAtoms[j]->addFrc(force);
913        }
914      }
# Line 942 | Line 943 | template<typename T> void ZConstraint<T>::doHarmonic()
943  
944      if (states[i] == zcsMoving){
945        zconsMols[i]->getCOM(COM);
946 <      cout << "Moving Molecule\tindex: " << indexOfZConsMols[i]
947 <           << "\tcurrent zpos: " << COM[whichDirection] << endl;
946 > //       cout << "Moving Molecule\tindex: " << indexOfZConsMols[i]
947 > //         << "\tcurrent zpos: " << COM[whichDirection] << endl;
948 >
949 >      diff = COM[whichDirection] -zPos[i];
950      
948    diff = COM[whichDirection] -zPos[i];
949    
951        harmonicU = 0.5 * kz[i] * diff * diff;  
952 <    info->lrPot += harmonicU;
952 >      info->lrPot += harmonicU;
953  
954        harmonicF =  - kz[i] * diff;
955        totalFZ_local += harmonicF;
# Line 958 | Line 959 | template<typename T> void ZConstraint<T>::doHarmonic()
959        Atom** movingZAtoms = zconsMols[i]->getMyAtoms();    
960  
961         for(int j = 0; j < zconsMols[i]->getNAtoms(); j++){          
962 <        force[whichDirection] = harmonicF / zconsMols[i]->getNAtoms();
963 <         //force[whichDirection] = forcePolicy->getHFOfFixedZMols(zconsMols[i], movingZAtoms[j], harmonicF);
962 >        //force[whichDirection] = harmonicF / zconsMols[i]->getNAtoms();
963 >        force[whichDirection] = forcePolicy->getHFOfFixedZMols(zconsMols[i], movingZAtoms[j], harmonicF);
964           movingZAtoms[j]->addFrc(force);
965         }
966      }
# Line 982 | Line 983 | template<typename T> void ZConstraint<T>::doHarmonic()
983       Atom** unconsAtoms = unconsMols[i]->getMyAtoms();
984      
985       for(int j = 0; j < unconsMols[i]->getNAtoms(); j++){          
986 <       force[whichDirection] = - totalFZ /totNumOfUnconsAtoms;
987 <       //force[whichDirection] = - forcePolicy->getHFOfUnconsMols(unconsAtoms[j], totalFZ);
986 >       //force[whichDirection] = - totalFZ /totNumOfUnconsAtoms;
987 >       force[whichDirection] = - forcePolicy->getHFOfUnconsMols(unconsAtoms[j], totalFZ);
988         unconsAtoms[j]->addFrc(force);    
989       }
990    }  
# Line 1023 | Line 1024 | template<typename T> bool ZConstraint<T>::checkZConsSt
1024   #else
1025    MPI_Allreduce(&changed_local, &changed, 1, MPI_INT,MPI_SUM, MPI_COMM_WORLD);
1026   #endif
1027 <  
1027 >
1028    return (changed > 0);
1029 +
1030   }
1031  
1032   template<typename T> bool ZConstraint<T>::haveFixedZMols(){
# Line 1046 | Line 1048 | template<typename T> bool ZConstraint<T>::haveFixedZMo
1048    MPI_Allreduce(&havingFixed_local, &havingFixed, 1, MPI_INT,MPI_SUM, MPI_COMM_WORLD);
1049   #endif
1050  
1051 <  return havingFixed > 0 ? true : false;
1051 >  return (havingFixed > 0);
1052   }
1053  
1054  
# Line 1072 | Line 1074 | template<typename T> bool ZConstraint<T>::haveMovingZM
1074    MPI_Allreduce(&havingMoving_local, &havingMoving, 1, MPI_INT,MPI_SUM, MPI_COMM_WORLD);
1075   #endif
1076  
1077 <  return havingMoving > 0 ? true : false;
1077 >  return (havingMoving > 0);
1078    
1079   }
1080  
# Line 1207 | Line 1209 | template<typename T> void ZConstraint<T>::PolicyByNumb
1209   #ifdef IS_MPI
1210    if(worldRank == 0){
1211   #endif
1212 <    std::cerr << "\n"
1213 <              << "*******************************************\n"
1214 <              << " fiished Policy by numbr()\n"
1215 <              << "*******************************************\n"
1216 <              << "\n";
1212 > //    std::cerr << "\n"
1213 > //            << "*******************************************\n"
1214 > //            << " fiished Policy by numbr()\n"
1215 > //            << "*******************************************\n"
1216 > //            << "\n";
1217   #ifdef IS_MPI
1218    }
1219   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines