Beispiel #1
0
 def __init__(self, dt, group, alphaGroup, EGroup):
     """Create a AMDForceGroupIntegrator.
     
     Parameters:
      - dt (time) The integration time step to use
      - group (int) The force group to apply the boost to
      - alphaGroup (energy) The alpha parameter to use for the boosted force group
      - EGroup (energy) The energy cutoff to use for the boosted force group
     """
     CustomIntegrator.__init__(self, dt)
     self.addGlobalVariable("alphaGroup", alphaGroup)
     self.addGlobalVariable("EGroup", EGroup)
     self.addGlobalVariable("groupEnergy", 0)
     self.addPerDofVariable("oldx", 0)
     self.addPerDofVariable("fg", 0)
     self.addUpdateContextState()
     self.addComputeGlobal("groupEnergy", "energy" + str(group))
     self.addComputePerDof("fg", "f" + str(group))
     self.addComputePerDof(
         "v",
         "v+dt*fprime/m; fprime=fother + fg*((1-modify) + modify*(alphaGroup/(alphaGroup+EGroup-groupEnergy))^2); fother=f-fg; modify=step(EGroup-groupEnergy)"
     )
     self.addComputePerDof("oldx", "x")
     self.addComputePerDof("x", "x+dt*v")
     self.addConstrainPositions()
     self.addComputePerDof("v", "(x-oldx)/dt")
Beispiel #2
0
    def __init__(self, dt, group, alphaGroup, EGroup):
        """Create a AMDForceGroupIntegrator.

        Parameters
        ----------
        dt : time
            The integration time step to use
        group : int
            The force group to apply the boost to
        alphaGroup : energy
            The alpha parameter to use for the boosted force group
        EGroup : energy
            The energy cutoff to use for the boosted force group
        """
        CustomIntegrator.__init__(self, dt)
        self.addGlobalVariable("alphaGroup", alphaGroup)
        self.addGlobalVariable("EGroup", EGroup)
        self.addGlobalVariable("groupEnergy", 0)
        self.addPerDofVariable("oldx", 0)
        self.addPerDofVariable("fg", 0)
        self.addUpdateContextState();
        self.addComputeGlobal("groupEnergy", "energy"+str(group))
        self.addComputePerDof("fg", "f"+str(group))
        self.addComputePerDof("v", "v+dt*fprime/m; fprime=fother + fg*((1-modify) + modify*(alphaGroup/(alphaGroup+EGroup-groupEnergy))^2); fother=f-fg; modify=step(EGroup-groupEnergy)")
        self.addComputePerDof("oldx", "x")
        self.addComputePerDof("x", "x+dt*v")
        self.addConstrainPositions()
        self.addComputePerDof("v", "(x-oldx)/dt")
Beispiel #3
0
    def __init__(self, dt, group, alphaTotal, ETotal, alphaGroup, EGroup):
        """Create a DualAMDIntegrator.

        Parameters:
         - dt (time) The integration time step to use
         - group (int) The force group to apply the second boost to
         - alphaTotal (energy) The alpha parameter to use for the total energy
         - ETotal (energy) The energy cutoff to use for the total energy
         - alphaGroup (energy) The alpha parameter to use for the boosted force group
         - EGroup (energy) The energy cutoff to use for the boosted force group
        """
        CustomIntegrator.__init__(self, dt)
        self.addGlobalVariable("alphaTotal", alphaTotal)
        self.addGlobalVariable("ETotal", ETotal)
        self.addGlobalVariable("alphaGroup", alphaGroup)
        self.addGlobalVariable("EGroup", EGroup)
        self.addGlobalVariable("groupEnergy", 0)
        self.addPerDofVariable("oldx", 0)
        self.addPerDofVariable("fg", 0)
        self.addUpdateContextState()
        self.addComputeGlobal("groupEnergy", "energy" + str(group))
        self.addComputePerDof("fg", "f" + str(group))
        self.addComputePerDof(
            "v", """v+dt*fprime/m;
                                      fprime=fprime1 + fprime2;
                                      fprime2=fg*((1-modifyGroup) + modifyGroup*(alphaGroup/(alphaGroup+EGroup-groupEnergy))^2);
                                      fprime1=fother*((1-modifyTotal) + modifyTotal*(alphaTotal/(alphaTotal+ETotal-energy))^2);
                                      fother=f-fg;
                                      modifyTotal=step(ETotal-energy); modifyGroup=step(EGroup-groupEnergy)"""
        )
        self.addComputePerDof("oldx", "x")
        self.addComputePerDof("x", "x+dt*v")
        self.addConstrainPositions()
        self.addComputePerDof("v", "(x-oldx)/dt")
Beispiel #4
0
    def __init__(self, dt, group, alphaTotal, ETotal, alphaGroup, EGroup):
        """Create a DualAMDIntegrator.

        Parameters:
         - dt (time) The integration time step to use
         - group (int) The force group to apply the second boost to
         - alphaTotal (energy) The alpha parameter to use for the total energy
         - ETotal (energy) The energy cutoff to use for the total energy
         - alphaGroup (energy) The alpha parameter to use for the boosted force group
         - EGroup (energy) The energy cutoff to use for the boosted force group
        """
        CustomIntegrator.__init__(self, dt)
        self.addGlobalVariable("alphaTotal", alphaTotal)
        self.addGlobalVariable("ETotal", ETotal)
        self.addGlobalVariable("alphaGroup", alphaGroup)
        self.addGlobalVariable("EGroup", EGroup)
        self.addGlobalVariable("groupEnergy", 0)
        self.addPerDofVariable("oldx", 0)
        self.addPerDofVariable("fg", 0)
        self.addUpdateContextState();
        self.addComputeGlobal("groupEnergy", "energy"+str(group))
        self.addComputePerDof("fg", "f"+str(group))
        self.addComputePerDof("v", """v+dt*fprime/m;
                                      fprime=fprime1 + fprime2;
                                      fprime2=fg*((1-modifyGroup) + modifyGroup*(alphaGroup/(alphaGroup+EGroup-groupEnergy))^2);
                                      fprime1=fother*((1-modifyTotal) + modifyTotal*(alphaTotal/(alphaTotal+ETotal-energy))^2);
                                      fother=f-fg;
                                      modifyTotal=step(ETotal-energy); modifyGroup=step(EGroup-groupEnergy)""")
        self.addComputePerDof("oldx", "x")
        self.addComputePerDof("x", "x+dt*v")
        self.addConstrainPositions()
        self.addComputePerDof("v", "(x-oldx)/dt")
    def __init__(self, temperature, friction, dt, groups):
        """Create an MTSLangevinIntegrator.

        Parameters
        ----------
        temperature : temperature
            the temperature of the heat bath
        friction : 1/temperature
            the friction coefficient which couples the system to the heat bath
        dt : time
            The largest (outermost) integration time step to use
        groups : list
            A list of tuples defining the force groups.  The first element of
            each tuple is the force group index, and the second element is the
            number of times that force group should be evaluated in one time step.
        """
        if len(groups) == 0:
            raise ValueError("No force groups specified")
        groups = sorted(groups, key=lambda x: x[1])
        CustomIntegrator.__init__(self, dt)
        self.temperature = temperature
        self.friction = friction
        import math
        self.addGlobalVariable("a", math.exp(-friction*dt))
        self.addGlobalVariable("b", math.sqrt(1-math.exp(-2*friction*dt)))
        from simtk.unit import MOLAR_GAS_CONSTANT_R
        self.addGlobalVariable('kT', MOLAR_GAS_CONSTANT_R*temperature)
        self.addPerDofVariable("x1", 0)
        self.addUpdateContextState();
        self._createSubsteps(1, groups)
        self.addConstrainVelocities();
Beispiel #6
0
    def __init__(self, dt, alpha, E):
        """Create an AMDIntegrator.

        Parameters
        ----------
        dt : time
            The integration time step to use
        alpha : energy
            The alpha parameter to use
        E : energy
            The energy cutoff to use
        """
        CustomIntegrator.__init__(self, dt)
        self.addGlobalVariable("alpha", alpha)
        self.addGlobalVariable("E", E)
        self.addPerDofVariable("oldx", 0)
        self.addUpdateContextState()
        self.addComputePerDof(
            "v",
            "v+dt*fprime/m; fprime=f*((1-modify) + modify*(alpha/(alpha+E-energy))^2); modify=step(E-energy)"
        )
        self.addComputePerDof("oldx", "x")
        self.addComputePerDof("x", "x+dt*v")
        self.addConstrainPositions()
        self.addComputePerDof("v", "(x-oldx)/dt")
Beispiel #7
0
    def __init__(self, temperature, friction, dt, group, scaleFactor):
        CustomIntegrator.__init__(self, dt)
        #added:
        self.addGlobalVariable("scaleFactor", scaleFactor)
            #normal langevin:
        self.addGlobalVariable("temperature", temperature);
        self.addGlobalVariable("friction", friction);
        self.addGlobalVariable("vscale", 0);
        self.addGlobalVariable("fscale", 0);
        self.addGlobalVariable("noisescale", 0);
        self.addPerDofVariable("x0", 0);
        #added:
        self.addPerDofVariable("fg", 0)
            #normal langevin:
        self.addUpdateContextState();
        self.addComputeGlobal("vscale", "exp(-dt*friction)");
        self.addComputeGlobal("fscale", "(1-vscale)/friction");
        self.addComputeGlobal("noisescale", "sqrt(kT*(1-vscale*vscale)); kT=0.00831451*temperature");
        self.addComputePerDof("x0", "x");

        #added:
        self.addComputePerDof("fg", "f"+str(group))
            #original:
            #self.addComputePerDof("v", "vscale*v + fscale*f/m + noisescale*gaussian/sqrt(m)");
        #new (same as AMDForceGroupIntegrator code but with a globalvariable scaling factor)
        self.addComputePerDof("v", "vscale*v + fscale*fprime/m + noisescale*gaussian/sqrt(m); fprime=fother+fg*scaleFactor; fother=f-fg");
            #normal langevin
        self.addComputePerDof("x", "x+dt*v");
        self.addConstrainPositions();
        self.addComputePerDof("v", "(x-x0)/dt");
Beispiel #8
0
 def __init__(self, dt, groups):
     """Create an MTSIntegrator.
     
     Parameters:
      - dt (time) The largest (outermost) integration time step to use
      - groups (list) A list of tuples defining the force groups.  The first element of each
        tuple is the force group index, and the second element is the number of times that force
        group should be evaluated in one time step.
     """
     if len(groups) == 0:
         raise ValueError("No force groups specified")
     groups = sorted(groups, key=lambda x: x[1])
     CustomIntegrator.__init__(self, dt)
     self.addPerDofVariable("x1", 0)
     self.addUpdateContextState()
     self._createSubsteps(1, groups)
     self.addConstrainVelocities()
Beispiel #9
0
 def __init__(self, dt, groups):
     """Create an MTSIntegrator.
     
     Parameters:
      - dt (time) The largest (outermost) integration time step to use
      - groups (list) A list of tuples defining the force groups.  The first element of each
        tuple is the force group index, and the second element is the number of times that force
        group should be evaluated in one time step.
     """
     if len(groups) == 0:
         raise ValueError("No force groups specified")
     groups = sorted(groups, key=lambda x: x[1])
     CustomIntegrator.__init__(self, dt)
     self.addPerDofVariable("x1", 0)
     self.addUpdateContextState();
     self._createSubsteps(1, groups)
     self.addConstrainVelocities();
Beispiel #10
0
 def __init__(self, dt, alpha, E):
     """Create an AMDIntegrator.
     
     Parameters:
      - dt (time) The integration time step to use
      - alpha (energy) The alpha parameter to use
      - E (energy) The energy cutoff to use
     """
     CustomIntegrator.__init__(self, dt)
     self.addGlobalVariable("alpha", alpha)
     self.addGlobalVariable("E", E)
     self.addPerDofVariable("oldx", 0)
     self.addUpdateContextState();
     self.addComputePerDof("v", "v+dt*fprime/m; fprime=f*((1-modify) + modify*(alpha/(alpha+E-energy))^2); modify=step(E-energy)")
     self.addComputePerDof("oldx", "x")
     self.addComputePerDof("x", "x+dt*v")
     self.addConstrainPositions()
     self.addComputePerDof("v", "(x-oldx)/dt")
Beispiel #11
0
def VelocityVerletIntegrator(timestep):
    # Velocity Verlet integrator with explicit velocities.
    integrator = CustomIntegrator(timestep)
    integrator.addPerDofVariable("x1", 0)
    integrator.addPerDofVariable("x2", 0)
    integrator.addUpdateContextState()
    integrator.addComputePerDof("v", "v+0.5*dt*f/m")
    integrator.addComputePerDof("x", "x+dt*v")
    integrator.addComputePerDof("x1", "x")
    integrator.addConstrainPositions()
    integrator.addComputePerDof("x2", "x")
    integrator.addComputePerDof("v", "v+0.5*dt*f/m+(x2-x1)/dt")
    integrator.addConstrainVelocities()
    return integrator
Beispiel #12
0
def VelocityVerletIntegrator(timestep):
    # Velocity Verlet integrator with explicit velocities.
    integrator = CustomIntegrator(timestep)
    integrator.addPerDofVariable("x1", 0)
    integrator.addPerDofVariable("x2", 0)
    integrator.addUpdateContextState()
    integrator.addComputePerDof("v", "v+0.5*dt*f/m")
    integrator.addComputePerDof("x", "x+dt*v")
    integrator.addComputePerDof("x1", "x")
    integrator.addConstrainPositions()
    integrator.addComputePerDof("x2", "x")
    integrator.addComputePerDof("v", "v+0.5*dt*f/m+(x2-x1)/dt")
    integrator.addConstrainVelocities()
    return integrator