# | 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 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 944 | Line 945 | template<typename T> void ZConstraint<T>::doHarmonic() | |
945 | zconsMols[i]->getCOM(COM); | |
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 |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |