| 58 | 
  | 
      else{ | 
| 59 | 
  | 
        sprintf( painCave.errMsg, | 
| 60 | 
  | 
                  "ZConstraint Warning: unknown force substraction policy, " | 
| 61 | 
< | 
                  "average force substraction policy is used\n"); | 
| 61 | 
> | 
                  "PolicyByMass is used\n"); | 
| 62 | 
  | 
        painCave.isFatal = 0; | 
| 63 | 
  | 
        simError();       | 
| 64 | 
+ | 
        forcePolicy = (ForceSubstractionPolicy*) new PolicyByMass(this); | 
| 65 | 
  | 
      }    | 
| 66 | 
  | 
    } | 
| 67 | 
  | 
  } | 
| 250 | 
  | 
          (*parameters)[i].zPos = COM[whichDirection]; | 
| 251 | 
  | 
 | 
| 252 | 
  | 
          sprintf( painCave.errMsg, | 
| 253 | 
< | 
                     "ZConstraint warningr: Does not specify zpos for z-constraint molecule " | 
| 253 | 
> | 
                     "ZConstraint warning: Does not specify zpos for z-constraint molecule " | 
| 254 | 
  | 
                     "initial z coornidate will be used \n"); | 
| 255 | 
  | 
           painCave.isFatal = 0; | 
| 256 | 
  | 
           simError();   | 
| 579 | 
  | 
  //do zconstraint force;  | 
| 580 | 
  | 
  if (haveFixedZMols()) | 
| 581 | 
  | 
    this->doZconstraintForce(); | 
| 582 | 
< | 
      | 
| 582 | 
> | 
 | 
| 583 | 
  | 
  //use harmonical poteintial to move the molecules to the specified positions | 
| 584 | 
  | 
  if (haveMovingZMols()) | 
| 585 | 
  | 
    this->doHarmonic(); | 
| 613 | 
  | 
#ifdef IS_MPI | 
| 614 | 
  | 
  } | 
| 615 | 
  | 
#endif | 
| 615 | 
– | 
 | 
| 616 | 
  | 
} | 
| 617 | 
  | 
 | 
| 618 | 
  | 
 | 
| 802 | 
  | 
  double COM[3]; | 
| 803 | 
  | 
  double force[3]; | 
| 804 | 
  | 
 | 
| 805 | 
– | 
 | 
| 806 | 
– | 
 | 
| 805 | 
  | 
  //constrain the molecules which do not reach the specified positions   | 
| 806 | 
  | 
     | 
| 807 | 
  | 
  //Zero Out the force of z-contrained molecules     | 
| 864 | 
  | 
 | 
| 865 | 
  | 
//   cout << "after zero out z-constraint force on fixed z-constraint molecuels " | 
| 866 | 
  | 
//        << "total force is " << calcTotalForce() << endl; | 
| 869 | 
– | 
 | 
| 870 | 
– | 
  //calculate the number of atoms of moving z-constrained molecules | 
| 871 | 
– | 
  int nMovingZAtoms_local; | 
| 872 | 
– | 
  int nMovingZAtoms; | 
| 873 | 
– | 
   | 
| 874 | 
– | 
  nMovingZAtoms_local = 0; | 
| 875 | 
– | 
  for(int i = 0; i < zconsMols.size(); i++) | 
| 876 | 
– | 
    if(states[i] == zcsMoving) | 
| 877 | 
– | 
     nMovingZAtoms_local += zconsMols[i]->getNAtoms(); | 
| 878 | 
– | 
   | 
| 879 | 
– | 
#ifdef IS_MPI | 
| 880 | 
– | 
  MPI_Allreduce(&nMovingZAtoms_local, &nMovingZAtoms, 1,  | 
| 881 | 
– | 
                      MPI_DOUBLE,MPI_SUM, MPI_COMM_WORLD); | 
| 882 | 
– | 
#else | 
| 883 | 
– | 
  nMovingZAtoms = nMovingZAtoms_local; | 
| 884 | 
– | 
#endif | 
| 867 | 
  | 
 | 
| 868 | 
  | 
  force[0]= 0; | 
| 869 | 
  | 
  force[1]= 0; |