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)
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)
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")
def angles_HCH(ENGINE, rang=5, recur=10, refine=False, explore=True): groups = [] for idx in range(0, ENGINE.pdb.numberOfAtoms, 13): groups.append(np.array([idx + 1, idx + 2, idx + 3], dtype=np.int32)) # H11-C1-H12 groups.append(np.array([idx + 4, idx + 5, idx + 6], dtype=np.int32)) # H21-C2-H22 groups.append(np.array([idx + 7, idx + 8, idx + 9], dtype=np.int32)) # H31-C3-H32 groups.append(np.array([idx + 10, idx + 11, idx + 12], dtype=np.int32)) # H41-C4-H42 ENGINE.set_groups(groups) [ g.set_move_generator(AngleAgitationGenerator(amplitude=5)) for g in ENGINE.groups ] # set selector if refine or explore: gs = RecursiveGroupSelector(RandomSelector(ENGINE), 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 'angles_HCH' mode step %i" % (stepIdx)) ENGINE.run(numberOfSteps=nsteps, saveFrequency=nsteps)
def expand_nanoparticule(recur=50, explore=True, refine=False, ncores=1): # create expansion selector and explore creating shell layer center = np.sum(ENGINE.realCoordinates, axis=0)/ENGINE.realCoordinates.shape[0] GS = DirectionalOrderSelector(ENGINE, center=center, expand=True, adjustMoveGenerators=True) RGS = RecursiveGroupSelector(GS, recur=recur, refine=refine, explore=explore) ENGINE.set_group_selector(RGS) nsteps = ENGINE.numberOfAtoms*recur # run rmc ENGINE.run(numberOfSteps=nsteps, saveFrequency=nsteps/10, ncores=ncores, restartPdb=None)
def refine(ENGINE, nsteps=1000, rang=5): # 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=2),RotationGenerator(amplitude=45)],randomize=True) ) for g in ENGINE.groups] # set selector recur = nsteps gs = RecursiveGroupSelector(RandomSelector(ENGINE), recur=recur, refine=True, explore=False) # run for step in range(rang): ENGINE.run(numberOfSteps=nsteps, saveFrequency=2*nsteps)
def atoms(ENGINE, rang=30, recur=20, refine=False, explore=True): ENGINE.set_groups_as_atoms() # set selector if refine or explore: gs = RecursiveGroupSelector(RandomSelector(ENGINE), 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 'atoms' mode step %i" % (stepIdx)) ENGINE.run(numberOfSteps=nsteps, saveFrequency=nsteps)
def run_recurring_atoms(ENGINE, rang=None, recur=None, explore=True, refine=False, xyzFrequency=500): ENGINE.set_groups(None) # set selector if recur is None: recur = 10 gs = RecursiveGroupSelector(RandomSelector(ENGINE), recur=recur, refine=refine, explore=explore) ENGINE.set_group_selector(gs) # number of steps nsteps = recur * len(ENGINE.groups) if rang is None: rang = 20 for stepIdx in range(rang): LOGGER.info("Running 'explore' mode step %i" % (stepIdx)) if explore: ENGINE.run(numberOfSteps=nsteps, saveFrequency=nsteps, xyzFrequency=xyzFrequency, xyzPath="exploreTraj.xyz", restartPdb=None) elif refine: ENGINE.run(numberOfSteps=nsteps, saveFrequency=nsteps, xyzFrequency=xyzFrequency, xyzPath="refineTraj.xyz", restartPdb=None) else: ENGINE.run(numberOfSteps=nsteps, saveFrequency=nsteps, xyzFrequency=xyzFrequency, xyzPath="recurTraj.xyz", restartPdb=None)
def atoms_type(ENGINE, type='C', rang=30, recur=20, refine=False, explore=True): allElements = ENGINE.allElements groups = [] for idx, el in enumerate(allElements): if el == type: groups.append([idx]) ENGINE.set_groups(groups) # set selector if refine or explore: gs = RecursiveGroupSelector(RandomSelector(ENGINE), 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 'atoms' mode step %i" % (stepIdx)) ENGINE.run(numberOfSteps=nsteps, saveFrequency=nsteps)
# set groups as all atoms ENGINE.set_groups_as_atoms() LOGGER.info("@%s Setting groups as atoms (%i)"%(fname, len(ENGINE.groups))) # run all frames as a mixture system of all subframes WM.run_dependant(nCycle=10000, firstNAccepted=1, numberOfSteps=100, subframesWeight=None, normalize=1, driftTolerance=1) WM.run_dependant(nCycle=10000, firstNAccepted=1, numberOfSteps=100, subframesWeight=10, normalize=1, driftTolerance=1) ################################################################################ ################## MOVE ALL ATOMS IN ALL FRAMES SYNCHRONOUSLY ################## RECUR = 200 for sf in ENGINE.frames[multiframe]['frames_name']: fname = os.path.join(multiframe, sf) ENGINE.set_used_frame(fname) # set groups as all atoms ENGINE.set_groups_as_atoms() # create recurring random selector to explore gs = RecursiveGroupSelector(RandomSelector(ENGINE), recur=RECUR, refine=False, explore=True) ENGINE.set_group_selector(gs) LOGGER.info("@%s Setting groups as atoms (%i)"%(fname, len(ENGINE.groups))) # run all frames as a mixture system of all subframes WM.run_dependant(nCycle=10000, firstNAccepted=1, numberOfSteps=RECUR, saveFrequency=10, cycleTimeout=900) ################################################################################ ################################ CALL plot.py ################################ os.system("%s %s"%(sys.executable, os.path.join(DIR_PATH, 'plot.py')))
def run_explore(recur=50, saveFreq=10000, ncores=1): gs = RecursiveGroupSelector(RandomSelector(ENGINE), recur=recur, refine=False, explore=True) ENGINE.set_group_selector(gs) # number of steps nsteps = recur*len(ENGINE.groups) ENGINE.run(numberOfSteps=nsteps, saveFrequency=nsteps, ncores=ncores, restartPdb=None)