Esempio n. 1
0
def agitate_both():
    print "Agitate both"
    # agitate all
    ENGINE.set_groups_as_molecules() 
    groups = [g for g in ENGINE.groups]
    for idx in range(0,ENGINE.pdb.numberOfAtoms,3):
        groups.append(np.array([idx, idx+1]))
        groups.append(np.array([idx, idx+2]))
    ENGINE.add_groups(groups)  
    # set move generator
    for g in ENGINE.groups:
        if len(g)==2:
            g.set_move_generator(DistanceAgitationGenerator(amplitude=0.1, agitate=(False,True)))
        elif len(g)==3:
            g.set_move_generator(AngleAgitationGenerator(amplitude=5))
        else:
            raise 
    # set ordered selector
    ENGINE.set_group_selector(DefinedOrderSelector(ENGINE, order=None) )
    # set ordered selector
    ENGINE.set_group_selector(DefinedOrderSelector(ENGINE, order=None) )
    # run engine
    xyzPath="both.xyz"
    if os.path.isfile(xyzPath): os.remove(xyzPath)
    nsteps = 250*len(ENGINE.groups)
    xyzFrequency = len(ENGINE.groups)
    # run engine
    ENGINE.run(numberOfSteps=nsteps, saveFrequency=2*nsteps, xyzFrequency=xyzFrequency, xyzPath=xyzPath, restartPdb=None)
Esempio n. 2
0
def along1(ENGINE, rang=5, recur=100, refine=False, explore=True):
    ENGINE.set_groups_as_molecules()
    [
        g.set_move_generator(
            TranslationAlongSymmetryAxisGenerator(axis=1, amplitude=0.1))
        for g in ENGINE.groups
    ]
    # set selector
    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)
    recur = 200
    gs = RecursiveGroupSelector(DefinedOrderSelector(ENGINE, order=order),
                                recur=recur,
                                refine=refine,
                                explore=explore)
    ENGINE.set_group_selector(gs)
    # number of steps
    nsteps = recur * len(ENGINE.groups)
    for stepIdx in range(rang):
        LOGGER.info("Running 'along1' mode step %i" % (stepIdx))
        ENGINE.run(numberOfSteps=nsteps, saveFrequency=nsteps)
Esempio n. 3
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")
Esempio n. 4
0
def agitate_bonds():
    print("Agitate bonds")
    # agitate bonds
    groups = []
    for idx in range(0, ENGINE.pdb.numberOfAtoms, 3):
        groups.append(np.array([idx, idx + 1]))
        groups.append(np.array([idx, idx + 2]))
    ENGINE.set_groups(groups)
    [
        g.set_move_generator(
            DistanceAgitationGenerator(amplitude=0.1, agitate=(False, True)))
        for g in ENGINE.groups
    ]
    # set ordered selector
    ENGINE.set_group_selector(DefinedOrderSelector(ENGINE, order=None))
    # run engine
    xyzPath = "bonds.xyz"
    if os.path.isfile(xyzPath): os.remove(xyzPath)
    nsteps = 250 * len(ENGINE.groups)
    xyzFrequency = len(ENGINE.groups)
    ENGINE.run(numberOfSteps=nsteps,
               saveFrequency=2 * nsteps,
               xyzFrequency=xyzFrequency,
               xyzPath=xyzPath,
               restartPdb=None)
Esempio n. 5
0
def agitate_angles():
    print "Agitate angles"
    # agitate angles
    ENGINE.set_groups_as_molecules() 
    [g.set_move_generator(AngleAgitationGenerator(amplitude=5)) for g in ENGINE.groups]
    # set ordered selector
    ENGINE.set_group_selector(DefinedOrderSelector(ENGINE, order=None) )
    # run engine
    xyzPath="angles.xyz"
    if os.path.isfile(xyzPath): os.remove(xyzPath)
    nsteps = 250*len(ENGINE.groups)
    xyzFrequency = len(ENGINE.groups)
    ENGINE.run(numberOfSteps=nsteps, saveFrequency=2*nsteps, xyzFrequency=xyzFrequency, xyzPath=xyzPath, restartPdb=None)