コード例 #1
0
 def _runtime_initialize(self):
     """
     Automatically sets the selector order at the engine runtime.
     """
     diffs = np.array([(np.sum(self.engine.realCoordinates[g.indexes], axis=0)/len(g))-self.__center for g in self.engine.groups], dtype=FLOAT_TYPE)
     dists = np.array([np.sqrt(np.add.reduce(diff**2)) for diff in diffs])
     order = np.argsort(dists).astype(INT_TYPE)
     if self.__expand:
         order = [o for o in reversed(order)]
     # set order
     self.set_order(order)
     # set groups move generators
     if self.__adjustMoveGenerators:
         from fullrmc.Core.MoveGenerator import MoveGeneratorCollector
         from fullrmc.Generators.Rotations import RotationGenerator
         from fullrmc.Generators.Translations import TranslationTowardsCenterGenerator
         TG_amp  = self.__generatorsParams['TG']['amplitude']
         TG_ang  = self.__generatorsParams['TG']['angle']
         TG_dam  = self.__generatorsParams['TG']['damping']
         RG_ang  = self.__generatorsParams['RG']['amplitude']
         maxDist = FLOAT_TYPE(np.max(dists))
         TG_ampInterval = TG_amp-TG_amp*TG_dam
         for idx in range(len(self.engine.groups)):
             g = self.engine.groups[idx]
             damping = ((maxDist-dists[idx])/maxDist)*TG_ampInterval
             coll = [TranslationTowardsCenterGenerator(center={"fixed":self.__center}, amplitude=TG_amp-damping, angle=TG_ang, direction=not self.__expand)]
             if len(g) > 1:
                 coll.append(RotationGenerator(amplitude=RG_ang))
             mg = MoveGeneratorCollector(collection=coll, randomize=True)
             g.set_move_generator( mg )
コード例 #2
0
def run_molecules(ENGINE,
                  rang=5,
                  recur=100,
                  refine=False,
                  explore=True,
                  exportPdb=False,
                  xyzFrequency=500):
    ENGINE.set_groups_as_molecules()
    [
        g.set_move_generator(
            MoveGeneratorCollector(collection=[
                TranslationGenerator(amplitude=0.2),
                RotationGenerator(amplitude=2)
            ],
                                   randomize=True)) for g in ENGINE.groups
    ]
    # number of steps
    nsteps = 20 * len(ENGINE.groups)
    # set selector
    gs = RecursiveGroupSelector(RandomSelector(ENGINE),
                                recur=recur,
                                refine=refine,
                                explore=explore)
    ENGINE.set_group_selector(gs)
    for stepIdx in range(rang):
        LOGGER.info("Running 'molecules' mode step %i" % (stepIdx))
        ENGINE.run(numberOfSteps=nsteps,
                   saveFrequency=nsteps,
                   xyzFrequency=xyzFrequency,
                   xyzPath="moleculeTraj.xyz",
                   restartPdb=None)
コード例 #3
0
def move_towards():
    # set only one molecule group
    ENGINE.set_groups_as_molecules()
    secMolIdxs = ENGINE.groups[1].indexes
    ENGINE.set_groups(ENGINE.groups[0])
    # set move generator
    for g in ENGINE.groups:
        t = TranslationTowardsCenterGenerator(center={'indexes': secMolIdxs},
                                              amplitude=0.15,
                                              angle=90)
        r = RotationGenerator(amplitude=10)
        mg = MoveGeneratorCollector(collection=[t, r],
                                    randomize=True,
                                    weights=[(0, 1), (1, 5)])
        g.set_move_generator(mg)
    # set runtime parameters
    nsteps = 1000
    xyzFrequency = 1
    # run engine
    xyzPath = "trajectory.xyz"
    if os.path.isfile(xyzPath): os.remove(xyzPath)
    ENGINE.run(numberOfSteps=nsteps,
               saveFrequency=2 * nsteps,
               xyzFrequency=xyzFrequency,
               xyzPath=xyzPath,
               restartPdb=None)
コード例 #4
0
def shrink(ENGINE, newDim):
    ENGINE.set_groups_as_molecules()
    [
        g.set_move_generator(
            MoveGeneratorCollector(collection=[
                TranslationGenerator(amplitude=0.2),
                RotationGenerator(amplitude=5)
            ],
                                   randomize=True)) for g in ENGINE.groups
    ]
    # get groups order
    centers = [
        np.sum(ENGINE.realCoordinates[g.indexes], axis=0) / len(g)
        for g in ENGINE.groups
    ]
    distances = [np.sqrt(np.add.reduce(c**2)) for c in centers]
    order = np.argsort(distances)
    # change boundary conditions
    bcFrom = str([list(bc) for bc in ENGINE.boundaryConditions.get_vectors()])
    ENGINE.set_boundary_conditions(newDim)
    bcTo = str([list(bc) for bc in ENGINE.boundaryConditions.get_vectors()])
    LOGGER.info("boundary conditions changed from %s to %s" % (bcFrom, bcTo))
    # set selector
    recur = 200
    gs = RecursiveGroupSelector(DefinedOrderSelector(ENGINE, order=order),
                                recur=recur,
                                refine=True)
    ENGINE.set_group_selector(gs)
    # number of steps
    nsteps = recur * len(ENGINE.groups)
    for stepIdx in range(10):
        LOGGER.info("Running 'shrink' mode step %i" % (stepIdx))
        ENGINE.run(numberOfSteps=nsteps, saveFrequency=nsteps)
        fname = "shrink_" + str(newDim).replace(".", "p")
コード例 #5
0
ファイル: run.py プロジェクト: zizai/fullrmc
def random():
    # run engine random rotations
    xyzPath="random.xyz"
    print("Random rotation")
    if os.path.isfile(xyzPath): os.remove(xyzPath)
    [g.set_move_generator(RotationGenerator(amplitude=10)) for g in ENGINE.groups]
    ENGINE.run(numberOfSteps=nsteps, saveFrequency=2*nsteps, xyzFrequency=xyzFrequency, xyzPath=xyzPath, restartPdb=None)
コード例 #6
0
ファイル: run.py プロジェクト: zubair57-unsw/fullrmc
def explore(ENGINE, nsteps=1000, rang=3):
    # create group of single molecule
    ENGINE.set_groups_as_molecules()
    ENGINE.set_groups(ENGINE.groups[0])
    # set move generator
    [
        g.set_move_generator(
            MoveGeneratorCollector(collection=[
                TranslationGenerator(amplitude=0.5),
                RotationGenerator(amplitude=5)
            ],
                                   randomize=True)) for g in ENGINE.groups
    ]
    # set selector
    recur = nsteps
    gs = RecursiveGroupSelector(RandomSelector(ENGINE),
                                recur=recur,
                                refine=False,
                                explore=True)
    # run
    for step in range(rang):
        ENGINE.run(numberOfSteps=nsteps, saveFrequency=2 * nsteps)