def executePropagator(prop, phys, forces, io, numsteps):
    """
      Run and finish the propagator.
      
      @type prop: Propagator
      @param prop: MDL Propagator object
      
      @type phys: Physical
      @param phys: The physical system.
      
      @type forces: Forces
      @param forces: MDL Forces object
      
      @type numsteps: int
      @param numsteps: Number of steps to run
      """
    # RUN

    if (prop.myStep == 0 and prop.myLevel == 0):
        io.run(phys, forces, prop.myStep, prop.myTimestep, prop.myPropagator)
    if (prop.isMDL(prop.myPropagator)):
        prop.runModifiers(prop.myPropagator.prerunmodifiers, phys, forces,
                          prop, prop.myPropagator)
    ii = 0

    while (ii < numsteps):
        if (io.pmvMODE == 0):  # STOP CODE
            return
        elif (io.pmvMODE != 2):  # RUN CODE
            if (prop.isMDL(prop.myPropagator)):
                prop.myPropagator.run(phys, forces, prop)
                phys.myTop.time = prop.myStep * prop.myPropagator.getTimestep(
                ) * Constants.invTimeFactor()
                phys.updateCOM_Momenta()
            else:
                prop.myPropagator.run(1)
            if (io.doPmv):
                io.pmvPlot()
            ii = ii + 1
            if (prop.myLevel == 0):
                prop.myStep += 1
                phys.myTop.time = prop.myStep * prop.myPropagator.getTimestep()
                io.run(phys, forces, prop.myStep, prop.myTimestep,
                       prop.myPropagator)
            if (phys.remcom >= 0):
                TopologyUtilities.removeLinearMomentum(phys.velvec,
                                                       phys.myTop).disown()
            if (phys.remang >= 0):
                TopologyUtilities.removeAngularMomentum(
                    phys.posvec, phys.velvec, phys.myTop).disown()
        else:  # PAUSE CODE
            io.pmvPlot()
    if (prop.isMDL(prop.myPropagator)):
        prop.runModifiers(prop.myPropagator.postrunmodifiers, phys, forces,
                          prop, prop.myPropagator)
        prop.myPropagator.finish(phys, forces, prop)
Exemple #2
0
def executePropagator(prop, phys, forces, io, numsteps):
      """
      Run and finish the propagator.
      
      @type prop: Propagator
      @param prop: MDL Propagator object
      
      @type phys: Physical
      @param phys: The physical system.
      
      @type forces: Forces
      @param forces: MDL Forces object
      
      @type numsteps: int
      @param numsteps: Number of steps to run
      """
      # RUN

      if (prop.myStep == 0 and prop.myLevel == 0):
           io.run(phys, forces, prop.myStep, prop.myTimestep, prop.myPropagator)
      if (prop.isMDL(prop.myPropagator)):
           prop.runModifiers(prop.myPropagator.prerunmodifiers, phys, forces, prop, prop.myPropagator)
      ii = 0

      while (ii < numsteps):
           if (io.pmvMODE == 0): # STOP CODE
               return
           elif (io.pmvMODE != 2):  # RUN CODE
              if (prop.isMDL(prop.myPropagator)):
                 prop.myPropagator.run(phys, forces, prop)
                 phys.myTop.time = prop.myStep*prop.myPropagator.getTimestep()*Constants.invTimeFactor()
		 phys.updateCOM_Momenta()		 
              else:
                 prop.myPropagator.run(1)
	      if (io.doPmv):
                 io.pmvPlot()
              ii = ii + 1
              if (prop.myLevel == 0):
                 prop.myStep += 1
		 phys.myTop.time = prop.myStep*prop.myPropagator.getTimestep()
		 io.run(phys, forces, prop.myStep, prop.myTimestep, prop.myPropagator)
	      if (phys.remcom >= 0):
                 TopologyUtilities.removeLinearMomentum(phys.velvec, phys.myTop).disown()
              if (phys.remang >= 0):
	         TopologyUtilities.removeAngularMomentum(phys.posvec, phys.velvec, phys.myTop).disown()
           else: # PAUSE CODE
              io.pmvPlot()
      if (prop.isMDL(prop.myPropagator)):
           prop.runModifiers(prop.myPropagator.postrunmodifiers, phys, forces, prop, prop.myPropagator)
           prop.myPropagator.finish(phys, forces, prop)
Exemple #3
0
   def build(self):
      """
      Build the physical data.
      """
      tm = -1
      if (hasattr(self, "myTop")):
          tm = self.myTop.time
      if (self.bc == "Periodic"):
          if (self.defaultCBV):
             # TEMPORARY STRUCTURES USED TO COMPUTE
             # BOUNDING BOX
             v1 = numpy.ndarray(3)
             v2 = numpy.ndarray(3)
             v3 = numpy.ndarray(3)
             v4 = numpy.ndarray(3)
             v1.fill(sys.maxint)
             v2.fill(-sys.maxint)
             # BOUNDING BOX
             i = 0
             while (i < numpy.size(self.positions)):
                if (self.positions[i] < v1[0]):
                   v1[0] = float(self.positions[i])
                if (self.positions[i] > v2[0]):
                   v2[0] = float(self.positions[i])
                if (self.positions[i+1] < v1[1]):
                   v1[1] = float(self.positions[i+1])
                if (self.positions[i+1] > v2[1]):
                   v2[1] = float(self.positions[i+1])
                if (self.positions[i+2] < v1[2]):
                   v1[2] = float(self.positions[i+2])
                if (self.positions[i+2] > v2[2]):
                   v2[2] = float(self.positions[i+2])
                i += 3
             v4.fill(Constants.periodicBoundaryTolerance()/2.0)
             v1 = v1 - v4
             v2 = v2 + v4
             v3 = v2 - v1
             self.cB1[0] = v3[0]
             self.cB2[1] = v3[1]
             self.cB3[2] = v3[2]
             self.cO = v1 + v3 * 0.5
             self.myTop.setBC(self.cB1[0],self.cB1[1],self.cB1[2],self.cB2[0],self.cB2[1],self.cB2[2],self.cB3[0],self.cB3[1],self.cB3[2],self.cO[0],self.cO[1],self.cO[2])
      self.myTop.setExclusion(self.exclude)
      if (self.myPSF.numAtoms() > 0 and hasattr(self.myPAR, 'readFlag')):
	 GenericTopology.buildTopology(self.myTop, self.myPSF, self.myPAR, 0, self.myTop.makeSCPISM())
	 if (numpy.size(self.velocities) == 0):
            # This function actually returns a value, since it is
            # unused the runtime environment detects a memory leak.
            # disown() removes this concern.
            MathUtilities.randomNumber(self.seed)
            # NOTE TO SELF: THIS WAS COMMENTED OUT FOR PM 3
            # IT MAY EFFECT RANDOM NUMBER CONSISTENCY
            #aaa = MathUtilities.randomNumberFirst(self.seed, 1)
	    TopologyUtilities.randomVelocity(self.temperature, self.myTop, self.velvec, self.seed)
	 if (self.remcom >= 0):
	   TopologyUtilities.removeLinearMomentum(self.velvec, self.myTop).disown()
         if (self.remang >= 0):
	   TopologyUtilities.removeAngularMomentum(self.posvec, self.velvec, self.myTop).disown()
      if (self.bc == "Periodic"):
           self.myTop.setCellSize(self.cellsize)
      # COMPUTE INV MASS MATRIX
      temp = list()
      ii = 0
      while ii < self.numAtoms()*3:
          temp.append(0.0)
          ii += 1
      ii = 0
      self.invmasses.resize(self.numAtoms()*3)
      while ii < self.numAtoms()*3:
          im = 1.0 / self.myPSF.getMass(ii/3)
          self.invmasses[ii] = im
          self.invmasses[ii+1] = im
          self.invmasses[ii+2] = im
          ii += 3

      # COMPUTE MASS MATRIX
      temp = list()
      ii = 0
      while ii < self.numAtoms()*3:
          temp.append(0.0)
          ii += 1
      ii = 0
      self.masses.resize(self.numAtoms()*3)
      while ii < self.numAtoms()*3:
          m = self.myPSF.getMass(ii/3)
          temp[ii] = m
          self.masses[ii] = temp[ii]
          temp[ii] = 0.0
          temp[ii+1] = m
          self.masses[ii+1] = temp[ii+1]
          temp[ii+1] = 0.0
          temp[ii+2] = m
          self.masses[ii+2] = temp[ii+2]
          temp[ii+2] = 0.0
          ii += 3


      # COMPUTE MASS SUM
      self.masssum = 0
      ii = 0
      while ii < self.numAtoms():
         self.masssum += self.myPSF.getMass(ii)
         ii += 1

      # SET SELFICAL TIME
      if (tm != -1):
          self.myTop.time = tm

      self.dirty = 0  # clean now!