当前位置: 首页>>代码示例>>Python>>正文


Python Constants.invTimeFactor方法代码示例

本文整理汇总了Python中Constants.invTimeFactor方法的典型用法代码示例。如果您正苦于以下问题:Python Constants.invTimeFactor方法的具体用法?Python Constants.invTimeFactor怎么用?Python Constants.invTimeFactor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Constants的用法示例。


在下文中一共展示了Constants.invTimeFactor方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: impulse

# 需要导入模块: import Constants [as 别名]
# 或者: from Constants import invTimeFactor [as 别名]
def impulse(phys, forces, io, steps, cyclelength, fg, nextinteg, *args):
   """
   Verlet/r-RESPA propagation method.
   Implements the multiple-timestepping Verlet/r-RESPA method, also
   known as Impulse.  This propagator invokes an 'inner' propagator
   for a specific number of cycles per iteration, then computes its
   own forces.
   cf. H. Grubmuller, H. Heller, A. Windemuth and K. Schulten.
   Generalized Verlet Algorithm for Efficient Molecular Dyanmics
   Simulatiosn with Long-Range Interactions.  Molecular Simulation,
   vol. 6, pages 121-142, 1991.
   
   @type phys: Physical
   @param phys: The physical system.

   @type forces: Forces
   @param forces: MDL Forces object.

   @type io: IO
   @param io: MDL IO object.

   @type steps: int
   @param steps: Number of steps to run.

   @type cyclelength: float
   @param cyclelength: Number of iterations of inner method.

   @type fg: ForceField
   @param fg: MDL force field for evaluation.

   @type nextinteg: function handle
   @param nextinteg: Method handle for next propagator in the chain

   @type args: tuple
   @param args: Parameters for the next propagator in the chain

   """
   # Calculate initial forces
   step = 0
   # For all steps
   timestep = cyclelength*args[0]
   args2 = (args[0]*Constants.invTimeFactor(),)+args[1:len(args)]

   while (step < steps):
      # Update velocities by half a step
      phys.velocities += forces.force*0.5*timestep*phys.invmasses   # half kick
      # Run the next integrator in the chain, and store its results
      # in an array
      nextinteg(phys, forces, io, cyclelength/Constants.invTimeFactor(), *args2)
      # Calculate new forces
      fg.calculateForces(phys, forces)
      # Update velocities by another half step
      phys.velocities += forces.force*0.5*timestep*phys.invmasses   # half kick
      step = step + 1
开发者ID:badi,项目名称:protomol-mirror,代码行数:56,代码来源:impulse.py

示例2: timestep

# 需要导入模块: import Constants [as 别名]
# 或者: from Constants import invTimeFactor [as 别名]
    def timestep(self, integ):
        """
      Return the timestep of a propagator, scaled accordingly

      @type integ: object
      @param integ: MDL propagator object (STS or MTS)

      @rtype: float
      @return: The timestep (dt) of a propagator
      """
        return integ.getTimestep() * Constants.invTimeFactor()
开发者ID:badi,项目名称:protomol-mirror,代码行数:13,代码来源:Propagator.py

示例3: executePropagator

# 需要导入模块: import Constants [as 别名]
# 或者: from Constants import invTimeFactor [as 别名]
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 io: IO
      @param io: MDL IO 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

      #prop.myPropagator.run(numsteps)
      #return
      while (ii < numsteps):
              nextstop = int(numpy.minimum(numsteps, io.computeNext(ii, phys.remcom, phys.remang)))

              if (prop.isMDL(prop.myPropagator)):
                 while (ii < nextstop):
		    prop.myPropagator.run(phys, forces, prop)
		    ii += 1
                 phys.myTop.time = prop.myStep*prop.myPropagator.getTimestep()*Constants.invTimeFactor()
                 phys.updateCOM_Momenta()
              else:
                 prop.myPropagator.run(nextstop-ii)
                 ii = nextstop
              
	      
	      if (prop.myLevel == 0):
                 prop.myStep = nextstop
		 phys.myTop.time = prop.myStep*prop.myPropagator.getTimestep()
		 io.run(phys, forces, prop.myStep, prop.myTimestep, prop.myPropagator)
	      if (phys.remcom > 0 and ii % phys.remcom == 0):
                 TopologyUtilities.remLin(phys.velvec, phys.myTop)
              if (phys.remang > 0 and ii % phys.remang >= 0):
	         TopologyUtilities.remAng(phys.posvec, phys.velvec, phys.myTop)
      if (prop.isMDL(prop.myPropagator)):
           prop.runModifiers(prop.myPropagator.postrunmodifiers, phys, forces, prop, prop.myPropagator)
           prop.myPropagator.finish(phys, forces, prop)
开发者ID:badi,项目名称:protomol-mirror,代码行数:55,代码来源:PropagatorFactory.py

示例4: executePropagator

# 需要导入模块: import Constants [as 别名]
# 或者: from Constants import invTimeFactor [as 别名]
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)
开发者ID:badi,项目名称:protomol-mirror,代码行数:52,代码来源:PropagatorT.py

示例5: init

# 需要导入模块: import Constants [as 别名]
# 或者: from Constants import invTimeFactor [as 别名]
    def init(self, phys, forces, prop):
       """
       Set and initialize the propagator.
       
       @type phys: Physical
       @param phys: The physical system.
       
       @type forces: Forces
       @param forces: MDL Forces object

       @type prop: Propagator
       @param prop: MDL Propagator object
       """
       self.gamma = self.gamma*0.001/Constants.invTimeFactor()  #: Dissipative factor
       prop.calculateForces(forces)
开发者ID:badi,项目名称:protomol-mirror,代码行数:17,代码来源:BBKMDL.py

示例6: propagate

# 需要导入模块: import Constants [as 别名]
# 或者: from Constants import invTimeFactor [as 别名]

#.........这里部分代码省略.........

            if str(type(scheme))[7:11] != "list":
                chain += (params,)
            else:
                if params.has_key(outerscheme):
                    chain += (params[outerscheme],)
                else:
                    chain += ({},)
            for i in range(1, levels):
                if str(type(scheme))[7:11] == "list" and i < len(scheme):
                    chain += (scheme[i],)
                if str(type(cyclelength))[7:11] == "list" and i < len(cyclelength):
                    chain += (cyclelength[i],)
                else:
                    chain += (dt,)
                chain += (self.deepCopyForce(forcefield[i]),)
                if params.has_key(scheme[i]):
                    chain += (params[scheme[i]],)
                else:
                    chain += ({},)
        else:  # STS
            outertime = dt
            outerscheme = scheme
            outerforcefield = self.deepCopyForce(forcefield)
            chain += (params,)
        # Build force fields.
        # Tricky, because we could be dealing with
        # a single object or list.
        if (str(type(forcefield)))[7 : len(str(type(forcefield))) - 2] == "list":
            for ff in forcefield:
                if ff.dirty:
                    ff.build()
                if ff.gbsa:
                    self.phys.myTop.implicitSolvent = 2
                    self.phys.myTop.doGBSAOpenMM = 1
                    self.phys.build()
        else:
            if forcefield.dirty:
                forcefield.build()
            if forcefield.gbsa:
                self.phys.myTop.implicitSolvent = 2
                self.phys.myTop.doGBSAOpenMM = 1
                self.phys.build()
        if self.io.dirty:
            self.io.build()

        if propFactory.getType(outerscheme) == "method":
            # Calculate the forces, store them in force.
            if not hasattr(self.phys, "app"):
                self.phys.app = ProtoMolApp.ProtoMolApp()
                self.phys.app.makeApp(self.phys.myTop, self.phys.posvec, self.phys.velvec, self.forces.energies, dt)
            self.phys.updateCOM_Momenta()
            outerforcefield.calculateForces(self.phys, self.forces)
            self.io.run(self.phys, self.forces, 0, outertime)
            self.io.myProp = self
            for ii in range(1, steps + 1):
                self.phys.app.energies.clear()
                self.forces.energies.initialize(self.phys)
                propFactory.create(
                    1,
                    outerscheme,
                    self.phys,
                    self.forces,
                    self.io,
                    1,
                    outertime * Constants.invTimeFactor(),
                    outerforcefield,
                    *chain
                )
                self.phys.time = ii * outertime * Constants.invTimeFactor()
                self.io.run(self.phys, self.forces, ii, outertime)
                self.phys.updateCOM_Momenta()
                # self.phys.app.energies.clear()
                # self.forces.forcevec.zero()
        else:  # Object
            setPropagator(
                self,
                self.phys,
                self.forces,
                propFactory.applyModifiers(
                    propFactory.create(1, outerscheme, outertime, outerforcefield, *chain), outerscheme
                ),
            )
            shake = False
            if params.has_key("shake") and params["shake"] == "on":
                shake = True
                shakeMod = ModifierShake.ModifierShake(0.000001, 30)
                # shakeMod = self.myPropagator.createShakeModifier(0.000001, 30)
                self.myPropagator.adoptPostDriftOrNextModifier(shakeMod)
            rattle = False
            if params.has_key("rattle") and params["rattle"] == "on":
                rattle = True
                rattleMod = self.myPropagator.createRattleModifier(0.02, 30)
                self.myPropagator.adoptPostDriftOrNextModifier(rattleMod)
            executePropagator(self, self.phys, self.forces, self.io, steps)  # Runs the propagator for a number of steps
            if shake:
                self.myPropagator.removeModifier(shakeMod)
            if rattle:
                self.myPropagator.removeModifier(rattleMod)
        self.phys.updateCOM_Momenta()
开发者ID:badi,项目名称:protomol-mirror,代码行数:104,代码来源:Propagator.py

示例7: create

# 需要导入模块: import Constants [as 别名]
# 或者: from Constants import invTimeFactor [as 别名]
   def create(self, *args):
      """
      Accept a Python tuple containing the propagator name,
      timestep, parameter values and force field.
      This tuple can thus be various sizes depending on the number
      of parameters.
      Create and return a corresponding instantiated propagator object,
      or method handle.

      @type args: tuple
      @param args: List of propagator name, dt, parameter values and force field.  If the propagation scheme is MTS, this list is followed by the name of the next propagator in the chain and its associated parameters, etc.

      @rtype: STS, MTS, or Python method handle
      @return: The propagator.
      """
      if (not self.registry.has_key(args[0])):
         if (type(args[0]).__name__ == 'str'):
             print "[MDL] ERROR: UNRECOGNIZED PROPAGATOR: ",
             print args[0]
             return
         if (args.__len__() <= 2):
            print "[MDL] WARNING: USING LEAPFROG AS INNER PROPAGATOR"
            return self.create("Leapfrog", args[0], args[1])
         else:
            print "[MDL] WARNING: USING LEAPFROG AS INNER PROPAGATOR"
            return self.create("Leapfrog", args[0], args[1], args.__getslice__(2, args.__len__()))
      regprop = self.registry[args[0]]
      if (regprop['type'] == "protomol"):
         arglist = (args[1],)  # Timestep or cyclelength
         ii = 0
         while (ii < regprop['defaults'].__len__()):
            if (args[3].has_key(regprop['defaults'][ii])):
                arglist += (args[3][regprop['defaults'][ii]],)
            else:
                arglist += (regprop['defaults'][ii+1],)
            ii += 2                     
         arglist += (args[2],)
         if (args.__len__() > 4):
	    # Python referencing - we must save the object we create
	    # in a temporary array; otherwise when it loses scope it gets
	    # destroyed
            self.objects.append(apply(self.create, args.__getslice__(4, len(args))))
	    # Now append to the list
	    arglist += (self.objects[len(self.objects)-1],)
	 return apply(regprop['constructor'], arglist)
      elif (regprop['type'] == "object"):
         if (len(args) <= 4):
            self.objects.append(apply(regprop['constructor'], (args[1], args[2])))
	    self.objects[len(self.objects)-1].dt = args[1]*Constants.invTimeFactor()
         else:
            self.objects.append(apply(self.create, args.__getslice__(4, args.__len__())))
            self.objects.append(apply(regprop['constructor'], (args[1], args[2], self.objects[self.objects.__len__()-1])))
	    self.objects[len(self.objects)-1].cyclelength = args[1]
            self.objects[self.objects.__len__()-1].next = self.objects[self.objects.__len__()-2]
            if (hasattr(self.objects[self.objects.__len__()-1], "setMOLLYForceGroups")):
                self.objects[self.objects.__len__()-1].setMOLLYForceGroups()
         ii = 0
         while (ii < regprop['defaults'].__len__()):
            if (args[3].has_key(regprop['defaults'][ii])):
                setattr(self.objects[self.objects.__len__()-1], regprop['defaults'][ii], args[3][regprop['defaults'][ii]])
            else:
                setattr(self.objects[self.objects.__len__()-1], regprop['defaults'][ii], regprop['defaults'][ii+1])
            ii += 2
         self.objects[self.objects.__len__()-1].preinitmodifiers = list()
         self.objects[self.objects.__len__()-1].postinitmodifiers = list()
         self.objects[self.objects.__len__()-1].prerunmodifiers = list()
         self.objects[self.objects.__len__()-1].preforcemodifiers = list()
         self.objects[self.objects.__len__()-1].postforcemodifiers = list()
         self.objects[self.objects.__len__()-1].postrunmodifiers = list()
         return self.objects[self.objects.__len__()-1]
      elif (regprop['type'] == "method"):
         tup = (args[1], args[2], args[3], args[4], args[5], args[6])
         ii = 0
         while (ii < regprop['defaults'].__len__()):
             if (args[7].has_key(regprop['defaults'][ii])):
                 tup += (args[7][regprop['defaults'][ii]],)
             else:
                 tup += (regprop['defaults'][ii+1],)
             ii += 2

         ourtup = args
         i = 8;
         # LOOP WHILE THERE ARE MORE METHODS IN THE CHAIN
         while (len(ourtup) > i):
             tup += (self.registry[ourtup[i]]['constructor'],)  # NEXT METHOD
             ii = 0
             while (ii < self.registry[ourtup[i]]['defaults'].__len__()):
                 if (ourtup[i+3].has_key(self.registry[ourtup[8]]['defaults'][ii])):
                     tup += (ourtup[i+3][ii],)
                 else:
                     tup += (self.registry[ourtup[i]]['defaults'][ii+1],)
                 ii += 2
             tup += ourtup.__getslice__(i+1,i+3) # dt, ff
             ourtup = ourtup.__getslice__(i+4, len(ourtup))
             i = 4
         self.objects.append(apply(regprop['constructor'], tup))
         return self.objects[self.objects.__len__()-1]
开发者ID:badi,项目名称:protomol-mirror,代码行数:99,代码来源:PropagatorT.py


注:本文中的Constants.invTimeFactor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。